FFmpeg
hwcontext_videotoolbox.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "config.h"
20 
21 #include <stdint.h>
22 #include <string.h>
23 
24 #include <VideoToolbox/VideoToolbox.h>
25 
26 #include "buffer.h"
27 #include "buffer_internal.h"
28 #include "common.h"
29 #include "hwcontext.h"
30 #include "hwcontext_internal.h"
31 #include "hwcontext_videotoolbox.h"
32 #include "mem.h"
33 #include "pixfmt.h"
34 #include "pixdesc.h"
35 
36 typedef struct VTFramesContext {
37  CVPixelBufferPoolRef pool;
39 
40 static const struct {
41  uint32_t cv_fmt;
42  bool full_range;
44 } cv_pix_fmts[] = {
45  { kCVPixelFormatType_420YpCbCr8Planar, false, AV_PIX_FMT_YUV420P },
46  { kCVPixelFormatType_422YpCbCr8, false, AV_PIX_FMT_UYVY422 },
47  { kCVPixelFormatType_32BGRA, false, AV_PIX_FMT_BGRA },
48 #ifdef kCFCoreFoundationVersionNumber10_7
49  { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV12 },
50  { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV12 },
51  { kCVPixelFormatType_4444AYpCbCr16, false, AV_PIX_FMT_AYUV64 },
52 #endif
53 #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
56 #endif
57 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
58  { kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV16 },
59  { kCVPixelFormatType_422YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV16 },
60 #endif
61 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
62  { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P210 },
63  { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P210 },
64 #endif
65 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE
66  { kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P216 },
67 #endif
68 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
69  { kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV24 },
70  { kCVPixelFormatType_444YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV24 },
71 #endif
72 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
73  { kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P410 },
74  { kCVPixelFormatType_444YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P410 },
75 #endif
76 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
77  { kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P416 },
78 #endif
79 };
80 
81 static const enum AVPixelFormat supported_formats[] = {
82 #ifdef kCFCoreFoundationVersionNumber10_7
85 #endif
88 #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
90 #endif
91 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
93 #endif
94 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
96 #endif
97 #if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE
99 #endif
100 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
102 #endif
103 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
105 #endif
106 #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
108 #endif
110 };
111 
113  const void *hwconfig,
114  AVHWFramesConstraints *constraints)
115 {
116  int i;
117 
119  sizeof(*constraints->valid_sw_formats));
120  if (!constraints->valid_sw_formats)
121  return AVERROR(ENOMEM);
122 
123  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
124  constraints->valid_sw_formats[i] = supported_formats[i];
126 
127  constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats));
128  if (!constraints->valid_hw_formats)
129  return AVERROR(ENOMEM);
130 
131  constraints->valid_hw_formats[0] = AV_PIX_FMT_VIDEOTOOLBOX;
132  constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
133 
134  return 0;
135 }
136 
138 {
139  int i;
140  for (i = 0; i < FF_ARRAY_ELEMS(cv_pix_fmts); i++) {
141  if (cv_pix_fmts[i].cv_fmt == cv_fmt)
142  return cv_pix_fmts[i].pix_fmt;
143  }
144  return AV_PIX_FMT_NONE;
145 }
146 
148 {
150 }
151 
153 {
154  int i;
155  for (i = 0; i < FF_ARRAY_ELEMS(cv_pix_fmts); i++) {
157  return cv_pix_fmts[i].cv_fmt;
158  }
159  return 0;
160 }
161 
163 {
164  VTFramesContext *fctx = ctx->internal->priv;
165  CVReturn err;
166  CFNumberRef w, h, pixfmt;
167  uint32_t cv_pixfmt;
168  CFMutableDictionaryRef attributes, iosurface_properties;
169 
170  attributes = CFDictionaryCreateMutable(
171  NULL,
172  2,
173  &kCFTypeDictionaryKeyCallBacks,
174  &kCFTypeDictionaryValueCallBacks);
175 
176  cv_pixfmt = av_map_videotoolbox_format_from_pixfmt(ctx->sw_format);
177  pixfmt = CFNumberCreate(NULL, kCFNumberSInt32Type, &cv_pixfmt);
178  CFDictionarySetValue(
179  attributes,
180  kCVPixelBufferPixelFormatTypeKey,
181  pixfmt);
182  CFRelease(pixfmt);
183 
184  iosurface_properties = CFDictionaryCreateMutable(
185  NULL,
186  0,
187  &kCFTypeDictionaryKeyCallBacks,
188  &kCFTypeDictionaryValueCallBacks);
189  CFDictionarySetValue(attributes, kCVPixelBufferIOSurfacePropertiesKey, iosurface_properties);
190  CFRelease(iosurface_properties);
191 
192  w = CFNumberCreate(NULL, kCFNumberSInt32Type, &ctx->width);
193  h = CFNumberCreate(NULL, kCFNumberSInt32Type, &ctx->height);
194  CFDictionarySetValue(attributes, kCVPixelBufferWidthKey, w);
195  CFDictionarySetValue(attributes, kCVPixelBufferHeightKey, h);
196  CFRelease(w);
197  CFRelease(h);
198 
199  err = CVPixelBufferPoolCreate(
200  NULL,
201  NULL,
202  attributes,
203  &fctx->pool);
204  CFRelease(attributes);
205 
206  if (err == kCVReturnSuccess)
207  return 0;
208 
209  av_log(ctx, AV_LOG_ERROR, "Error creating CVPixelBufferPool: %d\n", err);
210  return AVERROR_EXTERNAL;
211 }
212 
213 static AVBufferRef *vt_dummy_pool_alloc(void *opaque, size_t size)
214 {
215  return NULL;
216 }
217 
219 {
220  VTFramesContext *fctx = ctx->internal->priv;
221  if (fctx->pool) {
222  CVPixelBufferPoolRelease(fctx->pool);
223  fctx->pool = NULL;
224  }
225 }
226 
228 {
229  int i, ret;
230 
231  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
232  if (ctx->sw_format == supported_formats[i])
233  break;
234  }
236  av_log(ctx, AV_LOG_ERROR, "Pixel format '%s' is not supported\n",
237  av_get_pix_fmt_name(ctx->sw_format));
238  return AVERROR(ENOSYS);
239  }
240 
241  // create a dummy pool so av_hwframe_get_buffer doesn't EINVAL
242  if (!ctx->pool) {
243  ctx->internal->pool_internal = av_buffer_pool_init2(0, ctx, vt_dummy_pool_alloc, NULL);
244  if (!ctx->internal->pool_internal)
245  return AVERROR(ENOMEM);
246  }
247 
248  ret = vt_pool_alloc(ctx);
249  if (ret < 0)
250  return ret;
251 
252  return 0;
253 }
254 
255 static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
256 {
257  CVPixelBufferRelease((CVPixelBufferRef)data);
258 }
259 
261 {
262  VTFramesContext *fctx = ctx->internal->priv;
263 
264  if (ctx->pool && ctx->pool->size != 0) {
265  frame->buf[0] = av_buffer_pool_get(ctx->pool);
266  if (!frame->buf[0])
267  return AVERROR(ENOMEM);
268  } else {
269  CVPixelBufferRef pixbuf;
270  AVBufferRef *buf = NULL;
271  CVReturn err;
272 
273  err = CVPixelBufferPoolCreatePixelBuffer(
274  NULL,
275  fctx->pool,
276  &pixbuf
277  );
278  if (err != kCVReturnSuccess) {
279  av_log(ctx, AV_LOG_ERROR, "Failed to create pixel buffer from pool: %d\n", err);
280  return AVERROR_EXTERNAL;
281  }
282 
283  buf = av_buffer_create((uint8_t *)pixbuf, 1, videotoolbox_buffer_release, NULL, 0);
284  if (!buf) {
285  CVPixelBufferRelease(pixbuf);
286  return AVERROR(ENOMEM);
287  }
288  frame->buf[0] = buf;
289  }
290 
291  frame->data[3] = frame->buf[0]->data;
292  frame->format = AV_PIX_FMT_VIDEOTOOLBOX;
293  frame->width = ctx->width;
294  frame->height = ctx->height;
295 
296  return 0;
297 }
298 
301  enum AVPixelFormat **formats)
302 {
303  enum AVPixelFormat *fmts = av_malloc_array(2, sizeof(*fmts));
304  if (!fmts)
305  return AVERROR(ENOMEM);
306 
307  fmts[0] = ctx->sw_format;
308  fmts[1] = AV_PIX_FMT_NONE;
309 
310  *formats = fmts;
311  return 0;
312 }
313 
315 {
316  CVPixelBufferRef pixbuf = (CVPixelBufferRef)hwmap->source->data[3];
317 
318  CVPixelBufferUnlockBaseAddress(pixbuf, (uintptr_t)hwmap->priv);
319 }
320 
321 static int vt_pixbuf_set_par(void *log_ctx,
322  CVPixelBufferRef pixbuf, const AVFrame *src)
323 {
324  CFMutableDictionaryRef par = NULL;
325  CFNumberRef num = NULL, den = NULL;
326  AVRational avpar = src->sample_aspect_ratio;
327 
328  if (avpar.num == 0)
329  return 0;
330 
331  av_reduce(&avpar.num, &avpar.den,
332  avpar.num, avpar.den,
333  0xFFFFFFFF);
334 
335  num = CFNumberCreate(kCFAllocatorDefault,
336  kCFNumberIntType,
337  &avpar.num);
338 
339  den = CFNumberCreate(kCFAllocatorDefault,
340  kCFNumberIntType,
341  &avpar.den);
342 
343  par = CFDictionaryCreateMutable(kCFAllocatorDefault,
344  2,
345  &kCFCopyStringDictionaryKeyCallBacks,
346  &kCFTypeDictionaryValueCallBacks);
347 
348  if (!par || !num || !den) {
349  if (par) CFRelease(par);
350  if (num) CFRelease(num);
351  if (den) CFRelease(den);
352  return AVERROR(ENOMEM);
353  }
354 
355  CFDictionarySetValue(
356  par,
357  kCVImageBufferPixelAspectRatioHorizontalSpacingKey,
358  num);
359  CFDictionarySetValue(
360  par,
361  kCVImageBufferPixelAspectRatioVerticalSpacingKey,
362  den);
363 
364  CVBufferSetAttachment(
365  pixbuf,
366  kCVImageBufferPixelAspectRatioKey,
367  par,
368  kCVAttachmentMode_ShouldPropagate
369  );
370 
371  CFRelease(par);
372  CFRelease(num);
373  CFRelease(den);
374 
375  return 0;
376 }
377 
379 {
380  switch (loc) {
381  case AVCHROMA_LOC_LEFT:
382  return kCVImageBufferChromaLocation_Left;
383  case AVCHROMA_LOC_CENTER:
384  return kCVImageBufferChromaLocation_Center;
385  case AVCHROMA_LOC_TOP:
386  return kCVImageBufferChromaLocation_Top;
387  case AVCHROMA_LOC_BOTTOM:
388  return kCVImageBufferChromaLocation_Bottom;
390  return kCVImageBufferChromaLocation_TopLeft;
392  return kCVImageBufferChromaLocation_BottomLeft;
393  default:
394  return NULL;
395  }
396 }
397 
398 static int vt_pixbuf_set_chromaloc(void *log_ctx,
399  CVPixelBufferRef pixbuf, const AVFrame *src)
400 {
401  CFStringRef loc = av_map_videotoolbox_chroma_loc_from_av(src->chroma_location);
402 
403  if (loc) {
404  CVBufferSetAttachment(
405  pixbuf,
406  kCVImageBufferChromaLocationTopFieldKey,
407  loc,
408  kCVAttachmentMode_ShouldPropagate);
409  }
410 
411  return 0;
412 }
413 
415 {
416  switch (space) {
417  case AVCOL_SPC_BT2020_CL:
419 #if HAVE_KCVIMAGEBUFFERYCBCRMATRIX_ITU_R_2020
420  if (__builtin_available(macOS 10.11, iOS 9, *))
422 #endif
423  return CFSTR("ITU_R_2020");
424  case AVCOL_SPC_BT470BG:
425  case AVCOL_SPC_SMPTE170M:
426  return kCVImageBufferYCbCrMatrix_ITU_R_601_4;
427  case AVCOL_SPC_BT709:
428  return kCVImageBufferYCbCrMatrix_ITU_R_709_2;
429  case AVCOL_SPC_SMPTE240M:
430  return kCVImageBufferYCbCrMatrix_SMPTE_240M_1995;
431  default:
432 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
433  if (__builtin_available(macOS 10.13, iOS 11, tvOS 11, watchOS 4, *))
434  return CVYCbCrMatrixGetStringForIntegerCodePoint(space);
435 #endif
437  return NULL;
438  }
439 }
440 
442 {
443  switch (pri) {
444  case AVCOL_PRI_BT2020:
445 #if HAVE_KCVIMAGEBUFFERCOLORPRIMARIES_ITU_R_2020
446  if (__builtin_available(macOS 10.11, iOS 9, *))
448 #endif
449  return CFSTR("ITU_R_2020");
450  case AVCOL_PRI_BT709:
451  return kCVImageBufferColorPrimaries_ITU_R_709_2;
452  case AVCOL_PRI_SMPTE170M:
453  return kCVImageBufferColorPrimaries_SMPTE_C;
454  case AVCOL_PRI_BT470BG:
455  return kCVImageBufferColorPrimaries_EBU_3213;
456  default:
457 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
458  if (__builtin_available(macOS 10.13, iOS 11, tvOS 11, watchOS 4, *))
459  return CVColorPrimariesGetStringForIntegerCodePoint(pri);
460 #endif
462  return NULL;
463  }
464 }
465 
467 {
468 
469  switch (trc) {
470  case AVCOL_TRC_SMPTE2084:
471 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
472  if (__builtin_available(macOS 10.13, iOS 11, *))
473  return kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
474 #endif
475  return CFSTR("SMPTE_ST_2084_PQ");
476  case AVCOL_TRC_BT2020_10:
477  case AVCOL_TRC_BT2020_12:
478 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2020
479  if (__builtin_available(macOS 10.11, iOS 9, *))
481 #endif
482  return CFSTR("ITU_R_2020");
483  case AVCOL_TRC_BT709:
484  return kCVImageBufferTransferFunction_ITU_R_709_2;
485  case AVCOL_TRC_SMPTE240M:
486  return kCVImageBufferTransferFunction_SMPTE_240M_1995;
487  case AVCOL_TRC_SMPTE428:
488 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_428_1
489  if (__builtin_available(macOS 10.12, iOS 10, *))
490  return kCVImageBufferTransferFunction_SMPTE_ST_428_1;
491 #endif
492  return CFSTR("SMPTE_ST_428_1");
494 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
495  if (__builtin_available(macOS 10.13, iOS 11, *))
496  return kCVImageBufferTransferFunction_ITU_R_2100_HLG;
497 #endif
498  return CFSTR("ITU_R_2100_HLG");
499  case AVCOL_TRC_GAMMA22:
500  return kCVImageBufferTransferFunction_UseGamma;
501  case AVCOL_TRC_GAMMA28:
502  return kCVImageBufferTransferFunction_UseGamma;
503  default:
504 #if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
505  if (__builtin_available(macOS 10.13, iOS 11, tvOS 11, watchOS 4, *))
506  return CVTransferFunctionGetStringForIntegerCodePoint(trc);
507 #endif
509  return NULL;
510  }
511 }
512 
513 static int vt_pixbuf_set_colorspace(void *log_ctx,
514  CVPixelBufferRef pixbuf, const AVFrame *src)
515 {
516  CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL;
517  Float32 gamma = 0;
518 
519  colormatrix = av_map_videotoolbox_color_matrix_from_av(src->colorspace);
520  if (!colormatrix && src->colorspace != AVCOL_SPC_UNSPECIFIED)
521  av_log(log_ctx, AV_LOG_WARNING, "Color space %s is not supported.\n", av_color_space_name(src->colorspace));
522 
523  colorpri = av_map_videotoolbox_color_primaries_from_av(src->color_primaries);
524  if (!colorpri && src->color_primaries != AVCOL_PRI_UNSPECIFIED)
525  av_log(log_ctx, AV_LOG_WARNING, "Color primaries %s is not supported.\n", av_color_primaries_name(src->color_primaries));
526 
527  colortrc = av_map_videotoolbox_color_trc_from_av(src->color_trc);
528  if (!colortrc && src->color_trc != AVCOL_TRC_UNSPECIFIED)
529  av_log(log_ctx, AV_LOG_WARNING, "Color transfer function %s is not supported.\n", av_color_transfer_name(src->color_trc));
530 
531  if (src->color_trc == AVCOL_TRC_GAMMA22)
532  gamma = 2.2;
533  else if (src->color_trc == AVCOL_TRC_GAMMA28)
534  gamma = 2.8;
535 
536  if (colormatrix) {
537  CVBufferSetAttachment(
538  pixbuf,
539  kCVImageBufferYCbCrMatrixKey,
540  colormatrix,
541  kCVAttachmentMode_ShouldPropagate);
542  }
543  if (colorpri) {
544  CVBufferSetAttachment(
545  pixbuf,
546  kCVImageBufferColorPrimariesKey,
547  colorpri,
548  kCVAttachmentMode_ShouldPropagate);
549  }
550  if (colortrc) {
551  CVBufferSetAttachment(
552  pixbuf,
553  kCVImageBufferTransferFunctionKey,
554  colortrc,
555  kCVAttachmentMode_ShouldPropagate);
556  }
557  if (gamma != 0) {
558  CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
559  CVBufferSetAttachment(
560  pixbuf,
561  kCVImageBufferGammaLevelKey,
562  gamma_level,
563  kCVAttachmentMode_ShouldPropagate);
564  CFRelease(gamma_level);
565  }
566 
567  return 0;
568 }
569 
570 static int vt_pixbuf_set_attachments(void *log_ctx,
571  CVPixelBufferRef pixbuf, const AVFrame *src)
572 {
573  int ret;
574  ret = vt_pixbuf_set_par(log_ctx, pixbuf, src);
575  if (ret < 0)
576  return ret;
577  ret = vt_pixbuf_set_colorspace(log_ctx, pixbuf, src);
578  if (ret < 0)
579  return ret;
580  ret = vt_pixbuf_set_chromaloc(log_ctx, pixbuf, src);
581  if (ret < 0)
582  return ret;
583  return 0;
584 }
585 
587  CVPixelBufferRef pixbuf, const AVFrame *src)
588 {
589  return vt_pixbuf_set_attachments(log_ctx, pixbuf, src);
590 }
591 
593  int flags)
594 {
595  CVPixelBufferRef pixbuf = (CVPixelBufferRef)src->data[3];
596  OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
597  CVReturn err;
598  uint32_t map_flags = 0;
599  int ret;
600  int i;
601  enum AVPixelFormat format;
602 
604  if (dst->format != format) {
605  av_log(ctx, AV_LOG_ERROR, "Unsupported or mismatching pixel format: %s\n",
606  av_fourcc2str(pixel_format));
607  return AVERROR_UNKNOWN;
608  }
609 
610  if (CVPixelBufferGetWidth(pixbuf) != ctx->width ||
611  CVPixelBufferGetHeight(pixbuf) != ctx->height) {
612  av_log(ctx, AV_LOG_ERROR, "Inconsistent frame dimensions.\n");
613  return AVERROR_UNKNOWN;
614  }
615 
616  if (flags == AV_HWFRAME_MAP_READ)
617  map_flags = kCVPixelBufferLock_ReadOnly;
618 
619  err = CVPixelBufferLockBaseAddress(pixbuf, map_flags);
620  if (err != kCVReturnSuccess) {
621  av_log(ctx, AV_LOG_ERROR, "Error locking the pixel buffer.\n");
622  return AVERROR_UNKNOWN;
623  }
624 
625  if (CVPixelBufferIsPlanar(pixbuf)) {
626  int planes = CVPixelBufferGetPlaneCount(pixbuf);
627  for (i = 0; i < planes; i++) {
628  dst->data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
629  dst->linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
630  }
631  } else {
632  dst->data[0] = CVPixelBufferGetBaseAddress(pixbuf);
633  dst->linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
634  }
635 
636  ret = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, vt_unmap,
637  (void *)(uintptr_t)map_flags);
638  if (ret < 0)
639  goto unlock;
640 
641  return 0;
642 
643 unlock:
644  CVPixelBufferUnlockBaseAddress(pixbuf, map_flags);
645  return ret;
646 }
647 
649  AVFrame *dst, const AVFrame *src)
650 {
651  AVFrame *map;
652  int err;
653 
654  if (dst->width > hwfc->width || dst->height > hwfc->height)
655  return AVERROR(EINVAL);
656 
657  map = av_frame_alloc();
658  if (!map)
659  return AVERROR(ENOMEM);
660  map->format = dst->format;
661 
662  err = vt_map_frame(hwfc, map, src, AV_HWFRAME_MAP_READ);
663  if (err)
664  goto fail;
665 
666  map->width = dst->width;
667  map->height = dst->height;
668 
669  err = av_frame_copy(dst, map);
670  if (err)
671  goto fail;
672 
673  err = 0;
674 fail:
675  av_frame_free(&map);
676  return err;
677 }
678 
680  AVFrame *dst, const AVFrame *src)
681 {
682  AVFrame *map;
683  int err;
684 
685  if (src->width > hwfc->width || src->height > hwfc->height)
686  return AVERROR(EINVAL);
687 
688  map = av_frame_alloc();
689  if (!map)
690  return AVERROR(ENOMEM);
691  map->format = src->format;
692 
694  if (err)
695  goto fail;
696 
697  map->width = src->width;
698  map->height = src->height;
699 
700  err = av_frame_copy(map, src);
701  if (err)
702  goto fail;
703 
704  err = vt_pixbuf_set_attachments(hwfc, (CVPixelBufferRef)dst->data[3], src);
705  if (err)
706  goto fail;
707 
708  err = 0;
709 fail:
710  av_frame_free(&map);
711  return err;
712 }
713 
714 static int vt_map_from(AVHWFramesContext *hwfc, AVFrame *dst,
715  const AVFrame *src, int flags)
716 {
717  int err;
718 
719  if (dst->format == AV_PIX_FMT_NONE)
720  dst->format = hwfc->sw_format;
721  else if (dst->format != hwfc->sw_format)
722  return AVERROR(ENOSYS);
723 
724  err = vt_map_frame(hwfc, dst, src, flags);
725  if (err)
726  return err;
727 
728  dst->width = src->width;
729  dst->height = src->height;
730 
731  err = av_frame_copy_props(dst, src);
732  if (err)
733  return err;
734 
735  return 0;
736 }
737 
738 static int vt_device_create(AVHWDeviceContext *ctx, const char *device,
739  AVDictionary *opts, int flags)
740 {
741  if (device && device[0]) {
742  av_log(ctx, AV_LOG_ERROR, "Device selection unsupported.\n");
743  return AVERROR_UNKNOWN;
744  }
745 
746  return 0;
747 }
748 
751  .name = "videotoolbox",
752 
753  .frames_priv_size = sizeof(VTFramesContext),
754 
755  .device_create = vt_device_create,
756  .frames_init = vt_frames_init,
757  .frames_get_buffer = vt_get_buffer,
758  .frames_get_constraints = vt_frames_get_constraints,
759  .frames_uninit = vt_frames_uninit,
760  .transfer_get_formats = vt_transfer_get_formats,
761  .transfer_data_to = vt_transfer_data_to,
762  .transfer_data_from = vt_transfer_data_from,
763  .map_from = vt_map_from,
764 
766 };
formats
formats
Definition: signature.h:48
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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.
Definition: hwcontext_videotoolbox.c:466
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
space
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated space
Definition: undefined.txt:4
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:494
HWMapDescriptor::source
AVFrame * source
A reference to the original source of the mapping.
Definition: hwcontext_internal.h:136
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.
Definition: hwcontext_videotoolbox.c:414
vt_transfer_data_from
static int vt_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:648
AVCHROMA_LOC_BOTTOM
@ AVCHROMA_LOC_BOTTOM
Definition: pixfmt.h:623
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pix_fmt
enum AVPixelFormat pix_fmt
Definition: hwcontext_videotoolbox.c:43
buffer_internal.h
pixdesc.h
AVFrame::width
int width
Definition: frame.h:389
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:497
av_vt_pixbuf_set_attachments
int av_vt_pixbuf_set_attachments(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:586
data
const char data[16]
Definition: mxf.c:143
AV_HWFRAME_MAP_WRITE
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
Definition: hwcontext.h:528
AV_HWFRAME_MAP_OVERWRITE
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
Definition: hwcontext.h:534
vt_dummy_pool_alloc
static AVBufferRef * vt_dummy_pool_alloc(void *opaque, size_t size)
Definition: hwcontext_videotoolbox.c:213
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:510
vt_frames_init
static int vt_frames_init(AVHWFramesContext *ctx)
Definition: hwcontext_videotoolbox.c:227
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
AVDictionary
Definition: dict.c:30
ff_hwframe_map_create
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
Definition: hwcontext.c:737
AV_HWDEVICE_TYPE_VIDEOTOOLBOX
@ AV_HWDEVICE_TYPE_VIDEOTOOLBOX
Definition: hwcontext.h:34
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:469
vt_map_frame
static int vt_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_videotoolbox.c:592
HWMapDescriptor::priv
void * priv
Hardware-specific private data associated with the mapping.
Definition: hwcontext_internal.h:151
AVHWFramesConstraints::valid_hw_formats
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition: hwcontext.h:458
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:229
VTFramesContext::pool
CVPixelBufferPoolRef pool
Definition: hwcontext_videotoolbox.c:37
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:535
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
ff_hwcontext_type_videotoolbox
const HWContextType ff_hwcontext_type_videotoolbox
Definition: hwcontext_videotoolbox.c:749
AVHWFramesConstraints
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition: hwcontext.h:453
vt_pixbuf_set_attachments
static int vt_pixbuf_set_attachments(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:570
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:529
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3048
fail
#define fail()
Definition: checkasm.h:128
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:500
av_buffer_pool_init2
AVBufferPool * av_buffer_pool_init2(size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
Definition: buffer.c:259
kCVImageBufferYCbCrMatrix_ITU_R_2020
CFStringRef kCVImageBufferYCbCrMatrix_ITU_R_2020
Definition: videotoolboxenc.c:69
vt_device_create
static int vt_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_videotoolbox.c:738
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
AVRational::num
int num
Numerator.
Definition: rational.h:59
vt_frames_uninit
static void vt_frames_uninit(AVHWFramesContext *ctx)
Definition: hwcontext_videotoolbox.c:218
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:499
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
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.
Definition: hwcontext_videotoolbox.c:441
HWContextType::type
enum AVHWDeviceType type
Definition: hwcontext_internal.h:30
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVHWFramesContext::height
int height
Definition: hwcontext.h:229
AVHWFramesConstraints::valid_sw_formats
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition: hwcontext.h:465
vt_pixbuf_set_chromaloc
static int vt_pixbuf_set_chromaloc(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:398
av_buffer_pool_get
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:387
full_range
bool full_range
Definition: hwcontext_videotoolbox.c:42
AVCHROMA_LOC_TOP
@ AVCHROMA_LOC_TOP
Definition: pixfmt.h:621
supported_formats
static enum AVPixelFormat supported_formats[]
Definition: hwcontext_videotoolbox.c:81
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:530
vt_transfer_get_formats
static int vt_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_videotoolbox.c:299
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:472
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:476
vt_pixbuf_set_colorspace
static int vt_pixbuf_set_colorspace(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:513
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:477
opts
AVDictionary * opts
Definition: movenc.c:50
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:222
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
vt_map_from
static int vt_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_videotoolbox.c:714
cv_fmt
uint32_t cv_fmt
Definition: hwcontext_videotoolbox.c:41
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.
Definition: hwcontext_videotoolbox.c:147
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:618
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:620
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:471
AV_PIX_FMT_P410
#define AV_PIX_FMT_P410
Definition: pixfmt.h:461
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3006
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:509
planes
static const struct @323 planes[]
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:480
AV_HWFRAME_MAP_READ
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
Definition: hwcontext.h:524
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:511
hwcontext_videotoolbox.h
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:502
vt_pixbuf_set_par
static int vt_pixbuf_set_par(void *log_ctx, CVPixelBufferRef pixbuf, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:321
kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
@ kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
Definition: videotoolboxenc.c:51
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:678
kCVImageBufferTransferFunction_ITU_R_2020
CFStringRef kCVImageBufferTransferFunction_ITU_R_2020
Definition: videotoolboxenc.c:68
size
int size
Definition: twinvq_data.h:10344
format
ofilter format
Definition: ffmpeg_filter.c:172
AV_PIX_FMT_AYUV64
#define AV_PIX_FMT_AYUV64
Definition: pixfmt.h:452
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:404
AV_PIX_FMT_NV16
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:191
buffer.h
vt_frames_get_constraints
static int vt_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_videotoolbox.c:112
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AV_PIX_FMT_P216
#define AV_PIX_FMT_P216
Definition: pixfmt.h:462
AV_PIX_FMT_P210
#define AV_PIX_FMT_P210
Definition: pixfmt.h:460
vt_unmap
static void vt_unmap(AVHWFramesContext *ctx, HWMapDescriptor *hwmap)
Definition: hwcontext_videotoolbox.c:314
vt_transfer_data_to
static int vt_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_videotoolbox.c:679
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:496
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:616
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:531
AV_PIX_FMT_VIDEOTOOLBOX
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
Definition: pixfmt.h:272
cv_pix_fmts
static const struct @310 cv_pix_fmts[]
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:534
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:523
AV_PIX_FMT_NV24
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:338
common.h
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:526
AVHWFrameTransferDirection
AVHWFrameTransferDirection
Definition: hwcontext.h:415
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
vt_get_buffer
static int vt_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_videotoolbox.c:260
videotoolbox_buffer_release
static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
Definition: hwcontext_videotoolbox.c:255
ret
ret
Definition: filter_design.txt:187
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:365
pixfmt.h
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
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.
Definition: hwcontext_videotoolbox.c:137
kCVPixelFormatType_420YpCbCr10BiPlanarFullRange
@ kCVPixelFormatType_420YpCbCr10BiPlanarFullRange
Definition: videotoolboxenc.c:50
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
AVFrame::height
int height
Definition: frame.h:389
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:515
kCVImageBufferColorPrimaries_ITU_R_2020
CFStringRef kCVImageBufferColorPrimaries_ITU_R_2020
Definition: videotoolboxenc.c:67
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:619
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:453
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.
Definition: hwcontext_videotoolbox.c:378
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
hwcontext_internal.h
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
AV_PIX_FMT_P416
#define AV_PIX_FMT_P416
Definition: pixfmt.h:463
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
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 form...
Definition: hwcontext_videotoolbox.c:152
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
hwcontext.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
HWContextType
Definition: hwcontext_internal.h:29
AVCOL_TRC_SMPTE428
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
Definition: pixfmt.h:513
h
h
Definition: vp9dsp_template.c:2038
VTFramesContext
Definition: hwcontext_videotoolbox.c:36
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:525
HWMapDescriptor
Definition: hwcontext_internal.h:132
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3027
AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_BOTTOMLEFT
Definition: pixfmt.h:622
vt_pool_alloc
static int vt_pool_alloc(AVHWFramesContext *ctx)
Definition: hwcontext_videotoolbox.c:162
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2580
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:348