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