Go to the documentation of this file.
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",
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.
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
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
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
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.
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.
#define FF_ARRAY_ELEMS(a)
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
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
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.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static const struct @309 cv_pix_fmts[]
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
#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
static const struct @322 planes[]
const VDPAUPixFmtMap * map
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...
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define av_fourcc2str(fourcc)