AnimEncoder API: Support input frames in YUV(A) format.

We automatically convert them to ARGB format.

Change-Id: Ia21f07e08c746e16a318cb035af375c81d9af0de
This commit is contained in:
Urvang Joshi
2015-03-10 11:27:09 -07:00
parent 44bd95612e
commit 0873f85b54
2 changed files with 15 additions and 3 deletions

View File

@ -1058,14 +1058,25 @@ int WebPAnimEncoderAdd(WebPAnimEncoder* enc, WebPPicture* frame, int duration,
return 0;
}
if (frame->width != enc->canvas_width_ ||
frame->height != enc->canvas_height_ || !frame->use_argb ||
duration < 0) {
frame->height != enc->canvas_height_ || duration < 0) {
frame->error_code = VP8_ENC_ERROR_INVALID_CONFIGURATION;
if (enc->options_.verbose) {
fprintf(stderr, "ERROR adding frame: Invalid input.\n");
}
return 0;
}
if (!frame->use_argb) { // Convert frame from YUV(A) to ARGB.
if (enc->options_.verbose) {
fprintf(stderr, "WARNING: Converting frame from YUV(A) to ARGB format; "
"this incurs a small loss.\n");
}
if (!WebPPictureYUVAToARGB(frame)) {
fprintf(stderr, "ERROR converting frame from YUV(A) to ARGB\n");
return 0;
}
}
if (encoder_config != NULL) {
config = *encoder_config;
} else {