vpx_frame_buffer.h 3.1 KB

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