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.

169 lines
4.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. #include <stdint.h>
  25. // emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
  26. // http://openradar.appspot.com/8026390
  27. #undef __GNUC_STDC_INLINE__
  28. #define Picture QuickdrawPicture
  29. #include <VideoDecodeAcceleration/VDADecoder.h>
  30. #undef Picture
  31. /**
  32. * This structure is used to store a decoded frame information and data.
  33. */
  34. typedef struct {
  35. /**
  36. * The PTS of the frame.
  37. *
  38. * - encoding: unused
  39. * - decoding: Set/Unset by libavcodec.
  40. */
  41. int64_t pts;
  42. /**
  43. * The CoreVideo buffer that contains the decoded data.
  44. *
  45. * - encoding: unused
  46. * - decoding: Set/Unset by libavcodec.
  47. */
  48. CVPixelBufferRef cv_buffer;
  49. /**
  50. * A pointer to the next frame.
  51. *
  52. * - encoding: unused
  53. * - decoding: Set/Unset by libavcodec.
  54. */
  55. struct vda_frame *next_frame;
  56. } vda_frame;
  57. /**
  58. * This structure is used to provide the necessary configurations and data
  59. * to the VDA FFmpeg HWAccel implementation.
  60. *
  61. * The application must make it available as AVCodecContext.hwaccel_context.
  62. */
  63. struct vda_context {
  64. /**
  65. * VDA decoder object.
  66. *
  67. * - encoding: unused
  68. * - decoding: Set/Unset by libavcodec.
  69. */
  70. VDADecoder decoder;
  71. /**
  72. * VDA frames queue ordered by presentation timestamp.
  73. *
  74. * - encoding: unused
  75. * - decoding: Set/Unset by libavcodec.
  76. */
  77. vda_frame *queue;
  78. /**
  79. * Mutex for locking queue operations.
  80. *
  81. * - encoding: unused
  82. * - decoding: Set/Unset by libavcodec.
  83. */
  84. void *queue_mutex;
  85. /**
  86. * The frame width.
  87. *
  88. * - encoding: unused
  89. * - decoding: Set/Unset by user.
  90. */
  91. int width;
  92. /**
  93. * The frame height.
  94. *
  95. * - encoding: unused
  96. * - decoding: Set/Unset by user.
  97. */
  98. int height;
  99. /**
  100. * The frame format.
  101. *
  102. * - encoding: unused
  103. * - decoding: Set/Unset by user.
  104. */
  105. int format;
  106. /**
  107. * The pixel format for output image buffers.
  108. *
  109. * - encoding: unused
  110. * - decoding: Set/Unset by user.
  111. */
  112. OSType cv_pix_fmt_type;
  113. /**
  114. * The current bitstream buffer.
  115. *
  116. * - encoding: unused
  117. * - decoding: Set/Unset by libavcodec.
  118. */
  119. uint8_t *bitstream;
  120. /**
  121. * The current size of the bitstream.
  122. *
  123. * - encoding: unused
  124. * - decoding: Set/Unset by libavcodec.
  125. */
  126. int bitstream_size;
  127. /**
  128. * The reference size used for fast reallocation.
  129. *
  130. * - encoding: unused
  131. * - decoding: Set/Unset by libavcodec.
  132. */
  133. int ref_size;
  134. };
  135. /** Creates the video decoder. */
  136. int ff_vda_create_decoder(struct vda_context *vda_ctx,
  137. uint8_t *extradata,
  138. int extradata_size);
  139. /** Destroys the video decoder. */
  140. int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
  141. /** Returns the top frame of the queue. */
  142. vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
  143. /** Releases the given frame. */
  144. void ff_vda_release_vda_frame(vda_frame *frame);
  145. #endif /* AVCODEC_VDA_H */