FFmpeg
Data Structures | Functions | Variables
hwcontext_videotoolbox.c File Reference
#include "config.h"
#include <stdint.h>
#include <string.h>
#include <VideoToolbox/VideoToolbox.h>
#include "buffer.h"
#include "buffer_internal.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_internal.h"
#include "hwcontext_videotoolbox.h"
#include "mem.h"
#include "pixfmt.h"
#include "pixdesc.h"

Go to the source code of this file.

Data Structures

struct  VTFramesContext
 

Functions

static int vt_frames_get_constraints (AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
 
enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt (uint32_t cv_fmt)
 Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat. More...
 
uint32_t av_map_videotoolbox_format_from_pixfmt (enum AVPixelFormat pix_fmt)
 Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format. More...
 
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 formats via a flag. More...
 
static int vt_pool_alloc (AVHWFramesContext *ctx)
 
static AVBufferRefvt_dummy_pool_alloc (void *opaque, size_t size)
 
static void vt_frames_uninit (AVHWFramesContext *ctx)
 
static int vt_frames_init (AVHWFramesContext *ctx)
 
static void videotoolbox_buffer_release (void *opaque, uint8_t *data)
 
static int vt_get_buffer (AVHWFramesContext *ctx, AVFrame *frame)
 
static int vt_transfer_get_formats (AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
 
static void vt_unmap (AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
 
static int vt_pixbuf_set_par (AVHWFramesContext *hwfc, CVPixelBufferRef pixbuf, const AVFrame *src)
 
static int vt_pixbuf_set_chromaloc (AVHWFramesContext *hwfc, CVPixelBufferRef pixbuf, const AVFrame *src)
 
static int vt_pixbuf_set_colorspace (AVHWFramesContext *hwfc, CVPixelBufferRef pixbuf, const AVFrame *src)
 
static int vt_pixbuf_set_attachments (AVHWFramesContext *hwfc, CVPixelBufferRef pixbuf, const AVFrame *src)
 
static int vt_map_frame (AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
 
static int vt_transfer_data_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static int vt_transfer_data_to (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
 
static int vt_device_create (AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
 

Variables

struct {
   uint32_t   cv_fmt
 
   bool   full_range
 
   enum AVPixelFormat   pix_fmt
 
cv_pix_fmts []
 
static enum AVPixelFormat supported_formats []
 
const HWContextType ff_hwcontext_type_videotoolbox
 

Function Documentation

◆ vt_frames_get_constraints()

static int vt_frames_get_constraints ( AVHWDeviceContext ctx,
const void *  hwconfig,
AVHWFramesConstraints constraints 
)
static

Definition at line 66 of file hwcontext_videotoolbox.c.

◆ av_map_videotoolbox_format_to_pixfmt()

enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt ( uint32_t  cv_fmt)

Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.

Returns AV_PIX_FMT_NONE if no known equivalent was found.

Definition at line 91 of file hwcontext_videotoolbox.c.

Referenced by vt_map_frame().

◆ av_map_videotoolbox_format_from_pixfmt()

uint32_t av_map_videotoolbox_format_from_pixfmt ( enum AVPixelFormat  pix_fmt)

Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.

Returns 0 if no known equivalent was found.

Definition at line 101 of file hwcontext_videotoolbox.c.

Referenced by vt_pool_alloc().

◆ av_map_videotoolbox_format_from_pixfmt2()

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 formats via a flag.

Definition at line 106 of file hwcontext_videotoolbox.c.

Referenced by av_map_videotoolbox_format_from_pixfmt().

◆ vt_pool_alloc()

static int vt_pool_alloc ( AVHWFramesContext ctx)
static

Definition at line 116 of file hwcontext_videotoolbox.c.

Referenced by vt_frames_init().

◆ vt_dummy_pool_alloc()

static AVBufferRef* vt_dummy_pool_alloc ( void *  opaque,
size_t  size 
)
static

Definition at line 167 of file hwcontext_videotoolbox.c.

Referenced by vt_frames_init().

◆ vt_frames_uninit()

static void vt_frames_uninit ( AVHWFramesContext ctx)
static

Definition at line 172 of file hwcontext_videotoolbox.c.

◆ vt_frames_init()

static int vt_frames_init ( AVHWFramesContext ctx)
static

Definition at line 181 of file hwcontext_videotoolbox.c.

◆ videotoolbox_buffer_release()

static void videotoolbox_buffer_release ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 209 of file hwcontext_videotoolbox.c.

Referenced by vt_get_buffer().

◆ vt_get_buffer()

static int vt_get_buffer ( AVHWFramesContext ctx,
AVFrame frame 
)
static

Definition at line 214 of file hwcontext_videotoolbox.c.

◆ vt_transfer_get_formats()

static int vt_transfer_get_formats ( AVHWFramesContext ctx,
enum AVHWFrameTransferDirection  dir,
enum AVPixelFormat **  formats 
)
static

Definition at line 253 of file hwcontext_videotoolbox.c.

◆ vt_unmap()

static void vt_unmap ( AVHWFramesContext ctx,
HWMapDescriptor hwmap 
)
static

Definition at line 268 of file hwcontext_videotoolbox.c.

Referenced by vt_map_frame().

◆ vt_pixbuf_set_par()

static int vt_pixbuf_set_par ( AVHWFramesContext hwfc,
CVPixelBufferRef  pixbuf,
const AVFrame src 
)
static

Definition at line 275 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ vt_pixbuf_set_chromaloc()

static int vt_pixbuf_set_chromaloc ( AVHWFramesContext hwfc,
CVPixelBufferRef  pixbuf,
const AVFrame src 
)
static

Definition at line 332 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ vt_pixbuf_set_colorspace()

static int vt_pixbuf_set_colorspace ( AVHWFramesContext hwfc,
CVPixelBufferRef  pixbuf,
const AVFrame src 
)
static

Definition at line 369 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ vt_pixbuf_set_attachments()

static int vt_pixbuf_set_attachments ( AVHWFramesContext hwfc,
CVPixelBufferRef  pixbuf,
const AVFrame src 
)
static

Definition at line 501 of file hwcontext_videotoolbox.c.

Referenced by vt_transfer_data_to().

◆ vt_map_frame()

static int vt_map_frame ( AVHWFramesContext ctx,
AVFrame dst,
const AVFrame src,
int  flags 
)
static

Definition at line 517 of file hwcontext_videotoolbox.c.

Referenced by vt_transfer_data_from(), and vt_transfer_data_to().

◆ vt_transfer_data_from()

static int vt_transfer_data_from ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 573 of file hwcontext_videotoolbox.c.

◆ vt_transfer_data_to()

static int vt_transfer_data_to ( AVHWFramesContext hwfc,
AVFrame dst,
const AVFrame src 
)
static

Definition at line 604 of file hwcontext_videotoolbox.c.

◆ vt_device_create()

static int vt_device_create ( AVHWDeviceContext ctx,
const char *  device,
AVDictionary opts,
int  flags 
)
static

Definition at line 639 of file hwcontext_videotoolbox.c.

Variable Documentation

◆ cv_fmt

uint32_t cv_fmt

Definition at line 41 of file hwcontext_videotoolbox.c.

Referenced by av_map_videotoolbox_format_to_pixfmt().

◆ full_range

bool full_range

◆ pix_fmt

enum AVPixelFormat pix_fmt

◆ cv_pix_fmts

const { ... } cv_pix_fmts[]
Initial value:
= {
{ kCVPixelFormatType_420YpCbCr8Planar, false, AV_PIX_FMT_YUV420P },
{ kCVPixelFormatType_422YpCbCr8, false, AV_PIX_FMT_UYVY422 },
{ kCVPixelFormatType_32BGRA, false, AV_PIX_FMT_BGRA },
}

Referenced by av_map_videotoolbox_format_from_pixfmt2(), and av_map_videotoolbox_format_to_pixfmt().

◆ supported_formats

enum AVPixelFormat supported_formats[]
static

◆ ff_hwcontext_type_videotoolbox

const HWContextType ff_hwcontext_type_videotoolbox
Initial value:
= {
.name = "videotoolbox",
.frames_priv_size = sizeof(VTFramesContext),
.device_create = vt_device_create,
.frames_init = vt_frames_init,
.frames_get_buffer = vt_get_buffer,
.frames_get_constraints = vt_frames_get_constraints,
.frames_uninit = vt_frames_uninit,
.transfer_get_formats = vt_transfer_get_formats,
.transfer_data_to = vt_transfer_data_to,
.transfer_data_from = vt_transfer_data_from,
}

Definition at line 650 of file hwcontext_videotoolbox.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
vt_transfer_data_from
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:573
vt_frames_init
static int vt_frames_init(AVHWFramesContext *ctx)
Definition: hwcontext_videotoolbox.c:181
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
AV_HWDEVICE_TYPE_VIDEOTOOLBOX
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
Definition: hwcontext.h:34
vt_device_create
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_videotoolbox.c:639
vt_frames_uninit
static void vt_frames_uninit(AVHWFramesContext *ctx)
Definition: hwcontext_videotoolbox.c:172
vt_transfer_get_formats
static int vt_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_videotoolbox.c:253
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:290
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
vt_frames_get_constraints
static int vt_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_videotoolbox.c:66
vt_transfer_data_to
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:604
AV_PIX_FMT_VIDEOTOOLBOX
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
Definition: pixfmt.h:272
vt_get_buffer
static int vt_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_videotoolbox.c:214
AV_PIX_FMT_NV12
@ 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...
Definition: pixfmt.h:89
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:438
VTFramesContext
Definition: hwcontext_videotoolbox.c:36