24 #include <VideoToolbox/VideoToolbox.h> 42 #ifdef kCFCoreFoundationVersionNumber10_7 45 #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 101 CVPixelBufferRef pixbuf = (CVPixelBufferRef)hwmap->
source->
data[3];
103 CVPixelBufferUnlockBaseAddress(pixbuf, (uintptr_t)hwmap->
priv);
109 CVPixelBufferRef pixbuf = (CVPixelBufferRef)src->
data[3];
110 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
112 uint32_t map_flags = 0;
118 if (dst->
format != format) {
124 if (CVPixelBufferGetWidth(pixbuf) != ctx->
width ||
125 CVPixelBufferGetHeight(pixbuf) != ctx->
height) {
131 map_flags = kCVPixelBufferLock_ReadOnly;
133 err = CVPixelBufferLockBaseAddress(pixbuf, map_flags);
134 if (err != kCVReturnSuccess) {
139 if (CVPixelBufferIsPlanar(pixbuf)) {
140 int planes = CVPixelBufferGetPlaneCount(pixbuf);
141 for (i = 0; i <
planes; i++) {
142 dst->
data[
i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
143 dst->
linesize[
i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
146 dst->
data[0] = CVPixelBufferGetBaseAddress(pixbuf);
147 dst->
linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
151 (
void *)(uintptr_t)map_flags);
158 CVPixelBufferUnlockBaseAddress(pixbuf, map_flags);
227 if (device && device[0]) {
237 .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
static const struct @314 planes[]
static const char * format[]
This structure describes decoded (raw) audio or video data.
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
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
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
The mapping must be readable.
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 i(width, name, range_min, range_max)
#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...
The mapping must be writeable.
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.
#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)
This struct describes a set or pool of "hardware" frames (i.e.
refcounted data buffer API
const VDPAUPixFmtMap * map
#define flags(name, subs,...)
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
#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().
enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt)
Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
static const struct @303 cv_pix_fmts[]
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.