24 #include <VideoToolbox/VideoToolbox.h>
43 #ifdef kCFCoreFoundationVersionNumber10_7
44 { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
false,
AV_PIX_FMT_NV12 },
45 { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
true,
AV_PIX_FMT_NV12 },
47 #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
100 fmts[0] =
ctx->sw_format;
109 CVPixelBufferRef pixbuf = (CVPixelBufferRef)hwmap->
source->
data[3];
111 CVPixelBufferUnlockBaseAddress(pixbuf, (uintptr_t)hwmap->
priv);
117 CVPixelBufferRef pixbuf = (CVPixelBufferRef)
src->data[3];
118 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
120 uint32_t map_flags = 0;
132 if (CVPixelBufferGetWidth(pixbuf) !=
ctx->width ||
133 CVPixelBufferGetHeight(pixbuf) !=
ctx->height) {
139 map_flags = kCVPixelBufferLock_ReadOnly;
141 err = CVPixelBufferLockBaseAddress(pixbuf, map_flags);
142 if (err != kCVReturnSuccess) {
147 if (CVPixelBufferIsPlanar(pixbuf)) {
148 int planes = CVPixelBufferGetPlaneCount(pixbuf);
150 dst->
data[
i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf,
i);
151 dst->
linesize[
i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf,
i);
154 dst->
data[0] = CVPixelBufferGetBaseAddress(pixbuf);
155 dst->
linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
159 (
void *)(uintptr_t)map_flags);
166 CVPixelBufferUnlockBaseAddress(pixbuf, map_flags);
213 map->format =
src->format;
220 map->height =
src->height;
235 if (device && device[0]) {
245 .name =
"videotoolbox",
static const char *const format[]
refcounted data buffer API
#define flags(name, subs,...)
common internal and external API header
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define av_fourcc2str(fourcc)
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
AVHWFrameTransferDirection
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
const VDPAUPixFmtMap * map
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static void vt_unmap(AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static const struct @309 cv_pix_fmts[]
enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt)
Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
enum AVPixelFormat pix_fmt
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
const HWContextType ff_hwcontext_type_videotoolbox
uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt)
Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
static int vt_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static int vt_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range)
Same as av_map_videotoolbox_format_from_pixfmt function, but can map and return full range pixel form...
static int vt_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.
static const struct @322 planes[]
Memory handling functions.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_ARRAY_ELEMS(a)
uint8_t * data
The data buffer.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
This struct describes a set or pool of "hardware" frames (i.e.
int width
The allocated dimensions of the frames in this pool.
void * priv
Hardware-specific private data associated with the mapping.
AVFrame * source
A reference to the original source of the mapping.
#define av_malloc_array(a, b)