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.

213 lines
5.3KB

  1. /*
  2. * VDA HW acceleration
  3. *
  4. * copyright (c) 2011 Sebastien Zwickert
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; 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/avcodec.h"
  30. #include "libavcodec/version.h"
  31. #include <stdint.h>
  32. // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
  33. // http://openradar.appspot.com/8026390
  34. #undef __GNUC_STDC_INLINE__
  35. #define Picture QuickdrawPicture
  36. #include <VideoDecodeAcceleration/VDADecoder.h>
  37. #undef Picture
  38. /**
  39. * @defgroup lavc_codec_hwaccel_vda VDA
  40. * @ingroup lavc_codec_hwaccel
  41. *
  42. * @{
  43. */
  44. /**
  45. * This structure is used to provide the necessary configurations and data
  46. * to the VDA Libav HWAccel implementation.
  47. *
  48. * The application must make it available as AVCodecContext.hwaccel_context.
  49. */
  50. struct vda_context {
  51. /**
  52. * VDA decoder object.
  53. *
  54. * - encoding: unused
  55. * - decoding: Set/Unset by libavcodec.
  56. */
  57. VDADecoder decoder;
  58. /**
  59. * The Core Video pixel buffer that contains the current image data.
  60. *
  61. * encoding: unused
  62. * decoding: Set by libavcodec. Unset by user.
  63. */
  64. CVPixelBufferRef cv_buffer;
  65. /**
  66. * Use the hardware decoder in synchronous mode.
  67. *
  68. * encoding: unused
  69. * decoding: Set by user.
  70. */
  71. int use_sync_decoding;
  72. /**
  73. * The frame width.
  74. *
  75. * - encoding: unused
  76. * - decoding: Set/Unset by user.
  77. */
  78. int width;
  79. /**
  80. * The frame height.
  81. *
  82. * - encoding: unused
  83. * - decoding: Set/Unset by user.
  84. */
  85. int height;
  86. /**
  87. * The frame format.
  88. *
  89. * - encoding: unused
  90. * - decoding: Set/Unset by user.
  91. */
  92. int format;
  93. /**
  94. * The pixel format for output image buffers.
  95. *
  96. * - encoding: unused
  97. * - decoding: Set/Unset by user.
  98. */
  99. OSType cv_pix_fmt_type;
  100. /**
  101. * unused
  102. */
  103. uint8_t *priv_bitstream;
  104. /**
  105. * unused
  106. */
  107. int priv_bitstream_size;
  108. /**
  109. * unused
  110. */
  111. int priv_allocated_size;
  112. };
  113. /** Create the video decoder. */
  114. int ff_vda_create_decoder(struct vda_context *vda_ctx,
  115. uint8_t *extradata,
  116. int extradata_size);
  117. /** Destroy the video decoder. */
  118. int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
  119. /**
  120. * This struct holds all the information that needs to be passed
  121. * between the caller and libavcodec for initializing VDA decoding.
  122. * Its size is not a part of the public ABI, it must be allocated with
  123. * av_vda_alloc_context() and freed with av_free().
  124. */
  125. typedef struct AVVDAContext {
  126. /**
  127. * VDA decoder object. Created and freed by the caller.
  128. */
  129. VDADecoder decoder;
  130. /**
  131. * The output callback that must be passed to VDADecoderCreate.
  132. * Set by av_vda_alloc_context().
  133. */
  134. VDADecoderOutputCallback output_callback;
  135. /**
  136. * CVPixelBuffer Format Type that VDA will use for decoded frames; set by
  137. * the caller.
  138. */
  139. OSType cv_pix_fmt_type;
  140. } AVVDAContext;
  141. /**
  142. * Allocate and initialize a VDA context.
  143. *
  144. * This function should be called from the get_format() callback when the caller
  145. * selects the AV_PIX_FMT_VDA format. The caller must then create the decoder
  146. * object (using the output callback provided by libavcodec) that will be used
  147. * for VDA-accelerated decoding.
  148. *
  149. * When decoding with VDA is finished, the caller must destroy the decoder
  150. * object and free the VDA context using av_free().
  151. *
  152. * @return the newly allocated context or NULL on failure
  153. */
  154. AVVDAContext *av_vda_alloc_context(void);
  155. /**
  156. * This is a convenience function that creates and sets up the VDA context using
  157. * an internal implementation.
  158. *
  159. * @param avctx the corresponding codec context
  160. *
  161. * @return >= 0 on success, a negative AVERROR code on failure
  162. */
  163. int av_vda_default_init(AVCodecContext *avctx);
  164. /**
  165. * This is a convenience function that creates and sets up the VDA context using
  166. * an internal implementation.
  167. *
  168. * @param avctx the corresponding codec context
  169. * @param vdactx the VDA context to use
  170. *
  171. * @return >= 0 on success, a negative AVERROR code on failure
  172. */
  173. int av_vda_default_init2(AVCodecContext *avctx, AVVDAContext *vdactx);
  174. /**
  175. * This function must be called to free the VDA context initialized with
  176. * av_vda_default_init().
  177. *
  178. * @param avctx the corresponding codec context
  179. */
  180. void av_vda_default_free(AVCodecContext *avctx);
  181. /**
  182. * @}
  183. */
  184. #endif /* AVCODEC_VDA_H */