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