mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Simplify std/gif decoding re warnings
This commit is contained in:
1 parent
28e4981d10
commit
a1a5b40178
2 files changed
+36
-149
No files matched your search
@@ -3433,15 +3433,9 @@ struct wuffs_gif__decoder__struct {
|
|||||||
uint8_t f_dst_palette[1024];
|
uint8_t f_dst_palette[1024];
|
||||||
wuffs_lzw__decoder f_lzw;
|
wuffs_lzw__decoder f_lzw;
|
||||||
|
|
||||||
struct {
|
|
||||||
wuffs_base__status v_status;
|
|
||||||
} s_decode_image_config[1];
|
|
||||||
struct {
|
struct {
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} s_skip_frame[1];
|
} s_skip_frame[1];
|
||||||
struct {
|
|
||||||
wuffs_base__status v_status;
|
|
||||||
} s_decode_up_to_id_part1[1];
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t v_c[6];
|
uint8_t v_c[6];
|
||||||
uint32_t v_i;
|
uint32_t v_i;
|
||||||
@@ -3452,9 +3446,6 @@ struct wuffs_gif__decoder__struct {
|
|||||||
uint32_t v_i;
|
uint32_t v_i;
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} s_decode_lsd[1];
|
} s_decode_lsd[1];
|
||||||
struct {
|
|
||||||
wuffs_base__status v_status;
|
|
||||||
} s_decode_extension[1];
|
|
||||||
struct {
|
struct {
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} s_skip_blocks[1];
|
} s_skip_blocks[1];
|
||||||
@@ -8687,11 +8678,9 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
|
|||||||
wuffs_base__status status = NULL;
|
wuffs_base__status status = NULL;
|
||||||
|
|
||||||
bool v_ffio = false;
|
bool v_ffio = false;
|
||||||
wuffs_base__status v_status = NULL;
|
|
||||||
|
|
||||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||||
if (coro_susp_point) {
|
if (coro_susp_point) {
|
||||||
v_status = self->private_data.s_decode_image_config[0].v_status;
|
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
@@ -8711,31 +8700,11 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
|
|||||||
status = wuffs_base__error__bad_call_sequence;
|
status = wuffs_base__error__bad_call_sequence;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
label_0_continue:;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
while (true) {
|
status = wuffs_gif__decoder__decode_up_to_id_part1(self, a_src);
|
||||||
{
|
if (status) {
|
||||||
wuffs_base__status t_0 =
|
goto suspend;
|
||||||
wuffs_gif__decoder__decode_up_to_id_part1(self, a_src);
|
|
||||||
v_status = t_0;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_suspension(v_status)) {
|
|
||||||
status = v_status;
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
|
||||||
goto label_0_continue;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_ok(v_status)) {
|
|
||||||
goto label_0_break;
|
|
||||||
}
|
|
||||||
status = v_status;
|
|
||||||
if (wuffs_base__status__is_error(status)) {
|
|
||||||
goto exit;
|
|
||||||
} else if (wuffs_base__status__is_suspension(status)) {
|
|
||||||
status = wuffs_base__error__cannot_return_a_suspension;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
goto ok;
|
|
||||||
}
|
}
|
||||||
label_0_break:;
|
|
||||||
v_ffio =
|
v_ffio =
|
||||||
(!self->private_impl.f_gc_has_transparent_index &&
|
(!self->private_impl.f_gc_has_transparent_index &&
|
||||||
(self->private_impl.f_frame_rect_x0 == 0) &&
|
(self->private_impl.f_frame_rect_x0 == 0) &&
|
||||||
@@ -8762,7 +8731,6 @@ suspend:
|
|||||||
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
||||||
self->private_impl.active_coroutine =
|
self->private_impl.active_coroutine =
|
||||||
wuffs_base__status__is_suspension(status) ? 1 : 0;
|
wuffs_base__status__is_suspension(status) ? 1 : 0;
|
||||||
self->private_data.s_decode_image_config[0].v_status = v_status;
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
@@ -9356,7 +9324,6 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
|||||||
wuffs_base__status status = NULL;
|
wuffs_base__status status = NULL;
|
||||||
|
|
||||||
uint8_t v_block_type = 0;
|
uint8_t v_block_type = 0;
|
||||||
wuffs_base__status v_status = NULL;
|
|
||||||
|
|
||||||
uint8_t* iop_a_src = NULL;
|
uint8_t* iop_a_src = NULL;
|
||||||
uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
@@ -9375,7 +9342,6 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
|||||||
|
|
||||||
uint32_t coro_susp_point = self->private_impl.p_decode_up_to_id_part1[0];
|
uint32_t coro_susp_point = self->private_impl.p_decode_up_to_id_part1[0];
|
||||||
if (coro_susp_point) {
|
if (coro_susp_point) {
|
||||||
v_status = self->private_data.s_decode_up_to_id_part1[0].v_status;
|
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
@@ -9413,39 +9379,19 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
|||||||
v_block_type = t_0;
|
v_block_type = t_0;
|
||||||
}
|
}
|
||||||
if (v_block_type == 33) {
|
if (v_block_type == 33) {
|
||||||
label_0_continue:;
|
if (a_src.private_impl.buf) {
|
||||||
while (true) {
|
a_src.private_impl.buf->meta.ri =
|
||||||
{
|
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||||
if (a_src.private_impl.buf) {
|
}
|
||||||
a_src.private_impl.buf->meta.ri =
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
status = wuffs_gif__decoder__decode_extension(self, a_src);
|
||||||
}
|
if (a_src.private_impl.buf) {
|
||||||
wuffs_base__status t_1 =
|
iop_a_src = a_src.private_impl.buf->data.ptr +
|
||||||
wuffs_gif__decoder__decode_extension(self, a_src);
|
a_src.private_impl.buf->meta.ri;
|
||||||
if (a_src.private_impl.buf) {
|
}
|
||||||
iop_a_src = a_src.private_impl.buf->data.ptr +
|
if (status) {
|
||||||
a_src.private_impl.buf->meta.ri;
|
goto suspend;
|
||||||
}
|
|
||||||
v_status = t_1;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_suspension(v_status)) {
|
|
||||||
status = v_status;
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
|
||||||
goto label_0_continue;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_ok(v_status)) {
|
|
||||||
goto label_0_break;
|
|
||||||
}
|
|
||||||
status = v_status;
|
|
||||||
if (wuffs_base__status__is_error(status)) {
|
|
||||||
goto exit;
|
|
||||||
} else if (wuffs_base__status__is_suspension(status)) {
|
|
||||||
status = wuffs_base__error__cannot_return_a_suspension;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
goto ok;
|
|
||||||
}
|
}
|
||||||
label_0_break:;
|
|
||||||
} else if (v_block_type == 44) {
|
} else if (v_block_type == 44) {
|
||||||
if (a_src.private_impl.buf) {
|
if (a_src.private_impl.buf) {
|
||||||
a_src.private_impl.buf->meta.ri =
|
a_src.private_impl.buf->meta.ri =
|
||||||
@@ -9460,16 +9406,16 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
|||||||
if (status) {
|
if (status) {
|
||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
goto label_1_break;
|
goto label_0_break;
|
||||||
} else if (v_block_type == 59) {
|
} else if (v_block_type == 59) {
|
||||||
self->private_impl.f_end_of_data = true;
|
self->private_impl.f_end_of_data = true;
|
||||||
goto label_1_break;
|
goto label_0_break;
|
||||||
} else {
|
} else {
|
||||||
status = wuffs_gif__error__bad_block;
|
status = wuffs_gif__error__bad_block;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
label_1_break:;
|
label_0_break:;
|
||||||
|
|
||||||
goto ok;
|
goto ok;
|
||||||
ok:
|
ok:
|
||||||
@@ -9481,7 +9427,6 @@ wuffs_gif__decoder__decode_up_to_id_part1(wuffs_gif__decoder* self,
|
|||||||
suspend:
|
suspend:
|
||||||
self->private_impl.p_decode_up_to_id_part1[0] =
|
self->private_impl.p_decode_up_to_id_part1[0] =
|
||||||
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
||||||
self->private_data.s_decode_up_to_id_part1[0].v_status = v_status;
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
@@ -9768,7 +9713,6 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
|||||||
wuffs_base__status status = NULL;
|
wuffs_base__status status = NULL;
|
||||||
|
|
||||||
uint8_t v_label = 0;
|
uint8_t v_label = 0;
|
||||||
wuffs_base__status v_status = NULL;
|
|
||||||
|
|
||||||
uint8_t* iop_a_src = NULL;
|
uint8_t* iop_a_src = NULL;
|
||||||
uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||||
@@ -9787,7 +9731,6 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
|||||||
|
|
||||||
uint32_t coro_susp_point = self->private_impl.p_decode_extension[0];
|
uint32_t coro_susp_point = self->private_impl.p_decode_extension[0];
|
||||||
if (coro_susp_point) {
|
if (coro_susp_point) {
|
||||||
v_status = self->private_data.s_decode_extension[0].v_status;
|
|
||||||
}
|
}
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
@@ -9818,38 +9761,19 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
|||||||
status = NULL;
|
status = NULL;
|
||||||
goto ok;
|
goto ok;
|
||||||
} else if (v_label == 255) {
|
} else if (v_label == 255) {
|
||||||
label_0_continue:;
|
if (a_src.private_impl.buf) {
|
||||||
while (true) {
|
a_src.private_impl.buf->meta.ri =
|
||||||
{
|
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
||||||
if (a_src.private_impl.buf) {
|
}
|
||||||
a_src.private_impl.buf->meta.ri =
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||||
((size_t)(iop_a_src - a_src.private_impl.buf->data.ptr));
|
status = wuffs_gif__decoder__decode_ae(self, a_src);
|
||||||
}
|
if (a_src.private_impl.buf) {
|
||||||
wuffs_base__status t_1 = wuffs_gif__decoder__decode_ae(self, a_src);
|
iop_a_src =
|
||||||
if (a_src.private_impl.buf) {
|
a_src.private_impl.buf->data.ptr + a_src.private_impl.buf->meta.ri;
|
||||||
iop_a_src = a_src.private_impl.buf->data.ptr +
|
}
|
||||||
a_src.private_impl.buf->meta.ri;
|
if (status) {
|
||||||
}
|
goto suspend;
|
||||||
v_status = t_1;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_suspension(v_status)) {
|
|
||||||
status = v_status;
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
|
||||||
goto label_0_continue;
|
|
||||||
}
|
|
||||||
if (wuffs_base__status__is_ok(v_status)) {
|
|
||||||
goto label_0_break;
|
|
||||||
}
|
|
||||||
status = v_status;
|
|
||||||
if (wuffs_base__status__is_error(status)) {
|
|
||||||
goto exit;
|
|
||||||
} else if (wuffs_base__status__is_suspension(status)) {
|
|
||||||
status = wuffs_base__error__cannot_return_a_suspension;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
goto ok;
|
|
||||||
}
|
}
|
||||||
label_0_break:;
|
|
||||||
status = NULL;
|
status = NULL;
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
@@ -9877,7 +9801,6 @@ wuffs_gif__decoder__decode_extension(wuffs_gif__decoder* self,
|
|||||||
suspend:
|
suspend:
|
||||||
self->private_impl.p_decode_extension[0] =
|
self->private_impl.p_decode_extension[0] =
|
||||||
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
wuffs_base__status__is_suspension(status) ? coro_susp_point : 0;
|
||||||
self->private_data.s_decode_extension[0].v_status = v_status;
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
|
|||||||
@@ -144,8 +144,7 @@ pub struct decoder?(
|
|||||||
)
|
)
|
||||||
|
|
||||||
pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_reader) {
|
pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_reader) {
|
||||||
var ffio base.bool
|
var ffio base.bool
|
||||||
var status base.status // TODO: this shouldn't be necessary.
|
|
||||||
|
|
||||||
if this.call_sequence == 0 {
|
if this.call_sequence == 0 {
|
||||||
this.decode_header?(src:args.src)
|
this.decode_header?(src:args.src)
|
||||||
@@ -154,18 +153,7 @@ pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_re
|
|||||||
return base."#bad call sequence"
|
return base."#bad call sequence"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this should be just "this.decode_up_to_id_part1?(src:args.src)".
|
this.decode_up_to_id_part1?(src:args.src)
|
||||||
while true {
|
|
||||||
status =? this.decode_up_to_id_part1?(src:args.src)
|
|
||||||
if status.is_suspension() {
|
|
||||||
yield? status
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if status.is_ok() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return status
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: if this.end_of_data, return an error and/or set dst to zero?
|
// TODO: if this.end_of_data, return an error and/or set dst to zero?
|
||||||
|
|
||||||
@@ -379,7 +367,6 @@ pri func decoder.reset_gc!() {
|
|||||||
|
|
||||||
pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
|
pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
|
||||||
var block_type base.u8
|
var block_type base.u8
|
||||||
var status base.status // TODO: this shouldn't be necessary.
|
|
||||||
|
|
||||||
if not this.restarted {
|
if not this.restarted {
|
||||||
if this.call_sequence <> 2 {
|
if this.call_sequence <> 2 {
|
||||||
@@ -394,18 +381,7 @@ pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
|
|||||||
while true {
|
while true {
|
||||||
block_type = args.src.read_u8?()
|
block_type = args.src.read_u8?()
|
||||||
if block_type == 0x21 { // The spec calls 0x21 the "Extension Introducer".
|
if block_type == 0x21 { // The spec calls 0x21 the "Extension Introducer".
|
||||||
// TODO: this should be just "this.decode_extension?(src:args.src)".
|
this.decode_extension?(src:args.src)
|
||||||
while true {
|
|
||||||
status =? this.decode_extension?(src:args.src)
|
|
||||||
if status.is_suspension() {
|
|
||||||
yield? status
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if status.is_ok() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return status
|
|
||||||
}
|
|
||||||
} else if block_type == 0x2C { // The spec calls 0x2C the "Image Separator".
|
} else if block_type == 0x2C { // The spec calls 0x2C the "Image Separator".
|
||||||
this.decode_id_part0?(src:args.src)
|
this.decode_id_part0?(src:args.src)
|
||||||
break
|
break
|
||||||
@@ -486,26 +462,14 @@ pri func decoder.decode_lsd?(src base.io_reader) {
|
|||||||
// - section 25 "Plain Text Extension" on page 18.
|
// - section 25 "Plain Text Extension" on page 18.
|
||||||
// - section 26 "Application Extension" on page 21.
|
// - section 26 "Application Extension" on page 21.
|
||||||
pri func decoder.decode_extension?(src base.io_reader) {
|
pri func decoder.decode_extension?(src base.io_reader) {
|
||||||
var label base.u8
|
var label base.u8
|
||||||
var status base.status // TODO: this shouldn't be necessary.
|
|
||||||
|
|
||||||
label = args.src.read_u8?()
|
label = args.src.read_u8?()
|
||||||
if label == 0xF9 { // The spec calls 0xF9 the "Graphic Control Label".
|
if label == 0xF9 { // The spec calls 0xF9 the "Graphic Control Label".
|
||||||
this.decode_gc?(src:args.src)
|
this.decode_gc?(src:args.src)
|
||||||
return ok
|
return ok
|
||||||
} else if label == 0xFF { // The spec calls 0xFF the "Application Extension Label".
|
} else if label == 0xFF { // The spec calls 0xFF the "Application Extension Label".
|
||||||
// TODO: this should be just "this.decode_ae?(src:args.src)".
|
this.decode_ae?(src:args.src)
|
||||||
while true {
|
|
||||||
status =? this.decode_ae?(src:args.src)
|
|
||||||
if status.is_suspension() {
|
|
||||||
yield? status
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if status.is_ok() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return status
|
|
||||||
}
|
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
// We skip over all other extensions, including 0x01 "Plain Text Label" and
|
// We skip over all other extensions, including 0x01 "Plain Text Label" and
|
||||||
|
|||||||
Reference in new issue
Block a user