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 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;
126 if (dst->
format != format) {
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);
149 for (i = 0; i <
planes; i++) {
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);
235 if (device && device[0]) {
245 .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.
The mapping must be readable.
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)
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
enum AVPixelFormat pix_fmt
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.
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...
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.
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
#define FF_ARRAY_ELEMS(a)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
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
static const struct @324 planes[]
The mapping must be writeable.
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.
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)
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
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
static const struct @311 cv_pix_fmts[]