FFmpeg  3.3.9
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 
27 #include "libavutil/fifo.h"
28 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 
32 #define MAX_REGISTERED_FRAMES 64
33 
34 typedef struct NvencSurface
35 {
38  int reg_idx;
39  int width;
40  int height;
41  int pitch;
42 
45  int size;
46  int lockCount;
47 } NvencSurface;
48 
49 typedef struct NvencDynLoadFunctions
50 {
53 
57 
58 enum {
69  PRESET_LOSSLESS_DEFAULT, // lossless presets must be the last ones
71 };
72 
73 enum {
78 };
79 
80 enum {
84 };
85 
86 enum {
91 };
92 
93 enum {
96 };
97 
98 typedef struct NvencContext
99 {
101 
103 
108 
111 
115 
116  struct {
119  int mapped;
121  } registered_frames[MAX_REGISTERED_FRAMES];
123 
124  /* the actual data pixel format, different from
125  * AVCodecContext.pix_fmt when using hwaccel frames on input */
126  enum AVPixelFormat data_pix_fmt;
127 
128  /* timestamps of the first two frames, for computing the first dts
129  * when B-frames are present */
130  int64_t initial_pts[2];
132 
133  void *nvencoder;
134 
135  int preset;
136  int profile;
137  int level;
138  int tier;
139  int rc;
140  int cbr;
141  int twopass;
142  int device;
143  int flags;
146  int aq;
149  int b_adapt;
152  int nonref_p;
155  int quality;
156  int aud;
161  int cqp;
162 } NvencContext;
163 
165 
167 
169  const AVFrame *frame, int *got_packet);
170 
171 extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
172 
173 #endif /* AVCODEC_NVENC_H */
int no_scenecut
Definition: nvenc.h:147
AVClass * avclass
Definition: nvenc.h:100
void * nvencoder
Definition: nvenc.h:133
enum AVPixelFormat ff_nvenc_pix_fmts[]
Definition: nvenc.c:39
int twopass
Definition: nvenc.h:141
NV_ENC_BUFFER_FORMAT format
Definition: nvenc.h:44
int ff_nvenc_encode_init(AVCodecContext *avctx)
Definition: nvenc.c:1329
int height
Definition: nvenc.h:40
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
AVFifoBuffer * timestamp_list
Definition: nvenc.h:114
NvencFunctions * nvenc_dl
Definition: nvenc.h:52
int mapped
Definition: nvenc.h:119
AVFrame * in_ref
Definition: nvenc.h:37
NvEncodeAPI provides a NVENC Video Encoding interface to NVIDIA GPU devices based on the Kepler archi...
int forced_idr
Definition: nvenc.h:148
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs
Definition: nvenc.h:54
NvencDynLoadFunctions nvenc_dload_funcs
Definition: nvenc.h:102
int first_packet_output
Definition: nvenc.h:131
NV_ENCODE_API_FUNCTION_LIST.
Definition: nvEncodeAPI.h:3149
static AVPacket pkt
int init_qp_b
Definition: nvenc.h:159
int preset
Definition: nvenc.h:135
int pitch
Definition: nvenc.h:41
int nvenc_device_count
Definition: nvenc.h:55
NV_ENC_INPUT_PTR input_surface
Definition: nvenc.h:36
int aq
Definition: nvenc.h:146
void * NV_ENC_INPUT_PTR
NVENCODE API input buffer.
Definition: nvEncodeAPI.h:110
CUcontext cu_context
Definition: nvenc.h:106
AVOptions.
int init_qp_p
Definition: nvenc.h:158
int ff_nvenc_encode_close(AVCodecContext *avctx)
Definition: nvenc.c:1256
NV_ENC_INITIALIZE_PARAMS init_encode_params
Definition: nvenc.h:104
static AVFrame * frame
#define MAX_REGISTERED_FRAMES
Definition: nvenc.h:32
NV_ENC_BUFFER_FORMAT
Input buffer formats.
Definition: nvEncodeAPI.h:306
AVFifoBuffer * output_surface_ready_queue
Definition: nvenc.h:113
CUdeviceptr ptr
Definition: nvenc.h:117
CUcontext cu_context_internal
Definition: nvenc.h:107
int async_depth
Definition: nvenc.h:144
void * NV_ENC_REGISTERED_PTR
A Resource that has been registered with NVENCODE API.
Definition: nvEncodeAPI.h:112
int rc
Definition: nvenc.h:139
int nb_registered_frames
Definition: nvenc.h:122
int level
Definition: nvenc.h:137
int quality
Definition: nvenc.h:155
int bluray_compat
Definition: nvenc.h:157
int aq_strength
Definition: nvenc.h:154
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: nvenc.c:1764
int flags
Definition: nvenc.h:143
NV_ENC_REGISTERED_PTR regptr
Definition: nvenc.h:118
int lockCount
Definition: nvenc.h:46
int profile
Definition: nvenc.h:136
AVFifoBuffer * output_surface_queue
Definition: nvenc.h:112
CudaFunctions * cuda_dl
Definition: nvenc.h:51
NV_ENC_CONFIG encode_config
Definition: nvenc.h:105
Libavcodec external API header.
int strict_gop
Definition: nvenc.h:153
int temporal_aq
Definition: nvenc.h:150
main external API structure.
Definition: avcodec.h:1732
int init_qp_i
Definition: nvenc.h:160
a very simple circular buffer FIFO implementation
Describe the class of an AVClass context structure.
Definition: log.h:67
int width
Definition: nvenc.h:39
int nonref_p
Definition: nvenc.h:152
int cbr
Definition: nvenc.h:140
int reg_idx
Definition: nvenc.h:38
int b_adapt
Definition: nvenc.h:149
int rc_lookahead
Definition: nvenc.h:145
void * NV_ENC_OUTPUT_PTR
NVENCODE API output buffer.
Definition: nvEncodeAPI.h:111
int size
Definition: nvenc.h:45
NvencSurface * surfaces
Definition: nvenc.h:110
NV_ENC_MAP_INPUT_RESOURCE in_map
Definition: nvenc.h:120
int device
Definition: nvenc.h:142
int nb_surfaces
Definition: nvenc.h:109
int aud
Definition: nvenc.h:156
int cqp
Definition: nvenc.h:161
int tier
Definition: nvenc.h:138
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
This structure stores compressed data.
Definition: avcodec.h:1634
NV_ENC_OUTPUT_PTR output_surface
Definition: nvenc.h:43
int zerolatency
Definition: nvenc.h:151