From e53497abe37aa8dcbfd801b562956659afb16e69 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Tue, 23 Nov 2021 15:23:18 +1100 Subject: [PATCH] Have convert-to-nia output valid NIA on bad frames --- example/convert-to-nia/convert-to-nia.c | 14 ++++++++------ test/nia-checksums-of-data.txt | 12 ++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/example/convert-to-nia/convert-to-nia.c b/example/convert-to-nia/convert-to-nia.c index 8ff6699b..d9c45a75 100644 --- a/example/convert-to-nia/convert-to-nia.c +++ b/example/convert-to-nia/convert-to-nia.c @@ -525,9 +525,6 @@ convert_frames() { return "main: animation frame duration overflow"; } total_duration += duration; - if (!g_flags.first_frame_only) { - print_nia_duration(total_duration); - } if (wuffs_base__frame_config__index(&g_frame_config) == 0) { fill_rectangle( @@ -561,14 +558,19 @@ convert_frames() { TRY(read_more_src()); } + if (!g_flags.first_frame_only) { + print_nia_duration(total_duration); + } print_nie_frame(); + if (!g_flags.first_frame_only) { + print_nia_padding(); + } if (df_status.repr != NULL) { return wuffs_base__status__message(&df_status); } else if (g_flags.first_frame_only) { return NULL; } - print_nia_padding(); switch (wuffs_base__frame_config__disposal(&g_frame_config)) { case WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND: { @@ -605,11 +607,11 @@ main1(int argc, char** argv) { if (!g_flags.first_frame_only) { print_nix_header(0x41AFC36E); // "nïA" as a u32le. } - TRY(convert_frames()); + const char* ret = convert_frames(); if (!g_flags.first_frame_only) { print_nia_footer(); } - return NULL; + return ret; } int // diff --git a/test/nia-checksums-of-data.txt b/test/nia-checksums-of-data.txt index e041d659..c13225b5 100644 --- a/test/nia-checksums-of-data.txt +++ b/test/nia-checksums-of-data.txt @@ -14,13 +14,13 @@ fdcc644f test/data/artificial-gif/metadata-full.gif a1a9b56d test/data/artificial-gif/multiple-graphic-controls.gif 47c877fd test/data/artificial-gif/multiple-loop-counts.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 +f33b9bc1 test/data/artificial-gif/pixel-data-none.gif +ac9d76d8 test/data/artificial-gif/pixel-data-not-enough.gif +2342e3fc test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif +2342e3fc test/data/artificial-gif/pixel-data-too-much-good-lzw.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 +f33b9bc1 test/data/artificial-gif/zero-width-frame.gif 0564b364 test/data/artificial-png/apng-skip-idat.png e08a7cc8 test/data/artificial-png/key-value-pairs.png 076cb375 test/data/bricks-color.bmp @@ -57,7 +57,7 @@ b727da8b test/data/hibiscus.regular.gif dcbb225a test/data/hippopotamus.bmp ed4b78fc test/data/hippopotamus.interlaced.gif dcbb225a test/data/hippopotamus.interlaced.png -a80781a1 test/data/hippopotamus.interlaced.truncated.gif +45bf0281 test/data/hippopotamus.interlaced.truncated.gif d3bbed27 test/data/hippopotamus.masked-with-muybridge.gif 7e6acf01 test/data/hippopotamus.masked-with-muybridge.png dcbb225a test/data/hippopotamus.nie