mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Tweak wuffs_gif__quirk_reject_empty_frame
This commit is contained in:
1 parent
d41430c4f5
commit
08dd41aa93
3 files changed
+17
-26
No files matched your search
@@ -9395,6 +9395,14 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self,
|
||||
goto suspend;
|
||||
}
|
||||
}
|
||||
if (self->private_impl.f_quirk_enabled_reject_empty_frame &&
|
||||
((self->private_impl.f_frame_rect_x0 ==
|
||||
self->private_impl.f_frame_rect_x1) ||
|
||||
(self->private_impl.f_frame_rect_y0 ==
|
||||
self->private_impl.f_frame_rect_y1))) {
|
||||
status = wuffs_gif__error__bad_frame_size;
|
||||
goto exit;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status = wuffs_gif__decoder__decode_id_part1(self, a_dst, a_src);
|
||||
if (status) {
|
||||
@@ -10605,14 +10613,6 @@ wuffs_gif__decoder__decode_id_part0(wuffs_gif__decoder* self,
|
||||
self->private_impl.f_frame_rect_y1 += self->private_impl.f_frame_rect_y0;
|
||||
self->private_impl.f_dst_x = self->private_impl.f_frame_rect_x0;
|
||||
self->private_impl.f_dst_y = self->private_impl.f_frame_rect_y0;
|
||||
if (self->private_impl.f_quirk_enabled_reject_empty_frame &&
|
||||
((self->private_impl.f_frame_rect_x0 ==
|
||||
self->private_impl.f_frame_rect_x1) ||
|
||||
(self->private_impl.f_frame_rect_y0 ==
|
||||
self->private_impl.f_frame_rect_y1))) {
|
||||
status = wuffs_gif__error__bad_frame_size;
|
||||
goto exit;
|
||||
}
|
||||
if ((self->private_impl.f_call_sequence == 0) &&
|
||||
!self->private_impl.f_quirk_enabled_image_bounds_are_strict) {
|
||||
self->private_impl.f_width = wuffs_base__u32__max(
|
||||
|
||||
@@ -101,7 +101,8 @@ pub const quirk_image_bounds_are_strict base.u32 = (0xF8586 << 10) | 2
|
||||
// buffer with that color.
|
||||
pub const quirk_background_is_opaque base.u32 = (0xF8586 << 10) | 3
|
||||
|
||||
// When this quirk is enabled, a frame with zero width or height is rejected.
|
||||
// When this quirk is enabled, a frame with zero width or height is rejected
|
||||
// during decode_frame (but accepted during decode_frame_config).
|
||||
pub const quirk_reject_empty_frame base.u32 = (0xF8586 << 10) | 5
|
||||
|
||||
// When this quirk is enabled, a frame with no explicit palette is rejected,
|
||||
@@ -472,6 +473,10 @@ pub func decoder.decode_frame?(dst ptr base.pixel_buffer, src base.io_reader, wo
|
||||
if this.call_sequence <> 4 {
|
||||
this.decode_frame_config?(dst:nullptr, src:args.src)
|
||||
}
|
||||
if this.quirk_enabled_reject_empty_frame and
|
||||
((this.frame_rect_x0 == this.frame_rect_x1) or (this.frame_rect_y0 == this.frame_rect_y1)) {
|
||||
return "#bad frame size"
|
||||
}
|
||||
this.decode_id_part1?(dst:args.dst, src:args.src)
|
||||
this.decode_id_part2?(dst:args.dst, src:args.src, workbuf:args.workbuf)
|
||||
|
||||
@@ -834,12 +839,6 @@ pri func decoder.decode_id_part0?(src base.io_reader) {
|
||||
this.dst_x = this.frame_rect_x0
|
||||
this.dst_y = this.frame_rect_y0
|
||||
|
||||
if this.quirk_enabled_reject_empty_frame and
|
||||
((this.frame_rect_x0 == this.frame_rect_x1) or
|
||||
(this.frame_rect_y0 == this.frame_rect_y1)) {
|
||||
return "#bad frame size"
|
||||
}
|
||||
|
||||
// Set the image's overall width and height to be the maximum of the
|
||||
// nominal image width and height (given in the Logical Screen Descriptor)
|
||||
// and the bottom right extent of the first frame. See
|
||||
|
||||
+3
-11
@@ -1128,13 +1128,6 @@ const char* test_wuffs_gif_decode_zero_width_frame() {
|
||||
status = wuffs_gif__decoder__decode_image_config(
|
||||
&dec, &ic, wuffs_base__io_buffer__reader(&src));
|
||||
if (status) {
|
||||
if (q == 2) {
|
||||
if (status != want) {
|
||||
RETURN_FAIL("q=%d: decode_image_config: got \"%s\", want \"%s\"", q,
|
||||
status, want);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
RETURN_FAIL("q=%d: decode_image_config: \"%s\"", q, status);
|
||||
}
|
||||
|
||||
@@ -1145,12 +1138,11 @@ const char* test_wuffs_gif_decode_zero_width_frame() {
|
||||
RETURN_FAIL("q=%d: set_from_slice: \"%s\"", q, status);
|
||||
}
|
||||
|
||||
status = wuffs_gif__decoder__decode_frame(
|
||||
const char* got = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, wuffs_base__io_buffer__reader(&src), global_work_slice,
|
||||
NULL);
|
||||
if (status != want) {
|
||||
RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, status,
|
||||
want);
|
||||
if (got != want) {
|
||||
RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, got, want);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
Reference in new issue
Block a user