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.

151 lines
4.6KB

  1. /*
  2. * Videotoolbox hardware acceleration
  3. *
  4. * copyright (c) 2012 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_VIDEOTOOLBOX_H
  23. #define AVCODEC_VIDEOTOOLBOX_H
  24. /**
  25. * @file
  26. * @ingroup lavc_codec_hwaccel_videotoolbox
  27. * Public libavcodec Videotoolbox header.
  28. */
  29. /**
  30. * @defgroup lavc_codec_hwaccel_videotoolbox VideoToolbox Decoder
  31. * @ingroup lavc_codec_hwaccel
  32. *
  33. * Hardware accelerated decoding using VideoToolbox on Apple Platforms
  34. *
  35. * @{
  36. */
  37. #include <stdint.h>
  38. #define Picture QuickdrawPicture
  39. #include <VideoToolbox/VideoToolbox.h>
  40. #undef Picture
  41. #include "libavcodec/avcodec.h"
  42. #include "libavutil/attributes.h"
  43. /**
  44. * This struct holds all the information that needs to be passed
  45. * between the caller and libavcodec for initializing Videotoolbox decoding.
  46. * Its size is not a part of the public ABI, it must be allocated with
  47. * av_videotoolbox_alloc_context() and freed with av_free().
  48. */
  49. typedef struct AVVideotoolboxContext {
  50. /**
  51. * Videotoolbox decompression session object.
  52. */
  53. VTDecompressionSessionRef session;
  54. #if FF_API_VT_OUTPUT_CALLBACK
  55. /**
  56. * The output callback that must be passed to the session.
  57. * Set by av_videottoolbox_default_init()
  58. */
  59. attribute_deprecated
  60. VTDecompressionOutputCallback output_callback;
  61. #endif
  62. /**
  63. * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
  64. * set by the caller. If this is set to 0, then no specific format is
  65. * requested from the decoder, and its native format is output.
  66. */
  67. OSType cv_pix_fmt_type;
  68. /**
  69. * CoreMedia Format Description that Videotoolbox will use to create the decompression session.
  70. */
  71. CMVideoFormatDescriptionRef cm_fmt_desc;
  72. /**
  73. * CoreMedia codec type that Videotoolbox will use to create the decompression session.
  74. */
  75. int cm_codec_type;
  76. } AVVideotoolboxContext;
  77. #if FF_API_VT_HWACCEL_CONTEXT
  78. /**
  79. * Allocate and initialize a Videotoolbox context.
  80. *
  81. * This function should be called from the get_format() callback when the caller
  82. * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
  83. * the decoder object (using the output callback provided by libavcodec) that
  84. * will be used for Videotoolbox-accelerated decoding.
  85. *
  86. * When decoding with Videotoolbox is finished, the caller must destroy the decoder
  87. * object and free the Videotoolbox context using av_free().
  88. *
  89. * @return the newly allocated context or NULL on failure
  90. * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead.
  91. */
  92. attribute_deprecated
  93. AVVideotoolboxContext *av_videotoolbox_alloc_context(void);
  94. /**
  95. * This is a convenience function that creates and sets up the Videotoolbox context using
  96. * an internal implementation.
  97. *
  98. * @param avctx the corresponding codec context
  99. *
  100. * @return >= 0 on success, a negative AVERROR code on failure
  101. * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead.
  102. */
  103. attribute_deprecated
  104. int av_videotoolbox_default_init(AVCodecContext *avctx);
  105. /**
  106. * This is a convenience function that creates and sets up the Videotoolbox context using
  107. * an internal implementation.
  108. *
  109. * @param avctx the corresponding codec context
  110. * @param vtctx the Videotoolbox context to use
  111. *
  112. * @return >= 0 on success, a negative AVERROR code on failure
  113. * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead.
  114. */
  115. attribute_deprecated
  116. int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx);
  117. /**
  118. * This function must be called to free the Videotoolbox context initialized with
  119. * av_videotoolbox_default_init().
  120. *
  121. * @param avctx the corresponding codec context
  122. * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead.
  123. */
  124. attribute_deprecated
  125. void av_videotoolbox_default_free(AVCodecContext *avctx);
  126. #endif /* FF_API_VT_HWACCEL_CONTEXT */
  127. /**
  128. * @}
  129. */
  130. #endif /* AVCODEC_VIDEOTOOLBOX_H */