28 #include <CoreFoundation/CoreFoundation.h>
34 #ifndef kCFCoreFoundationVersionNumber10_7
35 #define kCFCoreFoundationVersionNumber10_7 635.00
74 CVPixelBufferUnlockBaseAddress(context->
cv_buffer, 0);
83 if (!context || !buffer) {
89 pic->
data[0] = (
void *)1;
100 ret = ff_h264_decoder.
decode(avctx, data, got_frame, avpkt);
104 CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->
data[3];
106 CVPixelBufferRetain(cv_buffer);
107 CVPixelBufferLockBaseAddress(cv_buffer, 0);
110 if (CVPixelBufferIsPlanar(cv_buffer)) {
111 int i,
count = CVPixelBufferGetPlaneCount(cv_buffer);
113 for (i = 0; i <
count; i++) {
114 pic->
data[i] = CVPixelBufferGetBaseAddressOfPlane(cv_buffer, i);
115 pic->
linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(cv_buffer, i);
118 pic->
data[0] = CVPixelBufferGetBaseAddress(cv_buffer);
119 pic->
linesize[0] = CVPixelBufferGetBytesPerRow(cv_buffer);
134 ff_h264_decoder.
close(avctx);
148 if (!ff_h264_vda_decoder.
pix_fmts) {
182 if (status != kVDADecoderNoErr) {
184 "Failed to init VDA decoder: %d.\n", status);
192 #if FF_API_GET_BUFFER
198 ret = ff_h264_decoder.
init(avctx);
214 return ff_h264_decoder.
flush(avctx);
void * av_buffer_get_opaque(const AVBufferRef *buf)
This structure describes decoded (raw) audio or video data.
void(* flush)(AVCodecContext *)
Flush buffers.
static av_cold int init(AVCodecContext *avctx)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVCodec ff_h264_vda_decoder
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
int format
The frame format.
attribute_deprecated int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
OSType cv_pix_fmt_type
The pixel format for output image buffers.
int use_ref_buffer
Use av_buffer to manage buffer.
const char * name
Name of the codec implementation.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
static enum AVPixelFormat get_format(struct AVCodecContext *avctx, const enum AVPixelFormat *fmt)
enum AVPixelFormat pix_fmt
int width
The frame width.
static av_cold int vdadec_init(AVCodecContext *avctx)
static enum AVPixelFormat vda_pixfmts[]
H.264 / AVC / MPEG4 part10 codec.
int(* close)(AVCodecContext *)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Public libavcodec VDA header.
This structure is used to provide the necessary configurations and data to the VDA FFmpeg HWAccel imp...
Libavcodec external API header.
AVPixelFormat
Pixel format.
static av_cold int vdadec_close(AVCodecContext *avctx)
int width
picture width / height.
enum AVPixelFormat pix_fmt
struct vda_context vda_ctx
static void flush(AVCodecContext *avctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
CVPixelBufferRef cv_buffer
void * hwaccel_context
Hardware accelerator context.
int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
Destroy the video decoder.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
main external API structure.
static void close(AVCodecParserContext *s)
static enum AVPixelFormat vda_pixfmts_prior_10_7[]
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
int use_sync_decoding
Use the hardware decoder in synchronous mode.
static void vdadec_flush(AVCodecContext *avctx)
#define kCFCoreFoundationVersionNumber10_7
hardware decoding through VDA
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
A reference to a data buffer.
static void release_buffer(void *opaque, uint8_t *data)
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
int ff_vda_create_decoder(struct vda_context *vda_ctx, uint8_t *extradata, int extradata_size)
Create the video decoder.
static int vdadec_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int get_buffer2(AVCodecContext *avctx, AVFrame *pic, int flag)
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int(* init)(AVCodecContext *)
int height
The frame height.
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...