OLD | NEW |
1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
9 // | 9 // |
10 // WebP encoder: main interface | 10 // WebP encoder: main interface |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 struct WebPMemoryWriter { | 224 struct WebPMemoryWriter { |
225 uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). | 225 uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). |
226 size_t size; // final size | 226 size_t size; // final size |
227 size_t max_size; // total capacity | 227 size_t max_size; // total capacity |
228 uint32_t pad[1]; // padding for later use | 228 uint32_t pad[1]; // padding for later use |
229 }; | 229 }; |
230 | 230 |
231 // The following must be called first before any use. | 231 // The following must be called first before any use. |
232 WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); | 232 WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); |
233 | 233 |
234 #if WEBP_ENCODER_ABI_VERSION > 0x0202 | 234 #if WEBP_ENCODER_ABI_VERSION > 0x0203 |
235 // The following must be called to deallocate writer->mem memory. The 'writer' | 235 // The following must be called to deallocate writer->mem memory. The 'writer' |
236 // object itself is not deallocated. | 236 // object itself is not deallocated. |
237 WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer); | 237 WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer); |
238 #endif | 238 #endif |
239 // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon | 239 // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon |
240 // completion, writer.mem and writer.size will hold the coded data. | 240 // completion, writer.mem and writer.size will hold the coded data. |
241 #if WEBP_ENCODER_ABI_VERSION > 0x0202 | 241 #if WEBP_ENCODER_ABI_VERSION > 0x0203 |
242 // writer.mem must be freed by calling WebPMemoryWriterClear. | 242 // writer.mem must be freed by calling WebPMemoryWriterClear. |
243 #else | 243 #else |
244 // writer.mem must be freed by calling 'free(writer.mem)'. | 244 // writer.mem must be freed by calling 'free(writer.mem)'. |
245 #endif | 245 #endif |
246 WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, | 246 WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, |
247 const WebPPicture* picture); | 247 const WebPPicture* picture); |
248 | 248 |
249 // Progress hook, called from time to time to report progress. It can return | 249 // Progress hook, called from time to time to report progress. It can return |
250 // false to request an abort of the encoding process, or true otherwise if | 250 // false to request an abort of the encoding process, or true otherwise if |
251 // everything is OK. | 251 // everything is OK. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); | 439 WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); |
440 | 440 |
441 // Variants of the above, but taking BGR(A|X) input. | 441 // Variants of the above, but taking BGR(A|X) input. |
442 WEBP_EXTERN(int) WebPPictureImportBGR( | 442 WEBP_EXTERN(int) WebPPictureImportBGR( |
443 WebPPicture* picture, const uint8_t* bgr, int bgr_stride); | 443 WebPPicture* picture, const uint8_t* bgr, int bgr_stride); |
444 WEBP_EXTERN(int) WebPPictureImportBGRA( | 444 WEBP_EXTERN(int) WebPPictureImportBGRA( |
445 WebPPicture* picture, const uint8_t* bgra, int bgra_stride); | 445 WebPPicture* picture, const uint8_t* bgra, int bgra_stride); |
446 WEBP_EXTERN(int) WebPPictureImportBGRX( | 446 WEBP_EXTERN(int) WebPPictureImportBGRX( |
447 WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); | 447 WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); |
448 | 448 |
449 // Converts picture->argb data to the YUVA format specified by 'colorspace'. | 449 // Converts picture->argb data to the YUV420A format. The 'colorspace' |
| 450 // parameter is deprecated and should be equal to WEBP_YUV420. |
450 // Upon return, picture->use_argb is set to false. The presence of real | 451 // Upon return, picture->use_argb is set to false. The presence of real |
451 // non-opaque transparent values is detected, and 'colorspace' will be | 452 // non-opaque transparent values is detected, and 'colorspace' will be |
452 // adjusted accordingly. Note that this method is lossy. | 453 // adjusted accordingly. Note that this method is lossy. |
453 // Returns false in case of error. | 454 // Returns false in case of error. |
454 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, | 455 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, |
455 WebPEncCSP colorspace); | 456 WebPEncCSP /*colorspace = WEBP_YUV420*/); |
456 | 457 |
457 // Same as WebPPictureARGBToYUVA(), but the conversion is done using | 458 // Same as WebPPictureARGBToYUVA(), but the conversion is done using |
458 // pseudo-random dithering with a strength 'dithering' between | 459 // pseudo-random dithering with a strength 'dithering' between |
459 // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful | 460 // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful |
460 // for photographic picture. | 461 // for photographic picture. |
461 WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( | 462 WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( |
462 WebPPicture* picture, WebPEncCSP colorspace, float dithering); | 463 WebPPicture* picture, WebPEncCSP colorspace, float dithering); |
463 | 464 |
| 465 #if WEBP_ENCODER_ABI_VERSION > 0x0204 |
| 466 // Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion. |
| 467 // Downsampling is handled with extra care in case of color clipping. This |
| 468 // method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better |
| 469 // YUV representation. |
| 470 // Returns false in case of error. |
| 471 WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture); |
| 472 #endif |
| 473 |
464 // Converts picture->yuv to picture->argb and sets picture->use_argb to true. | 474 // Converts picture->yuv to picture->argb and sets picture->use_argb to true. |
465 // The input format must be YUV_420 or YUV_420A. | 475 // The input format must be YUV_420 or YUV_420A. |
466 // Note that the use of this method is discouraged if one has access to the | 476 // Note that the use of this method is discouraged if one has access to the |
467 // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the | 477 // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the |
468 // conversion from YUV420 to ARGB incurs a small loss too. | 478 // conversion from YUV420 to ARGB incurs a small loss too. |
469 // Returns false in case of error. | 479 // Returns false in case of error. |
470 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); | 480 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); |
471 | 481 |
472 // Helper function: given a width x height plane of RGBA or YUV(A) samples | 482 // Helper function: given a width x height plane of RGBA or YUV(A) samples |
473 // clean-up the YUV or RGB samples under fully transparent area, to help | 483 // clean-up the YUV or RGB samples under fully transparent area, to help |
(...skipping 25 matching lines...) Expand all Loading... |
499 // another is provided but they both incur some loss. | 509 // another is provided but they both incur some loss. |
500 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); | 510 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); |
501 | 511 |
502 //------------------------------------------------------------------------------ | 512 //------------------------------------------------------------------------------ |
503 | 513 |
504 #ifdef __cplusplus | 514 #ifdef __cplusplus |
505 } // extern "C" | 515 } // extern "C" |
506 #endif | 516 #endif |
507 | 517 |
508 #endif /* WEBP_WEBP_ENCODE_H_ */ | 518 #endif /* WEBP_WEBP_ENCODE_H_ */ |
OLD | NEW |