24 #include <VideoToolbox/VideoToolbox.h>
42 #ifdef kCFCoreFoundationVersionNumber10_7
98 CVPixelBufferRef pixbuf = (CVPixelBufferRef)hwmap->
source->
data[3];
100 CVPixelBufferUnlockBaseAddress(pixbuf, (uintptr_t)hwmap->
priv);
106 CVPixelBufferRef pixbuf = (CVPixelBufferRef)src->
data[3];
107 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
109 uint32_t map_flags = 0;
115 if (dst->
format != format) {
121 if (CVPixelBufferGetWidth(pixbuf) != ctx->
width ||
122 CVPixelBufferGetHeight(pixbuf) != ctx->
height) {
128 map_flags = kCVPixelBufferLock_ReadOnly;
130 err = CVPixelBufferLockBaseAddress(pixbuf, map_flags);
131 if (err != kCVReturnSuccess) {
136 if (CVPixelBufferIsPlanar(pixbuf)) {
137 int planes = CVPixelBufferGetPlaneCount(pixbuf);
138 for (i = 0; i < planes; i++) {
139 dst->
data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
140 dst->
linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
143 dst->
data[0] = CVPixelBufferGetBaseAddress(pixbuf);
144 dst->
linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
148 (
void *)(uintptr_t)map_flags);
155 CVPixelBufferUnlockBaseAddress(pixbuf, map_flags);
224 if (device && device[0]) {
234 .name =
"videotoolbox",
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
This structure describes decoded (raw) audio or video data.
Memory handling functions.
static int vt_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
hardware decoding through Videotoolbox
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt)
Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
int width
The allocated dimensions of the frames in this pool.
static int vt_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
enum AVPixelFormat pix_fmt
The mapping must be readable.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX.
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static int vt_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static void vt_unmap(AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
#define av_fourcc2str(fourcc)
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
AVFrame * source
A reference to the original source of the mapping.
static const struct @251 cv_pix_fmts[]
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
void * priv
Hardware-specific private data associated with the mapping.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
uint8_t * data
The data buffer.
const HWContextType ff_hwcontext_type_videotoolbox
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
static const char * format
This struct describes a set or pool of "hardware" frames (i.e.
refcounted data buffer API
const VDPAUPixFmtMap * map
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVHWFrameTransferDirection
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
The mapping must be writeable.
enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt)
Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.