restore encode API compatibility

protect WebPPictureSmartARGBToYUVA with an ABI check

Change-Id: Iaec4a9f8f590f27c4c72129b90068690efc84eb7
This commit is contained in:
James Zern 2014-10-13 16:52:01 +02:00
parent f17b95e992
commit 9129deb5b1
4 changed files with 10 additions and 0 deletions

View File

@ -111,7 +111,11 @@ int WebPValidateConfig(const WebPConfig* config) {
return 0; return 0;
if (config->show_compressed < 0 || config->show_compressed > 1) if (config->show_compressed < 0 || config->show_compressed > 1)
return 0; return 0;
#if WEBP_ENCODER_ABI_VERSION > 0x0204
if (config->preprocessing < 0 || config->preprocessing > 7) if (config->preprocessing < 0 || config->preprocessing > 7)
#else
if (config->preprocessing < 0 || config->preprocessing > 3)
#endif
return 0; return 0;
if (config->partitions < 0 || config->partitions > 3) if (config->partitions < 0 || config->partitions > 3)
return 0; return 0;

View File

@ -978,9 +978,11 @@ int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) {
return PictureARGBToYUVA(picture, colorspace, 0.f, 0); return PictureARGBToYUVA(picture, colorspace, 0.f, 0);
} }
#if WEBP_ENCODER_ABI_VERSION > 0x0204
int WebPPictureSmartARGBToYUVA(WebPPicture* picture) { int WebPPictureSmartARGBToYUVA(WebPPicture* picture) {
return PictureARGBToYUVA(picture, WEBP_YUV420, 0.f, 1); return PictureARGBToYUVA(picture, WEBP_YUV420, 0.f, 1);
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// call for YUVA -> ARGB conversion // call for YUVA -> ARGB conversion

View File

@ -329,9 +329,11 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
if (pic->y == NULL || pic->u == NULL || pic->v == NULL) { if (pic->y == NULL || pic->u == NULL || pic->v == NULL) {
// Make sure we have YUVA samples. // Make sure we have YUVA samples.
if (config->preprocessing & 4) { if (config->preprocessing & 4) {
#if WEBP_ENCODER_ABI_VERSION > 0x0204
if (!WebPPictureSmartARGBToYUVA(pic)) { if (!WebPPictureSmartARGBToYUVA(pic)) {
return 0; return 0;
} }
#endif
} else { } else {
float dithering = 0.f; float dithering = 0.f;
if (config->preprocessing & 2) { if (config->preprocessing & 2) {

View File

@ -462,12 +462,14 @@ WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( WEBP_EXTERN(int) WebPPictureARGBToYUVADithered(
WebPPicture* picture, WebPEncCSP colorspace, float dithering); WebPPicture* picture, WebPEncCSP colorspace, float dithering);
#if WEBP_ENCODER_ABI_VERSION > 0x0204
// Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion. // Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion.
// Downsampling is handled with extra care in case of color clipping. This // Downsampling is handled with extra care in case of color clipping. This
// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better // method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
// YUV representation. // YUV representation.
// Returns false in case of error. // Returns false in case of error.
WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture); WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture);
#endif
// Converts picture->yuv to picture->argb and sets picture->use_argb to true. // Converts picture->yuv to picture->argb and sets picture->use_argb to true.
// The input format must be YUV_420 or YUV_420A. // The input format must be YUV_420 or YUV_420A.