mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
restore encode API compatibility
protect WebPConfigLosslessPreset/WebPMemoryWriterClear w/a WEBP_ENCODER_ABI_VERSION check Change-Id: If4debc15fee172a3f18079bc2bd29eb8447bc14b
This commit is contained in:
@ -138,6 +138,7 @@ int WebPValidateConfig(const WebPConfig* config) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if WEBP_ENCODER_ABI_VERSION > 0x0202
|
||||
#define MAX_LEVEL 9
|
||||
|
||||
// Mapping between -z level and -m / -q parameter settings.
|
||||
@ -156,5 +157,6 @@ int WebPConfigLosslessPreset(WebPConfig* config, int level) {
|
||||
config->quality = kLosslessPresets[level].quality_;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -571,6 +571,10 @@ int WebPPictureAllocYUVA(WebPPicture* const picture, int width, int height);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if WEBP_ENCODER_ABI_VERSION <= 0x0202
|
||||
void WebPMemoryWriterClear(WebPMemoryWriter* writer);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WEBP_ENCODER_ABI_VERSION 0x0205 // MAJOR(8b) + MINOR(8b)
|
||||
#define WEBP_ENCODER_ABI_VERSION 0x0202 // MAJOR(8b) + MINOR(8b)
|
||||
|
||||
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
|
||||
// the types are left here for reference.
|
||||
@ -167,6 +167,7 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
|
||||
WEBP_ENCODER_ABI_VERSION);
|
||||
}
|
||||
|
||||
#if WEBP_ENCODER_ABI_VERSION > 0x0202
|
||||
// Activate the lossless compression mode with the desired efficiency level
|
||||
// between 0 (fastest, lowest compression) and 9 (slower, best compression).
|
||||
// A good default level is '6', providing a fair tradeoff between compression
|
||||
@ -174,6 +175,7 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
|
||||
// This function will overwrite several fields from config: 'method', 'quality'
|
||||
// and 'lossless'. Returns false in case of parameter error.
|
||||
WEBP_EXTERN(int) WebPConfigLosslessPreset(WebPConfig* config, int level);
|
||||
#endif
|
||||
|
||||
// Returns true if 'config' is non-NULL and all configuration parameters are
|
||||
// within their valid ranges.
|
||||
@ -229,12 +231,18 @@ struct WebPMemoryWriter {
|
||||
// The following must be called first before any use.
|
||||
WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer);
|
||||
|
||||
#if WEBP_ENCODER_ABI_VERSION > 0x0202
|
||||
// The following must be called to deallocate writer->mem memory. The 'writer'
|
||||
// object itself is not deallocated.
|
||||
WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer);
|
||||
#endif
|
||||
// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
|
||||
// completion, writer.mem and writer.size will hold the coded data.
|
||||
#if WEBP_ENCODER_ABI_VERSION > 0x0202
|
||||
// writer.mem must be freed by calling WebPMemoryWriterClear.
|
||||
#else
|
||||
// writer.mem must be freed by calling 'free(writer.mem)'.
|
||||
#endif
|
||||
WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size,
|
||||
const WebPPicture* picture);
|
||||
|
||||
|
Reference in New Issue
Block a user