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.

162 lines
3.7KB

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