Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Side by Side Diff: third_party/libwebp/webp/encode.h

Issue 2651883004: libwebp-0.6.0-rc1 (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libwebp/utils/utils.c ('k') | third_party/libwebp/webp/extras.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifdef __cplusplus 19 #ifdef __cplusplus
20 extern "C" { 20 extern "C" {
21 #endif 21 #endif
22 22
23 #define WEBP_ENCODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b) 23 #define WEBP_ENCODER_ABI_VERSION 0x020e // 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 int thread_level; // If non-zero, try and use multi-threaded encoding. 134 int thread_level; // If non-zero, try and use multi-threaded encoding.
135 int low_memory; // If set, reduce memory usage (but increase CPU use). 135 int low_memory; // If set, reduce memory usage (but increase CPU use).
136 136
137 int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off 137 int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off
138 // (default)]. 138 // (default)].
139 int exact; // if non-zero, preserve the exact RGB values under 139 int exact; // if non-zero, preserve the exact RGB values under
140 // transparent area. Otherwise, discard this invisible 140 // transparent area. Otherwise, discard this invisible
141 // RGB information for better compression. The default 141 // RGB information for better compression. The default
142 // value is 0. 142 // value is 0.
143 143
144 #ifdef WEBP_EXPERIMENTAL_FEATURES 144 int use_delta_palette; // reserved for future lossless feature
145 int delta_palettization; 145 int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion
146
146 uint32_t pad[2]; // padding for later use 147 uint32_t pad[2]; // padding for later use
147 #else
148 uint32_t pad[3]; // padding for later use
149 #endif // WEBP_EXPERIMENTAL_FEATURES
150 }; 148 };
151 149
152 // Enumerate some predefined settings for WebPConfig, depending on the type 150 // Enumerate some predefined settings for WebPConfig, depending on the type
153 // of source picture. These presets are used when calling WebPConfigPreset(). 151 // of source picture. These presets are used when calling WebPConfigPreset().
154 typedef enum WebPPreset { 152 typedef enum WebPPreset {
155 WEBP_PRESET_DEFAULT = 0, // default preset. 153 WEBP_PRESET_DEFAULT = 0, // default preset.
156 WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot 154 WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot
157 WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting 155 WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting
158 WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details 156 WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details
159 WEBP_PRESET_ICON, // small-sized colorful images 157 WEBP_PRESET_ICON, // small-sized colorful images
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Besides memory (which is reclaimed) all other fields of 'picture' are 379 // Besides memory (which is reclaimed) all other fields of 'picture' are
382 // preserved. 380 // preserved.
383 WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); 381 WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
384 382
385 // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst 383 // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst
386 // will fully own the copied pixels (this is not a view). The 'dst' picture need 384 // will fully own the copied pixels (this is not a view). The 'dst' picture need
387 // not be initialized as its content is overwritten. 385 // not be initialized as its content is overwritten.
388 // Returns false in case of memory allocation error. 386 // Returns false in case of memory allocation error.
389 WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); 387 WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
390 388
389 // Compute the single distortion for packed planes of samples.
390 // 'src' will be compared to 'ref', and the raw distortion stored into
391 // '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
392 // stored in '*result'.
393 // 'x_step' is the horizontal stride (in bytes) between samples.
394 // 'src/ref_stride' is the byte distance between rows.
395 // Returns false in case of error (bad parameter, memory allocation error, ...).
396 WEBP_EXTERN(int) WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
397 const uint8_t* ref, size_t ref_stride,
398 int width, int height,
399 size_t x_step,
400 int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
401 float* distortion, float* result);
402
391 // Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results 403 // 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. 404 // are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
393 // Returns false in case of error (src and ref don't have same dimension, ...) 405 // always performed using ARGB samples. Hence if the input is YUV(A), the
406 // picture will be internally converted to ARGB (just for the measurement).
394 // Warning: this function is rather CPU-intensive. 407 // Warning: this function is rather CPU-intensive.
395 WEBP_EXTERN(int) WebPPictureDistortion( 408 WEBP_EXTERN(int) WebPPictureDistortion(
396 const WebPPicture* src, const WebPPicture* ref, 409 const WebPPicture* src, const WebPPicture* ref,
397 int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM 410 int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
398 float result[5]); 411 float result[5]);
399 412
400 // self-crops a picture to the rectangle defined by top/left/width/height. 413 // self-crops a picture to the rectangle defined by top/left/width/height.
401 // Returns false in case of memory allocation error, or if the rectangle is 414 // Returns false in case of memory allocation error, or if the rectangle is
402 // outside of the source picture. 415 // outside of the source picture.
403 // The rectangle for the view is defined by the top-left corner pixel 416 // The rectangle for the view is defined by the top-left corner pixel
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, 479 WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
467 WebPEncCSP /*colorspace = WEBP_YUV420*/); 480 WebPEncCSP /*colorspace = WEBP_YUV420*/);
468 481
469 // Same as WebPPictureARGBToYUVA(), but the conversion is done using 482 // Same as WebPPictureARGBToYUVA(), but the conversion is done using
470 // pseudo-random dithering with a strength 'dithering' between 483 // pseudo-random dithering with a strength 'dithering' between
471 // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful 484 // 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
472 // for photographic picture. 485 // for photographic picture.
473 WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( 486 WEBP_EXTERN(int) WebPPictureARGBToYUVADithered(
474 WebPPicture* picture, WebPEncCSP colorspace, float dithering); 487 WebPPicture* picture, WebPEncCSP colorspace, float dithering);
475 488
476 // Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion. 489 // Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
477 // Downsampling is handled with extra care in case of color clipping. This 490 // Downsampling is handled with extra care in case of color clipping. This
478 // method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better 491 // method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
479 // YUV representation. 492 // and sharper YUV representation.
480 // Returns false in case of error. 493 // Returns false in case of error.
494 WEBP_EXTERN(int) WebPPictureSharpARGBToYUVA(WebPPicture* picture);
495 // kept for backward compatibility:
481 WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture); 496 WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture);
482 497
483 // Converts picture->yuv to picture->argb and sets picture->use_argb to true. 498 // Converts picture->yuv to picture->argb and sets picture->use_argb to true.
484 // The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to 499 // The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
485 // ARGB incurs a small loss too. 500 // ARGB incurs a small loss too.
486 // Note that the use of this colorspace is discouraged if one has access to the 501 // Note that the use of this colorspace is discouraged if one has access to the
487 // raw ARGB samples, since using YUV420 is comparatively lossy. 502 // raw ARGB samples, since using YUV420 is comparatively lossy.
488 // Returns false in case of error. 503 // Returns false in case of error.
489 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); 504 WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture);
490 505
(...skipping 27 matching lines...) Expand all
518 // another is provided but they both incur some loss. 533 // another is provided but they both incur some loss.
519 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); 534 WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);
520 535
521 //------------------------------------------------------------------------------ 536 //------------------------------------------------------------------------------
522 537
523 #ifdef __cplusplus 538 #ifdef __cplusplus
524 } // extern "C" 539 } // extern "C"
525 #endif 540 #endif
526 541
527 #endif /* WEBP_WEBP_ENCODE_H_ */ 542 #endif /* WEBP_WEBP_ENCODE_H_ */
OLDNEW
« no previous file with comments | « third_party/libwebp/utils/utils.c ('k') | third_party/libwebp/webp/extras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698