Go to the documentation of this file.
24 #include <VideoToolbox/VideoToolbox.h>
42 #ifdef kCFCoreFoundationVersionNumber10_7
45 #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
92 fmts[0] =
ctx->sw_format;
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;
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);
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);
205 map->format =
src->format;
212 map->height =
src->height;
227 if (device && device[0]) {
237 .name =
"videotoolbox",
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVFrame * source
A reference to the original source of the mapping.
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
enum AVPixelFormat pix_fmt
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
static int vt_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
void * priv
Hardware-specific private data associated with the mapping.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int width
The allocated dimensions of the frames in this pool.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const HWContextType ff_hwcontext_type_videotoolbox
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
static const struct @303 cv_pix_fmts[]
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static int vt_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt)
Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
static const struct @314 planes[]
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static void vt_unmap(AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
#define i(width, name, range_min, range_max)
#define av_malloc_array(a, b)
AVHWFrameTransferDirection
This struct describes a set or pool of "hardware" frames (i.e.
static int vt_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
@ 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...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt)
Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_ARRAY_ELEMS(a)
const VDPAUPixFmtMap * map
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define av_fourcc2str(fourcc)