FFmpeg
Loading...
Searching...
No Matches
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 "attributes.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.
 
static uint32_t vt_format_from_pixfmt (enum AVPixelFormat pix_fmt, enum AVColorRange range)
 
uint32_t av_map_videotoolbox_format_from_pixfmt (enum AVPixelFormat pix_fmt)
 Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
 
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.
 
static int vt_pool_alloc (AVHWFramesContext *ctx)
 
static void videotoolbox_buffer_release (void *opaque, uint8_t *data)
 
static AVBufferRefvt_pool_alloc_buffer (void *opaque, size_t size)
 
static void vt_frames_uninit (AVHWFramesContext *ctx)
 
static int vt_frames_init (AVHWFramesContext *ctx)
 
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 (void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
 
CFStringRef av_map_videotoolbox_chroma_loc_from_av (enum AVChromaLocation loc)
 Convert an AVChromaLocation to a VideoToolbox/CoreVideo chroma location string.
 
static int vt_pixbuf_set_chromaloc (void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
 
CFStringRef av_map_videotoolbox_color_matrix_from_av (enum AVColorSpace space)
 Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string.
 
CFStringRef av_map_videotoolbox_color_primaries_from_av (enum AVColorPrimaries pri)
 Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string.
 
CFStringRef av_map_videotoolbox_color_trc_from_av (enum AVColorTransferCharacteristic trc)
 Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer function string.
 
static CFDictionaryRef vt_cv_buffer_copy_attachments (CVBufferRef buffer, CVAttachmentMode attachment_mode)
 Copy all attachments for the specified mode from the given buffer.
 
static int vt_pixbuf_set_colorspace (void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
 
static int vt_pixbuf_set_attachments (void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
 
int av_vt_pixbuf_set_attachments (void *log_ctx, 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_map_from (AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
 
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 128 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 153 of file hwcontext_videotoolbox.c.

Referenced by vt_map_frame().

◆ vt_format_from_pixfmt()

static uint32_t vt_format_from_pixfmt ( enum AVPixelFormat pix_fmt,
enum AVColorRange range )
static

◆ 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 182 of file hwcontext_videotoolbox.c.

◆ 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 187 of file hwcontext_videotoolbox.c.

Referenced by av_map_videotoolbox_format_from_pixfmt(), and get_cv_pixel_format().

◆ vt_pool_alloc()

static int vt_pool_alloc ( AVHWFramesContext * ctx)
static

Definition at line 192 of file hwcontext_videotoolbox.c.

Referenced by vt_frames_init().

◆ videotoolbox_buffer_release()

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

Definition at line 244 of file hwcontext_videotoolbox.c.

◆ vt_pool_alloc_buffer()

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

Definition at line 249 of file hwcontext_videotoolbox.c.

Referenced by vt_frames_init().

◆ vt_frames_uninit()

static void vt_frames_uninit ( AVHWFramesContext * ctx)
static

Definition at line 276 of file hwcontext_videotoolbox.c.

◆ vt_frames_init()

static int vt_frames_init ( AVHWFramesContext * ctx)
static

Definition at line 285 of file hwcontext_videotoolbox.c.

◆ vt_get_buffer()

static int vt_get_buffer ( AVHWFramesContext * ctx,
AVFrame * frame )
static

Definition at line 313 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 327 of file hwcontext_videotoolbox.c.

◆ vt_unmap()

static void vt_unmap ( AVHWFramesContext * ctx,
HWMapDescriptor * hwmap )
static

Definition at line 342 of file hwcontext_videotoolbox.c.

Referenced by vt_map_frame().

◆ vt_pixbuf_set_par()

static int vt_pixbuf_set_par ( void * log_ctx,
CVPixelBufferRef pixbuf,
const AVFrame * src )
static

Definition at line 349 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ av_map_videotoolbox_chroma_loc_from_av()

CFStringRef av_map_videotoolbox_chroma_loc_from_av ( enum AVChromaLocation loc)

Convert an AVChromaLocation to a VideoToolbox/CoreVideo chroma location string.

Returns 0 if no known equivalent was found.

Definition at line 408 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_chromaloc().

◆ vt_pixbuf_set_chromaloc()

static int vt_pixbuf_set_chromaloc ( void * log_ctx,
CVPixelBufferRef pixbuf,
const AVFrame * src )
static

Definition at line 428 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ av_map_videotoolbox_color_matrix_from_av()

CFStringRef av_map_videotoolbox_color_matrix_from_av ( enum AVColorSpace space)

Convert an AVColorSpace to a VideoToolbox/CoreVideo color matrix string.

Returns 0 if no known equivalent was found.

Definition at line 447 of file hwcontext_videotoolbox.c.

Referenced by scale_vt_init(), vt_pixbuf_set_colorspace(), and vtenc_configure_encoder().

◆ av_map_videotoolbox_color_primaries_from_av()

CFStringRef av_map_videotoolbox_color_primaries_from_av ( enum AVColorPrimaries pri)

Convert an AVColorPrimaries to a VideoToolbox/CoreVideo color primaries string.

Returns 0 if no known equivalent was found.

Definition at line 475 of file hwcontext_videotoolbox.c.

Referenced by scale_vt_init(), vt_pixbuf_set_colorspace(), and vtenc_configure_encoder().

◆ av_map_videotoolbox_color_trc_from_av()

CFStringRef av_map_videotoolbox_color_trc_from_av ( enum AVColorTransferCharacteristic trc)

Convert an AVColorTransferCharacteristic to a VideoToolbox/CoreVideo color transfer function string.

Returns 0 if no known equivalent was found.

Definition at line 501 of file hwcontext_videotoolbox.c.

Referenced by scale_vt_init(), vt_pixbuf_set_colorspace(), and vtenc_configure_encoder().

◆ vt_cv_buffer_copy_attachments()

static CFDictionaryRef vt_cv_buffer_copy_attachments ( CVBufferRef buffer,
CVAttachmentMode attachment_mode )
static

Copy all attachments for the specified mode from the given buffer.

Definition at line 552 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_colorspace().

◆ vt_pixbuf_set_colorspace()

static int vt_pixbuf_set_colorspace ( void * log_ctx,
CVPixelBufferRef pixbuf,
const AVFrame * src )
static

Definition at line 578 of file hwcontext_videotoolbox.c.

Referenced by vt_pixbuf_set_attachments().

◆ vt_pixbuf_set_attachments()

static int vt_pixbuf_set_attachments ( void * log_ctx,
CVPixelBufferRef pixbuf,
const AVFrame * src )
static

Definition at line 661 of file hwcontext_videotoolbox.c.

Referenced by av_vt_pixbuf_set_attachments(), and vt_transfer_data_to().

◆ av_vt_pixbuf_set_attachments()

int av_vt_pixbuf_set_attachments ( void * log_ctx,
CVPixelBufferRef pixbuf,
const AVFrame * src )

Definition at line 677 of file hwcontext_videotoolbox.c.

Referenced by videotoolbox_postproc_frame().

◆ vt_map_frame()

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

◆ vt_transfer_data_from()

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

Definition at line 739 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 770 of file hwcontext_videotoolbox.c.

◆ vt_map_from()

static int vt_map_from ( AVHWFramesContext * hwfc,
AVFrame * dst,
const AVFrame * src,
int flags )
static

Definition at line 805 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 829 of file hwcontext_videotoolbox.c.

Variable Documentation

◆ cv_fmt

uint32_t cv_fmt

Definition at line 46 of file hwcontext_videotoolbox.c.

Referenced by av_map_videotoolbox_format_to_pixfmt().

◆ full_range

bool full_range

Definition at line 47 of file hwcontext_videotoolbox.c.

◆ pix_fmt

enum AVPixelFormat pix_fmt

Definition at line 48 of file hwcontext_videotoolbox.c.

◆ [struct]

const struct { ... } cv_pix_fmts[]

◆ supported_formats

enum AVPixelFormat supported_formats[]
static

Definition at line 92 of file hwcontext_videotoolbox.c.

◆ ff_hwcontext_type_videotoolbox

const HWContextType ff_hwcontext_type_videotoolbox
Initial value:
= {
.name = "videotoolbox",
.frames_hwctx_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,
.map_from = vt_map_from,
}
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
Definition hwcontext.h:34
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static int vt_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
static int vt_frames_init(AVHWFramesContext *ctx)
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
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_frames_uninit(AVHWFramesContext *ctx)
static int vt_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
Definition pixfmt.h:305

Definition at line 840 of file hwcontext_videotoolbox.c.