mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Note if GIF's previous LZW decode ended abruptly
This commit is contained in:
1 parent
76c6af4ff4
commit
614ac408ae
3 files changed
+18
No files matched your search
@@ -1123,6 +1123,7 @@ typedef struct {
|
||||
uint32_t f_width;
|
||||
uint32_t f_height;
|
||||
uint8_t f_call_sequence;
|
||||
bool f_previous_lzw_decode_ended_abruptly;
|
||||
uint8_t f_background_color_index;
|
||||
uint8_t f_block_type;
|
||||
bool f_peek_block_type;
|
||||
@@ -2863,6 +2864,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
v_i += 1;
|
||||
}
|
||||
}
|
||||
if (self->private_impl.f_previous_lzw_decode_ended_abruptly) {
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
if (WUFFS_BASE__UNLIKELY(b_rptr_src == b_rend_src)) {
|
||||
@@ -2877,6 +2880,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
}
|
||||
wuffs_gif__lzw_decoder__set_literal_width(&self->private_impl.f_lzw,
|
||||
((uint32_t)(v_lw)));
|
||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
||||
while (true) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
@@ -2889,6 +2893,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
if (v_block_size == 0) {
|
||||
goto label_0_break;
|
||||
}
|
||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
||||
while (true) {
|
||||
wuffs_base__io_reader__mark(&a_src, b_rptr_src);
|
||||
{
|
||||
@@ -2916,6 +2921,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
||||
a_src.private_impl.bounds[0] = o_0_bounds0_src;
|
||||
}
|
||||
if (v_z == 0) {
|
||||
self->private_impl.f_previous_lzw_decode_ended_abruptly = false;
|
||||
goto label_1_break;
|
||||
}
|
||||
wuffs_base__u64__sat_sub_indirect(
|
||||
|
||||
@@ -1123,6 +1123,7 @@ typedef struct {
|
||||
uint32_t f_width;
|
||||
uint32_t f_height;
|
||||
uint8_t f_call_sequence;
|
||||
bool f_previous_lzw_decode_ended_abruptly;
|
||||
uint8_t f_background_color_index;
|
||||
uint8_t f_block_type;
|
||||
bool f_peek_block_type;
|
||||
|
||||
@@ -28,6 +28,8 @@ pub struct decoder?(
|
||||
// - 1 -> 1: via decode_frame.
|
||||
call_sequence base.u8,
|
||||
|
||||
previous_lzw_decode_ended_abruptly base.bool,
|
||||
|
||||
background_color_index base.u8,
|
||||
|
||||
block_type base.u8,
|
||||
@@ -298,17 +300,24 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
||||
}
|
||||
}
|
||||
|
||||
if this.previous_lzw_decode_ended_abruptly {
|
||||
// TODO: reset this.lzw.
|
||||
}
|
||||
|
||||
var lw base.u8 = in.src.read_u8?()
|
||||
if (lw < 2) or (8 < lw) {
|
||||
return error "bad literal width"
|
||||
}
|
||||
this.lzw.set_literal_width!(lw:lw as base.u32)
|
||||
|
||||
this.previous_lzw_decode_ended_abruptly = true
|
||||
while true {
|
||||
var block_size base.u64 = in.src.read_u8?() as base.u64
|
||||
if block_size == 0 {
|
||||
break
|
||||
}
|
||||
this.previous_lzw_decode_ended_abruptly = true
|
||||
|
||||
while true {
|
||||
// TODO: should "mark" be "set_mark" or "set_mark_here"?
|
||||
in.src.mark()
|
||||
@@ -317,6 +326,8 @@ pri func decoder.decode_id?(dst base.io_writer, src base.io_reader)() {
|
||||
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
||||
}
|
||||
if z.is_ok() {
|
||||
// TODO: check that block_size (after the ~sat-) is zero?
|
||||
this.previous_lzw_decode_ended_abruptly = false
|
||||
break
|
||||
}
|
||||
block_size ~sat-= in.src.since_mark().length()
|
||||
|
||||
Reference in new issue
Block a user