hwcontext_videotoolbox.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 "pixfmt.h"
  23. /**
  24. * @file
  25. * An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.
  26. *
  27. * This API supports frame allocation using a native CVPixelBufferPool
  28. * instead of an AVBufferPool.
  29. *
  30. * If the API user sets a custom pool, AVHWFramesContext.pool must return
  31. * AVBufferRefs whose data pointer is a CVImageBufferRef or CVPixelBufferRef.
  32. * Note that the underlying CVPixelBuffer could be retained by OS frameworks
  33. * depending on application usage, so it is preferable to let CoreVideo manage
  34. * the pool using the default implementation.
  35. *
  36. * Currently AVHWDeviceContext.hwctx and AVHWFramesContext.hwctx are always
  37. * NULL.
  38. */
  39. /**
  40. * Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
  41. * Returns AV_PIX_FMT_NONE if no known equivalent was found.
  42. */
  43. enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt);
  44. /**
  45. * Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
  46. * Returns 0 if no known equivalent was found.
  47. */
  48. uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt);
  49. /**
  50. * Same as av_map_videotoolbox_format_from_pixfmt function, but can map and
  51. * return full range pixel formats via a flag.
  52. */
  53. uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range);
  54. /**
  55. * Convert an AVChromaLocation to a VideoToolbox/CoreVideo chroma location string.
  56. * Returns 0 if no known equivalent was found.
  57. */
  58. CFStringRef av_map_videotoolbox_chroma_loc_from_av(enum AVChromaLocation loc);
  59. /**
  60. * Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string.
  61. * Returns 0 if no known equivalent was found.
  62. */
  63. CFStringRef av_map_videotoolbox_color_matrix_from_av(enum AVColorSpace space);
  64. /**
  65. * Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string.
  66. * Returns 0 if no known equivalent was found.
  67. */
  68. CFStringRef av_map_videotoolbox_color_primaries_from_av(enum AVColorPrimaries pri);
  69. /**
  70. * Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer
  71. * function string.
  72. * Returns 0 if no known equivalent was found.
  73. */
  74. CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteristic trc);
  75. /**
  76. * Update a CVPixelBufferRef's metadata to based on an AVFrame.
  77. * Returns 0 if no known equivalent was found.
  78. */
  79. int av_vt_pixbuf_set_attachments(void *log_ctx,
  80. CVPixelBufferRef pixbuf, const struct AVFrame *src);
  81. #endif /* AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H */