FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvenc.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 #ifndef AVCODEC_NVENC_H
20 #define AVCODEC_NVENC_H
21 
23 
24 #include "config.h"
25 
26 #include "libavutil/fifo.h"
27 #include "libavutil/opt.h"
28 
29 #include "avcodec.h"
30 
31 #if CONFIG_CUDA
33 #else
34 
35 #if defined(_WIN32)
36 #define CUDAAPI __stdcall
37 #else
38 #define CUDAAPI
39 #endif
40 
41 typedef enum cudaError_enum {
43 } CUresult;
44 typedef int CUdevice;
45 typedef void* CUcontext;
46 typedef void* CUdeviceptr;
47 #endif
48 
49 #define MAX_REGISTERED_FRAMES 64
50 
51 typedef struct NvencSurface
52 {
56  int reg_idx;
57  int width;
58  int height;
59  int pitch;
60 
63  int size;
64  int lockCount;
65 } NvencSurface;
66 
67 typedef CUresult(CUDAAPI *PCUINIT)(unsigned int Flags);
69 typedef CUresult(CUDAAPI *PCUDEVICEGET)(CUdevice *device, int ordinal);
70 typedef CUresult(CUDAAPI *PCUDEVICEGETNAME)(char *name, int len, CUdevice dev);
71 typedef CUresult(CUDAAPI *PCUDEVICECOMPUTECAPABILITY)(int *major, int *minor, CUdevice dev);
72 typedef CUresult(CUDAAPI *PCUCTXCREATE)(CUcontext *pctx, unsigned int flags, CUdevice dev);
75 
78 
79 typedef struct NvencDynLoadFunctions
80 {
81 #if !CONFIG_CUDA
82  void *cuda;
83 #endif
84  void *nvenc;
85 
94 
98 
99 enum {
110  PRESET_LOSSLESS_DEFAULT, // lossless presets must be the last ones
112 };
113 
114 enum {
119 };
120 
121 enum {
125 };
126 
127 enum {
132 };
133 
134 enum {
137 };
138 
139 typedef struct NvencContext
140 {
142 
144 
149 
152 
156 
157  struct {
160  int mapped;
163 
164  /* the actual data pixel format, different from
165  * AVCodecContext.pix_fmt when using hwaccel frames on input */
167 
168  /* timestamps of the first two frames, for computing the first dts
169  * when B-frames are present */
170  int64_t initial_pts[2];
172 
173  void *nvencoder;
174 
175  int preset;
176  int profile;
177  int level;
178  int tier;
179  int rc;
180  int cbr;
181  int twopass;
182  int device;
183  int flags;
186  int aq;
189  int b_adapt;
192  int nonref_p;
195  int quality;
196 } NvencContext;
197 
199 
201 
203  const AVFrame *frame, int *got_packet);
204 
205 extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
206 
207 #endif /* AVCODEC_NVENC_H */
int no_scenecut
Definition: nvenc.h:187
AVClass * avclass
Definition: nvenc.h:141
void * nvencoder
Definition: nvenc.h:173
enum AVPixelFormat ff_nvenc_pix_fmts[]
Definition: nvenc.c:78
int twopass
Definition: nvenc.h:181
NV_ENC_BUFFER_FORMAT format
Definition: nvenc.h:62
int ff_nvenc_encode_init(AVCodecContext *avctx)
Definition: nvenc.c:1301
int height
Definition: nvenc.h:58
struct NvencContext::@101 registered_frames[MAX_REGISTERED_FRAMES]
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
AVFifoBuffer * timestamp_list
Definition: nvenc.h:155
int mapped
Definition: nvenc.h:160
AVFrame * in_ref
Definition: nvenc.h:54
NV_ENC_MAP_INPUT_RESOURCE in_map
Definition: nvenc.h:55
NvEncodeAPI provides a NVENC Video Encoding interface to NVIDIA GPU devices based on the Kepler archi...
int forced_idr
Definition: nvenc.h:188
int CUdevice
Definition: nvenc.h:44
PCUCTXDESTROY cu_ctx_destroy
Definition: nvenc.h:93
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs
Definition: nvenc.h:95
NvencDynLoadFunctions nvenc_dload_funcs
Definition: nvenc.h:143
int first_packet_output
Definition: nvenc.h:171
NV_ENCODE_API_FUNCTION_LIST.
Definition: nvEncodeAPI.h:3149
PCUDEVICEGETNAME cu_device_get_name
Definition: nvenc.h:89
int version
Definition: avisynth_c.h:766
static AVPacket pkt
int preset
Definition: nvenc.h:175
int pitch
Definition: nvenc.h:59
int nvenc_device_count
Definition: nvenc.h:96
NV_ENC_INPUT_PTR input_surface
Definition: nvenc.h:53
int aq
Definition: nvenc.h:186
void * NV_ENC_INPUT_PTR
NVENCODE API input buffer.
Definition: nvEncodeAPI.h:110
CUcontext cu_context
Definition: nvenc.h:147
AVOptions.
PCUDEVICEGETCOUNT cu_device_get_count
Definition: nvenc.h:87
PCUDEVICECOMPUTECAPABILITY cu_device_compute_capability
Definition: nvenc.h:90
CUresult(CUDAAPI * PCUCTXCREATE)(CUcontext *pctx, unsigned int flags, CUdevice dev)
Definition: nvenc.h:72
int ff_nvenc_encode_close(AVCodecContext *avctx)
Definition: nvenc.c:1224
CUresult(CUDAAPI * PCUDEVICECOMPUTECAPABILITY)(int *major, int *minor, CUdevice dev)
Definition: nvenc.h:71
NV_ENC_INITIALIZE_PARAMS init_encode_params
Definition: nvenc.h:145
static AVFrame * frame
#define MAX_REGISTERED_FRAMES
Definition: nvenc.h:49
NV_ENC_BUFFER_FORMAT
Input buffer formats.
Definition: nvEncodeAPI.h:306
#define CUDAAPI
Definition: nvenc.h:38
AVFifoBuffer * output_surface_ready_queue
Definition: nvenc.h:154
CUdeviceptr ptr
Definition: nvenc.h:158
CUcontext cu_context_internal
Definition: nvenc.h:148
An API-specific header for AV_HWDEVICE_TYPE_CUDA.
int async_depth
Definition: nvenc.h:184
void * NV_ENC_REGISTERED_PTR
A Resource that has been registered with NVENCODE API.
Definition: nvEncodeAPI.h:112
int rc
Definition: nvenc.h:179
NVENCSTATUS(NVENCAPI * PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTION_LIST *functionList)
Definition: nvenc.h:77
int nb_registered_frames
Definition: nvenc.h:162
PCUDEVICEGET cu_device_get
Definition: nvenc.h:88
GLsizei count
Definition: opengl_enc.c:109
CUresult(CUDAAPI * PCUDEVICEGET)(CUdevice *device, int ordinal)
Definition: nvenc.h:69
int level
Definition: nvenc.h:177
int quality
Definition: nvenc.h:195
int aq_strength
Definition: nvenc.h:194
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: nvenc.c:1703
PCUINIT cu_init
Definition: nvenc.h:86
int flags
Definition: nvenc.h:183
NV_ENC_REGISTERED_PTR regptr
Definition: nvenc.h:159
int lockCount
Definition: nvenc.h:64
CUresult(CUDAAPI * PCUDEVICEGETCOUNT)(int *count)
Definition: nvenc.h:68
AVFormatContext * ctx
Definition: movenc.c:48
CUresult
Definition: nvenc.h:41
int profile
Definition: nvenc.h:176
AVFifoBuffer * output_surface_queue
Definition: nvenc.h:153
enum AVPixelFormat data_pix_fmt
Definition: nvenc.h:166
PCUCTXCREATE cu_ctx_create
Definition: nvenc.h:91
NV_ENC_CONFIG encode_config
Definition: nvenc.h:146
Libavcodec external API header.
int strict_gop
Definition: nvenc.h:193
int temporal_aq
Definition: nvenc.h:190
int64_t initial_pts[2]
Definition: nvenc.h:170
main external API structure.
Definition: avcodec.h:1676
a very simple circular buffer FIFO implementation
CUresult(CUDAAPI * PCUCTXDESTROY)(CUcontext ctx)
Definition: nvenc.h:74
void * CUdeviceptr
Definition: nvenc.h:46
Describe the class of an AVClass context structure.
Definition: log.h:67
int width
Definition: nvenc.h:57
#define NVENCAPI
Definition: nvEncodeAPI.h:71
int nonref_p
Definition: nvenc.h:192
CUresult(CUDAAPI * PCUINIT)(unsigned int Flags)
Definition: nvenc.h:67
int cbr
Definition: nvenc.h:180
static int flags
Definition: cpu.c:47
int reg_idx
Definition: nvenc.h:56
int b_adapt
Definition: nvenc.h:189
PCUCTXPOPCURRENT cu_ctx_pop_current
Definition: nvenc.h:92
int rc_lookahead
Definition: nvenc.h:185
void * NV_ENC_OUTPUT_PTR
NVENCODE API output buffer.
Definition: nvEncodeAPI.h:111
int size
Definition: nvenc.h:63
NvencSurface * surfaces
Definition: nvenc.h:151
int len
int device
Definition: nvenc.h:182
int nb_surfaces
Definition: nvenc.h:150
NVENCSTATUS(NVENCAPI * PNVENCODEAPIGETMAXSUPPORTEDVERSION)(uint32_t *version)
Definition: nvenc.h:76
CUresult(CUDAAPI * PCUCTXPOPCURRENT)(CUcontext *pctx)
Definition: nvenc.h:73
int tier
Definition: nvenc.h:178
void * CUcontext
Definition: nvenc.h:45
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1578
NV_ENC_OUTPUT_PTR output_surface
Definition: nvenc.h:61
CUresult(CUDAAPI * PCUDEVICEGETNAME)(char *name, int len, CUdevice dev)
Definition: nvenc.h:70
int zerolatency
Definition: nvenc.h:191
NVENCSTATUS
Error Codes.
Definition: nvEncodeAPI.h:375
const char * name
Definition: opengl_enc.c:103