mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 14:18:21 +01:00
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:
parent
6753f35cac
commit
da98d31ced
@ -699,6 +699,8 @@ static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame,
|
|||||||
static void CopyCurrentCanvas(WebPAnimEncoder* const enc) {
|
static void CopyCurrentCanvas(WebPAnimEncoder* const enc) {
|
||||||
if (enc->curr_canvas_copy_modified_) {
|
if (enc->curr_canvas_copy_modified_) {
|
||||||
WebPCopyPixels(enc->curr_canvas_, &enc->curr_canvas_copy_);
|
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;
|
enc->curr_canvas_copy_modified_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1164,6 +1166,7 @@ static int FlushFrames(WebPAnimEncoder* const enc) {
|
|||||||
int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp,
|
int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp,
|
||||||
const WebPConfig* encoder_config) {
|
const WebPConfig* encoder_config) {
|
||||||
WebPConfig config;
|
WebPConfig config;
|
||||||
|
int ok;
|
||||||
|
|
||||||
if (enc == NULL) {
|
if (enc == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1223,17 +1226,14 @@ int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int timestamp,
|
|||||||
assert(enc->curr_canvas_copy_modified_ == 1);
|
assert(enc->curr_canvas_copy_modified_ == 1);
|
||||||
CopyCurrentCanvas(enc);
|
CopyCurrentCanvas(enc);
|
||||||
|
|
||||||
if (!CacheFrame(enc, &config)) {
|
ok = CacheFrame(enc, &config) && FlushFrames(enc);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FlushFrames(enc)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
enc->curr_canvas_ = NULL;
|
enc->curr_canvas_ = NULL;
|
||||||
enc->curr_canvas_copy_modified_ = 1;
|
enc->curr_canvas_copy_modified_ = 1;
|
||||||
enc->prev_timestamp_ = timestamp;
|
if (ok) {
|
||||||
return 1;
|
enc->prev_timestamp_ = timestamp;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user