Merge "configuration, support disabling any subset of ARM arch"
[libvpx.git] / vpx / vpx_decoder.h
blobe50fd765f1207ef6484abf024df0b976a06b733d
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 /*!\defgroup decoder Decoder Algorithm Interface
13 * \ingroup codec
14 * This abstraction allows applications using this decoder to easily support
15 * multiple video formats with minimal code duplication. This section describes
16 * the interface common to all decoders.
17 * @{
20 /*!\file
21 * \brief Describes the decoder algorithm interface to applications.
23 * This file describes the interface between an application and a
24 * video decoder algorithm.
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
31 #ifndef VPX_DECODER_H
32 #define VPX_DECODER_H
33 #include "vpx_codec.h"
35 /*!\brief Current ABI version number
37 * \internal
38 * If this file is altered in any way that changes the ABI, this value
39 * must be bumped. Examples include, but are not limited to, changing
40 * types, removing or reassigning enums, adding/removing/rearranging
41 * fields to structures
43 #define VPX_DECODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
45 /*! \brief Decoder capabilities bitfield
47 * Each decoder advertises the capabilities it supports as part of its
48 * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
49 * or functionality, and are not required to be supported by a decoder.
51 * The available flags are specified by VPX_CODEC_CAP_* defines.
53 #define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
54 #define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
55 #define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
56 #define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000 /**< Can conceal errors due to
57 packet loss */
59 /*! \brief Initialization-time Feature Enabling
61 * Certain codec features must be known at initialization time, to allow for
62 * proper memory allocation.
64 * The available flags are specified by VPX_CODEC_USE_* defines.
66 #define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
67 #define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded
68 frames */
70 /*!\brief Stream properties
72 * This structure is used to query or set properties of the decoded
73 * stream. Algorithms may extend this structure with data specific
74 * to their bitstream by setting the sz member appropriately.
76 typedef struct vpx_codec_stream_info
78 unsigned int sz; /**< Size of this structure */
79 unsigned int w; /**< Width (or 0 for unknown/default) */
80 unsigned int h; /**< Height (or 0 for unknown/default) */
81 unsigned int is_kf; /**< Current frame is a keyframe */
82 } vpx_codec_stream_info_t;
84 /* REQUIRED FUNCTIONS
86 * The following functions are required to be implemented for all decoders.
87 * They represent the base case functionality expected of all decoders.
91 /*!\brief Initialization Configurations
93 * This structure is used to pass init time configuration options to the
94 * decoder.
96 typedef struct vpx_codec_dec_cfg
98 unsigned int threads; /**< Maximum number of threads to use, default 1 */
99 unsigned int w; /**< Width */
100 unsigned int h; /**< Height */
101 } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
104 /*!\brief Initialize a decoder instance
106 * Initializes a decoder context using the given interface. Applications
107 * should call the vpx_codec_dec_init convenience macro instead of this
108 * function directly, to ensure that the ABI version number parameter
109 * is properly initialized.
111 * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
112 * parameter), the storage pointed to by the cfg parameter must be
113 * kept readable and stable until all memory maps have been set.
115 * \param[in] ctx Pointer to this instance's context.
116 * \param[in] iface Pointer to the algorithm interface to use.
117 * \param[in] cfg Configuration to use, if known. May be NULL.
118 * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
119 * \param[in] ver ABI version number. Must be set to
120 * VPX_DECODER_ABI_VERSION
121 * \retval #VPX_CODEC_OK
122 * The decoder algorithm initialized.
123 * \retval #VPX_CODEC_MEM_ERROR
124 * Memory allocation failed.
126 vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
127 vpx_codec_iface_t *iface,
128 vpx_codec_dec_cfg_t *cfg,
129 vpx_codec_flags_t flags,
130 int ver);
132 /*!\brief Convenience macro for vpx_codec_dec_init_ver()
134 * Ensures the ABI version parameter is properly set.
136 #define vpx_codec_dec_init(ctx, iface, cfg, flags) \
137 vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
140 /*!\brief Parse stream info from a buffer
142 * Performs high level parsing of the bitstream. Construction of a decoder
143 * context is not necessary. Can be used to determine if the bitstream is
144 * of the proper format, and to extract information from the stream.
146 * \param[in] iface Pointer to the algorithm interface
147 * \param[in] data Pointer to a block of data to parse
148 * \param[in] data_sz Size of the data buffer
149 * \param[in,out] si Pointer to stream info to update. The size member
150 * \ref MUST be properly initialized, but \ref MAY be
151 * clobbered by the algorithm. This parameter \ref MAY
152 * be NULL.
154 * \retval #VPX_CODEC_OK
155 * Bitstream is parsable and stream information updated
157 vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
158 const uint8_t *data,
159 unsigned int data_sz,
160 vpx_codec_stream_info_t *si);
163 /*!\brief Return information about the current stream.
165 * Returns information about the stream that has been parsed during decoding.
167 * \param[in] ctx Pointer to this instance's context
168 * \param[in,out] si Pointer to stream info to update. The size member
169 * \ref MUST be properly initialized, but \ref MAY be
170 * clobbered by the algorithm. This parameter \ref MAY
171 * be NULL.
173 * \retval #VPX_CODEC_OK
174 * Bitstream is parsable and stream information updated
176 vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
177 vpx_codec_stream_info_t *si);
180 /*!\brief Decode data
182 * Processes a buffer of coded data. If the processing results in a new
183 * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
184 * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
185 * time stamp) order. Frames produced will always be in PTS (presentation
186 * time stamp) order.
188 * \param[in] ctx Pointer to this instance's context
189 * \param[in] data Pointer to this block of new coded data. If
190 * NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
191 * for the previously decoded frame.
192 * \param[in] data_sz Size of the coded data, in bytes.
193 * \param[in] user_priv Application specific data to associate with
194 * this frame.
195 * \param[in] deadline Soft deadline the decoder should attempt to meet,
196 * in us. Set to zero for unlimited.
198 * \return Returns #VPX_CODEC_OK if the coded data was processed completely
199 * and future pictures can be decoded without error. Otherwise,
200 * see the descriptions of the other error codes in ::vpx_codec_err_t
201 * for recoverability capabilities.
203 vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx,
204 const uint8_t *data,
205 unsigned int data_sz,
206 void *user_priv,
207 long deadline);
210 /*!\brief Decoded frames iterator
212 * Iterates over a list of the frames available for display. The iterator
213 * storage should be initialized to NULL to start the iteration. Iteration is
214 * complete when this function returns NULL.
216 * The list of available frames becomes valid upon completion of the
217 * vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
219 * \param[in] ctx Pointer to this instance's context
220 * \param[in,out] iter Iterator storage, initialized to NULL
222 * \return Returns a pointer to an image, if one is ready for display. Frames
223 * produced will always be in PTS (presentation time stamp) order.
225 vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx,
226 vpx_codec_iter_t *iter);
229 /*!\defgroup cap_put_frame Frame-Based Decoding Functions
231 * The following functions are required to be implemented for all decoders
232 * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions
233 * for codecs that don't advertise this capability will result in an error
234 * code being returned, usually VPX_CODEC_ERROR
235 * @{
238 /*!\brief put frame callback prototype
240 * This callback is invoked by the decoder to notify the application of
241 * the availability of decoded image data.
243 typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
244 const vpx_image_t *img);
247 /*!\brief Register for notification of frame completion.
249 * Registers a given function to be called when a decoded frame is
250 * available.
252 * \param[in] ctx Pointer to this instance's context
253 * \param[in] cb Pointer to the callback function
254 * \param[in] user_priv User's private data
256 * \retval #VPX_CODEC_OK
257 * Callback successfully registered.
258 * \retval #VPX_CODEC_ERROR
259 * Decoder context not initialized, or algorithm not capable of
260 * posting slice completion.
262 vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
263 vpx_codec_put_frame_cb_fn_t cb,
264 void *user_priv);
267 /*!@} - end defgroup cap_put_frame */
269 /*!\defgroup cap_put_slice Slice-Based Decoding Functions
271 * The following functions are required to be implemented for all decoders
272 * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions
273 * for codecs that don't advertise this capability will result in an error
274 * code being returned, usually VPX_CODEC_ERROR
275 * @{
278 /*!\brief put slice callback prototype
280 * This callback is invoked by the decoder to notify the application of
281 * the availability of partially decoded image data. The
283 typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
284 const vpx_image_t *img,
285 const vpx_image_rect_t *valid,
286 const vpx_image_rect_t *update);
289 /*!\brief Register for notification of slice completion.
291 * Registers a given function to be called when a decoded slice is
292 * available.
294 * \param[in] ctx Pointer to this instance's context
295 * \param[in] cb Pointer to the callback function
296 * \param[in] user_priv User's private data
298 * \retval #VPX_CODEC_OK
299 * Callback successfully registered.
300 * \retval #VPX_CODEC_ERROR
301 * Decoder context not initialized, or algorithm not capable of
302 * posting slice completion.
304 vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
305 vpx_codec_put_slice_cb_fn_t cb,
306 void *user_priv);
309 /*!@} - end defgroup cap_put_slice*/
311 /*!@} - end defgroup decoder*/
313 #endif
315 #ifdef __cplusplus
317 #endif
319 #if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
320 #include "vpx_decoder_compat.h"
321 #endif