mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +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_width;
|
||||||
uint32_t f_height;
|
uint32_t f_height;
|
||||||
uint8_t f_call_sequence;
|
uint8_t f_call_sequence;
|
||||||
|
bool f_previous_lzw_decode_ended_abruptly;
|
||||||
uint8_t f_background_color_index;
|
uint8_t f_background_color_index;
|
||||||
uint8_t f_block_type;
|
uint8_t f_block_type;
|
||||||
bool f_peek_block_type;
|
bool f_peek_block_type;
|
||||||
@@ -2863,6 +2864,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
|||||||
v_i += 1;
|
v_i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (self->private_impl.f_previous_lzw_decode_ended_abruptly) {
|
||||||
|
}
|
||||||
{
|
{
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||||
if (WUFFS_BASE__UNLIKELY(b_rptr_src == b_rend_src)) {
|
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,
|
wuffs_gif__lzw_decoder__set_literal_width(&self->private_impl.f_lzw,
|
||||||
((uint32_t)(v_lw)));
|
((uint32_t)(v_lw)));
|
||||||
|
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
{
|
{
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||||
@@ -2889,6 +2893,7 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
|
|||||||
if (v_block_size == 0) {
|
if (v_block_size == 0) {
|
||||||
goto label_0_break;
|
goto label_0_break;
|
||||||
}
|
}
|
||||||
|
self->private_impl.f_previous_lzw_decode_ended_abruptly = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__io_reader__mark(&a_src, b_rptr_src);
|
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;
|
a_src.private_impl.bounds[0] = o_0_bounds0_src;
|
||||||
}
|
}
|
||||||
if (v_z == 0) {
|
if (v_z == 0) {
|
||||||
|
self->private_impl.f_previous_lzw_decode_ended_abruptly = false;
|
||||||
goto label_1_break;
|
goto label_1_break;
|
||||||
}
|
}
|
||||||
wuffs_base__u64__sat_sub_indirect(
|
wuffs_base__u64__sat_sub_indirect(
|
||||||
|
|||||||
@@ -1123,6 +1123,7 @@ typedef struct {
|
|||||||
uint32_t f_width;
|
uint32_t f_width;
|
||||||
uint32_t f_height;
|
uint32_t f_height;
|
||||||
uint8_t f_call_sequence;
|
uint8_t f_call_sequence;
|
||||||
|
bool f_previous_lzw_decode_ended_abruptly;
|
||||||
uint8_t f_background_color_index;
|
uint8_t f_background_color_index;
|
||||||
uint8_t f_block_type;
|
uint8_t f_block_type;
|
||||||
bool f_peek_block_type;
|
bool f_peek_block_type;
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ pub struct decoder?(
|
|||||||
// - 1 -> 1: via decode_frame.
|
// - 1 -> 1: via decode_frame.
|
||||||
call_sequence base.u8,
|
call_sequence base.u8,
|
||||||
|
|
||||||
|
previous_lzw_decode_ended_abruptly base.bool,
|
||||||
|
|
||||||
background_color_index base.u8,
|
background_color_index base.u8,
|
||||||
|
|
||||||
block_type 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?()
|
var lw base.u8 = in.src.read_u8?()
|
||||||
if (lw < 2) or (8 < lw) {
|
if (lw < 2) or (8 < lw) {
|
||||||
return error "bad literal width"
|
return error "bad literal width"
|
||||||
}
|
}
|
||||||
this.lzw.set_literal_width!(lw:lw as base.u32)
|
this.lzw.set_literal_width!(lw:lw as base.u32)
|
||||||
|
|
||||||
|
this.previous_lzw_decode_ended_abruptly = true
|
||||||
while true {
|
while true {
|
||||||
var block_size base.u64 = in.src.read_u8?() as base.u64
|
var block_size base.u64 = in.src.read_u8?() as base.u64
|
||||||
if block_size == 0 {
|
if block_size == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
this.previous_lzw_decode_ended_abruptly = true
|
||||||
|
|
||||||
while true {
|
while true {
|
||||||
// TODO: should "mark" be "set_mark" or "set_mark_here"?
|
// TODO: should "mark" be "set_mark" or "set_mark_here"?
|
||||||
in.src.mark()
|
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)
|
var z base.status = try this.lzw.decode?(dst:in.dst, src:in.src)
|
||||||
}
|
}
|
||||||
if z.is_ok() {
|
if z.is_ok() {
|
||||||
|
// TODO: check that block_size (after the ~sat-) is zero?
|
||||||
|
this.previous_lzw_decode_ended_abruptly = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
block_size ~sat-= in.src.since_mark().length()
|
block_size ~sat-= in.src.since_mark().length()
|
||||||
|
|||||||
Reference in new issue
Block a user