From 9399c8240918493ee1baac24f1259db7ea5b7ede Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 19 Dec 2020 22:03:22 +1100 Subject: [PATCH] Have non-animated image decoders give EOD earlier --- release/c/wuffs-unsupported-snapshot.c | 330 +------------------------ std/bmp/decode_bmp.wuffs | 112 +-------- std/wbmp/decode_wbmp.wuffs | 14 +- test/c/std/bmp.c | 4 - test/c/std/wbmp.c | 4 - 5 files changed, 7 insertions(+), 457 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index d82edabe..a870bb96 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -5621,7 +5621,6 @@ struct wuffs_bmp__decoder__struct { uint8_t f_call_sequence; bool f_top_down; uint32_t f_pad_per_row; - uint64_t f_bytes_per_row; uint32_t f_src_pixfmt; uint32_t f_io_redirect_fourcc; uint64_t f_io_redirect_pos; @@ -5646,7 +5645,6 @@ struct wuffs_bmp__decoder__struct { uint32_t p_decode_image_config[1]; uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame[1]; - uint32_t p_skip_frame[1]; uint32_t p_read_palette[1]; } private_impl; @@ -5661,10 +5659,6 @@ struct wuffs_bmp__decoder__struct { wuffs_base__status v_status; uint64_t scratch; } s_decode_frame[1]; - struct { - uint32_t v_rle_state; - uint64_t scratch; - } s_skip_frame[1]; struct { uint32_t v_i; uint64_t scratch; @@ -7788,7 +7782,6 @@ struct wuffs_wbmp__decoder__struct { uint32_t p_decode_image_config[1]; uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame[1]; - uint32_t p_skip_frame[1]; } private_impl; struct { @@ -7803,9 +7796,6 @@ struct wuffs_wbmp__decoder__struct { uint8_t v_src[1]; uint8_t v_c; } s_decode_frame[1]; - struct { - uint64_t scratch; - } s_skip_frame[1]; } private_data; #ifdef __cplusplus @@ -15869,11 +15859,6 @@ wuffs_bmp__decoder__swizzle_low_bit_depth( wuffs_base__pixel_buffer* a_dst, wuffs_base__io_buffer* a_src); -static wuffs_base__status -wuffs_bmp__decoder__skip_frame( - wuffs_bmp__decoder* self, - wuffs_base__io_buffer* a_src); - static wuffs_base__status wuffs_bmp__decoder__read_palette( wuffs_bmp__decoder* self, @@ -16866,27 +16851,20 @@ wuffs_bmp__decoder__decode_image_config( } if (self->private_impl.f_bits_per_pixel == 1) { v_byte_width = ((self->private_impl.f_width >> 3) + (((self->private_impl.f_width & 7) + 7) >> 3)); - self->private_impl.f_bytes_per_row = ((((((uint64_t)(v_byte_width)) * 1) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = ((4 - (v_byte_width & 3)) & 3); } else if (self->private_impl.f_bits_per_pixel == 2) { v_byte_width = ((self->private_impl.f_width >> 2) + (((self->private_impl.f_width & 3) + 3) >> 2)); - self->private_impl.f_bytes_per_row = ((((((uint64_t)(v_byte_width)) * 1) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = ((4 - (v_byte_width & 3)) & 3); } else if (self->private_impl.f_bits_per_pixel == 4) { v_byte_width = ((self->private_impl.f_width >> 1) + (self->private_impl.f_width & 1)); - self->private_impl.f_bytes_per_row = ((((((uint64_t)(v_byte_width)) * 1) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = ((4 - (v_byte_width & 3)) & 3); } else if (self->private_impl.f_bits_per_pixel == 8) { - self->private_impl.f_bytes_per_row = ((((((uint64_t)(self->private_impl.f_width)) * 1) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = ((4 - (self->private_impl.f_width & 3)) & 3); } else if (self->private_impl.f_bits_per_pixel == 16) { - self->private_impl.f_bytes_per_row = ((((((uint64_t)(self->private_impl.f_width)) * 2) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = ((self->private_impl.f_width & 1) * 2); } else if (self->private_impl.f_bits_per_pixel == 24) { - self->private_impl.f_bytes_per_row = ((((((uint64_t)(self->private_impl.f_width)) * 3) + 3) >> 2) << 2); self->private_impl.f_pad_per_row = (self->private_impl.f_width & 3); } else if (self->private_impl.f_bits_per_pixel == 32) { - self->private_impl.f_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * 4); self->private_impl.f_pad_per_row = 0; } self->private_impl.f_frame_config_io_position = wuffs_base__u64__sat_add(a_src->meta.pos, ((uint64_t)(iop_a_src - io0_a_src))); @@ -16993,17 +16971,7 @@ wuffs_bmp__decoder__decode_frame_config( goto exit; } } else if (self->private_impl.f_call_sequence == 2) { - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); - status = wuffs_bmp__decoder__skip_frame(self, a_src); - if (a_src) { - iop_a_src = a_src->data.ptr + a_src->meta.ri; - } - if (status.repr) { - goto suspend; - } + self->private_impl.f_call_sequence = 3; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -17914,227 +17882,6 @@ wuffs_bmp__decoder__swizzle_low_bit_depth( return status; } -// -------- func bmp.decoder.skip_frame - -static wuffs_base__status -wuffs_bmp__decoder__skip_frame( - wuffs_bmp__decoder* self, - wuffs_base__io_buffer* a_src) { - wuffs_base__status status = wuffs_base__make_status(NULL); - - uint8_t v_code = 0; - uint32_t v_rle_state = 0; - - const uint8_t* iop_a_src = NULL; - const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - if (a_src) { - io0_a_src = a_src->data.ptr; - io1_a_src = io0_a_src + a_src->meta.ri; - iop_a_src = io1_a_src; - io2_a_src = io0_a_src + a_src->meta.wi; - } - - uint32_t coro_susp_point = self->private_impl.p_skip_frame[0]; - if (coro_susp_point) { - v_rle_state = self->private_data.s_skip_frame[0].v_rle_state; - } - switch (coro_susp_point) { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - - self->private_data.s_skip_frame[0].scratch = self->private_impl.f_padding; - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); - if (self->private_data.s_skip_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { - self->private_data.s_skip_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); - iop_a_src = io2_a_src; - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - iop_a_src += self->private_data.s_skip_frame[0].scratch; - if ((self->private_impl.f_compression != 1) && (self->private_impl.f_compression != 2)) { - self->private_data.s_skip_frame[0].scratch = (self->private_impl.f_bytes_per_row * ((uint64_t)(self->private_impl.f_height))); - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); - if (self->private_data.s_skip_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { - self->private_data.s_skip_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); - iop_a_src = io2_a_src; - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - iop_a_src += self->private_data.s_skip_frame[0].scratch; - } else { - label__loop__continue:; - while (true) { - if (v_rle_state == 0) { - { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); - if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - uint8_t t_0 = *iop_a_src++; - v_code = t_0; - } - if (v_code == 0) { - v_rle_state = 2; - goto label__loop__continue; - } - self->private_impl.f_rle_length = ((uint32_t)(v_code)); - v_rle_state = 1; - goto label__loop__continue; - } else if (v_rle_state == 1) { - { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); - if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - uint8_t t_1 = *iop_a_src++; - v_code = t_1; - } - wuffs_base__u32__sat_add_indirect(&self->private_impl.f_dst_x, self->private_impl.f_rle_length); - v_rle_state = 0; - goto label__loop__continue; - } else if (v_rle_state == 2) { - { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); - if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - uint8_t t_2 = *iop_a_src++; - v_code = t_2; - } - if (v_code < 2) { - if ((self->private_impl.f_dst_y >= self->private_impl.f_height) && (v_code == 0)) { - status = wuffs_base__make_status(wuffs_bmp__error__bad_rle_compression); - goto exit; - } - self->private_impl.f_dst_x = 0; - self->private_impl.f_dst_y += self->private_impl.f_dst_y_inc; - if (v_code > 0) { - goto label__loop__break; - } - v_rle_state = 0; - goto label__loop__continue; - } else if (v_code == 2) { - v_rle_state = 4; - goto label__loop__continue; - } - self->private_impl.f_rle_length = ((uint32_t)(v_code)); - v_rle_state = 3; - goto label__loop__continue; - } else if (v_rle_state == 3) { - if (self->private_impl.f_bits_per_pixel == 8) { - self->private_data.s_skip_frame[0].scratch = (((self->private_impl.f_rle_length + 1) / 2) * 2); - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); - if (self->private_data.s_skip_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { - self->private_data.s_skip_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); - iop_a_src = io2_a_src; - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - iop_a_src += self->private_data.s_skip_frame[0].scratch; - } else { - self->private_data.s_skip_frame[0].scratch = (((self->private_impl.f_rle_length + 3) / 4) * 2); - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); - if (self->private_data.s_skip_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { - self->private_data.s_skip_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); - iop_a_src = io2_a_src; - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - iop_a_src += self->private_data.s_skip_frame[0].scratch; - } - wuffs_base__u32__sat_add_indirect(&self->private_impl.f_dst_x, self->private_impl.f_rle_length); - self->private_impl.f_rle_length = 0; - v_rle_state = 0; - goto label__loop__continue; - } else if (v_rle_state == 4) { - { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); - if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - uint8_t t_3 = *iop_a_src++; - self->private_impl.f_rle_delta_x = t_3; - } - v_rle_state = 5; - goto label__loop__continue; - } - { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); - if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - uint8_t t_4 = *iop_a_src++; - v_code = t_4; - } - if (self->private_impl.f_rle_delta_x > 0) { - wuffs_base__u32__sat_add_indirect(&self->private_impl.f_dst_x, ((uint32_t)(self->private_impl.f_rle_delta_x))); - self->private_impl.f_rle_delta_x = 0; - if (self->private_impl.f_dst_x > self->private_impl.f_width) { - status = wuffs_base__make_status(wuffs_bmp__error__bad_rle_compression); - goto exit; - } - } - if (v_code > 0) { -#if defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - v_code -= 1; -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - while (true) { - self->private_impl.f_dst_y += self->private_impl.f_dst_y_inc; - if (self->private_impl.f_dst_y >= self->private_impl.f_height) { - status = wuffs_base__make_status(wuffs_bmp__error__bad_rle_compression); - goto exit; - } - if (v_code <= 0) { - goto label__0__break; - } -#if defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - v_code -= 1; -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - } - label__0__break:; - } - v_rle_state = 0; - } - label__loop__break:; - } - self->private_impl.f_call_sequence = 3; - - goto ok; - ok: - self->private_impl.p_skip_frame[0] = 0; - goto exit; - } - - goto suspend; - suspend: - self->private_impl.p_skip_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; - self->private_data.s_skip_frame[0].v_rle_state = v_rle_state; - - goto exit; - exit: - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - - return status; -} - // -------- func bmp.decoder.frame_dirty_rect WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32 @@ -27645,11 +27392,6 @@ const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header"; // ---------------- Private Function Prototypes -static wuffs_base__status -wuffs_wbmp__decoder__skip_frame( - wuffs_wbmp__decoder* self, - wuffs_base__io_buffer* a_src); - // ---------------- VTables const wuffs_base__image_decoder__func_ptrs @@ -27971,17 +27713,7 @@ wuffs_wbmp__decoder__decode_frame_config( goto exit; } } else if (self->private_impl.f_call_sequence == 2) { - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); - status = wuffs_wbmp__decoder__skip_frame(self, a_src); - if (a_src) { - iop_a_src = a_src->data.ptr + a_src->meta.ri; - } - if (status.repr) { - goto suspend; - } + self->private_impl.f_call_sequence = 3; status = wuffs_base__make_status(wuffs_base__note__end_of_data); goto ok; } else { @@ -28199,64 +27931,6 @@ wuffs_wbmp__decoder__decode_frame( return status; } -// -------- func wbmp.decoder.skip_frame - -static wuffs_base__status -wuffs_wbmp__decoder__skip_frame( - wuffs_wbmp__decoder* self, - wuffs_base__io_buffer* a_src) { - wuffs_base__status status = wuffs_base__make_status(NULL); - - uint64_t v_bytes_per_row = 0; - uint64_t v_total_bytes = 0; - - const uint8_t* iop_a_src = NULL; - const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; - if (a_src) { - io0_a_src = a_src->data.ptr; - io1_a_src = io0_a_src + a_src->meta.ri; - iop_a_src = io1_a_src; - io2_a_src = io0_a_src + a_src->meta.wi; - } - - uint32_t coro_susp_point = self->private_impl.p_skip_frame[0]; - switch (coro_susp_point) { - WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; - - v_bytes_per_row = ((((uint64_t)(self->private_impl.f_width)) + 7) / 8); - v_total_bytes = (v_bytes_per_row * ((uint64_t)(self->private_impl.f_height))); - self->private_data.s_skip_frame[0].scratch = v_total_bytes; - WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); - if (self->private_data.s_skip_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { - self->private_data.s_skip_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); - iop_a_src = io2_a_src; - status = wuffs_base__make_status(wuffs_base__suspension__short_read); - goto suspend; - } - iop_a_src += self->private_data.s_skip_frame[0].scratch; - self->private_impl.f_call_sequence = 3; - - goto ok; - ok: - self->private_impl.p_skip_frame[0] = 0; - goto exit; - } - - goto suspend; - suspend: - self->private_impl.p_skip_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; - - goto exit; - exit: - if (a_src) { - a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); - } - - return status; -} - // -------- func wbmp.decoder.frame_dirty_rect WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32 diff --git a/std/bmp/decode_bmp.wuffs b/std/bmp/decode_bmp.wuffs index f0a84673..96f91f0f 100644 --- a/std/bmp/decode_bmp.wuffs +++ b/std/bmp/decode_bmp.wuffs @@ -35,10 +35,9 @@ pub struct decoder? implements base.image_decoder( call_sequence : base.u8, - top_down : base.bool, - pad_per_row : base.u32[..= 3], - bytes_per_row : base.u64[..= 0x0000_0001_FFFF_FFFC], // 4 * 0x7FFF_FFFF - src_pixfmt : base.u32, + top_down : base.bool, + pad_per_row : base.u32[..= 3], + src_pixfmt : base.u32, io_redirect_fourcc : base.u32, io_redirect_pos : base.u64, @@ -326,29 +325,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_ if this.bits_per_pixel == 1 { // byte_width is this.width divided by 8, rounding up. byte_width = (this.width >> 3) + (((this.width & 7) + 7) >> 3) - this.bytes_per_row = ((((byte_width as base.u64) * 1) + 3) >> 2) << 2 this.pad_per_row = (4 - (byte_width & 3)) & 3 } else if this.bits_per_pixel == 2 { // byte_width is this.width divided by 4, rounding up. byte_width = (this.width >> 2) + (((this.width & 3) + 3) >> 2) - this.bytes_per_row = ((((byte_width as base.u64) * 1) + 3) >> 2) << 2 this.pad_per_row = (4 - (byte_width & 3)) & 3 } else if this.bits_per_pixel == 4 { // byte_width is this.width divided by 2, rounding up. byte_width = (this.width >> 1) + (this.width & 1) - this.bytes_per_row = ((((byte_width as base.u64) * 1) + 3) >> 2) << 2 this.pad_per_row = (4 - (byte_width & 3)) & 3 } else if this.bits_per_pixel == 8 { - this.bytes_per_row = ((((this.width as base.u64) * 1) + 3) >> 2) << 2 this.pad_per_row = (4 - (this.width & 3)) & 3 } else if this.bits_per_pixel == 16 { - this.bytes_per_row = ((((this.width as base.u64) * 2) + 3) >> 2) << 2 this.pad_per_row = (this.width & 1) * 2 } else if this.bits_per_pixel == 24 { - this.bytes_per_row = ((((this.width as base.u64) * 3) + 3) >> 2) << 2 this.pad_per_row = this.width & 3 } else if this.bits_per_pixel == 32 { - this.bytes_per_row = (this.width as base.u64) * 4 this.pad_per_row = 0 } @@ -383,7 +375,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ return base."#bad restart" } } else if this.call_sequence == 2 { - this.skip_frame?(src: args.src) + this.call_sequence = 3 return base."@end of data" } else { return base."@end of data" @@ -1086,102 +1078,6 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io return ok } -pri func decoder.skip_frame?(src: base.io_reader) { - var code : base.u8 - var rle_state : base.u32 - - args.src.skip_u32?(n: this.padding) - - if (this.compression <> COMPRESSION_RLE8) and - (this.compression <> COMPRESSION_RLE4) { - args.src.skip?(n: this.bytes_per_row * (this.height as base.u64)) - - } else { - while.loop true { - if rle_state == RLE_STATE_NEUTRAL { - code = args.src.read_u8?() - if code == 0 { - rle_state = RLE_STATE_ESCAPE - continue.loop - } - this.rle_length = code as base.u32 - rle_state = RLE_STATE_RUN - continue.loop - - } else if rle_state == RLE_STATE_RUN { - code = args.src.read_u8?() - this.dst_x ~sat+= this.rle_length - rle_state = RLE_STATE_NEUTRAL - continue.loop - - } else if rle_state == RLE_STATE_ESCAPE { - code = args.src.read_u8?() - if code < 2 { // 0=EOL, 1=EOF. - if (this.dst_y >= this.height) and (code == 0) { - return "#bad RLE compression" - } - this.dst_x = 0 - this.dst_y ~mod+= this.dst_y_inc - if code > 0 { - break.loop - } - rle_state = RLE_STATE_NEUTRAL - continue.loop - } else if code == 2 { // 2=DELTA. - rle_state = RLE_STATE_DELTA_X - continue.loop - } - this.rle_length = code as base.u32 - rle_state = RLE_STATE_LITERAL - continue.loop - - } else if rle_state == RLE_STATE_LITERAL { - if this.bits_per_pixel == 8 { - args.src.skip_u32?(n: ((this.rle_length + 1) / 2) * 2) - } else { - args.src.skip_u32?(n: ((this.rle_length + 3) / 4) * 2) - } - this.dst_x ~sat+= this.rle_length - this.rle_length = 0 - rle_state = RLE_STATE_NEUTRAL - continue.loop - - } else if rle_state == RLE_STATE_DELTA_X { - this.rle_delta_x = args.src.read_u8?() - rle_state = RLE_STATE_DELTA_Y - continue.loop - - } // else (rle_state == RLE_STATE_DELTA_Y). - code = args.src.read_u8?() - if this.rle_delta_x > 0 { - this.dst_x ~sat+= this.rle_delta_x as base.u32 - this.rle_delta_x = 0 - if this.dst_x > this.width { - return "#bad RLE compression" - } - } - - if code > 0 { - code -= 1 - while true { - this.dst_y ~mod+= this.dst_y_inc - if this.dst_y >= this.height { - return "#bad RLE compression" - } - if code <= 0 { - break - } - code -= 1 - } endwhile - } - - rle_state = RLE_STATE_NEUTRAL - } endwhile.loop - } - - this.call_sequence = 3 -} - pub func decoder.frame_dirty_rect() base.rect_ie_u32 { return this.util.make_rect_ie_u32( min_incl_x: 0, diff --git a/std/wbmp/decode_wbmp.wuffs b/std/wbmp/decode_wbmp.wuffs index 931461dd..caff6016 100644 --- a/std/wbmp/decode_wbmp.wuffs +++ b/std/wbmp/decode_wbmp.wuffs @@ -102,7 +102,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_ return base."#bad restart" } } else if this.call_sequence == 2 { - this.skip_frame?(src: args.src) + this.call_sequence = 3 return base."@end of data" } else { return base."@end of data" @@ -224,18 +224,6 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, this.call_sequence = 3 } -pri func decoder.skip_frame?(src: base.io_reader) { - var bytes_per_row : base.u64[..= 0x2000_0000] - var total_bytes : base.u64 - - bytes_per_row = ((this.width as base.u64) + 7) / 8 - total_bytes = bytes_per_row * (this.height as base.u64) - - args.src.skip?(n: total_bytes) - - this.call_sequence = 3 -} - pub func decoder.frame_dirty_rect() base.rect_ie_u32 { return this.util.make_rect_ie_u32( min_incl_x: 0, diff --git a/test/c/std/bmp.c b/test/c/std/bmp.c index 96975cf2..3eeb6526 100644 --- a/test/c/std/bmp.c +++ b/test/c/std/bmp.c @@ -122,10 +122,6 @@ test_wuffs_bmp_decode_frame_config() { RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr, wuffs_base__note__end_of_data); } - if (src.meta.ri != src.meta.wi) { - RETURN_FAIL("at end of data: ri (%zu) doesn't equal wi (%zu)", src.meta.ri, - src.meta.wi); - } return NULL; } diff --git a/test/c/std/wbmp.c b/test/c/std/wbmp.c index bef5ff01..3b58ae88 100644 --- a/test/c/std/wbmp.c +++ b/test/c/std/wbmp.c @@ -307,10 +307,6 @@ test_wuffs_wbmp_decode_frame_config() { RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr, wuffs_base__note__end_of_data); } - if (src.meta.ri != src.meta.wi) { - RETURN_FAIL("at end of data: ri (%zu) doesn't equal wi (%zu)", src.meta.ri, - src.meta.wi); - } return NULL; }