mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Fix std/png history_position for interlacing
This commit is contained in:
1 parent
90d3232eae
commit
f9c029c788
3 files changed
+31
-9
No files matched your search
@@ -9122,6 +9122,7 @@ struct wuffs_png__decoder__struct {
|
||||
uint32_t f_height;
|
||||
uint64_t f_pass_bytes_per_row;
|
||||
uint64_t f_workbuf_wi;
|
||||
uint64_t f_workbuf_hist_pos_base;
|
||||
uint64_t f_overall_workbuf_length;
|
||||
uint64_t f_pass_workbuf_length;
|
||||
uint8_t f_call_sequence;
|
||||
@@ -37715,6 +37716,7 @@ wuffs_png__decoder__decode_frame(
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_workbuf_hist_pos_base = 0;
|
||||
while (true) {
|
||||
v_pass_width = (16777215 & ((((uint32_t)(WUFFS_PNG__INTERLACING[self->private_impl.f_interlace_pass][1])) + self->private_impl.f_width) >> WUFFS_PNG__INTERLACING[self->private_impl.f_interlace_pass][0]));
|
||||
v_pass_height = (16777215 & ((((uint32_t)(WUFFS_PNG__INTERLACING[self->private_impl.f_interlace_pass][4])) + self->private_impl.f_height) >> WUFFS_PNG__INTERLACING[self->private_impl.f_interlace_pass][3]));
|
||||
@@ -37737,6 +37739,7 @@ wuffs_png__decoder__decode_frame(
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_workbuf_hist_pos_base += self->private_impl.f_pass_workbuf_length;
|
||||
}
|
||||
if ((self->private_impl.f_interlace_pass == 0) || (self->private_impl.f_interlace_pass >= 7)) {
|
||||
goto label__0__break;
|
||||
@@ -37832,7 +37835,7 @@ wuffs_png__decoder__decode_pass(
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_workbuf_wi,
|
||||
self->private_impl.f_pass_workbuf_length),
|
||||
self->private_impl.f_workbuf_wi);
|
||||
((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi)));
|
||||
{
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
|
||||
@@ -37,6 +37,7 @@ pub struct decoder? implements base.image_decoder(
|
||||
pass_bytes_per_row : base.u64[..= 0x07FF_FFF8],
|
||||
|
||||
workbuf_wi : base.u64,
|
||||
workbuf_hist_pos_base : base.u64,
|
||||
overall_workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007],
|
||||
pass_workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007],
|
||||
|
||||
@@ -533,6 +534,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
return status
|
||||
}
|
||||
|
||||
this.workbuf_hist_pos_base = 0
|
||||
while true {
|
||||
pass_width = 0x00FF_FFFF &
|
||||
(((INTERLACING[this.interlace_pass][1] as base.u32) + this.width) >>
|
||||
@@ -549,6 +551,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
this.workbuf_hist_pos_base ~mod+= this.pass_workbuf_length
|
||||
}
|
||||
|
||||
if (this.interlace_pass == 0) or (this.interlace_pass >= 7) {
|
||||
@@ -574,7 +577,7 @@ pri func decoder.decode_pass?(src: base.io_reader, workbuf: slice base.u8) {
|
||||
this.pass_workbuf_length > args.workbuf.length()) {
|
||||
return base."#bad workbuf length"
|
||||
}
|
||||
io_bind (io: w, data: args.workbuf[this.workbuf_wi .. this.pass_workbuf_length], history_position: this.workbuf_wi) {
|
||||
io_bind (io: w, data: args.workbuf[this.workbuf_wi .. this.pass_workbuf_length], history_position: this.workbuf_hist_pos_base ~mod+ this.workbuf_wi) {
|
||||
io_limit (io: args.src, limit: this.chunk_length) {
|
||||
w_mark = w.mark()
|
||||
r_mark = args.src.mark()
|
||||
|
||||
+23
-7
@@ -182,13 +182,29 @@ const char* //
|
||||
test_wuffs_png_decode_interface() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_png__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
return do_test__wuffs_base__image_decoder(
|
||||
wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/bricks-gray.png", 0, SIZE_MAX, 160, 120, 0xFF060606);
|
||||
|
||||
{
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
CHECK_STRING(do_test__wuffs_base__image_decoder(
|
||||
wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/bricks-gray.png", 0, SIZE_MAX, 160, 120, 0xFF060606));
|
||||
}
|
||||
|
||||
{
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
CHECK_STRING(do_test__wuffs_base__image_decoder(
|
||||
wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/hippopotamus.interlaced.png", 0, SIZE_MAX, 36, 28,
|
||||
0xFFF5F5F5));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
|
||||
Reference in new issue
Block a user