1 /* 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 3 * 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 */ 10 11 #ifndef VPX_VPX_FRAME_BUFFER_H_ 12 #define VPX_VPX_FRAME_BUFFER_H_ 13 14 /*!\file 15 * \brief Describes the decoder external frame buffer interface. 16 */ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #include "./vpx_integer.h" 23 24 /*!\brief The maximum number of work buffers used by libvpx. 25 */ 26 #define VPX_MAXIMUM_WORK_BUFFERS 1 27 28 /*!\brief The maximum number of reference buffers that a VP9 encoder may use. 29 */ 30 #define VP9_MAXIMUM_REF_BUFFERS 8 31 32 /*!\brief External frame buffer 33 * 34 * This structure holds allocated frame buffers used by the decoder. 35 */ 36 typedef struct vpx_codec_frame_buffer { 37 uint8_t *data; /**< Pointer to the data buffer */ 38 size_t size; /**< Size of data in bytes */ 39 void *priv; /**< Frame's private data */ 40 41 int fb_index; 42 int fb_stride; 43 int fb_height_stride; 44 } vpx_codec_frame_buffer_t; 45 46 /*!\brief get frame buffer callback prototype 47 * 48 * This callback is invoked by the decoder to retrieve data for the frame 49 * buffer in order for the decode call to complete. The callback must 50 * allocate at least min_size in bytes and assign it to fb->data. Then the 51 * callback must set fb->size to the allocated size. The application does not 52 * need to align the allocated data. The callback is triggered when the 53 * decoder needs a frame buffer to decode a compressed image into. This 54 * function may be called more than once for every call to vpx_codec_decode. 55 * The application may set fb->priv to some data which will be passed 56 * back in the ximage and the release function call. |fb| is guaranteed to 57 * not be NULL. On success the callback must return 0. Any failure the 58 * callback must return a value less than 0. 59 * 60 * \param[in] priv Callback's private data 61 * \param[in] new_size Size in bytes needed by the buffer 62 * \param[in,out] fb Pointer to vpx_codec_frame_buffer_t 63 */ 64 typedef int (*vpx_get_frame_buffer_cb_fn_t)( 65 void *priv, size_t min_size, vpx_codec_frame_buffer_t *fb); 66 67 /*!\brief release frame buffer callback prototype 68 * 69 * This callback is invoked by the decoder when the frame buffer is not 70 * referenced by any other buffers. |fb| is guaranteed to not be NULL. On 71 * success the callback must return 0. Any failure the callback must return 72 * a value less than 0. 73 * 74 * \param[in] priv Callback's private data 75 * \param[in] fb Pointer to vpx_codec_frame_buffer_t 76 */ 77 typedef int (*vpx_release_frame_buffer_cb_fn_t)( 78 void *priv, vpx_codec_frame_buffer_t *fb); 79 80 #ifdef __cplusplus 81 } // extern "C" 82 #endif 83 84 #endif // VPX_VPX_FRAME_BUFFER_H_ 85