From da98d31ced699f9f72aa5a5716d0aa6d3a2ec3d8 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 5 Feb 2016 19:53:50 +0000 Subject: [PATCH] AnimEncoder: Support progress hook and user data. Pass them along to internal 'pic' object, so that progress can be reported back and user data can also be inspected. Change-Id: Idb5d0d4a76d07283d704a86c5892e1ad7bda09fa --- src/mux/anim_encode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mux/anim_encode.c b/src/mux/anim_encode.c index 228603f1..b8a0f979 100644 --- a/src/mux/anim_encode.c +++ b/src/mux/anim_encode.c @@ -699,6 +699,8 @@ static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame, static void CopyCurrentCanvas(WebPAnimEncoder* const enc) { if (enc->curr_canvas_copy_modified_) { WebPCopyPixels(enc->curr_canvas_, &enc->curr_canvas_copy_); + enc->curr_canvas_copy_.progress_hook = enc->curr_canvas_->progress_hook; + enc->curr_canvas_copy_.user_data = enc->curr_canvas_->user_data; enc->curr_canvas_copy_modified_ = 0; } } @@ -1164,6 +1166,7 @@ static int FlushFrames(WebPAnimEncoder* const enc) { int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp, const WebPConfig* encoder_config) { WebPConfig config; + int ok; if (enc == NULL) { return 0; @@ -1223,17 +1226,14 @@ int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp, assert(enc->curr_canvas_copy_modified_ == 1); CopyCurrentCanvas(enc); - if (!CacheFrame(enc, &config)) { - return 0; - } + ok = CacheFrame(enc, &config) && FlushFrames(enc); - if (!FlushFrames(enc)) { - return 0; - } enc->curr_canvas_ = NULL; enc->curr_canvas_copy_modified_ = 1; - enc->prev_timestamp_ = timestamp; - return 1; + if (ok) { + enc->prev_timestamp_ = timestamp; + } + return ok; } // -----------------------------------------------------------------------------