| OLD | NEW |
| 1 // Copyright 2010 Google Inc. | 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- | 6 // ----------------------------------------------------------------------------- |
| 7 // | 7 // |
| 8 // Low-level API for VP8 decoder | 8 // Low-level API for VP8 decoder |
| 9 // | 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 11 |
| 12 #ifndef WEBP_WEBP_DECODE_VP8_H_ | 12 #ifndef WEBP_WEBP_DECODE_VP8_H_ |
| 13 #define WEBP_WEBP_DECODE_VP8_H_ | 13 #define WEBP_WEBP_DECODE_VP8_H_ |
| 14 | 14 |
| 15 #include "./decode.h" | 15 #include "../webp/decode.h" |
| 16 | 16 |
| 17 #if defined(__cplusplus) || defined(c_plusplus) | 17 #if defined(__cplusplus) || defined(c_plusplus) |
| 18 extern "C" { | 18 extern "C" { |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 //------------------------------------------------------------------------------ | 21 //------------------------------------------------------------------------------ |
| 22 // Lower-level API | 22 // Lower-level API |
| 23 // | 23 // |
| 24 // These functions provide fine-grained control of the decoding process. | 24 // These functions provide fine-grained control of the decoding process. |
| 25 // The call flow should resemble: | 25 // The call flow should resemble: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Called just after block decoding is finished (or when an error occurred | 75 // Called just after block decoding is finished (or when an error occurred |
| 76 // during put()). Is NOT called if setup() failed. | 76 // during put()). Is NOT called if setup() failed. |
| 77 VP8IoTeardownHook teardown; | 77 VP8IoTeardownHook teardown; |
| 78 | 78 |
| 79 // this is a recommendation for the user-side yuv->rgb converter. This flag | 79 // this is a recommendation for the user-side yuv->rgb converter. This flag |
| 80 // is set when calling setup() hook and can be overwritten by it. It then | 80 // is set when calling setup() hook and can be overwritten by it. It then |
| 81 // can be taken into consideration during the put() method. | 81 // can be taken into consideration during the put() method. |
| 82 int fancy_upsampling; | 82 int fancy_upsampling; |
| 83 | 83 |
| 84 // Input buffer. | 84 // Input buffer. |
| 85 uint32_t data_size; | 85 size_t data_size; |
| 86 const uint8_t* data; | 86 const uint8_t* data; |
| 87 | 87 |
| 88 // If true, in-loop filtering will not be performed even if present in the | 88 // If true, in-loop filtering will not be performed even if present in the |
| 89 // bitstream. Switching off filtering may speed up decoding at the expense | 89 // bitstream. Switching off filtering may speed up decoding at the expense |
| 90 // of more visible blocking. Note that output will also be non-compliant | 90 // of more visible blocking. Note that output will also be non-compliant |
| 91 // with the VP8 specifications. | 91 // with the VP8 specifications. |
| 92 int bypass_filtering; | 92 int bypass_filtering; |
| 93 | 93 |
| 94 // Cropping parameters. | 94 // Cropping parameters. |
| 95 int use_cropping; | 95 int use_cropping; |
| 96 int crop_left, crop_right, crop_top, crop_bottom; | 96 int crop_left, crop_right, crop_top, crop_bottom; |
| 97 | 97 |
| 98 // Scaling parameters. | 98 // Scaling parameters. |
| 99 int use_scaling; | 99 int use_scaling; |
| 100 int scaled_width, scaled_height; | 100 int scaled_width, scaled_height; |
| 101 | 101 |
| 102 // pointer to the alpha data (if present) corresponding to the rows | 102 // If non NULL, pointer to the alpha data (if present) corresponding to the |
| 103 // start of the current row (That is: it is pre-offset by mb_y and takes |
| 104 // cropping into account). |
| 103 const uint8_t* a; | 105 const uint8_t* a; |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 // Internal, version-checked, entry point | 108 // Internal, version-checked, entry point |
| 107 WEBP_EXTERN(int) VP8InitIoInternal(VP8Io* const, int); | 109 int VP8InitIoInternal(VP8Io* const, int); |
| 108 | 110 |
| 109 // Set the custom IO function pointers and user-data. The setter for IO hooks | 111 // Set the custom IO function pointers and user-data. The setter for IO hooks |
| 110 // should be called before initiating incremental decoding. Returns true if | 112 // should be called before initiating incremental decoding. Returns true if |
| 111 // WebPIDecoder object is successfully modified, false otherwise. | 113 // WebPIDecoder object is successfully modified, false otherwise. |
| 112 WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec, | 114 int WebPISetIOHooks(WebPIDecoder* const idec, |
| 113 VP8IoPutHook put, | 115 VP8IoPutHook put, |
| 114 VP8IoSetupHook setup, | 116 VP8IoSetupHook setup, |
| 115 VP8IoTeardownHook teardown, | 117 VP8IoTeardownHook teardown, |
| 116 void* user_data); | 118 void* user_data); |
| 117 | 119 |
| 118 // Main decoding object. This is an opaque structure. | 120 // Main decoding object. This is an opaque structure. |
| 119 typedef struct VP8Decoder VP8Decoder; | 121 typedef struct VP8Decoder VP8Decoder; |
| 120 | 122 |
| 121 // Create a new decoder object. | 123 // Create a new decoder object. |
| 122 WEBP_EXTERN(VP8Decoder*) VP8New(void); | 124 VP8Decoder* VP8New(void); |
| 123 | 125 |
| 124 // Must be called to make sure 'io' is initialized properly. | 126 // Must be called to make sure 'io' is initialized properly. |
| 125 // Returns false in case of version mismatch. Upon such failure, no other | 127 // Returns false in case of version mismatch. Upon such failure, no other |
| 126 // decoding function should be called (VP8Decode, VP8GetHeaders, ...) | 128 // decoding function should be called (VP8Decode, VP8GetHeaders, ...) |
| 127 static inline int VP8InitIo(VP8Io* const io) { | 129 static WEBP_INLINE int VP8InitIo(VP8Io* const io) { |
| 128 return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION); | 130 return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION); |
| 129 } | 131 } |
| 130 | 132 |
| 131 // Start decoding a new picture. Returns true if ok. | 133 // Start decoding a new picture. Returns true if ok. |
| 132 WEBP_EXTERN(int) VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io); | 134 int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io); |
| 133 | 135 |
| 134 // Decode a picture. Will call VP8GetHeaders() if it wasn't done already. | 136 // Decode a picture. Will call VP8GetHeaders() if it wasn't done already. |
| 135 // Returns false in case of error. | 137 // Returns false in case of error. |
| 136 WEBP_EXTERN(int) VP8Decode(VP8Decoder* const dec, VP8Io* const io); | 138 int VP8Decode(VP8Decoder* const dec, VP8Io* const io); |
| 137 | 139 |
| 138 // Return current status of the decoder: | 140 // Return current status of the decoder: |
| 139 WEBP_EXTERN(VP8StatusCode) VP8Status(VP8Decoder* const dec); | 141 VP8StatusCode VP8Status(VP8Decoder* const dec); |
| 140 | 142 |
| 141 // return readable string corresponding to the last status. | 143 // return readable string corresponding to the last status. |
| 142 WEBP_EXTERN(const char*) VP8StatusMessage(VP8Decoder* const dec); | 144 const char* VP8StatusMessage(VP8Decoder* const dec); |
| 143 | 145 |
| 144 // Resets the decoder in its initial state, reclaiming memory. | 146 // Resets the decoder in its initial state, reclaiming memory. |
| 145 // Not a mandatory call between calls to VP8Decode(). | 147 // Not a mandatory call between calls to VP8Decode(). |
| 146 WEBP_EXTERN(void) VP8Clear(VP8Decoder* const dec); | 148 void VP8Clear(VP8Decoder* const dec); |
| 147 | 149 |
| 148 // Destroy the decoder object. | 150 // Destroy the decoder object. |
| 149 WEBP_EXTERN(void) VP8Delete(VP8Decoder* const dec); | 151 void VP8Delete(VP8Decoder* const dec); |
| 150 | 152 |
| 151 //------------------------------------------------------------------------------ | 153 //------------------------------------------------------------------------------ |
| 154 // Miscellaneous VP8/VP8L bitstream probing functions. |
| 155 |
| 156 // Returns true if the next 3 bytes in data contain the VP8 signature. |
| 157 WEBP_EXTERN(int) VP8CheckSignature(const uint8_t* const data, size_t data_size); |
| 158 |
| 159 // Validates the VP8 data-header and retrieves basic header information viz |
| 160 // width and height. Returns 0 in case of formatting error. *width/*height |
| 161 // can be passed NULL. |
| 162 WEBP_EXTERN(int) VP8GetInfo( |
| 163 const uint8_t* data, |
| 164 size_t data_size, // data available so far |
| 165 size_t chunk_size, // total data size expected in the chunk |
| 166 int* const width, int* const height); |
| 167 |
| 168 // Returns true if the next byte(s) in data is a VP8L signature. |
| 169 WEBP_EXTERN(int) VP8LCheckSignature(const uint8_t* const data, size_t size); |
| 170 |
| 171 // Validates the VP8L data-header and retrieves basic header information viz |
| 172 // width, height and alpha. Returns 0 in case of formatting error. |
| 173 // width/height/has_alpha can be passed NULL. |
| 174 WEBP_EXTERN(int) VP8LGetInfo( |
| 175 const uint8_t* data, size_t data_size, // data available so far |
| 176 int* const width, int* const height, int* const has_alpha); |
| 152 | 177 |
| 153 #if defined(__cplusplus) || defined(c_plusplus) | 178 #if defined(__cplusplus) || defined(c_plusplus) |
| 154 } // extern "C" | 179 } // extern "C" |
| 155 #endif | 180 #endif |
| 156 | 181 |
| 157 #endif /* WEBP_WEBP_DECODE_VP8_H_ */ | 182 #endif /* WEBP_WEBP_DECODE_VP8_H_ */ |
| OLD | NEW |