20
20
extern "C" {
21
21
#endif
22
22
23
- #define WEBP_ENCODER_ABI_VERSION 0x0202 // MAJOR(8b) + MINOR(8b)
23
+ #define WEBP_ENCODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b)
24
24
25
25
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
26
26
// the types are left here for reference.
@@ -42,7 +42,7 @@ WEBP_EXTERN(int) WebPGetEncoderVersion(void);
42
42
43
43
// Returns the size of the compressed data (pointed to by *output), or 0 if
44
44
// an error occurred. The compressed data must be released by the caller
45
- // using the call 'free (*output)'.
45
+ // using the call 'WebPFree (*output)'.
46
46
// These functions compress using the lossy format, and the quality_factor
47
47
// can go from 0 (smaller output, lower quality) to 100 (best quality,
48
48
// larger output).
@@ -75,6 +75,9 @@ WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra,
75
75
int width , int height , int stride ,
76
76
uint8_t * * output );
77
77
78
+ // Releases memory returned by the WebPEncode*() functions above.
79
+ WEBP_EXTERN (void ) WebPFree (void * ptr );
80
+
78
81
//------------------------------------------------------------------------------
79
82
// Coding parameters
80
83
@@ -131,7 +134,19 @@ struct WebPConfig {
131
134
int thread_level ; // If non-zero, try and use multi-threaded encoding.
132
135
int low_memory ; // If set, reduce memory usage (but increase CPU use).
133
136
134
- uint32_t pad [5 ]; // padding for later use
137
+ int near_lossless ; // Near lossless encoding [0 = off(default) .. 100].
138
+ // This feature is experimental.
139
+ int exact ; // if non-zero, preserve the exact RGB values under
140
+ // transparent area. Otherwise, discard this invisible
141
+ // RGB information for better compression. The default
142
+ // value is 0.
143
+
144
+ #ifdef WEBP_EXPERIMENTAL_FEATURES
145
+ int delta_palettization ;
146
+ uint32_t pad [2 ]; // padding for later use
147
+ #else
148
+ uint32_t pad [3 ]; // padding for later use
149
+ #endif // WEBP_EXPERIMENTAL_FEATURES
135
150
};
136
151
137
152
// Enumerate some predefined settings for WebPConfig, depending on the type
@@ -167,15 +182,13 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
167
182
WEBP_ENCODER_ABI_VERSION );
168
183
}
169
184
170
- #if WEBP_ENCODER_ABI_VERSION > 0x0202
171
185
// Activate the lossless compression mode with the desired efficiency level
172
186
// between 0 (fastest, lowest compression) and 9 (slower, best compression).
173
187
// A good default level is '6', providing a fair tradeoff between compression
174
188
// speed and final compressed size.
175
189
// This function will overwrite several fields from config: 'method', 'quality'
176
190
// and 'lossless'. Returns false in case of parameter error.
177
191
WEBP_EXTERN (int ) WebPConfigLosslessPreset (WebPConfig * config , int level );
178
- #endif
179
192
180
193
// Returns true if 'config' is non-NULL and all configuration parameters are
181
194
// within their valid ranges.
@@ -209,8 +222,10 @@ struct WebPAuxStats {
209
222
int cache_bits ; // number of bits for color cache lookup
210
223
int palette_size ; // number of color in palette, if used
211
224
int lossless_size ; // final lossless size
225
+ int lossless_hdr_size ; // lossless header (transform, huffman etc) size
226
+ int lossless_data_size ; // lossless image data size
212
227
213
- uint32_t pad [4 ]; // padding for later use
228
+ uint32_t pad [2 ]; // padding for later use
214
229
};
215
230
216
231
// Signature for output function. Should return true if writing was successful.
@@ -231,18 +246,12 @@ struct WebPMemoryWriter {
231
246
// The following must be called first before any use.
232
247
WEBP_EXTERN (void ) WebPMemoryWriterInit (WebPMemoryWriter * writer );
233
248
234
- #if WEBP_ENCODER_ABI_VERSION > 0x0203
235
249
// The following must be called to deallocate writer->mem memory. The 'writer'
236
250
// object itself is not deallocated.
237
251
WEBP_EXTERN (void ) WebPMemoryWriterClear (WebPMemoryWriter * writer );
238
- #endif
239
252
// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
240
253
// completion, writer.mem and writer.size will hold the coded data.
241
- #if WEBP_ENCODER_ABI_VERSION > 0x0203
242
254
// writer.mem must be freed by calling WebPMemoryWriterClear.
243
- #else
244
- // writer.mem must be freed by calling 'free(writer.mem)'.
245
- #endif
246
255
WEBP_EXTERN (int ) WebPMemoryWrite (const uint8_t * data , size_t data_size ,
247
256
const WebPPicture * picture );
248
257
@@ -379,8 +388,8 @@ WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
379
388
// Returns false in case of memory allocation error.
380
389
WEBP_EXTERN (int ) WebPPictureCopy (const WebPPicture * src , WebPPicture * dst );
381
390
382
- // Compute PSNR, SSIM or LSIM distortion metric between two pictures.
383
- // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order.
391
+ // Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
392
+ // are in dB, stored in result[] in the Y/U/V/Alpha/All or B/G/R/A /All order.
384
393
// Returns false in case of error (src and ref don't have same dimension, ...)
385
394
// Warning: this function is rather CPU-intensive.
386
395
WEBP_EXTERN (int ) WebPPictureDistortion (
@@ -464,14 +473,12 @@ WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
464
473
WEBP_EXTERN (int ) WebPPictureARGBToYUVADithered (
465
474
WebPPicture * picture , WebPEncCSP colorspace , float dithering );
466
475
467
- #if WEBP_ENCODER_ABI_VERSION > 0x0204
468
476
// Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion.
469
477
// Downsampling is handled with extra care in case of color clipping. This
470
478
// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
471
479
// YUV representation.
472
480
// Returns false in case of error.
473
481
WEBP_EXTERN (int ) WebPPictureSmartARGBToYUVA (WebPPicture * picture );
474
- #endif
475
482
476
483
// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
477
484
// The input format must be YUV_420 or YUV_420A.
0 commit comments