FFmpeg  4.4.4
hwcontext_cuda.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 "buffer.h"
20 #include "common.h"
21 #include "hwcontext.h"
22 #include "hwcontext_internal.h"
24 #if CONFIG_VULKAN
25 #include "hwcontext_vulkan.h"
26 #endif
27 #include "cuda_check.h"
28 #include "mem.h"
29 #include "pixdesc.h"
30 #include "pixfmt.h"
31 #include "imgutils.h"
32 
33 typedef struct CUDAFramesContext {
37 
38 static const enum AVPixelFormat supported_formats[] = {
48 #if CONFIG_VULKAN
50 #endif
51 };
52 
53 #define CHECK_CU(x) FF_CUDA_CHECK_DL(device_ctx, cu, x)
54 
56  const void *hwconfig,
57  AVHWFramesConstraints *constraints)
58 {
59  int i;
60 
62  sizeof(*constraints->valid_sw_formats));
63  if (!constraints->valid_sw_formats)
64  return AVERROR(ENOMEM);
65 
66  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
67  constraints->valid_sw_formats[i] = supported_formats[i];
69 
70  constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats));
71  if (!constraints->valid_hw_formats)
72  return AVERROR(ENOMEM);
73 
74  constraints->valid_hw_formats[0] = AV_PIX_FMT_CUDA;
75  constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
76 
77  return 0;
78 }
79 
80 static void cuda_buffer_free(void *opaque, uint8_t *data)
81 {
82  AVHWFramesContext *ctx = opaque;
83  AVHWDeviceContext *device_ctx = ctx->device_ctx;
84  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
85  CudaFunctions *cu = hwctx->internal->cuda_dl;
86 
87  CUcontext dummy;
88 
89  CHECK_CU(cu->cuCtxPushCurrent(hwctx->cuda_ctx));
90 
91  CHECK_CU(cu->cuMemFree((CUdeviceptr)data));
92 
93  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
94 }
95 
97 {
98  AVHWFramesContext *ctx = opaque;
99  AVHWDeviceContext *device_ctx = ctx->device_ctx;
100  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
101  CudaFunctions *cu = hwctx->internal->cuda_dl;
102 
103  AVBufferRef *ret = NULL;
104  CUcontext dummy = NULL;
105  CUdeviceptr data;
106  int err;
107 
108  err = CHECK_CU(cu->cuCtxPushCurrent(hwctx->cuda_ctx));
109  if (err < 0)
110  return NULL;
111 
112  err = CHECK_CU(cu->cuMemAlloc(&data, size));
113  if (err < 0)
114  goto fail;
115 
117  if (!ret) {
118  CHECK_CU(cu->cuMemFree(data));
119  goto fail;
120  }
121 
122 fail:
123  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
124  return ret;
125 }
126 
128 {
129  AVHWDeviceContext *device_ctx = ctx->device_ctx;
130  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
131  CUDAFramesContext *priv = ctx->internal->priv;
132  CudaFunctions *cu = hwctx->internal->cuda_dl;
133  int err, i;
134 
135  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) {
136  if (ctx->sw_format == supported_formats[i])
137  break;
138  }
140  av_log(ctx, AV_LOG_ERROR, "Pixel format '%s' is not supported\n",
141  av_get_pix_fmt_name(ctx->sw_format));
142  return AVERROR(ENOSYS);
143  }
144 
145  err = CHECK_CU(cu->cuDeviceGetAttribute(&priv->tex_alignment,
146  14 /* CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT */,
147  hwctx->internal->cuda_device));
148  if (err < 0)
149  return err;
150 
151  av_log(ctx, AV_LOG_DEBUG, "CUDA texture alignment: %d\n", priv->tex_alignment);
152 
153  // YUV420P is a special case.
154  // Since nvenc expects the U/V planes to have half the linesize of the Y plane
155  // alignment has to be doubled to ensure the U/V planes still end up aligned.
156  if (ctx->sw_format == AV_PIX_FMT_YUV420P)
157  priv->tex_alignment *= 2;
158 
159  av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, &priv->shift_height);
160 
161  if (!ctx->pool) {
162  int size = av_image_get_buffer_size(ctx->sw_format, ctx->width, ctx->height, priv->tex_alignment);
163  if (size < 0)
164  return size;
165 
167  if (!ctx->internal->pool_internal)
168  return AVERROR(ENOMEM);
169  }
170 
171  return 0;
172 }
173 
175 {
176  CUDAFramesContext *priv = ctx->internal->priv;
177  int res;
178 
179  frame->buf[0] = av_buffer_pool_get(ctx->pool);
180  if (!frame->buf[0])
181  return AVERROR(ENOMEM);
182 
184  ctx->sw_format, ctx->width, ctx->height, priv->tex_alignment);
185  if (res < 0)
186  return res;
187 
188  // YUV420P is a special case.
189  // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
190  if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
191  frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
192  frame->data[2] = frame->data[1];
193  frame->data[1] = frame->data[2] + frame->linesize[2] * (ctx->height / 2);
194  }
195 
197  frame->width = ctx->width;
198  frame->height = ctx->height;
199 
200  return 0;
201 }
202 
205  enum AVPixelFormat **formats)
206 {
207  enum AVPixelFormat *fmts;
208 
209  fmts = av_malloc_array(2, sizeof(*fmts));
210  if (!fmts)
211  return AVERROR(ENOMEM);
212 
213  fmts[0] = ctx->sw_format;
214  fmts[1] = AV_PIX_FMT_NONE;
215 
216  *formats = fmts;
217 
218  return 0;
219 }
220 
222  const AVFrame *src)
223 {
224  CUDAFramesContext *priv = ctx->internal->priv;
225  AVHWDeviceContext *device_ctx = ctx->device_ctx;
226  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
227  CudaFunctions *cu = hwctx->internal->cuda_dl;
228 
229  CUcontext dummy;
230  int i, ret;
231 
232  if ((src->hw_frames_ctx && ((AVHWFramesContext*)src->hw_frames_ctx->data)->format != AV_PIX_FMT_CUDA) ||
233  (dst->hw_frames_ctx && ((AVHWFramesContext*)dst->hw_frames_ctx->data)->format != AV_PIX_FMT_CUDA))
234  return AVERROR(ENOSYS);
235 
236  ret = CHECK_CU(cu->cuCtxPushCurrent(hwctx->cuda_ctx));
237  if (ret < 0)
238  return ret;
239 
240  for (i = 0; i < FF_ARRAY_ELEMS(src->data) && src->data[i]; i++) {
241  CUDA_MEMCPY2D cpy = {
242  .srcPitch = src->linesize[i],
243  .dstPitch = dst->linesize[i],
244  .WidthInBytes = FFMIN(src->linesize[i], dst->linesize[i]),
245  .Height = src->height >> ((i == 0 || i == 3) ? 0 : priv->shift_height),
246  };
247 
248  if (src->hw_frames_ctx) {
249  cpy.srcMemoryType = CU_MEMORYTYPE_DEVICE;
250  cpy.srcDevice = (CUdeviceptr)src->data[i];
251  } else {
252  cpy.srcMemoryType = CU_MEMORYTYPE_HOST;
253  cpy.srcHost = src->data[i];
254  }
255 
256  if (dst->hw_frames_ctx) {
257  cpy.dstMemoryType = CU_MEMORYTYPE_DEVICE;
258  cpy.dstDevice = (CUdeviceptr)dst->data[i];
259  } else {
260  cpy.dstMemoryType = CU_MEMORYTYPE_HOST;
261  cpy.dstHost = dst->data[i];
262  }
263 
264  ret = CHECK_CU(cu->cuMemcpy2DAsync(&cpy, hwctx->stream));
265  if (ret < 0)
266  goto exit;
267  }
268 
269  if (!dst->hw_frames_ctx) {
270  ret = CHECK_CU(cu->cuStreamSynchronize(hwctx->stream));
271  if (ret < 0)
272  goto exit;
273  }
274 
275 exit:
276  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
277 
278  return 0;
279 }
280 
281 static void cuda_device_uninit(AVHWDeviceContext *device_ctx)
282 {
283  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
284 
285  if (hwctx->internal) {
286  CudaFunctions *cu = hwctx->internal->cuda_dl;
287 
288  if (hwctx->internal->is_allocated && hwctx->cuda_ctx) {
290  CHECK_CU(cu->cuDevicePrimaryCtxRelease(hwctx->internal->cuda_device));
291  else
292  CHECK_CU(cu->cuCtxDestroy(hwctx->cuda_ctx));
293 
294  hwctx->cuda_ctx = NULL;
295  }
296 
297  cuda_free_functions(&hwctx->internal->cuda_dl);
298  }
299 
300  av_freep(&hwctx->internal);
301 }
302 
304 {
305  AVCUDADeviceContext *hwctx = ctx->hwctx;
306  int ret;
307 
308  if (!hwctx->internal) {
309  hwctx->internal = av_mallocz(sizeof(*hwctx->internal));
310  if (!hwctx->internal)
311  return AVERROR(ENOMEM);
312  }
313 
314  if (!hwctx->internal->cuda_dl) {
315  ret = cuda_load_functions(&hwctx->internal->cuda_dl, ctx);
316  if (ret < 0) {
317  av_log(ctx, AV_LOG_ERROR, "Could not dynamically load CUDA\n");
318  goto error;
319  }
320  }
321 
322  return 0;
323 
324 error:
326  return ret;
327 }
328 
329 static int cuda_context_init(AVHWDeviceContext *device_ctx, int flags) {
330  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
331  CudaFunctions *cu;
332  CUcontext dummy;
333  int ret, dev_active = 0;
334  unsigned int dev_flags = 0;
335 
336  const unsigned int desired_flags = CU_CTX_SCHED_BLOCKING_SYNC;
337 
338  cu = hwctx->internal->cuda_dl;
339 
340  hwctx->internal->flags = flags;
341 
343  ret = CHECK_CU(cu->cuDevicePrimaryCtxGetState(hwctx->internal->cuda_device,
344  &dev_flags, &dev_active));
345  if (ret < 0)
346  return ret;
347 
348  if (dev_active && dev_flags != desired_flags) {
349  av_log(device_ctx, AV_LOG_ERROR, "Primary context already active with incompatible flags.\n");
350  return AVERROR(ENOTSUP);
351  } else if (dev_flags != desired_flags) {
352  ret = CHECK_CU(cu->cuDevicePrimaryCtxSetFlags(hwctx->internal->cuda_device,
353  desired_flags));
354  if (ret < 0)
355  return ret;
356  }
357 
358  ret = CHECK_CU(cu->cuDevicePrimaryCtxRetain(&hwctx->cuda_ctx,
359  hwctx->internal->cuda_device));
360  if (ret < 0)
361  return ret;
362  } else {
363  ret = CHECK_CU(cu->cuCtxCreate(&hwctx->cuda_ctx, desired_flags,
364  hwctx->internal->cuda_device));
365  if (ret < 0)
366  return ret;
367 
368  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
369  }
370 
371  hwctx->internal->is_allocated = 1;
372 
373  // Setting stream to NULL will make functions automatically use the default CUstream
374  hwctx->stream = NULL;
375 
376  return 0;
377 }
378 
379 static int cuda_device_create(AVHWDeviceContext *device_ctx,
380  const char *device,
381  AVDictionary *opts, int flags)
382 {
383  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
384  CudaFunctions *cu;
385  int ret, device_idx = 0;
386 
387  if (device)
388  device_idx = strtol(device, NULL, 0);
389 
390  if (cuda_device_init(device_ctx) < 0)
391  goto error;
392 
393  cu = hwctx->internal->cuda_dl;
394 
395  ret = CHECK_CU(cu->cuInit(0));
396  if (ret < 0)
397  goto error;
398 
399  ret = CHECK_CU(cu->cuDeviceGet(&hwctx->internal->cuda_device, device_idx));
400  if (ret < 0)
401  goto error;
402 
403  ret = cuda_context_init(device_ctx, flags);
404  if (ret < 0)
405  goto error;
406 
407  return 0;
408 
409 error:
410  cuda_device_uninit(device_ctx);
411  return AVERROR_UNKNOWN;
412 }
413 
414 static int cuda_device_derive(AVHWDeviceContext *device_ctx,
416  int flags) {
417  AVCUDADeviceContext *hwctx = device_ctx->hwctx;
418  CudaFunctions *cu;
419  const char *src_uuid = NULL;
420  int ret, i, device_count;
421 
422 #if CONFIG_VULKAN
423  VkPhysicalDeviceIDProperties vk_idp = {
424  .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES,
425  };
426 #endif
427 
428  switch (src_ctx->type) {
429 #if CONFIG_VULKAN
431  AVVulkanDeviceContext *vkctx = src_ctx->hwctx;
432  VkPhysicalDeviceProperties2 vk_dev_props = {
433  .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
434  .pNext = &vk_idp,
435  };
436  vkGetPhysicalDeviceProperties2(vkctx->phys_dev, &vk_dev_props);
437  src_uuid = vk_idp.deviceUUID;
438  break;
439  }
440 #endif
441  default:
442  return AVERROR(ENOSYS);
443  }
444 
445  if (!src_uuid) {
446  av_log(device_ctx, AV_LOG_ERROR,
447  "Failed to get UUID of source device.\n");
448  goto error;
449  }
450 
451  if (cuda_device_init(device_ctx) < 0)
452  goto error;
453 
454  cu = hwctx->internal->cuda_dl;
455 
456  ret = CHECK_CU(cu->cuInit(0));
457  if (ret < 0)
458  goto error;
459 
460  ret = CHECK_CU(cu->cuDeviceGetCount(&device_count));
461  if (ret < 0)
462  goto error;
463 
464  hwctx->internal->cuda_device = -1;
465  for (i = 0; i < device_count; i++) {
466  CUdevice dev;
467  CUuuid uuid;
468 
469  ret = CHECK_CU(cu->cuDeviceGet(&dev, i));
470  if (ret < 0)
471  goto error;
472 
473  ret = CHECK_CU(cu->cuDeviceGetUuid(&uuid, dev));
474  if (ret < 0)
475  goto error;
476 
477  if (memcmp(src_uuid, uuid.bytes, sizeof (uuid.bytes)) == 0) {
478  hwctx->internal->cuda_device = dev;
479  break;
480  }
481  }
482 
483  if (hwctx->internal->cuda_device == -1) {
484  av_log(device_ctx, AV_LOG_ERROR, "Could not derive CUDA device.\n");
485  goto error;
486  }
487 
488  ret = cuda_context_init(device_ctx, flags);
489  if (ret < 0)
490  goto error;
491 
492  return 0;
493 
494 error:
495  cuda_device_uninit(device_ctx);
496  return AVERROR_UNKNOWN;
497 }
498 
501  .name = "CUDA",
502 
503  .device_hwctx_size = sizeof(AVCUDADeviceContext),
504  .frames_priv_size = sizeof(CUDAFramesContext),
505 
506  .device_create = cuda_device_create,
507  .device_derive = cuda_device_derive,
508  .device_init = cuda_device_init,
509  .device_uninit = cuda_device_uninit,
510  .frames_get_constraints = cuda_frames_get_constraints,
511  .frames_init = cuda_frames_init,
512  .frames_get_buffer = cuda_get_buffer,
513  .transfer_get_formats = cuda_transfer_get_formats,
514  .transfer_data_to = cuda_transfer_data,
515  .transfer_data_from = cuda_transfer_data,
516 
517  .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE },
518 };
uint8_t
refcounted data buffer API
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define fail()
Definition: checkasm.h:133
common internal and external API header
#define FFMIN(a, b)
Definition: common.h:105
#define NULL
Definition: coverity.c:32
static AVFrame * frame
#define AV_CUDA_USE_PRIMARY_CONTEXT
Use primary device context instead of creating a new one.
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:29
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:373
AVBufferPool * av_buffer_pool_init2(buffer_size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, buffer_size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
Definition: buffer.c:245
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters.
Definition: imgutils.c:466
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array.
Definition: imgutils.c:446
AVHWFrameTransferDirection
Definition: hwcontext.h:415
@ AV_HWDEVICE_TYPE_VULKAN
Definition: hwcontext.h:39
@ AV_HWDEVICE_TYPE_CUDA
Definition: hwcontext.h:30
static enum AVPixelFormat supported_formats[]
static void cuda_device_uninit(AVHWDeviceContext *device_ctx)
static int cuda_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static int cuda_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static void cuda_buffer_free(void *opaque, uint8_t *data)
static AVBufferRef * cuda_pool_alloc(void *opaque, buffer_size_t size)
static int cuda_device_init(AVHWDeviceContext *ctx)
static int cuda_frames_init(AVHWFramesContext *ctx)
static int cuda_context_init(AVHWDeviceContext *device_ctx, int flags)
const HWContextType ff_hwcontext_type_cuda
#define CHECK_CU(x)
static int cuda_device_create(AVHWDeviceContext *device_ctx, const char *device, AVDictionary *opts, int flags)
static int cuda_device_derive(AVHWDeviceContext *device_ctx, AVHWDeviceContext *src_ctx, AVDictionary *opts, int flags)
static int cuda_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
FFmpeg internal API for CUDA.
API-specific header for AV_HWDEVICE_TYPE_VULKAN.
misc image utilities
int i
Definition: input.c:407
int buffer_size_t
Definition: internal.h:306
Memory handling functions.
int dummy
Definition: motion.c:64
const char data[16]
Definition: mxf.c:142
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
Definition: pixdesc.c:2601
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:2489
pixel format definitions
#define AV_PIX_FMT_0RGB32
Definition: pixfmt.h:376
#define AV_PIX_FMT_P010
Definition: pixfmt.h:448
#define AV_PIX_FMT_P016
Definition: pixfmt.h:449
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ 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
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:356
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:235
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_0BGR32
Definition: pixfmt.h:377
formats
Definition: signature.h:48
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Definition: buffer.h:84
uint8_t * data
The data buffer.
Definition: buffer.h:92
This struct is allocated as AVHWDeviceContext.hwctx.
AVCUDADeviceContextInternal * internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int width
Definition: frame.h:376
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
Definition: frame.h:657
int height
Definition: frame.h:376
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:509
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:391
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:79
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition: hwcontext.h:453
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
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
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
VkPhysicalDevice phys_dev
Physical device.
enum AVHWDeviceType type
#define av_malloc_array(a, b)
#define av_freep(p)
#define av_log(a,...)
static void error(const char *err)
#define src
Definition: vp8dsp.c:255
AVFormatContext * ctx
Definition: movenc.c:48
AVDictionary * opts
Definition: movenc.c:50
int size