FFmpeg
Loading...
Searching...
No Matches
videotoolbox.c File Reference
#include "config.h"
#include "config_components.h"
#include "videotoolbox.h"
#include "libavutil/attributes.h"
#include "libavutil/hwcontext_videotoolbox.h"
#include "libavutil/mem.h"
#include "vt_internal.h"
#include "libavutil/avutil.h"
#include "libavutil/hwcontext.h"
#include "libavutil/pixdesc.h"
#include "bytestream.h"
#include "decode.h"
#include "internal.h"
#include "h264dec.h"
#include "hevc/hevcdec.h"
#include "hwaccel_internal.h"
#include "mpegvideo.h"
#include "proresdec.h"
#include "prores_raw.h"
#include <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>

Go to the source code of this file.

Data Structures

struct  VTHWFrame
 

Macros

#define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder   CFSTR("RequireHardwareAcceleratedVideoDecoder")
 
#define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder   CFSTR("EnableHardwareAcceleratedVideoDecoder")
 
#define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING   12
 
#define AV_W8(p, v)
 
#define COUNT_SIZE_PS(T, t)
 
#define APPEND_PS(T, t)
 

Enumerations

enum  { kCMVideoCodecType_HEVC = 'hvc1' }
 
enum  { kCMVideoCodecType_VP9 = 'vp09' }
 
enum  { kCMVideoCodecType_AV1 = 'av01' }
 

Functions

static void videotoolbox_buffer_release (void *opaque, uint8_t *data)
 
int ff_videotoolbox_buffer_copy (VTContext *vtctx, const uint8_t *buffer, uint32_t size)
 
int ff_videotoolbox_buffer_append (VTContext *vtctx, const uint8_t *buffer, uint32_t size)
 
static int videotoolbox_postproc_frame (void *avctx, AVFrame *frame)
 
int ff_videotoolbox_alloc_frame (AVCodecContext *avctx, AVFrame *frame)
 
static int escape_ps (uint8_t *dst, const uint8_t *src, int src_size)
 
CFDataRef ff_videotoolbox_avcc_extradata_create (AVCodecContext *avctx)
 
CFDataRef ff_videotoolbox_hvcc_extradata_create (AVCodecContext *avctx)
 
int ff_videotoolbox_h264_start_frame (AVCodecContext *avctx, const AVBufferRef *buffer_ref, const uint8_t *buffer, uint32_t size)
 
static int videotoolbox_h264_decode_params (AVCodecContext *avctx, int type, const uint8_t *buffer, uint32_t size)
 
static int videotoolbox_common_decode_slice (AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 
int ff_videotoolbox_h264_decode_slice (AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 

Macro Definition Documentation

◆ kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder

#define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder   CFSTR("RequireHardwareAcceleratedVideoDecoder")

Definition at line 47 of file videotoolbox.c.

◆ kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder

#define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder   CFSTR("EnableHardwareAcceleratedVideoDecoder")

Definition at line 50 of file videotoolbox.c.

◆ VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING

#define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING   12

Definition at line 65 of file videotoolbox.c.

◆ AV_W8

#define AV_W8 ( p,
v )
Value:
*(p) = (v)

Definition at line 182 of file videotoolbox.c.

Referenced by ff_videotoolbox_avcc_extradata_create(), and ff_videotoolbox_hvcc_extradata_create().

◆ COUNT_SIZE_PS

#define COUNT_SIZE_PS ( T,
t )
Value:
for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
if (h->ps.t##ps_list[i]) { \
const HEVC##T##PS *lps = h->ps.t##ps_list[i]; \
vt_extradata_size += 2 + escape_ps(NULL, lps->data, lps->data_size); \
num_##t##ps++; \
} \
}
#define T(x)
Definition vpx_arith.h:29
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
static int escape_ps(uint8_t *dst, const uint8_t *src, int src_size)

Referenced by ff_videotoolbox_hvcc_extradata_create().

◆ APPEND_PS

#define APPEND_PS ( T,
t )
Value:
/* \
* bit(1) array_completeness; \
* unsigned int(1) reserved = 0; \
* unsigned int(6) NAL_unit_type; \
*/ \
AV_W8(p, 1 << 7 | \
HEVC_NAL_##T##PS & 0x3f); \
/* unsigned int(16) numNalus; */ \
AV_WB16(p + 1, num_##t##ps); \
p += 3; \
for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
if (h->ps.t##ps_list[i]) { \
const HEVC##T##PS *lps = h->ps.t##ps_list[i]; \
int size = escape_ps(p + 2, lps->data, lps->data_size); \
/* unsigned int(16) nalUnitLength; */ \
AV_WB16(p, size); \
/* bit(8*nalUnitLength) nalUnit; */ \
p += 2 + size; \
} \
}
int size

Referenced by ff_videotoolbox_hvcc_extradata_create().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kCMVideoCodecType_HEVC 

Definition at line 54 of file videotoolbox.c.

◆ anonymous enum

anonymous enum
Enumerator
kCMVideoCodecType_VP9 

Definition at line 58 of file videotoolbox.c.

◆ anonymous enum

anonymous enum
Enumerator
kCMVideoCodecType_AV1 

Definition at line 62 of file videotoolbox.c.

Function Documentation

◆ videotoolbox_buffer_release()

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

Definition at line 72 of file videotoolbox.c.

Referenced by ff_videotoolbox_alloc_frame(), and vt_pool_alloc_buffer().

◆ ff_videotoolbox_buffer_copy()

int ff_videotoolbox_buffer_copy ( VTContext * vtctx,
const uint8_t * buffer,
uint32_t size )

Definition at line 81 of file videotoolbox.c.

Referenced by videotoolbox_vp9_decode_slice().

◆ ff_videotoolbox_buffer_append()

int ff_videotoolbox_buffer_append ( VTContext * vtctx,
const uint8_t * buffer,
uint32_t size )

Definition at line 101 of file videotoolbox.c.

Referenced by videotoolbox_av1_end_frame().

◆ videotoolbox_postproc_frame()

static int videotoolbox_postproc_frame ( void * avctx,
AVFrame * frame )
static

Definition at line 121 of file videotoolbox.c.

Referenced by ff_videotoolbox_alloc_frame().

◆ ff_videotoolbox_alloc_frame()

int ff_videotoolbox_alloc_frame ( AVCodecContext * avctx,
AVFrame * frame )

Definition at line 152 of file videotoolbox.c.

◆ escape_ps()

static int escape_ps ( uint8_t * dst,
const uint8_t * src,
int src_size )
static

Definition at line 184 of file videotoolbox.c.

Referenced by ff_videotoolbox_avcc_extradata_create().

◆ ff_videotoolbox_avcc_extradata_create()

CFDataRef ff_videotoolbox_avcc_extradata_create ( AVCodecContext * avctx)

Definition at line 213 of file videotoolbox.c.

◆ ff_videotoolbox_hvcc_extradata_create()

CFDataRef ff_videotoolbox_hvcc_extradata_create ( AVCodecContext * avctx)

Definition at line 258 of file videotoolbox.c.

◆ ff_videotoolbox_h264_start_frame()

int ff_videotoolbox_h264_start_frame ( AVCodecContext * avctx,
const AVBufferRef * buffer_ref,
const uint8_t * buffer,
uint32_t size )

Definition at line 415 of file videotoolbox.c.

◆ videotoolbox_h264_decode_params()

static int videotoolbox_h264_decode_params ( AVCodecContext * avctx,
int type,
const uint8_t * buffer,
uint32_t size )
static

Definition at line 430 of file videotoolbox.c.

◆ videotoolbox_common_decode_slice()

static int videotoolbox_common_decode_slice ( AVCodecContext * avctx,
const uint8_t * buffer,
uint32_t size )
static

Definition at line 453 of file videotoolbox.c.

◆ ff_videotoolbox_h264_decode_slice()

int ff_videotoolbox_h264_decode_slice ( AVCodecContext * avctx,
const uint8_t * buffer,
uint32_t size )

Definition at line 476 of file videotoolbox.c.