OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 * plugins implementing this interface may trust the input parameters to be | 68 * plugins implementing this interface may trust the input parameters to be |
69 * properly initialized. | 69 * properly initialized. |
70 * | 70 * |
71 * \param[in] ctx Pointer to this instance's context | 71 * \param[in] ctx Pointer to this instance's context |
72 * \retval #VPX_CODEC_OK | 72 * \retval #VPX_CODEC_OK |
73 * The input stream was recognized and decoder initialized. | 73 * The input stream was recognized and decoder initialized. |
74 * \retval #VPX_CODEC_MEM_ERROR | 74 * \retval #VPX_CODEC_MEM_ERROR |
75 * Memory operation failed. | 75 * Memory operation failed. |
76 */ | 76 */ |
77 typedef vpx_codec_err_t (*vpx_codec_init_fn_t)(vpx_codec_ctx_t *ctx, | 77 typedef vpx_codec_err_t (*vpx_codec_init_fn_t)(vpx_codec_ctx_t *ctx, |
78 vpx_codec_priv_enc_mr_cfg_t *data); | 78 vpx_codec_priv_enc_mr_cfg_t *data
); |
79 | 79 |
80 /*!\brief destroy function pointer prototype | 80 /*!\brief destroy function pointer prototype |
81 * | 81 * |
82 * Performs algorithm-specific destruction of the decoder context. This | 82 * Performs algorithm-specific destruction of the decoder context. This |
83 * function is called by the generic vpx_codec_destroy() wrapper function, | 83 * function is called by the generic vpx_codec_destroy() wrapper function, |
84 * so plugins implementing this interface may trust the input parameters | 84 * so plugins implementing this interface may trust the input parameters |
85 * to be properly initialized. | 85 * to be properly initialized. |
86 * | 86 * |
87 * \param[in] ctx Pointer to this instance's context | 87 * \param[in] ctx Pointer to this instance's context |
88 * \retval #VPX_CODEC_OK | 88 * \retval #VPX_CODEC_OK |
(...skipping 13 matching lines...) Expand all Loading... |
102 * \param[in] data_sz Size of the data buffer | 102 * \param[in] data_sz Size of the data buffer |
103 * \param[in,out] si Pointer to stream info to update. The size member | 103 * \param[in,out] si Pointer to stream info to update. The size member |
104 * \ref MUST be properly initialized, but \ref MAY be | 104 * \ref MUST be properly initialized, but \ref MAY be |
105 * clobbered by the algorithm. This parameter \ref MAY | 105 * clobbered by the algorithm. This parameter \ref MAY |
106 * be NULL. | 106 * be NULL. |
107 * | 107 * |
108 * \retval #VPX_CODEC_OK | 108 * \retval #VPX_CODEC_OK |
109 * Bitstream is parsable and stream information updated | 109 * Bitstream is parsable and stream information updated |
110 */ | 110 */ |
111 typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(const uint8_t *data, | 111 typedef vpx_codec_err_t (*vpx_codec_peek_si_fn_t)(const uint8_t *data, |
112 unsigned int data_sz, | 112 unsigned int data_sz
, |
113 vpx_codec_stream_info_t *si); | 113 vpx_codec_stream_info_t *si); |
114 | 114 |
115 /*!\brief Return information about the current stream. | 115 /*!\brief Return information about the current stream. |
116 * | 116 * |
117 * Returns information about the stream that has been parsed during decoding. | 117 * Returns information about the stream that has been parsed during decoding. |
118 * | 118 * |
119 * \param[in] ctx Pointer to this instance's context | 119 * \param[in] ctx Pointer to this instance's context |
120 * \param[in,out] si Pointer to stream info to update. The size member | 120 * \param[in,out] si Pointer to stream info to update. The size member |
121 * \ref MUST be properly initialized, but \ref MAY be | 121 * \ref MUST be properly initialized, but \ref MAY be |
122 * clobbered by the algorithm. This parameter \ref MAY | 122 * clobbered by the algorithm. This parameter \ref MAY |
123 * be NULL. | 123 * be NULL. |
124 * | 124 * |
125 * \retval #VPX_CODEC_OK | 125 * \retval #VPX_CODEC_OK |
126 * Bitstream is parsable and stream information updated | 126 * Bitstream is parsable and stream information updated |
127 */ | 127 */ |
128 typedef vpx_codec_err_t (*vpx_codec_get_si_fn_t)(vpx_codec_alg_priv_t *ctx, | 128 typedef vpx_codec_err_t (*vpx_codec_get_si_fn_t)(vpx_codec_alg_priv_t *ctx, |
129 vpx_codec_stream_info_t *si); | 129 vpx_codec_stream_info_t *si); |
130 | 130 |
131 /*!\brief control function pointer prototype | 131 /*!\brief control function pointer prototype |
132 * | 132 * |
133 * This function is used to exchange algorithm specific data with the decoder | 133 * This function is used to exchange algorithm specific data with the decoder |
134 * instance. This can be used to implement features specific to a particular | 134 * instance. This can be used to implement features specific to a particular |
135 * algorithm. | 135 * algorithm. |
136 * | 136 * |
137 * This function is called by the generic vpx_codec_control() wrapper | 137 * This function is called by the generic vpx_codec_control() wrapper |
138 * function, so plugins implementing this interface may trust the input | 138 * function, so plugins implementing this interface may trust the input |
139 * parameters to be properly initialized. However, this interface does not | 139 * parameters to be properly initialized. However, this interface does not |
140 * provide type safety for the exchanged data or assign meanings to the | 140 * provide type safety for the exchanged data or assign meanings to the |
141 * control codes. Those details should be specified in the algorithm's | 141 * control codes. Those details should be specified in the algorithm's |
142 * header file. In particular, the ctrl_id parameter is guaranteed to exist | 142 * header file. In particular, the ctrl_id parameter is guaranteed to exist |
143 * in the algorithm's control mapping table, and the data parameter may be NULL. | 143 * in the algorithm's control mapping table, and the data parameter may be NULL. |
144 * | 144 * |
145 * | 145 * |
146 * \param[in] ctx Pointer to this instance's context | 146 * \param[in] ctx Pointer to this instance's context |
147 * \param[in] ctrl_id Algorithm specific control identifier | 147 * \param[in] ctrl_id Algorithm specific control identifier |
148 * \param[in,out] data Data to exchange with algorithm instance. | 148 * \param[in,out] data Data to exchange with algorithm instance. |
149 * | 149 * |
150 * \retval #VPX_CODEC_OK | 150 * \retval #VPX_CODEC_OK |
151 * The internal state data was deserialized. | 151 * The internal state data was deserialized. |
152 */ | 152 */ |
153 typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(vpx_codec_alg_priv_t *ctx, | 153 typedef vpx_codec_err_t (*vpx_codec_control_fn_t)(vpx_codec_alg_priv_t *ctx, |
154 int ctrl_id, | 154 int ctrl_id, |
155 va_list ap); | 155 va_list ap); |
156 | 156 |
157 /*!\brief control function pointer mapping | 157 /*!\brief control function pointer mapping |
158 * | 158 * |
159 * This structure stores the mapping between control identifiers and | 159 * This structure stores the mapping between control identifiers and |
160 * implementing functions. Each algorithm provides a list of these | 160 * implementing functions. Each algorithm provides a list of these |
161 * mappings. This list is searched by the vpx_codec_control() wrapper | 161 * mappings. This list is searched by the vpx_codec_control() wrapper |
162 * function to determine which function to invoke. The special | 162 * function to determine which function to invoke. The special |
163 * value {0, NULL} is used to indicate end-of-list, and must be | 163 * value {0, NULL} is used to indicate end-of-list, and must be |
164 * present. The special value {0, <non-null>} can be used as a catch-all | 164 * present. The special value {0, <non-null>} can be used as a catch-all |
165 * mapping. This implies that ctrl_id values chosen by the algorithm | 165 * mapping. This implies that ctrl_id values chosen by the algorithm |
166 * \ref MUST be non-zero. | 166 * \ref MUST be non-zero. |
167 */ | 167 */ |
168 typedef const struct vpx_codec_ctrl_fn_map | 168 typedef const struct vpx_codec_ctrl_fn_map { |
169 { | 169 int ctrl_id; |
170 int ctrl_id; | 170 vpx_codec_control_fn_t fn; |
171 vpx_codec_control_fn_t fn; | |
172 } vpx_codec_ctrl_fn_map_t; | 171 } vpx_codec_ctrl_fn_map_t; |
173 | 172 |
174 /*!\brief decode data function pointer prototype | 173 /*!\brief decode data function pointer prototype |
175 * | 174 * |
176 * Processes a buffer of coded data. If the processing results in a new | 175 * Processes a buffer of coded data. If the processing results in a new |
177 * decoded frame becoming available, #VPX_CODEC_CB_PUT_SLICE and | 176 * decoded frame becoming available, #VPX_CODEC_CB_PUT_SLICE and |
178 * #VPX_CODEC_CB_PUT_FRAME events are generated as appropriate. This | 177 * #VPX_CODEC_CB_PUT_FRAME events are generated as appropriate. This |
179 * function is called by the generic vpx_codec_decode() wrapper function, | 178 * function is called by the generic vpx_codec_decode() wrapper function, |
180 * so plugins implementing this interface may trust the input parameters | 179 * so plugins implementing this interface may trust the input parameters |
181 * to be properly initialized. | 180 * to be properly initialized. |
182 * | 181 * |
183 * \param[in] ctx Pointer to this instance's context | 182 * \param[in] ctx Pointer to this instance's context |
184 * \param[in] data Pointer to this block of new coded data. If | 183 * \param[in] data Pointer to this block of new coded data. If |
185 * NULL, a #VPX_CODEC_CB_PUT_FRAME event is posted | 184 * NULL, a #VPX_CODEC_CB_PUT_FRAME event is posted |
186 * for the previously decoded frame. | 185 * for the previously decoded frame. |
187 * \param[in] data_sz Size of the coded data, in bytes. | 186 * \param[in] data_sz Size of the coded data, in bytes. |
188 * | 187 * |
189 * \return Returns #VPX_CODEC_OK if the coded data was processed completely | 188 * \return Returns #VPX_CODEC_OK if the coded data was processed completely |
190 * and future pictures can be decoded without error. Otherwise, | 189 * and future pictures can be decoded without error. Otherwise, |
191 * see the descriptions of the other error codes in ::vpx_codec_err_t | 190 * see the descriptions of the other error codes in ::vpx_codec_err_t |
192 * for recoverability capabilities. | 191 * for recoverability capabilities. |
193 */ | 192 */ |
194 typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx, | 193 typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx, |
195 const uint8_t *data, | 194 const uint8_t *data, |
196 unsigned int data_sz, | 195 unsigned int data_sz, |
197 void *user_priv, | 196 void *user_priv, |
198 long deadline); | 197 long deadline); |
199 | 198 |
200 /*!\brief Decoded frames iterator | 199 /*!\brief Decoded frames iterator |
201 * | 200 * |
202 * Iterates over a list of the frames available for display. The iterator | 201 * Iterates over a list of the frames available for display. The iterator |
203 * storage should be initialized to NULL to start the iteration. Iteration is | 202 * storage should be initialized to NULL to start the iteration. Iteration is |
204 * complete when this function returns NULL. | 203 * complete when this function returns NULL. |
205 * | 204 * |
206 * The list of available frames becomes valid upon completion of the | 205 * The list of available frames becomes valid upon completion of the |
207 * vpx_codec_decode call, and remains valid until the next call to vpx_codec_dec
ode. | 206 * vpx_codec_decode call, and remains valid until the next call to vpx_codec_dec
ode. |
208 * | 207 * |
209 * \param[in] ctx Pointer to this instance's context | 208 * \param[in] ctx Pointer to this instance's context |
210 * \param[in out] iter Iterator storage, initialized to NULL | 209 * \param[in out] iter Iterator storage, initialized to NULL |
211 * | 210 * |
212 * \return Returns a pointer to an image, if one is ready for display. Frames | 211 * \return Returns a pointer to an image, if one is ready for display. Frames |
213 * produced will always be in PTS (presentation time stamp) order. | 212 * produced will always be in PTS (presentation time stamp) order. |
214 */ | 213 */ |
215 typedef vpx_image_t*(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx, | 214 typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx, |
216 vpx_codec_iter_t *iter); | 215 vpx_codec_iter_t *iter); |
217 | 216 |
218 | 217 |
219 /*\brief eXternal Memory Allocation memory map get iterator | 218 /*\brief eXternal Memory Allocation memory map get iterator |
220 * | 219 * |
221 * Iterates over a list of the memory maps requested by the decoder. The | 220 * Iterates over a list of the memory maps requested by the decoder. The |
222 * iterator storage should be initialized to NULL to start the iteration. | 221 * iterator storage should be initialized to NULL to start the iteration. |
223 * Iteration is complete when this function returns NULL. | 222 * Iteration is complete when this function returns NULL. |
224 * | 223 * |
225 * \param[in out] iter Iterator storage, initialized to NULL | 224 * \param[in out] iter Iterator storage, initialized to NULL |
226 * | 225 * |
227 * \return Returns a pointer to an memory segment descriptor, or NULL to | 226 * \return Returns a pointer to an memory segment descriptor, or NULL to |
228 * indicate end-of-list. | 227 * indicate end-of-list. |
229 */ | 228 */ |
230 typedef vpx_codec_err_t (*vpx_codec_get_mmap_fn_t)(const vpx_codec_ctx_t *c
tx, | 229 typedef vpx_codec_err_t (*vpx_codec_get_mmap_fn_t)(const vpx_codec_ctx_t *c
tx, |
231 vpx_codec_mmap_t *mmap, | 230 vpx_codec_mmap_t *m
map, |
232 vpx_codec_iter_t *iter); | 231 vpx_codec_iter_t *i
ter); |
233 | 232 |
234 | 233 |
235 /*\brief eXternal Memory Allocation memory map set iterator | 234 /*\brief eXternal Memory Allocation memory map set iterator |
236 * | 235 * |
237 * Sets a memory descriptor inside the decoder instance. | 236 * Sets a memory descriptor inside the decoder instance. |
238 * | 237 * |
239 * \param[in] ctx Pointer to this instance's context | 238 * \param[in] ctx Pointer to this instance's context |
240 * \param[in] mmap Memory map to store. | 239 * \param[in] mmap Memory map to store. |
241 * | 240 * |
242 * \retval #VPX_CODEC_OK | 241 * \retval #VPX_CODEC_OK |
243 * The memory map was accepted and stored. | 242 * The memory map was accepted and stored. |
244 * \retval #VPX_CODEC_MEM_ERROR | 243 * \retval #VPX_CODEC_MEM_ERROR |
245 * The memory map was rejected. | 244 * The memory map was rejected. |
246 */ | 245 */ |
247 typedef vpx_codec_err_t (*vpx_codec_set_mmap_fn_t)(vpx_codec_ctx_t *ctx, | 246 typedef vpx_codec_err_t (*vpx_codec_set_mmap_fn_t)(vpx_codec_ctx_t *ctx, |
248 const vpx_codec_mmap_t *mmap); | 247 const vpx_codec_mmap_t *mmap
); |
249 | 248 |
250 | 249 |
251 typedef vpx_codec_err_t (*vpx_codec_encode_fn_t)(vpx_codec_alg_priv_t *ctx, | 250 typedef vpx_codec_err_t (*vpx_codec_encode_fn_t)(vpx_codec_alg_priv_t *ctx, |
252 const vpx_image_t *img, | 251 const vpx_image_t *img, |
253 vpx_codec_pts_t pts, | 252 vpx_codec_pts_t pts, |
254 unsigned long duration, | 253 unsigned long duration
, |
255 vpx_enc_frame_flags_t flags, | 254 vpx_enc_frame_flags_t flags, |
256 unsigned long deadline); | 255 unsigned long deadline
); |
257 typedef const vpx_codec_cx_pkt_t*(*vpx_codec_get_cx_data_fn_t)(vpx_codec_alg_pri
v_t *ctx, | 256 typedef const vpx_codec_cx_pkt_t *(*vpx_codec_get_cx_data_fn_t)(vpx_codec_alg_pr
iv_t *ctx, |
258 vpx_codec_iter_t *iter); | 257 vpx_codec_iter_t
*iter); |
259 | 258 |
260 typedef vpx_codec_err_t | 259 typedef vpx_codec_err_t |
261 (*vpx_codec_enc_config_set_fn_t)(vpx_codec_alg_priv_t *ctx, | 260 (*vpx_codec_enc_config_set_fn_t)(vpx_codec_alg_priv_t *ctx, |
262 const vpx_codec_enc_cfg_t *cfg); | 261 const vpx_codec_enc_cfg_t *cfg); |
263 typedef vpx_fixed_buf_t * | 262 typedef vpx_fixed_buf_t * |
264 (*vpx_codec_get_global_headers_fn_t)(vpx_codec_alg_priv_t *ctx); | 263 (*vpx_codec_get_global_headers_fn_t)(vpx_codec_alg_priv_t *ctx); |
265 | 264 |
266 typedef vpx_image_t * | 265 typedef vpx_image_t * |
267 (*vpx_codec_get_preview_frame_fn_t)(vpx_codec_alg_priv_t *ctx); | 266 (*vpx_codec_get_preview_frame_fn_t)(vpx_codec_alg_priv_t *ctx); |
268 | 267 |
269 typedef vpx_codec_err_t | 268 typedef vpx_codec_err_t |
270 (*vpx_codec_enc_mr_get_mem_loc_fn_t)(const vpx_codec_enc_cfg_t *cfg, | 269 (*vpx_codec_enc_mr_get_mem_loc_fn_t)(const vpx_codec_enc_cfg_t *cfg, |
271 void **mem_loc); | 270 void **mem_loc); |
272 | 271 |
273 /*!\brief usage configuration mapping | 272 /*!\brief usage configuration mapping |
274 * | 273 * |
275 * This structure stores the mapping between usage identifiers and | 274 * This structure stores the mapping between usage identifiers and |
276 * configuration structures. Each algorithm provides a list of these | 275 * configuration structures. Each algorithm provides a list of these |
277 * mappings. This list is searched by the vpx_codec_enc_config_default() | 276 * mappings. This list is searched by the vpx_codec_enc_config_default() |
278 * wrapper function to determine which config to return. The special value | 277 * wrapper function to determine which config to return. The special value |
279 * {-1, {0}} is used to indicate end-of-list, and must be present. At least | 278 * {-1, {0}} is used to indicate end-of-list, and must be present. At least |
280 * one mapping must be present, in addition to the end-of-list. | 279 * one mapping must be present, in addition to the end-of-list. |
281 * | 280 * |
282 */ | 281 */ |
283 typedef const struct vpx_codec_enc_cfg_map | 282 typedef const struct vpx_codec_enc_cfg_map { |
284 { | 283 int usage; |
285 int usage; | 284 vpx_codec_enc_cfg_t cfg; |
286 vpx_codec_enc_cfg_t cfg; | |
287 } vpx_codec_enc_cfg_map_t; | 285 } vpx_codec_enc_cfg_map_t; |
288 | 286 |
289 #define NOT_IMPLEMENTED 0 | 287 #define NOT_IMPLEMENTED 0 |
290 | 288 |
291 /*!\brief Decoder algorithm interface interface | 289 /*!\brief Decoder algorithm interface interface |
292 * | 290 * |
293 * All decoders \ref MUST expose a variable of this type. | 291 * All decoders \ref MUST expose a variable of this type. |
294 */ | 292 */ |
295 struct vpx_codec_iface | 293 struct vpx_codec_iface { |
296 { | 294 const char *name; /**< Identification String */ |
297 const char *name; /**< Identification String */ | 295 int abi_version; /**< Implemented ABI version */ |
298 int abi_version; /**< Implemented ABI version */ | 296 vpx_codec_caps_t caps; /**< Decoder capabilities */ |
299 vpx_codec_caps_t caps; /**< Decoder capabilities */ | 297 vpx_codec_init_fn_t init; /**< \copydoc ::vpx_codec_init_fn_t */ |
300 vpx_codec_init_fn_t init; /**< \copydoc ::vpx_codec_init_fn_t */ | 298 vpx_codec_destroy_fn_t destroy; /**< \copydoc ::vpx_codec_destroy_fn_t
*/ |
301 vpx_codec_destroy_fn_t destroy; /**< \copydoc ::vpx_codec_destroy_fn_
t */ | 299 vpx_codec_ctrl_fn_map_t *ctrl_maps; /**< \copydoc ::vpx_codec_ctrl_fn_map_t
*/ |
302 vpx_codec_ctrl_fn_map_t *ctrl_maps; /**< \copydoc ::vpx_codec_ctrl_fn_map
_t */ | 300 vpx_codec_get_mmap_fn_t get_mmap; /**< \copydoc ::vpx_codec_get_mmap_fn_t
*/ |
303 vpx_codec_get_mmap_fn_t get_mmap; /**< \copydoc ::vpx_codec_get_mmap_fn
_t */ | 301 vpx_codec_set_mmap_fn_t set_mmap; /**< \copydoc ::vpx_codec_set_mmap_fn_t
*/ |
304 vpx_codec_set_mmap_fn_t set_mmap; /**< \copydoc ::vpx_codec_set_mmap_fn
_t */ | 302 struct vpx_codec_dec_iface { |
305 struct vpx_codec_dec_iface | 303 vpx_codec_peek_si_fn_t peek_si; /**< \copydoc ::vpx_codec_peek_si_fn_
t */ |
306 { | 304 vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_peek_si_fn_
t */ |
307 vpx_codec_peek_si_fn_t peek_si; /**< \copydoc ::vpx_codec_peek_si
_fn_t */ | 305 vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_fn_t
*/ |
308 vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_peek_si
_fn_t */ | 306 vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_frame_f
n_t */ |
309 vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_
fn_t */ | 307 } dec; |
310 vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_fra
me_fn_t */ | 308 struct vpx_codec_enc_iface { |
311 } dec; | 309 vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_codec_
enc_cfg_map_t */ |
312 struct vpx_codec_enc_iface | 310 vpx_codec_encode_fn_t encode; /**< \copydoc ::vpx_codec_
encode_fn_t */ |
313 { | 311 vpx_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::vpx_codec_
get_cx_data_fn_t */ |
314 vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_co
dec_enc_cfg_map_t */ | 312 vpx_codec_enc_config_set_fn_t cfg_set; /**< \copydoc ::vpx_codec_
enc_config_set_fn_t */ |
315 vpx_codec_encode_fn_t encode; /**< \copydoc ::vpx_co
dec_encode_fn_t */ | 313 vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_codec_
get_global_headers_fn_t */ |
316 vpx_codec_get_cx_data_fn_t get_cx_data; /**< \copydoc ::vpx_co
dec_get_cx_data_fn_t */ | 314 vpx_codec_get_preview_frame_fn_t get_preview; /**< \copydoc ::vpx_codec_
get_preview_frame_fn_t */ |
317 vpx_codec_enc_config_set_fn_t cfg_set; /**< \copydoc ::vpx_co
dec_enc_config_set_fn_t */ | 315 vpx_codec_enc_mr_get_mem_loc_fn_t mr_get_mem_loc; /**< \copydoc ::vpx_cod
ec_enc_mr_get_mem_loc_fn_t */ |
318 vpx_codec_get_global_headers_fn_t get_glob_hdrs; /**< \copydoc ::vpx_co
dec_get_global_headers_fn_t */ | 316 } enc; |
319 vpx_codec_get_preview_frame_fn_t get_preview; /**< \copydoc ::vpx_co
dec_get_preview_frame_fn_t */ | |
320 vpx_codec_enc_mr_get_mem_loc_fn_t mr_get_mem_loc; /**< \copydoc ::vpx
_codec_enc_mr_get_mem_loc_fn_t */ | |
321 } enc; | |
322 }; | 317 }; |
323 | 318 |
324 /*!\brief Callback function pointer / user data pair storage */ | 319 /*!\brief Callback function pointer / user data pair storage */ |
325 typedef struct vpx_codec_priv_cb_pair | 320 typedef struct vpx_codec_priv_cb_pair { |
326 { | 321 union { |
327 union | 322 vpx_codec_put_frame_cb_fn_t put_frame; |
328 { | 323 vpx_codec_put_slice_cb_fn_t put_slice; |
329 vpx_codec_put_frame_cb_fn_t put_frame; | 324 } u; |
330 vpx_codec_put_slice_cb_fn_t put_slice; | 325 void *user_priv; |
331 } u; | |
332 void *user_priv; | |
333 } vpx_codec_priv_cb_pair_t; | 326 } vpx_codec_priv_cb_pair_t; |
334 | 327 |
335 | 328 |
336 /*!\brief Instance private storage | 329 /*!\brief Instance private storage |
337 * | 330 * |
338 * This structure is allocated by the algorithm's init function. It can be | 331 * This structure is allocated by the algorithm's init function. It can be |
339 * extended in one of two ways. First, a second, algorithm specific structure | 332 * extended in one of two ways. First, a second, algorithm specific structure |
340 * can be allocated and the priv member pointed to it. Alternatively, this | 333 * can be allocated and the priv member pointed to it. Alternatively, this |
341 * structure can be made the first member of the algorithm specific structure, | 334 * structure can be made the first member of the algorithm specific structure, |
342 * and the pointer cast to the proper type. | 335 * and the pointer cast to the proper type. |
343 */ | 336 */ |
344 struct vpx_codec_priv | 337 struct vpx_codec_priv { |
345 { | 338 unsigned int sz; |
346 unsigned int sz; | 339 vpx_codec_iface_t *iface; |
347 vpx_codec_iface_t *iface; | 340 struct vpx_codec_alg_priv *alg_priv; |
348 struct vpx_codec_alg_priv *alg_priv; | 341 const char *err_detail; |
349 const char *err_detail; | 342 vpx_codec_flags_t init_flags; |
350 vpx_codec_flags_t init_flags; | 343 struct { |
351 struct | 344 vpx_codec_priv_cb_pair_t put_frame_cb; |
352 { | 345 vpx_codec_priv_cb_pair_t put_slice_cb; |
353 vpx_codec_priv_cb_pair_t put_frame_cb; | 346 } dec; |
354 vpx_codec_priv_cb_pair_t put_slice_cb; | 347 struct { |
355 } dec; | 348 int tbd; |
356 struct | 349 struct vpx_fixed_buf cx_data_dst_buf; |
357 { | 350 unsigned int cx_data_pad_before; |
358 int tbd; | 351 unsigned int cx_data_pad_after; |
359 struct vpx_fixed_buf cx_data_dst_buf; | 352 vpx_codec_cx_pkt_t cx_data_pkt; |
360 unsigned int cx_data_pad_before; | 353 unsigned int total_encoders; |
361 unsigned int cx_data_pad_after; | 354 } enc; |
362 vpx_codec_cx_pkt_t cx_data_pkt; | |
363 unsigned int total_encoders; | |
364 } enc; | |
365 }; | 355 }; |
366 | 356 |
367 /* | 357 /* |
368 * Multi-resolution encoding internal configuration | 358 * Multi-resolution encoding internal configuration |
369 */ | 359 */ |
370 struct vpx_codec_priv_enc_mr_cfg | 360 struct vpx_codec_priv_enc_mr_cfg |
371 { | 361 { |
372 unsigned int mr_total_resolutions; | 362 unsigned int mr_total_resolutions; |
373 unsigned int mr_encoder_id; | 363 unsigned int mr_encoder_id; |
374 struct vpx_rational mr_down_sampling_factor; | 364 struct vpx_rational mr_down_sampling_factor; |
375 void* mr_low_res_mode_info; | 365 void* mr_low_res_mode_info; |
376 }; | 366 }; |
377 | 367 |
378 #undef VPX_CTRL_USE_TYPE | 368 #undef VPX_CTRL_USE_TYPE |
379 #define VPX_CTRL_USE_TYPE(id, typ) \ | 369 #define VPX_CTRL_USE_TYPE(id, typ) \ |
380 static typ id##__value(va_list args) {return va_arg(args, typ);} \ | 370 static typ id##__value(va_list args) {return va_arg(args, typ);} \ |
381 static typ id##__convert(void *x)\ | 371 static typ id##__convert(void *x)\ |
| 372 {\ |
| 373 union\ |
382 {\ | 374 {\ |
383 union\ | 375 void *x;\ |
384 {\ | 376 typ d;\ |
385 void *x;\ | 377 } u;\ |
386 typ d;\ | 378 u.x = x;\ |
387 } u;\ | 379 return u.d;\ |
388 u.x = x;\ | 380 } |
389 return u.d;\ | |
390 } | |
391 | 381 |
392 | 382 |
393 #undef VPX_CTRL_USE_TYPE_DEPRECATED | 383 #undef VPX_CTRL_USE_TYPE_DEPRECATED |
394 #define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \ | 384 #define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \ |
395 static typ id##__value(va_list args) {return va_arg(args, typ);} \ | 385 static typ id##__value(va_list args) {return va_arg(args, typ);} \ |
396 static typ id##__convert(void *x)\ | 386 static typ id##__convert(void *x)\ |
| 387 {\ |
| 388 union\ |
397 {\ | 389 {\ |
398 union\ | 390 void *x;\ |
399 {\ | 391 typ d;\ |
400 void *x;\ | 392 } u;\ |
401 typ d;\ | 393 u.x = x;\ |
402 } u;\ | 394 return u.d;\ |
403 u.x = x;\ | 395 } |
404 return u.d;\ | |
405 } | |
406 | 396 |
407 #define CAST(id, arg) id##__value(arg) | 397 #define CAST(id, arg) id##__value(arg) |
408 #define RECAST(id, x) id##__convert(x) | 398 #define RECAST(id, x) id##__convert(x) |
409 | 399 |
410 | 400 |
411 /* CODEC_INTERFACE convenience macro | 401 /* CODEC_INTERFACE convenience macro |
412 * | 402 * |
413 * By convention, each codec interface is a struct with extern linkage, where | 403 * By convention, each codec interface is a struct with extern linkage, where |
414 * the symbol is suffixed with _algo. A getter function is also defined to | 404 * the symbol is suffixed with _algo. A getter function is also defined to |
415 * return a pointer to the struct, since in some cases it's easier to work | 405 * return a pointer to the struct, since in some cases it's easier to work |
416 * with text symbols than data symbols (see issue #169). This function has | 406 * with text symbols than data symbols (see issue #169). This function has |
417 * the same name as the struct, less the _algo suffix. The CODEC_INTERFACE | 407 * the same name as the struct, less the _algo suffix. The CODEC_INTERFACE |
418 * macro is provided to define this getter function automatically. | 408 * macro is provided to define this getter function automatically. |
419 */ | 409 */ |
420 #define CODEC_INTERFACE(id)\ | 410 #define CODEC_INTERFACE(id)\ |
421 vpx_codec_iface_t* id(void) { return &id##_algo; }\ | 411 vpx_codec_iface_t* id(void) { return &id##_algo; }\ |
422 vpx_codec_iface_t id##_algo | 412 vpx_codec_iface_t id##_algo |
423 | 413 |
424 | 414 |
425 /* Internal Utility Functions | 415 /* Internal Utility Functions |
426 * | 416 * |
427 * The following functions are intended to be used inside algorithms as | 417 * The following functions are intended to be used inside algorithms as |
428 * utilities for manipulating vpx_codec_* data structures. | 418 * utilities for manipulating vpx_codec_* data structures. |
429 */ | 419 */ |
430 struct vpx_codec_pkt_list | 420 struct vpx_codec_pkt_list { |
431 { | 421 unsigned int cnt; |
432 unsigned int cnt; | 422 unsigned int max; |
433 unsigned int max; | 423 struct vpx_codec_cx_pkt pkts[1]; |
434 struct vpx_codec_cx_pkt pkts[1]; | |
435 }; | 424 }; |
436 | 425 |
437 #define vpx_codec_pkt_list_decl(n)\ | 426 #define vpx_codec_pkt_list_decl(n)\ |
438 union {struct vpx_codec_pkt_list head;\ | 427 union {struct vpx_codec_pkt_list head;\ |
439 struct {struct vpx_codec_pkt_list head;\ | 428 struct {struct vpx_codec_pkt_list head;\ |
440 struct vpx_codec_cx_pkt pkts[n];} alloc;} | 429 struct vpx_codec_cx_pkt pkts[n];} alloc;} |
441 | 430 |
442 #define vpx_codec_pkt_list_init(m)\ | 431 #define vpx_codec_pkt_list_init(m)\ |
443 (m)->alloc.head.cnt = 0,\ | 432 (m)->alloc.head.cnt = 0,\ |
444 (m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof
((m)->alloc.pkts[0]) | 433 (m)->alloc.head.max = sizeof((m)->alloc.pkts) / sizeof((
m)->alloc.pkts[0]) |
445 | 434 |
446 int | 435 int |
447 vpx_codec_pkt_list_add(struct vpx_codec_pkt_list *, | 436 vpx_codec_pkt_list_add(struct vpx_codec_pkt_list *, |
448 const struct vpx_codec_cx_pkt *); | 437 const struct vpx_codec_cx_pkt *); |
449 | 438 |
450 const vpx_codec_cx_pkt_t* | 439 const vpx_codec_cx_pkt_t * |
451 vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list, | 440 vpx_codec_pkt_list_get(struct vpx_codec_pkt_list *list, |
452 vpx_codec_iter_t *iter); | 441 vpx_codec_iter_t *iter); |
453 | 442 |
454 | 443 |
455 #include <stdio.h> | 444 #include <stdio.h> |
456 #include <setjmp.h> | 445 #include <setjmp.h> |
457 struct vpx_internal_error_info | 446 struct vpx_internal_error_info { |
458 { | 447 vpx_codec_err_t error_code; |
459 vpx_codec_err_t error_code; | 448 int has_detail; |
460 int has_detail; | 449 char detail[80]; |
461 char detail[80]; | 450 int setjmp; |
462 int setjmp; | 451 jmp_buf jmp; |
463 jmp_buf jmp; | |
464 }; | 452 }; |
465 | 453 |
466 static void vpx_internal_error(struct vpx_internal_error_info *info, | 454 static void vpx_internal_error(struct vpx_internal_error_info *info, |
467 vpx_codec_err_t error, | 455 vpx_codec_err_t error, |
468 const char *fmt, | 456 const char *fmt, |
469 ...) | 457 ...) { |
470 { | 458 va_list ap; |
471 va_list ap; | |
472 | 459 |
473 info->error_code = error; | 460 info->error_code = error; |
474 info->has_detail = 0; | 461 info->has_detail = 0; |
475 | 462 |
476 if (fmt) | 463 if (fmt) { |
477 { | 464 size_t sz = sizeof(info->detail); |
478 size_t sz = sizeof(info->detail); | |
479 | 465 |
480 info->has_detail = 1; | 466 info->has_detail = 1; |
481 va_start(ap, fmt); | 467 va_start(ap, fmt); |
482 vsnprintf(info->detail, sz - 1, fmt, ap); | 468 vsnprintf(info->detail, sz - 1, fmt, ap); |
483 va_end(ap); | 469 va_end(ap); |
484 info->detail[sz-1] = '\0'; | 470 info->detail[sz - 1] = '\0'; |
485 } | 471 } |
486 | 472 |
487 if (info->setjmp) | 473 if (info->setjmp) |
488 longjmp(info->jmp, info->error_code); | 474 longjmp(info->jmp, info->error_code); |
489 } | 475 } |
490 #endif | 476 #endif |
OLD | NEW |