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

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

Issue 1546003002: libwebp: update to 0.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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/demux.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 2010 Google Inc. All Rights Reserved. 1 // Copyright 2010 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 // Main decoding functions for WebP images. 10 // Main decoding functions for WebP images.
11 // 11 //
12 // Author: Skal (pascal.massimino@gmail.com) 12 // Author: Skal (pascal.massimino@gmail.com)
13 13
14 #ifndef WEBP_WEBP_DECODE_H_ 14 #ifndef WEBP_WEBP_DECODE_H_
15 #define WEBP_WEBP_DECODE_H_ 15 #define WEBP_WEBP_DECODE_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_DECODER_ABI_VERSION 0x0203 // MAJOR(8b) + MINOR(8b) 23 #define WEBP_DECODER_ABI_VERSION 0x0208 // 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 VP8StatusCode VP8StatusCode; 27 // typedef enum VP8StatusCode VP8StatusCode;
28 // typedef enum WEBP_CSP_MODE WEBP_CSP_MODE; 28 // typedef enum WEBP_CSP_MODE WEBP_CSP_MODE;
29 typedef struct WebPRGBABuffer WebPRGBABuffer; 29 typedef struct WebPRGBABuffer WebPRGBABuffer;
30 typedef struct WebPYUVABuffer WebPYUVABuffer; 30 typedef struct WebPYUVABuffer WebPYUVABuffer;
31 typedef struct WebPDecBuffer WebPDecBuffer; 31 typedef struct WebPDecBuffer WebPDecBuffer;
32 typedef struct WebPIDecoder WebPIDecoder; 32 typedef struct WebPIDecoder WebPIDecoder;
33 typedef struct WebPBitstreamFeatures WebPBitstreamFeatures; 33 typedef struct WebPBitstreamFeatures WebPBitstreamFeatures;
34 typedef struct WebPDecoderOptions WebPDecoderOptions; 34 typedef struct WebPDecoderOptions WebPDecoderOptions;
35 typedef struct WebPDecoderConfig WebPDecoderConfig; 35 typedef struct WebPDecoderConfig WebPDecoderConfig;
36 36
37 // Return the decoder's version number, packed in hexadecimal using 8bits for 37 // Return the decoder's version number, packed in hexadecimal using 8bits for
38 // each of major/minor/revision. E.g: v2.5.7 is 0x020507. 38 // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
39 WEBP_EXTERN(int) WebPGetDecoderVersion(void); 39 WEBP_EXTERN(int) WebPGetDecoderVersion(void);
40 40
41 // Retrieve basic header information: width, height. 41 // Retrieve basic header information: width, height.
42 // This function will also validate the header and return 0 in 42 // This function will also validate the header and return 0 in
43 // case of formatting error. 43 // case of formatting error.
44 // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. 44 // Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
45 WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, 45 WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size,
46 int* width, int* height); 46 int* width, int* height);
47 47
48 // Decodes WebP images pointed to by 'data' and returns RGBA samples, along 48 // Decodes WebP images pointed to by 'data' and returns RGBA samples, along
49 // with the dimensions in *width and *height. The ordering of samples in 49 // with the dimensions in *width and *height. The ordering of samples in
50 // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). 50 // memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
51 // The returned pointer should be deleted calling free(). 51 // The returned pointer should be deleted calling WebPFree().
52 // Returns NULL in case of error. 52 // Returns NULL in case of error.
53 WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, 53 WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size,
54 int* width, int* height); 54 int* width, int* height);
55 55
56 // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. 56 // Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
57 WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, 57 WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size,
58 int* width, int* height); 58 int* width, int* height);
59 59
60 // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. 60 // Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
61 WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, 61 WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size,
62 int* width, int* height); 62 int* width, int* height);
63 63
64 // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. 64 // Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
65 // If the bitstream contains transparency, it is ignored. 65 // If the bitstream contains transparency, it is ignored.
66 WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, 66 WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size,
67 int* width, int* height); 67 int* width, int* height);
68 68
69 // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. 69 // Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
70 WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, 70 WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size,
71 int* width, int* height); 71 int* width, int* height);
72 72
73 73
74 // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer 74 // Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
75 // returned is the Y samples buffer. Upon return, *u and *v will point to 75 // returned is the Y samples buffer. Upon return, *u and *v will point to
76 // the U and V chroma data. These U and V buffers need NOT be free()'d, 76 // the U and V chroma data. These U and V buffers need NOT be passed to
77 // unlike the returned Y luma one. The dimension of the U and V planes 77 // WebPFree(), unlike the returned Y luma one. The dimension of the U and V
78 // are both (*width + 1) / 2 and (*height + 1)/ 2. 78 // planes are both (*width + 1) / 2 and (*height + 1)/ 2.
79 // Upon return, the Y buffer has a stride returned as '*stride', while U and V 79 // Upon return, the Y buffer has a stride returned as '*stride', while U and V
80 // have a common stride returned as '*uv_stride'. 80 // have a common stride returned as '*uv_stride'.
81 // Return NULL in case of error. 81 // Return NULL in case of error.
82 // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr 82 // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr
83 WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, 83 WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size,
84 int* width, int* height, 84 int* width, int* height,
85 uint8_t** u, uint8_t** v, 85 uint8_t** u, uint8_t** v,
86 int* stride, int* uv_stride); 86 int* stride, int* uv_stride);
87 87
88 // Releases memory returned by the WebPDecode*() functions above.
89 WEBP_EXTERN(void) WebPFree(void* ptr);
90
88 // These five functions are variants of the above ones, that decode the image 91 // These five functions are variants of the above ones, that decode the image
89 // directly into a pre-allocated buffer 'output_buffer'. The maximum storage 92 // directly into a pre-allocated buffer 'output_buffer'. The maximum storage
90 // available in this buffer is indicated by 'output_buffer_size'. If this 93 // available in this buffer is indicated by 'output_buffer_size'. If this
91 // storage is not sufficient (or an error occurred), NULL is returned. 94 // storage is not sufficient (or an error occurred), NULL is returned.
92 // Otherwise, output_buffer is returned, for convenience. 95 // Otherwise, output_buffer is returned, for convenience.
93 // The parameter 'output_stride' specifies the distance (in bytes) 96 // The parameter 'output_stride' specifies the distance (in bytes)
94 // between scanlines. Hence, output_buffer_size is expected to be at least 97 // between scanlines. Hence, output_buffer_size is expected to be at least
95 // output_stride x picture-height. 98 // output_stride x picture-height.
96 WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( 99 WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
97 const uint8_t* data, size_t data_size, 100 const uint8_t* data, size_t data_size,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 */ 402 */
400 403
401 // Features gathered from the bitstream 404 // Features gathered from the bitstream
402 struct WebPBitstreamFeatures { 405 struct WebPBitstreamFeatures {
403 int width; // Width in pixels, as read from the bitstream. 406 int width; // Width in pixels, as read from the bitstream.
404 int height; // Height in pixels, as read from the bitstream. 407 int height; // Height in pixels, as read from the bitstream.
405 int has_alpha; // True if the bitstream contains an alpha channel. 408 int has_alpha; // True if the bitstream contains an alpha channel.
406 int has_animation; // True if the bitstream is an animation. 409 int has_animation; // True if the bitstream is an animation.
407 int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless 410 int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless
408 411
409 // Unused for now: 412 uint32_t pad[5]; // padding for later use
410 int no_incremental_decoding; // if true, using incremental decoding is not
411 // recommended.
412 int rotate; // TODO(later)
413 int uv_sampling; // should be 0 for now. TODO(later)
414 uint32_t pad[2]; // padding for later use
415 }; 413 };
416 414
417 // Internal, version-checked, entry point 415 // Internal, version-checked, entry point
418 WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( 416 WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
419 const uint8_t*, size_t, WebPBitstreamFeatures*, int); 417 const uint8_t*, size_t, WebPBitstreamFeatures*, int);
420 418
421 // Retrieve features from the bitstream. The *features structure is filled 419 // Retrieve features from the bitstream. The *features structure is filled
422 // with information gathered from the bitstream. 420 // with information gathered from the bitstream.
423 // Returns VP8_STATUS_OK when the features are successfully retrieved. Returns 421 // Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
424 // VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the 422 // VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
(...skipping 10 matching lines...) Expand all
435 int bypass_filtering; // if true, skip the in-loop filtering 433 int bypass_filtering; // if true, skip the in-loop filtering
436 int no_fancy_upsampling; // if true, use faster pointwise upsampler 434 int no_fancy_upsampling; // if true, use faster pointwise upsampler
437 int use_cropping; // if true, cropping is applied _first_ 435 int use_cropping; // if true, cropping is applied _first_
438 int crop_left, crop_top; // top-left position for cropping. 436 int crop_left, crop_top; // top-left position for cropping.
439 // Will be snapped to even values. 437 // Will be snapped to even values.
440 int crop_width, crop_height; // dimension of the cropping area 438 int crop_width, crop_height; // dimension of the cropping area
441 int use_scaling; // if true, scaling is applied _afterward_ 439 int use_scaling; // if true, scaling is applied _afterward_
442 int scaled_width, scaled_height; // final resolution 440 int scaled_width, scaled_height; // final resolution
443 int use_threads; // if true, use multi-threaded decoding 441 int use_threads; // if true, use multi-threaded decoding
444 int dithering_strength; // dithering strength (0=Off, 100=full) 442 int dithering_strength; // dithering strength (0=Off, 100=full)
445 #if WEBP_DECODER_ABI_VERSION > 0x0203
446 int flip; // flip output vertically 443 int flip; // flip output vertically
447 #endif
448 #if WEBP_DECODER_ABI_VERSION > 0x0204
449 int alpha_dithering_strength; // alpha dithering strength in [0..100] 444 int alpha_dithering_strength; // alpha dithering strength in [0..100]
450 #endif
451 445
452 // Unused for now:
453 int force_rotation; // forced rotation (to be applied _last_)
454 int no_enhancement; // if true, discard enhancement layer
455 #if WEBP_DECODER_ABI_VERSION < 0x0203
456 uint32_t pad[5]; // padding for later use 446 uint32_t pad[5]; // padding for later use
457 #elif WEBP_DECODER_ABI_VERSION < 0x0204
458 uint32_t pad[4]; // padding for later use
459 #else
460 uint32_t pad[3]; // padding for later use
461 #endif
462 }; 447 };
463 448
464 // Main object storing the configuration for advanced decoding. 449 // Main object storing the configuration for advanced decoding.
465 struct WebPDecoderConfig { 450 struct WebPDecoderConfig {
466 WebPBitstreamFeatures input; // Immutable bitstream features (optional) 451 WebPBitstreamFeatures input; // Immutable bitstream features (optional)
467 WebPDecBuffer output; // Output buffer (can point to external mem) 452 WebPDecBuffer output; // Output buffer (can point to external mem)
468 WebPDecoderOptions options; // Decoding options 453 WebPDecoderOptions options; // Decoding options
469 }; 454 };
470 455
471 // Internal, version-checked, entry point 456 // Internal, version-checked, entry point
(...skipping 22 matching lines...) Expand all
494 // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK 479 // 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
495 // if the decoding was successful). 480 // if the decoding was successful).
496 WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, 481 WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size,
497 WebPDecoderConfig* config); 482 WebPDecoderConfig* config);
498 483
499 #ifdef __cplusplus 484 #ifdef __cplusplus
500 } // extern "C" 485 } // extern "C"
501 #endif 486 #endif
502 487
503 #endif /* WEBP_WEBP_DECODE_H_ */ 488 #endif /* WEBP_WEBP_DECODE_H_ */
OLDNEW
« no previous file with comments | « third_party/libwebp/utils/utils.c ('k') | third_party/libwebp/webp/demux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698