You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
5.0KB

  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 "libavcodec/version.h"
  30. #if FF_API_VDA_ASYNC
  31. #include <pthread.h>
  32. #endif
  33. #include <stdint.h>
  34. // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
  35. // http://openradar.appspot.com/8026390
  36. #undef __GNUC_STDC_INLINE__
  37. #define Picture QuickdrawPicture
  38. #include <VideoDecodeAcceleration/VDADecoder.h>
  39. #undef Picture
  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 a decoded frame information and data.
  49. *
  50. * @deprecated Use synchronous decoding mode.
  51. *
  52. */
  53. typedef struct {
  54. /**
  55. * The PTS of the frame.
  56. *
  57. * - encoding: unused
  58. * - decoding: Set/Unset by libavcodec.
  59. */
  60. int64_t pts;
  61. /**
  62. * The CoreVideo buffer that contains the decoded data.
  63. *
  64. * - encoding: unused
  65. * - decoding: Set/Unset by libavcodec.
  66. */
  67. CVPixelBufferRef cv_buffer;
  68. /**
  69. * A pointer to the next frame.
  70. *
  71. * - encoding: unused
  72. * - decoding: Set/Unset by libavcodec.
  73. */
  74. struct vda_frame *next_frame;
  75. } vda_frame;
  76. #endif
  77. /**
  78. * This structure is used to provide the necessary configurations and data
  79. * to the VDA FFmpeg HWAccel implementation.
  80. *
  81. * The application must make it available as AVCodecContext.hwaccel_context.
  82. */
  83. struct vda_context {
  84. /**
  85. * VDA decoder object.
  86. *
  87. * - encoding: unused
  88. * - decoding: Set/Unset by libavcodec.
  89. */
  90. VDADecoder decoder;
  91. /**
  92. * The Core Video pixel buffer that contains the current image data.
  93. *
  94. * encoding: unused
  95. * decoding: Set by libavcodec. Unset by user.
  96. */
  97. CVPixelBufferRef cv_buffer;
  98. /**
  99. * An integer value that indicates whether use the hardware decoder in synchronous mode.
  100. *
  101. * encoding: unused
  102. * decoding: Set by user.
  103. */
  104. int use_sync_decoding;
  105. #if FF_API_VDA_ASYNC
  106. /**
  107. * VDA frames queue ordered by presentation timestamp.
  108. *
  109. * @deprecated Use synchronous decoding mode.
  110. *
  111. * - encoding: unused
  112. * - decoding: Set/Unset by libavcodec.
  113. */
  114. vda_frame *queue;
  115. /**
  116. * Mutex for locking queue operations.
  117. *
  118. * @deprecated Use synchronous decoding mode.
  119. *
  120. * - encoding: unused
  121. * - decoding: Set/Unset by libavcodec.
  122. */
  123. pthread_mutex_t queue_mutex;
  124. #endif
  125. /**
  126. * The frame width.
  127. *
  128. * - encoding: unused
  129. * - decoding: Set/Unset by user.
  130. */
  131. int width;
  132. /**
  133. * The frame height.
  134. *
  135. * - encoding: unused
  136. * - decoding: Set/Unset by user.
  137. */
  138. int height;
  139. /**
  140. * The frame format.
  141. *
  142. * - encoding: unused
  143. * - decoding: Set/Unset by user.
  144. */
  145. int format;
  146. /**
  147. * The pixel format for output image buffers.
  148. *
  149. * - encoding: unused
  150. * - decoding: Set/Unset by user.
  151. */
  152. OSType cv_pix_fmt_type;
  153. /**
  154. * The current bitstream buffer.
  155. *
  156. * - encoding: unused
  157. * - decoding: Set/Unset by libavcodec.
  158. */
  159. uint8_t *bitstream;
  160. /**
  161. * The current size of the bitstream.
  162. *
  163. * - encoding: unused
  164. * - decoding: Set/Unset by libavcodec.
  165. */
  166. int bitstream_size;
  167. /**
  168. * The reference size used for fast reallocation.
  169. *
  170. * - encoding: unused
  171. * - decoding: Set/Unset by libavcodec.
  172. */
  173. int ref_size;
  174. };
  175. /** Create the video decoder. */
  176. int ff_vda_create_decoder(struct vda_context *vda_ctx,
  177. uint8_t *extradata,
  178. int extradata_size);
  179. /** Destroy the video decoder. */
  180. int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
  181. #if FF_API_VDA_ASYNC
  182. /**
  183. * Return the top frame of the queue.
  184. *
  185. * @deprecated Use synchronous decoding mode.
  186. */
  187. vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
  188. /**
  189. * Release the given frame.
  190. *
  191. * @deprecated Use synchronous decoding mode.
  192. */
  193. void ff_vda_release_vda_frame(vda_frame *frame);
  194. #endif
  195. /**
  196. * @}
  197. */
  198. #endif /* AVCODEC_VDA_H */