FFmpeg
Loading...
Searching...
No Matches
hwcontext_cuda.h
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
20#ifndef AVUTIL_HWCONTEXT_CUDA_H
21#define AVUTIL_HWCONTEXT_CUDA_H
22
23#ifndef CUDA_VERSION
24#include <cuda.h>
25#endif
26
27#include <stdint.h>
28
29#include "pixfmt.h"
30
31/**
32 * @file
33 * An API-specific header for AV_HWDEVICE_TYPE_CUDA.
34 *
35 * This API supports dynamic frame pools. AVHWFramesContext.pool must return
36 * AVBufferRefs whose data pointer is a CUdeviceptr.
37 */
38
40
41/**
42 * This struct is allocated as AVHWDeviceContext.hwctx
43 */
49
50/**
51 * CUDA frame descriptor for pool allocation of AV_PIX_FMT_CUARRAY frames.
52 *
53 * In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs
54 * with the data pointer pointing at an object of this type describing the
55 * planes of the frame.
56 *
57 * This has no use outside of custom allocation, and AVFrame AVBufferRef do not
58 * necessarily point to an instance of this struct.
59 */
61 /**
62 * The CUarray containing the frame data.
63 *
64 * Normally stored in AVFrame.data[0].
65 */
66 CUarray array;
67
68 /**
69 * The index into AVCUDAFramesContext.cuarray_surfaces, or 0 if not applicable.
70 *
71 * Normally stored in AVFrame.data[1] (cast from intptr_t).
72 */
73 intptr_t index;
75
76/**
77 * This struct is allocated as AVHWFramesContext.hwctx
78 */
79typedef struct AVCUDAFramesContext {
80 /**
81 * CUDA_ARRAY3D_DESCRIPTOR CUarrays will be initialized with.
82 * Mostly used to provide external Flags.
83 *
84 * Width, Height and Format only honored if != 0.
85 * Filled with default parameters from the FramesContext otherwise.
86 *
87 * Only applicable for AV_PIX_FMT_CUARRAY.
88 */
89 CUDA_ARRAY3D_DESCRIPTOR cuarray_desc;
90
91 /**
92 * If >0, pre-allocate a fixed pool of surfaces.
93 * The surfaces will be available via cuarray_surfaces after init.
94 * Size of the pool cannot be changed afterwards.
95 *
96 * Only applicable for AV_PIX_FMT_CUARRAY.
97 */
99
100 /**
101 * If cuarray_num_surfaces is >0, this contains the array of pre-allocated surfaces.
102 *
103 * Only applicable for AV_PIX_FMT_CUARRAY.
104 */
107
108/**
109 * CUDA hardware pipeline configuration details.
110 *
111 * Passed to av_hwdevice_get_hwframe_constraints() to query
112 * per-hw-format constraints. When provided, valid_sw_formats
113 * will be filtered to only those compatible with the specified
114 * hw_format.
115 */
116typedef struct AVCUDAHWConfig {
117 /**
118 * The hardware pixel format to query constraints for.
119 * Must be AV_PIX_FMT_CUDA or AV_PIX_FMT_CUARRAY.
120 */
123
124/**
125 * @defgroup hwcontext_cuda Device context creation flags
126 *
127 * Flags for av_hwdevice_ctx_create.
128 *
129 * @{
130 */
131
132/**
133 * Use primary device context instead of creating a new one.
134 */
135#define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0)
136
137/**
138 * Use current device context instead of creating a new one.
139 */
140#define AV_CUDA_USE_CURRENT_CONTEXT (1 << 1)
141
142/**
143 * @}
144 */
145
146#endif /* AVUTIL_HWCONTEXT_CUDA_H */
pixel format definitions
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
CUDA frame descriptor for pool allocation of AV_PIX_FMT_CUARRAY frames.
intptr_t index
The index into AVCUDAFramesContext.cuarray_surfaces, or 0 if not applicable.
CUarray array
The CUarray containing the frame data.
This struct is allocated as AVHWDeviceContext.hwctx.
AVCUDADeviceContextInternal * internal
This struct is allocated as AVHWFramesContext.hwctx.
CUarray * cuarray_surfaces
If cuarray_num_surfaces is >0, this contains the array of pre-allocated surfaces.
CUDA_ARRAY3D_DESCRIPTOR cuarray_desc
CUDA_ARRAY3D_DESCRIPTOR CUarrays will be initialized with.
int cuarray_num_surfaces
If >0, pre-allocate a fixed pool of surfaces.
CUDA hardware pipeline configuration details.
enum AVPixelFormat hw_format
The hardware pixel format to query constraints for.