mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Move some std/gif code inside its io_bind
This commit is contained in:
1 parent
2df6ea4b7a
commit
0f32650064
2 files changed
+12
-12
No files matched your search
+9
-9
@@ -2874,11 +2874,11 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
|||||||
}
|
}
|
||||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__io_reader__set_mark(&a_src, b_rptr_src);
|
|
||||||
{
|
{
|
||||||
uint8_t* o_0_bounds0_src = a_src.private_impl.bounds[0];
|
uint8_t* o_0_bounds0_src = a_src.private_impl.bounds[0];
|
||||||
uint8_t* o_0_bounds1_src = a_src.private_impl.bounds[1];
|
uint8_t* o_0_bounds1_src = a_src.private_impl.bounds[1];
|
||||||
wuffs_base__io_reader__set_limit(&a_src, b_rptr_src, v_block_size);
|
wuffs_base__io_reader__set_limit(&a_src, b_rptr_src, v_block_size);
|
||||||
|
wuffs_base__io_reader__set_mark(&a_src, b_rptr_src);
|
||||||
{
|
{
|
||||||
if (a_src.private_impl.buf) {
|
if (a_src.private_impl.buf) {
|
||||||
a_src.private_impl.buf->ri =
|
a_src.private_impl.buf->ri =
|
||||||
@@ -2892,6 +2892,14 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
|||||||
}
|
}
|
||||||
v_z = t_14;
|
v_z = t_14;
|
||||||
}
|
}
|
||||||
|
wuffs_base__u64__sat_sub_indirect(
|
||||||
|
&v_block_size,
|
||||||
|
((uint64_t)(((wuffs_base__slice_u8){
|
||||||
|
.ptr = a_src.private_impl.bounds[0],
|
||||||
|
.len = (size_t)(b_rptr_src -
|
||||||
|
a_src.private_impl.bounds[0]),
|
||||||
|
})
|
||||||
|
.len)));
|
||||||
a_src.private_impl.bounds[1] = o_0_bounds1_src;
|
a_src.private_impl.bounds[1] = o_0_bounds1_src;
|
||||||
a_src.private_impl.bounds[0] = o_0_bounds0_src;
|
a_src.private_impl.bounds[0] = o_0_bounds0_src;
|
||||||
}
|
}
|
||||||
@@ -2899,14 +2907,6 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
|||||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = false;
|
self->private_impl.f_previous_lzw_decode_ended_abruptly = false;
|
||||||
goto label_1_break;
|
goto label_1_break;
|
||||||
}
|
}
|
||||||
wuffs_base__u64__sat_sub_indirect(
|
|
||||||
&v_block_size,
|
|
||||||
((uint64_t)(
|
|
||||||
((wuffs_base__slice_u8){
|
|
||||||
.ptr = a_src.private_impl.bounds[0],
|
|
||||||
.len = (size_t)(b_rptr_src - a_src.private_impl.bounds[0]),
|
|
||||||
})
|
|
||||||
.len)));
|
|
||||||
if ((v_block_size == 0) && (v_z == WUFFS_GIF__SUSPENSION_SHORT_READ)) {
|
if ((v_block_size == 0) && (v_z == WUFFS_GIF__SUSPENSION_SHORT_READ)) {
|
||||||
goto label_1_break;
|
goto label_1_break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,6 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
|||||||
this.previous_lzw_decode_ended_abruptly = true
|
this.previous_lzw_decode_ended_abruptly = true
|
||||||
|
|
||||||
while true {
|
while true {
|
||||||
in.src.set_mark!()
|
|
||||||
io_bind (in.src) {
|
io_bind (in.src) {
|
||||||
// TODO: enforce that calling r.set_limit has a precondition
|
// TODO: enforce that calling r.set_limit has a precondition
|
||||||
// that r.is_bound(), and that you can't suspend inside an
|
// that r.is_bound(), and that you can't suspend inside an
|
||||||
@@ -347,14 +346,15 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
|||||||
//
|
//
|
||||||
// Should calling r.set_mark also require r.is_bound()?
|
// Should calling r.set_mark also require r.is_bound()?
|
||||||
in.src.set_limit!(l:block_size)
|
in.src.set_limit!(l:block_size)
|
||||||
|
in.src.set_mark!()
|
||||||
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
||||||
|
block_size ~sat-= in.src.since_mark().length()
|
||||||
}
|
}
|
||||||
if z.is_ok() {
|
if z.is_ok() {
|
||||||
// TODO: check that block_size (after the ~sat-) is zero?
|
// TODO: check that block_size is zero?
|
||||||
this.previous_lzw_decode_ended_abruptly = false
|
this.previous_lzw_decode_ended_abruptly = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
block_size ~sat-= in.src.since_mark().length()
|
|
||||||
if (block_size == 0) and (z == suspension "short read") {
|
if (block_size == 0) and (z == suspension "short read") {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user