1*77c1e3ccSAndroid Build Coastguard Worker /* 2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker * 4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker */ 11*77c1e3ccSAndroid Build Coastguard Worker 12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AOM_AOM_FRAME_BUFFER_H_ 13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AOM_AOM_FRAME_BUFFER_H_ 14*77c1e3ccSAndroid Build Coastguard Worker 15*77c1e3ccSAndroid Build Coastguard Worker /*!\file 16*77c1e3ccSAndroid Build Coastguard Worker * \brief Describes the decoder external frame buffer interface. 17*77c1e3ccSAndroid Build Coastguard Worker */ 18*77c1e3ccSAndroid Build Coastguard Worker 19*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 20*77c1e3ccSAndroid Build Coastguard Worker extern "C" { 21*77c1e3ccSAndroid Build Coastguard Worker #endif 22*77c1e3ccSAndroid Build Coastguard Worker 23*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h" 24*77c1e3ccSAndroid Build Coastguard Worker 25*77c1e3ccSAndroid Build Coastguard Worker /*!\brief The maximum number of work buffers used by libaom. 26*77c1e3ccSAndroid Build Coastguard Worker * Support maximum 4 threads to decode video in parallel. 27*77c1e3ccSAndroid Build Coastguard Worker * Each thread will use one work buffer. 28*77c1e3ccSAndroid Build Coastguard Worker * TODO(hkuang): Add support to set number of worker threads dynamically. 29*77c1e3ccSAndroid Build Coastguard Worker */ 30*77c1e3ccSAndroid Build Coastguard Worker #define AOM_MAXIMUM_WORK_BUFFERS 8 31*77c1e3ccSAndroid Build Coastguard Worker 32*77c1e3ccSAndroid Build Coastguard Worker /*!\brief The maximum number of reference buffers that a AV1 encoder may use. 33*77c1e3ccSAndroid Build Coastguard Worker */ 34*77c1e3ccSAndroid Build Coastguard Worker #define AOM_MAXIMUM_REF_BUFFERS 8 35*77c1e3ccSAndroid Build Coastguard Worker 36*77c1e3ccSAndroid Build Coastguard Worker /*!\brief External frame buffer 37*77c1e3ccSAndroid Build Coastguard Worker * 38*77c1e3ccSAndroid Build Coastguard Worker * This structure holds allocated frame buffers used by the decoder. 39*77c1e3ccSAndroid Build Coastguard Worker */ 40*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_codec_frame_buffer { 41*77c1e3ccSAndroid Build Coastguard Worker uint8_t *data; /**< Pointer to the data buffer */ 42*77c1e3ccSAndroid Build Coastguard Worker size_t size; /**< Size of data in bytes */ 43*77c1e3ccSAndroid Build Coastguard Worker void *priv; /**< Frame's private data */ 44*77c1e3ccSAndroid Build Coastguard Worker } aom_codec_frame_buffer_t; 45*77c1e3ccSAndroid Build Coastguard Worker 46*77c1e3ccSAndroid Build Coastguard Worker /*!\brief get frame buffer callback prototype 47*77c1e3ccSAndroid Build Coastguard Worker * 48*77c1e3ccSAndroid Build Coastguard Worker * This callback is invoked by the decoder to retrieve data for the frame 49*77c1e3ccSAndroid Build Coastguard Worker * buffer in order for the decode call to complete. The callback must 50*77c1e3ccSAndroid Build Coastguard Worker * allocate at least min_size in bytes and assign it to fb->data. The callback 51*77c1e3ccSAndroid Build Coastguard Worker * must zero out all the data allocated. Then the callback must set fb->size 52*77c1e3ccSAndroid Build Coastguard Worker * to the allocated size. The application does not need to align the allocated 53*77c1e3ccSAndroid Build Coastguard Worker * data. The callback is triggered when the decoder needs a frame buffer to 54*77c1e3ccSAndroid Build Coastguard Worker * decode a compressed image into. This function may be called more than once 55*77c1e3ccSAndroid Build Coastguard Worker * for every call to aom_codec_decode. The application may set fb->priv to 56*77c1e3ccSAndroid Build Coastguard Worker * some data which will be passed back in the aom_image_t and the release 57*77c1e3ccSAndroid Build Coastguard Worker * function call. |fb| is guaranteed to not be NULL. On success the callback 58*77c1e3ccSAndroid Build Coastguard Worker * must return 0. Any failure the callback must return a value less than 0. 59*77c1e3ccSAndroid Build Coastguard Worker * 60*77c1e3ccSAndroid Build Coastguard Worker * \param[in] priv Callback's private data 61*77c1e3ccSAndroid Build Coastguard Worker * \param[in] min_size Size in bytes needed by the buffer 62*77c1e3ccSAndroid Build Coastguard Worker * \param[in,out] fb Pointer to aom_codec_frame_buffer_t 63*77c1e3ccSAndroid Build Coastguard Worker */ 64*77c1e3ccSAndroid Build Coastguard Worker typedef int (*aom_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size, 65*77c1e3ccSAndroid Build Coastguard Worker aom_codec_frame_buffer_t *fb); 66*77c1e3ccSAndroid Build Coastguard Worker 67*77c1e3ccSAndroid Build Coastguard Worker /*!\brief release frame buffer callback prototype 68*77c1e3ccSAndroid Build Coastguard Worker * 69*77c1e3ccSAndroid Build Coastguard Worker * This callback is invoked by the decoder when the frame buffer is not 70*77c1e3ccSAndroid Build Coastguard Worker * referenced by any other buffers. |fb| is guaranteed to not be NULL. On 71*77c1e3ccSAndroid Build Coastguard Worker * success the callback must return 0. Any failure the callback must return 72*77c1e3ccSAndroid Build Coastguard Worker * a value less than 0. 73*77c1e3ccSAndroid Build Coastguard Worker * 74*77c1e3ccSAndroid Build Coastguard Worker * \param[in] priv Callback's private data 75*77c1e3ccSAndroid Build Coastguard Worker * \param[in] fb Pointer to aom_codec_frame_buffer_t 76*77c1e3ccSAndroid Build Coastguard Worker */ 77*77c1e3ccSAndroid Build Coastguard Worker typedef int (*aom_release_frame_buffer_cb_fn_t)(void *priv, 78*77c1e3ccSAndroid Build Coastguard Worker aom_codec_frame_buffer_t *fb); 79*77c1e3ccSAndroid Build Coastguard Worker 80*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 81*77c1e3ccSAndroid Build Coastguard Worker } // extern "C" 82*77c1e3ccSAndroid Build Coastguard Worker #endif 83*77c1e3ccSAndroid Build Coastguard Worker 84*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AOM_AOM_FRAME_BUFFER_H_ 85