Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 11 | #ifndef AOM_AOM_DECODER_H_ |
| 12 | #define AOM_AOM_DECODER_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 13 | |
| 14 | /*!\defgroup decoder Decoder Algorithm Interface |
| 15 | * \ingroup codec |
| 16 | * This abstraction allows applications using this decoder to easily support |
| 17 | * multiple video formats with minimal code duplication. This section describes |
| 18 | * the interface common to all decoders. |
| 19 | * @{ |
| 20 | */ |
| 21 | |
| 22 | /*!\file |
| 23 | * \brief Describes the decoder algorithm interface to applications. |
| 24 | * |
| 25 | * This file describes the interface between an application and a |
| 26 | * video decoder algorithm. |
| 27 | * |
| 28 | */ |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 33 | #include "./aom_codec.h" |
| 34 | #include "./aom_frame_buffer.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 35 | |
| 36 | /*!\brief Current ABI version number |
| 37 | * |
| 38 | * \internal |
| 39 | * If this file is altered in any way that changes the ABI, this value |
| 40 | * must be bumped. Examples include, but are not limited to, changing |
| 41 | * types, removing or reassigning enums, adding/removing/rearranging |
| 42 | * fields to structures |
| 43 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 44 | #define AOM_DECODER_ABI_VERSION \ |
| 45 | (3 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 46 | |
| 47 | /*! \brief Decoder capabilities bitfield |
| 48 | * |
| 49 | * Each decoder advertises the capabilities it supports as part of its |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 50 | * ::aom_codec_iface_t interface structure. Capabilities are extra interfaces |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 51 | * or functionality, and are not required to be supported by a decoder. |
| 52 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 53 | * The available flags are specified by AOM_CODEC_CAP_* defines. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 54 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 55 | #define AOM_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */ |
| 56 | #define AOM_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */ |
| 57 | #define AOM_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | /*!\brief Can receive encoded frames one fragment at a time */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 59 | #define AOM_CODEC_CAP_INPUT_FRAGMENTS 0x100000 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 60 | |
| 61 | /*! \brief Initialization-time Feature Enabling |
| 62 | * |
| 63 | * Certain codec features must be known at initialization time, to allow for |
| 64 | * proper memory allocation. |
| 65 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 66 | * The available flags are specified by AOM_CODEC_USE_* defines. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 67 | */ |
| 68 | /*!\brief Can support frame-based multi-threading */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 69 | #define AOM_CODEC_CAP_FRAME_THREADING 0x200000 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 70 | /*!brief Can support external frame buffers */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 71 | #define AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 72 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 73 | #define AOM_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 74 | /*!\brief The input frame should be passed to the decoder one fragment at a |
| 75 | * time */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 76 | #define AOM_CODEC_USE_INPUT_FRAGMENTS 0x40000 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 77 | /*!\brief Enable frame-based multi-threading */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 78 | #define AOM_CODEC_USE_FRAME_THREADING 0x80000 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 79 | |
| 80 | /*!\brief Stream properties |
| 81 | * |
| 82 | * This structure is used to query or set properties of the decoded |
Ralph Giles | afe71d9 | 2017-05-03 13:18:57 -0700 | [diff] [blame] | 83 | * stream. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 84 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 85 | typedef struct aom_codec_stream_info { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | unsigned int w; /**< Width (or 0 for unknown/default) */ |
| 87 | unsigned int h; /**< Height (or 0 for unknown/default) */ |
| 88 | unsigned int is_kf; /**< Current frame is a keyframe */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 89 | } aom_codec_stream_info_t; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 90 | |
| 91 | /* REQUIRED FUNCTIONS |
| 92 | * |
| 93 | * The following functions are required to be implemented for all decoders. |
| 94 | * They represent the base case functionality expected of all decoders. |
| 95 | */ |
| 96 | |
| 97 | /*!\brief Initialization Configurations |
| 98 | * |
| 99 | * This structure is used to pass init time configuration options to the |
| 100 | * decoder. |
| 101 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 102 | typedef struct aom_codec_dec_cfg { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 103 | unsigned int threads; /**< Maximum number of threads to use, default 1 */ |
| 104 | unsigned int w; /**< Width */ |
| 105 | unsigned int h; /**< Height */ |
Sebastien Alaiwan | 8b7a4e1 | 2017-06-13 11:25:57 +0200 | [diff] [blame] | 106 | unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */ |
| 107 | } aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 108 | |
| 109 | /*!\brief Initialize a decoder instance |
| 110 | * |
| 111 | * Initializes a decoder context using the given interface. Applications |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 112 | * should call the aom_codec_dec_init convenience macro instead of this |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 113 | * function directly, to ensure that the ABI version number parameter |
| 114 | * is properly initialized. |
| 115 | * |
| 116 | * If the library was configured with --disable-multithread, this call |
| 117 | * is not thread safe and should be guarded with a lock if being used |
| 118 | * in a multithreaded context. |
| 119 | * |
| 120 | * \param[in] ctx Pointer to this instance's context. |
| 121 | * \param[in] iface Pointer to the algorithm interface to use. |
| 122 | * \param[in] cfg Configuration to use, if known. May be NULL. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 123 | * \param[in] flags Bitfield of AOM_CODEC_USE_* flags |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 124 | * \param[in] ver ABI version number. Must be set to |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 125 | * AOM_DECODER_ABI_VERSION |
| 126 | * \retval #AOM_CODEC_OK |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 127 | * The decoder algorithm initialized. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 128 | * \retval #AOM_CODEC_MEM_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 129 | * Memory allocation failed. |
| 130 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 131 | aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx, |
| 132 | aom_codec_iface_t *iface, |
| 133 | const aom_codec_dec_cfg_t *cfg, |
| 134 | aom_codec_flags_t flags, int ver); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 135 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 136 | /*!\brief Convenience macro for aom_codec_dec_init_ver() |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 137 | * |
| 138 | * Ensures the ABI version parameter is properly set. |
| 139 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 140 | #define aom_codec_dec_init(ctx, iface, cfg, flags) \ |
| 141 | aom_codec_dec_init_ver(ctx, iface, cfg, flags, AOM_DECODER_ABI_VERSION) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 142 | |
| 143 | /*!\brief Parse stream info from a buffer |
| 144 | * |
| 145 | * Performs high level parsing of the bitstream. Construction of a decoder |
| 146 | * context is not necessary. Can be used to determine if the bitstream is |
| 147 | * of the proper format, and to extract information from the stream. |
| 148 | * |
| 149 | * \param[in] iface Pointer to the algorithm interface |
| 150 | * \param[in] data Pointer to a block of data to parse |
| 151 | * \param[in] data_sz Size of the data buffer |
Ralph Giles | afe71d9 | 2017-05-03 13:18:57 -0700 | [diff] [blame] | 152 | * \param[in,out] si Pointer to stream info to update. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 153 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 154 | * \retval #AOM_CODEC_OK |
Ralph Giles | afe71d9 | 2017-05-03 13:18:57 -0700 | [diff] [blame] | 155 | * Bitstream is parsable and stream information updated. |
| 156 | * \retval #AOM_CODEC_INVALID_PARAM |
| 157 | * One of the arguments is invalid, for example a NULL pointer. |
| 158 | * \retval #AOM_CODEC_UNSUP_BITSTREAM |
| 159 | * The decoder didn't recognize the coded data, or the |
| 160 | * buffer was too short. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 161 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 162 | aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 163 | const uint8_t *data, |
| 164 | unsigned int data_sz, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 165 | aom_codec_stream_info_t *si); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 166 | |
| 167 | /*!\brief Return information about the current stream. |
| 168 | * |
| 169 | * Returns information about the stream that has been parsed during decoding. |
| 170 | * |
| 171 | * \param[in] ctx Pointer to this instance's context |
Ralph Giles | afe71d9 | 2017-05-03 13:18:57 -0700 | [diff] [blame] | 172 | * \param[in,out] si Pointer to stream info to update. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 173 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 174 | * \retval #AOM_CODEC_OK |
Ralph Giles | afe71d9 | 2017-05-03 13:18:57 -0700 | [diff] [blame] | 175 | * Bitstream is parsable and stream information updated. |
| 176 | * \retval #AOM_CODEC_INVALID_PARAM |
| 177 | * One of the arguments is invalid, for example a NULL pointer. |
| 178 | * \retval #AOM_CODEC_UNSUP_BITSTREAM |
| 179 | * The decoder couldn't parse the submitted data. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 180 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 181 | aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx, |
| 182 | aom_codec_stream_info_t *si); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 183 | |
| 184 | /*!\brief Decode data |
| 185 | * |
| 186 | * Processes a buffer of coded data. If the processing results in a new |
| 187 | * decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be |
| 188 | * generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode |
| 189 | * time stamp) order. Frames produced will always be in PTS (presentation |
| 190 | * time stamp) order. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 191 | * If the decoder is configured with AOM_CODEC_USE_INPUT_FRAGMENTS enabled, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 192 | * data and data_sz can contain a fragment of the encoded frame. Fragment |
| 193 | * \#n must contain at least partition \#n, but can also contain subsequent |
| 194 | * partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must |
| 195 | * be empty. When no more data is available, this function should be called |
| 196 | * with NULL as data and 0 as data_sz. The memory passed to this function |
| 197 | * must be available until the frame has been decoded. |
| 198 | * |
| 199 | * \param[in] ctx Pointer to this instance's context |
| 200 | * \param[in] data Pointer to this block of new coded data. If |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 201 | * NULL, a AOM_CODEC_CB_PUT_FRAME event is posted |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 202 | * for the previously decoded frame. |
| 203 | * \param[in] data_sz Size of the coded data, in bytes. |
| 204 | * \param[in] user_priv Application specific data to associate with |
| 205 | * this frame. |
| 206 | * \param[in] deadline Soft deadline the decoder should attempt to meet, |
| 207 | * in us. Set to zero for unlimited. |
| 208 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 209 | * \return Returns #AOM_CODEC_OK if the coded data was processed completely |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 210 | * and future pictures can be decoded without error. Otherwise, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 211 | * see the descriptions of the other error codes in ::aom_codec_err_t |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 212 | * for recoverability capabilities. |
| 213 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 214 | aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 215 | unsigned int data_sz, void *user_priv, |
| 216 | long deadline); |
| 217 | |
| 218 | /*!\brief Decoded frames iterator |
| 219 | * |
| 220 | * Iterates over a list of the frames available for display. The iterator |
| 221 | * storage should be initialized to NULL to start the iteration. Iteration is |
| 222 | * complete when this function returns NULL. |
| 223 | * |
| 224 | * The list of available frames becomes valid upon completion of the |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 225 | * aom_codec_decode call, and remains valid until the next call to |
| 226 | * aom_codec_decode. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 227 | * |
| 228 | * \param[in] ctx Pointer to this instance's context |
| 229 | * \param[in,out] iter Iterator storage, initialized to NULL |
| 230 | * |
| 231 | * \return Returns a pointer to an image, if one is ready for display. Frames |
| 232 | * produced will always be in PTS (presentation time stamp) order. |
| 233 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 234 | aom_image_t *aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 235 | |
| 236 | /*!\defgroup cap_put_frame Frame-Based Decoding Functions |
| 237 | * |
| 238 | * The following functions are required to be implemented for all decoders |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 239 | * that advertise the AOM_CODEC_CAP_PUT_FRAME capability. Calling these |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 240 | * functions |
| 241 | * for codecs that don't advertise this capability will result in an error |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 242 | * code being returned, usually AOM_CODEC_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 243 | * @{ |
| 244 | */ |
| 245 | |
| 246 | /*!\brief put frame callback prototype |
| 247 | * |
| 248 | * This callback is invoked by the decoder to notify the application of |
| 249 | * the availability of decoded image data. |
| 250 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 251 | typedef void (*aom_codec_put_frame_cb_fn_t)(void *user_priv, |
| 252 | const aom_image_t *img); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 253 | |
| 254 | /*!\brief Register for notification of frame completion. |
| 255 | * |
| 256 | * Registers a given function to be called when a decoded frame is |
| 257 | * available. |
| 258 | * |
| 259 | * \param[in] ctx Pointer to this instance's context |
| 260 | * \param[in] cb Pointer to the callback function |
| 261 | * \param[in] user_priv User's private data |
| 262 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 263 | * \retval #AOM_CODEC_OK |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 264 | * Callback successfully registered. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 265 | * \retval #AOM_CODEC_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 266 | * Decoder context not initialized, or algorithm not capable of |
| 267 | * posting slice completion. |
| 268 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 269 | aom_codec_err_t aom_codec_register_put_frame_cb(aom_codec_ctx_t *ctx, |
| 270 | aom_codec_put_frame_cb_fn_t cb, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 271 | void *user_priv); |
| 272 | |
| 273 | /*!@} - end defgroup cap_put_frame */ |
| 274 | |
| 275 | /*!\defgroup cap_put_slice Slice-Based Decoding Functions |
| 276 | * |
| 277 | * The following functions are required to be implemented for all decoders |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 278 | * that advertise the AOM_CODEC_CAP_PUT_SLICE capability. Calling these |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 279 | * functions |
| 280 | * for codecs that don't advertise this capability will result in an error |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 281 | * code being returned, usually AOM_CODEC_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 282 | * @{ |
| 283 | */ |
| 284 | |
| 285 | /*!\brief put slice callback prototype |
| 286 | * |
| 287 | * This callback is invoked by the decoder to notify the application of |
| 288 | * the availability of partially decoded image data. The |
| 289 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 290 | typedef void (*aom_codec_put_slice_cb_fn_t)(void *user_priv, |
| 291 | const aom_image_t *img, |
| 292 | const aom_image_rect_t *valid, |
| 293 | const aom_image_rect_t *update); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 294 | |
| 295 | /*!\brief Register for notification of slice completion. |
| 296 | * |
| 297 | * Registers a given function to be called when a decoded slice is |
| 298 | * available. |
| 299 | * |
| 300 | * \param[in] ctx Pointer to this instance's context |
| 301 | * \param[in] cb Pointer to the callback function |
| 302 | * \param[in] user_priv User's private data |
| 303 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 304 | * \retval #AOM_CODEC_OK |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 305 | * Callback successfully registered. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 306 | * \retval #AOM_CODEC_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 307 | * Decoder context not initialized, or algorithm not capable of |
| 308 | * posting slice completion. |
| 309 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 310 | aom_codec_err_t aom_codec_register_put_slice_cb(aom_codec_ctx_t *ctx, |
| 311 | aom_codec_put_slice_cb_fn_t cb, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 312 | void *user_priv); |
| 313 | |
| 314 | /*!@} - end defgroup cap_put_slice*/ |
| 315 | |
| 316 | /*!\defgroup cap_external_frame_buffer External Frame Buffer Functions |
| 317 | * |
| 318 | * The following section is required to be implemented for all decoders |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 319 | * that advertise the AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 320 | * Calling this function for codecs that don't advertise this capability |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 321 | * will result in an error code being returned, usually AOM_CODEC_ERROR. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 322 | * |
| 323 | * \note |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 324 | * Currently this only works with AV1. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 325 | * @{ |
| 326 | */ |
| 327 | |
| 328 | /*!\brief Pass in external frame buffers for the decoder to use. |
| 329 | * |
| 330 | * Registers functions to be called when libaom needs a frame buffer |
| 331 | * to decode the current frame and a function to be called when libaom does |
| 332 | * not internally reference the frame buffer. This set function must |
| 333 | * be called before the first call to decode or libaom will assume the |
| 334 | * default behavior of allocating frame buffers internally. |
| 335 | * |
| 336 | * \param[in] ctx Pointer to this instance's context |
| 337 | * \param[in] cb_get Pointer to the get callback function |
| 338 | * \param[in] cb_release Pointer to the release callback function |
| 339 | * \param[in] cb_priv Callback's private data |
| 340 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 341 | * \retval #AOM_CODEC_OK |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 342 | * External frame buffers will be used by libaom. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 343 | * \retval #AOM_CODEC_INVALID_PARAM |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 344 | * One or more of the callbacks were NULL. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 345 | * \retval #AOM_CODEC_ERROR |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 346 | * Decoder context not initialized, or algorithm not capable of |
| 347 | * using external frame buffers. |
| 348 | * |
| 349 | * \note |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 350 | * When decoding AV1, the application may be required to pass in at least |
| 351 | * #AOM_MAXIMUM_WORK_BUFFERS external frame |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 352 | * buffers. |
| 353 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 354 | aom_codec_err_t aom_codec_set_frame_buffer_functions( |
| 355 | aom_codec_ctx_t *ctx, aom_get_frame_buffer_cb_fn_t cb_get, |
| 356 | aom_release_frame_buffer_cb_fn_t cb_release, void *cb_priv); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 357 | |
| 358 | /*!@} - end defgroup cap_external_frame_buffer */ |
| 359 | |
| 360 | /*!@} - end defgroup decoder*/ |
| 361 | #ifdef __cplusplus |
| 362 | } |
| 363 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 364 | #endif // AOM_AOM_DECODER_H_ |