diff --git a/release/c/wuffs-unsupported-snapshot.h b/release/c/wuffs-unsupported-snapshot.h index ce59de62..e0d0b6e6 100644 --- a/release/c/wuffs-unsupported-snapshot.h +++ b/release/c/wuffs-unsupported-snapshot.h @@ -9137,8 +9137,18 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self, ((uint32_t)(v_lw))); self->private_impl.f_previous_lzw_decode_ended_abruptly = true; while (true) { + if (((uint64_t)(io1_a_src - iop_a_src)) == 0) { + if (self->private_impl.f_uncompressed_ri != + self->private_impl.f_uncompressed_wi) { + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); + status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst); + if (status) { + goto suspend; + } + } + } { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); if (WUFFS_BASE__UNLIKELY(iop_a_src == io1_a_src)) { status = wuffs_base__suspension__short_read; goto suspend; @@ -9199,32 +9209,34 @@ wuffs_gif__decoder__decode_id_part1(wuffs_gif__decoder* self, io1_v_w = o_0_io1_v_w; a_src = o_0_a_src; } - if (wuffs_base__status__is_ok(v_z) || - (v_z == wuffs_base__suspension__short_write)) { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); - status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst); - if (status) { - goto suspend; - } - if (v_z == wuffs_base__suspension__short_write) { - goto label_1_continue; - } - self->private_impl.f_previous_lzw_decode_ended_abruptly = false; - goto label_1_break; - } if ((v_block_size == 0) && (v_z == wuffs_base__suspension__short_read)) { goto label_1_break; } + if (self->private_impl.f_uncompressed_ri != + self->private_impl.f_uncompressed_wi) { + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); + status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst); + if (status) { + goto suspend; + } + } + if (wuffs_base__status__is_ok(v_z)) { + self->private_impl.f_previous_lzw_decode_ended_abruptly = false; + goto label_1_break; + } + if (v_z == wuffs_base__suspension__short_write) { + goto label_1_continue; + } status = v_z; - WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7); + WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8); } label_1_break:; } label_0_break:; if (self->private_impl.f_uncompressed_ri != self->private_impl.f_uncompressed_wi) { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); + WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); status = wuffs_gif__decoder__copy_to_image_buffer(self, a_dst); if (status) { goto suspend; diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 8e667830..5f72a207 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -606,6 +606,11 @@ pri func decoder.decode_id_part1!??(dst ptr base.pixel_buffer, src base.io_reade this.previous_lzw_decode_ended_abruptly = true while true { + if args.src.available() == 0 { + if this.uncompressed_ri != this.uncompressed_wi { + this.copy_to_image_buffer!??(pb:args.dst) + } + } var block_size base.u64 = args.src.read_u8!??() as base.u64 if block_size == 0 { break @@ -629,18 +634,21 @@ pri func decoder.decode_id_part1!??(dst ptr base.pixel_buffer, src base.io_reade block_size ~sat-= args.src.since_mark().length() } - if z.is_ok() or (z == status "$short write") { - this.copy_to_image_buffer!??(pb:args.dst) + if (block_size == 0) and (z == status "$short read") { + break:inner + } - if z == status "$short write" { - continue:inner - } + if this.uncompressed_ri != this.uncompressed_wi { + this.copy_to_image_buffer!??(pb:args.dst) + } + + if z.is_ok() { // TODO: check that block_size is zero? this.previous_lzw_decode_ended_abruptly = false break:inner } - if (block_size == 0) and (z == status "$short read") { - break:inner + if z == status "$short write" { + continue:inner } yield z } diff --git a/test/c/std/gif.c b/test/c/std/gif.c index 7e6ee122..a543cd56 100644 --- a/test/c/std/gif.c +++ b/test/c/std/gif.c @@ -862,9 +862,7 @@ const char* test_wuffs_gif_frame_dirty_rect() { // 2, 6, 10, ..., 22, 26, 1, 3, 5, ..., 25, 27. As we progress, the dirty // rect's max_excl_y should be one more than the highest decoded row so far. // If we haven't decoded any rows yet, max_excl_y should be zero. - // - // TODO: this should be 0, 1, 9, 17, 25, 27, 28. - uint32_t wants[2] = {0, 28}; + uint32_t wants[7] = {0, 1, 9, 17, 25, 27, 28}; int i = 0; while (true) { @@ -1135,7 +1133,7 @@ const char* test_wuffs_gif_io_position_two_chunks() { return do_test_wuffs_gif_io_position(true); } - // ---------------- Mimic Tests +// ---------------- Mimic Tests #ifdef WUFFS_MIMIC @@ -1319,7 +1317,7 @@ const char* bench_wuffs_gif_decode_anim_screencap() { "test/data/gifplayer-muybridge.gif", 1); } - // ---------------- Mimic Benches +// ---------------- Mimic Benches #ifdef WUFFS_MIMIC