mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
restore decode API compatibility
protect flip/alpha_dither w/a WEBP_DECODER_ABI_VERSION check Change-Id: I437a5d5f78800f71b7e7e323faa321f946bf9515
This commit is contained in:
@ -195,10 +195,12 @@ VP8StatusCode WebPAllocateDecBuffer(int w, int h,
|
||||
status = AllocateBuffer(out);
|
||||
if (status != VP8_STATUS_OK) return status;
|
||||
|
||||
#if WEBP_DECODER_ABI_VERSION > 0x0203
|
||||
// Use the stride trick if vertical flip is needed.
|
||||
if (options != NULL && options->flip) {
|
||||
status = WebPFlipBuffer(out);
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ void VP8InitDithering(const WebPDecoderOptions* const options,
|
||||
dec->dither_ = 1;
|
||||
}
|
||||
}
|
||||
#if WEBP_DECODER_ABI_VERSION > 0x0203
|
||||
// potentially allow alpha dithering
|
||||
dec->alpha_dithering_ = options->alpha_dithering_strength;
|
||||
if (dec->alpha_dithering_ > 100) {
|
||||
@ -184,6 +185,7 @@ void VP8InitDithering(const WebPDecoderOptions* const options,
|
||||
} else if (dec->alpha_dithering_ < 0) {
|
||||
dec->alpha_dithering_ = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,15 +240,17 @@ static int CheckMemBufferMode(MemBuffer* const mem, MemBufferMode expected) {
|
||||
|
||||
// To be called last.
|
||||
static VP8StatusCode FinishDecoding(WebPIDecoder* const idec) {
|
||||
#if WEBP_DECODER_ABI_VERSION > 0x0203
|
||||
const WebPDecoderOptions* const options = idec->params_.options;
|
||||
WebPDecBuffer* const output = idec->params_.output;
|
||||
|
||||
idec->state_ = STATE_DONE;
|
||||
if (options != NULL && options->flip) {
|
||||
return WebPFlipBuffer(output);
|
||||
} else {
|
||||
return VP8_STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
idec->state_ = STATE_DONE;
|
||||
return VP8_STATUS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -521,9 +521,11 @@ static VP8StatusCode DecodeInto(const uint8_t* const data, size_t data_size,
|
||||
WebPFreeDecBuffer(params->output);
|
||||
}
|
||||
|
||||
#if WEBP_DECODER_ABI_VERSION > 0x0203
|
||||
if (params->options != NULL && params->options->flip) {
|
||||
status = WebPFlipBuffer(params->output);
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user