Have std/gif replicate interlaced rows

This commit is contained in:
Nigel Tao committed 2019-09-14 08:35:50 +10:00
1 parent 050bca9120
commit ca9015bd2d
4 files changed
+131

No files matched your search

+29
View File
@@ -118,6 +118,7 @@ pub const quirk_reject_empty_palette base.u32 = (0xF8586 << 10) | 6
// to that maximum value (and therefore outside the frame rect).
pri const interlace_start array[5] base.u32 = [0xFFFFFFFF, 1, 2, 4, 0]
pri const interlace_delta array[5] base.u8 = [1, 2, 4, 8, 8]
pri const interlace_count array[5] base.u8 = [0, 0, 1, 3, 7]
pub struct decoder?(
width base.u32,
@@ -1112,6 +1113,9 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
var tab table base.u8
var i base.u64
var j base.u64
var replicate_count base.u32
var replicate_dst slice base.u8
var replicate_src slice base.u8
// TODO: a Wuffs (not just C) name for the WUFFS_BASE__PIXEL_FORMAT__ETC
// magic pixfmt constants. Also, support more formats.
@@ -1162,6 +1166,31 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
if this.frame_rect_x1 <= this.dst_x {
this.dst_x = this.frame_rect_x0
if this.interlace == 0 {
this.dst_y ~sat+= 1
continue
}
// For the first frame of an interlaced, non-transparent GIF,
// replicate the early passes' rows. For example, when such an
// image is downloaded over a slow network, this produces a richer
// intermediate image while waiting for the complete image.
//
// Some other GIF implementations call this progressive display or
// a "Haeberli inspired" technique.
if (this.num_decoded_frames_value == 0) and
(not this.gc_has_transparent_index) and
(this.interlace > 1) {
replicate_count = interlace_count[this.interlace] as base.u32
replicate_src = tab.row(y:this.dst_y)
while replicate_count > 0 {
replicate_dst = tab.row(y:this.dst_y ~sat+ replicate_count)
replicate_dst.copy_from_slice!(s:replicate_src)
replicate_count -= 1
}
}
this.dst_y ~sat+= interlace_delta[this.interlace] as base.u32
while (this.interlace > 0) and (this.dst_y >= this.frame_rect_y1) {
this.interlace -= 1