| 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 // Internal header: WebP decoding parameters and custom IO on buffer | 10 // Internal header: WebP decoding parameters and custom IO on buffer |
| 11 // | 11 // |
| 12 // Author: somnath@google.com (Somnath Banerjee) | 12 // Author: somnath@google.com (Somnath Banerjee) |
| 13 | 13 |
| 14 #ifndef WEBP_DEC_WEBPI_H_ | 14 #ifndef WEBP_DEC_WEBPI_H_ |
| 15 #define WEBP_DEC_WEBPI_H_ | 15 #define WEBP_DEC_WEBPI_H_ |
| 16 | 16 |
| 17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
| 18 extern "C" { | 18 extern "C" { |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #include "../utils/rescaler.h" | 21 #include "../utils/rescaler_utils.h" |
| 22 #include "./decode_vp8.h" | 22 #include "./vp8_dec.h" |
| 23 | 23 |
| 24 //------------------------------------------------------------------------------ | 24 //------------------------------------------------------------------------------ |
| 25 // WebPDecParams: Decoding output parameters. Transient internal object. | 25 // WebPDecParams: Decoding output parameters. Transient internal object. |
| 26 | 26 |
| 27 typedef struct WebPDecParams WebPDecParams; | 27 typedef struct WebPDecParams WebPDecParams; |
| 28 typedef int (*OutputFunc)(const VP8Io* const io, WebPDecParams* const p); | 28 typedef int (*OutputFunc)(const VP8Io* const io, WebPDecParams* const p); |
| 29 typedef int (*OutputAlphaFunc)(const VP8Io* const io, WebPDecParams* const p, | 29 typedef int (*OutputAlphaFunc)(const VP8Io* const io, WebPDecParams* const p, |
| 30 int expected_num_out_lines); | 30 int expected_num_out_lines); |
| 31 typedef int (*OutputRowFunc)(WebPDecParams* const p, int y_pos, | 31 typedef int (*OutputRowFunc)(WebPDecParams* const p, int y_pos, |
| 32 int max_out_lines); | 32 int max_out_lines); |
| 33 | 33 |
| 34 struct WebPDecParams { | 34 struct WebPDecParams { |
| 35 WebPDecBuffer* output; // output buffer. | 35 WebPDecBuffer* output; // output buffer. |
| 36 uint8_t* tmp_y, *tmp_u, *tmp_v; // cache for the fancy upsampler | 36 uint8_t* tmp_y, *tmp_u, *tmp_v; // cache for the fancy upsampler |
| 37 // or used for tmp rescaling | 37 // or used for tmp rescaling |
| 38 | 38 |
| 39 int last_y; // coordinate of the line that was last output | 39 int last_y; // coordinate of the line that was last output |
| 40 const WebPDecoderOptions* options; // if not NULL, use alt decoding features | 40 const WebPDecoderOptions* options; // if not NULL, use alt decoding features |
| 41 // rescalers | 41 |
| 42 WebPRescaler scaler_y, scaler_u, scaler_v, scaler_a; | 42 WebPRescaler* scaler_y, *scaler_u, *scaler_v, *scaler_a; // rescalers |
| 43 void* memory; // overall scratch memory for the output work. | 43 void* memory; // overall scratch memory for the output work. |
| 44 | 44 |
| 45 OutputFunc emit; // output RGB or YUV samples | 45 OutputFunc emit; // output RGB or YUV samples |
| 46 OutputAlphaFunc emit_alpha; // output alpha channel | 46 OutputAlphaFunc emit_alpha; // output alpha channel |
| 47 OutputRowFunc emit_alpha_row; // output one line of rescaled alpha values | 47 OutputRowFunc emit_alpha_row; // output one line of rescaled alpha values |
| 48 | |
| 49 WebPDecBuffer* final_output; // In case the user supplied a slow-memory | |
| 50 // output, we decode image in temporary buffer | |
| 51 // (this::output) and copy it here. | |
| 52 WebPDecBuffer tmp_buffer; // this::output will point to this one in case | |
| 53 // of slow memory. | |
| 54 }; | 48 }; |
| 55 | 49 |
| 56 // Should be called first, before any use of the WebPDecParams object. | 50 // Should be called first, before any use of the WebPDecParams object. |
| 57 void WebPResetDecParams(WebPDecParams* const params); | 51 void WebPResetDecParams(WebPDecParams* const params); |
| 58 | 52 |
| 59 // Delete all memory (after an error occurred, for instance) | |
| 60 void WebPFreeDecParams(WebPDecParams* const params); | |
| 61 | |
| 62 //------------------------------------------------------------------------------ | 53 //------------------------------------------------------------------------------ |
| 63 // Header parsing helpers | 54 // Header parsing helpers |
| 64 | 55 |
| 65 // Structure storing a description of the RIFF headers. | 56 // Structure storing a description of the RIFF headers. |
| 66 typedef struct { | 57 typedef struct { |
| 67 const uint8_t* data; // input buffer | 58 const uint8_t* data; // input buffer |
| 68 size_t data_size; // input buffer size | 59 size_t data_size; // input buffer size |
| 69 int have_all_data; // true if all data is known to be available | 60 int have_all_data; // true if all data is known to be available |
| 70 size_t offset; // offset to main data chunk (VP8 or VP8L) | 61 size_t offset; // offset to main data chunk (VP8 or VP8L) |
| 71 const uint8_t* alpha_data; // points to alpha chunk (if present) | 62 const uint8_t* alpha_data; // points to alpha chunk (if present) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 int WebPAvoidSlowMemory(const WebPDecBuffer* const output, | 124 int WebPAvoidSlowMemory(const WebPDecBuffer* const output, |
| 134 const WebPBitstreamFeatures* const features); | 125 const WebPBitstreamFeatures* const features); |
| 135 | 126 |
| 136 //------------------------------------------------------------------------------ | 127 //------------------------------------------------------------------------------ |
| 137 | 128 |
| 138 #ifdef __cplusplus | 129 #ifdef __cplusplus |
| 139 } // extern "C" | 130 } // extern "C" |
| 140 #endif | 131 #endif |
| 141 | 132 |
| 142 #endif /* WEBP_DEC_WEBPI_H_ */ | 133 #endif /* WEBP_DEC_WEBPI_H_ */ |
| OLD | NEW |