FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvEncodeAPI.h
Go to the documentation of this file.
1 /*
2  * This copyright notice applies to this header file only:
3  *
4  * Copyright (c) 2010-2017 NVIDIA Corporation
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the software, and to permit persons to whom the
12  * software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 /**
29  * \file nvEncodeAPI.h
30  * NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder
31  * (referred to as NVENC) which provides fully-accelerated hardware-based video encoding.
32  * NvEncodeAPI provides the interface for NVIDIA video encoder (NVENC).
33  * \date 2011-2017
34  * This file contains the interface constants, structure definitions and function prototypes.
35  */
36 
37 #ifndef _NV_ENCODEAPI_H_
38 #define _NV_ENCODEAPI_H_
39 
40 #include <stdlib.h>
41 
42 #ifdef _WIN32
43 #include <windows.h>
44 #endif
45 
46 #ifdef _MSC_VER
47 #ifndef _STDINT
48 typedef __int32 int32_t;
49 typedef unsigned __int32 uint32_t;
50 typedef __int64 int64_t;
51 typedef unsigned __int64 uint64_t;
52 typedef signed char int8_t;
53 typedef unsigned char uint8_t;
54 typedef short int16_t;
55 typedef unsigned short uint16_t;
56 #endif
57 #else
58 #include <stdint.h>
59 #endif
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 /**
66  * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
67  * @{
68  */
69 
70 #if defined(_WIN32) || defined(__CYGWIN__)
71 #define NVENCAPI __stdcall
72 #else
73 #define NVENCAPI
74 #endif
75 
76 #ifdef _WIN32
77 typedef RECT NVENC_RECT;
78 #else
79 // =========================================================================================
80 #ifndef GUID
81 /*!
82  * \struct GUID
83  * Abstracts the GUID structure for non-windows platforms.
84  */
85 // =========================================================================================
86 typedef struct
87 {
88  uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */
89  uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */
90  uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */
91  uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits.
92  The remaining 6 bytes contain the final 12 hexadecimal digits. */
93 } GUID;
94 #endif // GUID
95 
96 /**
97  * \struct _NVENC_RECT
98  * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME.
99  */
100 typedef struct _NVENC_RECT
101 {
102  uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */
103  uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */
104  uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */
105  uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */
106 } NVENC_RECT;
107 
108 #endif // _WIN32
109 
110 /** @} */ /* End of GUID and NVENC_RECT structure grouping*/
111 
112 typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */
113 typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/
114 typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/
115 
116 #define NVENCAPI_MAJOR_VERSION 8
117 #define NVENCAPI_MINOR_VERSION 0
118 
119 #define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
120 
121 /**
122  * Macro to generate per-structure version for use with API.
123  */
124 #define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28))
125 
126 
127 #define NVENC_INFINITE_GOPLENGTH 0xffffffff
128 
129 #define NV_MAX_SEQ_HDR_LEN (512)
130 
131 // =========================================================================================
132 // Encode Codec GUIDS supported by the NvEncodeAPI interface.
133 // =========================================================================================
134 
135 // {6BC82762-4E63-4ca4-AA85-1E50F321F6BF}
137 { 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } };
138 
139 // {790CDC88-4522-4d7b-9425-BDA9975F7603}
141 { 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } };
142 
143 
144 
145 // =========================================================================================
146 // * Encode Profile GUIDS supported by the NvEncodeAPI interface.
147 // =========================================================================================
148 
149 // {BFD6F8E7-233C-4341-8B3E-4818523803F4}
151 { 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } };
152 
153 // {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A}
155 { 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } };
156 
157 // {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D}
159 { 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } };
160 
161 // {E7CBC309-4F7A-4b89-AF2A-D537C92BE310}
163 { 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } };
164 
165 // {7AC663CB-A598-4960-B844-339B261A7D52}
167 { 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } };
168 
169 // {40847BF5-33F7-4601-9084-E8FE3C1DB8B7}
171 { 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } };
172 
173 // {CE788D20-AAA9-4318-92BB-AC7E858C8D36}
175 { 0xce788d20, 0xaaa9, 0x4318, { 0x92, 0xbb, 0xac, 0x7e, 0x85, 0x8c, 0x8d, 0x36 } };
176 
177 // {B405AFAC-F32B-417B-89C4-9ABEED3E5978}
179 { 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } };
180 
181 // {AEC1BD87-E85B-48f2-84C3-98BCA6285072}
183 { 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } };
184 
185 // {B514C39A-B55B-40fa-878F-F1253B4DFDEC}
187 { 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } };
188 
189 // {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5}
191 { 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } };
192 
193 // For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only
194 // {51ec32b5-1b4c-453c-9cbd-b616bd621341}
196 { 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } };
197 
198 // =========================================================================================
199 // * Preset GUIDS supported by the NvEncodeAPI interface.
200 // =========================================================================================
201 // {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
203 { 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } };
204 
205 // {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
207 { 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } };
208 
209 // {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
211 { 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } };
212 
213 // {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
215 { 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } };
216 
217 // {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
219 { 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } };
220 
221 // {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
223 { 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } };
224 
225 // {67082A44-4BAD-48FA-98EA-93056D150A58}
227 { 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } };
228 
229 // {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
231 { 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } };
232 
233 // {149998E7-2364-411d-82EF-179888093409}
235 { 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } };
236 
237 /**
238  * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
239  * @{
240  */
241 
242 /**
243  * Input frame encode modes
244  */
245 typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE
246 {
247  NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */
248  NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */
249  NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */
251 
252 /**
253  * Rate Control Modes
254  */
255 typedef enum _NV_ENC_PARAMS_RC_MODE
256 {
257  NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */
258  NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */
259  NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */
260  NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ = 0x8, /**< low-delay CBR, high quality */
261  NV_ENC_PARAMS_RC_CBR_HQ = 0x10, /**< CBR, high quality (slower) */
262  NV_ENC_PARAMS_RC_VBR_HQ = 0x20 /**< VBR, high quality (slower) */
264 
265 #define NV_ENC_PARAMS_RC_VBR_MINQP (NV_ENC_PARAMS_RC_MODE)0x4 /**< Deprecated */
266 #define NV_ENC_PARAMS_RC_2_PASS_QUALITY NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ /**< Deprecated */
267 #define NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP NV_ENC_PARAMS_RC_CBR_HQ /**< Deprecated */
268 #define NV_ENC_PARAMS_RC_2_PASS_VBR NV_ENC_PARAMS_RC_VBR_HQ /**< Deprecated */
269 #define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */
270 
271 /**
272  * Input picture structure
273  */
274 typedef enum _NV_ENC_PIC_STRUCT
275 {
276  NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */
277  NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */
278  NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */
280 
281 /**
282  * Input picture type
283  */
284 typedef enum _NV_ENC_PIC_TYPE
285 {
286  NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */
287  NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */
288  NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */
289  NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */
290  NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */
291  NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */
292  NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */
293  NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */
295 
296 /**
297  * Motion vector precisions
298  */
299 typedef enum _NV_ENC_MV_PRECISION
300 {
301  NV_ENC_MV_PRECISION_DEFAULT = 0x0, /**<Driver selects QuarterPel motion vector precision by default*/
302  NV_ENC_MV_PRECISION_FULL_PEL = 0x01, /**< FullPel motion vector precision */
303  NV_ENC_MV_PRECISION_HALF_PEL = 0x02, /**< HalfPel motion vector precision */
304  NV_ENC_MV_PRECISION_QUARTER_PEL = 0x03 /**< QuarterPel motion vector precision */
306 
307 
308 /**
309  * Input buffer formats
310  */
311 typedef enum _NV_ENC_BUFFER_FORMAT
312 {
313  NV_ENC_BUFFER_FORMAT_UNDEFINED = 0x00000000, /**< Undefined buffer format */
314 
315  NV_ENC_BUFFER_FORMAT_NV12 = 0x00000001, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
316  NV_ENC_BUFFER_FORMAT_YV12 = 0x00000010, /**< Planar YUV [Y plane followed by V and U planes] */
317  NV_ENC_BUFFER_FORMAT_IYUV = 0x00000100, /**< Planar YUV [Y plane followed by U and V planes] */
318  NV_ENC_BUFFER_FORMAT_YUV444 = 0x00001000, /**< Planar YUV [Y plane followed by U and V planes] */
319  NV_ENC_BUFFER_FORMAT_YUV420_10BIT = 0x00010000, /**< 10 bit Semi-Planar YUV [Y plane followed by interleaved UV plane]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
320  NV_ENC_BUFFER_FORMAT_YUV444_10BIT = 0x00100000, /**< 10 bit Planar YUV444 [Y plane followed by U and V planes]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
321  NV_ENC_BUFFER_FORMAT_ARGB = 0x01000000, /**< 8 bit Packed A8R8G8B8. This is a word-ordered format
322  where a pixel is represented by a 32-bit word with B
323  in the lowest 8 bits, G in the next 8 bits, R in the
324  8 bits after that and A in the highest 8 bits. */
325  NV_ENC_BUFFER_FORMAT_ARGB10 = 0x02000000, /**< 10 bit Packed A2R10G10B10. This is a word-ordered format
326  where a pixel is represented by a 32-bit word with B
327  in the lowest 10 bits, G in the next 10 bits, R in the
328  10 bits after that and A in the highest 2 bits. */
329  NV_ENC_BUFFER_FORMAT_AYUV = 0x04000000, /**< 8 bit Packed A8Y8U8V8. This is a word-ordered format
330  where a pixel is represented by a 32-bit word with V
331  in the lowest 8 bits, U in the next 8 bits, Y in the
332  8 bits after that and A in the highest 8 bits. */
333  NV_ENC_BUFFER_FORMAT_ABGR = 0x10000000, /**< 8 bit Packed A8B8G8R8. This is a word-ordered format
334  where a pixel is represented by a 32-bit word with R
335  in the lowest 8 bits, G in the next 8 bits, B in the
336  8 bits after that and A in the highest 8 bits. */
337  NV_ENC_BUFFER_FORMAT_ABGR10 = 0x20000000, /**< 10 bit Packed A2B10G10R10. This is a word-ordered format
338  where a pixel is represented by a 32-bit word with R
339  in the lowest 10 bits, G in the next 10 bits, B in the
340  10 bits after that and A in the highest 2 bits. */
342 
343 #define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
344 #define NV_ENC_BUFFER_FORMAT_YV12_PL NV_ENC_BUFFER_FORMAT_YV12
345 #define NV_ENC_BUFFER_FORMAT_IYUV_PL NV_ENC_BUFFER_FORMAT_IYUV
346 #define NV_ENC_BUFFER_FORMAT_YUV444_PL NV_ENC_BUFFER_FORMAT_YUV444
347 
348 /**
349  * Encoding levels
350  */
351 typedef enum _NV_ENC_LEVEL
352 {
354 
372 
373 
387 
390 } NV_ENC_LEVEL;
391 
392 /**
393  * Error Codes
394  */
395 typedef enum _NVENCSTATUS
396 {
397  /**
398  * This indicates that API call returned with no errors.
399  */
401 
402  /**
403  * This indicates that no encode capable devices were detected.
404  */
406 
407  /**
408  * This indicates that devices pass by the client is not supported.
409  */
411 
412  /**
413  * This indicates that the encoder device supplied by the client is not
414  * valid.
415  */
417 
418  /**
419  * This indicates that device passed to the API call is invalid.
420  */
422 
423  /**
424  * This indicates that device passed to the API call is no longer available and
425  * needs to be reinitialized. The clients need to destroy the current encoder
426  * session by freeing the allocated input output buffers and destroying the device
427  * and create a new encoding session.
428  */
430 
431  /**
432  * This indicates that one or more of the pointers passed to the API call
433  * is invalid.
434  */
436 
437  /**
438  * This indicates that completion event passed in ::NvEncEncodePicture() call
439  * is invalid.
440  */
442 
443  /**
444  * This indicates that one or more of the parameter passed to the API call
445  * is invalid.
446  */
448 
449  /**
450  * This indicates that an API call was made in wrong sequence/order.
451  */
453 
454  /**
455  * This indicates that the API call failed because it was unable to allocate
456  * enough memory to perform the requested operation.
457  */
459 
460  /**
461  * This indicates that the encoder has not been initialized with
462  * ::NvEncInitializeEncoder() or that initialization has failed.
463  * The client cannot allocate input or output buffers or do any encoding
464  * related operation before successfully initializing the encoder.
465  */
467 
468  /**
469  * This indicates that an unsupported parameter was passed by the client.
470  */
472 
473  /**
474  * This indicates that the ::NvEncLockBitstream() failed to lock the output
475  * buffer. This happens when the client makes a non blocking lock call to
476  * access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
477  * This is not a fatal error and client should retry the same operation after
478  * few milliseconds.
479  */
481 
482  /**
483  * This indicates that the size of the user buffer passed by the client is
484  * insufficient for the requested operation.
485  */
487 
488  /**
489  * This indicates that an invalid struct version was used by the client.
490  */
492 
493  /**
494  * This indicates that ::NvEncMapInputResource() API failed to map the client
495  * provided input resource.
496  */
498 
499  /**
500  * This indicates encode driver requires more input buffers to produce an output
501  * bitstream. If this error is returned from ::NvEncEncodePicture() API, this
502  * is not a fatal error. If the client is encoding with B frames then,
503  * ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
504  *
505  * A client operating in synchronous mode cannot call ::NvEncLockBitstream()
506  * API on the output bitstream buffer if ::NvEncEncodePicture() returned the
507  * ::NV_ENC_ERR_NEED_MORE_INPUT error code.
508  * The client must continue providing input frames until encode driver returns
509  * ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
510  * ::NvEncLockBitstream() API on the output buffers in the same order in which
511  * it has called ::NvEncEncodePicture().
512  */
514 
515  /**
516  * This indicates that the HW encoder is busy encoding and is unable to encode
517  * the input. The client should call ::NvEncEncodePicture() again after few
518  * milliseconds.
519  */
521 
522  /**
523  * This indicates that the completion event passed in ::NvEncEncodePicture()
524  * API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().
525  */
527 
528  /**
529  * This indicates that an unknown internal error has occurred.
530  */
532 
533  /**
534  * This indicates that the client is attempting to use a feature
535  * that is not available for the license type for the current system.
536  */
538 
539  /**
540  * This indicates that the client is attempting to use a feature
541  * that is not implemented for the current version.
542  */
544 
545  /**
546  * This indicates that the ::NvEncRegisterResource API failed to register the resource.
547  */
549 
550  /**
551  * This indicates that the client is attempting to unregister a resource
552  * that has not been successfully registered.
553  */
555 
556  /**
557  * This indicates that the client is attempting to unmap a resource
558  * that has not been successfully mapped.
559  */
561 
562 } NVENCSTATUS;
563 
564 /**
565  * Encode Picture encode flags.
566  */
567 typedef enum _NV_ENC_PIC_FLAGS
568 {
569  NV_ENC_PIC_FLAG_FORCEINTRA = 0x1, /**< Encode the current picture as an Intra picture */
570  NV_ENC_PIC_FLAG_FORCEIDR = 0x2, /**< Encode the current picture as an IDR picture.
571  This flag is only valid when Picture type decision is taken by the Encoder
572  [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
573  NV_ENC_PIC_FLAG_OUTPUT_SPSPPS = 0x4, /**< Write the sequence and picture header in encoded bitstream of the current picture */
574  NV_ENC_PIC_FLAG_EOS = 0x8, /**< Indicates end of the input stream */
576 
577 /**
578  * Memory heap to allocate input and output buffers.
579  */
580 typedef enum _NV_ENC_MEMORY_HEAP
581 {
582  NV_ENC_MEMORY_HEAP_AUTOSELECT = 0, /**< Memory heap to be decided by the encoder driver based on the usage */
583  NV_ENC_MEMORY_HEAP_VID = 1, /**< Memory heap is in local video memory */
584  NV_ENC_MEMORY_HEAP_SYSMEM_CACHED = 2, /**< Memory heap is in cached system memory */
585  NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED = 3 /**< Memory heap is in uncached system memory */
587 
588 
589 /**
590  * H.264 entropy coding modes.
591  */
592 typedef enum _NV_ENC_H264_ENTROPY_CODING_MODE
593 {
594  NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT = 0x0, /**< Entropy coding mode is auto selected by the encoder driver */
595  NV_ENC_H264_ENTROPY_CODING_MODE_CABAC = 0x1, /**< Entropy coding mode is CABAC */
596  NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC = 0x2 /**< Entropy coding mode is CAVLC */
598 
599 /**
600  * H.264 specific Bdirect modes
601  */
602 typedef enum _NV_ENC_H264_BDIRECT_MODE
603 {
604  NV_ENC_H264_BDIRECT_MODE_AUTOSELECT = 0x0, /**< BDirect mode is auto selected by the encoder driver */
605  NV_ENC_H264_BDIRECT_MODE_DISABLE = 0x1, /**< Disable BDirect mode */
606  NV_ENC_H264_BDIRECT_MODE_TEMPORAL = 0x2, /**< Temporal BDirect mode */
607  NV_ENC_H264_BDIRECT_MODE_SPATIAL = 0x3 /**< Spatial BDirect mode */
609 
610 /**
611  * H.264 specific FMO usage
612  */
613 typedef enum _NV_ENC_H264_FMO_MODE
614 {
615  NV_ENC_H264_FMO_AUTOSELECT = 0x0, /**< FMO usage is auto selected by the encoder driver */
616  NV_ENC_H264_FMO_ENABLE = 0x1, /**< Enable FMO */
617  NV_ENC_H264_FMO_DISABLE = 0x2, /**< Disble FMO */
619 
620 /**
621  * H.264 specific Adaptive Transform modes
622  */
623 typedef enum _NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
624 {
625  NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT = 0x0, /**< Adaptive Transform 8x8 mode is auto selected by the encoder driver*/
626  NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE = 0x1, /**< Adaptive Transform 8x8 mode disabled */
627  NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE = 0x2, /**< Adaptive Transform 8x8 mode should be used */
629 
630 /**
631  * Stereo frame packing modes.
632  */
633 typedef enum _NV_ENC_STEREO_PACKING_MODE
634 {
635  NV_ENC_STEREO_PACKING_MODE_NONE = 0x0, /**< No Stereo packing required */
636  NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD = 0x1, /**< Checkerboard mode for packing stereo frames */
637  NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE = 0x2, /**< Column Interleave mode for packing stereo frames */
638  NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE = 0x3, /**< Row Interleave mode for packing stereo frames */
639  NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE = 0x4, /**< Side-by-side mode for packing stereo frames */
640  NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM = 0x5, /**< Top-Bottom mode for packing stereo frames */
641  NV_ENC_STEREO_PACKING_MODE_FRAMESEQ = 0x6 /**< Frame Sequential mode for packing stereo frames */
643 
644 /**
645  * Input Resource type
646  */
647 typedef enum _NV_ENC_INPUT_RESOURCE_TYPE
648 {
649  NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX = 0x0, /**< input resource type is a directx9 surface*/
650  NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR = 0x1, /**< input resource type is a cuda device pointer surface*/
651  NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY = 0x2, /**< input resource type is a cuda array surface */
652  NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX = 0x3 /**< input resource type is an OpenGL texture */
654 
655 /**
656  * Encoder Device type
657  */
658 typedef enum _NV_ENC_DEVICE_TYPE
659 {
660  NV_ENC_DEVICE_TYPE_DIRECTX = 0x0, /**< encode device type is a directx9 device */
661  NV_ENC_DEVICE_TYPE_CUDA = 0x1, /**< encode device type is a cuda device */
662  NV_ENC_DEVICE_TYPE_OPENGL = 0x2 /**< encode device type is an OpenGL device.
663  Use of this device type is supported only on Linux */
665 
666 /**
667  * Encoder capabilities enumeration.
668  */
669 typedef enum _NV_ENC_CAPS
670 {
671  /**
672  * Maximum number of B-Frames supported.
673  */
675 
676  /**
677  * Rate control modes supported.
678  * \n The API return value is a bitmask of the values in NV_ENC_PARAMS_RC_MODE.
679  */
681 
682  /**
683  * Indicates HW support for field mode encoding.
684  * \n 0 : Interlaced mode encoding is not supported.
685  * \n 1 : Interlaced field mode encoding is supported.
686  * \n 2 : Interlaced frame encoding and field mode encoding are both supported.
687  */
689 
690  /**
691  * Indicates HW support for monochrome mode encoding.
692  * \n 0 : Monochrome mode not supported.
693  * \n 1 : Monochrome mode supported.
694  */
696 
697  /**
698  * Indicates HW support for FMO.
699  * \n 0 : FMO not supported.
700  * \n 1 : FMO supported.
701  */
703 
704  /**
705  * Indicates HW capability for Quarter pel motion estimation.
706  * \n 0 : QuarterPel Motion Estimation not supported.
707  * \n 1 : QuarterPel Motion Estimation supported.
708  */
710 
711  /**
712  * H.264 specific. Indicates HW support for BDirect modes.
713  * \n 0 : BDirect mode encoding not supported.
714  * \n 1 : BDirect mode encoding supported.
715  */
717 
718  /**
719  * H264 specific. Indicates HW support for CABAC entropy coding mode.
720  * \n 0 : CABAC entropy coding not supported.
721  * \n 1 : CABAC entropy coding supported.
722  */
724 
725  /**
726  * Indicates HW support for Adaptive Transform.
727  * \n 0 : Adaptive Transform not supported.
728  * \n 1 : Adaptive Transform supported.
729  */
731 
732  /**
733  * Reserved enum field.
734  */
736 
737  /**
738  * Indicates HW support for encoding Temporal layers.
739  * \n 0 : Encoding Temporal layers not supported.
740  * \n 1 : Encoding Temporal layers supported.
741  */
743 
744  /**
745  * Indicates HW support for Hierarchical P frames.
746  * \n 0 : Hierarchical P frames not supported.
747  * \n 1 : Hierarchical P frames supported.
748  */
750 
751  /**
752  * Indicates HW support for Hierarchical B frames.
753  * \n 0 : Hierarchical B frames not supported.
754  * \n 1 : Hierarchical B frames supported.
755  */
757 
758  /**
759  * Maximum Encoding level supported (See ::NV_ENC_LEVEL for details).
760  */
762 
763  /**
764  * Minimum Encoding level supported (See ::NV_ENC_LEVEL for details).
765  */
767 
768  /**
769  * Indicates HW support for separate colour plane encoding.
770  * \n 0 : Separate colour plane encoding not supported.
771  * \n 1 : Separate colour plane encoding supported.
772  */
774 
775  /**
776  * Maximum output width supported.
777  */
779 
780  /**
781  * Maximum output height supported.
782  */
784 
785  /**
786  * Indicates Temporal Scalability Support.
787  * \n 0 : Temporal SVC encoding not supported.
788  * \n 1 : Temporal SVC encoding supported.
789  */
791 
792  /**
793  * Indicates Dynamic Encode Resolution Change Support.
794  * Support added from NvEncodeAPI version 2.0.
795  * \n 0 : Dynamic Encode Resolution Change not supported.
796  * \n 1 : Dynamic Encode Resolution Change supported.
797  */
799 
800  /**
801  * Indicates Dynamic Encode Bitrate Change Support.
802  * Support added from NvEncodeAPI version 2.0.
803  * \n 0 : Dynamic Encode bitrate change not supported.
804  * \n 1 : Dynamic Encode bitrate change supported.
805  */
807 
808  /**
809  * Indicates Forcing Constant QP On The Fly Support.
810  * Support added from NvEncodeAPI version 2.0.
811  * \n 0 : Forcing constant QP on the fly not supported.
812  * \n 1 : Forcing constant QP on the fly supported.
813  */
815 
816  /**
817  * Indicates Dynamic rate control mode Change Support.
818  * \n 0 : Dynamic rate control mode change not supported.
819  * \n 1 : Dynamic rate control mode change supported.
820  */
822 
823  /**
824  * Indicates Subframe readback support for slice-based encoding.
825  * \n 0 : Subframe readback not supported.
826  * \n 1 : Subframe readback supported.
827  */
829 
830  /**
831  * Indicates Constrained Encoding mode support.
832  * Support added from NvEncodeAPI version 2.0.
833  * \n 0 : Constrained encoding mode not supported.
834  * \n 1 : Constarined encoding mode supported.
835  * If this mode is supported client can enable this during initialisation.
836  * Client can then force a picture to be coded as constrained picture where
837  * each slice in a constrained picture will have constrained_intra_pred_flag set to 1
838  * and disable_deblocking_filter_idc will be set to 2 and prediction vectors for inter
839  * macroblocks in each slice will be restricted to the slice region.
840  */
842 
843  /**
844  * Indicates Intra Refresh Mode Support.
845  * Support added from NvEncodeAPI version 2.0.
846  * \n 0 : Intra Refresh Mode not supported.
847  * \n 1 : Intra Refresh Mode supported.
848  */
850 
851  /**
852  * Indicates Custom VBV Bufer Size support. It can be used for capping frame size.
853  * Support added from NvEncodeAPI version 2.0.
854  * \n 0 : Custom VBV buffer size specification from client, not supported.
855  * \n 1 : Custom VBV buffer size specification from client, supported.
856  */
858 
859  /**
860  * Indicates Dynamic Slice Mode Support.
861  * Support added from NvEncodeAPI version 2.0.
862  * \n 0 : Dynamic Slice Mode not supported.
863  * \n 1 : Dynamic Slice Mode supported.
864  */
866 
867  /**
868  * Indicates Reference Picture Invalidation Support.
869  * Support added from NvEncodeAPI version 2.0.
870  * \n 0 : Reference Picture Invalidation not supported.
871  * \n 1 : Reference Picture Invalidation supported.
872  */
874 
875  /**
876  * Indicates support for PreProcessing.
877  * The API return value is a bitmask of the values defined in ::NV_ENC_PREPROC_FLAGS
878  */
880 
881  /**
882  * Indicates support Async mode.
883  * \n 0 : Async Encode mode not supported.
884  * \n 1 : Async Encode mode supported.
885  */
887 
888  /**
889  * Maximum MBs per frame supported.
890  */
892 
893  /**
894  * Maximum aggregate throughput in MBs per sec.
895  */
897 
898  /**
899  * Indicates HW support for YUV444 mode encoding.
900  * \n 0 : YUV444 mode encoding not supported.
901  * \n 1 : YUV444 mode encoding supported.
902  */
904 
905  /**
906  * Indicates HW support for lossless encoding.
907  * \n 0 : lossless encoding not supported.
908  * \n 1 : lossless encoding supported.
909  */
911 
912  /**
913  * Indicates HW support for Sample Adaptive Offset.
914  * \n 0 : SAO not supported.
915  * \n 1 : SAO encoding supported.
916  */
918 
919  /**
920  * Indicates HW support for MEOnly Mode.
921  * \n 0 : MEOnly Mode not supported.
922  * \n 1 : MEOnly Mode supported for I and P frames.
923  * \n 2 : MEOnly Mode supported for I, P and B frames.
924  */
926 
927  /**
928  * Indicates HW support for lookahead encoding (enableLookahead=1).
929  * \n 0 : Lookahead not supported.
930  * \n 1 : Lookahead supported.
931  */
933 
934  /**
935  * Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
936  * \n 0 : Temporal AQ not supported.
937  * \n 1 : Temporal AQ supported.
938  */
940  /**
941  * Indicates HW support for 10 bit encoding.
942  * \n 0 : 10 bit encoding not supported.
943  * \n 1 : 10 bit encoding supported.
944  */
946  /**
947  * Maximum number of Long Term Reference frames supported
948  */
950 
951  /**
952  * Indicates HW support for Weighted Predicition.
953  * \n 0 : Weighted Predicition not supported.
954  * \n 1 : Weighted Predicition supported.
955  */
957 
958  /**
959  * Reserved - Not to be used by clients.
960  */
962 } NV_ENC_CAPS;
963 
964 /**
965  * HEVC CU SIZE
966  */
967 typedef enum _NV_ENC_HEVC_CUSIZE
968 {
975 
976 /**
977  * Input struct for querying Encoding capabilities.
978  */
979 typedef struct _NV_ENC_CAPS_PARAM
980 {
981  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CAPS_PARAM_VER */
982  NV_ENC_CAPS capsToQuery; /**< [in]: Specifies the encode capability to be queried. Client should pass a member for ::NV_ENC_CAPS enum. */
983  uint32_t reserved[62]; /**< [in]: Reserved and must be set to 0 */
985 
986 /** NV_ENC_CAPS_PARAM struct version. */
987 #define NV_ENC_CAPS_PARAM_VER NVENCAPI_STRUCT_VERSION(1)
988 
989 
990 /**
991  * Creation parameters for input buffer.
992  */
993 typedef struct _NV_ENC_CREATE_INPUT_BUFFER
994 {
995  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER */
996  uint32_t width; /**< [in]: Input buffer width */
997  uint32_t height; /**< [in]: Input buffer width */
998  NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
999  NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Input buffer format */
1000  uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
1001  NV_ENC_INPUT_PTR inputBuffer; /**< [out]: Pointer to input buffer */
1002  void* pSysMemBuffer; /**< [in]: Pointer to existing sysmem buffer */
1003  uint32_t reserved1[57]; /**< [in]: Reserved and must be set to 0 */
1004  void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
1006 
1007 /** NV_ENC_CREATE_INPUT_BUFFER struct version. */
1008 #define NV_ENC_CREATE_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
1009 
1010 /**
1011  * Creation parameters for output bitstream buffer.
1012  */
1013 typedef struct _NV_ENC_CREATE_BITSTREAM_BUFFER
1014 {
1015  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER */
1016  uint32_t size; /**< [in]: Deprecated. Do not use */
1017  NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
1018  uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
1019  NV_ENC_OUTPUT_PTR bitstreamBuffer; /**< [out]: Pointer to the output bitstream buffer */
1020  void* bitstreamBufferPtr; /**< [out]: Reserved and should not be used */
1021  uint32_t reserved1[58]; /**< [in]: Reserved and should be set to 0 */
1022  void* reserved2[64]; /**< [in]: Reserved and should be set to NULL */
1024 
1025 /** NV_ENC_CREATE_BITSTREAM_BUFFER struct version. */
1026 #define NV_ENC_CREATE_BITSTREAM_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
1027 
1028 /**
1029  * Structs needed for ME only mode.
1030  */
1031 typedef struct _NV_ENC_MVECTOR
1032 {
1033  int16_t mvx; /**< the x component of MV in qpel units */
1034  int16_t mvy; /**< the y component of MV in qpel units */
1035 } NV_ENC_MVECTOR;
1036 
1037 /**
1038  * Motion vector structure per macroblock for H264 motion estimation.
1039  */
1040 typedef struct _NV_ENC_H264_MV_DATA
1041 {
1042  NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors for 8x8 partition */
1043  uint8_t mbType; /**< 0 (I), 1 (P), 2 (IPCM), 3 (B) */
1044  uint8_t partitionType; /**< Specifies the block partition type. 0:16x16, 1:8x8, 2:16x8, 3:8x16 */
1045  uint16_t reserved; /**< reserved padding for alignment */
1046  uint32_t mbCost;
1048 
1049 /**
1050  * Motion vector structure per CU for HEVC motion estimation.
1051  */
1052 typedef struct _NV_ENC_HEVC_MV_DATA
1053 {
1054  NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors within a CU */
1055  uint8_t cuType; /**< 0 (I), 1(P), 2 (Skip) */
1056  uint8_t cuSize; /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
1057  uint8_t partitionMode; /**< The CU partition mode
1058  0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
1059  4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N) */
1060  uint8_t lastCUInCTB; /**< Marker to separate CUs in the current CTB from CUs in the next CTB */
1062 
1063 /**
1064  * Creation parameters for output motion vector buffer for ME only mode.
1065  */
1066 typedef struct _NV_ENC_CREATE_MV_BUFFER
1067 {
1068  uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_CREATE_MV_BUFFER_VER */
1069  NV_ENC_OUTPUT_PTR mvBuffer; /**< [out]: Pointer to the output motion vector buffer */
1070  uint32_t reserved1[255]; /**< [in]: Reserved and should be set to 0 */
1071  void* reserved2[63]; /**< [in]: Reserved and should be set to NULL */
1073 
1074 /** NV_ENC_CREATE_MV_BUFFER struct version*/
1075 #define NV_ENC_CREATE_MV_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
1076 
1077 /**
1078  * QP value for frames
1079  */
1080 typedef struct _NV_ENC_QP
1081 {
1082  uint32_t qpInterP;
1083  uint32_t qpInterB;
1084  uint32_t qpIntra;
1085 } NV_ENC_QP;
1086 
1087 /**
1088  * Rate Control Configuration Paramters
1089  */
1090  typedef struct _NV_ENC_RC_PARAMS
1091  {
1092  uint32_t version;
1093  NV_ENC_PARAMS_RC_MODE rateControlMode; /**< [in]: Specifies the rate control mode. Check support for various rate control modes using ::NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES caps. */
1094  NV_ENC_QP constQP; /**< [in]: Specifies the initial QP to be used for encoding, these values would be used for all frames if in Constant QP mode. */
1095  uint32_t averageBitRate; /**< [in]: Specifies the average bitrate(in bits/sec) used for encoding. */
1096  uint32_t maxBitRate; /**< [in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode. */
1097  uint32_t vbvBufferSize; /**< [in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size. */
1098  uint32_t vbvInitialDelay; /**< [in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay .*/
1099  uint32_t enableMinQP :1; /**< [in]: Set this to 1 if minimum QP used for rate control. */
1100  uint32_t enableMaxQP :1; /**< [in]: Set this to 1 if maximum QP used for rate control. */
1101  uint32_t enableInitialRCQP :1; /**< [in]: Set this to 1 if user suppplied initial QP is used for rate control. */
1102  uint32_t enableAQ :1; /**< [in]: Set this to 1 to enable adaptive quantization (Spatial). */
1103  uint32_t enableExtQPDeltaMap :1; /**< [in]: Set this to 1 to enable additional QP modifier for each MB supplied by client though signed byte array pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap (Not Supported when AQ(Spatial/Temporal) is enabled) */
1104  uint32_t enableLookahead :1; /**< [in]: Set this to 1 to enable lookahead with depth <lookaheadDepth> (if lookahead is enabled, input frames must remain available to the encoder until encode completion) */
1105  uint32_t disableIadapt :1; /**< [in]: Set this to 1 to disable adaptive I-frame insertion at scene cuts (only has an effect when lookahead is enabled) */
1106  uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */
1107  uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ for H.264 */
1108  uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */
1109  uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */
1110  uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */
1111  uint32_t aqStrength :4; /**< [in]: When AQ (Spatial) is enabled (i.e. NV_ENC_RC_PARAMS::enableAQ is set), this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive). If not set, strength is autoselected by driver. */
1112  uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */
1113  NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */
1114  NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */
1115  NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */
1116  uint32_t temporallayerIdxMask; /**< [in]: Specifies the temporal layers (as a bitmask) whose QPs have changed. Valid max bitmask is [2^NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS - 1] */
1117  uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as as the array index */
1118  uint8_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */
1119  uint8_t targetQualityLSB; /**< [in]: Fractional part of target quality (as 8.8 fixed point format) */
1120  uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1) */
1121  uint32_t reserved[9];
1122  } NV_ENC_RC_PARAMS;
1123 
1124 /** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */
1125 #define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
1126 
1127 
1128 
1129 /**
1130  * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
1131  * H264 Video Usability Info parameters
1132  */
1134 {
1135  uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */
1136  uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */
1137  uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
1138  uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
1139  uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
1140  uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
1141  uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
1142  uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
1143  uint32_t colourMatrix; /**< [in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification). */
1144  uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
1145  uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
1146  uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
1147  uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
1148  uint32_t reserved[15];
1150 
1152 
1153 /**
1154  * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
1155  * External motion vector hint counts per block type.
1156  * H264 supports multiple hint while HEVC supports one hint for each valid candidate.
1157  */
1159 {
1160  uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Supported for H264,HEVC.It Specifies the number of candidates per 16x16 block. */
1161  uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Supported for H264 only.Specifies the number of candidates per 16x8 block. */
1162  uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Supported for H264 only.Specifies the number of candidates per 8x16 block. */
1163  uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Supported for H264,HEVC.Specifies the number of candidates per 8x8 block. */
1164  uint32_t reserved : 16; /**< [in]: Reserved for padding. */
1165  uint32_t reserved1[3]; /**< [in]: Reserved for future use. */
1167 
1168 
1169 /**
1170  * \struct _NVENC_EXTERNAL_ME_HINT
1171  * External Motion Vector hint structure.
1172  */
1174 {
1175  int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */
1176  int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/
1177  int32_t refidx : 5; /**< [in]: Specifies the reference index (31=invalid). Current we support only 1 reference frame per direction for external hints, so \p refidx must be 0. */
1178  int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
1179  int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/
1180  int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */
1181  int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */
1183 
1184 
1185 /**
1186  * \struct _NV_ENC_CONFIG_H264
1187  * H264 encoder configuration parameters
1188  */
1189 typedef struct _NV_ENC_CONFIG_H264
1190 {
1191  uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/
1192  uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/
1193  uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical PFrames */
1194  uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical BFrames */
1195  uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */
1196  uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream. When set for following rateControlMode : NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ,
1197  NV_ENC_PARAMS_RC_CBR_HQ, filler data is inserted if needed to achieve hrd bitrate */
1198  uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */
1199  uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */
1200  uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */
1201  uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
1202  uint32_t enableIntraRefresh :1; /**< [in]: Set to 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */
1203  uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constarined picture is independent of other slices
1204  Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
1205  uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */
1206  uint32_t enableVFR :1; /**< [in]: Set to 1 to enable variable frame rate. */
1207  uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
1208  LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
1209  Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future.
1210  LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
1211  ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
1212  for using LTR.
1213  Note that LTRs are not supported if encoding session is configured with B-frames */
1214  uint32_t qpPrimeYZeroTransformBypassFlag :1; /**< [in]: To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP and profile to HIGH_444_PREDICTIVE_PROFILE.
1215  Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */
1216  uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
1217  uint32_t reservedBitFields :15; /**< [in]: Reserved bitfields and must be set to 0 */
1218  uint32_t level; /**< [in]: Specifies the encoding level. Client is recommended to set this to NV_ENC_LEVEL_AUTOSELECT in order to enable the NvEncodeAPI interface to select the correct level. */
1219  uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */
1220  uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */
1221  uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2] */
1222  uint32_t numTemporalLayers; /**< [in]: Specifies max temporal layers to be used for hierarchical coding. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */
1223  uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
1224  uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
1225  NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode; /**< [in]: Specifies the AdaptiveTransform Mode. Check support for AdaptiveTransform mode using ::NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM caps. */
1226  NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */
1227  NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/
1228  NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode; /**< [in]: Specifies the entropy coding mode. Check support for CABAC mode using ::NV_ENC_CAPS_SUPPORT_CABAC caps. */
1229  NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement SEI */
1230  uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
1231  Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
1232  uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */
1233  uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default dpb size.
1234  The low latency application which wants to invalidate reference frame as an error resilience tool
1235  is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
1236  frames are invalidated. */
1237  uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
1238  sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
1239  When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
1240  When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
1241  uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
1242  sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
1243  sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
1244  sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
1245  sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
1246  NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info pamameters */
1247  uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames. This parameter has different meaning in two LTR modes.
1248  In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
1249  In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
1250  uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_H264::enableLTR for description of the two modes.
1251  Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
1252  be deprecated in future releases.
1253  Set to 0 when using "LTR Per Picture" mode of LTR operation. */
1254  uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
1255  Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/
1256  uint32_t maxTemporalLayers; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
1257  uint32_t reserved1[270]; /**< [in]: Reserved and must be set to 0 */
1258  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1260 
1261 
1262 /**
1263  * \struct _NV_ENC_CONFIG_HEVC
1264  * HEVC encoder configuration parameters to be set during initialization.
1265  */
1266 typedef struct _NV_ENC_CONFIG_HEVC
1267 {
1268  uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
1269  uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
1270  NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/
1271  NV_ENC_HEVC_CUSIZE maxCUSize; /**< [in]: Specifies the maximum size of luma coding unit. Currently NVENC SDK only supports maxCUSize equal to NV_ENC_HEVC_CUSIZE_32x32.*/
1272  uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
1273  uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/
1274  uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */
1275  uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */
1276  uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */
1277  uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
1278  LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
1279  Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future releases.
1280  LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
1281  ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
1282  for using LTR.
1283  Note that LTRs are not supported if encoding session is configured with B-frames */
1284  uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS,SPS and PPS signalling in the bitstream. */
1285  uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/
1286  uint32_t enableIntraRefresh :1; /**< [in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */
1287  uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/
1288  uint32_t pixelBitDepthMinus8 :3; /**< [in]: Specifies pixel bit depth minus 8. Should be set to 0 for 8 bit input, 2 for 10 bit input.*/
1289  uint32_t reserved :18; /**< [in]: Reserved bitfields.*/
1290  uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */
1291  uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
1292  Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
1293  uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */
1294  uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
1295  uint32_t ltrNumFrames; /**< [in]: This parameter has different meaning in two LTR modes.
1296  In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
1297  In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
1298  uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set */
1299  uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
1300  uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
1301  uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
1302  sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
1303  When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
1304  uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
1305  sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
1306  sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
1307  sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
1308  sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
1309  uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
1310  NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info pamameters */
1311  uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_HEVC::enableLTR for description of the two modes.
1312  Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
1313  be deprecated in future releases.
1314  Set to 0 when using "LTR Per Picture" mode of LTR operation. */
1315  uint32_t reserved1[217]; /**< [in]: Reserved and must be set to 0.*/
1316  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1318 
1319 /**
1320  * \struct _NV_ENC_CONFIG_H264_MEONLY
1321  * H264 encoder configuration parameters for ME only Mode
1322  *
1323  */
1325 {
1326  uint32_t disablePartition16x16 :1; /**< [in]: Disable MotionEstimation on 16x16 blocks*/
1327  uint32_t disablePartition8x16 :1; /**< [in]: Disable MotionEstimation on 8x16 blocks*/
1328  uint32_t disablePartition16x8 :1; /**< [in]: Disable MotionEstimation on 16x8 blocks*/
1329  uint32_t disablePartition8x8 :1; /**< [in]: Disable MotionEstimation on 8x8 blocks*/
1330  uint32_t disableIntraSearch :1; /**< [in]: Disable Intra search during MotionEstimation*/
1331  uint32_t bStereoEnable :1; /**< [in]: Enable Stereo Mode for Motion Estimation where each view is independently executed*/
1332  uint32_t reserved :26; /**< [in]: Reserved and must be set to 0 */
1333  uint32_t reserved1 [255]; /**< [in]: Reserved and must be set to 0 */
1334  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1336 
1337 
1338 /**
1339  * \struct _NV_ENC_CONFIG_HEVC_MEONLY
1340  * HEVC encoder configuration parameters for ME only Mode
1341  *
1342  */
1344 {
1345  uint32_t reserved [256]; /**< [in]: Reserved and must be set to 0 */
1346  void* reserved1[64]; /**< [in]: Reserved and must be set to NULL */
1348 
1349 /**
1350  * \struct _NV_ENC_CODEC_CONFIG
1351  * Codec-specific encoder configuration parameters to be set during initialization.
1352  */
1354 {
1355  NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */
1356  NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */
1357  NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig; /**< [in]: Specifies the H.264-specific ME only encoder configuration. */
1358  NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig; /**< [in]: Specifies the HEVC-specific ME only encoder configuration. */
1359  uint32_t reserved[320]; /**< [in]: Reserved and must be set to 0 */
1361 
1362 
1363 /**
1364  * \struct _NV_ENC_CONFIG
1365  * Encoder configuration parameters to be set during initialization.
1366  */
1367 typedef struct _NV_ENC_CONFIG
1368 {
1369  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */
1370  GUID profileGUID; /**< [in]: Specifies the codec profile guid. If client specifies \p NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID the NvEncodeAPI interface will select the appropriate codec profile. */
1371  uint32_t gopLength; /**< [in]: Specifies the number of pictures in one GOP. Low latency application client can set goplength to NVENC_INFINITE_GOPLENGTH so that keyframes are not inserted automatically. */
1372  int32_t frameIntervalP; /**< [in]: Specifies the GOP pattern as follows: \p frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH \p frameIntervalP should be set to 1. */
1373  uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */
1374  NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode.
1375  Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
1376  Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */
1377  NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */
1378  NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */
1379  NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */
1380  uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */
1381  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1382 } NV_ENC_CONFIG;
1383 
1384 /** macro for constructing the version field of ::_NV_ENC_CONFIG */
1385 #define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(6) | ( 1<<31 ))
1386 
1387 
1388 /**
1389  * \struct _NV_ENC_INITIALIZE_PARAMS
1390  * Encode Session Initialization parameters.
1391  */
1393 {
1394  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
1395  GUID encodeGUID; /**< [in]: Specifies the Encode GUID for which the encoder is being created. ::NvEncInitializeEncoder() API will fail if this is not set, or set to unsupported value. */
1396  GUID presetGUID; /**< [in]: Specifies the preset for encoding. If the preset GUID is set then , the preset configuration will be applied before any other parameter. */
1397  uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */
1398  uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */
1399  uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */
1400  uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */
1401  uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
1402  uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
1403  uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */
1404  uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */
1405  uint32_t reportSliceOffsets :1; /**< [in]: Set this to 1 to enable reporting slice offsets in ::_NV_ENC_LOCK_BITSTREAM. NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync must be set to 0 to use this feature. Client must set this to 0 if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs */
1406  uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals */
1407  uint32_t enableExternalMEHints :1; /**< [in]: Set to 1 to enable external ME hints for the current frame. For NV_ENC_INITIALIZE_PARAMS::enablePTD=1 with B frames, programming L1 hints is optional for B frames since Client doesn't know internal GOP structure.
1408  NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
1409  uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/
1410  uint32_t enableWeightedPrediction :1; /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames( 'frameIntervalP' in NV_ENC_CONFIG is greater than 1).*/
1411  uint32_t reservedBitFields :27; /**< [in]: Reserved bitfields and must be set to 0 */
1412  uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */
1413  void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */
1414  NV_ENC_CONFIG* encodeConfig; /**< [in]: Specifies the advanced codec specific structure. If client has sent a valid codec config structure, it will override parameters set by the NV_ENC_INITIALIZE_PARAMS::presetGUID parameter. If set to NULL the NvEncodeAPI interface will use the NV_ENC_INITIALIZE_PARAMS::presetGUID to set the codec specific parameters.
1415  Client can also optionally query the NvEncodeAPI interface to get codec specific parameters for a presetGUID using ::NvEncGetEncodePresetConfig() API. It can then modify (if required) some of the codec config parameters and send down a custom config structure as part of ::_NV_ENC_INITIALIZE_PARAMS.
1416  Even in this case client is recommended to pass the same preset guid it has used in ::NvEncGetEncodePresetConfig() API to query the config structure; as NV_ENC_INITIALIZE_PARAMS::presetGUID. This will not override the custom config structure but will be used to determine other Encoder HW specific parameters not exposed in the API. */
1417  uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session.
1418  Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */
1419  uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session.
1420  Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */
1421  NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE maxMEHintCountsPerBlock[2]; /**< [in]: If Client wants to pass external motion vectors in NV_ENC_PIC_PARAMS::meExternalHints buffer it must specify the maximum number of hint candidates per block per direction for the encode session.
1422  The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
1423  This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */
1424  uint32_t reserved [289]; /**< [in]: Reserved and must be set to 0 */
1425  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1427 
1428 /** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */
1429 #define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1<<31 ))
1430 
1431 
1432 /**
1433  * \struct _NV_ENC_RECONFIGURE_PARAMS
1434  * Encode Session Reconfigured parameters.
1435  */
1437 {
1438  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */
1439  NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters. */
1440  uint32_t resetEncoder :1; /**< [in]: This resets the rate control states and other internal encoder states. This should be used only with an IDR frame.
1441  If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */
1442  uint32_t forceIDR :1; /**< [in]: Encode the current picture as an IDR picture. This flag is only valid when Picture type decision is taken by the Encoder
1443  [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
1444  uint32_t reserved :30;
1445 
1447 
1448 /** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */
1449 #define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 ))
1450 
1451 /**
1452  * \struct _NV_ENC_PRESET_CONFIG
1453  * Encoder preset config
1454  */
1456 {
1457  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */
1458  NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */
1459  uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */
1460  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1462 
1463 /** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */
1464 #define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
1465 
1466 
1467 /**
1468  * \struct _NV_ENC_SEI_PAYLOAD
1469  * User SEI message
1470  */
1471 typedef struct _NV_ENC_SEI_PAYLOAD
1472 {
1473  uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */
1474  uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */
1475  uint8_t *payload; /**< [in] pointer to user data */
1477 
1478 #define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
1479 
1480 /**
1481  * \struct _NV_ENC_PIC_PARAMS_H264
1482  * H264 specific enc pic params. sent on a per frame basis.
1483  */
1485 {
1486  uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
1487  uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */
1488  uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
1489  uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */
1490  uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
1491  When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
1492  forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
1493  uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
1494  NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
1495  uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
1496  When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
1497  uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
1498  uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
1499  uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
1500  uint8_t* sliceTypeData; /**< [in]: Deprecated. */
1501  uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */
1502  uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
1503  NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
1504  uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
1505  sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
1506  When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
1507  When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
1508  uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
1509  sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
1510  sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
1511  sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
1512  sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
1513  uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
1514  uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the the associated bitmap of LTR frame indices to use when encoding this frame. */
1515  uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
1516  uint32_t reserved [243]; /**< [in]: Reserved and must be set to 0. */
1517  void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */
1519 
1520 /**
1521  * \struct _NV_ENC_PIC_PARAMS_HEVC
1522  * HEVC specific enc pic params. sent on a per frame basis.
1523  */
1525 {
1526  uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
1527  uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
1528  uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
1529  uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
1530  When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
1531  forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
1532  uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
1533  NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
1534  uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
1535  When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
1536  uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
1537  uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
1538  uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
1539  uint8_t* sliceTypeData; /**< [in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3.
1540  Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
1541  Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I
1542  all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */
1543  uint32_t sliceTypeArrayCnt; /**< [in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0 */
1544  uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
1545  sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
1546  When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
1547  When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
1548  uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
1549  sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
1550  sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
1551  sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
1552  sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
1553  uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/
1554  uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
1555  uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
1556  uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
1557  uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
1558  NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
1559  uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */
1560  void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
1562 
1563 
1564 /**
1565  * Codec specific per-picture encoding parameters.
1566  */
1567 typedef union _NV_ENC_CODEC_PIC_PARAMS
1568 {
1569  NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */
1570  NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. */
1571  uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */
1573 
1574 /**
1575  * \struct _NV_ENC_PIC_PARAMS
1576  * Encoding parameters that need to be sent on a per frame basis.
1577  */
1578 typedef struct _NV_ENC_PIC_PARAMS
1579 {
1580  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */
1581  uint32_t inputWidth; /**< [in]: Specifies the input buffer width */
1582  uint32_t inputHeight; /**< [in]: Specifies the input buffer height */
1583  uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */
1584  uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR`ed encode pic flags. See ::NV_ENC_PIC_FLAGS enum. */
1585  uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */
1586  uint64_t inputTimeStamp; /**< [in]: Specifies presentation timestamp associated with the input picture. */
1587  uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */
1588  NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
1589  NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API. */
1590  void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
1591  NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
1592  NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */
1593  NV_ENC_PIC_TYPE pictureType; /**< [in]: Specifies input picture type. Client required to be set explicitly by the client if the client has not set NV_ENC_INITALIZE_PARAMS::enablePTD to 1 while calling NvInitializeEncoder. */
1594  NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */
1595  NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block per direction for the current frame. meHintCountsPerBlock[0] is for L0 predictors and meHintCountsPerBlock[1] is for L1 predictors.
1596  The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */
1597  NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
1598  The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
1599  + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */
1600  uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */
1601  void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */
1602  int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing QP delta value per MB in raster scan order in the current picture. This QP modifier is applied on top of the QP chosen by rate control. */
1603  uint32_t qpDeltaMapSize; /**< [in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap. Surface (array) should be picWidthInMbs * picHeightInMbs */
1604  uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */
1605  uint16_t meHintRefPicDist[2]; /**< [in]: Specifies temporal distance for reference picture (NVENC_EXTERNAL_ME_HINT::refidx = 0) used during external ME with NV_ENC_INITALIZE_PARAMS::enablePTD = 1 . meHintRefPicDist[0] is for L0 hints and meHintRefPicDist[1] is for L1 hints.
1606  If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */
1607  uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */
1608  void* reserved4[60]; /**< [in]: Reserved and must be set to NULL */
1610 
1611 /** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */
1612 #define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
1613 
1614 
1615 /**
1616  * \struct _NV_ENC_MEONLY_PARAMS
1617  * MEOnly parameters that need to be sent on a per motion estimation basis.
1618  * NV_ENC_MEONLY_PARAMS::meExternalHints is supported for H264 only.
1619  */
1621 {
1622  uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/
1623  uint32_t inputWidth; /**< [in]: Specifies the input buffer width */
1624  uint32_t inputHeight; /**< [in]: Specifies the input buffer height */
1625  NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
1626  NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */
1627  NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. */
1628  NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
1629  void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of motion estimation
1630  of this Frame [only if operating in Asynchronous mode].
1631  Each output buffer should be associated with a distinct event pointer. */
1632  uint32_t viewID; /**< [in]: Specifies left,right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set.
1633  viewID can be 0,1 if bStereoEnable is set, 0 otherwise. */
1635  meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block for the current frame. meHintCountsPerBlock[0] is for L0 predictors.
1636  The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */
1637  NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
1638  The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
1639  + 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */
1640  uint32_t reserved1[243]; /**< [in]: Reserved and must be set to 0 */
1641  void* reserved2[59]; /**< [in]: Reserved and must be set to NULL */
1643 
1644 /** NV_ENC_MEONLY_PARAMS struct version*/
1645 #define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(3)
1646 
1647 
1648 /**
1649  * \struct _NV_ENC_LOCK_BITSTREAM
1650  * Bitstream buffer lock parameters.
1651  */
1653 {
1654  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
1655  uint32_t doNotWait :1; /**< [in]: If this flag is set, the NvEncodeAPI interface will return buffer pointer even if operation is not completed. If not set, the call will block until operation completes. */
1656  uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
1657  uint32_t reservedBitFields :30; /**< [in]: Reserved bit fields and must be set to 0 */
1658  void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */
1659  uint32_t* sliceOffsets; /**< [in,out]: Array which receives the slice offsets. This is not supported if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs. Array size must be equal to size of frame in MBs. */
1660  uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */
1661  uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */
1662  uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */
1663  uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr. */
1664  uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */
1665  uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */
1666  void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream.
1667  For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to
1668  NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */
1669  NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */
1670  NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */
1671  uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
1672  uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */
1673  uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
1674  uint32_t ltrFrameBitmap; /**< [out]: Bitmap of LTR frames indices which were used for encoding this frame. Value of 0 if no LTR frames were used. */
1675  uint32_t reserved [236]; /**< [in]: Reserved and must be set to 0 */
1676  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1678 
1679 /** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */
1680 #define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1)
1681 
1682 
1683 /**
1684  * \struct _NV_ENC_LOCK_INPUT_BUFFER
1685  * Uncompressed Input Buffer lock parameters.
1686  */
1688 {
1689  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */
1690  uint32_t doNotWait :1; /**< [in]: Set to 1 to make ::NvEncLockInputBuffer() a unblocking call. If the encoding is not completed, driver will return ::NV_ENC_ERR_ENCODER_BUSY error code. */
1691  uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */
1692  NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource API. */
1693  void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */
1694  uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */
1695  uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */
1696  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1698 
1699 /** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */
1700 #define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
1701 
1702 
1703 /**
1704  * \struct _NV_ENC_MAP_INPUT_RESOURCE
1705  * Map an input resource to a Nvidia Encoder Input Buffer
1706  */
1708 {
1709  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */
1710  uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */
1711  void* inputResource; /**< [in]: Deprecated. Do not use. */
1712  NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */
1713  NV_ENC_INPUT_PTR mappedResource; /**< [out]: Mapped pointer corresponding to the registeredResource. This pointer must be used in NV_ENC_PIC_PARAMS::inputBuffer parameter in ::NvEncEncodePicture() API. */
1714  NV_ENC_BUFFER_FORMAT mappedBufferFmt; /**< [out]: Buffer format of the outputResource. This buffer format must be used in NV_ENC_PIC_PARAMS::bufferFmt if client using the above mapped resource pointer. */
1715  uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */
1716  void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
1718 
1719 /** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */
1720 #define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
1721 
1722 /**
1723  * \struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
1724  * NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type,
1725  * when NV_ENC_REGISTER_RESOURCE::resourceType is NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX
1726  */
1728 {
1729  uint32_t texture; /**< [in]: The name of the texture to be used. */
1730  uint32_t target; /**< [in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D. */
1732 
1733 /**
1734  * \struct _NV_ENC_REGISTER_RESOURCE
1735  * Register a resource for future use with the Nvidia Video Encoder Interface.
1736  */
1738 {
1739  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */
1740  NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered.
1741  Supported values are
1742  ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX,
1743  ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR,
1744  ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */
1745  uint32_t width; /**< [in]: Input buffer Width. */
1746  uint32_t height; /**< [in]: Input buffer Height. */
1747  uint32_t pitch; /**< [in]: Input buffer Pitch. */
1748  uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
1749  void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */
1750  NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
1751  NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */
1752  uint32_t reserved1[248]; /**< [in]: Reserved and must be set to 0. */
1753  void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */
1755 
1756 /** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */
1757 #define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3)
1758 
1759 /**
1760  * \struct _NV_ENC_STAT
1761  * Encode Stats structure.
1762  */
1763 typedef struct _NV_ENC_STAT
1764 {
1765  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */
1766  uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
1767  NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */
1768  uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */
1769  uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */
1770  uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */
1771  uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */
1772  uint32_t picIdx; /**< [out]: Picture number */
1773  uint32_t reserved1[233]; /**< [in]: Reserved and must be set to 0 */
1774  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1775 } NV_ENC_STAT;
1776 
1777 /** Macro for constructing the version field of ::_NV_ENC_STAT */
1778 #define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1)
1779 
1780 
1781 /**
1782  * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
1783  * Sequence and picture paramaters payload.
1784  */
1786 {
1787  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
1788  uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provied by the client */
1789  uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */
1790  uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */
1791  void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize. It is the client's responsibility to manage this memory. */
1792  uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes written by the NvEncodeAPI interface to the SPSPPSBuffer. */
1793  uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */
1794  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1796 
1797 /** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */
1798 #define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1)
1799 
1800 
1801 /**
1802  * Event registration/unregistration parameters.
1803  */
1804 typedef struct _NV_ENC_EVENT_PARAMS
1805 {
1806  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */
1807  uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
1808  void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */
1809  uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
1810  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1812 
1813 /** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */
1814 #define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
1815 
1816 /**
1817  * Encoder Session Creation parameters
1818  */
1819 typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS
1820 {
1821  uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */
1822  NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */
1823  void* device; /**< [in]: Pointer to client device. */
1824  void* reserved; /**< [in]: Reserved and must be set to 0. */
1825  uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */
1826  uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
1827  void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
1829 /** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */
1830 #define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
1831 
1832 /** @} */ /* END ENCODER_STRUCTURE */
1833 
1834 
1835 /**
1836  * \addtogroup ENCODE_FUNC NvEncodeAPI Functions
1837  * @{
1838  */
1839 
1840 // NvEncOpenEncodeSession
1841 /**
1842  * \brief Opens an encoding session.
1843  *
1844  * Deprecated.
1845  *
1846  * \return
1847  * ::NV_ENC_ERR_INVALID_CALL\n
1848  *
1849  */
1850 NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder);
1851 
1852 // NvEncGetEncodeGuidCount
1853 /**
1854  * \brief Retrieves the number of supported encode GUIDs.
1855  *
1856  * The function returns the number of codec guids supported by the NvEncodeAPI
1857  * interface.
1858  *
1859  * \param [in] encoder
1860  * Pointer to the NvEncodeAPI interface.
1861  * \param [out] encodeGUIDCount
1862  * Number of supported encode GUIDs.
1863  *
1864  * \return
1865  * ::NV_ENC_SUCCESS \n
1866  * ::NV_ENC_ERR_INVALID_PTR \n
1867  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
1868  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
1869  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
1870  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
1871  * ::NV_ENC_ERR_INVALID_PARAM \n
1872  * ::NV_ENC_ERR_GENERIC \n
1873  *
1874  */
1875 NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount);
1876 
1877 
1878 // NvEncGetEncodeGUIDs
1879 /**
1880  * \brief Retrieves an array of supported encoder codec GUIDs.
1881  *
1882  * The function returns an array of codec guids supported by the NvEncodeAPI interface.
1883  * The client must allocate an array where the NvEncodeAPI interface can
1884  * fill the supported guids and pass the pointer in \p *GUIDs parameter.
1885  * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API.
1886  * The Nvidia Encoding interface returns the number of codec guids it has actually
1887  * filled in the guid array in the \p GUIDCount parameter.
1888  *
1889  * \param [in] encoder
1890  * Pointer to the NvEncodeAPI interface.
1891  * \param [in] guidArraySize
1892  * Number of GUIDs to retrieved. Should be set to the number retrieved using
1893  * ::NvEncGetEncodeGUIDCount.
1894  * \param [out] GUIDs
1895  * Array of supported Encode GUIDs.
1896  * \param [out] GUIDCount
1897  * Number of supported Encode GUIDs.
1898  *
1899  * \return
1900  * ::NV_ENC_SUCCESS \n
1901  * ::NV_ENC_ERR_INVALID_PTR \n
1902  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
1903  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
1904  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
1905  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
1906  * ::NV_ENC_ERR_INVALID_PARAM \n
1907  * ::NV_ENC_ERR_GENERIC \n
1908  *
1909  */
1910 NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
1911 
1912 
1913 // NvEncGetEncodeProfileGuidCount
1914 /**
1915  * \brief Retrieves the number of supported profile GUIDs.
1916  *
1917  * The function returns the number of profile GUIDs supported for a given codec.
1918  * The client must first enumerate the codec guids supported by the NvEncodeAPI
1919  * interface. After determining the codec guid, it can query the NvEncodeAPI
1920  * interface to determine the number of profile guids supported for a particular
1921  * codec guid.
1922  *
1923  * \param [in] encoder
1924  * Pointer to the NvEncodeAPI interface.
1925  * \param [in] encodeGUID
1926  * The codec guid for which the profile guids are being enumerated.
1927  * \param [out] encodeProfileGUIDCount
1928  * Number of encode profiles supported for the given encodeGUID.
1929  *
1930  * \return
1931  * ::NV_ENC_SUCCESS \n
1932  * ::NV_ENC_ERR_INVALID_PTR \n
1933  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
1934  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
1935  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
1936  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
1937  * ::NV_ENC_ERR_INVALID_PARAM \n
1938  * ::NV_ENC_ERR_GENERIC \n
1939  *
1940  */
1941 NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
1942 
1943 
1944 // NvEncGetEncodeProfileGUIDs
1945 /**
1946  * \brief Retrieves an array of supported encode profile GUIDs.
1947  *
1948  * The function returns an array of supported profile guids for a particular
1949  * codec guid. The client must allocate an array where the NvEncodeAPI interface
1950  * can populate the profile guids. The client can determine the array size using
1951  * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the
1952  * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID
1953  * parameter.
1954  *
1955  * \param [in] encoder
1956  * Pointer to the NvEncodeAPI interface.
1957  * \param [in] encodeGUID
1958  * The encode guid whose profile guids are being enumerated.
1959  * \param [in] guidArraySize
1960  * Number of GUIDs to be retrieved. Should be set to the number retrieved using
1961  * ::NvEncGetEncodeProfileGUIDCount.
1962  * \param [out] profileGUIDs
1963  * Array of supported Encode Profile GUIDs
1964  * \param [out] GUIDCount
1965  * Number of valid encode profile GUIDs in \p profileGUIDs array.
1966  *
1967  * \return
1968  * ::NV_ENC_SUCCESS \n
1969  * ::NV_ENC_ERR_INVALID_PTR \n
1970  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
1971  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
1972  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
1973  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
1974  * ::NV_ENC_ERR_INVALID_PARAM \n
1975  * ::NV_ENC_ERR_GENERIC \n
1976  *
1977  */
1978 NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
1979 
1980 // NvEncGetInputFormatCount
1981 /**
1982  * \brief Retrieve the number of supported Input formats.
1983  *
1984  * The function returns the number of supported input formats. The client must
1985  * query the NvEncodeAPI interface to determine the supported input formats
1986  * before creating the input surfaces.
1987  *
1988  * \param [in] encoder
1989  * Pointer to the NvEncodeAPI interface.
1990  * \param [in] encodeGUID
1991  * Encode GUID, corresponding to which the number of supported input formats
1992  * is to be retrieved.
1993  * \param [out] inputFmtCount
1994  * Number of input formats supported for specified Encode GUID.
1995  *
1996  * \return
1997  * ::NV_ENC_SUCCESS \n
1998  * ::NV_ENC_ERR_INVALID_PTR \n
1999  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2000  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2001  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2002  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2003  * ::NV_ENC_ERR_INVALID_PARAM \n
2004  * ::NV_ENC_ERR_GENERIC \n
2005  */
2006 NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
2007 
2008 
2009 // NvEncGetInputFormats
2010 /**
2011  * \brief Retrieves an array of supported Input formats
2012  *
2013  * Returns an array of supported input formats The client must use the input
2014  * format to create input surface using ::NvEncCreateInputBuffer() API.
2015  *
2016  * \param [in] encoder
2017  * Pointer to the NvEncodeAPI interface.
2018  * \param [in] encodeGUID
2019  * Encode GUID, corresponding to which the number of supported input formats
2020  * is to be retrieved.
2021  *\param [in] inputFmtArraySize
2022  * Size input format count array passed in \p inputFmts.
2023  *\param [out] inputFmts
2024  * Array of input formats supported for this Encode GUID.
2025  *\param [out] inputFmtCount
2026  * The number of valid input format types returned by the NvEncodeAPI
2027  * interface in \p inputFmts array.
2028  *
2029  * \return
2030  * ::NV_ENC_SUCCESS \n
2031  * ::NV_ENC_ERR_INVALID_PTR \n
2032  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2033  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2034  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2035  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2036  * ::NV_ENC_ERR_INVALID_PARAM \n
2037  * ::NV_ENC_ERR_GENERIC \n
2038  *
2039  */
2040 NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
2041 
2042 
2043 // NvEncGetEncodeCaps
2044 /**
2045  * \brief Retrieves the capability value for a specified encoder attribute.
2046  *
2047  * The function returns the capability value for a given encoder attribute. The
2048  * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before
2049  * calling this function. The encoder attribute being queried are enumerated in
2050  * ::NV_ENC_CAPS_PARAM enum.
2051  *
2052  * \param [in] encoder
2053  * Pointer to the NvEncodeAPI interface.
2054  * \param [in] encodeGUID
2055  * Encode GUID, corresponding to which the capability attribute is to be retrieved.
2056  * \param [in] capsParam
2057  * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more
2058  * details.
2059  * \param [out] capsVal
2060  * The value corresponding to the capability attribute being queried.
2061  *
2062  * \return
2063  * ::NV_ENC_SUCCESS \n
2064  * ::NV_ENC_ERR_INVALID_PTR \n
2065  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2066  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2067  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2068  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2069  * ::NV_ENC_ERR_INVALID_PARAM \n
2070  * ::NV_ENC_ERR_GENERIC \n
2071  */
2072 NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
2073 
2074 
2075 // NvEncGetEncodePresetCount
2076 /**
2077  * \brief Retrieves the number of supported preset GUIDs.
2078  *
2079  * The function returns the number of preset GUIDs available for a given codec.
2080  * The client must validate the codec guid using ::NvEncGetEncodeGUIDs() API
2081  * before calling this function.
2082  *
2083  * \param [in] encoder
2084  * Pointer to the NvEncodeAPI interface.
2085  * \param [in] encodeGUID
2086  * Encode GUID, corresponding to which the number of supported presets is to
2087  * be retrieved.
2088  * \param [out] encodePresetGUIDCount
2089  * Receives the number of supported preset GUIDs.
2090  *
2091  * \return
2092  * ::NV_ENC_SUCCESS \n
2093  * ::NV_ENC_ERR_INVALID_PTR \n
2094  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2095  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2096  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2097  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2098  * ::NV_ENC_ERR_INVALID_PARAM \n
2099  * ::NV_ENC_ERR_GENERIC \n
2100  *
2101  */
2102 NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
2103 
2104 
2105 // NvEncGetEncodePresetGUIDs
2106 /**
2107  * \brief Receives an array of supported encoder preset GUIDs.
2108  *
2109  * The function returns an array of encode preset guids available for a given codec.
2110  * The client can directly use one of the preset guids based upon the use case
2111  * or target device. The preset guid chosen can be directly used in
2112  * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
2113  * Alternately client can also use the preset guid to retrieve the encoding config
2114  * parameters being used by NvEncodeAPI interface for that given preset, using
2115  * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
2116  * as per its use case and send it to NvEncodeAPI interface as part of
2117  * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
2118  * API.
2119  *
2120  *
2121  * \param [in] encoder
2122  * Pointer to the NvEncodeAPI interface.
2123  * \param [in] encodeGUID
2124  * Encode GUID, corresponding to which the list of supported presets is to be
2125  * retrieved.
2126  * \param [in] guidArraySize
2127  * Size of array of preset guids passed in \p preset GUIDs
2128  * \param [out] presetGUIDs
2129  * Array of supported Encode preset GUIDs from the NvEncodeAPI interface
2130  * to client.
2131  * \param [out] encodePresetGUIDCount
2132  * Receives the number of preset GUIDs returned by the NvEncodeAPI
2133  * interface.
2134  *
2135  * \return
2136  * ::NV_ENC_SUCCESS \n
2137  * ::NV_ENC_ERR_INVALID_PTR \n
2138  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2139  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2140  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2141  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2142  * ::NV_ENC_ERR_INVALID_PARAM \n
2143  * ::NV_ENC_ERR_GENERIC \n
2144  *
2145  */
2146 NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
2147 
2148 
2149 // NvEncGetEncodePresetConfig
2150 /**
2151  * \brief Returns a preset config structure supported for given preset GUID.
2152  *
2153  * The function returns a preset config structure for a given preset guid. Before
2154  * using this function the client must enumerate the preset guids available for
2155  * a given codec. The preset config structure can be modified by the client depending
2156  * upon its use case and can be then used to initialize the encoder using
2157  * ::NvEncInitializeEncoder() API. The client can use this function only if it
2158  * wants to modify the NvEncodeAPI preset configuration, otherwise it can
2159  * directly use the preset guid.
2160  *
2161  * \param [in] encoder
2162  * Pointer to the NvEncodeAPI interface.
2163  * \param [in] encodeGUID
2164  * Encode GUID, corresponding to which the list of supported presets is to be
2165  * retrieved.
2166  * \param [in] presetGUID
2167  * Preset GUID, corresponding to which the Encoding configurations is to be
2168  * retrieved.
2169  * \param [out] presetConfig
2170  * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
2171 * more details.
2172  *
2173  * \return
2174  * ::NV_ENC_SUCCESS \n
2175  * ::NV_ENC_ERR_INVALID_PTR \n
2176  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2177  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2178  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2179  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2180  * ::NV_ENC_ERR_INVALID_PARAM \n
2181  * ::NV_ENC_ERR_INVALID_VERSION \n
2182  * ::NV_ENC_ERR_GENERIC \n
2183  *
2184  */
2185 NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
2186 
2187 // NvEncInitializeEncoder
2188 /**
2189  * \brief Initialize the encoder.
2190  *
2191  * This API must be used to initialize the encoder. The initialization parameter
2192  * is passed using \p *createEncodeParams The client must send the following
2193  * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
2194  * - NV_ENC_INITIALIZE_PARAMS::encodeGUID
2195  * - NV_ENC_INITIALIZE_PARAMS::encodeWidth
2196  * - NV_ENC_INITIALIZE_PARAMS::encodeHeight
2197  *
2198  * The client can pass a preset guid directly to the NvEncodeAPI interface using
2199  * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
2200  * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
2201  * will be selected based on the preset guid. The preset guid must have been
2202  * validated by the client using ::NvEncGetEncodePresetGUIDs() API.
2203  * If the client passes a custom ::_NV_ENC_CONFIG structure through
2204  * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
2205  * based on the preset guid. It is recommended that even if the client passes a custom config,
2206  * it should also send a preset guid. In this case, the preset guid passed by the client
2207  * will not override any of the custom config parameters programmed by the client,
2208  * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
2209  * which are not exposed to the client.
2210  *
2211  * There are two modes of operation for the encoder namely:
2212  * - Asynchronous mode
2213  * - Synchronous mode
2214  *
2215  * The client can select asynchronous or synchronous mode by setting the \p
2216  * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
2217  *\par Asynchronous mode of operation:
2218  * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
2219  * The client operating in asynchronous mode must allocate completion event object
2220  * for each output buffer and pass the completion event object in the
2221  * ::NvEncEncodePicture() API. The client can create another thread and wait on
2222  * the event object to be signalled by NvEncodeAPI interface on completion of the
2223  * encoding process for the output frame. This should unblock the main thread from
2224  * submitting work to the encoder. When the event is signalled the client can call
2225  * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
2226  * API. This is the preferred mode of operation.
2227  *
2228  * NOTE: Asynchronous mode is not supported on Linux.
2229  *
2230  *\par Synchronous mode of operation:
2231  * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
2232  * The client working in synchronous mode can work in a single threaded or multi
2233  * threaded mode. The client need not allocate any event objects. The client can
2234  * only lock the bitstream data after NvEncodeAPI interface has returned
2235  * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
2236  * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
2237  * client must not lock the output buffer in such case but should send the next
2238  * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
2239  * until it returns ::NV_ENC_SUCCESS. \n
2240  * The client must always lock the bitstream data in order in which it has submitted.
2241  * This is true for both asynchronous and synchronous mode.
2242  *
2243  *\par Picture type decision:
2244  * If the client is taking the picture type decision and it must disable the picture
2245  * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
2246  * to 0. In this case the client is required to send the picture in encoding
2247  * order to NvEncodeAPI by doing the re-ordering for B frames. \n
2248  * If the client doesn't want to take the picture type decision it can enable
2249  * picture type decision module in the NvEncodeAPI interface by setting
2250  * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
2251  * order.
2252  *
2253  * \param [in] encoder
2254  * Pointer to the NvEncodeAPI interface.
2255  * \param [in] createEncodeParams
2256  * Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
2257  *
2258  * \return
2259  * ::NV_ENC_SUCCESS \n
2260  * ::NV_ENC_ERR_INVALID_PTR \n
2261  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2262  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2263  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2264  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2265  * ::NV_ENC_ERR_INVALID_PARAM \n
2266  * ::NV_ENC_ERR_INVALID_VERSION \n
2267  * ::NV_ENC_ERR_GENERIC \n
2268  *
2269  */
2270 NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
2271 
2272 
2273 // NvEncCreateInputBuffer
2274 /**
2275  * \brief Allocates Input buffer.
2276  *
2277  * This function is used to allocate an input buffer. The client must enumerate
2278  * the input buffer format before allocating the input buffer resources. The
2279  * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
2280  * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
2281  * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
2282  * client must be at least 4 more than the number of B frames being used for encoding.
2283  *
2284  * \param [in] encoder
2285  * Pointer to the NvEncodeAPI interface.
2286  * \param [in,out] createInputBufferParams
2287  * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
2288  *
2289  * \return
2290  * ::NV_ENC_SUCCESS \n
2291  * ::NV_ENC_ERR_INVALID_PTR \n
2292  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2293  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2294  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2295  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2296  * ::NV_ENC_ERR_INVALID_PARAM \n
2297  * ::NV_ENC_ERR_INVALID_VERSION \n
2298  * ::NV_ENC_ERR_GENERIC \n
2299  *
2300  */
2301 NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
2302 
2303 
2304 // NvEncDestroyInputBuffer
2305 /**
2306  * \brief Release an input buffers.
2307  *
2308  * This function is used to free an input buffer. If the client has allocated
2309  * any input buffer using ::NvEncCreateInputBuffer() API, it must free those
2310  * input buffers by calling this function. The client must release the input
2311  * buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
2312  *
2313  * \param [in] encoder
2314  * Pointer to the NvEncodeAPI interface.
2315  * \param [in] inputBuffer
2316  * Pointer to the input buffer to be released.
2317  *
2318  * \return
2319  * ::NV_ENC_SUCCESS \n
2320  * ::NV_ENC_ERR_INVALID_PTR \n
2321  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2322  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2323  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2324  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2325  * ::NV_ENC_ERR_INVALID_PARAM \n
2326  * ::NV_ENC_ERR_INVALID_VERSION \n
2327  * ::NV_ENC_ERR_GENERIC \n
2328  *
2329  */
2330 NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
2331 
2332 
2333 // NvEncCreateBitstreamBuffer
2334 /**
2335  * \brief Allocates an output bitstream buffer
2336  *
2337  * This function is used to allocate an output bitstream buffer and returns a
2338  * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
2339  * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
2340  * The client can only call this function after the encoder session has been
2341  * initialized using ::NvEncInitializeEncoder() API. The minimum number of output
2342  * buffers allocated by the client must be at least 4 more than the number of B
2343  * B frames being used for encoding. The client can only access the output
2344  * bitsteam data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
2345  * function.
2346  *
2347  * \param [in] encoder
2348  * Pointer to the NvEncodeAPI interface.
2349  * \param [in,out] createBitstreamBufferParams
2350  * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
2351  *
2352  * \return
2353  * ::NV_ENC_SUCCESS \n
2354  * ::NV_ENC_ERR_INVALID_PTR \n
2355  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2356  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2357  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2358  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2359  * ::NV_ENC_ERR_INVALID_PARAM \n
2360  * ::NV_ENC_ERR_INVALID_VERSION \n
2361  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2362  * ::NV_ENC_ERR_GENERIC \n
2363  *
2364  */
2365 NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
2366 
2367 
2368 // NvEncDestroyBitstreamBuffer
2369 /**
2370  * \brief Release a bitstream buffer.
2371  *
2372  * This function is used to release the output bitstream buffer allocated using
2373  * the ::NvEncCreateBitstreamBuffer() function. The client must release the output
2374  * bitstreamBuffer using this function before destroying the encoder session.
2375  *
2376  * \param [in] encoder
2377  * Pointer to the NvEncodeAPI interface.
2378  * \param [in] bitstreamBuffer
2379  * Pointer to the bitstream buffer being released.
2380  *
2381  * \return
2382  * ::NV_ENC_SUCCESS \n
2383  * ::NV_ENC_ERR_INVALID_PTR \n
2384  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2385  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2386  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2387  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2388  * ::NV_ENC_ERR_INVALID_PARAM \n
2389  * ::NV_ENC_ERR_INVALID_VERSION \n
2390  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2391  * ::NV_ENC_ERR_GENERIC \n
2392  *
2393  */
2394 NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
2395 
2396 // NvEncEncodePicture
2397 /**
2398  * \brief Submit an input picture for encoding.
2399  *
2400  * This function is used to submit an input picture buffer for encoding. The
2401  * encoding parameters are passed using \p *encodePicParams which is a pointer
2402  * to the ::_NV_ENC_PIC_PARAMS structure.
2403  *
2404  * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
2405  * send a valid value for the following fields.
2406  * - NV_ENC_PIC_PARAMS::pictureType
2407  * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
2408  * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
2409  * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
2410  *
2411  *
2412  *\par Asynchronous Encoding
2413  * If the client has enabled asynchronous mode of encoding by setting
2414  * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
2415  * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
2416  * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
2417  * API commands from the main thread and then queue output buffers to be processed
2418  * to a secondary worker thread. Before the locking the output buffers in the
2419  * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
2420  * it has queued in ::NvEncEncodePicture() API call. The client must always process
2421  * completion event and the output buffer in the same order in which they have been
2422  * submitted for encoding. The NvEncodeAPI interface is responsible for any
2423  * re-ordering required for B frames and will always ensure that encoded bitstream
2424  * data is written in the same order in which output buffer is submitted.
2425  *\code
2426  The below example shows how asynchronous encoding in case of 1 B frames
2427  ------------------------------------------------------------------------
2428  Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
2429  and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
2430  keep a copy of the input buffers for re-ordering and it allocates following
2431  internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
2432  and the client is not responsible for the allocating or freeing the memory of
2433  the internal buffers.
2434 
2435  a) The client main thread will queue the following encode frame calls.
2436  Note the picture type is unknown to the client, the decision is being taken by
2437  NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
2438  consisting of allocated input buffer, output buffer and output events in successive
2439  ::NvEncEncodePicture() API calls along with other required encode picture params.
2440  For example:
2441  1st EncodePicture parameters - (I1, O1, E1)
2442  2nd EncodePicture parameters - (I2, O2, E2)
2443  3rd EncodePicture parameters - (I3, O3, E3)
2444 
2445  b) NvEncodeAPI SW will receive the following encode Commands from the client.
2446  The left side shows input from client in the form (Input buffer, Output Buffer,
2447  Output Event). The right hand side shows a possible picture type decision take by
2448  the NvEncodeAPI interface.
2449  (I1, O1, E1) ---P1 Frame
2450  (I2, O2, E2) ---B2 Frame
2451  (I3, O3, E3) ---P3 Frame
2452 
2453  c) NvEncodeAPI interface will make a copy of the input buffers to its internal
2454  buffersfor re-ordering. These copies are done as part of nvEncEncodePicture
2455  function call from the client and NvEncodeAPI interface is responsible for
2456  synchronization of copy operation with the actual encoding operation.
2457  I1 --> NvI1
2458  I2 --> NvI2
2459  I3 --> NvI3
2460 
2461  d) After returning from ::NvEncEncodePicture() call , the client must queue the output
2462  bitstream processing work to the secondary thread. The output bitstream processing
2463  for asynchronous mode consist of first waiting on completion event(E1, E2..)
2464  and then locking the output bitstream buffer(O1, O2..) for reading the encoded
2465  data. The work queued to the secondary thread by the client is in the following order
2466  (I1, O1, E1)
2467  (I2, O2, E2)
2468  (I3, O3, E3)
2469  Note they are in the same order in which client calls ::NvEncEncodePicture() API
2470  in \p step a).
2471 
2472  e) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
2473  the following encode commands:
2474  (NvI1, O1, E1) ---P1 Frame
2475  (NvI3, O2, E2) ---P3 Frame
2476  (NvI2, O3, E3) ---B2 frame
2477 
2478  f) After the encoding operations are completed, the events will be signalled
2479  by NvEncodeAPI interface in the following order :
2480  (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signalled.
2481  (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signalled.
2482  (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signalled.
2483 
2484  g) The client must lock the bitstream data using ::NvEncLockBitstream() API in
2485  the order O1,O2,O3 to read the encoded data, after waiting for the events
2486  to be signalled in the same order i.e E1, E2 and E3.The output processing is
2487  done in the secondary thread in the following order:
2488  Waits on E1, copies encoded bitstream from O1
2489  Waits on E2, copies encoded bitstream from O2
2490  Waits on E3, copies encoded bitstream from O3
2491 
2492  -Note the client will receive the events signalling and output buffer in the
2493  same order in which they have submitted for encoding.
2494  -Note the LockBitstream will have picture type field which will notify the
2495  output picture type to the clients.
2496  -Note the input, output buffer and the output completion event are free to be
2497  reused once NvEncodeAPI interfaced has signalled the event and the client has
2498  copied the data from the output buffer.
2499 
2500  * \endcode
2501  *
2502  *\par Synchronous Encoding
2503  * The client can enable synchronous mode of encoding by setting
2504  * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
2505  * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
2506  * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
2507  * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
2508  * interface might not be able to submit an input picture buffer for encoding
2509  * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
2510  * submit the input picture which is decided to be encoded as B frame as it waits
2511  * for backward reference from temporally subsequent frames. This input picture
2512  * is buffered internally and waits for more input picture to arrive. The client
2513  * must not call ::NvEncLockBitstream() API on the output buffers whose
2514  * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
2515  * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
2516  * output bitstreams to read the encoded bitstream data. The following example
2517  * explains the scenario with synchronous encoding with 2 B frames.
2518  *\code
2519  The below example shows how synchronous encoding works in case of 1 B frames
2520  -----------------------------------------------------------------------------
2521  Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
2522  and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
2523  keep a copy of the input buffers for re-ordering and it allocates following
2524  internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
2525  and the client is not responsible for the allocating or freeing the memory of
2526  the internal buffers.
2527 
2528  The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
2529  The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
2530  HW and returns ::NV_ENC_SUCCESS.
2531  The client can now read the encoded data by locking the output O1 by calling
2532  NvEncLockBitstream API.
2533 
2534  The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
2535  The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
2536  to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
2537  The error is not fatal and it notifies client that it cannot read the encoded
2538  data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
2539  more work to the NvEncodeAPI interface.
2540 
2541  The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
2542  The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
2543  encoding which will be used as backward reference frame for I2.
2544  The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
2545  the submission are part of the same ::NvEncEncodePicture() function call.
2546  The client can now read the encoded data for both the frames by locking the output
2547  O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
2548 
2549  The client must always lock the output in the same order in which it has submitted
2550  to receive the encoded bitstream in correct encoding order.
2551 
2552  * \endcode
2553  *
2554  * \param [in] encoder
2555  * Pointer to the NvEncodeAPI interface.
2556  * \param [in,out] encodePicParams
2557  * Pointer to the ::_NV_ENC_PIC_PARAMS structure.
2558  *
2559  * \return
2560  * ::NV_ENC_SUCCESS \n
2561  * ::NV_ENC_ERR_INVALID_PTR \n
2562  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2563  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2564  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2565  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2566  * ::NV_ENC_ERR_INVALID_PARAM \n
2567  * ::NV_ENC_ERR_INVALID_VERSION \n
2568  * ::NV_ENC_ERR_ENCODER_BUSY \n
2569  * ::NV_ENC_ERR_NEED_MORE_INPUT \n
2570  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2571  * ::NV_ENC_ERR_GENERIC \n
2572  *
2573  */
2574 NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
2575 
2576 
2577 // NvEncLockBitstream
2578 /**
2579  * \brief Lock output bitstream buffer
2580  *
2581  * This function is used to lock the bitstream buffer to read the encoded data.
2582  * The client can only access the encoded data by calling this function.
2583  * The pointer to client accessible encoded data is returned in the
2584  * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
2585  * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
2586  * The NvEncodeAPI interface also returns the output picture type and picture structure
2587  * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
2588  * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
2589  * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
2590  * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
2591  * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
2592  * retry the function after few milliseconds.
2593  *
2594  * \param [in] encoder
2595  * Pointer to the NvEncodeAPI interface.
2596  * \param [in,out] lockBitstreamBufferParams
2597  * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
2598  *
2599  * \return
2600  * ::NV_ENC_SUCCESS \n
2601  * ::NV_ENC_ERR_INVALID_PTR \n
2602  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2603  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2604  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2605  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2606  * ::NV_ENC_ERR_INVALID_PARAM \n
2607  * ::NV_ENC_ERR_INVALID_VERSION \n
2608  * ::NV_ENC_ERR_LOCK_BUSY \n
2609  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2610  * ::NV_ENC_ERR_GENERIC \n
2611  *
2612  */
2613 NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
2614 
2615 
2616 // NvEncUnlockBitstream
2617 /**
2618  * \brief Unlock the output bitstream buffer
2619  *
2620  * This function is used to unlock the output bitstream buffer after the client
2621  * has read the encoded data from output buffer. The client must call this function
2622  * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
2623  * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
2624  * the function to fail.
2625  *
2626  * \param [in] encoder
2627  * Pointer to the NvEncodeAPI interface.
2628  * \param [in,out] bitstreamBuffer
2629  * bitstream buffer pointer being unlocked
2630  *
2631  * \return
2632  * ::NV_ENC_SUCCESS \n
2633  * ::NV_ENC_ERR_INVALID_PTR \n
2634  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2635  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2636  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2637  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2638  * ::NV_ENC_ERR_INVALID_PARAM \n
2639  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2640  * ::NV_ENC_ERR_GENERIC \n
2641  *
2642  */
2643 NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
2644 
2645 
2646 // NvLockInputBuffer
2647 /**
2648  * \brief Locks an input buffer
2649  *
2650  * This function is used to lock the input buffer to load the uncompressed YUV
2651  * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
2652  * it had previously allocated using ::NvEncCreateInputBuffer()in the
2653  * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
2654  * The NvEncodeAPI interface returns pointer to client accessible input buffer
2655  * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
2656  *
2657  * \param [in] encoder
2658  * Pointer to the NvEncodeAPI interface.
2659  * \param [in,out] lockInputBufferParams
2660  * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
2661  *
2662  * \return
2663  * \return
2664  * ::NV_ENC_SUCCESS \n
2665  * ::NV_ENC_ERR_INVALID_PTR \n
2666  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2667  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2668  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2669  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2670  * ::NV_ENC_ERR_INVALID_PARAM \n
2671  * ::NV_ENC_ERR_INVALID_VERSION \n
2672  * ::NV_ENC_ERR_LOCK_BUSY \n
2673  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2674  * ::NV_ENC_ERR_GENERIC \n
2675  *
2676  */
2677 NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
2678 
2679 
2680 // NvUnlockInputBuffer
2681 /**
2682  * \brief Unlocks the input buffer
2683  *
2684  * This function is used to unlock the input buffer memory previously locked for
2685  * uploading YUV pixel data. The input buffer must be unlocked before being used
2686  * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
2687  *
2688  * \param [in] encoder
2689  * Pointer to the NvEncodeAPI interface.
2690  * \param [in] inputBuffer
2691  * Pointer to the input buffer that is being unlocked.
2692  *
2693  * \return
2694  * ::NV_ENC_SUCCESS \n
2695  * ::NV_ENC_ERR_INVALID_PTR \n
2696  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2697  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2698  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2699  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2700  * ::NV_ENC_ERR_INVALID_VERSION \n
2701  * ::NV_ENC_ERR_INVALID_PARAM \n
2702  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2703  * ::NV_ENC_ERR_GENERIC \n
2704  *
2705  *
2706  */
2707 NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
2708 
2709 
2710 // NvEncGetEncodeStats
2711 /**
2712  * \brief Get encoding statistics.
2713  *
2714  * This function is used to retrieve the encoding statistics.
2715  * This API is not supported when encode device type is CUDA.
2716  *
2717  * \param [in] encoder
2718  * Pointer to the NvEncodeAPI interface.
2719  * \param [in,out] encodeStats
2720  * Pointer to the ::_NV_ENC_STAT structure.
2721  *
2722  * \return
2723  * ::NV_ENC_SUCCESS \n
2724  * ::NV_ENC_ERR_INVALID_PTR \n
2725  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2726  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2727  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2728  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2729  * ::NV_ENC_ERR_INVALID_PARAM \n
2730  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2731  * ::NV_ENC_ERR_GENERIC \n
2732  *
2733  */
2734 NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
2735 
2736 
2737 // NvEncGetSequenceParams
2738 /**
2739  * \brief Get encoded sequence and picture header.
2740  *
2741  * This function can be used to retrieve the sequence and picture header out of
2742  * band. The client must call this function only after the encoder has been
2743  * initialized using ::NvEncInitializeEncoder() function. The client must
2744  * allocate the memory where the NvEncodeAPI interface can copy the bitstream
2745  * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
2746  * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
2747  * The NvEncodeAPI interface will copy the bitstream header payload and returns
2748  * the actual size of the bitstream header in the field
2749  * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
2750  * The client must call ::NvEncGetSequenceParams() function from the same thread which is
2751  * being used to call ::NvEncEncodePicture() function.
2752  *
2753  * \param [in] encoder
2754  * Pointer to the NvEncodeAPI interface.
2755  * \param [in,out] sequenceParamPayload
2756  * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
2757  *
2758  * \return
2759  * ::NV_ENC_SUCCESS \n
2760  * ::NV_ENC_ERR_INVALID_PTR \n
2761  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2762  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2763  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2764  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2765  * ::NV_ENC_ERR_INVALID_VERSION \n
2766  * ::NV_ENC_ERR_INVALID_PARAM \n
2767  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2768  * ::NV_ENC_ERR_GENERIC \n
2769  *
2770  */
2771 NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
2772 
2773 
2774 // NvEncRegisterAsyncEvent
2775 /**
2776  * \brief Register event for notification to encoding completion.
2777  *
2778  * This function is used to register the completion event with NvEncodeAPI
2779  * interface. The event is required when the client has configured the encoder to
2780  * work in asynchronous mode. In this mode the client needs to send a completion
2781  * event with every output buffer. The NvEncodeAPI interface will signal the
2782  * completion of the encoding process using this event. Only after the event is
2783  * signalled the client can get the encoded data using ::NvEncLockBitstream() function.
2784  *
2785  * \param [in] encoder
2786  * Pointer to the NvEncodeAPI interface.
2787  * \param [in] eventParams
2788  * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
2789  *
2790  * \return
2791  * ::NV_ENC_SUCCESS \n
2792  * ::NV_ENC_ERR_INVALID_PTR \n
2793  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2794  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2795  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2796  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2797  * ::NV_ENC_ERR_INVALID_VERSION \n
2798  * ::NV_ENC_ERR_INVALID_PARAM \n
2799  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2800  * ::NV_ENC_ERR_GENERIC \n
2801  *
2802  */
2803 NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
2804 
2805 
2806 // NvEncUnregisterAsyncEvent
2807 /**
2808  * \brief Unregister completion event.
2809  *
2810  * This function is used to unregister completion event which has been previously
2811  * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
2812  * all events before destroying the encoder using ::NvEncDestroyEncoder() function.
2813  *
2814  * \param [in] encoder
2815  * Pointer to the NvEncodeAPI interface.
2816  * \param [in] eventParams
2817  * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
2818  *
2819  * \return
2820  * ::NV_ENC_SUCCESS \n
2821  * ::NV_ENC_ERR_INVALID_PTR \n
2822  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2823  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2824  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2825  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2826  * ::NV_ENC_ERR_INVALID_VERSION \n
2827  * ::NV_ENC_ERR_INVALID_PARAM \n
2828  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2829  * ::NV_ENC_ERR_GENERIC \n
2830  *
2831  */
2833 
2834 
2835 // NvEncMapInputResource
2836 /**
2837  * \brief Map an externally created input resource pointer for encoding.
2838  *
2839  * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
2840  * which can be used for encoding in the ::NvEncEncodePicture() function. The
2841  * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
2842  * The NvEncodeAPI interface also returns the buffer format of the mapped resource
2843  * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
2844  * This function provides synchronization guarantee that any graphics or compute
2845  * work submitted on the input buffer is completed before the buffer is used for encoding.
2846  * The client should not access any input buffer while they are mapped by the encoder.
2847  *
2848  * \param [in] encoder
2849  * Pointer to the NvEncodeAPI interface.
2850  * \param [in,out] mapInputResParams
2851  * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
2852  *
2853  * \return
2854  * ::NV_ENC_SUCCESS \n
2855  * ::NV_ENC_ERR_INVALID_PTR \n
2856  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2857  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2858  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2859  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2860  * ::NV_ENC_ERR_INVALID_VERSION \n
2861  * ::NV_ENC_ERR_INVALID_PARAM \n
2862  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2863  * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
2864  * ::NV_ENC_ERR_MAP_FAILED \n
2865  * ::NV_ENC_ERR_GENERIC \n
2866  *
2867  */
2868 NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
2869 
2870 
2871 // NvEncUnmapInputResource
2872 /**
2873  * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
2874  *
2875  *
2876  * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
2877  * API. The mapping created using ::NvEncMapInputResource() should be invalidated
2878  * using this API before the external resource is destroyed by the client. The client
2879  * must unmap the buffer after ::NvEncLockBitstream() API returns succuessfully for encode
2880  * work submitted using the mapped input buffer.
2881  *
2882  *
2883  * \param [in] encoder
2884  * Pointer to the NvEncodeAPI interface.
2885  * \param [in] mappedInputBuffer
2886  * Pointer to the NV_ENC_INPUT_PTR
2887  *
2888  * \return
2889  * ::NV_ENC_SUCCESS \n
2890  * ::NV_ENC_ERR_INVALID_PTR \n
2891  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2892  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2893  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2894  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2895  * ::NV_ENC_ERR_INVALID_VERSION \n
2896  * ::NV_ENC_ERR_INVALID_PARAM \n
2897  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
2898  * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
2899  * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
2900  * ::NV_ENC_ERR_GENERIC \n
2901  *
2902  */
2903 NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
2904 
2905 // NvEncDestroyEncoder
2906 /**
2907  * \brief Destroy Encoding Session
2908  *
2909  * Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
2910  * function. The client must flush the encoder before freeing any resources. In order
2911  * to flush the encoder the client must pass a NULL encode picture packet and either
2912  * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
2913  * for the flush event to be signaled by the encoder in asynchronous mode.
2914  * The client must free all the input and output resources created using the
2915  * NvEncodeAPI interface before destroying the encoder. If the client is operating
2916  * in asynchronous mode, it must also unregister the completion events previously
2917  * registered.
2918  *
2919  * \param [in] encoder
2920  * Pointer to the NvEncodeAPI interface.
2921  *
2922  * \return
2923  * ::NV_ENC_SUCCESS \n
2924  * ::NV_ENC_ERR_INVALID_PTR \n
2925  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2926  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2927  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2928  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2929  * ::NV_ENC_ERR_INVALID_PARAM \n
2930  * ::NV_ENC_ERR_GENERIC \n
2931  *
2932  */
2933 NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
2934 
2935 // NvEncInvalidateRefFrames
2936 /**
2937  * \brief Invalidate reference frames
2938  *
2939  * Invalidates reference frame based on the time stamp provided by the client.
2940  * The encoder marks any reference frames or any frames which have been reconstructed
2941  * using the corrupt frame as invalid for motion estimation and uses older reference
2942  * frames for motion estimation. The encoded forces the current frame to be encoded
2943  * as an intra frame if no reference frames are left after invalidation process.
2944  * This is useful for low latency application for error resiliency. The client
2945  * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
2946  * that encoder can keep a backup of older reference frames in the DPB and can use them
2947  * for motion estimation when the newer reference frames have been invalidated.
2948  * This API can be called multiple times.
2949  *
2950  * \param [in] encoder
2951  * Pointer to the NvEncodeAPI interface.
2952  * \param [in] invalidRefFrameTimeStamp
2953  * Timestamp of the invalid reference frames which needs to be invalidated.
2954  *
2955  * \return
2956  * ::NV_ENC_SUCCESS \n
2957  * ::NV_ENC_ERR_INVALID_PTR \n
2958  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
2959  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2960  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2961  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
2962  * ::NV_ENC_ERR_INVALID_PARAM \n
2963  * ::NV_ENC_ERR_GENERIC \n
2964  *
2965  */
2966 NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
2967 
2968 // NvEncOpenEncodeSessionEx
2969 /**
2970  * \brief Opens an encoding session.
2971  *
2972  * Opens an encoding session and returns a pointer to the encoder interface in
2973  * the \p **encoder parameter. The client should start encoding process by calling
2974  * this API first.
2975  * The client must pass a pointer to IDirect3DDevice9 device or CUDA context in the \p *device parameter.
2976  * For the OpenGL interface, \p device must be NULL. An OpenGL context must be current when
2977  * calling all NvEncodeAPI functions.
2978  * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
2979  * before exiting.
2980  *
2981  * \param [in] openSessionExParams
2982  * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
2983  * \param [out] encoder
2984  * Encode Session pointer to the NvEncodeAPI interface.
2985  * \return
2986  * ::NV_ENC_SUCCESS \n
2987  * ::NV_ENC_ERR_INVALID_PTR \n
2988  * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
2989  * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
2990  * ::NV_ENC_ERR_INVALID_DEVICE \n
2991  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
2992  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
2993  * ::NV_ENC_ERR_GENERIC \n
2994  *
2995  */
2997 
2998 // NvEncRegisterResource
2999 /**
3000  * \brief Registers a resource with the Nvidia Video Encoder Interface.
3001  *
3002  * Registers a resource with the Nvidia Video Encoder Interface for book keeping.
3003  * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
3004  *
3005  * \param [in] encoder
3006  * Pointer to the NVEncodeAPI interface.
3007  *
3008  * \param [in] registerResParams
3009  * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
3010  *
3011  * \return
3012  * ::NV_ENC_SUCCESS \n
3013  * ::NV_ENC_ERR_INVALID_PTR \n
3014  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
3015  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3016  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3017  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
3018  * ::NV_ENC_ERR_INVALID_VERSION \n
3019  * ::NV_ENC_ERR_INVALID_PARAM \n
3020  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
3021  * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
3022  * ::NV_ENC_ERR_GENERIC \n
3023  * ::NV_ENC_ERR_UNIMPLEMENTED \n
3024  *
3025  */
3026 NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
3027 
3028 // NvEncUnregisterResource
3029 /**
3030  * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
3031  *
3032  * Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
3033  * The client is expected to unregister any resource that it has registered with the
3034  * Nvidia Video Encoder Interface before destroying the resource.
3035  *
3036  * \param [in] encoder
3037  * Pointer to the NVEncodeAPI interface.
3038  *
3039  * \param [in] registeredResource
3040  * The registered resource pointer that was returned in ::NvEncRegisterResource.
3041  *
3042  * \return
3043  * ::NV_ENC_SUCCESS \n
3044  * ::NV_ENC_ERR_INVALID_PTR \n
3045  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
3046  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3047  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3048  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
3049  * ::NV_ENC_ERR_INVALID_VERSION \n
3050  * ::NV_ENC_ERR_INVALID_PARAM \n
3051  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
3052  * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
3053  * ::NV_ENC_ERR_GENERIC \n
3054  * ::NV_ENC_ERR_UNIMPLEMENTED \n
3055  *
3056  */
3057 NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
3058 
3059 // NvEncReconfigureEncoder
3060 /**
3061  * \brief Reconfigure an existing encoding session.
3062  *
3063  * Reconfigure an existing encoding session.
3064  * The client should call this API to change/reconfigure the parameter passed during
3065  * NvEncInitializeEncoder API call.
3066  * Currently Reconfiguration of following are not supported.
3067  * Change in GOP structure.
3068  * Change in sync-Async mode.
3069  * Change in MaxWidth & MaxHeight.
3070  * Change in PTDmode.
3071  *
3072  * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
3073  * is set while creating encoder session.
3074  *
3075  * \param [in] encoder
3076  * Pointer to the NVEncodeAPI interface.
3077  *
3078  * \param [in] reInitEncodeParams
3079  * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
3080  * \return
3081  * ::NV_ENC_SUCCESS \n
3082  * ::NV_ENC_ERR_INVALID_PTR \n
3083  * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
3084  * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
3085  * ::NV_ENC_ERR_INVALID_DEVICE \n
3086  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3087  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3088  * ::NV_ENC_ERR_GENERIC \n
3089  *
3090  */
3091 NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
3092 
3093 
3094 
3095 // NvEncCreateMVBuffer
3096 /**
3097  * \brief Allocates output MV buffer for ME only mode.
3098  *
3099  * This function is used to allocate an output MV buffer. The size of the mvBuffer is
3100  * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
3101  * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
3102  * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
3103  * ::NvEncRunMotionEstimationOnly() API.
3104  * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
3105  *
3106  * \param [in] encoder
3107  * Pointer to the NvEncodeAPI interface.
3108  * \param [in,out] createMVBufferParams
3109  * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure.
3110  *
3111  * \return
3112  * ::NV_ENC_SUCCESS \n
3113  * ::NV_ENC_ERR_INVALID_PTR \n
3114  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
3115  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3116  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3117  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
3118  * ::NV_ENC_ERR_INVALID_PARAM \n
3119  * ::NV_ENC_ERR_INVALID_VERSION \n
3120  * ::NV_ENC_ERR_GENERIC \n
3121  */
3122 NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
3123 
3124 
3125 // NvEncDestroyMVBuffer
3126 /**
3127  * \brief Release an output MV buffer for ME only mode.
3128  *
3129  * This function is used to release the output MV buffer allocated using
3130  * the ::NvEncCreateMVBuffer() function. The client must release the output
3131  * mvBuffer using this function before destroying the encoder session.
3132  *
3133  * \param [in] encoder
3134  * Pointer to the NvEncodeAPI interface.
3135  * \param [in] mvBuffer
3136  * Pointer to the mvBuffer being released.
3137  *
3138  * \return
3139  * ::NV_ENC_SUCCESS \n
3140  * ::NV_ENC_ERR_INVALID_PTR \n
3141  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
3142  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3143  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3144  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
3145  * ::NV_ENC_ERR_INVALID_PARAM \n
3146  * ::NV_ENC_ERR_INVALID_VERSION \n
3147  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
3148  * ::NV_ENC_ERR_GENERIC \n
3149  */
3150 NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
3151 
3152 
3153 // NvEncRunMotionEstimationOnly
3154 /**
3155  * \brief Submit an input picture and reference frame for motion estimation in ME only mode.
3156  *
3157  * This function is used to submit the input frame and reference frame for motion
3158  * estimation. The ME parameters are passed using *meOnlyParams which is a pointer
3159  * to ::_NV_ENC_MEONLY_PARAMS structure.
3160  * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
3161  * to get motion vector data.
3162  *
3163  * \param [in] encoder
3164  * Pointer to the NvEncodeAPI interface.
3165  * \param [in] meOnlyParams
3166  * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure.
3167  *
3168  * \return
3169  * ::NV_ENC_SUCCESS \n
3170  * ::NV_ENC_ERR_INVALID_PTR \n
3171  * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
3172  * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
3173  * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
3174  * ::NV_ENC_ERR_OUT_OF_MEMORY \n
3175  * ::NV_ENC_ERR_INVALID_PARAM \n
3176  * ::NV_ENC_ERR_INVALID_VERSION \n
3177  * ::NV_ENC_ERR_NEED_MORE_INPUT \n
3178  * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
3179  * ::NV_ENC_ERR_GENERIC \n
3180  */
3182 
3183 // NvEncodeAPIGetMaxSupportedVersion
3184 /**
3185  * \brief Get the largest NvEncodeAPI version supported by the driver.
3186  *
3187  * This function can be used by clients to determine if the driver supports
3188  * the NvEncodeAPI header the application was compiled with.
3189  *
3190  * \param [out] version
3191  * Pointer to the requested value. The 4 least significant bits in the returned
3192  * indicate the minor version and the rest of the bits indicate the major
3193  * version of the largest supported version.
3194  *
3195  * \return
3196  * ::NV_ENC_SUCCESS \n
3197  * ::NV_ENC_ERR_INVALID_PTR \n
3198  */
3200 
3201 
3202 /// \cond API PFN
3203 /*
3204  * Defines API function pointers
3205  */
3206 typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder);
3207 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount);
3208 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
3209 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
3210 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
3211 typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
3212 typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
3213 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
3214 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
3215 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
3216 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
3217 typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
3218 typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
3219 typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
3220 typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
3221 typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
3222 typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
3223 typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
3224 typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
3225 typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
3226 typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
3227 typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats);
3228 typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
3229 typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
3230 typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
3231 typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
3232 typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
3233 typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder);
3234 typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp);
3235 typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
3236 typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
3237 typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes);
3238 typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
3239 
3240 typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
3241 typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
3242 typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
3243 
3244 
3245 /// \endcond
3246 
3247 
3248 /** @} */ /* END ENCODE_FUNC */
3249 
3250 /**
3251  * \ingroup ENCODER_STRUCTURE
3252  * NV_ENCODE_API_FUNCTION_LIST
3253  */
3254 typedef struct _NV_ENCODE_API_FUNCTION_LIST
3255 {
3256  uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */
3257  uint32_t reserved; /**< [in]: Reserved and should be set to 0. */
3258  PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
3259  PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */
3260  PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/
3261  PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */
3262  PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */
3263  PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */
3264  PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */
3265  PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */
3266  PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */
3267  PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */
3268  PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */
3269  PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */
3270  PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */
3271  PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */
3272  PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */
3273  PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */
3274  PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */
3275  PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */
3276  PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */
3277  PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */
3278  PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */
3279  PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */
3280  PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */
3281  PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */
3282  PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */
3283  PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */
3284  PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */
3285  PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */
3286  PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */
3287  PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
3288  PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */
3289  PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */
3290  PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */
3291  void* reserved1;
3292  PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */
3293  PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */
3294  PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */
3295  void* reserved2[281]; /**< [in]: Reserved and must be set to NULL */
3297 
3298 /** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */
3299 #define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2)
3300 
3301 // NvEncodeAPICreateInstance
3302 /**
3303  * \ingroup ENCODE_FUNC
3304  * Entry Point to the NvEncodeAPI interface.
3305  *
3306  * Creates an instance of the NvEncodeAPI interface, and populates the
3307  * pFunctionList with function pointers to the API routines implemented by the
3308  * NvEncodeAPI interface.
3309  *
3310  * \param [out] functionList
3311  *
3312  * \return
3313  * ::NV_ENC_SUCCESS
3314  * ::NV_ENC_ERR_INVALID_PTR
3315  */
3317 
3318 #ifdef __cplusplus
3319 }
3320 #endif
3321 
3322 
3323 #endif
3324 
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1369
uint8_t * sliceTypeData
[in]: Array which specifies the slice type used to force intra slice for a particular slice...
Definition: nvEncodeAPI.h:1539
NVENCSTATUS NVENCAPI NvEncRegisterResource(void *encoder, NV_ENC_REGISTER_RESOURCE *registerResParams)
Registers a resource with the Nvidia Video Encoder Interface.
NVENCSTATUS NVENCAPI NvEncCreateMVBuffer(void *encoder, NV_ENC_CREATE_MV_BUFFER *createMVBufferParams)
Allocates output MV buffer for ME only mode.
PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs
[out]: Client should access NvEncGetEncodeGUIDs() API through this pointer.
Definition: nvEncodeAPI.h:3262
NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer(void *encoder, NV_ENC_INPUT_PTR inputBuffer)
Release an input buffers.
uint32_t idrPeriod
[in]: Specifies the IDR interval.
Definition: nvEncodeAPI.h:1219
Entropy coding mode is CAVLC.
Definition: nvEncodeAPI.h:596
Progressive frame.
Definition: nvEncodeAPI.h:276
NV_ENC_PIC_TYPE
Input picture type.
Definition: nvEncodeAPI.h:284
No Stereo packing required.
Definition: nvEncodeAPI.h:635
PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer
[out]: Client should access NvEncCreateBitstreamBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3272
PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount
[out]: Client should access NvEncGetEncodeProfileGUIDCount() API through this pointer.
Definition: nvEncodeAPI.h:3260
void * completionEvent
[in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface.
Definition: nvEncodeAPI.h:1808
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1739
uint32_t bitStreamSize
[out]: Size of generated bitstream in bytes.
Definition: nvEncodeAPI.h:1768
Adaptive Transform 8x8 mode disabled.
Definition: nvEncodeAPI.h:626
uint32_t temporalId
[in]: Specifies the temporal id of the picture
Definition: nvEncodeAPI.h:1528
uint32_t vbvBufferSize
[in]: Specifies the VBV(HRD) buffer size.
Definition: nvEncodeAPI.h:1097
NV_ENC_PIC_TYPE pictureType
[in]: Specifies input picture type.
Definition: nvEncodeAPI.h:1593
Field encoding bottom field first.
Definition: nvEncodeAPI.h:278
int8_t * qpDeltaMap
[in]: Specifies the pointer to signed byte array containing QP delta value per MB in raster scan orde...
Definition: nvEncodeAPI.h:1602
NV_ENC_QP constQP
[in]: Specifies the initial QP to be used for encoding, these values would be used for all frames if ...
Definition: nvEncodeAPI.h:1094
uint32_t seiPayloadArrayCnt
[in]: Specifies the number of elements allocated in seiPayloadArray array.
Definition: nvEncodeAPI.h:1556
Semi-Planar YUV [Y plane followed by interleaved UV plane].
Definition: nvEncodeAPI.h:315
uint32_t sliceModeData
[in]: Specifies the parameter needed for sliceMode.
Definition: nvEncodeAPI.h:1508
Indicates Subframe readback support for slice-based encoding.
Definition: nvEncodeAPI.h:828
uint32_t encodeWidth
[in]: Specifies the encode width.
Definition: nvEncodeAPI.h:1397
uint32_t pitch
[out]: Pitch of the locked input buffer.
Definition: nvEncodeAPI.h:1694
This indicates that the HW encoder is busy encoding and is unable to encode the input.
Definition: nvEncodeAPI.h:520
static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID
Definition: nvEncodeAPI.h:166
static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID
Definition: nvEncodeAPI.h:190
FullPel motion vector precision.
Definition: nvEncodeAPI.h:302
NV_ENC_REGISTERED_PTR registeredResource
[in]: The Registered resource handle obtained by calling NvEncRegisterInputResource.
Definition: nvEncodeAPI.h:1712
NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void *encoder, uint64_t invalidRefFrameTimeStamp)
Invalidate reference frames.
NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type...
Driver selects QuarterPel motion vector precision by default.
Definition: nvEncodeAPI.h:301
Indicates end of the input stream.
Definition: nvEncodeAPI.h:574
PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer
[out]: Client should access NvEncDestroyMVBuffer API through this pointer.
Definition: nvEncodeAPI.h:3293
uint8_t * payload
[in] pointer to user data
Definition: nvEncodeAPI.h:1475
This indicates that the NvEncRegisterResource API failed to register the resource.
Definition: nvEncodeAPI.h:548
uint32_t ppsId
[in]: Specifies the PPS id of the picture header
Definition: nvEncodeAPI.h:1300
GUID presetGUID
[in]: Specifies the preset for encoding.
Definition: nvEncodeAPI.h:1396
void * device
[in]: Pointer to client device.
Definition: nvEncodeAPI.h:1823
Memory heap is in cached system memory.
Definition: nvEncodeAPI.h:584
NVENCSTATUS NVENCAPI NvEncReconfigureEncoder(void *encoder, NV_ENC_RECONFIGURE_PARAMS *reInitEncodeParams)
Reconfigure an existing encoding session.
HEVC encoder configuration parameters to be set during initialization.
Indicates HW support for Weighted Predicition.
Definition: nvEncodeAPI.h:956
Register a resource for future use with the Nvidia Video Encoder Interface.
NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void **encoder)
Opens an encoding session.
NVENC_EXTERNAL_ME_HINT * meExternalHints
[in]: Specifies the pointer to ME external hints for the current frame.
Definition: nvEncodeAPI.h:1637
Indicates HW capability for Quarter pel motion estimation.
Definition: nvEncodeAPI.h:709
NV_ENC_BUFFER_FORMAT bufferFmt
[in]: Specifies the input buffer format.
Definition: nvEncodeAPI.h:1628
void * outputBitstream
[in]: Pointer to the bitstream buffer being locked.
Definition: nvEncodeAPI.h:1658
uint32_t * sliceOffsets
[in,out]: Array which receives the slice offsets.
Definition: nvEncodeAPI.h:1659
uint32_t inBufferSize
[in]: Specifies the size of the spsppsBuffer provied by the client
Definition: nvEncodeAPI.h:1788
uint32_t privDataSize
[in]: Reserved private data buffer size and must be set to 0
Definition: nvEncodeAPI.h:1412
NV_ENC_OUTPUT_PTR mvBuffer
[in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer.
Definition: nvEncodeAPI.h:1627
NVENCSTATUS NVENCAPI NvEncUnmapInputResource(void *encoder, NV_ENC_INPUT_PTR mappedInputBuffer)
UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding.
NV_ENC_INPUT_PTR inputBuffer
[in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from NvEncCre...
Definition: nvEncodeAPI.h:1692
NV_ENC_STEREO_PACKING_MODE stereoMode
[in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement S...
Definition: nvEncodeAPI.h:1229
NVENCSTATUS NVENCAPI NvEncCreateInputBuffer(void *encoder, NV_ENC_CREATE_INPUT_BUFFER *createInputBufferParams)
Allocates Input buffer.
NV_ENC_CONFIG_H264 h264Config
[in]: Specifies the H.264-specific encoder configuration.
Definition: nvEncodeAPI.h:1355
PNVENCGETENCODECAPS nvEncGetEncodeCaps
[out]: Client should access NvEncGetEncodeCaps() API through this pointer.
Definition: nvEncodeAPI.h:3265
uint32_t ltrUseFrameBitmap
[in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame...
Definition: nvEncodeAPI.h:1554
NV_ENC_MEMORY_HEAP memoryHeap
Definition: nvEncodeAPI.h:1017
Uncompressed Input Buffer lock parameters.
uint32_t chromaFormatIDC
[in]: Specifies the chroma format.
Definition: nvEncodeAPI.h:1254
Forward predicted.
Definition: nvEncodeAPI.h:286
NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig(void *encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG *presetConfig)
Returns a preset config structure supported for given preset GUID.
uint32_t payloadSize
[in] SEI payload size in bytes.
Definition: nvEncodeAPI.h:1473
NV_ENC_OUTPUT_PTR bitstreamBuffer
[out]: Pointer to the output bitstream buffer
Definition: nvEncodeAPI.h:1019
H264 specific enc pic params.
VBR, high quality (slower)
Definition: nvEncodeAPI.h:262
PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder
[out]: Client should access NvEncReconfigureEncoder() API through this pointer.
Definition: nvEncodeAPI.h:3290
Side-by-side mode for packing stereo frames.
Definition: nvEncodeAPI.h:639
NV_ENC_INPUT_PTR inputBuffer
[in]: Specifies the input buffer pointer.
Definition: nvEncodeAPI.h:1625
NV_ENCODE_API_FUNCTION_LIST.
Definition: nvEncodeAPI.h:3254
This indicates that one or more of the parameter passed to the API call is invalid.
Definition: nvEncodeAPI.h:447
This indicates that the encoder device supplied by the client is not valid.
Definition: nvEncodeAPI.h:416
Defines a Rectangle.
NV_ENC_INPUT_PTR mappedResource
[out]: Mapped pointer corresponding to the registeredResource.
Definition: nvEncodeAPI.h:1713
Indicates HW support for MEOnly Mode.
Definition: nvEncodeAPI.h:925
NVENCSTATUS NVENCAPI NvEncInitializeEncoder(void *encoder, NV_ENC_INITIALIZE_PARAMS *createEncodeParams)
Initialize the encoder.
This indicates that an unknown internal error has occurred.
Definition: nvEncodeAPI.h:531
PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent
[out]: Client should access NvEncUnregisterAsyncEvent() API through this pointer. ...
Definition: nvEncodeAPI.h:3282
Indicates Temporal Scalability Support.
Definition: nvEncodeAPI.h:790
static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID
Definition: nvEncodeAPI.h:195
uint32_t intraRefreshPeriod
[in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set...
Definition: nvEncodeAPI.h:1291
int version
Definition: avisynth_c.h:766
NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode
[in]: Specifies the AdaptiveTransform Mode.
Definition: nvEncodeAPI.h:1225
Indicates HW support for encoding Temporal layers.
Definition: nvEncodeAPI.h:742
Indicates HW support for monochrome mode encoding.
Definition: nvEncodeAPI.h:695
NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount(void *encoder, GUID encodeGUID, uint32_t *encodeProfileGUIDCount)
Retrieves the number of supported profile GUIDs.
NVENC_EXTERNAL_ME_HINT * meExternalHints
[in]: Specifies the pointer to ME external hints for the current frame.
Definition: nvEncodeAPI.h:1597
uint32_t height
[in]: Input buffer width
Definition: nvEncodeAPI.h:997
NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS
Definition: nvEncodeAPI.h:1151
PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount
[out]: Client should access NvEncGetInputFormatCount() API through this pointer.
Definition: nvEncodeAPI.h:3263
NV_ENC_CODEC_PIC_PARAMS codecPicParams
[in]: Specifies the codec specific per-picture encoding parameters.
Definition: nvEncodeAPI.h:1594
uint32_t ltrNumFrames
[in]: Specifies the number of LTR frames.
Definition: nvEncodeAPI.h:1247
uint32_t forceIntraRefreshWithFrameCnt
[in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
Definition: nvEncodeAPI.h:1490
NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode
[in]: Specifies the frame/field mode.
Definition: nvEncodeAPI.h:1374
uint32_t forceIntraRefreshWithFrameCnt
[in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
Definition: nvEncodeAPI.h:1529
uint32_t ltrUseFrameBitmap
[in]: Specifies the the associated bitmap of LTR frame indices to use when encoding this frame...
Definition: nvEncodeAPI.h:1514
NV_ENC_QP maxQP
[in]: Specifies the maximum QP used for rate control.
Definition: nvEncodeAPI.h:1114
uint32_t payloadType
[in] SEI payload types and syntax can be found in Annex D of the H.264 Specification.
Definition: nvEncodeAPI.h:1474
static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID
Definition: nvEncodeAPI.h:150
Encoding parameters that need to be sent on a per frame basis.
uint32_t reservedBitFields
[in]: Reserved bitfields and must be set to 0
Definition: nvEncodeAPI.h:1604
PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer
[out]: Client should access NvEncUnlockInputBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3278
NVENCSTATUS NVENCAPI NvEncUnlockBitstream(void *encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer)
Unlock the output bitstream buffer.
10 bit Planar YUV444 [Y plane followed by U and V planes].
Definition: nvEncodeAPI.h:320
uint32_t overscanInfoPresentFlag
[in]: if set to 1 , it specifies that the overscanInfo is present
Definition: nvEncodeAPI.h:1135
uint32_t top
[in]: Y coordinate of the upper left corner of the rectangular area to be specified.
Definition: nvEncodeAPI.h:103
NVENCSTATUS NVENCAPI NvEncGetEncodeCaps(void *encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM *capsParam, int *capsVal)
Retrieves the capability value for a specified encoder attribute.
Constant QP mode.
Definition: nvEncodeAPI.h:257
HEVC specific enc pic params.
Map an input resource to a Nvidia Encoder Input Buffer.
static const GUID NV_ENC_H264_PROFILE_MAIN_GUID
Definition: nvEncodeAPI.h:158
NV_ENC_QP initialRCQP
[in]: Specifies the initial QP used for rate control.
Definition: nvEncodeAPI.h:1115
Bi-directionally predicted with only Intra MBs.
Definition: nvEncodeAPI.h:290
NV_ENC_PARAMS_RC_MODE rateControlMode
[in]: Specifies the rate control mode.
Definition: nvEncodeAPI.h:1093
This indicates that an invalid struct version was used by the client.
Definition: nvEncodeAPI.h:491
void * completionEvent
[in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating i...
Definition: nvEncodeAPI.h:1590
input resource type is an OpenGL texture
Definition: nvEncodeAPI.h:652
PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer
[out]: Client should access NvEncDestroyInputBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3271
void * NV_ENC_INPUT_PTR
NVENCODE API input buffer.
Definition: nvEncodeAPI.h:112
Creation parameters for input buffer.
Definition: nvEncodeAPI.h:993
This indicates that API call returned with no errors.
Definition: nvEncodeAPI.h:400
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1622
NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters
[in]: Specifies the H264 video usability info pamameters
Definition: nvEncodeAPI.h:1246
uint32_t height
[in]: Input buffer Height.
Definition: nvEncodeAPI.h:1746
uint8_t partitionMode
The CU partition mode 0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN), 4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N)
Definition: nvEncodeAPI.h:1057
NVENCSTATUS NVENCAPI NvEncOpenEncodeSession(void *device, uint32_t deviceType, void **encoder)
Opens an encoding session.
NV_ENC_OUTPUT_PTR mvBuffer
[out]: Pointer to the output motion vector buffer
Definition: nvEncodeAPI.h:1069
uint32_t picType
[out]: Picture type of encoded picture.
Definition: nvEncodeAPI.h:1769
PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer
[out]: Client should access NvEncCreateInputBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3270
NV_ENC_CONFIG * encodeConfig
[in]: Specifies the advanced codec specific structure.
Definition: nvEncodeAPI.h:1414
NVENCSTATUS NVENCAPI NvEncEncodePicture(void *encoder, NV_ENC_PIC_PARAMS *encodePicParams)
Submit an input picture for encoding.
uint8_t
uint32_t inputWidth
[in]: Specifies the input buffer width
Definition: nvEncodeAPI.h:1581
Indicates HW support for field mode encoding.
Definition: nvEncodeAPI.h:688
Indicates Forcing Constant QP On The Fly Support.
Definition: nvEncodeAPI.h:814
uint32_t intraRefreshCnt
[in]: Specifies the length of intra refresh in number of frames for periodic intra refresh...
Definition: nvEncodeAPI.h:1293
PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount
[out]: Client should access NvEncGetEncodeGUIDCount() API through this pointer.
Definition: nvEncodeAPI.h:3259
PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames
[out]: Client should access NvEncInvalidateRefFrames() API through this pointer.
Definition: nvEncodeAPI.h:3286
NV_ENC_MEMORY_HEAP memoryHeap
Definition: nvEncodeAPI.h:998
uint32_t spsId
[in]: Specifies the SPS id of the sequence header
Definition: nvEncodeAPI.h:1299
NVENCSTATUS NVENCAPI NvEncUnregisterResource(void *encoder, NV_ENC_REGISTERED_PTR registeredResource)
Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
NV_ENC_PIC_PARAMS_HEVC hevcPicParams
[in]: HEVC encode picture params.
Definition: nvEncodeAPI.h:1570
NV_ENC_HEVC_CUSIZE
HEVC CU SIZE.
Definition: nvEncodeAPI.h:967
uint32_t ltrMarkFrameIdx
[in]: Specifies the long term reference frame index to use for marking this frame as LTR...
Definition: nvEncodeAPI.h:1553
uint32_t inputHeight
[in]: Specifies the input buffer height
Definition: nvEncodeAPI.h:1624
PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount
[out]: Client should access NvEncGetEncodePresetCount() API through this pointer. ...
Definition: nvEncodeAPI.h:3266
PNVENCLOCKBITSTREAM nvEncLockBitstream
[out]: Client should access NvEncLockBitstream() API through this pointer.
Definition: nvEncodeAPI.h:3275
Encode Session Initialization parameters.
BDirect mode is auto selected by the encoder driver.
Definition: nvEncodeAPI.h:604
Indicates HW support for 10 bit encoding.
Definition: nvEncodeAPI.h:945
uint32_t colourMatrix
[in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (...
Definition: nvEncodeAPI.h:1143
Input struct for querying Encoding capabilities.
Definition: nvEncodeAPI.h:979
Field encoding top field first.
Definition: nvEncodeAPI.h:277
uint32_t numSlices
[out]: Number of slices in the encoded picture.
Definition: nvEncodeAPI.h:1662
Minimum Encoding level supported (See NV_ENC_LEVEL for details).
Definition: nvEncodeAPI.h:766
NV_ENC_LEVEL
Encoding levels.
Definition: nvEncodeAPI.h:351
uint32_t maxNumRefFrames
[in]: Specifies the DPB size used for encoding.
Definition: nvEncodeAPI.h:1233
Creation parameters for output motion vector buffer for ME only mode.
Definition: nvEncodeAPI.h:1066
NV_ENC_OUTPUT_PTR outputBitstream
[in]: Specifies the pointer to output buffer.
Definition: nvEncodeAPI.h:1589
NV_ENC_BUFFER_FORMAT bufferFormat
[in]: Buffer format of resource to be registered.
Definition: nvEncodeAPI.h:1751
uint32_t displayPOCSyntax
[in]: Specifies the display POC syntax This is required to be set if client is handling the picture t...
Definition: nvEncodeAPI.h:1486
This indicates encode driver requires more input buffers to produce an output bitstream.
Definition: nvEncodeAPI.h:513
Indicates HW support for lossless encoding.
Definition: nvEncodeAPI.h:910
Encode Session Reconfigured parameters.
QuarterPel motion vector precision.
Definition: nvEncodeAPI.h:304
uint16_t Data3
[in]: Specifies the second group of 4 hexadecimal digits.
Definition: nvEncodeAPI.h:90
This indicates that the client is attempting to use a feature that is not available for the license t...
Definition: nvEncodeAPI.h:537
NV_ENC_OUTPUT_PTR outputBitStream
[out]: Specifies the pointer to output bitstream.
Definition: nvEncodeAPI.h:1767
NV_ENC_REGISTERED_PTR registeredResource
[out]: Registered resource handle.
Definition: nvEncodeAPI.h:1750
uint32_t Data1
[in]: Specifies the first 8 hexadecimal digits of the GUID.
Definition: nvEncodeAPI.h:88
uint32_t subResourceIndex
[in]: Subresource Index of the DirectX resource to be registered.
Definition: nvEncodeAPI.h:1748
Encode the current picture as an Intra picture.
Definition: nvEncodeAPI.h:569
uint32_t picIdx
[out]: Picture number
Definition: nvEncodeAPI.h:1772
Encode the current picture as an IDR picture.
Definition: nvEncodeAPI.h:570
NV_ENC_BUFFER_FORMAT
Input buffer formats.
Definition: nvEncodeAPI.h:311
NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer(void *encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer)
Release a bitstream buffer.
uint8_t targetQuality
[in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) ...
Definition: nvEncodeAPI.h:1118
Rate control modes supported.
Definition: nvEncodeAPI.h:680
Undefined buffer format.
Definition: nvEncodeAPI.h:313
This indicates that the completion event passed in NvEncEncodePicture() API has not been registered w...
Definition: nvEncodeAPI.h:526
uint32_t vpsId
[in]: Specifies the VPS id of the video parameter set
Definition: nvEncodeAPI.h:1298
uint32_t * outSPSPPSPayloadSize
[out]: Size of the sequence and picture header in bytes written by the NvEncodeAPI interface to the S...
Definition: nvEncodeAPI.h:1792
Indicates Dynamic Encode Bitrate Change Support.
Definition: nvEncodeAPI.h:806
uint32_t apiVersion
[in]: API version.
Definition: nvEncodeAPI.h:1825
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1394
PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent
[out]: Client should access NvEncRegisterAsyncEvent() API through this pointer.
Definition: nvEncodeAPI.h:3281
This indicates that the NvEncLockBitstream() failed to lock the output buffer.
Definition: nvEncodeAPI.h:480
8 bit Packed A8Y8U8V8.
Definition: nvEncodeAPI.h:329
Variable bitrate mode.
Definition: nvEncodeAPI.h:258
PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer
[out]: Client should access NvEncLockInputBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3277
uint32_t refPicFlag
[in]: Set to 1 for a reference picture.
Definition: nvEncodeAPI.h:1488
uint8_t targetQualityLSB
[in]: Fractional part of target quality (as 8.8 fixed point format)
Definition: nvEncodeAPI.h:1119
uint32_t inputPitch
[in]: Specifies the input buffer pitch.
Definition: nvEncodeAPI.h:1583
void * completionEvent
[in]: Specifies an event to be signalled on completion of motion estimation of this Frame [only if op...
Definition: nvEncodeAPI.h:1629
NV_ENC_HEVC_CUSIZE maxCUSize
[in]: Specifies the maximum size of luma coding unit.
Definition: nvEncodeAPI.h:1271
uint32_t frameSatd
[out]: Total SATD cost for whole frame.
Definition: nvEncodeAPI.h:1672
PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams
[out]: Client should access NvEncGetSequenceParams() API through this pointer.
Definition: nvEncodeAPI.h:3280
NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode
[in]: Specifies the entropy coding mode.
Definition: nvEncodeAPI.h:1228
uint32_t colourPrimaries
[in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specificatio...
Definition: nvEncodeAPI.h:1141
NV_ENC_SEI_PAYLOAD * seiPayloadArray
[in]: Array of SEI payloads which will be inserted for this frame.
Definition: nvEncodeAPI.h:1558
10 bit Packed A2R10G10B10.
Definition: nvEncodeAPI.h:325
Adaptive Transform 8x8 mode is auto selected by the encoder driver.
Definition: nvEncodeAPI.h:625
PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly
[out]: Client should access NvEncRunMotionEstimationOnly API through this pointer.
Definition: nvEncodeAPI.h:3294
uint32_t reserved
[in]: Reserved and must be set to 0.
Definition: nvEncodeAPI.h:1557
static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID
Definition: nvEncodeAPI.h:234
static const GUID NV_ENC_CODEC_H264_GUID
Definition: nvEncodeAPI.h:136
Indicates HW support for lookahead encoding (enableLookahead=1).
Definition: nvEncodeAPI.h:932
uint32_t numTemporalLayers
[in]: Specifies max temporal layers to be used for hierarchical coding.
Definition: nvEncodeAPI.h:1222
input resource type is a cuda device pointer surface
Definition: nvEncodeAPI.h:650
void * NV_ENC_REGISTERED_PTR
A Resource that has been registered with NVENCODE API.
Definition: nvEncodeAPI.h:114
uint32_t width
[in]: Input buffer Width.
Definition: nvEncodeAPI.h:1745
NV_ENC_CONFIG presetCfg
[out]: preset config returned by the Nvidia Video Encoder interface.
Definition: nvEncodeAPI.h:1458
uint32_t colourDescriptionPresentFlag
[in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix ar...
Definition: nvEncodeAPI.h:1140
Memory heap to be decided by the encoder driver based on the usage.
Definition: nvEncodeAPI.h:582
Planar YUV [Y plane followed by V and U planes].
Definition: nvEncodeAPI.h:316
Row Interleave mode for packing stereo frames.
Definition: nvEncodeAPI.h:638
This indicates that the size of the user buffer passed by the client is insufficient for the requeste...
Definition: nvEncodeAPI.h:486
uint64_t inputTimeStamp
[in]: Specifies presentation timestamp associated with the input picture.
Definition: nvEncodeAPI.h:1586
Reserved enum field.
Definition: nvEncodeAPI.h:735
NV_ENC_CAPS capsToQuery
[in]: Specifies the encode capability to be queried.
Definition: nvEncodeAPI.h:982
uint32_t chromaSampleLocationTop
[in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specifica...
Definition: nvEncodeAPI.h:1145
uint32_t videoFullRangeFlag
[in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Sp...
Definition: nvEncodeAPI.h:1139
static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID
Definition: nvEncodeAPI.h:154
Indicates support for PreProcessing.
Definition: nvEncodeAPI.h:879
static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID
Definition: nvEncodeAPI.h:226
uint32_t spsId
[in]: Specifies the SPS id to be used in sequence header.
Definition: nvEncodeAPI.h:1789
uint32_t bitstreamSizeInBytes
[out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr.
Definition: nvEncodeAPI.h:1663
static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID
Definition: nvEncodeAPI.h:218
NV_ENC_INPUT_PTR inputBuffer
[out]: Pointer to input buffer
Definition: nvEncodeAPI.h:1001
uint8_t lastCUInCTB
Marker to separate CUs in the current CTB from CUs in the next CTB.
Definition: nvEncodeAPI.h:1060
NV_ENC_INPUT_RESOURCE_TYPE resourceType
[in]: Specifies the type of resource to be registered.
Definition: nvEncodeAPI.h:1740
NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer(void *encoder, NV_ENC_CREATE_BITSTREAM_BUFFER *createBitstreamBufferParams)
Allocates an output bitstream buffer.
PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig
[out]: Client should access NvEncGetEncodePresetConfig() API through this pointer.
Definition: nvEncodeAPI.h:3268
This indicates that the client is attempting to unregister a resource that has not been successfully ...
Definition: nvEncodeAPI.h:554
uint32_t reserved3
[in]: Reserved and must be set to 0
Definition: nvEncodeAPI.h:1487
uint32_t maxNumRefFramesInDPB
[in]: Specifies the maximum number of references frames in the DPB.
Definition: nvEncodeAPI.h:1294
uint32_t ltrTrustMode
[in]: Specifies the LTR operating mode.
Definition: nvEncodeAPI.h:1250
uint32_t averageBitRate
[in]: Specifies the average bitrate(in bits/sec) used for encoding.
Definition: nvEncodeAPI.h:1095
Encode Stats structure.
uint32_t overscanInfo
[in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification).
Definition: nvEncodeAPI.h:1136
static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID
Definition: nvEncodeAPI.h:178
static const GUID NV_ENC_H264_PROFILE_STEREO_GUID
Definition: nvEncodeAPI.h:170
10 bit Packed A2B10G10R10.
Definition: nvEncodeAPI.h:337
Maximum aggregate throughput in MBs per sec.
Definition: nvEncodeAPI.h:896
NV_ENC_PIC_PARAMS_H264 h264PicParams
[in]: H264 encode picture params.
Definition: nvEncodeAPI.h:1569
PNVENCREGISTERRESOURCE nvEncRegisterResource
[out]: Client should access NvEncRegisterResource() API through this pointer.
Definition: nvEncodeAPI.h:3288
uint32_t target
[in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D.
Definition: nvEncodeAPI.h:1730
uint64_t inputDuration
[in]: Specifies duration of the input picture
Definition: nvEncodeAPI.h:1587
uint32_t ltrMarkFrameIdx
[in]: Specifies the long term referenceframe index to use for marking this frame as LTR...
Definition: nvEncodeAPI.h:1513
NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount(void *encoder, uint32_t *encodeGUIDCount)
Retrieves the number of supported encode GUIDs.
Indicates support Async mode.
Definition: nvEncodeAPI.h:886
uint32_t qpDeltaMapSize
[in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_...
Definition: nvEncodeAPI.h:1603
uint32_t videoSignalTypePresentFlag
[in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresent...
Definition: nvEncodeAPI.h:1137
NV_ENC_PIC_FLAGS
Encode Picture encode flags.
Definition: nvEncodeAPI.h:567
Encoder Session Creation parameters.
Definition: nvEncodeAPI.h:1819
PNVENCGETINPUTFORMATS nvEncGetInputFormats
[out]: Client should access NvEncGetInputFormats() API through this pointer.
Definition: nvEncodeAPI.h:3264
int64_t __int64
8 bit Packed A8B8G8R8.
Definition: nvEncodeAPI.h:333
NV_ENC_INPUT_RESOURCE_TYPE
Input Resource type.
Definition: nvEncodeAPI.h:647
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1457
GUID profileGUID
[in]: Specifies the codec profile guid.
Definition: nvEncodeAPI.h:1370
Temporal BDirect mode.
Definition: nvEncodeAPI.h:606
uint32_t sliceMode
[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divi...
Definition: nvEncodeAPI.h:1237
PNVENCENCODEPICTURE nvEncEncodePicture
[out]: Client should access NvEncEncodePicture() API through this pointer.
Definition: nvEncodeAPI.h:3274
PNVENCCREATEMVBUFFER nvEncCreateMVBuffer
[out]: Client should access NvEncCreateMVBuffer API through this pointer.
Definition: nvEncodeAPI.h:3292
NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs(void *encoder, GUID encodeGUID, GUID *presetGUIDs, uint32_t guidArraySize, uint32_t *encodePresetGUIDCount)
Receives an array of supported encoder preset GUIDs.
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1787
uint32_t sliceMode
[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divi...
Definition: nvEncodeAPI.h:1544
This indicates that the client is attempting to use a feature that is not implemented for the current...
Definition: nvEncodeAPI.h:543
NVENCSTATUS NVENCAPI NvEncLockInputBuffer(void *encoder, NV_ENC_LOCK_INPUT_BUFFER *lockInputBufferParams)
Locks an input buffer.
10 bit Semi-Planar YUV [Y plane followed by interleaved UV plane].
Definition: nvEncodeAPI.h:319
Spatial BDirect mode.
Definition: nvEncodeAPI.h:607
Indicates HW support for separate colour plane encoding.
Definition: nvEncodeAPI.h:773
uint32_t qpInterB
Definition: nvEncodeAPI.h:1083
NV_ENC_BUFFER_FORMAT mappedBufferFmt
[out]: Buffer format of the outputResource.
Definition: nvEncodeAPI.h:1714
Indicates HW support for Hierarchical B frames.
Definition: nvEncodeAPI.h:756
Indicates Dynamic Encode Resolution Change Support.
Definition: nvEncodeAPI.h:798
Entropy coding mode is auto selected by the encoder driver.
Definition: nvEncodeAPI.h:594
PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx
[out]: Client should access NvEncOpenEncodeSession() API through this pointer.
Definition: nvEncodeAPI.h:3287
NV_ENC_QP minQP
[in]: Specifies the minimum QP used for rate control.
Definition: nvEncodeAPI.h:1113
H264 encoder configuration parameters for ME only Mode.
uint32_t encodePicFlags
[in]: Specifies bit-wise OR`ed encode pic flags.
Definition: nvEncodeAPI.h:1584
uint32_t separateColourPlaneFlag
[in]: Set to 1 to enable 4:4:4 separate colour planes
Definition: nvEncodeAPI.h:1220
This indicates that device passed to the API call is invalid.
Definition: nvEncodeAPI.h:421
Encoder preset config.
This indicates that the client is attempting to unmap a resource that has not been successfully mappe...
Definition: nvEncodeAPI.h:560
NV_ENC_SEI_PAYLOAD * seiPayloadArray
[in]: Array of SEI payloads which will be inserted for this frame.
Definition: nvEncodeAPI.h:1503
uint32_t maxEncodeHeight
[in]: Maximum encode height to be allowed for current Encode session.
Definition: nvEncodeAPI.h:1419
Maximum output height supported.
Definition: nvEncodeAPI.h:783
Entropy coding mode is CABAC.
Definition: nvEncodeAPI.h:595
uint32_t idrPeriod
[in]: Specifies the IDR interval.
Definition: nvEncodeAPI.h:1290
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1580
H264 Video Usability Info parameters.
uint16_t lookaheadDepth
[in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1) ...
Definition: nvEncodeAPI.h:1120
Indicates Dynamic rate control mode Change Support.
Definition: nvEncodeAPI.h:821
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1015
int32_t
uint32_t refPicFlag
[in]: Set to 1 for a reference picture.
Definition: nvEncodeAPI.h:1527
void * bitstreamBufferPtr
[out]: Reserved and should not be used
Definition: nvEncodeAPI.h:1020
Intra predicted picture.
Definition: nvEncodeAPI.h:288
NV_ENC_PIC_STRUCT pictureStruct
[out]: Structure of the generated output picture.
Definition: nvEncodeAPI.h:1670
Maximum output width supported.
Definition: nvEncodeAPI.h:778
Bitstream buffer lock parameters.
uint32_t displayPOCSyntax
[in]: Specifies the display POC syntax This is required to be set if client is handling the picture t...
Definition: nvEncodeAPI.h:1526
PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer
[out]: Client should access NvEncDestroyBitstreamBuffer() API through this pointer.
Definition: nvEncodeAPI.h:3273
uint16_t Data2
[in]: Specifies the first group of 4 hexadecimal digits.
Definition: nvEncodeAPI.h:89
uint32_t left
[in]: X coordinate of the upper left corner of rectangular area to be specified.
Definition: nvEncodeAPI.h:102
8 bit Packed A8R8G8B8.
Definition: nvEncodeAPI.h:321
uint32_t maxBitRate
[in]: Specifies the maximum bitrate for the encoded output.
Definition: nvEncodeAPI.h:1096
NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent(void *encoder, NV_ENC_EVENT_PARAMS *eventParams)
Register event for notification to encoding completion.
Sequence and picture paramaters payload.
Constant bitrate mode.
Definition: nvEncodeAPI.h:259
External Motion Vector hint structure.
uint32_t vbvInitialDelay
[in]: Specifies the VBV(HRD) initial delay in bits.
Definition: nvEncodeAPI.h:1098
Motion vector structure per macroblock for H264 motion estimation.
Definition: nvEncodeAPI.h:1040
uint8_t mbType
0 (I), 1 (P), 2 (IPCM), 3 (B)
Definition: nvEncodeAPI.h:1043
User SEI message.
static const GUID NV_ENC_PRESET_BD_GUID
Definition: nvEncodeAPI.h:214
static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID
Definition: nvEncodeAPI.h:222
Disable BDirect mode.
Definition: nvEncodeAPI.h:605
Reserved - Not to be used by clients.
Definition: nvEncodeAPI.h:961
NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs(void *encoder, GUID encodeGUID, GUID *profileGUIDs, uint32_t guidArraySize, uint32_t *GUIDCount)
Retrieves an array of supported encode profile GUIDs.
uint32_t level
[in]: Specifies the encoding level.
Definition: nvEncodeAPI.h:1218
static const GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY
Definition: nvEncodeAPI.h:174
NV_ENC_BUFFER_FORMAT bufferFmt
[in]: Input buffer format
Definition: nvEncodeAPI.h:999
NV_ENC_H264_ENTROPY_CODING_MODE
H.264 entropy coding modes.
Definition: nvEncodeAPI.h:592
NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs(void *encoder, GUID *GUIDs, uint32_t guidArraySize, uint32_t *GUIDCount)
Retrieves an array of supported encoder codec GUIDs.
NV_ENC_PIC_STRUCT
Input picture structure.
Definition: nvEncodeAPI.h:274
Maximum number of Long Term Reference frames supported.
Definition: nvEncodeAPI.h:949
static const int8_t mv[256][2]
Definition: 4xm.c:77
PNVENCUNREGISTERRESOURCE nvEncUnregisterResource
[out]: Client should access NvEncUnregisterResource() API through this pointer.
Definition: nvEncodeAPI.h:3289
uint32_t inputHeight
[in]: Specifies the input buffer height
Definition: nvEncodeAPI.h:1582
static const GUID NV_ENC_PRESET_HP_GUID
Definition: nvEncodeAPI.h:206
uint32_t ltrUsageMode
[in]: Not supported.
Definition: nvEncodeAPI.h:1515
uint32_t spsId
[in]: Specifies the SPS id of the sequence header
Definition: nvEncodeAPI.h:1223
uint32_t qpInterP
Definition: nvEncodeAPI.h:1082
HalfPel motion vector precision.
Definition: nvEncodeAPI.h:303
int32_t __int32
uint32_t maxEncodeWidth
[in]: Maximum encode width to be used for current Encode session.
Definition: nvEncodeAPI.h:1417
NVENCSTATUS NVENCAPI NvEncGetEncodeStats(void *encoder, NV_ENC_STAT *encodeStats)
Get encoding statistics.
uint32_t reserved
[in]: Reserved and must be set to 0
Definition: nvEncodeAPI.h:1766
uint32_t seiPayloadArrayCnt
[in]: Specifies the number of elements allocated in seiPayloadArray array.
Definition: nvEncodeAPI.h:1502
uint32_t disableDeblockingFilterIDC
[in]: Specifies the deblocking filter mode.
Definition: nvEncodeAPI.h:1221
Indicates Reference Picture Invalidation Support.
Definition: nvEncodeAPI.h:873
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:995
PNVENCMAPINPUTRESOURCE nvEncMapInputResource
[out]: Client should access NvEncMapInputResource() API through this pointer.
Definition: nvEncodeAPI.h:3283
NVENCSTATUS NVENCAPI NvEncGetInputFormatCount(void *encoder, GUID encodeGUID, uint32_t *inputFmtCount)
Retrieve the number of supported Input formats.
encode device type is a cuda device
Definition: nvEncodeAPI.h:661
NV_ENC_MEMORY_HEAP
Memory heap to allocate input and output buffers.
Definition: nvEncodeAPI.h:580
PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs
[out]: Client should access NvEncGetEncodePresetGUIDs() API through this pointer. ...
Definition: nvEncodeAPI.h:3267
void * bitstreamBufferPtr
[out]: Pointer to the generated output bitstream.
Definition: nvEncodeAPI.h:1666
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1765
Creation parameters for output bitstream buffer.
Definition: nvEncodeAPI.h:1013
FMO usage is auto selected by the encoder driver.
Definition: nvEncodeAPI.h:615
NV_ENC_H264_FMO_MODE fmoMode
[in]: Specified the FMO Mode.
Definition: nvEncodeAPI.h:1226
NVENCSTATUS NVENCAPI NvEncGetSequenceParams(void *encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD *sequenceParamPayload)
Get encoded sequence and picture header.
Indicates HW support for Adaptive Transform.
Definition: nvEncodeAPI.h:730
uint32_t frameRateNum
[in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = fr...
Definition: nvEncodeAPI.h:1401
uint32_t maxTemporalLayers
[in]: Specifies the max temporal layer used for hierarchical coding.
Definition: nvEncodeAPI.h:1256
uint32_t reserved
[in]: Reserved and must be set to 0
Definition: nvEncodeAPI.h:1807
uint32_t sliceTypeArrayCnt
[in]: Client should set this to the number of elements allocated in sliceTypeData array...
Definition: nvEncodeAPI.h:1543
NV_ENC_STEREO_PACKING_MODE
Stereo frame packing modes.
Definition: nvEncodeAPI.h:633
uint32_t frameAvgQP
[out]: Average QP of the frame.
Definition: nvEncodeAPI.h:1671
Rate Control Configuration Paramters.
Definition: nvEncodeAPI.h:1090
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1806
uint32_t ltrUsageMode
[in]: Not supported.
Definition: nvEncodeAPI.h:1555
QP value for frames.
Definition: nvEncodeAPI.h:1080
Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
Definition: nvEncodeAPI.h:939
NV_ENC_H264_BDIRECT_MODE bdirectMode
[in]: Specifies the BDirect mode.
Definition: nvEncodeAPI.h:1227
H264 encoder configuration parameters.
uint32_t ppsId
[in]: Specifies the PPS id of the picture header
Definition: nvEncodeAPI.h:1224
NV_ENC_RC_PARAMS rcParams
[in]: Specifies the rate control parameters for the current encoding session.
Definition: nvEncodeAPI.h:1378
input resource type is a cuda array surface
Definition: nvEncodeAPI.h:651
PNVENCOPENENCODESESSION nvEncOpenEncodeSession
[out]: Client should access NvEncOpenEncodeSession() API through this pointer.
Definition: nvEncodeAPI.h:3258
This indicates that one or more of the pointers passed to the API call is invalid.
Definition: nvEncodeAPI.h:435
Maximum MBs per frame supported.
Definition: nvEncodeAPI.h:891
uint32_t frameIdx
[out]: Frame no.
Definition: nvEncodeAPI.h:1660
NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion(uint32_t *version)
Get the largest NvEncodeAPI version supported by the driver.
GUID encodeGUID
[in]: Specifies the Encode GUID for which the encoder is being created.
Definition: nvEncodeAPI.h:1395
NV_ENC_INPUT_PTR inputBuffer
[in]: Specifies the input buffer pointer.
Definition: nvEncodeAPI.h:1588
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1068
Codec-specific encoder configuration parameters to be set during initialization.
uint32_t chromaSampleLocationFlag
[in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are pre...
Definition: nvEncodeAPI.h:1144
uint32_t level
[in]: Specifies the level of the encoded bitstream.
Definition: nvEncodeAPI.h:1268
void * bufferDataPtr
[out]: Pointed to the locked input buffer data.
Definition: nvEncodeAPI.h:1693
uint32_t transferCharacteristics
[in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU...
Definition: nvEncodeAPI.h:1142
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1438
Codec specific per-picture encoding parameters.
Definition: nvEncodeAPI.h:1567
uint32_t monoChromeEncoding
[in]: Set this to 1 to enable monochrome encoding for this session.
Definition: nvEncodeAPI.h:1373
uint32_t ppsId
[in]: Specifies the PPS id to be used in picture header.
Definition: nvEncodeAPI.h:1790
Motion vector structure per CU for HEVC motion estimation.
Definition: nvEncodeAPI.h:1052
uint32_t right
[in]: X coordinate of the bottom right corner of the rectangular area to be specified.
Definition: nvEncodeAPI.h:104
Indicates HW support for FMO.
Definition: nvEncodeAPI.h:702
NV_ENC_H264_BDIRECT_MODE
H.264 specific Bdirect modes.
Definition: nvEncodeAPI.h:602
NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig
[in]: Specifies the HEVC-specific ME only encoder configuration.
Definition: nvEncodeAPI.h:1358
Indicates HW support for Hierarchical P frames.
Definition: nvEncodeAPI.h:749
uint8_t cuType
0 (I), 1(P), 2 (Skip)
Definition: nvEncodeAPI.h:1055
This indicates that an API call was made in wrong sequence/order.
Definition: nvEncodeAPI.h:452
uint8_t partitionType
Specifies the block partition type.
Definition: nvEncodeAPI.h:1044
NV_ENC_DEVICE_TYPE
Encoder Device type.
Definition: nvEncodeAPI.h:658
Indicates HW support for YUV444 mode encoding.
Definition: nvEncodeAPI.h:903
uint32_t hwEncodeStatus
[out]: The NvEncodeAPI interface status for the locked picture.
Definition: nvEncodeAPI.h:1661
uint32_t colourPlaneId
[in]: Specifies the colour plane ID associated with the current input.
Definition: nvEncodeAPI.h:1489
uint32_t ltrNumFrames
[in]: This parameter has different meaning in two LTR modes.
Definition: nvEncodeAPI.h:1295
#define NVENCAPI
Definition: nvEncodeAPI.h:73
Frame Sequential mode for packing stereo frames.
Definition: nvEncodeAPI.h:641
uint32_t pitch
[in]: Input buffer Pitch.
Definition: nvEncodeAPI.h:1747
MEOnly parameters that need to be sent on a per motion estimation basis.
int16_t mvy
the y component of MV in qpel units
Definition: nvEncodeAPI.h:1034
Structs needed for ME only mode.
Definition: nvEncodeAPI.h:1031
HEVC encoder configuration parameters for ME only Mode.
PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource
[out]: Client should access NvEncUnmapInputResource() API through this pointer.
Definition: nvEncodeAPI.h:3284
uint32_t sliceModeData
[in]: Specifies the parameter needed for sliceMode.
Definition: nvEncodeAPI.h:1548
uint32_t ltrFrameIdx
[out]: Frame index associated with this LTR frame.
Definition: nvEncodeAPI.h:1673
NVENCSTATUS NVENCAPI NvEncGetInputFormats(void *encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT *inputFmts, uint32_t inputFmtArraySize, uint32_t *inputFmtCount)
Retrieves an array of supported Input formats.
uint32_t frameRateDen
[in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = ...
Definition: nvEncodeAPI.h:1402
void * reserved
[in]: Reserved and must be set to 0.
Definition: nvEncodeAPI.h:1824
uint64_t outputDuration
[out]: Presentation duration associates with the encoded output.
Definition: nvEncodeAPI.h:1665
Picture is skipped.
Definition: nvEncodeAPI.h:291
uint32_t temporallayerIdxMask
[in]: Specifies the temporal layers (as a bitmask) whose QPs have changed.
Definition: nvEncodeAPI.h:1116
NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters
[in]: Specifies the HEVC video usability info pamameters
Definition: nvEncodeAPI.h:1310
NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer(void *encoder, NV_ENC_INPUT_PTR inputBuffer)
Unlocks the input buffer.
NV_ENC_CONFIG_HEVC hevcConfig
[in]: Specifies the HEVC-specific encoder configuration.
Definition: nvEncodeAPI.h:1356
uint32_t gopLength
[in]: Specifies the number of pictures in one GOP.
Definition: nvEncodeAPI.h:1371
uint32_t texture
[in]: The name of the texture to be used.
Definition: nvEncodeAPI.h:1729
uint32_t sliceModeData
[in]: Specifies the parameter needed for sliceMode.
Definition: nvEncodeAPI.h:1304
uint64_t outputTimeStamp
[out]: Presentation timestamp associated with the encoded output.
Definition: nvEncodeAPI.h:1664
NV_ENC_MV_PRECISION
Motion vector precisions.
Definition: nvEncodeAPI.h:299
This indicates that devices pass by the client is not supported.
Definition: nvEncodeAPI.h:410
IDR picture.
Definition: nvEncodeAPI.h:289
NV_ENC_MV_PRECISION mvPrecision
[in]: Specifies the desired motion vector prediction precision.
Definition: nvEncodeAPI.h:1377
Memory heap is in local video memory.
Definition: nvEncodeAPI.h:583
static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID
Definition: nvEncodeAPI.h:186
NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent(void *encoder, NV_ENC_EVENT_PARAMS *eventParams)
Unregister completion event.
uint32_t bitstreamRestrictionFlag
[in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream...
Definition: nvEncodeAPI.h:1147
uint32_t maxTemporalLayersMinus1
[in]: Specifies the max temporal layer used for hierarchical coding.
Definition: nvEncodeAPI.h:1309
uint32_t sliceMode
[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divi...
Definition: nvEncodeAPI.h:1504
NV_ENC_CAPS
Encoder capabilities enumeration.
Definition: nvEncodeAPI.h:669
Indicates Constrained Encoding mode support.
Definition: nvEncodeAPI.h:841
uint32_t sliceMode
[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divi...
Definition: nvEncodeAPI.h:1301
Bi-directionally predicted picture.
Definition: nvEncodeAPI.h:287
This indicates that completion event passed in NvEncEncodePicture() call is invalid.
Definition: nvEncodeAPI.h:441
NV_ENC_PIC_TYPE pictureType
[out]: Picture type of the encoded picture.
Definition: nvEncodeAPI.h:1669
uint32_t reserved
[in]: Reserved and should be set to 0.
Definition: nvEncodeAPI.h:3257
uint32_t reserved
[in]: Reserved and must be set to 0
Definition: nvEncodeAPI.h:1018
NV_ENC_INITIALIZE_PARAMS reInitEncodeParams
[in]: Encoder session re-initialization parameters.
Definition: nvEncodeAPI.h:1439
NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount(void *encoder, GUID encodeGUID, uint32_t *encodePresetGUIDCount)
Retrieves the number of supported preset GUIDs.
Indicates HW support for Sample Adaptive Offset.
Definition: nvEncodeAPI.h:917
Column Interleave mode for packing stereo frames.
Definition: nvEncodeAPI.h:637
static const GUID NV_ENC_PRESET_DEFAULT_GUID
Definition: nvEncodeAPI.h:202
uint32_t tier
[in]: Specifies the level tier of the encoded bitstream.
Definition: nvEncodeAPI.h:1269
int16_t mvx
the x component of MV in qpel units
Definition: nvEncodeAPI.h:1033
This indicates that an unsupported parameter was passed by the client.
Definition: nvEncodeAPI.h:471
uint32_t bottom
[in]: Y coordinate of the bottom right corner of the rectangular area to be specified.
Definition: nvEncodeAPI.h:105
NV_ENC_DEVICE_TYPE deviceType
[in]: Specified the device Type
Definition: nvEncodeAPI.h:1822
uint32_t reserved
[in]: Reserved and must be set to 0
Definition: nvEncodeAPI.h:1000
uint32_t frameIdx
[in]: Specifies the frame index associated with the input frame [optional].
Definition: nvEncodeAPI.h:1585
uint32_t ltrFrameBitmap
[out]: Bitmap of LTR frames indices which were used for encoding this frame.
Definition: nvEncodeAPI.h:1674
Maximum Encoding level supported (See NV_ENC_LEVEL for details).
Definition: nvEncodeAPI.h:761
Picture type unknown.
Definition: nvEncodeAPI.h:293
void * resourceToRegister
[in]: Handle to the resource that is being registered.
Definition: nvEncodeAPI.h:1749
uint32_t width
[in]: Input buffer width
Definition: nvEncodeAPI.h:996
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1821
void * NV_ENC_OUTPUT_PTR
NVENCODE API output buffer.
Definition: nvEncodeAPI.h:113
PNVENCDESTROYENCODER nvEncDestroyEncoder
[out]: Client should access NvEncDestroyEncoder() API through this pointer.
Definition: nvEncodeAPI.h:3285
NV_ENC_PIC_STRUCT pictureStruct
[in]: Specifies structure of the input picture.
Definition: nvEncodeAPI.h:1592
static const GUID NV_ENC_CODEC_HEVC_GUID
Definition: nvEncodeAPI.h:140
uint32_t intraRefreshPeriod
[in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set...
Definition: nvEncodeAPI.h:1230
static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID
Definition: nvEncodeAPI.h:182
NVENCSTATUS NVENCAPI NvEncLockBitstream(void *encoder, NV_ENC_LOCK_BITSTREAM *lockBitstreamBufferParams)
Lock output bitstream buffer.
static const GUID NV_ENC_PRESET_HQ_GUID
Definition: nvEncodeAPI.h:210
Planar YUV [Y plane followed by U and V planes].
Definition: nvEncodeAPI.h:317
Indicates Custom VBV Bufer Size support.
Definition: nvEncodeAPI.h:857
Write the sequence and picture header in encoded bitstream of the current picture.
Definition: nvEncodeAPI.h:573
uint32_t ltrTrustMode
[in]: Specifies the LTR operating mode.
Definition: nvEncodeAPI.h:1311
uint32_t darWidth
[in]: Specifies the display aspect ratio Width.
Definition: nvEncodeAPI.h:1399
static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID
Definition: nvEncodeAPI.h:230
void * pSysMemBuffer
[in]: Pointer to existing sysmem buffer
Definition: nvEncodeAPI.h:1002
uint8_t cuSize
0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64
Definition: nvEncodeAPI.h:1056
PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs
[out]: Client should access NvEncGetEncodeProfileGUIDs() API through this pointer.
Definition: nvEncodeAPI.h:3261
Indicates Intra Refresh Mode Support.
Definition: nvEncodeAPI.h:849
uint32_t viewID
[in]: Specifies left,right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set.
Definition: nvEncodeAPI.h:1632
NV_ENC_HEVC_CUSIZE minCUSize
[in]: Specifies the minimum size of luma coding unit.
Definition: nvEncodeAPI.h:1270
Memory heap is in uncached system memory.
Definition: nvEncodeAPI.h:585
uint32_t sliceModeData
[in]: Specifies the parameter needed for sliceMode.
Definition: nvEncodeAPI.h:1241
void * privData
[in]: Reserved private data buffer and must be set to NULL
Definition: nvEncodeAPI.h:1413
low-delay CBR, high quality
Definition: nvEncodeAPI.h:260
uint32_t darHeight
[in]: Specifies the display aspect ratio height.
Definition: nvEncodeAPI.h:1400
Checkerboard mode for packing stereo frames.
Definition: nvEncodeAPI.h:636
uint32_t enableEncodeAsync
[in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completi...
Definition: nvEncodeAPI.h:1403
NV_ENC_PARAMS_RC_MODE
Rate Control Modes.
Definition: nvEncodeAPI.h:255
NVENCSTATUS NVENCAPI NvEncMapInputResource(void *encoder, NV_ENC_MAP_INPUT_RESOURCE *mapInputResParams)
Map an externally created input resource pointer for encoding.
uint32_t qpIntra
Definition: nvEncodeAPI.h:1084
input resource type is a directx9 surface
Definition: nvEncodeAPI.h:649
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1709
static const GUID NV_ENC_H264_PROFILE_HIGH_GUID
Definition: nvEncodeAPI.h:162
int32_t frameIntervalP
[in]: Specifies the GOP pattern as follows: frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH frameIntervalP should be set to 1.
Definition: nvEncodeAPI.h:1372
NV_ENC_BUFFER_FORMAT bufferFmt
[in]: Specifies the input buffer format.
Definition: nvEncodeAPI.h:1591
NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer(void *encoder, NV_ENC_OUTPUT_PTR mvBuffer)
Release an output MV buffer for ME only mode.
uint16_t reserved
reserved padding for alignment
Definition: nvEncodeAPI.h:1045
PNVENCGETENCODESTATS nvEncGetEncodeStats
[out]: Client should access NvEncGetEncodeStats() API through this pointer.
Definition: nvEncodeAPI.h:3279
Top-Bottom mode for packing stereo frames.
Definition: nvEncodeAPI.h:640
NVENCSTATUS NVENCAPI NvEncDestroyEncoder(void *encoder)
Destroy Encoding Session.
PNVENCINITIALIZEENCODER nvEncInitializeEncoder
[out]: Client should access NvEncInitializeEncoder() API through this pointer.
Definition: nvEncodeAPI.h:3269
NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList)
Entry Point to the NvEncodeAPI interface.
uint32_t enablePTD
[in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface...
Definition: nvEncodeAPI.h:1404
NV_ENC_H264_FMO_MODE
H.264 specific FMO usage.
Definition: nvEncodeAPI.h:613
Indicates Dynamic Slice Mode Support.
Definition: nvEncodeAPI.h:865
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1654
encode device type is an OpenGL device.
Definition: nvEncodeAPI.h:662
CBR, high quality (slower)
Definition: nvEncodeAPI.h:261
PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream
[out]: Client should access NvEncUnlockBitstream() API through this pointer.
Definition: nvEncodeAPI.h:3276
Planar YUV [Y plane followed by U and V planes].
Definition: nvEncodeAPI.h:318
uint32_t encodeHeight
[in]: Specifies the encode height.
Definition: nvEncodeAPI.h:1398
uint32_t inputWidth
[in]: Specifies the input buffer width
Definition: nvEncodeAPI.h:1623
NV_ENC_PARAMS_FRAME_FIELD_MODE
Input frame encode modes.
Definition: nvEncodeAPI.h:245
NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
H.264 specific Adaptive Transform modes.
Definition: nvEncodeAPI.h:623
void * spsppsBuffer
[in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
Definition: nvEncodeAPI.h:1791
uint32_t videoFormat
[in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).
Definition: nvEncodeAPI.h:1138
Encoder configuration parameters to be set during initialization.
uint32_t chromaSampleLocationBot
[in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specif...
Definition: nvEncodeAPI.h:1146
MB adaptive frame/field.
Definition: nvEncodeAPI.h:249
uint32_t version
[in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER.
Definition: nvEncodeAPI.h:3256
encode device type is a directx9 device
Definition: nvEncodeAPI.h:660
This indicates that the encoder has not been initialized with NvEncInitializeEncoder() or that initia...
Definition: nvEncodeAPI.h:466
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:981
External motion vector hint counts per block type.
First picture in intra refresh cycle.
Definition: nvEncodeAPI.h:292
Event registration/unregistration parameters.
Definition: nvEncodeAPI.h:1804
NV_ENC_INPUT_PTR referenceFrame
[in]: Specifies the reference frame pointer
Definition: nvEncodeAPI.h:1626
NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly(void *encoder, NV_ENC_MEONLY_PARAMS *meOnlyParams)
Submit an input picture and reference frame for motion estimation in ME only mode.
uint32_t intraRefreshCnt
[in]: Specifies the length of intra refresh in number of frames for periodic intra refresh...
Definition: nvEncodeAPI.h:1232
This indicates that device passed to the API call is no longer available and needs to be reinitialize...
Definition: nvEncodeAPI.h:429
NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig
[in]: Specifies the H.264-specific ME only encoder configuration.
Definition: nvEncodeAPI.h:1357
This indicates that no encode capable devices were detected.
Definition: nvEncodeAPI.h:405
NVENCSTATUS
Error Codes.
Definition: nvEncodeAPI.h:395
uint32_t lastValidByteOffset
[out]: Offset of last valid bytes of completed bitstream
Definition: nvEncodeAPI.h:1770
Maximum number of B-Frames supported.
Definition: nvEncodeAPI.h:674
This indicates that NvEncMapInputResource() API failed to map the client provided input resource...
Definition: nvEncodeAPI.h:497
NV_ENC_CODEC_CONFIG encodeCodecConfig
[in]: Specifies the codec specific config parameters through this union.
Definition: nvEncodeAPI.h:1379
This indicates that the API call failed because it was unable to allocate enough memory to perform th...
Definition: nvEncodeAPI.h:458
uint32_t version
[in]: Struct version.
Definition: nvEncodeAPI.h:1689
Adaptive Transform 8x8 mode should be used.
Definition: nvEncodeAPI.h:627