28 #include <CoreFoundation/CoreFoundation.h>
34 #ifndef kCFCoreFoundationVersionNumber10_7
35 #define kCFCoreFoundationVersionNumber10_7 635.00
80 CVPixelBufferUnlockBaseAddress(context->
cv_buffer, 0);
89 if (!context || !buffer) {
95 pic->
data[0] = (
void *)1;
126 ret = ff_h264_decoder.
decode(avctx, data, got_frame, avpkt);
131 CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->
data[3];
133 CVPixelBufferRetain(cv_buffer);
134 CVPixelBufferLockBaseAddress(cv_buffer, 0);
137 if (CVPixelBufferIsPlanar(cv_buffer)) {
138 int i,
count = CVPixelBufferGetPlaneCount(cv_buffer);
140 for (i = 0; i <
count; i++) {
141 pic->
data[i] = CVPixelBufferGetBaseAddressOfPlane(cv_buffer, i);
142 pic->
linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(cv_buffer, i);
145 pic->
data[0] = CVPixelBufferGetBaseAddress(cv_buffer);
146 pic->
linesize[0] = CVPixelBufferGetBytesPerRow(cv_buffer);
162 ff_h264_decoder.
close(avctx);
178 if (!ff_h264_vda_decoder.
pix_fmts) {
212 if (status != kVDADecoderNoErr) {
214 "Failed to init VDA decoder: %d.\n", status);
220 ret = ff_h264_decoder.
init(avctx);
248 ff_h264_decoder.
flush(avctx);
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
const struct AVCodec * codec
static enum AVPixelFormat pix_fmt
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
void(* flush)(AVCodecContext *)
Flush buffers.
AVBufferRef * sps_list[MAX_SPS_COUNT]
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
AVCodec ff_h264_vda_decoder
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
int format
The frame format.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
OSType cv_pix_fmt_type
The pixel format for output image buffers.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int use_ref_buffer
Use av_buffer to manage buffer.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void * hwaccel_context
Hardware accelerator context.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static enum AVPixelFormat get_format(struct AVCodecContext *avctx, const enum AVPixelFormat *fmt)
int width
The frame width.
static av_cold int vdadec_init(AVCodecContext *avctx)
static enum AVPixelFormat vda_pixfmts[]
int(* close)(AVCodecContext *)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
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.
This structure is used to provide the necessary configurations and data to the VDA FFmpeg HWAccel imp...
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
static av_cold int vdadec_close(AVCodecContext *avctx)
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
int width
picture width / height.
H.264 / AVC / MPEG-4 part10 codec.
enum AVPixelFormat pix_fmt
struct vda_context vda_ctx
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
CVPixelBufferRef cv_buffer
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Public libavcodec VDA header.
int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
Destroy the video decoder.
main external API structure.
uint8_t * data
The data buffer.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static enum AVPixelFormat vda_pixfmts_prior_10_7[]
static void set_context(AVCodecContext *avctx)
void * av_buffer_get_opaque(const AVBufferRef *buf)
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
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
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A reference to a data buffer.
hardware decoding through VDA
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void restore_context(AVCodecContext *avctx)
static void release_buffer(void *opaque, uint8_t *data)
int bit_depth_luma
bit_depth_luma_minus8 + 8
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)
int(* init)(AVCodecContext *)
int height
The frame height.
AVPixelFormat
Pixel format.
This structure stores compressed data.