Use 0 (not 1) num_animation_loops for still GIFs

For example, the crc32 checksums in test/nia-checksums-of-data.txt for
test/data/pjw-thumbnail.{bmp,gif,png} now all match.
This commit is contained in:
Nigel Tao committed 2021-11-23 15:06:55 +11:00
1 parent 8bd52a8791
commit ac4d3e6420
4 files changed
+44 -22

No files matched your search

+4 -1
View File
@@ -29298,7 +29298,10 @@ wuffs_gif__decoder__num_animation_loops(
if (self->private_impl.f_seen_num_animation_loops_value) {
return self->private_impl.f_num_animation_loops_value;
}
return 1;
if (self->private_impl.f_num_decoded_frame_configs_value > 1) {
return 1;
}
return 0;
}
// -------- func gif.decoder.num_decoded_frame_configs
+15 -1
View File
@@ -277,7 +277,21 @@ pub func decoder.num_animation_loops() base.u32 {
if this.seen_num_animation_loops_value {
return this.num_animation_loops_value
}
return 1
// Absent an explicit animation loop count, default to 1 meaning "play each
// frame exactly once" for animated GIFs and 0 meaning "loop forever" for
// still (non-animated) GIFs.
//
// In practice, returning 1 or 0 has no difference for still GIFs, in that
// either way, the pixels on screen do not change over time. However,
// returning 0 here matches other Wuffs image decoders (e.g. BMP, PNG)
// returning 0 for their still images.
//
// As a consequence, if a still GIF is losslessly converted to a still BMP
// and both of those are then converted to NIA, the two NIA outputs match.
if this.num_decoded_frame_configs_value > 1 {
return 1
}
return 0
}
pub func decoder.num_decoded_frame_configs() base.u64 {
+11 -6
View File
@@ -252,11 +252,6 @@ do_test_wuffs_gif_decode(const char* filename,
CHECK_STATUS("set_from_slice", wuffs_base__pixel_buffer__set_from_slice(
&pb, &ic.pixcfg, g_pixel_slice_u8));
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
if (have != 1) {
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want 1", have);
}
}
int num_iters = 0;
@@ -422,6 +417,16 @@ do_test_wuffs_gif_decode(const char* filename,
}
}
{
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
uint32_t want =
(wuffs_gif__decoder__num_decoded_frame_configs(&dec) > 1) ? 1 : 0;
if (have != want) {
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want %" PRIu32, have,
want);
}
}
return NULL;
}
@@ -1510,7 +1515,7 @@ test_wuffs_gif_decode_multiple_loop_counts() {
// loop counts are the number of animation loops *after* the first play
// through, and Wuffs' are the number *including* the first play through.
uint32_t want_num_animation_loops[4] = {1, 1, 51, 31};
uint32_t want_num_animation_loops[4] = {0, 1, 51, 31};
uint32_t i = 0;
while (true) {
+14 -14
View File
@@ -11,14 +11,14 @@ f9a10dac test/data/artificial-gif/background-color.gif
db4c30eb test/data/artificial-gif/frame-out-of-bounds.gif
fdcc644f test/data/artificial-gif/metadata-empty.gif
fdcc644f test/data/artificial-gif/metadata-full.gif
6d03b5f3 test/data/artificial-gif/multiple-graphic-controls.gif
a1a9b56d test/data/artificial-gif/multiple-graphic-controls.gif
47c877fd test/data/artificial-gif/multiple-loop-counts.gif
76c44866 test/data/artificial-gif/no-frames.gif
ba6e48f8 test/data/artificial-gif/no-frames.gif
6ec818c3 test/data/artificial-gif/pixel-data-none.gif
5e57adb2 test/data/artificial-gif/pixel-data-not-enough.gif
3e29f88a test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif
3e29f88a test/data/artificial-gif/pixel-data-too-much-good-lzw.gif
f50d1d50 test/data/artificial-gif/small-frame-interlaced.gif
39a71dce test/data/artificial-gif/small-frame-interlaced.gif
beaec397 test/data/artificial-gif/transparent-index.gif
6ec818c3 test/data/artificial-gif/zero-width-frame.gif
0564b364 test/data/artificial-png/apng-skip-idat.png
@@ -26,15 +26,15 @@ e08a7cc8 test/data/artificial-png/key-value-pairs.png
076cb375 test/data/bricks-color.bmp
076cb375 test/data/bricks-color.png
f36c2e80 test/data/bricks-dither.bmp
3fc62e1e test/data/bricks-dither.gif
f36c2e80 test/data/bricks-dither.gif
f36c2e80 test/data/bricks-dither.no-ancillary.png
f36c2e80 test/data/bricks-dither.png
c2bce675 test/data/bricks-gray.bmp
0e16e6eb test/data/bricks-gray.gif
c2bce675 test/data/bricks-gray.gif
c2bce675 test/data/bricks-gray.no-ancillary.png
c2bce675 test/data/bricks-gray.png
7aebfe6c test/data/bricks-nodither.bmp
b641fef2 test/data/bricks-nodither.gif
7aebfe6c test/data/bricks-nodither.gif
7aebfe6c test/data/bricks-nodither.png
ae2e547d test/data/bricks-nodither.wbmp
b47730a2 test/data/checkerboard.gamma1dot0.png
@@ -42,32 +42,32 @@ b47730a2 test/data/checkerboard.gamma2dot2.png
aa3e6c7c test/data/crude-flag.nie
3014b4c0 test/data/gifplayer-muybridge.gif
030f5a48 test/data/harvesters.bmp
0d213dc4 test/data/harvesters.gif
c18b3d5a test/data/harvesters.gif
030f5a48 test/data/harvesters.png
e776c90f test/data/hat.bmp
a161a63a test/data/hat.gif
6dcba6a4 test/data/hat.gif
e776c90f test/data/hat.png
d30bfe5d test/data/hat.wbmp
33a44f22 test/data/hibiscus.primitive.bmp
e948122d test/data/hibiscus.primitive.gif
25e212b3 test/data/hibiscus.primitive.gif
33a44f22 test/data/hibiscus.primitive.png
60040742 test/data/hibiscus.regular.bmp
7b8dda15 test/data/hibiscus.regular.gif
b727da8b test/data/hibiscus.regular.gif
60040742 test/data/hibiscus.regular.png
dcbb225a test/data/hippopotamus.bmp
21e17862 test/data/hippopotamus.interlaced.gif
ed4b78fc test/data/hippopotamus.interlaced.gif
dcbb225a test/data/hippopotamus.interlaced.png
a80781a1 test/data/hippopotamus.interlaced.truncated.gif
1f11edb9 test/data/hippopotamus.masked-with-muybridge.gif
d3bbed27 test/data/hippopotamus.masked-with-muybridge.gif
7e6acf01 test/data/hippopotamus.masked-with-muybridge.png
dcbb225a test/data/hippopotamus.nie
21e17862 test/data/hippopotamus.regular.gif
ed4b78fc test/data/hippopotamus.regular.gif
dcbb225a test/data/hippopotamus.regular.png
2dccfe56 test/data/muybridge-frame-000.wbmp
db2733f5 test/data/muybridge.apng
db2733f5 test/data/muybridge.gif
bf7e8c96 test/data/pjw-thumbnail.bmp
73d48c08 test/data/pjw-thumbnail.gif
bf7e8c96 test/data/pjw-thumbnail.gif
bf7e8c96 test/data/pjw-thumbnail.png
38cb4cbf test/data/red-blue-gradient.dcip3d65-no-chrm-no-gama.png
38cb4cbf test/data/red-blue-gradient.gamma1dot0.png