FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vda_h264.c
Go to the documentation of this file.
1 /*
2  * VDA H264 HW acceleration.
3  *
4  * copyright (c) 2011 Sebastien Zwickert
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <CoreFoundation/CFDictionary.h>
24 #include <CoreFoundation/CFNumber.h>
25 #include <CoreFoundation/CFData.h>
26 
27 #include "vda.h"
28 #include "libavutil/avutil.h"
29 #include "h264.h"
30 
31 struct vda_buffer {
32  CVPixelBufferRef cv_buffer;
33 };
34 #include "internal.h"
35 #include "vda_internal.h"
36 
37 typedef struct VDAContext {
38  // The current bitstream buffer.
40 
41  // The current size of the bitstream.
43 
44  // The reference size used for fast reallocation.
46 
47  CVImageBufferRef frame;
48 } VDAContext;
49 
50 /* Decoder callback that adds the vda frame to the queue in display order. */
51 static void vda_decoder_callback(void *vda_hw_ctx,
52  CFDictionaryRef user_info,
53  OSStatus status,
54  uint32_t infoFlags,
55  CVImageBufferRef image_buffer)
56 {
57  struct vda_context *vda_ctx = vda_hw_ctx;
58 
59  if (infoFlags & kVDADecodeInfo_FrameDropped)
60  vda_ctx->cv_buffer = NULL;
61 
62  if (!image_buffer)
63  return;
64 
65  if (vda_ctx->cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
66  return;
67 
68  vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer);
69 }
70 
71 static int vda_sync_decode(VDAContext *ctx, struct vda_context *vda_ctx)
72 {
73  OSStatus status;
74  CFDataRef coded_frame;
75  uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
76 
77  coded_frame = CFDataCreate(kCFAllocatorDefault,
78  ctx->bitstream,
79  ctx->bitstream_size);
80 
81  status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
82 
83  if (kVDADecoderNoErr == status)
84  status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
85 
86  CFRelease(coded_frame);
87 
88  return status;
89 }
90 
91 
93  av_unused const uint8_t *buffer,
94  av_unused uint32_t size)
95 {
96  VDAContext *vda = avctx->internal->hwaccel_priv_data;
97  struct vda_context *vda_ctx = avctx->hwaccel_context;
98 
99  if (!vda_ctx->decoder)
100  return -1;
101 
102  vda->bitstream_size = 0;
103 
104  return 0;
105 }
106 
108  const uint8_t *buffer,
109  uint32_t size)
110 {
111  VDAContext *vda = avctx->internal->hwaccel_priv_data;
112  struct vda_context *vda_ctx = avctx->hwaccel_context;
113  void *tmp;
114 
115  if (!vda_ctx->decoder)
116  return -1;
117 
118  tmp = av_fast_realloc(vda->bitstream,
119  &vda->allocated_size,
120  vda->bitstream_size + size + 4);
121  if (!tmp)
122  return AVERROR(ENOMEM);
123 
124  vda->bitstream = tmp;
125 
126  AV_WB32(vda->bitstream + vda->bitstream_size, size);
127  memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
128 
129  vda->bitstream_size += size + 4;
130 
131  return 0;
132 }
133 
134 static void vda_h264_release_buffer(void *opaque, uint8_t *data)
135 {
136  struct vda_buffer *context = opaque;
137  CVPixelBufferRelease(context->cv_buffer);
138  av_free(context);
139 }
140 
142 {
143  H264Context *h = avctx->priv_data;
144  VDAContext *vda = avctx->internal->hwaccel_priv_data;
145  struct vda_context *vda_ctx = avctx->hwaccel_context;
146  AVFrame *frame = h->cur_pic_ptr->f;
147  struct vda_buffer *context;
149  int status;
150 
151  if (!vda_ctx->decoder || !vda->bitstream)
152  return -1;
153 
154  status = vda_sync_decode(vda, vda_ctx);
155  frame->data[3] = (void*)vda_ctx->cv_buffer;
156 
157  if (status)
158  av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
159 
160  if (!vda_ctx->use_ref_buffer || status)
161  return status;
162 
163  context = av_mallocz(sizeof(*context));
164  buffer = av_buffer_create(NULL, 0, vda_h264_release_buffer, context, 0);
165  if (!context || !buffer) {
166  CVPixelBufferRelease(vda_ctx->cv_buffer);
167  av_free(context);
168  return -1;
169  }
170 
171  context->cv_buffer = vda_ctx->cv_buffer;
172  frame->buf[3] = buffer;
173 
174  return status;
175 }
176 
177 int ff_vda_create_decoder(struct vda_context *vda_ctx,
178  uint8_t *extradata,
179  int extradata_size)
180 {
181  OSStatus status;
182  CFNumberRef height;
183  CFNumberRef width;
184  CFNumberRef format;
185  CFDataRef avc_data;
186  CFMutableDictionaryRef config_info;
187  CFMutableDictionaryRef buffer_attributes;
188  CFMutableDictionaryRef io_surface_properties;
189  CFNumberRef cv_pix_fmt;
190 
191  vda_ctx->priv_bitstream = NULL;
192  vda_ctx->priv_allocated_size = 0;
193 
194  /* Each VCL NAL in the bitstream sent to the decoder
195  * is preceded by a 4 bytes length header.
196  * Change the avcC atom header if needed, to signal headers of 4 bytes. */
197  if (extradata_size >= 4 && (extradata[4] & 0x03) != 0x03) {
198  uint8_t *rw_extradata;
199 
200  if (!(rw_extradata = av_malloc(extradata_size)))
201  return AVERROR(ENOMEM);
202 
203  memcpy(rw_extradata, extradata, extradata_size);
204 
205  rw_extradata[4] |= 0x03;
206 
207  avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, extradata_size);
208 
209  av_freep(&rw_extradata);
210  } else {
211  avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size);
212  }
213 
214  config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
215  4,
216  &kCFTypeDictionaryKeyCallBacks,
217  &kCFTypeDictionaryValueCallBacks);
218 
219  height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height);
220  width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width);
221  format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format);
222 
223  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
224  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
225  CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
226  CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
227 
228  buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
229  2,
230  &kCFTypeDictionaryKeyCallBacks,
231  &kCFTypeDictionaryValueCallBacks);
232  io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
233  0,
234  &kCFTypeDictionaryKeyCallBacks,
235  &kCFTypeDictionaryValueCallBacks);
236  cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
237  kCFNumberSInt32Type,
238  &vda_ctx->cv_pix_fmt_type);
239  CFDictionarySetValue(buffer_attributes,
240  kCVPixelBufferPixelFormatTypeKey,
241  cv_pix_fmt);
242  CFDictionarySetValue(buffer_attributes,
243  kCVPixelBufferIOSurfacePropertiesKey,
244  io_surface_properties);
245 
246  status = VDADecoderCreate(config_info,
247  buffer_attributes,
248  (VDADecoderOutputCallback *)vda_decoder_callback,
249  vda_ctx,
250  &vda_ctx->decoder);
251 
252  CFRelease(height);
253  CFRelease(width);
254  CFRelease(format);
255  CFRelease(avc_data);
256  CFRelease(config_info);
257  CFRelease(io_surface_properties);
258  CFRelease(cv_pix_fmt);
259  CFRelease(buffer_attributes);
260 
261  return status;
262 }
263 
265 {
266  OSStatus status = kVDADecoderNoErr;
267 
268  if (vda_ctx->decoder)
269  status = VDADecoderDestroy(vda_ctx->decoder);
270 
271  return status;
272 }
273 
274 static int vda_h264_uninit(AVCodecContext *avctx)
275 {
276  VDAContext *vda = avctx->internal->hwaccel_priv_data;
277  if (vda) {
278  av_freep(&vda->bitstream);
279  if (vda->frame)
280  CVPixelBufferRelease(vda->frame);
281  }
282  return 0;
283 }
284 
286  .name = "h264_vda",
287  .type = AVMEDIA_TYPE_VIDEO,
288  .id = AV_CODEC_ID_H264,
289  .pix_fmt = AV_PIX_FMT_VDA_VLD,
290  .start_frame = vda_old_h264_start_frame,
291  .decode_slice = vda_old_h264_decode_slice,
292  .end_frame = vda_old_h264_end_frame,
293  .uninit = vda_h264_uninit,
294  .priv_data_size = sizeof(VDAContext),
295 };
296 
297 void ff_vda_output_callback(void *opaque,
298  CFDictionaryRef user_info,
299  OSStatus status,
300  uint32_t infoFlags,
301  CVImageBufferRef image_buffer)
302 {
303  AVCodecContext *ctx = opaque;
305 
306 
307  if (vda->frame) {
308  CVPixelBufferRelease(vda->frame);
309  vda->frame = NULL;
310  }
311 
312  if (!image_buffer)
313  return;
314 
315  vda->frame = CVPixelBufferRetain(image_buffer);
316 }
317 
319  const uint8_t *buffer,
320  uint32_t size)
321 {
322  VDAContext *vda = avctx->internal->hwaccel_priv_data;
323  H264Context *h = avctx->priv_data;
324 
325  if (h->is_avc == 1) {
326  void *tmp;
327  vda->bitstream_size = 0;
328  tmp = av_fast_realloc(vda->bitstream,
329  &vda->allocated_size,
330  size);
331  vda->bitstream = tmp;
332  memcpy(vda->bitstream, buffer, size);
333  vda->bitstream_size = size;
334  } else {
335  vda->bitstream_size = 0;
336  }
337  return 0;
338 }
339 
341  const uint8_t *buffer,
342  uint32_t size)
343 {
344  VDAContext *vda = avctx->internal->hwaccel_priv_data;
345  H264Context *h = avctx->priv_data;
346  void *tmp;
347 
348  if (h->is_avc == 1)
349  return 0;
350 
351  tmp = av_fast_realloc(vda->bitstream,
352  &vda->allocated_size,
353  vda->bitstream_size + size + 4);
354  if (!tmp)
355  return AVERROR(ENOMEM);
356 
357  vda->bitstream = tmp;
358 
359  AV_WB32(vda->bitstream + vda->bitstream_size, size);
360  memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
361 
362  vda->bitstream_size += size + 4;
363 
364  return 0;
365 }
366 
367 static void release_buffer(void *opaque, uint8_t *data)
368 {
369  CVImageBufferRef frame = (CVImageBufferRef)data;
370  CVPixelBufferRelease(frame);
371 }
372 
374 {
375  H264Context *h = avctx->priv_data;
376  VDAContext *vda = avctx->internal->hwaccel_priv_data;
377  AVVDAContext *vda_ctx = avctx->hwaccel_context;
378  AVFrame *frame = h->cur_pic_ptr->f;
379  uint32_t flush_flags = 1 << 0; ///< kVDADecoderFlush_emitFrames
380  CFDataRef coded_frame;
381  OSStatus status;
382 
383  if (!vda->bitstream_size)
384  return AVERROR_INVALIDDATA;
385 
386 
387  coded_frame = CFDataCreate(kCFAllocatorDefault,
388  vda->bitstream,
389  vda->bitstream_size);
390 
391  status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, NULL);
392 
393  if (status == kVDADecoderNoErr)
394  status = VDADecoderFlush(vda_ctx->decoder, flush_flags);
395 
396  CFRelease(coded_frame);
397 
398  if (!vda->frame)
399  return AVERROR_UNKNOWN;
400 
401  if (status != kVDADecoderNoErr) {
402  av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
403  return AVERROR_UNKNOWN;
404  }
405 
406  av_buffer_unref(&frame->buf[0]);
407 
408  frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
409  sizeof(vda->frame),
412  if (!frame->buf)
413  return AVERROR(ENOMEM);
414 
415  frame->data[3] = (uint8_t*)vda->frame;
416  vda->frame = NULL;
417 
418  return 0;
419 }
420 
422 {
423  AVVDAContext *vda_ctx = avctx->hwaccel_context;
424  OSStatus status = kVDADecoderNoErr;
425  CFNumberRef height;
426  CFNumberRef width;
427  CFNumberRef format;
428  CFDataRef avc_data;
429  CFMutableDictionaryRef config_info;
430  CFMutableDictionaryRef buffer_attributes;
431  CFMutableDictionaryRef io_surface_properties;
432  CFNumberRef cv_pix_fmt;
433  int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
434 
435  // kCVPixelFormatType_420YpCbCr8Planar;
436 
437  /* Each VCL NAL in the bitstream sent to the decoder
438  * is preceded by a 4 bytes length header.
439  * Change the avcC atom header if needed, to signal headers of 4 bytes. */
440  if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) {
441  uint8_t *rw_extradata;
442 
443  if (!(rw_extradata = av_malloc(avctx->extradata_size)))
444  return AVERROR(ENOMEM);
445 
446  memcpy(rw_extradata, avctx->extradata, avctx->extradata_size);
447 
448  rw_extradata[4] |= 0x03;
449 
450  avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size);
451 
452  av_freep(&rw_extradata);
453  } else {
454  avc_data = CFDataCreate(kCFAllocatorDefault,
455  avctx->extradata, avctx->extradata_size);
456  }
457 
458  config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
459  4,
460  &kCFTypeDictionaryKeyCallBacks,
461  &kCFTypeDictionaryValueCallBacks);
462 
463  height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->height);
464  width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &avctx->width);
465  format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &fmt);
466  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height);
467  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width);
468  CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data);
469  CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
470 
471  buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
472  2,
473  &kCFTypeDictionaryKeyCallBacks,
474  &kCFTypeDictionaryValueCallBacks);
475  io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
476  0,
477  &kCFTypeDictionaryKeyCallBacks,
478  &kCFTypeDictionaryValueCallBacks);
479  cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
480  kCFNumberSInt32Type,
481  &pix_fmt);
482 
483  CFDictionarySetValue(buffer_attributes,
484  kCVPixelBufferPixelFormatTypeKey,
485  cv_pix_fmt);
486  CFDictionarySetValue(buffer_attributes,
487  kCVPixelBufferIOSurfacePropertiesKey,
488  io_surface_properties);
489 
490  status = VDADecoderCreate(config_info,
491  buffer_attributes,
492  (VDADecoderOutputCallback *)ff_vda_output_callback,
493  avctx,
494  &vda_ctx->decoder);
495 
496  CFRelease(format);
497  CFRelease(height);
498  CFRelease(width);
499  CFRelease(avc_data);
500  CFRelease(config_info);
501  CFRelease(cv_pix_fmt);
502  CFRelease(io_surface_properties);
503  CFRelease(buffer_attributes);
504 
505  if (status != kVDADecoderNoErr) {
506  av_log(avctx, AV_LOG_ERROR, "Cannot initialize VDA %d\n", status);
507  }
508 
509  switch (status) {
510  case kVDADecoderHardwareNotSupportedErr:
511  case kVDADecoderFormatNotSupportedErr:
512  return AVERROR(ENOSYS);
513  case kVDADecoderConfigurationError:
514  return AVERROR(EINVAL);
515  case kVDADecoderDecoderFailedErr:
516  return AVERROR_INVALIDDATA;
517  case kVDADecoderNoErr:
518  return 0;
519  default:
520  return AVERROR_UNKNOWN;
521  }
522 }
523 
525 {
526  frame->width = avctx->width;
527  frame->height = avctx->height;
528  frame->format = avctx->pix_fmt;
529  frame->buf[0] = av_buffer_alloc(1);
530 
531  if (!frame->buf[0])
532  return AVERROR(ENOMEM);
533  return 0;
534 }
535 
537  .name = "h264_vda",
538  .type = AVMEDIA_TYPE_VIDEO,
539  .id = AV_CODEC_ID_H264,
540  .pix_fmt = AV_PIX_FMT_VDA,
541  .alloc_frame = vda_h264_alloc_frame,
542  .start_frame = vda_h264_start_frame,
543  .decode_slice = vda_h264_decode_slice,
544  .end_frame = vda_h264_end_frame,
545  .uninit = vda_h264_uninit,
546  .priv_data_size = sizeof(VDAContext),
547 };
#define NULL
Definition: coverity.c:32
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static enum AVPixelFormat pix_fmt
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:124
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
const char * fmt
Definition: avisynth_c.h:632
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:441
AVHWAccel ff_h264_vda_old_hwaccel
Definition: vda_h264.c:285
static int vda_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: vda_h264.c:340
static void release_buffer(void *opaque, uint8_t *data)
Definition: vda_h264.c:367
void ff_vda_output_callback(void *opaque, CFDictionaryRef user_info, OSStatus status, uint32_t infoFlags, CVImageBufferRef image_buffer)
Definition: vda_h264.c:297
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1444
external API header
int is_avc
Used to parse AVC variant of h264.
Definition: h264.h:606
H264Context.
Definition: h264.h:499
AVFrame * f
Definition: h264.h:293
static int vda_old_h264_end_frame(AVCodecContext *avctx)
Definition: vda_h264.c:141
int format
The frame format.
Definition: vda.h:112
OSType cv_pix_fmt_type
The pixel format for output image buffers.
Definition: vda.h:120
This struct holds all the information that needs to be passed between the caller and libavcodec for i...
Definition: vda.h:163
int use_ref_buffer
Use av_buffer to manage buffer.
Definition: vda.h:146
if()
Definition: avfilter.c:975
uint8_t
#define av_malloc(s)
void * hwaccel_context
Hardware accelerator context.
Definition: avcodec.h:2656
OSType cv_pix_fmt_type
CVPixelBuffer Format Type that VDA will use for decoded frames; set by the caller.
Definition: vda.h:179
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1355
static AVFrame * frame
int width
The frame width.
Definition: vda.h:96
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
Definition: buffer.h:113
ptrdiff_t size
Definition: opengl_enc.c:101
#define av_log(a,...)
static int vda_h264_uninit(AVCodecContext *avctx)
Definition: vda_h264.c:274
CVPixelBufferRef cv_buffer
The Core Video pixel buffer that contains the current image data.
Definition: vda.h:80
H.264 / AVC / MPEG4 part10 codec.
int ff_vda_default_init(AVCodecContext *avctx)
Definition: vda_h264.c:421
int width
width and height of the video frame
Definition: frame.h:220
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
Definition: mem.c:478
VDADecoder decoder
VDA decoder object.
Definition: vda.h:72
#define AVERROR(e)
Definition: error.h:43
static int vda_h264_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: vda_h264.c:524
static int vda_sync_decode(VDAContext *ctx, struct vda_context *vda_ctx)
Definition: vda_h264.c:71
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.
Definition: buffer.c:28
HW acceleration through VDA, data[3] contains a CVPixelBufferRef.
Definition: pixfmt.h:232
This structure is used to provide the necessary configurations and data to the VDA FFmpeg HWAccel imp...
Definition: vda.h:65
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:3294
int width
picture width / height.
Definition: avcodec.h:1414
int32_t
static void vda_h264_release_buffer(void *opaque, uint8_t *data)
Definition: vda_h264.c:134
VDADecoder decoder
VDA decoder object.
Definition: vda.h:167
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:232
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:66
Public libavcodec VDA header.
int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
Destroy the video decoder.
Definition: vda_h264.c:264
main external API structure.
Definition: avcodec.h:1241
static int vda_old_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: vda_h264.c:107
int extradata_size
Definition: avcodec.h:1356
static void vda_decoder_callback(void *vda_hw_ctx, CFDictionaryRef user_info, OSStatus status, uint32_t infoFlags, CVImageBufferRef image_buffer)
Definition: vda_h264.c:51
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
H264Picture * cur_pic_ptr
Definition: h264.h:509
AVHWAccel ff_h264_vda_hwaccel
Definition: vda_h264.c:536
uint8_t * priv_bitstream
unused
Definition: vda.h:125
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:182
A reference to a data buffer.
Definition: buffer.h:81
hardware decoding through VDA
Definition: pixfmt.h:168
CVPixelBufferRef cv_buffer
Definition: vda_h264.c:32
common internal api header.
static int vda_h264_end_frame(AVCodecContext *avctx)
Definition: vda_h264.c:373
int allocated_size
Definition: vda_h264.c:45
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:161
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
void * priv_data
Definition: avcodec.h:1283
#define av_free(p)
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1291
int ff_vda_create_decoder(struct vda_context *vda_ctx, uint8_t *extradata, int extradata_size)
Create the video decoder.
Definition: vda_h264.c:177
static int vda_old_h264_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vda_h264.c:92
int priv_allocated_size
unused
Definition: vda.h:135
int height
Definition: frame.h:220
int bitstream_size
Definition: vda_h264.c:42
#define av_freep(p)
static int vda_h264_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: vda_h264.c:318
uint8_t * bitstream
Definition: vda_h264.c:39
int height
The frame height.
Definition: vda.h:104
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:250
GLuint buffer
Definition: opengl_enc.c:102
#define av_unused
Definition: attributes.h:118
CVImageBufferRef frame
Definition: vda_h264.c:47
static int width