| 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 |
| 11 // | 11 // |
| 12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 13 | 13 |
| 14 #ifndef WEBP_WEBP_ENCODE_H_ | 14 #ifndef WEBP_WEBP_ENCODE_H_ |
| 15 #define WEBP_WEBP_ENCODE_H_ | 15 #define WEBP_WEBP_ENCODE_H_ |
| 16 | 16 |
| 17 #include "./types.h" | 17 #include "./types.h" |
| 18 | 18 |
| 19 #if defined(__cplusplus) || defined(c_plusplus) | 19 #ifdef __cplusplus |
| 20 extern "C" { | 20 extern "C" { |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #define WEBP_ENCODER_ABI_VERSION 0x0201 // MAJOR(8b) + MINOR(8b) | 23 #define WEBP_ENCODER_ABI_VERSION 0x0202 // MAJOR(8b) + MINOR(8b) |
| 24 | 24 |
| 25 // Note: forward declaring enumerations is not allowed in (strict) C and C++, | 25 // Note: forward declaring enumerations is not allowed in (strict) C and C++, |
| 26 // the types are left here for reference. | 26 // the types are left here for reference. |
| 27 // typedef enum WebPImageHint WebPImageHint; | 27 // typedef enum WebPImageHint WebPImageHint; |
| 28 // typedef enum WebPEncCSP WebPEncCSP; | 28 // typedef enum WebPEncCSP WebPEncCSP; |
| 29 // typedef enum WebPPreset WebPPreset; | 29 // typedef enum WebPPreset WebPPreset; |
| 30 // typedef enum WebPEncodingError WebPEncodingError; | 30 // typedef enum WebPEncodingError WebPEncodingError; |
| 31 typedef struct WebPConfig WebPConfig; | 31 typedef struct WebPConfig WebPConfig; |
| 32 typedef struct WebPPicture WebPPicture; // main structure for I/O | 32 typedef struct WebPPicture WebPPicture; // main structure for I/O |
| 33 typedef struct WebPAuxStats WebPAuxStats; | 33 typedef struct WebPAuxStats WebPAuxStats; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, | 110 int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, |
| 111 // 1 = compressed with WebP lossless). Default is 1. | 111 // 1 = compressed with WebP lossless). Default is 1. |
| 112 int alpha_filtering; // Predictive filtering method for alpha plane. | 112 int alpha_filtering; // Predictive filtering method for alpha plane. |
| 113 // 0: none, 1: fast, 2: best. Default if 1. | 113 // 0: none, 1: fast, 2: best. Default if 1. |
| 114 int alpha_quality; // Between 0 (smallest size) and 100 (lossless). | 114 int alpha_quality; // Between 0 (smallest size) and 100 (lossless). |
| 115 // Default is 100. | 115 // Default is 100. |
| 116 int pass; // number of entropy-analysis passes (in [1..10]). | 116 int pass; // number of entropy-analysis passes (in [1..10]). |
| 117 | 117 |
| 118 int show_compressed; // if true, export the compressed picture back. | 118 int show_compressed; // if true, export the compressed picture back. |
| 119 // In-loop filtering is not applied. | 119 // In-loop filtering is not applied. |
| 120 int preprocessing; // preprocessing filter (0=none, 1=segment-smooth) | 120 int preprocessing; // preprocessing filter: |
| 121 // 0=none, 1=segment-smooth, 2=pseudo-random dithering |
| 121 int partitions; // log2(number of token partitions) in [0..3]. Default | 122 int partitions; // log2(number of token partitions) in [0..3]. Default |
| 122 // is set to 0 for easier progressive decoding. | 123 // is set to 0 for easier progressive decoding. |
| 123 int partition_limit; // quality degradation allowed to fit the 512k limit | 124 int partition_limit; // quality degradation allowed to fit the 512k limit |
| 124 // on prediction modes coding (0: no degradation, | 125 // on prediction modes coding (0: no degradation, |
| 125 // 100: maximum possible degradation). | 126 // 100: maximum possible degradation). |
| 126 int emulate_jpeg_size; // If true, compression parameters will be remapped | 127 int emulate_jpeg_size; // If true, compression parameters will be remapped |
| 127 // to better match the expected output size from | 128 // to better match the expected output size from |
| 128 // JPEG compression. Generally, the output size will | 129 // JPEG compression. Generally, the output size will |
| 129 // be similar but the degradation will be lower. | 130 // be similar but the degradation will be lower. |
| 130 int thread_level; // If non-zero, try and use multi-threaded encoding. | 131 int thread_level; // If non-zero, try and use multi-threaded encoding. |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); | 437 WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); |
| 437 | 438 |
| 438 // Converts picture->argb data to the YUVA format specified by 'colorspace'. | 439 // Converts picture->argb data to the YUVA format specified by 'colorspace'. |
| 439 // Upon return, picture->use_argb is set to false. The presence of real | 440 // Upon return, picture->use_argb is set to false. The presence of real |
| 440 // non-opaque transparent values is detected, and 'colorspace' will be | 441 // non-opaque transparent values is detected, and 'colorspace' will be |
| 441 // adjusted accordingly. Note that this method is lossy. | 442 // adjusted accordingly. Note that this method is lossy. |
| 442 // Returns false in case of error. | 443 // Returns false in case of error. |
| 443 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, | 444 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, |
| 444 WebPEncCSP colorspace); | 445 WebPEncCSP colorspace); |
| 445 | 446 |
| 447 // Same as WebPPictureARGBToYUVA(), but the conversion is done using |
| 448 // pseudo-random dithering with a strength 'dithering' between |
| 449 // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful |
| 450 // for photographic picture. |
| 451 WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( |
| 452 WebPPicture* picture, WebPEncCSP colorspace, float dithering); |
| 453 |
| 446 // Converts picture->yuv to picture->argb and sets picture->use_argb to true. | 454 // Converts picture->yuv to picture->argb and sets picture->use_argb to true. |
| 447 // The input format must be YUV_420 or YUV_420A. | 455 // The input format must be YUV_420 or YUV_420A. |
| 448 // Note that the use of this method is discouraged if one has access to the | 456 // Note that the use of this method is discouraged if one has access to the |
| 449 // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the | 457 // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the |
| 450 // conversion from YUV420 to ARGB incurs a small loss too. | 458 // conversion from YUV420 to ARGB incurs a small loss too. |
| 451 // Returns false in case of error. | 459 // Returns false in case of error. |
| 452 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); | 460 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); |
| 453 | 461 |
| 454 // Helper function: given a width x height plane of YUV(A) samples | 462 // Helper function: given a width x height plane of YUV(A) samples |
| 455 // (with stride 'stride'), clean-up the YUV samples under fully transparent | 463 // (with stride 'stride'), clean-up the YUV samples under fully transparent |
| 456 // area, to help compressibility (no guarantee, though). | 464 // area, to help compressibility (no guarantee, though). |
| 457 WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); | 465 WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); |
| 458 | 466 |
| 459 // Scan the picture 'picture' for the presence of non fully opaque alpha values. | 467 // Scan the picture 'picture' for the presence of non fully opaque alpha values. |
| 460 // Returns true in such case. Otherwise returns false (indicating that the | 468 // Returns true in such case. Otherwise returns false (indicating that the |
| 461 // alpha plane can be ignored altogether e.g.). | 469 // alpha plane can be ignored altogether e.g.). |
| 462 WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); | 470 WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); |
| 463 | 471 |
| 472 // Remove the transparency information (if present) by blending the color with |
| 473 // the background color 'background_rgb' (specified as 24bit RGB triplet). |
| 474 // After this call, all alpha values are reset to 0xff. |
| 475 WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); |
| 476 |
| 464 //------------------------------------------------------------------------------ | 477 //------------------------------------------------------------------------------ |
| 465 // Main call | 478 // Main call |
| 466 | 479 |
| 467 // Main encoding call, after config and picture have been initialized. | 480 // Main encoding call, after config and picture have been initialized. |
| 468 // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), | 481 // 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), |
| 469 // and the 'config' object must be a valid one. | 482 // and the 'config' object must be a valid one. |
| 470 // Returns false in case of error, true otherwise. | 483 // Returns false in case of error, true otherwise. |
| 471 // In case of error, picture->error_code is updated accordingly. | 484 // In case of error, picture->error_code is updated accordingly. |
| 472 // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending | 485 // 'picture' can hold the source samples in both YUV(A) or ARGB input, depending |
| 473 // on the value of 'picture->use_argb'. It is highly recommended to use | 486 // on the value of 'picture->use_argb'. It is highly recommended to use |
| 474 // the former for lossy encoding, and the latter for lossless encoding | 487 // the former for lossy encoding, and the latter for lossless encoding |
| 475 // (when config.lossless is true). Automatic conversion from one format to | 488 // (when config.lossless is true). Automatic conversion from one format to |
| 476 // another is provided but they both incur some loss. | 489 // another is provided but they both incur some loss. |
| 477 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); | 490 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); |
| 478 | 491 |
| 479 //------------------------------------------------------------------------------ | 492 //------------------------------------------------------------------------------ |
| 480 | 493 |
| 481 #if defined(__cplusplus) || defined(c_plusplus) | 494 #ifdef __cplusplus |
| 482 } // extern "C" | 495 } // extern "C" |
| 483 #endif | 496 #endif |
| 484 | 497 |
| 485 #endif /* WEBP_WEBP_ENCODE_H_ */ | 498 #endif /* WEBP_WEBP_ENCODE_H_ */ |
| OLD | NEW |