mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Have std/png io_bind the workbuf
This commit is contained in:
1 parent
b81999f9fc
commit
67a05d1e25
2 files changed
+49
-5
No files matched your search
@@ -8093,6 +8093,7 @@ struct wuffs_png__decoder__struct {
|
|||||||
uint32_t f_width;
|
uint32_t f_width;
|
||||||
uint32_t f_height;
|
uint32_t f_height;
|
||||||
uint64_t f_bytes_per_row;
|
uint64_t f_bytes_per_row;
|
||||||
|
uint64_t f_workbuf_index;
|
||||||
uint64_t f_workbuf_length;
|
uint64_t f_workbuf_length;
|
||||||
uint8_t f_call_sequence;
|
uint8_t f_call_sequence;
|
||||||
uint8_t f_depth;
|
uint8_t f_depth;
|
||||||
@@ -30011,6 +30012,13 @@ wuffs_png__decoder__decode_frame(
|
|||||||
self->private_impl.active_coroutine = 0;
|
self->private_impl.active_coroutine = 0;
|
||||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||||
|
|
||||||
|
wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer();
|
||||||
|
wuffs_base__io_buffer* v_w = &u_w;
|
||||||
|
uint8_t* iop_v_w WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
|
uint8_t* io0_v_w WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
|
uint8_t* io1_v_w WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
|
uint8_t* io2_v_w WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
|
|
||||||
const uint8_t* iop_a_src = NULL;
|
const uint8_t* iop_a_src = NULL;
|
||||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = 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* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
@@ -30043,12 +30051,38 @@ wuffs_png__decoder__decode_frame(
|
|||||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
self->private_impl.f_workbuf_index = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
if ((self->private_impl.f_workbuf_index >= self->private_impl.f_workbuf_length) || (self->private_impl.f_workbuf_length >= ((uint64_t)(a_workbuf.len)))) {
|
||||||
|
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
const uint8_t *o_0_io2_a_src = io2_a_src;
|
wuffs_base__io_buffer* o_0_v_w = v_w;
|
||||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
uint8_t *o_0_iop_v_w = iop_v_w;
|
||||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
uint8_t *o_0_io0_v_w = io0_v_w;
|
||||||
io2_a_src = o_0_io2_a_src;
|
uint8_t *o_0_io1_v_w = io1_v_w;
|
||||||
|
uint8_t *o_0_io2_v_w = io2_v_w;
|
||||||
|
v_w = wuffs_base__io_writer__set(
|
||||||
|
&u_w,
|
||||||
|
&iop_v_w,
|
||||||
|
&io0_v_w,
|
||||||
|
&io1_v_w,
|
||||||
|
&io2_v_w,
|
||||||
|
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||||
|
self->private_impl.f_workbuf_index,
|
||||||
|
self->private_impl.f_workbuf_length));
|
||||||
|
{
|
||||||
|
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||||
|
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||||
|
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||||
|
io2_a_src = o_1_io2_a_src;
|
||||||
|
}
|
||||||
|
v_w = o_0_v_w;
|
||||||
|
iop_v_w = o_0_iop_v_w;
|
||||||
|
io0_v_w = o_0_io0_v_w;
|
||||||
|
io1_v_w = o_0_io1_v_w;
|
||||||
|
io2_v_w = o_0_io2_v_w;
|
||||||
}
|
}
|
||||||
goto label__0__break;
|
goto label__0__break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub struct decoder? implements base.image_decoder(
|
|||||||
// bytes_per_row doesn't include the 1 byte for the per-row filter.
|
// bytes_per_row doesn't include the 1 byte for the per-row filter.
|
||||||
bytes_per_row : base.u64[..= 0x07FF_FFF8],
|
bytes_per_row : base.u64[..= 0x07FF_FFF8],
|
||||||
|
|
||||||
|
workbuf_index : base.u64,
|
||||||
workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007],
|
workbuf_length : base.u64[..= 0x0007_FFFF_F100_0007],
|
||||||
|
|
||||||
// Call sequence states:
|
// Call sequence states:
|
||||||
@@ -223,6 +224,8 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||||
|
var w : base.io_writer
|
||||||
|
|
||||||
if this.call_sequence < 4 {
|
if this.call_sequence < 4 {
|
||||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||||
} else if this.call_sequence == 4 {
|
} else if this.call_sequence == 4 {
|
||||||
@@ -231,8 +234,15 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
|||||||
return base."@end of data"
|
return base."@end of data"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.workbuf_index = 0
|
||||||
while true {
|
while true {
|
||||||
io_limit (io: args.src, limit: this.chunk_length as base.u64) {
|
if (this.workbuf_index >= this.workbuf_length) or (
|
||||||
|
this.workbuf_length >= args.workbuf.length()) {
|
||||||
|
return base."#bad workbuf length"
|
||||||
|
}
|
||||||
|
io_bind (io: w, data: args.workbuf[this.workbuf_index .. this.workbuf_length]) {
|
||||||
|
io_limit (io: args.src, limit: this.chunk_length as base.u64) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
} endwhile
|
} endwhile
|
||||||
|
|||||||
Reference in new issue
Block a user