media/libvpx/vpx/vpx_decoder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vpx/vpx_decoder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,334 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +#ifndef VPX_DECODER_H
    1.14 +#define VPX_DECODER_H
    1.15 +
    1.16 +/*!\defgroup decoder Decoder Algorithm Interface
    1.17 + * \ingroup codec
    1.18 + * This abstraction allows applications using this decoder to easily support
    1.19 + * multiple video formats with minimal code duplication. This section describes
    1.20 + * the interface common to all decoders.
    1.21 + * @{
    1.22 + */
    1.23 +
    1.24 +/*!\file
    1.25 + * \brief Describes the decoder algorithm interface to applications.
    1.26 + *
    1.27 + * This file describes the interface between an application and a
    1.28 + * video decoder algorithm.
    1.29 + *
    1.30 + */
    1.31 +#ifdef __cplusplus
    1.32 +extern "C" {
    1.33 +#endif
    1.34 +
    1.35 +#include "vpx_codec.h"
    1.36 +
    1.37 +  /*!\brief Current ABI version number
    1.38 +   *
    1.39 +   * \internal
    1.40 +   * If this file is altered in any way that changes the ABI, this value
    1.41 +   * must be bumped.  Examples include, but are not limited to, changing
    1.42 +   * types, removing or reassigning enums, adding/removing/rearranging
    1.43 +   * fields to structures
    1.44 +   */
    1.45 +#define VPX_DECODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
    1.46 +
    1.47 +  /*! \brief Decoder capabilities bitfield
    1.48 +   *
    1.49 +   *  Each decoder advertises the capabilities it supports as part of its
    1.50 +   *  ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
    1.51 +   *  or functionality, and are not required to be supported by a decoder.
    1.52 +   *
    1.53 +   *  The available flags are specified by VPX_CODEC_CAP_* defines.
    1.54 +   */
    1.55 +#define VPX_CODEC_CAP_PUT_SLICE  0x10000 /**< Will issue put_slice callbacks */
    1.56 +#define VPX_CODEC_CAP_PUT_FRAME  0x20000 /**< Will issue put_frame callbacks */
    1.57 +#define VPX_CODEC_CAP_POSTPROC   0x40000 /**< Can postprocess decoded frame */
    1.58 +#define VPX_CODEC_CAP_ERROR_CONCEALMENT   0x80000 /**< Can conceal errors due to
    1.59 +  packet loss */
    1.60 +#define VPX_CODEC_CAP_INPUT_FRAGMENTS   0x100000 /**< Can receive encoded frames
    1.61 +  one fragment at a time */
    1.62 +
    1.63 +  /*! \brief Initialization-time Feature Enabling
    1.64 +   *
    1.65 +   *  Certain codec features must be known at initialization time, to allow for
    1.66 +   *  proper memory allocation.
    1.67 +   *
    1.68 +   *  The available flags are specified by VPX_CODEC_USE_* defines.
    1.69 +   */
    1.70 +#define VPX_CODEC_CAP_FRAME_THREADING   0x200000 /**< Can support frame-based
    1.71 +                                                      multi-threading */
    1.72 +
    1.73 +#define VPX_CODEC_USE_POSTPROC   0x10000 /**< Postprocess decoded frame */
    1.74 +#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded
    1.75 +  frames */
    1.76 +#define VPX_CODEC_USE_INPUT_FRAGMENTS   0x40000 /**< The input frame should be
    1.77 +  passed to the decoder one
    1.78 +  fragment at a time */
    1.79 +#define VPX_CODEC_USE_FRAME_THREADING   0x80000 /**< Enable frame-based
    1.80 +                                                     multi-threading */
    1.81 +
    1.82 +  /*!\brief Stream properties
    1.83 +   *
    1.84 +   * This structure is used to query or set properties of the decoded
    1.85 +   * stream. Algorithms may extend this structure with data specific
    1.86 +   * to their bitstream by setting the sz member appropriately.
    1.87 +   */
    1.88 +  typedef struct vpx_codec_stream_info {
    1.89 +    unsigned int sz;     /**< Size of this structure */
    1.90 +    unsigned int w;      /**< Width (or 0 for unknown/default) */
    1.91 +    unsigned int h;      /**< Height (or 0 for unknown/default) */
    1.92 +    unsigned int is_kf;  /**< Current frame is a keyframe */
    1.93 +  } vpx_codec_stream_info_t;
    1.94 +
    1.95 +  /* REQUIRED FUNCTIONS
    1.96 +   *
    1.97 +   * The following functions are required to be implemented for all decoders.
    1.98 +   * They represent the base case functionality expected of all decoders.
    1.99 +   */
   1.100 +
   1.101 +
   1.102 +  /*!\brief Initialization Configurations
   1.103 +   *
   1.104 +   * This structure is used to pass init time configuration options to the
   1.105 +   * decoder.
   1.106 +   */
   1.107 +  typedef struct vpx_codec_dec_cfg {
   1.108 +    unsigned int threads; /**< Maximum number of threads to use, default 1 */
   1.109 +    unsigned int w;      /**< Width */
   1.110 +    unsigned int h;      /**< Height */
   1.111 +  } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
   1.112 +
   1.113 +
   1.114 +  /*!\brief Initialize a decoder instance
   1.115 +   *
   1.116 +   * Initializes a decoder context using the given interface. Applications
   1.117 +   * should call the vpx_codec_dec_init convenience macro instead of this
   1.118 +   * function directly, to ensure that the ABI version number parameter
   1.119 +   * is properly initialized.
   1.120 +   *
   1.121 +   * If the library was configured with --disable-multithread, this call
   1.122 +   * is not thread safe and should be guarded with a lock if being used
   1.123 +   * in a multithreaded context.
   1.124 +   *
   1.125 +   * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags
   1.126 +   * parameter), the storage pointed to by the cfg parameter must be
   1.127 +   * kept readable and stable until all memory maps have been set.
   1.128 +   *
   1.129 +   * \param[in]    ctx     Pointer to this instance's context.
   1.130 +   * \param[in]    iface   Pointer to the algorithm interface to use.
   1.131 +   * \param[in]    cfg     Configuration to use, if known. May be NULL.
   1.132 +   * \param[in]    flags   Bitfield of VPX_CODEC_USE_* flags
   1.133 +   * \param[in]    ver     ABI version number. Must be set to
   1.134 +   *                       VPX_DECODER_ABI_VERSION
   1.135 +   * \retval #VPX_CODEC_OK
   1.136 +   *     The decoder algorithm initialized.
   1.137 +   * \retval #VPX_CODEC_MEM_ERROR
   1.138 +   *     Memory allocation failed.
   1.139 +   */
   1.140 +  vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t      *ctx,
   1.141 +                                         vpx_codec_iface_t    *iface,
   1.142 +                                         vpx_codec_dec_cfg_t  *cfg,
   1.143 +                                         vpx_codec_flags_t     flags,
   1.144 +                                         int                   ver);
   1.145 +
   1.146 +  /*!\brief Convenience macro for vpx_codec_dec_init_ver()
   1.147 +   *
   1.148 +   * Ensures the ABI version parameter is properly set.
   1.149 +   */
   1.150 +#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
   1.151 +  vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
   1.152 +
   1.153 +
   1.154 +  /*!\brief Parse stream info from a buffer
   1.155 +   *
   1.156 +   * Performs high level parsing of the bitstream. Construction of a decoder
   1.157 +   * context is not necessary. Can be used to determine if the bitstream is
   1.158 +   * of the proper format, and to extract information from the stream.
   1.159 +   *
   1.160 +   * \param[in]      iface   Pointer to the algorithm interface
   1.161 +   * \param[in]      data    Pointer to a block of data to parse
   1.162 +   * \param[in]      data_sz Size of the data buffer
   1.163 +   * \param[in,out]  si      Pointer to stream info to update. The size member
   1.164 +   *                         \ref MUST be properly initialized, but \ref MAY be
   1.165 +   *                         clobbered by the algorithm. This parameter \ref MAY
   1.166 +   *                         be NULL.
   1.167 +   *
   1.168 +   * \retval #VPX_CODEC_OK
   1.169 +   *     Bitstream is parsable and stream information updated
   1.170 +   */
   1.171 +  vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t       *iface,
   1.172 +                                             const uint8_t           *data,
   1.173 +                                             unsigned int             data_sz,
   1.174 +                                             vpx_codec_stream_info_t *si);
   1.175 +
   1.176 +
   1.177 +  /*!\brief Return information about the current stream.
   1.178 +   *
   1.179 +   * Returns information about the stream that has been parsed during decoding.
   1.180 +   *
   1.181 +   * \param[in]      ctx     Pointer to this instance's context
   1.182 +   * \param[in,out]  si      Pointer to stream info to update. The size member
   1.183 +   *                         \ref MUST be properly initialized, but \ref MAY be
   1.184 +   *                         clobbered by the algorithm. This parameter \ref MAY
   1.185 +   *                         be NULL.
   1.186 +   *
   1.187 +   * \retval #VPX_CODEC_OK
   1.188 +   *     Bitstream is parsable and stream information updated
   1.189 +   */
   1.190 +  vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t         *ctx,
   1.191 +                                            vpx_codec_stream_info_t *si);
   1.192 +
   1.193 +
   1.194 +  /*!\brief Decode data
   1.195 +   *
   1.196 +   * Processes a buffer of coded data. If the processing results in a new
   1.197 +   * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
   1.198 +   * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
   1.199 +   * time stamp) order. Frames produced will always be in PTS (presentation
   1.200 +   * time stamp) order.
   1.201 +   * If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
   1.202 +   * data and data_sz can contain a fragment of the encoded frame. Fragment
   1.203 +   * \#n must contain at least partition \#n, but can also contain subsequent
   1.204 +   * partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
   1.205 +   * be empty. When no more data is available, this function should be called
   1.206 +   * with NULL as data and 0 as data_sz. The memory passed to this function
   1.207 +   * must be available until the frame has been decoded.
   1.208 +   *
   1.209 +   * \param[in] ctx          Pointer to this instance's context
   1.210 +   * \param[in] data         Pointer to this block of new coded data. If
   1.211 +   *                         NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
   1.212 +   *                         for the previously decoded frame.
   1.213 +   * \param[in] data_sz      Size of the coded data, in bytes.
   1.214 +   * \param[in] user_priv    Application specific data to associate with
   1.215 +   *                         this frame.
   1.216 +   * \param[in] deadline     Soft deadline the decoder should attempt to meet,
   1.217 +   *                         in us. Set to zero for unlimited.
   1.218 +   *
   1.219 +   * \return Returns #VPX_CODEC_OK if the coded data was processed completely
   1.220 +   *         and future pictures can be decoded without error. Otherwise,
   1.221 +   *         see the descriptions of the other error codes in ::vpx_codec_err_t
   1.222 +   *         for recoverability capabilities.
   1.223 +   */
   1.224 +  vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t    *ctx,
   1.225 +                                   const uint8_t        *data,
   1.226 +                                   unsigned int            data_sz,
   1.227 +                                   void               *user_priv,
   1.228 +                                   long                deadline);
   1.229 +
   1.230 +
   1.231 +  /*!\brief Decoded frames iterator
   1.232 +   *
   1.233 +   * Iterates over a list of the frames available for display. The iterator
   1.234 +   * storage should be initialized to NULL to start the iteration. Iteration is
   1.235 +   * complete when this function returns NULL.
   1.236 +   *
   1.237 +   * The list of available frames becomes valid upon completion of the
   1.238 +   * vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode.
   1.239 +   *
   1.240 +   * \param[in]     ctx      Pointer to this instance's context
   1.241 +   * \param[in,out] iter     Iterator storage, initialized to NULL
   1.242 +   *
   1.243 +   * \return Returns a pointer to an image, if one is ready for display. Frames
   1.244 +   *         produced will always be in PTS (presentation time stamp) order.
   1.245 +   */
   1.246 +  vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t  *ctx,
   1.247 +                                   vpx_codec_iter_t *iter);
   1.248 +
   1.249 +
   1.250 +  /*!\defgroup cap_put_frame Frame-Based Decoding Functions
   1.251 +   *
   1.252 +   * The following functions are required to be implemented for all decoders
   1.253 +   * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions
   1.254 +   * for codecs that don't advertise this capability will result in an error
   1.255 +   * code being returned, usually VPX_CODEC_ERROR
   1.256 +   * @{
   1.257 +   */
   1.258 +
   1.259 +  /*!\brief put frame callback prototype
   1.260 +   *
   1.261 +   * This callback is invoked by the decoder to notify the application of
   1.262 +   * the availability of decoded image data.
   1.263 +   */
   1.264 +  typedef void (*vpx_codec_put_frame_cb_fn_t)(void        *user_priv,
   1.265 +                                              const vpx_image_t *img);
   1.266 +
   1.267 +
   1.268 +  /*!\brief Register for notification of frame completion.
   1.269 +   *
   1.270 +   * Registers a given function to be called when a decoded frame is
   1.271 +   * available.
   1.272 +   *
   1.273 +   * \param[in] ctx          Pointer to this instance's context
   1.274 +   * \param[in] cb           Pointer to the callback function
   1.275 +   * \param[in] user_priv    User's private data
   1.276 +   *
   1.277 +   * \retval #VPX_CODEC_OK
   1.278 +   *     Callback successfully registered.
   1.279 +   * \retval #VPX_CODEC_ERROR
   1.280 +   *     Decoder context not initialized, or algorithm not capable of
   1.281 +   *     posting slice completion.
   1.282 +   */
   1.283 +  vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t             *ctx,
   1.284 +                                                  vpx_codec_put_frame_cb_fn_t  cb,
   1.285 +                                                  void                        *user_priv);
   1.286 +
   1.287 +
   1.288 +  /*!@} - end defgroup cap_put_frame */
   1.289 +
   1.290 +  /*!\defgroup cap_put_slice Slice-Based Decoding Functions
   1.291 +   *
   1.292 +   * The following functions are required to be implemented for all decoders
   1.293 +   * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions
   1.294 +   * for codecs that don't advertise this capability will result in an error
   1.295 +   * code being returned, usually VPX_CODEC_ERROR
   1.296 +   * @{
   1.297 +   */
   1.298 +
   1.299 +  /*!\brief put slice callback prototype
   1.300 +   *
   1.301 +   * This callback is invoked by the decoder to notify the application of
   1.302 +   * the availability of partially decoded image data. The
   1.303 +   */
   1.304 +  typedef void (*vpx_codec_put_slice_cb_fn_t)(void         *user_priv,
   1.305 +                                              const vpx_image_t      *img,
   1.306 +                                              const vpx_image_rect_t *valid,
   1.307 +                                              const vpx_image_rect_t *update);
   1.308 +
   1.309 +
   1.310 +  /*!\brief Register for notification of slice completion.
   1.311 +   *
   1.312 +   * Registers a given function to be called when a decoded slice is
   1.313 +   * available.
   1.314 +   *
   1.315 +   * \param[in] ctx          Pointer to this instance's context
   1.316 +   * \param[in] cb           Pointer to the callback function
   1.317 +   * \param[in] user_priv    User's private data
   1.318 +   *
   1.319 +   * \retval #VPX_CODEC_OK
   1.320 +   *     Callback successfully registered.
   1.321 +   * \retval #VPX_CODEC_ERROR
   1.322 +   *     Decoder context not initialized, or algorithm not capable of
   1.323 +   *     posting slice completion.
   1.324 +   */
   1.325 +  vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t             *ctx,
   1.326 +                                                  vpx_codec_put_slice_cb_fn_t  cb,
   1.327 +                                                  void                        *user_priv);
   1.328 +
   1.329 +
   1.330 +  /*!@} - end defgroup cap_put_slice*/
   1.331 +
   1.332 +  /*!@} - end defgroup decoder*/
   1.333 +#ifdef __cplusplus
   1.334 +}
   1.335 +#endif
   1.336 +#endif
   1.337 +

mercurial