OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 Google Inc. |
| 2 // |
| 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- |
| 7 // |
| 8 // Main decoding functions for WEBP images. |
| 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 |
| 12 #ifndef WEBP_DECODE_WEBP_DECODE_H_ |
| 13 #define WEBP_DECODE_WEBP_DECODE_H_ |
| 14 |
| 15 #ifndef _MSC_VER |
| 16 #include <inttypes.h> |
| 17 #else |
| 18 typedef signed char int8_t; |
| 19 typedef unsigned char uint8_t; |
| 20 typedef signed short int16_t; |
| 21 typedef unsigned short uint16_t; |
| 22 typedef signed int int32_t; |
| 23 typedef unsigned int uint32_t; |
| 24 typedef unsigned long long int uint64_t; |
| 25 #define inline __forceinline |
| 26 #endif |
| 27 |
| 28 |
| 29 #if defined(__cplusplus) || defined(c_plusplus) |
| 30 extern "C" { |
| 31 #endif |
| 32 |
| 33 // Retrieve basic header information: width, height. |
| 34 // This function will also validate the header and return 0 in |
| 35 // case of formatting error. |
| 36 // Pointers *width/*height can be passed NULL if deemed irrelevant. |
| 37 int WebPGetInfo(const uint8_t* data, uint32_t data_size, |
| 38 int *width, int *height); |
| 39 |
| 40 // Decodes WEBP images pointed to by *data and returns RGB samples, along |
| 41 // with the dimensions in *width and *height. |
| 42 // The returned pointer should be deleted calling free(). |
| 43 // Returns NULL in case of error. |
| 44 uint8_t* WebPDecodeRGB(const uint8_t* data, uint32_t data_size, |
| 45 int *width, int *height); |
| 46 |
| 47 // Same as WebPDecodeRGB, but returning RGBA data. |
| 48 uint8_t* WebPDecodeRGBA(const uint8_t* data, uint32_t data_size, |
| 49 int *width, int *height); |
| 50 |
| 51 // This variant decode to BGR instead of RGB. |
| 52 uint8_t* WebPDecodeBGR(const uint8_t* data, uint32_t data_size, |
| 53 int *width, int *height); |
| 54 // This variant decodes to BGRA instead of RGBA. |
| 55 uint8_t* WebPDecodeBGRA(const uint8_t* data, uint32_t data_size, |
| 56 int *width, int *height); |
| 57 |
| 58 // Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is |
| 59 // the Y samples buffer. Upon return, *u and *v will point to the U and V |
| 60 // chroma data. These U and V buffers need NOT be free()'d, unlike the returned |
| 61 // Y luma one. The dimension of the U and V planes are both (*width + 1) / 2 |
| 62 // and (*height + 1)/ 2. |
| 63 // Upon return, the Y buffer has a stride returned as '*stride', while U and V |
| 64 // have a common stride returned as '*uv_stride'. |
| 65 // Return NULL in case of error. |
| 66 // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr |
| 67 uint8_t* WebPDecodeYUV(const uint8_t* data, uint32_t data_size, |
| 68 int *width, int *height, uint8_t** u, uint8_t** v, |
| 69 int *stride, int* uv_stride); |
| 70 |
| 71 // These three functions are variants of the above ones, that decode the image |
| 72 // directly into a pre-allocated buffer 'output_buffer'. The maximum storage |
| 73 // available in this buffer is indicated by 'output_buffer_size'. If this |
| 74 // storage is not sufficient (or an error occurred), NULL is returned. |
| 75 // Otherwise, output_buffer is returned, for convenience. |
| 76 // The parameter 'output_stride' specifies the distance (in bytes) |
| 77 // between scanlines. Hence, output_buffer_size is expected to be at least |
| 78 // output_stride x picture-height. |
| 79 uint8_t* WebPDecodeRGBInto(const uint8_t* data, uint32_t data_size, |
| 80 uint8_t* output_buffer, int output_buffer_size, |
| 81 int output_stride); |
| 82 uint8_t* WebPDecodeRGBAInto(const uint8_t* data, uint32_t data_size, |
| 83 uint8_t* output_buffer, int output_buffer_size, |
| 84 int output_stride); |
| 85 // BGR variants |
| 86 uint8_t* WebPDecodeBGRInto(const uint8_t* data, uint32_t data_size, |
| 87 uint8_t* output_buffer, int output_buffer_size, |
| 88 int output_stride); |
| 89 uint8_t* WebPDecodeBGRAInto(const uint8_t* data, uint32_t data_size, |
| 90 uint8_t* output_buffer, int output_buffer_size, |
| 91 int output_stride); |
| 92 |
| 93 // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly |
| 94 // into pre-allocated luma/chroma plane buffers. This function requires the |
| 95 // strides to be passed: one for the luma plane and one for each of the |
| 96 // chroma ones. The size of each plane buffer is passed as 'luma_size', |
| 97 // 'u_size' and 'v_size' respectively. |
| 98 // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred |
| 99 // during decoding (or because some buffers were found to be too small). |
| 100 uint8_t* WebPDecodeYUVInto(const uint8_t* data, uint32_t data_size, |
| 101 uint8_t* luma, int luma_size, int luma_stride, |
| 102 uint8_t* u, int u_size, int u_stride, |
| 103 uint8_t* v, int v_size, int v_stride); |
| 104 |
| 105 //----------------------------------------------------------------------------- |
| 106 |
| 107 #if defined(__cplusplus) || defined(c_plusplus) |
| 108 } // extern "C" |
| 109 #endif |
| 110 |
| 111 #endif // WEBP_DECODE_WEBP_DECODE_H_ |
OLD | NEW |