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.

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