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 
27 #include "libavutil/fifo.h"
28 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 
32 #define MAX_REGISTERED_FRAMES 64
33 #define RC_MODE_DEPRECATED 0x800000
34 #define RCD(rc_mode) ((rc_mode) | RC_MODE_DEPRECATED)
35 
36 typedef struct NvencSurface
37 {
41  int reg_idx;
42  int width;
43  int height;
44  int pitch;
45 
48  int size;
49 } NvencSurface;
50 
51 typedef struct NvencDynLoadFunctions
52 {
55 
59 
60 enum {
71  PRESET_LOSSLESS_DEFAULT, // lossless presets must be the last ones
73 };
74 
75 enum {
80 };
81 
82 enum {
86 };
87 
88 enum {
93 };
94 
95 enum {
98 };
99 
100 typedef struct NvencContext
101 {
103 
105 
110 
113 
118 
120 
121  struct {
124  int mapped;
127 
128  /* the actual data pixel format, different from
129  * AVCodecContext.pix_fmt when using hwaccel frames on input */
131 
132  /* timestamps of the first two frames, for computing the first dts
133  * when B-frames are present */
134  int64_t initial_pts[2];
136 
137  void *nvencoder;
138 
139  int preset;
140  int profile;
141  int level;
142  int tier;
143  int rc;
144  int cbr;
145  int twopass;
146  int device;
147  int flags;
150  int aq;
153  int b_adapt;
156  int nonref_p;
159  float quality;
160  int aud;
165  int cqp;
167  int coder;
168 } NvencContext;
169 
171 
173 
174 int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame);
175 
177 
179  const AVFrame *frame, int *got_packet);
180 
181 extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
182 
183 #endif /* AVCODEC_NVENC_H */
int no_scenecut
Definition: nvenc.h:151
AVClass * avclass
Definition: nvenc.h:102
void * nvencoder
Definition: nvenc.h:137
enum AVPixelFormat ff_nvenc_pix_fmts[]
Definition: nvenc.c:39
int twopass
Definition: nvenc.h:145
NV_ENC_BUFFER_FORMAT format
Definition: nvenc.h:47
int ff_nvenc_encode_init(AVCodecContext *avctx)
Definition: nvenc.c:1403
int height
Definition: nvenc.h:43
struct NvencContext::@101 registered_frames[MAX_REGISTERED_FRAMES]
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
AVFifoBuffer * timestamp_list
Definition: nvenc.h:117
NvencFunctions * nvenc_dl
Definition: nvenc.h:54
int mapped
Definition: nvenc.h:124
AVFrame * in_ref
Definition: nvenc.h:39
int encoder_flushing
Definition: nvenc.h:119
NV_ENC_MAP_INPUT_RESOURCE in_map
Definition: nvenc.h:40
NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder (referred to as...
int forced_idr
Definition: nvenc.h:152
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs
Definition: nvenc.h:56
NvencDynLoadFunctions nvenc_dload_funcs
Definition: nvenc.h:104
int first_packet_output
Definition: nvenc.h:135
NV_ENCODE_API_FUNCTION_LIST.
Definition: nvEncodeAPI.h:3254
static AVPacket pkt
int init_qp_b
Definition: nvenc.h:163
int preset
Definition: nvenc.h:139
int pitch
Definition: nvenc.h:44
int nvenc_device_count
Definition: nvenc.h:57
NV_ENC_INPUT_PTR input_surface
Definition: nvenc.h:38
int aq
Definition: nvenc.h:150
void * NV_ENC_INPUT_PTR
NVENCODE API input buffer.
Definition: nvEncodeAPI.h:112
CUcontext cu_context
Definition: nvenc.h:108
AVFifoBuffer * unused_surface_queue
Definition: nvenc.h:114
AVOptions.
int init_qp_p
Definition: nvenc.h:162
int ff_nvenc_encode_close(AVCodecContext *avctx)
Definition: nvenc.c:1326
int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: nvenc.c:1923
float quality
Definition: nvenc.h:159
NV_ENC_INITIALIZE_PARAMS init_encode_params
Definition: nvenc.h:106
static AVFrame * frame
#define MAX_REGISTERED_FRAMES
Definition: nvenc.h:32
NV_ENC_BUFFER_FORMAT
Input buffer formats.
Definition: nvEncodeAPI.h:311
AVFifoBuffer * output_surface_ready_queue
Definition: nvenc.h:116
CUdeviceptr ptr
Definition: nvenc.h:122
CUcontext cu_context_internal
Definition: nvenc.h:109
int async_depth
Definition: nvenc.h:148
int coder
Definition: nvenc.h:167
void * NV_ENC_REGISTERED_PTR
A Resource that has been registered with NVENCODE API.
Definition: nvEncodeAPI.h:114
int rc
Definition: nvenc.h:143
int nb_registered_frames
Definition: nvenc.h:126
int level
Definition: nvenc.h:141
int bluray_compat
Definition: nvenc.h:161
int aq_strength
Definition: nvenc.h:158
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: nvenc.c:1966
int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Definition: nvenc.c:1810
int flags
Definition: nvenc.h:147
NV_ENC_REGISTERED_PTR regptr
Definition: nvenc.h:123
int profile
Definition: nvenc.h:140
AVFifoBuffer * output_surface_queue
Definition: nvenc.h:115
CudaFunctions * cuda_dl
Definition: nvenc.h:53
enum AVPixelFormat data_pix_fmt
Definition: nvenc.h:130
NV_ENC_CONFIG encode_config
Definition: nvenc.h:107
Libavcodec external API header.
int strict_gop
Definition: nvenc.h:157
int temporal_aq
Definition: nvenc.h:154
int64_t initial_pts[2]
Definition: nvenc.h:134
main external API structure.
Definition: avcodec.h:1761
int init_qp_i
Definition: nvenc.h:164
a very simple circular buffer FIFO implementation
Describe the class of an AVClass context structure.
Definition: log.h:67
int width
Definition: nvenc.h:42
int nonref_p
Definition: nvenc.h:156
int cbr
Definition: nvenc.h:144
int reg_idx
Definition: nvenc.h:41
int b_adapt
Definition: nvenc.h:153
int weighted_pred
Definition: nvenc.h:166
int rc_lookahead
Definition: nvenc.h:149
void * NV_ENC_OUTPUT_PTR
NVENCODE API output buffer.
Definition: nvEncodeAPI.h:113
int size
Definition: nvenc.h:48
NvencSurface * surfaces
Definition: nvenc.h:112
int device
Definition: nvenc.h:146
int nb_surfaces
Definition: nvenc.h:111
int aud
Definition: nvenc.h:160
int cqp
Definition: nvenc.h:165
int tier
Definition: nvenc.h:142
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1656
NV_ENC_OUTPUT_PTR output_surface
Definition: nvenc.h:46
int zerolatency
Definition: nvenc.h:155