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