hwcontext_videotoolbox.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H
  19. #define AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H
  20. #include <stdint.h>
  21. #include <VideoToolbox/VideoToolbox.h>
  22. #include "frame.h"
  23. #include "pixfmt.h"
  24. /**
  25. * @file
  26. * An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.
  27. *
  28. * This API supports frame allocation using a native CVPixelBufferPool
  29. * instead of an AVBufferPool.
  30. *
  31. * If the API user sets a custom pool, AVHWFramesContext.pool must return
  32. * AVBufferRefs whose data pointer is a CVImageBufferRef or CVPixelBufferRef.
  33. * Note that the underlying CVPixelBuffer could be retained by OS frameworks
  34. * depending on application usage, so it is preferable to let CoreVideo manage
  35. * the pool using the default implementation.
  36. *
  37. * Currently AVHWDeviceContext.hwctx are always NULL.
  38. */
  39. typedef struct AVVTFramesContext {
  40. enum AVColorRange color_range;
  41. } AVVTFramesContext;
  42. /**
  43. * Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
  44. * Returns AV_PIX_FMT_NONE if no known equivalent was found.
  45. */
  46. enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt);
  47. /**
  48. * Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
  49. * Returns 0 if no known equivalent was found.
  50. */
  51. uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt);
  52. /**
  53. * Same as av_map_videotoolbox_format_from_pixfmt function, but can map and
  54. * return full range pixel formats via a flag.
  55. */
  56. uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range);
  57. /**
  58. * Convert an AVChromaLocation to a VideoToolbox/CoreVideo chroma location string.
  59. * Returns 0 if no known equivalent was found.
  60. */
  61. CFStringRef av_map_videotoolbox_chroma_loc_from_av(enum AVChromaLocation loc);
  62. /**
  63. * Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string.
  64. * Returns 0 if no known equivalent was found.
  65. */
  66. CFStringRef av_map_videotoolbox_color_matrix_from_av(enum AVColorSpace space);
  67. /**
  68. * Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string.
  69. * Returns 0 if no known equivalent was found.
  70. */
  71. CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pri);
  72. /**
  73. * Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer
  74. * function string.
  75. * Returns 0 if no known equivalent was found.
  76. */
  77. CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc);
  78. /**
  79. * Update a CVPixelBufferRef's metadata to based on an AVFrame.
  80. * Returns 0 if no known equivalent was found.
  81. */
  82. int av_vt_pixbuf_set_attachments(void *log_ctx,
  83. CVPixelBufferRef pixbuf, const struct AVFrame *src);
  84. #endif /* AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H */