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 |
(...skipping 27 matching lines...) Expand all Loading... |
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 // rescalers |
42 WebPRescaler scaler_y, scaler_u, scaler_v, scaler_a; | 42 WebPRescaler scaler_y, scaler_u, scaler_v, scaler_a; |
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. |
48 }; | 54 }; |
49 | 55 |
50 // Should be called first, before any use of the WebPDecParams object. | 56 // Should be called first, before any use of the WebPDecParams object. |
51 void WebPResetDecParams(WebPDecParams* const params); | 57 void WebPResetDecParams(WebPDecParams* const params); |
52 | 58 |
| 59 // Delete all memory (after an error occurred, for instance) |
| 60 void WebPFreeDecParams(WebPDecParams* const params); |
| 61 |
53 //------------------------------------------------------------------------------ | 62 //------------------------------------------------------------------------------ |
54 // Header parsing helpers | 63 // Header parsing helpers |
55 | 64 |
56 // Structure storing a description of the RIFF headers. | 65 // Structure storing a description of the RIFF headers. |
57 typedef struct { | 66 typedef struct { |
58 const uint8_t* data; // input buffer | 67 const uint8_t* data; // input buffer |
59 size_t data_size; // input buffer size | 68 size_t data_size; // input buffer size |
60 int have_all_data; // true if all data is known to be available | 69 int have_all_data; // true if all data is known to be available |
61 size_t offset; // offset to main data chunk (VP8 or VP8L) | 70 size_t offset; // offset to main data chunk (VP8 or VP8L) |
62 const uint8_t* alpha_data; // points to alpha chunk (if present) | 71 const uint8_t* alpha_data; // points to alpha chunk (if present) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Also incorporates the options->flip flag to flip the buffer parameters if | 109 // Also incorporates the options->flip flag to flip the buffer parameters if |
101 // needed. | 110 // needed. |
102 VP8StatusCode WebPAllocateDecBuffer(int width, int height, | 111 VP8StatusCode WebPAllocateDecBuffer(int width, int height, |
103 const WebPDecoderOptions* const options, | 112 const WebPDecoderOptions* const options, |
104 WebPDecBuffer* const buffer); | 113 WebPDecBuffer* const buffer); |
105 | 114 |
106 // Flip buffer vertically by negating the various strides. | 115 // Flip buffer vertically by negating the various strides. |
107 VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer); | 116 VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer); |
108 | 117 |
109 // Copy 'src' into 'dst' buffer, making sure 'dst' is not marked as owner of the | 118 // Copy 'src' into 'dst' buffer, making sure 'dst' is not marked as owner of the |
110 // memory (still held by 'src'). | 119 // memory (still held by 'src'). No pixels are copied. |
111 void WebPCopyDecBuffer(const WebPDecBuffer* const src, | 120 void WebPCopyDecBuffer(const WebPDecBuffer* const src, |
112 WebPDecBuffer* const dst); | 121 WebPDecBuffer* const dst); |
113 | 122 |
114 // Copy and transfer ownership from src to dst (beware of parameter order!) | 123 // Copy and transfer ownership from src to dst (beware of parameter order!) |
115 void WebPGrabDecBuffer(WebPDecBuffer* const src, WebPDecBuffer* const dst); | 124 void WebPGrabDecBuffer(WebPDecBuffer* const src, WebPDecBuffer* const dst); |
116 | 125 |
| 126 // Copy pixels from 'src' into a *preallocated* 'dst' buffer. Returns |
| 127 // VP8_STATUS_INVALID_PARAM if the 'dst' is not set up correctly for the copy. |
| 128 VP8StatusCode WebPCopyDecBufferPixels(const WebPDecBuffer* const src, |
| 129 WebPDecBuffer* const dst); |
| 130 |
| 131 // Returns true if decoding will be slow with the current configuration |
| 132 // and bitstream features. |
| 133 int WebPAvoidSlowMemory(const WebPDecBuffer* const output, |
| 134 const WebPBitstreamFeatures* const features); |
| 135 |
117 //------------------------------------------------------------------------------ | 136 //------------------------------------------------------------------------------ |
118 | 137 |
119 #ifdef __cplusplus | 138 #ifdef __cplusplus |
120 } // extern "C" | 139 } // extern "C" |
121 #endif | 140 #endif |
122 | 141 |
123 #endif /* WEBP_DEC_WEBPI_H_ */ | 142 #endif /* WEBP_DEC_WEBPI_H_ */ |
OLD | NEW |