mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Decode multiple graphic controls in a GIF
This commit is contained in:
1 parent
5bea867f72
commit
b1ff27fded
6 files changed
+89
-16
No files matched your search
@@ -1245,6 +1245,40 @@ const char* test_wuffs_gif_decode_missing_two_src_bytes() {
|
||||
src, 0, wuffs_base__suspension__short_read, false);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_multiple_graphic_controls() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
read_file(&src, "test/data/artificial/gif-multiple-graphic-controls.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
RETURN_FAIL("initialize: \"%s\"", status);
|
||||
}
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
status = wuffs_gif__decoder__decode_frame_config(&dec, &fc, src_reader);
|
||||
if (status) {
|
||||
RETURN_FAIL("decode_frame_config: \"%s\"", status);
|
||||
}
|
||||
|
||||
int got = wuffs_base__frame_config__duration(&fc) /
|
||||
WUFFS_BASE__FLICKS_PER_MILLISECOND;
|
||||
int want = 300;
|
||||
if (got != want) {
|
||||
RETURN_FAIL("duration: got %d, want %d", got, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
@@ -2025,6 +2059,7 @@ proc tests[] = {
|
||||
test_wuffs_gif_decode_input_is_a_png, //
|
||||
test_wuffs_gif_decode_metadata, //
|
||||
test_wuffs_gif_decode_missing_two_src_bytes, //
|
||||
test_wuffs_gif_decode_multiple_graphic_controls, //
|
||||
test_wuffs_gif_decode_multiple_loop_counts, //
|
||||
test_wuffs_gif_decode_pixel_data_none, //
|
||||
test_wuffs_gif_decode_pixel_data_not_enough, //
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 56 B |
@@ -0,0 +1,31 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
# This GIF image contains multiple "Graphic Control Extensions" for a frame.
|
||||
#
|
||||
# The GIF89a specification says that "at most one Graphic Control Extension may
|
||||
# precede a graphic rendering block", but in practice, some encoders emit more
|
||||
# than one, and decoders ignore all but the last one.
|
||||
|
||||
make gif
|
||||
|
||||
header
|
||||
|
||||
image {
|
||||
imageWidthHeight 1 1
|
||||
palette {
|
||||
0x00 0x00 0xFF
|
||||
0x11 0x00 0xFF
|
||||
0x22 0x00 0xFF
|
||||
0x33 0x00 0xFF
|
||||
}
|
||||
}
|
||||
|
||||
graphicControlDuration 200ms
|
||||
graphicControlDuration 300ms
|
||||
|
||||
frame {
|
||||
frameLeftTopWidthHeight 0 0 1 1
|
||||
}
|
||||
lzw 2 0x00
|
||||
|
||||
trailer
|
||||
Reference in new issue
Block a user