190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber/* 2f71323e297a928af368937089d3ed71239786f86Andreas Huber * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 4f71323e297a928af368937089d3ed71239786f86Andreas Huber * Use of this source code is governed by a BSD-style license 5f71323e297a928af368937089d3ed71239786f86Andreas Huber * that can be found in the LICENSE file in the root of the source 6f71323e297a928af368937089d3ed71239786f86Andreas Huber * tree. An additional intellectual property rights grant can be found 7f71323e297a928af368937089d3ed71239786f86Andreas Huber * in the file PATENTS. All contributing project authors may 8f71323e297a928af368937089d3ed71239786f86Andreas Huber * be found in the AUTHORS file in the root of the source tree. 990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 10b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifndef VPX_VPX_DECODER_H_ 11b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#define VPX_VPX_DECODER_H_ 1290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 1390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber/*!\defgroup decoder Decoder Algorithm Interface 1490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * \ingroup codec 1590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * This abstraction allows applications using this decoder to easily support 1690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * multiple video formats with minimal code duplication. This section describes 1790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * the interface common to all decoders. 1890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * @{ 1990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 2090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 2179f15823c34ae1e423108295e416213200bb280fAndreas Huber/*!\file 2290d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * \brief Describes the decoder algorithm interface to applications. 2390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 2490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * This file describes the interface between an application and a 2590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * video decoder algorithm. 2690d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber * 2790d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber */ 2890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#ifdef __cplusplus 2990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huberextern "C" { 3090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#endif 3190d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 32b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "./vpx_codec.h" 33b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "./vpx_frame_buffer.h" 3490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 35ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Current ABI version number 36ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 37ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \internal 38ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If this file is altered in any way that changes the ABI, this value 39ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * must be bumped. Examples include, but are not limited to, changing 40ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * types, removing or reassigning enums, adding/removing/rearranging 41ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * fields to structures 42ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 43b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#define VPX_DECODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ 4490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber 45ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! \brief Decoder capabilities bitfield 46ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 47ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Each decoder advertises the capabilities it supports as part of its 48ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces 49ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * or functionality, and are not required to be supported by a decoder. 50ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 51ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The available flags are specified by VPX_CODEC_CAP_* defines. 52ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 5390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */ 5490d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */ 5590d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */ 561b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000 /**< Can conceal errors due to 57ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang packet loss */ 581b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000 /**< Can receive encoded frames 59ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang one fragment at a time */ 60ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 61ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*! \brief Initialization-time Feature Enabling 62ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 63ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Certain codec features must be known at initialization time, to allow for 64ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * proper memory allocation. 65ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 66ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The available flags are specified by VPX_CODEC_USE_* defines. 67ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 68ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_CODEC_CAP_FRAME_THREADING 0x200000 /**< Can support frame-based 69ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang multi-threading */ 70b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000 /**< Can support external 71b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian frame buffers */ 72ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 7390d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */ 741b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded 75ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang frames */ 761b362b15af34006e6a11974088a46d42b903418eJohann#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000 /**< The input frame should be 77ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang passed to the decoder one 78ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang fragment at a time */ 79ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VPX_CODEC_USE_FRAME_THREADING 0x80000 /**< Enable frame-based 80ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang multi-threading */ 81ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 82ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Stream properties 83ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 84ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure is used to query or set properties of the decoded 85ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * stream. Algorithms may extend this structure with data specific 86ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * to their bitstream by setting the sz member appropriately. 87ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 88ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_codec_stream_info { 89ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int sz; /**< Size of this structure */ 90ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int w; /**< Width (or 0 for unknown/default) */ 91ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int h; /**< Height (or 0 for unknown/default) */ 92ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int is_kf; /**< Current frame is a keyframe */ 93ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_codec_stream_info_t; 94ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 95ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /* REQUIRED FUNCTIONS 96ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 97ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The following functions are required to be implemented for all decoders. 98ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * They represent the base case functionality expected of all decoders. 99ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 100ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 101ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 102ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Initialization Configurations 103ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 104ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This structure is used to pass init time configuration options to the 105ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * decoder. 106ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 107ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef struct vpx_codec_dec_cfg { 108ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int threads; /**< Maximum number of threads to use, default 1 */ 109ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int w; /**< Width */ 110ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int h; /**< Height */ 111ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */ 112ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 113ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 114ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Initialize a decoder instance 115ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 116ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Initializes a decoder context using the given interface. Applications 117ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * should call the vpx_codec_dec_init convenience macro instead of this 118ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * function directly, to ensure that the ABI version number parameter 119ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * is properly initialized. 120ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 121ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If the library was configured with --disable-multithread, this call 122ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * is not thread safe and should be guarded with a lock if being used 123ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in a multithreaded context. 124ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 125ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * In XMA mode (activated by setting VPX_CODEC_USE_XMA in the flags 126ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * parameter), the storage pointed to by the cfg parameter must be 127ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * kept readable and stable until all memory maps have been set. 128ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 129ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context. 130ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] iface Pointer to the algorithm interface to use. 131ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cfg Configuration to use, if known. May be NULL. 132ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] flags Bitfield of VPX_CODEC_USE_* flags 133ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ver ABI version number. Must be set to 134ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * VPX_DECODER_ABI_VERSION 135ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 136ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The decoder algorithm initialized. 137ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_MEM_ERROR 138ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Memory allocation failed. 139ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 140ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, 141ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_iface_t *iface, 142ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_dec_cfg_t *cfg, 143ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_flags_t flags, 144ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang int ver); 145ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 146ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Convenience macro for vpx_codec_dec_init_ver() 147ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 148ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Ensures the ABI version parameter is properly set. 149ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 15090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#define vpx_codec_dec_init(ctx, iface, cfg, flags) \ 151ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION) 152ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 153ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 154ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Parse stream info from a buffer 155ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 156ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Performs high level parsing of the bitstream. Construction of a decoder 157ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * context is not necessary. Can be used to determine if the bitstream is 158ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * of the proper format, and to extract information from the stream. 159ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 160ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] iface Pointer to the algorithm interface 161ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] data Pointer to a block of data to parse 162ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] data_sz Size of the data buffer 163ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in,out] si Pointer to stream info to update. The size member 164ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \ref MUST be properly initialized, but \ref MAY be 165ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * clobbered by the algorithm. This parameter \ref MAY 166ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be NULL. 167ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 168ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 169ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Bitstream is parsable and stream information updated 170ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 171ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface, 172ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const uint8_t *data, 173ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int data_sz, 174ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_stream_info_t *si); 175ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 176ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 177ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Return information about the current stream. 178ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 179ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Returns information about the stream that has been parsed during decoding. 180ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 181ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 182ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in,out] si Pointer to stream info to update. The size member 183ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \ref MUST be properly initialized, but \ref MAY be 184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * clobbered by the algorithm. This parameter \ref MAY 185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be NULL. 186ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 187ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 188ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Bitstream is parsable and stream information updated 189ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 190ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx, 191ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_stream_info_t *si); 192ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 193ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 194ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Decode data 195ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 196ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Processes a buffer of coded data. If the processing results in a new 197ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be 198ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode 199ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * time stamp) order. Frames produced will always be in PTS (presentation 200ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * time stamp) order. 201ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled, 202ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * data and data_sz can contain a fragment of the encoded frame. Fragment 203ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \#n must contain at least partition \#n, but can also contain subsequent 204ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must 205ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * be empty. When no more data is available, this function should be called 206ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * with NULL as data and 0 as data_sz. The memory passed to this function 207ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * must be available until the frame has been decoded. 208ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 209ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 210ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] data Pointer to this block of new coded data. If 211ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * NULL, a VPX_CODEC_CB_PUT_FRAME event is posted 212ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for the previously decoded frame. 213ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] data_sz Size of the coded data, in bytes. 214ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] user_priv Application specific data to associate with 215ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * this frame. 216ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] deadline Soft deadline the decoder should attempt to meet, 217ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * in us. Set to zero for unlimited. 218ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 219ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \return Returns #VPX_CODEC_OK if the coded data was processed completely 220ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * and future pictures can be decoded without error. Otherwise, 221ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * see the descriptions of the other error codes in ::vpx_codec_err_t 222ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for recoverability capabilities. 223ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 224ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, 225ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const uint8_t *data, 226ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned int data_sz, 227ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void *user_priv, 228ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang long deadline); 229ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 230ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 231ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Decoded frames iterator 232ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 233ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Iterates over a list of the frames available for display. The iterator 234ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * storage should be initialized to NULL to start the iteration. Iteration is 235ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * complete when this function returns NULL. 236ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 237ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The list of available frames becomes valid upon completion of the 238ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * vpx_codec_decode call, and remains valid until the next call to vpx_codec_decode. 239ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 240ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 241ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in,out] iter Iterator storage, initialized to NULL 242ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 243ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \return Returns a pointer to an image, if one is ready for display. Frames 244ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * produced will always be in PTS (presentation time stamp) order. 245ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 246ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, 247ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_iter_t *iter); 248ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 249ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 250ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\defgroup cap_put_frame Frame-Based Decoding Functions 251ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 252ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The following functions are required to be implemented for all decoders 253ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these functions 254ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for codecs that don't advertise this capability will result in an error 255ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * code being returned, usually VPX_CODEC_ERROR 256ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * @{ 257ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 258ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 259ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief put frame callback prototype 260ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 261ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This callback is invoked by the decoder to notify the application of 262ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the availability of decoded image data. 263ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 264ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv, 265ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_t *img); 266ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 267ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 268ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Register for notification of frame completion. 269ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 270ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Registers a given function to be called when a decoded frame is 271ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * available. 272ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 273ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 274ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cb Pointer to the callback function 275ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] user_priv User's private data 276ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 277ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 278ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Callback successfully registered. 279ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_ERROR 280ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Decoder context not initialized, or algorithm not capable of 281ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * posting slice completion. 282ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 283ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx, 284ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_put_frame_cb_fn_t cb, 285ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void *user_priv); 286ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 287ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 288ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!@} - end defgroup cap_put_frame */ 289ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 290ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\defgroup cap_put_slice Slice-Based Decoding Functions 291ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 292ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * The following functions are required to be implemented for all decoders 293ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these functions 294ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * for codecs that don't advertise this capability will result in an error 295ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * code being returned, usually VPX_CODEC_ERROR 296ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * @{ 297ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 298ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 299ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief put slice callback prototype 300ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 301ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * This callback is invoked by the decoder to notify the application of 302ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * the availability of partially decoded image data. The 303ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 304ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv, 305ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_t *img, 306ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_rect_t *valid, 307ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const vpx_image_rect_t *update); 308ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 309ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 310ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!\brief Register for notification of slice completion. 311ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 312ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Registers a given function to be called when a decoded slice is 313ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * available. 314ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 315ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] ctx Pointer to this instance's context 316ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] cb Pointer to the callback function 317ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \param[in] user_priv User's private data 318ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * 319ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_OK 320ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Callback successfully registered. 321ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * \retval #VPX_CODEC_ERROR 322ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * Decoder context not initialized, or algorithm not capable of 323ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang * posting slice completion. 324ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */ 325ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx, 326ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang vpx_codec_put_slice_cb_fn_t cb, 327ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void *user_priv); 328ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 329ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 330ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!@} - end defgroup cap_put_slice*/ 331ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 332b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /*!\defgroup cap_external_frame_buffer External Frame Buffer Functions 333b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 334b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * The following section is required to be implemented for all decoders 335b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability. 336b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * Calling this function for codecs that don't advertise this capability 337b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * will result in an error code being returned, usually VPX_CODEC_ERROR. 338b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 339b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \note 340b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * Currently this only works with VP9. 341b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * @{ 342b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian */ 343b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 344b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /*!\brief Pass in external frame buffers for the decoder to use. 345b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 346b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * Registers functions to be called when libvpx needs a frame buffer 347b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * to decode the current frame and a function to be called when libvpx does 348b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * not internally reference the frame buffer. This set function must 349b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * be called before the first call to decode or libvpx will assume the 350b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * default behavior of allocating frame buffers internally. 351b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 352b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \param[in] ctx Pointer to this instance's context 353b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \param[in] cb_get Pointer to the get callback function 354b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \param[in] cb_release Pointer to the release callback function 355b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \param[in] cb_priv Callback's private data 356b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 357b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \retval #VPX_CODEC_OK 358b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * External frame buffers will be used by libvpx. 359b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \retval #VPX_CODEC_INVALID_PARAM 360b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * One or more of the callbacks were NULL. 361b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \retval #VPX_CODEC_ERROR 362b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * Decoder context not initialized, or algorithm not capable of 363b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * using external frame buffers. 364b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * 365b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * \note 366b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * When decoding VP9, the application may be required to pass in at least 367b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame 368b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian * buffers. 369b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian */ 370b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian vpx_codec_err_t vpx_codec_set_frame_buffer_functions( 371b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian vpx_codec_ctx_t *ctx, 372b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian vpx_get_frame_buffer_cb_fn_t cb_get, 373b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv); 374b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 375b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /*!@} - end defgroup cap_external_frame_buffer */ 376b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 377ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /*!@} - end defgroup decoder*/ 37890d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#ifdef __cplusplus 37990d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber} 38090d3ed91ae9228e1c8bab561b6138d4cb8c1e4fdAndreas Huber#endif 381b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif // VPX_VPX_DECODER_H_ 3825ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 383