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