vda.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * VDA HW acceleration
  3. *
  4. * copyright (c) 2011 Sebastien Zwickert
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_VDA_H
  23. #define AVCODEC_VDA_H
  24. /**
  25. * @file
  26. * @ingroup lavc_codec_hwaccel_vda
  27. * Public libavcodec VDA header.
  28. */
  29. #include <stdint.h>
  30. // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
  31. // http://openradar.appspot.com/8026390
  32. #undef __GNUC_STDC_INLINE__
  33. #define Picture QuickdrawPicture
  34. #include <VideoDecodeAcceleration/VDADecoder.h>
  35. #undef Picture
  36. #include "libavcodec/version.h"
  37. #if FF_API_VDA_ASYNC
  38. #include <pthread.h>
  39. #endif
  40. /**
  41. * @defgroup lavc_codec_hwaccel_vda VDA
  42. * @ingroup lavc_codec_hwaccel
  43. *
  44. * @{
  45. */
  46. #if FF_API_VDA_ASYNC
  47. /**
  48. * This structure is used to store decoded frame information and data.
  49. *
  50. * @deprecated Use synchronous decoding mode.
  51. */
  52. typedef struct {
  53. /**
  54. * The PTS of the frame.
  55. *
  56. * - encoding: unused
  57. * - decoding: Set/Unset by libavcodec.
  58. */
  59. int64_t pts;
  60. /**
  61. * The CoreVideo buffer that contains the decoded data.
  62. *
  63. * - encoding: unused
  64. * - decoding: Set/Unset by libavcodec.
  65. */
  66. CVPixelBufferRef cv_buffer;
  67. /**
  68. * A pointer to the next frame.
  69. *
  70. * - encoding: unused
  71. * - decoding: Set/Unset by libavcodec.
  72. */
  73. struct vda_frame *next_frame;
  74. } vda_frame;
  75. #endif
  76. /**
  77. * This structure is used to provide the necessary configurations and data
  78. * to the VDA FFmpeg HWAccel implementation.
  79. *
  80. * The application must make it available as AVCodecContext.hwaccel_context.
  81. */
  82. struct vda_context {
  83. /**
  84. * VDA decoder object.
  85. *
  86. * - encoding: unused
  87. * - decoding: Set/Unset by libavcodec.
  88. */
  89. VDADecoder decoder;
  90. /**
  91. * The Core Video pixel buffer that contains the current image data.
  92. *
  93. * encoding: unused
  94. * decoding: Set by libavcodec. Unset by user.
  95. */
  96. CVPixelBufferRef cv_buffer;
  97. /**
  98. * Use the hardware decoder in synchronous mode.
  99. *
  100. * encoding: unused
  101. * decoding: Set by user.
  102. */
  103. int use_sync_decoding;
  104. #if FF_API_VDA_ASYNC
  105. /**
  106. * VDA frames queue ordered by presentation timestamp.
  107. *
  108. * @deprecated Use synchronous decoding mode.
  109. *
  110. * - encoding: unused
  111. * - decoding: Set/Unset by libavcodec.
  112. */
  113. vda_frame *queue;
  114. /**
  115. * Mutex for locking queue operations.
  116. *
  117. * @deprecated Use synchronous decoding mode.
  118. *
  119. * - encoding: unused
  120. * - decoding: Set/Unset by libavcodec.
  121. */
  122. pthread_mutex_t queue_mutex;
  123. #endif
  124. /**
  125. * The frame width.
  126. *
  127. * - encoding: unused
  128. * - decoding: Set/Unset by user.
  129. */
  130. int width;
  131. /**
  132. * The frame height.
  133. *
  134. * - encoding: unused
  135. * - decoding: Set/Unset by user.
  136. */
  137. int height;
  138. /**
  139. * The frame format.
  140. *
  141. * - encoding: unused
  142. * - decoding: Set/Unset by user.
  143. */
  144. int format;
  145. /**
  146. * The pixel format for output image buffers.
  147. *
  148. * - encoding: unused
  149. * - decoding: Set/Unset by user.
  150. */
  151. OSType cv_pix_fmt_type;
  152. /**
  153. * The current bitstream buffer.
  154. *
  155. * - encoding: unused
  156. * - decoding: Set/Unset by libavcodec.
  157. */
  158. uint8_t *priv_bitstream;
  159. /**
  160. * The current size of the bitstream.
  161. *
  162. * - encoding: unused
  163. * - decoding: Set/Unset by libavcodec.
  164. */
  165. int priv_bitstream_size;
  166. /**
  167. * The reference size used for fast reallocation.
  168. *
  169. * - encoding: unused
  170. * - decoding: Set/Unset by libavcodec.
  171. */
  172. int priv_allocated_size;
  173. };
  174. /** Create the video decoder. */
  175. int ff_vda_create_decoder(struct vda_context *vda_ctx,
  176. uint8_t *extradata,
  177. int extradata_size);
  178. /** Destroy the video decoder. */
  179. int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
  180. #if FF_API_VDA_ASYNC
  181. /**
  182. * Return the top frame of the queue.
  183. *
  184. * @deprecated Use synchronous decoding mode.
  185. */
  186. vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
  187. /**
  188. * Release the given frame.
  189. *
  190. * @deprecated Use synchronous decoding mode.
  191. */
  192. void ff_vda_release_vda_frame(vda_frame *frame);
  193. #endif
  194. /**
  195. * @}
  196. */
  197. #endif /* AVCODEC_VDA_H */