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 1579de3cae)

Change-Id: Id3910395b05a1a1f2804be841b61f97bd4bac593
This commit is contained in:
James Zern 2015-02-05 21:09:27 -08:00
parent f97b3f86bf
commit 1d6b250b07

View File

@ -80,6 +80,16 @@ static void ClearParams(void) {
kParams.dmux = NULL; 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 // Color profile handling
static int ApplyColorProfile(const WebPData* const profile, static int ApplyColorProfile(const WebPData* const profile,
@ -180,6 +190,7 @@ static void decode_callback(int what) {
--kParams.loop_count; --kParams.loop_count;
kParams.done = (kParams.loop_count == 0); kParams.done = (kParams.loop_count == 0);
if (kParams.done) return; if (kParams.done) return;
ClearPreviousFrame();
} else { } else {
kParams.decoding_error = 1; kParams.decoding_error = 1;
kParams.done = 1; kParams.done = 1;
@ -394,7 +405,6 @@ int main(int argc, char *argv[]) {
int c; int c;
WebPDecoderConfig* const config = &kParams.config; WebPDecoderConfig* const config = &kParams.config;
WebPIterator* const curr = &kParams.curr_frame; WebPIterator* const curr = &kParams.curr_frame;
WebPIterator* const prev = &kParams.prev_frame;
if (!WebPInitDecoderConfig(config)) { if (!WebPInitDecoderConfig(config)) {
fprintf(stderr, "Library version mismatch!\n"); 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); printf("Canvas: %d x %d\n", kParams.canvas_width, kParams.canvas_height);
} }
prev->width = kParams.canvas_width; ClearPreviousFrame();
prev->height = kParams.canvas_height;
prev->x_offset = prev->y_offset = 0;
prev->dispose_method = WEBP_MUX_DISPOSE_BACKGROUND;
memset(&kParams.iccp, 0, sizeof(kParams.iccp)); memset(&kParams.iccp, 0, sizeof(kParams.iccp));
kParams.has_color_profile = kParams.has_color_profile =