diff options
author | James Zern <jzern@google.com> | 2015-02-05 21:09:27 -0800 |
---|---|---|
committer | James Zern <jzern@google.com> | 2015-03-03 17:53:46 -0800 |
commit | 1d6b250b076649e2ced86e5a7e0ad48f2e014577 (patch) | |
tree | e0074a14f47351bfd2d4185b79ad1494be0f900d | |
parent | f97b3f86bf0687405c0321cae64cf9633b7f68a4 (diff) | |
download | libwebp-1d6b250b076649e2ced86e5a7e0ad48f2e014577.tar.gz |
vwebp: clear canvas at the beginning of each loop
this is in line with the recommendation in the spec, cf.,
5603947 webp-container-spec: clarify background clear on loop
(cherry picked from commit 1579de3cae534938cd61b16dfabdab7c8eb3d359)
Change-Id: Id3910395b05a1a1f2804be841b61f97bd4bac593
-rw-r--r-- | examples/vwebp.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/vwebp.c b/examples/vwebp.c index 70520e42..b515b27a 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -80,6 +80,16 @@ static void ClearParams(void) { kParams.dmux = NULL; } +// Sets the previous frame to the dimensions of the canvas and has it dispose +// to background to cause the canvas to be cleared. +static void ClearPreviousFrame(void) { + WebPIterator* const prev = &kParams.prev_frame; + prev->width = kParams.canvas_width; + prev->height = kParams.canvas_height; + prev->x_offset = prev->y_offset = 0; + prev->dispose_method = WEBP_MUX_DISPOSE_BACKGROUND; +} + // ----------------------------------------------------------------------------- // Color profile handling static int ApplyColorProfile(const WebPData* const profile, @@ -180,6 +190,7 @@ static void decode_callback(int what) { --kParams.loop_count; kParams.done = (kParams.loop_count == 0); if (kParams.done) return; + ClearPreviousFrame(); } else { kParams.decoding_error = 1; kParams.done = 1; @@ -394,7 +405,6 @@ int main(int argc, char *argv[]) { int c; WebPDecoderConfig* const config = &kParams.config; WebPIterator* const curr = &kParams.curr_frame; - WebPIterator* const prev = &kParams.prev_frame; if (!WebPInitDecoderConfig(config)) { fprintf(stderr, "Library version mismatch!\n"); @@ -485,10 +495,7 @@ int main(int argc, char *argv[]) { printf("Canvas: %d x %d\n", kParams.canvas_width, kParams.canvas_height); } - prev->width = kParams.canvas_width; - prev->height = kParams.canvas_height; - prev->x_offset = prev->y_offset = 0; - prev->dispose_method = WEBP_MUX_DISPOSE_BACKGROUND; + ClearPreviousFrame(); memset(&kParams.iccp, 0, sizeof(kParams.iccp)); kParams.has_color_profile = |