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
This commit is contained in:
Urvang Joshi 2016-02-05 19:53:50 +00:00 committed by James Zern
parent 6753f35cac
commit da98d31ced

View File

@ -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;
if (ok) {
enc->prev_timestamp_ = timestamp;
return 1;
}
return ok;
}
// -----------------------------------------------------------------------------