videotoolbox.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #include <stdint.h>
  30. #define Picture QuickdrawPicture
  31. #include <VideoToolbox/VideoToolbox.h>
  32. #undef Picture
  33. #include "libavcodec/avcodec.h"
  34. /**
  35. * This struct holds all the information that needs to be passed
  36. * between the caller and libavcodec for initializing Videotoolbox decoding.
  37. * Its size is not a part of the public ABI, it must be allocated with
  38. * av_videotoolbox_alloc_context() and freed with av_free().
  39. */
  40. typedef struct AVVideotoolboxContext {
  41. /**
  42. * Videotoolbox decompression session object.
  43. * Created and freed the caller.
  44. */
  45. VTDecompressionSessionRef session;
  46. /**
  47. * The output callback that must be passed to the session.
  48. * Set by av_videottoolbox_default_init()
  49. */
  50. VTDecompressionOutputCallback output_callback;
  51. /**
  52. * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames.
  53. * set by the caller. If this is set to 0, then no specific format is
  54. * requested from the decoder, and its native format is output.
  55. */
  56. OSType cv_pix_fmt_type;
  57. /**
  58. * CoreMedia Format Description that Videotoolbox will use to create the decompression session.
  59. * Set by the caller.
  60. */
  61. CMVideoFormatDescriptionRef cm_fmt_desc;
  62. /**
  63. * CoreMedia codec type that Videotoolbox will use to create the decompression session.
  64. * Set by the caller.
  65. */
  66. int cm_codec_type;
  67. } AVVideotoolboxContext;
  68. /**
  69. * Allocate and initialize a Videotoolbox context.
  70. *
  71. * This function should be called from the get_format() callback when the caller
  72. * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create
  73. * the decoder object (using the output callback provided by libavcodec) that
  74. * will be used for Videotoolbox-accelerated decoding.
  75. *
  76. * When decoding with Videotoolbox is finished, the caller must destroy the decoder
  77. * object and free the Videotoolbox context using av_free().
  78. *
  79. * @return the newly allocated context or NULL on failure
  80. */
  81. AVVideotoolboxContext *av_videotoolbox_alloc_context(void);
  82. /**
  83. * This is a convenience function that creates and sets up the Videotoolbox context using
  84. * an internal implementation.
  85. *
  86. * @param avctx the corresponding codec context
  87. *
  88. * @return >= 0 on success, a negative AVERROR code on failure
  89. */
  90. int av_videotoolbox_default_init(AVCodecContext *avctx);
  91. /**
  92. * This is a convenience function that creates and sets up the Videotoolbox context using
  93. * an internal implementation.
  94. *
  95. * @param avctx the corresponding codec context
  96. * @param vtctx the Videotoolbox context to use
  97. *
  98. * @return >= 0 on success, a negative AVERROR code on failure
  99. */
  100. int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx);
  101. /**
  102. * This function must be called to free the Videotoolbox context initialized with
  103. * av_videotoolbox_default_init().
  104. *
  105. * @param avctx the corresponding codec context
  106. */
  107. void av_videotoolbox_default_free(AVCodecContext *avctx);
  108. /**
  109. * @}
  110. */
  111. #endif /* AVCODEC_VIDEOTOOLBOX_H */