Commit 570e8e7ba73732626da44533f8077f7e5694d7d2

Authored by Hu Chunming
1 parent b88660d7

提交 nv-codec-headers

nv-codec-headers/.gitignore 0 → 100644
  1 +ffnvcodec.pc
... ...
nv-codec-headers/Makefile 0 → 100644
  1 +PREFIX = /usr/local
  2 +LIBDIR = lib
  3 +INSTALL = install
  4 +SED = sed
  5 +
  6 +all:
  7 +ifeq ($(OS),Windows_NT)
  8 + $(SED) 's#@@PREFIX@@#$(shell cygpath -m ${PREFIX})#' ffnvcodec.pc.in > ffnvcodec.pc
  9 +else
  10 + $(SED) 's#@@PREFIX@@#$(PREFIX)#' ffnvcodec.pc.in > ffnvcodec.pc
  11 +endif
  12 +
  13 +install: all
  14 + $(INSTALL) -m 0755 -d '$(DESTDIR)$(PREFIX)/include/ffnvcodec'
  15 + $(INSTALL) -m 0644 include/ffnvcodec/*.h '$(DESTDIR)$(PREFIX)/include/ffnvcodec'
  16 + $(INSTALL) -m 0755 -d '$(DESTDIR)$(PREFIX)/$(LIBDIR)/pkgconfig'
  17 + $(INSTALL) -m 0644 ffnvcodec.pc '$(DESTDIR)$(PREFIX)/$(LIBDIR)/pkgconfig'
  18 +
  19 +uninstall:
  20 + rm -rf '$(DESTDIR)$(PREFIX)/include/ffnvcodec' '$(DESTDIR)$(PREFIX)/$(LIBDIR)/pkgconfig/ffnvcodec.pc'
  21 +
  22 +.PHONY: all install uninstall
  23 +
... ...
nv-codec-headers/README 0 → 100644
  1 +FFmpeg version of headers required to interface with Nvidias codec APIs.
  2 +
  3 +Corresponds to Video Codec SDK version 11.1.5.
  4 +
  5 +Minimum required driver versions:
  6 +Linux: 470.57.02 or newer
  7 +Windows: 471.41 or newer
... ...
nv-codec-headers/ffnvcodec.pc.in 0 → 100644
  1 +prefix=@@PREFIX@@
  2 +includedir=${prefix}/include
  3 +
  4 +Name: ffnvcodec
  5 +Description: FFmpeg version of Nvidia Codec SDK headers
  6 +Version: 11.1.5.1
  7 +Cflags: -I${includedir}
... ...
nv-codec-headers/include/ffnvcodec/dynlink_cuda.h 0 → 100644
  1 +/*
  2 + * This copyright notice applies to this header file only:
  3 + *
  4 + * Copyright (c) 2016
  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 +#if !defined(FFNV_DYNLINK_CUDA_H) && !defined(CUDA_VERSION)
  29 +#define FFNV_DYNLINK_CUDA_H
  30 +
  31 +#include <stddef.h>
  32 +#include <stdint.h>
  33 +
  34 +#define CUDA_VERSION 7050
  35 +
  36 +#if defined(_WIN32) || defined(__CYGWIN__)
  37 +#define CUDAAPI __stdcall
  38 +#else
  39 +#define CUDAAPI
  40 +#endif
  41 +
  42 +#define CU_CTX_SCHED_BLOCKING_SYNC 4
  43 +
  44 +typedef int CUdevice;
  45 +#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined(__LP64__) || defined(__aarch64__)
  46 +typedef unsigned long long CUdeviceptr;
  47 +#else
  48 +typedef unsigned int CUdeviceptr;
  49 +#endif
  50 +typedef unsigned long long CUtexObject;
  51 +
  52 +typedef struct CUarray_st *CUarray;
  53 +typedef struct CUctx_st *CUcontext;
  54 +typedef struct CUstream_st *CUstream;
  55 +typedef struct CUevent_st *CUevent;
  56 +typedef struct CUfunc_st *CUfunction;
  57 +typedef struct CUmod_st *CUmodule;
  58 +typedef struct CUmipmappedArray_st *CUmipmappedArray;
  59 +typedef struct CUgraphicsResource_st *CUgraphicsResource;
  60 +typedef struct CUextMemory_st *CUexternalMemory;
  61 +typedef struct CUextSemaphore_st *CUexternalSemaphore;
  62 +typedef struct CUeglStreamConnection_st *CUeglStreamConnection;
  63 +
  64 +typedef struct CUlinkState_st *CUlinkState;
  65 +
  66 +typedef enum cudaError_enum {
  67 + CUDA_SUCCESS = 0,
  68 + CUDA_ERROR_NOT_READY = 600,
  69 + CUDA_ERROR_LAUNCH_TIMEOUT = 702,
  70 + CUDA_ERROR_UNKNOWN = 999
  71 +} CUresult;
  72 +
  73 +/**
  74 + * Device properties (subset)
  75 + */
  76 +typedef enum CUdevice_attribute_enum {
  77 + CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13,
  78 + CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,
  79 + CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16,
  80 + CU_DEVICE_ATTRIBUTE_INTEGRATED = 18,
  81 + CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19,
  82 + CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20,
  83 + CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31,
  84 + CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33,
  85 + CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34,
  86 + CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35,
  87 + CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36,
  88 + CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37,
  89 + CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40,
  90 + CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41,
  91 + CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID = 50,
  92 + CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51,
  93 + CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
  94 + CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
  95 + CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83,
  96 + CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84,
  97 + CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85,
  98 +} CUdevice_attribute;
  99 +
  100 +typedef enum CUarray_format_enum {
  101 + CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
  102 + CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
  103 + CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
  104 + CU_AD_FORMAT_SIGNED_INT8 = 0x08,
  105 + CU_AD_FORMAT_SIGNED_INT16 = 0x09,
  106 + CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
  107 + CU_AD_FORMAT_HALF = 0x10,
  108 + CU_AD_FORMAT_FLOAT = 0x20
  109 +} CUarray_format;
  110 +
  111 +typedef enum CUmemorytype_enum {
  112 + CU_MEMORYTYPE_HOST = 1,
  113 + CU_MEMORYTYPE_DEVICE = 2,
  114 + CU_MEMORYTYPE_ARRAY = 3
  115 +} CUmemorytype;
  116 +
  117 +typedef enum CUlimit_enum {
  118 + CU_LIMIT_STACK_SIZE = 0,
  119 + CU_LIMIT_PRINTF_FIFO_SIZE = 1,
  120 + CU_LIMIT_MALLOC_HEAP_SIZE = 2,
  121 + CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 3,
  122 + CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 4
  123 +} CUlimit;
  124 +
  125 +typedef enum CUresourcetype_enum {
  126 + CU_RESOURCE_TYPE_ARRAY = 0x00,
  127 + CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
  128 + CU_RESOURCE_TYPE_LINEAR = 0x02,
  129 + CU_RESOURCE_TYPE_PITCH2D = 0x03
  130 +} CUresourcetype;
  131 +
  132 +typedef enum CUaddress_mode_enum {
  133 + CU_TR_ADDRESS_MODE_WRAP = 0,
  134 + CU_TR_ADDRESS_MODE_CLAMP = 1,
  135 + CU_TR_ADDRESS_MODE_MIRROR = 2,
  136 + CU_TR_ADDRESS_MODE_BORDER = 3
  137 +} CUaddress_mode;
  138 +
  139 +typedef enum CUfilter_mode_enum {
  140 + CU_TR_FILTER_MODE_POINT = 0,
  141 + CU_TR_FILTER_MODE_LINEAR = 1
  142 +} CUfilter_mode;
  143 +
  144 +typedef enum CUgraphicsRegisterFlags_enum {
  145 + CU_GRAPHICS_REGISTER_FLAGS_NONE = 0,
  146 + CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY = 1,
  147 + CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 2,
  148 + CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST = 4,
  149 + CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 8
  150 +} CUgraphicsRegisterFlags;
  151 +
  152 +typedef enum CUexternalMemoryHandleType_enum {
  153 + CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD = 1,
  154 + CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  155 + CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  156 + CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP = 4,
  157 + CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE = 5,
  158 +} CUexternalMemoryHandleType;
  159 +
  160 +typedef enum CUexternalSemaphoreHandleType_enum {
  161 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD = 1,
  162 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
  163 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = 3,
  164 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE = 4,
  165 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_FD = 9,
  166 + CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TIMELINE_SEMAPHORE_WIN32 = 10,
  167 +} CUexternalSemaphoreHandleType;
  168 +
  169 +typedef enum CUjit_option_enum
  170 +{
  171 + CU_JIT_MAX_REGISTERS = 0,
  172 + CU_JIT_THREADS_PER_BLOCK = 1,
  173 + CU_JIT_WALL_TIME = 2,
  174 + CU_JIT_INFO_LOG_BUFFER = 3,
  175 + CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES = 4,
  176 + CU_JIT_ERROR_LOG_BUFFER = 5,
  177 + CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES = 6,
  178 + CU_JIT_OPTIMIZATION_LEVEL = 7,
  179 + CU_JIT_TARGET_FROM_CUCONTEXT = 8,
  180 + CU_JIT_TARGET = 9,
  181 + CU_JIT_FALLBACK_STRATEGY = 10,
  182 + CU_JIT_GENERATE_DEBUG_INFO = 11,
  183 + CU_JIT_LOG_VERBOSE = 12,
  184 + CU_JIT_GENERATE_LINE_INFO = 13,
  185 + CU_JIT_CACHE_MODE = 14,
  186 + CU_JIT_NEW_SM3X_OPT = 15,
  187 + CU_JIT_FAST_COMPILE = 16,
  188 + CU_JIT_GLOBAL_SYMBOL_NAMES = 17,
  189 + CU_JIT_GLOBAL_SYMBOL_ADDRESSES = 18,
  190 + CU_JIT_GLOBAL_SYMBOL_COUNT = 19,
  191 + CU_JIT_NUM_OPTIONS
  192 +} CUjit_option;
  193 +
  194 +typedef enum CUjitInputType_enum
  195 +{
  196 + CU_JIT_INPUT_CUBIN = 0,
  197 + CU_JIT_INPUT_PTX = 1,
  198 + CU_JIT_INPUT_FATBINARY = 2,
  199 + CU_JIT_INPUT_OBJECT = 3,
  200 + CU_JIT_INPUT_LIBRARY = 4,
  201 + CU_JIT_NUM_INPUT_TYPES
  202 +} CUjitInputType;
  203 +
  204 +typedef enum CUeglFrameType
  205 +{
  206 + CU_EGL_FRAME_TYPE_ARRAY = 0,
  207 + CU_EGL_FRAME_TYPE_PITCH = 1,
  208 +} CUeglFrameType;
  209 +
  210 +typedef enum CUeglColorFormat
  211 +{
  212 + CU_EGL_COLOR_FORMAT_YUV420_PLANAR = 0x00,
  213 + CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR = 0x01,
  214 + CU_EGL_COLOR_FORMAT_YVU420_SEMIPLANAR = 0x15,
  215 + CU_EGL_COLOR_FORMAT_Y10V10U10_420_SEMIPLANAR = 0x17,
  216 + CU_EGL_COLOR_FORMAT_Y12V12U12_420_SEMIPLANAR = 0x19,
  217 +} CUeglColorFormat;
  218 +
  219 +typedef enum CUd3d11DeviceList_enum
  220 +{
  221 + CU_D3D11_DEVICE_LIST_ALL = 1,
  222 + CU_D3D11_DEVICE_LIST_CURRENT_FRAME = 2,
  223 + CU_D3D11_DEVICE_LIST_NEXT_FRAME = 3,
  224 +} CUd3d11DeviceList;
  225 +
  226 +#ifndef CU_UUID_HAS_BEEN_DEFINED
  227 +#define CU_UUID_HAS_BEEN_DEFINED
  228 +typedef struct CUuuid_st {
  229 + char bytes[16];
  230 +} CUuuid;
  231 +#endif
  232 +
  233 +typedef struct CUDA_MEMCPY2D_st {
  234 + size_t srcXInBytes;
  235 + size_t srcY;
  236 + CUmemorytype srcMemoryType;
  237 + const void *srcHost;
  238 + CUdeviceptr srcDevice;
  239 + CUarray srcArray;
  240 + size_t srcPitch;
  241 +
  242 + size_t dstXInBytes;
  243 + size_t dstY;
  244 + CUmemorytype dstMemoryType;
  245 + void *dstHost;
  246 + CUdeviceptr dstDevice;
  247 + CUarray dstArray;
  248 + size_t dstPitch;
  249 +
  250 + size_t WidthInBytes;
  251 + size_t Height;
  252 +} CUDA_MEMCPY2D;
  253 +
  254 +typedef struct CUDA_RESOURCE_DESC_st {
  255 + CUresourcetype resType;
  256 + union {
  257 + struct {
  258 + CUarray hArray;
  259 + } array;
  260 + struct {
  261 + CUmipmappedArray hMipmappedArray;
  262 + } mipmap;
  263 + struct {
  264 + CUdeviceptr devPtr;
  265 + CUarray_format format;
  266 + unsigned int numChannels;
  267 + size_t sizeInBytes;
  268 + } linear;
  269 + struct {
  270 + CUdeviceptr devPtr;
  271 + CUarray_format format;
  272 + unsigned int numChannels;
  273 + size_t width;
  274 + size_t height;
  275 + size_t pitchInBytes;
  276 + } pitch2D;
  277 + struct {
  278 + int reserved[32];
  279 + } reserved;
  280 + } res;
  281 + unsigned int flags;
  282 +} CUDA_RESOURCE_DESC;
  283 +
  284 +typedef struct CUDA_TEXTURE_DESC_st {
  285 + CUaddress_mode addressMode[3];
  286 + CUfilter_mode filterMode;
  287 + unsigned int flags;
  288 + unsigned int maxAnisotropy;
  289 + CUfilter_mode mipmapFilterMode;
  290 + float mipmapLevelBias;
  291 + float minMipmapLevelClamp;
  292 + float maxMipmapLevelClamp;
  293 + float borderColor[4];
  294 + int reserved[12];
  295 +} CUDA_TEXTURE_DESC;
  296 +
  297 +/* Unused type */
  298 +typedef struct CUDA_RESOURCE_VIEW_DESC_st CUDA_RESOURCE_VIEW_DESC;
  299 +
  300 +typedef unsigned int GLenum;
  301 +typedef unsigned int GLuint;
  302 +/*
  303 + * Prefix type name to avoid collisions. Clients using these types
  304 + * will include the real headers with real definitions.
  305 + */
  306 +typedef int32_t ffnv_EGLint;
  307 +typedef void *ffnv_EGLStreamKHR;
  308 +
  309 +typedef enum CUGLDeviceList_enum {
  310 + CU_GL_DEVICE_LIST_ALL = 1,
  311 + CU_GL_DEVICE_LIST_CURRENT_FRAME = 2,
  312 + CU_GL_DEVICE_LIST_NEXT_FRAME = 3,
  313 +} CUGLDeviceList;
  314 +
  315 +typedef struct CUDA_EXTERNAL_MEMORY_HANDLE_DESC_st {
  316 + CUexternalMemoryHandleType type;
  317 + union {
  318 + int fd;
  319 + struct {
  320 + void *handle;
  321 + const void *name;
  322 + } win32;
  323 + } handle;
  324 + unsigned long long size;
  325 + unsigned int flags;
  326 + unsigned int reserved[16];
  327 +} CUDA_EXTERNAL_MEMORY_HANDLE_DESC;
  328 +
  329 +typedef struct CUDA_EXTERNAL_MEMORY_BUFFER_DESC_st {
  330 + unsigned long long offset;
  331 + unsigned long long size;
  332 + unsigned int flags;
  333 + unsigned int reserved[16];
  334 +} CUDA_EXTERNAL_MEMORY_BUFFER_DESC;
  335 +
  336 +typedef struct CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC_st {
  337 + CUexternalSemaphoreHandleType type;
  338 + union {
  339 + int fd;
  340 + struct {
  341 + void *handle;
  342 + const void *name;
  343 + } win32;
  344 + } handle;
  345 + unsigned int flags;
  346 + unsigned int reserved[16];
  347 +} CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC;
  348 +
  349 +typedef struct CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_st {
  350 + struct {
  351 + struct {
  352 + unsigned long long value;
  353 + } fence;
  354 + unsigned int reserved[16];
  355 + } params;
  356 + unsigned int flags;
  357 + unsigned int reserved[16];
  358 +} CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS;
  359 +
  360 +typedef CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS;
  361 +
  362 +typedef struct CUDA_ARRAY3D_DESCRIPTOR_st {
  363 + size_t Width;
  364 + size_t Height;
  365 + size_t Depth;
  366 +
  367 + CUarray_format Format;
  368 + unsigned int NumChannels;
  369 + unsigned int Flags;
  370 +} CUDA_ARRAY3D_DESCRIPTOR;
  371 +
  372 +typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st {
  373 + unsigned long long offset;
  374 + CUDA_ARRAY3D_DESCRIPTOR arrayDesc;
  375 + unsigned int numLevels;
  376 + unsigned int reserved[16];
  377 +} CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC;
  378 +
  379 +#define CU_EGL_FRAME_MAX_PLANES 3
  380 +typedef struct CUeglFrame_st {
  381 + union {
  382 + CUarray pArray[CU_EGL_FRAME_MAX_PLANES];
  383 + void* pPitch[CU_EGL_FRAME_MAX_PLANES];
  384 + } frame;
  385 + unsigned int width;
  386 + unsigned int height;
  387 + unsigned int depth;
  388 + unsigned int pitch;
  389 + unsigned int planeCount;
  390 + unsigned int numChannels;
  391 + CUeglFrameType frameType;
  392 + CUeglColorFormat eglColorFormat;
  393 + CUarray_format cuFormat;
  394 +} CUeglFrame;
  395 +
  396 +#define CU_STREAM_NON_BLOCKING 1
  397 +#define CU_EVENT_BLOCKING_SYNC 1
  398 +#define CU_EVENT_DISABLE_TIMING 2
  399 +#define CU_TRSF_READ_AS_INTEGER 1
  400 +
  401 +typedef void CUDAAPI CUstreamCallback(CUstream hStream, CUresult status, void *userdata);
  402 +
  403 +typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
  404 +typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
  405 +typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
  406 +typedef CUresult CUDAAPI tcuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev);
  407 +typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
  408 +typedef CUresult CUDAAPI tcuDeviceGetUuid(CUuuid *uuid, CUdevice dev);
  409 +typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
  410 +typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
  411 +typedef CUresult CUDAAPI tcuCtxSetLimit(CUlimit limit, size_t value);
  412 +typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext pctx);
  413 +typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx);
  414 +typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx);
  415 +typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
  416 +typedef CUresult CUDAAPI tcuMemAllocPitch_v2(CUdeviceptr *dptr, size_t *pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes);
  417 +typedef CUresult CUDAAPI tcuMemAllocManaged(CUdeviceptr *dptr, size_t bytesize, unsigned int flags);
  418 +typedef CUresult CUDAAPI tcuMemsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream);
  419 +typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
  420 +typedef CUresult CUDAAPI tcuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t bytesize);
  421 +typedef CUresult CUDAAPI tcuMemcpyAsync(CUdeviceptr dst, CUdeviceptr src, size_t bytesize, CUstream hStream);
  422 +typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
  423 +typedef CUresult CUDAAPI tcuMemcpy2DAsync_v2(const CUDA_MEMCPY2D *pcopy, CUstream hStream);
  424 +typedef CUresult CUDAAPI tcuMemcpyHtoD_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount);
  425 +typedef CUresult CUDAAPI tcuMemcpyHtoDAsync_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream);
  426 +typedef CUresult CUDAAPI tcuMemcpyDtoH_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount);
  427 +typedef CUresult CUDAAPI tcuMemcpyDtoHAsync_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  428 +typedef CUresult CUDAAPI tcuMemcpyDtoD_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount);
  429 +typedef CUresult CUDAAPI tcuMemcpyDtoDAsync_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);
  430 +typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
  431 +typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);
  432 +typedef CUresult CUDAAPI tcuCtxGetDevice(CUdevice *device);
  433 +
  434 +typedef CUresult CUDAAPI tcuDevicePrimaryCtxRetain(CUcontext *pctx, CUdevice dev);
  435 +typedef CUresult CUDAAPI tcuDevicePrimaryCtxRelease(CUdevice dev);
  436 +typedef CUresult CUDAAPI tcuDevicePrimaryCtxSetFlags(CUdevice dev, unsigned int flags);
  437 +typedef CUresult CUDAAPI tcuDevicePrimaryCtxGetState(CUdevice dev, unsigned int *flags, int *active);
  438 +typedef CUresult CUDAAPI tcuDevicePrimaryCtxReset(CUdevice dev);
  439 +
  440 +typedef CUresult CUDAAPI tcuStreamCreate(CUstream *phStream, unsigned int flags);
  441 +typedef CUresult CUDAAPI tcuStreamQuery(CUstream hStream);
  442 +typedef CUresult CUDAAPI tcuStreamSynchronize(CUstream hStream);
  443 +typedef CUresult CUDAAPI tcuStreamDestroy_v2(CUstream hStream);
  444 +typedef CUresult CUDAAPI tcuStreamAddCallback(CUstream hStream, CUstreamCallback *callback, void *userdata, unsigned int flags);
  445 +typedef CUresult CUDAAPI tcuEventCreate(CUevent *phEvent, unsigned int flags);
  446 +typedef CUresult CUDAAPI tcuEventDestroy_v2(CUevent hEvent);
  447 +typedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent);
  448 +typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent);
  449 +typedef CUresult CUDAAPI tcuEventRecord(CUevent hEvent, CUstream hStream);
  450 +
  451 +typedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, CUstream hStream, void** kernelParams, void** extra);
  452 +typedef CUresult CUDAAPI tcuLinkCreate(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut);
  453 +typedef CUresult CUDAAPI tcuLinkAddData(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void** optionValues);
  454 +typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void** cubinOut, size_t* sizeOut);
  455 +typedef CUresult CUDAAPI tcuLinkDestroy(CUlinkState state);
  456 +typedef CUresult CUDAAPI tcuModuleLoadData(CUmodule* module, const void* image);
  457 +typedef CUresult CUDAAPI tcuModuleUnload(CUmodule hmod);
  458 +typedef CUresult CUDAAPI tcuModuleGetFunction(CUfunction* hfunc, CUmodule hmod, const char* name);
  459 +typedef CUresult CUDAAPI tcuModuleGetGlobal(CUdeviceptr *dptr, size_t *bytes, CUmodule hmod, const char* name);
  460 +typedef CUresult CUDAAPI tcuTexObjectCreate(CUtexObject* pTexObject, const CUDA_RESOURCE_DESC* pResDesc, const CUDA_TEXTURE_DESC* pTexDesc, const CUDA_RESOURCE_VIEW_DESC* pResViewDesc);
  461 +typedef CUresult CUDAAPI tcuTexObjectDestroy(CUtexObject texObject);
  462 +
  463 +typedef CUresult CUDAAPI tcuGLGetDevices_v2(unsigned int* pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
  464 +typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags);
  465 +typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource);
  466 +typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
  467 +typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream);
  468 +typedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray* pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel);
  469 +typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer(CUdeviceptr *devPtrOut, size_t *sizeOut, CUgraphicsResource resource);
  470 +
  471 +typedef CUresult CUDAAPI tcuImportExternalMemory(CUexternalMemory* extMem_out, const CUDA_EXTERNAL_MEMORY_HANDLE_DESC* memHandleDesc);
  472 +typedef CUresult CUDAAPI tcuDestroyExternalMemory(CUexternalMemory extMem);
  473 +typedef CUresult CUDAAPI tcuExternalMemoryGetMappedBuffer(CUdeviceptr* devPtr, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_BUFFER_DESC* bufferDesc);
  474 +typedef CUresult CUDAAPI tcuExternalMemoryGetMappedMipmappedArray(CUmipmappedArray* mipmap, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC* mipmapDesc);
  475 +typedef CUresult CUDAAPI tcuMipmappedArrayGetLevel(CUarray* pLevelArray, CUmipmappedArray hMipmappedArray, unsigned int level);
  476 +typedef CUresult CUDAAPI tcuMipmappedArrayDestroy(CUmipmappedArray hMipmappedArray);
  477 +
  478 +typedef CUresult CUDAAPI tcuImportExternalSemaphore(CUexternalSemaphore* extSem_out, const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC* semHandleDesc);
  479 +typedef CUresult CUDAAPI tcuDestroyExternalSemaphore(CUexternalSemaphore extSem);
  480 +typedef CUresult CUDAAPI tcuSignalExternalSemaphoresAsync(const CUexternalSemaphore* extSemArray, const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS* paramsArray, unsigned int numExtSems, CUstream stream);
  481 +typedef CUresult CUDAAPI tcuWaitExternalSemaphoresAsync(const CUexternalSemaphore* extSemArray, const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS* paramsArray, unsigned int numExtSems, CUstream stream);
  482 +
  483 +typedef CUresult CUDAAPI tcuArray3DCreate(CUarray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR* pAllocateArray);
  484 +typedef CUresult CUDAAPI tcuArrayDestroy(CUarray hArray);
  485 +
  486 +typedef CUresult CUDAAPI tcuEGLStreamProducerConnect(CUeglStreamConnection* conn, ffnv_EGLStreamKHR stream, ffnv_EGLint width, ffnv_EGLint height);
  487 +typedef CUresult CUDAAPI tcuEGLStreamProducerDisconnect(CUeglStreamConnection* conn);
  488 +typedef CUresult CUDAAPI tcuEGLStreamConsumerDisconnect(CUeglStreamConnection* conn);
  489 +typedef CUresult CUDAAPI tcuEGLStreamProducerPresentFrame(CUeglStreamConnection* conn, CUeglFrame eglframe, CUstream* pStream);
  490 +typedef CUresult CUDAAPI tcuEGLStreamProducerReturnFrame(CUeglStreamConnection* conn, CUeglFrame* eglframe, CUstream* pStream);
  491 +
  492 +typedef CUresult CUDAAPI tcuD3D11GetDevice(CUdevice *device, void *dxgiAdapter);
  493 +typedef CUresult CUDAAPI tcuD3D11GetDevices(unsigned int *deviceCountOut, CUdevice *devices, unsigned int deviceCount, void *d3d11device, CUd3d11DeviceList listType);
  494 +typedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource(CUgraphicsResource *cudaResourceOut, void *d3d11Resource, unsigned int flags);
  495 +#endif
... ...
nv-codec-headers/include/ffnvcodec/dynlink_cuviddec.h 0 → 100644
  1 +/*
  2 + * This copyright notice applies to this header file only:
  3 + *
  4 + * Copyright (c) 2010-2021 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 cuviddec.h
  30 +//! NVDECODE API provides video decoding interface to NVIDIA GPU devices.
  31 +//! This file contains constants, structure definitions and function prototypes used for decoding.
  32 +/*****************************************************************************************************/
  33 +
  34 +#if !defined(__CUDA_VIDEO_H__)
  35 +#define __CUDA_VIDEO_H__
  36 +
  37 +#if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
  38 +#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))
  39 +#define __CUVID_DEVPTR64
  40 +#endif
  41 +#endif
  42 +
  43 +#define NVDECAPI_MAJOR_VERSION 11
  44 +#define NVDECAPI_MINOR_VERSION 1
  45 +
  46 +#define NVDECAPI_VERSION (NVDECAPI_MAJOR_VERSION | (NVDECAPI_MINOR_VERSION << 24))
  47 +
  48 +#if defined(__cplusplus)
  49 +extern "C" {
  50 +#endif /* __cplusplus */
  51 +
  52 +#if defined(__CYGWIN__)
  53 +typedef unsigned int tcu_ulong;
  54 +#else
  55 +typedef unsigned long tcu_ulong;
  56 +#endif
  57 +
  58 +typedef void *CUvideodecoder;
  59 +typedef struct _CUcontextlock_st *CUvideoctxlock;
  60 +
  61 +/*********************************************************************************/
  62 +//! \enum cudaVideoCodec
  63 +//! Video codec enums
  64 +//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
  65 +/*********************************************************************************/
  66 +typedef enum cudaVideoCodec_enum {
  67 + cudaVideoCodec_MPEG1=0, /**< MPEG1 */
  68 + cudaVideoCodec_MPEG2, /**< MPEG2 */
  69 + cudaVideoCodec_MPEG4, /**< MPEG4 */
  70 + cudaVideoCodec_VC1, /**< VC1 */
  71 + cudaVideoCodec_H264, /**< H264 */
  72 + cudaVideoCodec_JPEG, /**< JPEG */
  73 + cudaVideoCodec_H264_SVC, /**< H264-SVC */
  74 + cudaVideoCodec_H264_MVC, /**< H264-MVC */
  75 + cudaVideoCodec_HEVC, /**< HEVC */
  76 + cudaVideoCodec_VP8, /**< VP8 */
  77 + cudaVideoCodec_VP9, /**< VP9 */
  78 + cudaVideoCodec_AV1, /**< AV1 */
  79 + cudaVideoCodec_NumCodecs, /**< Max codecs */
  80 + // Uncompressed YUV
  81 + cudaVideoCodec_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V')), /**< Y,U,V (4:2:0) */
  82 + cudaVideoCodec_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,V,U (4:2:0) */
  83 + cudaVideoCodec_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2')), /**< Y,UV (4:2:0) */
  84 + cudaVideoCodec_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V')), /**< YUYV/YUY2 (4:2:2) */
  85 + cudaVideoCodec_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y')) /**< UYVY (4:2:2) */
  86 +} cudaVideoCodec;
  87 +
  88 +/*********************************************************************************/
  89 +//! \enum cudaVideoSurfaceFormat
  90 +//! Video surface format enums used for output format of decoded output
  91 +//! These enums are used in CUVIDDECODECREATEINFO structure
  92 +/*********************************************************************************/
  93 +typedef enum cudaVideoSurfaceFormat_enum {
  94 + cudaVideoSurfaceFormat_NV12=0, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
  95 + cudaVideoSurfaceFormat_P016=1, /**< 16 bit Semi-Planar YUV [Y plane followed by interleaved UV plane].
  96 + Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0) */
  97 + cudaVideoSurfaceFormat_YUV444=2, /**< Planar YUV [Y plane followed by U and V planes] */
  98 + cudaVideoSurfaceFormat_YUV444_16Bit=3, /**< 16 bit Planar YUV [Y plane followed by U and V planes].
  99 + Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0) */
  100 +} cudaVideoSurfaceFormat;
  101 +
  102 +/******************************************************************************************************************/
  103 +//! \enum cudaVideoDeinterlaceMode
  104 +//! Deinterlacing mode enums
  105 +//! These enums are used in CUVIDDECODECREATEINFO structure
  106 +//! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing
  107 +//! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes
  108 +/******************************************************************************************************************/
  109 +typedef enum cudaVideoDeinterlaceMode_enum {
  110 + cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */
  111 + cudaVideoDeinterlaceMode_Bob, /**< Drop one field */
  112 + cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */
  113 +} cudaVideoDeinterlaceMode;
  114 +
  115 +/**************************************************************************************************************/
  116 +//! \enum cudaVideoChromaFormat
  117 +//! Chroma format enums
  118 +//! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures
  119 +/**************************************************************************************************************/
  120 +typedef enum cudaVideoChromaFormat_enum {
  121 + cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */
  122 + cudaVideoChromaFormat_420, /**< YUV 4:2:0 */
  123 + cudaVideoChromaFormat_422, /**< YUV 4:2:2 */
  124 + cudaVideoChromaFormat_444 /**< YUV 4:4:4 */
  125 +} cudaVideoChromaFormat;
  126 +
  127 +/*************************************************************************************************************/
  128 +//! \enum cudaVideoCreateFlags
  129 +//! Decoder flag enums to select preferred decode path
  130 +//! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible
  131 +/*************************************************************************************************************/
  132 +typedef enum cudaVideoCreateFlags_enum {
  133 + cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */
  134 + cudaVideoCreate_PreferCUDA = 0x01, /**< Use CUDA-based decoder (requires valid vidLock object for multi-threading) */
  135 + cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */
  136 + cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */
  137 +} cudaVideoCreateFlags;
  138 +
  139 +
  140 +/*************************************************************************/
  141 +//! \enum cuvidDecodeStatus
  142 +//! Decode status enums
  143 +//! These enums are used in CUVIDGETDECODESTATUS structure
  144 +/*************************************************************************/
  145 +typedef enum cuvidDecodeStatus_enum
  146 +{
  147 + cuvidDecodeStatus_Invalid = 0, // Decode status is not valid
  148 + cuvidDecodeStatus_InProgress = 1, // Decode is in progress
  149 + cuvidDecodeStatus_Success = 2, // Decode is completed without any errors
  150 + // 3 to 7 enums are reserved for future use
  151 + cuvidDecodeStatus_Error = 8, // Decode is completed with an error (error is not concealed)
  152 + cuvidDecodeStatus_Error_Concealed = 9, // Decode is completed with an error and error is concealed
  153 +} cuvidDecodeStatus;
  154 +
  155 +/**************************************************************************************************************/
  156 +//! \struct CUVIDDECODECAPS;
  157 +//! This structure is used in cuvidGetDecoderCaps API
  158 +/**************************************************************************************************************/
  159 +typedef struct _CUVIDDECODECAPS
  160 +{
  161 + cudaVideoCodec eCodecType; /**< IN: cudaVideoCodec_XXX */
  162 + cudaVideoChromaFormat eChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */
  163 + unsigned int nBitDepthMinus8; /**< IN: The Value "BitDepth minus 8" */
  164 + unsigned int reserved1[3]; /**< Reserved for future use - set to zero */
  165 +
  166 + unsigned char bIsSupported; /**< OUT: 1 if codec supported, 0 if not supported */
  167 + unsigned char nNumNVDECs; /**< OUT: Number of NVDECs that can support IN params */
  168 + unsigned short nOutputFormatMask; /**< OUT: each bit represents corresponding cudaVideoSurfaceFormat enum */
  169 + unsigned int nMaxWidth; /**< OUT: Max supported coded width in pixels */
  170 + unsigned int nMaxHeight; /**< OUT: Max supported coded height in pixels */
  171 + unsigned int nMaxMBCount; /**< OUT: Max supported macroblock count
  172 + CodedWidth*CodedHeight/256 must be <= nMaxMBCount */
  173 + unsigned short nMinWidth; /**< OUT: Min supported coded width in pixels */
  174 + unsigned short nMinHeight; /**< OUT: Min supported coded height in pixels */
  175 + unsigned char bIsHistogramSupported; /**< OUT: 1 if Y component histogram output is supported, 0 if not
  176 + Note: histogram is computed on original picture data before
  177 + any post-processing like scaling, cropping, etc. is applied */
  178 + unsigned char nCounterBitDepth; /**< OUT: histogram counter bit depth */
  179 + unsigned short nMaxHistogramBins; /**< OUT: Max number of histogram bins */
  180 + unsigned int reserved3[10]; /**< Reserved for future use - set to zero */
  181 +} CUVIDDECODECAPS;
  182 +
  183 +/**************************************************************************************************************/
  184 +//! \struct CUVIDDECODECREATEINFO
  185 +//! This structure is used in cuvidCreateDecoder API
  186 +/**************************************************************************************************************/
  187 +typedef struct _CUVIDDECODECREATEINFO
  188 +{
  189 + tcu_ulong ulWidth; /**< IN: Coded sequence width in pixels */
  190 + tcu_ulong ulHeight; /**< IN: Coded sequence height in pixels */
  191 + tcu_ulong ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */
  192 + cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */
  193 + cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */
  194 + tcu_ulong ulCreationFlags; /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX) */
  195 + tcu_ulong bitDepthMinus8; /**< IN: The value "BitDepth minus 8" */
  196 + tcu_ulong ulIntraDecodeOnly; /**< IN: Set 1 only if video has all intra frames (default value is 0). This will
  197 + optimize video memory for Intra frames only decoding. The support is limited
  198 + to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which
  199 + are not supported. However decoding might fail if the flag is enabled in case
  200 + of supported codecs for regular bit streams having P and/or B frames. */
  201 + tcu_ulong ulMaxWidth; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder */
  202 + tcu_ulong ulMaxHeight; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */
  203 + tcu_ulong Reserved1; /**< Reserved for future use - set to zero */
  204 + /**
  205 + * IN: area of the frame that should be displayed
  206 + */
  207 + struct {
  208 + short left;
  209 + short top;
  210 + short right;
  211 + short bottom;
  212 + } display_area;
  213 +
  214 + cudaVideoSurfaceFormat OutputFormat; /**< IN: cudaVideoSurfaceFormat_XXX */
  215 + cudaVideoDeinterlaceMode DeinterlaceMode; /**< IN: cudaVideoDeinterlaceMode_XXX */
  216 + tcu_ulong ulTargetWidth; /**< IN: Post-processed output width (Should be aligned to 2) */
  217 + tcu_ulong ulTargetHeight; /**< IN: Post-processed output height (Should be aligned to 2) */
  218 + tcu_ulong ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */
  219 + CUvideoctxlock vidLock; /**< IN: If non-NULL, context lock used for synchronizing ownership of
  220 + the cuda context. Needed for cudaVideoCreate_PreferCUDA decode */
  221 + /**
  222 + * IN: target rectangle in the output frame (for aspect ratio conversion)
  223 + * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used
  224 + */
  225 + struct {
  226 + short left;
  227 + short top;
  228 + short right;
  229 + short bottom;
  230 + } target_rect;
  231 +
  232 + tcu_ulong enableHistogram; /**< IN: enable histogram output, if supported */
  233 + tcu_ulong Reserved2[4]; /**< Reserved for future use - set to zero */
  234 +} CUVIDDECODECREATEINFO;
  235 +
  236 +/*********************************************************/
  237 +//! \struct CUVIDH264DPBENTRY
  238 +//! H.264 DPB entry
  239 +//! This structure is used in CUVIDH264PICPARAMS structure
  240 +/*********************************************************/
  241 +typedef struct _CUVIDH264DPBENTRY
  242 +{
  243 + int PicIdx; /**< picture index of reference frame */
  244 + int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */
  245 + int is_long_term; /**< 0=short term reference, 1=long term reference */
  246 + int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */
  247 + int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */
  248 + int FieldOrderCnt[2]; /**< field order count of top and bottom fields */
  249 +} CUVIDH264DPBENTRY;
  250 +
  251 +/************************************************************/
  252 +//! \struct CUVIDH264MVCEXT
  253 +//! H.264 MVC picture parameters ext
  254 +//! This structure is used in CUVIDH264PICPARAMS structure
  255 +/************************************************************/
  256 +typedef struct _CUVIDH264MVCEXT
  257 +{
  258 + int num_views_minus1; /**< Max number of coded views minus 1 in video : Range - 0 to 1023 */
  259 + int view_id; /**< view identifier */
  260 + unsigned char inter_view_flag; /**< 1 if used for inter-view prediction, 0 if not */
  261 + unsigned char num_inter_view_refs_l0; /**< number of inter-view ref pics in RefPicList0 */
  262 + unsigned char num_inter_view_refs_l1; /**< number of inter-view ref pics in RefPicList1 */
  263 + unsigned char MVCReserved8Bits; /**< Reserved bits */
  264 + int InterViewRefsL0[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList0 */
  265 + int InterViewRefsL1[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList1 */
  266 +} CUVIDH264MVCEXT;
  267 +
  268 +/*********************************************************/
  269 +//! \struct CUVIDH264SVCEXT
  270 +//! H.264 SVC picture parameters ext
  271 +//! This structure is used in CUVIDH264PICPARAMS structure
  272 +/*********************************************************/
  273 +typedef struct _CUVIDH264SVCEXT
  274 +{
  275 + unsigned char profile_idc;
  276 + unsigned char level_idc;
  277 + unsigned char DQId;
  278 + unsigned char DQIdMax;
  279 + unsigned char disable_inter_layer_deblocking_filter_idc;
  280 + unsigned char ref_layer_chroma_phase_y_plus1;
  281 + signed char inter_layer_slice_alpha_c0_offset_div2;
  282 + signed char inter_layer_slice_beta_offset_div2;
  283 +
  284 + unsigned short DPBEntryValidFlag;
  285 + unsigned char inter_layer_deblocking_filter_control_present_flag;
  286 + unsigned char extended_spatial_scalability_idc;
  287 + unsigned char adaptive_tcoeff_level_prediction_flag;
  288 + unsigned char slice_header_restriction_flag;
  289 + unsigned char chroma_phase_x_plus1_flag;
  290 + unsigned char chroma_phase_y_plus1;
  291 +
  292 + unsigned char tcoeff_level_prediction_flag;
  293 + unsigned char constrained_intra_resampling_flag;
  294 + unsigned char ref_layer_chroma_phase_x_plus1_flag;
  295 + unsigned char store_ref_base_pic_flag;
  296 + unsigned char Reserved8BitsA;
  297 + unsigned char Reserved8BitsB;
  298 +
  299 + short scaled_ref_layer_left_offset;
  300 + short scaled_ref_layer_top_offset;
  301 + short scaled_ref_layer_right_offset;
  302 + short scaled_ref_layer_bottom_offset;
  303 + unsigned short Reserved16Bits;
  304 + struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded.
  305 + Linked list ends at the target layer. */
  306 + int bRefBaseLayer; /**< whether to store ref base pic */
  307 +} CUVIDH264SVCEXT;
  308 +
  309 +/******************************************************/
  310 +//! \struct CUVIDH264PICPARAMS
  311 +//! H.264 picture parameters
  312 +//! This structure is used in CUVIDPICPARAMS structure
  313 +/******************************************************/
  314 +typedef struct _CUVIDH264PICPARAMS
  315 +{
  316 + // SPS
  317 + int log2_max_frame_num_minus4;
  318 + int pic_order_cnt_type;
  319 + int log2_max_pic_order_cnt_lsb_minus4;
  320 + int delta_pic_order_always_zero_flag;
  321 + int frame_mbs_only_flag;
  322 + int direct_8x8_inference_flag;
  323 + int num_ref_frames; // NOTE: shall meet level 4.1 restrictions
  324 + unsigned char residual_colour_transform_flag;
  325 + unsigned char bit_depth_luma_minus8; // Must be 0 (only 8-bit supported)
  326 + unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)
  327 + unsigned char qpprime_y_zero_transform_bypass_flag;
  328 + // PPS
  329 + int entropy_coding_mode_flag;
  330 + int pic_order_present_flag;
  331 + int num_ref_idx_l0_active_minus1;
  332 + int num_ref_idx_l1_active_minus1;
  333 + int weighted_pred_flag;
  334 + int weighted_bipred_idc;
  335 + int pic_init_qp_minus26;
  336 + int deblocking_filter_control_present_flag;
  337 + int redundant_pic_cnt_present_flag;
  338 + int transform_8x8_mode_flag;
  339 + int MbaffFrameFlag;
  340 + int constrained_intra_pred_flag;
  341 + int chroma_qp_index_offset;
  342 + int second_chroma_qp_index_offset;
  343 + int ref_pic_flag;
  344 + int frame_num;
  345 + int CurrFieldOrderCnt[2];
  346 + // DPB
  347 + CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB
  348 + // Quantization Matrices (raster-order)
  349 + unsigned char WeightScale4x4[6][16];
  350 + unsigned char WeightScale8x8[2][64];
  351 + // FMO/ASO
  352 + unsigned char fmo_aso_enable;
  353 + unsigned char num_slice_groups_minus1;
  354 + unsigned char slice_group_map_type;
  355 + signed char pic_init_qs_minus26;
  356 + unsigned int slice_group_change_rate_minus1;
  357 + union
  358 + {
  359 + unsigned long long slice_group_map_addr;
  360 + const unsigned char *pMb2SliceGroupMap;
  361 + } fmo;
  362 + unsigned int Reserved[12];
  363 + // SVC/MVC
  364 + union
  365 + {
  366 + CUVIDH264MVCEXT mvcext;
  367 + CUVIDH264SVCEXT svcext;
  368 + };
  369 +} CUVIDH264PICPARAMS;
  370 +
  371 +
  372 +/********************************************************/
  373 +//! \struct CUVIDMPEG2PICPARAMS
  374 +//! MPEG-2 picture parameters
  375 +//! This structure is used in CUVIDPICPARAMS structure
  376 +/********************************************************/
  377 +typedef struct _CUVIDMPEG2PICPARAMS
  378 +{
  379 + int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
  380 + int BackwardRefIdx; // Picture index of backward reference (B-frames)
  381 + int picture_coding_type;
  382 + int full_pel_forward_vector;
  383 + int full_pel_backward_vector;
  384 + int f_code[2][2];
  385 + int intra_dc_precision;
  386 + int frame_pred_frame_dct;
  387 + int concealment_motion_vectors;
  388 + int q_scale_type;
  389 + int intra_vlc_format;
  390 + int alternate_scan;
  391 + int top_field_first;
  392 + // Quantization matrices (raster order)
  393 + unsigned char QuantMatrixIntra[64];
  394 + unsigned char QuantMatrixInter[64];
  395 +} CUVIDMPEG2PICPARAMS;
  396 +
  397 +// MPEG-4 has VOP types instead of Picture types
  398 +#define I_VOP 0
  399 +#define P_VOP 1
  400 +#define B_VOP 2
  401 +#define S_VOP 3
  402 +
  403 +/*******************************************************/
  404 +//! \struct CUVIDMPEG4PICPARAMS
  405 +//! MPEG-4 picture parameters
  406 +//! This structure is used in CUVIDPICPARAMS structure
  407 +/*******************************************************/
  408 +typedef struct _CUVIDMPEG4PICPARAMS
  409 +{
  410 + int ForwardRefIdx; // Picture index of forward reference (P/B-frames)
  411 + int BackwardRefIdx; // Picture index of backward reference (B-frames)
  412 + // VOL
  413 + int video_object_layer_width;
  414 + int video_object_layer_height;
  415 + int vop_time_increment_bitcount;
  416 + int top_field_first;
  417 + int resync_marker_disable;
  418 + int quant_type;
  419 + int quarter_sample;
  420 + int short_video_header;
  421 + int divx_flags;
  422 + // VOP
  423 + int vop_coding_type;
  424 + int vop_coded;
  425 + int vop_rounding_type;
  426 + int alternate_vertical_scan_flag;
  427 + int interlaced;
  428 + int vop_fcode_forward;
  429 + int vop_fcode_backward;
  430 + int trd[2];
  431 + int trb[2];
  432 + // Quantization matrices (raster order)
  433 + unsigned char QuantMatrixIntra[64];
  434 + unsigned char QuantMatrixInter[64];
  435 + int gmc_enabled;
  436 +} CUVIDMPEG4PICPARAMS;
  437 +
  438 +/********************************************************/
  439 +//! \struct CUVIDVC1PICPARAMS
  440 +//! VC1 picture parameters
  441 +//! This structure is used in CUVIDPICPARAMS structure
  442 +/********************************************************/
  443 +typedef struct _CUVIDVC1PICPARAMS
  444 +{
  445 + int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */
  446 + int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */
  447 + int FrameWidth; /**< Actual frame width */
  448 + int FrameHeight; /**< Actual frame height */
  449 + // PICTURE
  450 + int intra_pic_flag; /**< Set to 1 for I,BI frames */
  451 + int ref_pic_flag; /**< Set to 1 for I,P frames */
  452 + int progressive_fcm; /**< Progressive frame */
  453 + // SEQUENCE
  454 + int profile;
  455 + int postprocflag;
  456 + int pulldown;
  457 + int interlace;
  458 + int tfcntrflag;
  459 + int finterpflag;
  460 + int psf;
  461 + int multires;
  462 + int syncmarker;
  463 + int rangered;
  464 + int maxbframes;
  465 + // ENTRYPOINT
  466 + int panscan_flag;
  467 + int refdist_flag;
  468 + int extended_mv;
  469 + int dquant;
  470 + int vstransform;
  471 + int loopfilter;
  472 + int fastuvmc;
  473 + int overlap;
  474 + int quantizer;
  475 + int extended_dmv;
  476 + int range_mapy_flag;
  477 + int range_mapy;
  478 + int range_mapuv_flag;
  479 + int range_mapuv;
  480 + int rangeredfrm; // range reduction state
  481 +} CUVIDVC1PICPARAMS;
  482 +
  483 +/***********************************************************/
  484 +//! \struct CUVIDJPEGPICPARAMS
  485 +//! JPEG picture parameters
  486 +//! This structure is used in CUVIDPICPARAMS structure
  487 +/***********************************************************/
  488 +typedef struct _CUVIDJPEGPICPARAMS
  489 +{
  490 + int Reserved;
  491 +} CUVIDJPEGPICPARAMS;
  492 +
  493 +
  494 +/*******************************************************/
  495 +//! \struct CUVIDHEVCPICPARAMS
  496 +//! HEVC picture parameters
  497 +//! This structure is used in CUVIDPICPARAMS structure
  498 +/*******************************************************/
  499 +typedef struct _CUVIDHEVCPICPARAMS
  500 +{
  501 + // sps
  502 + int pic_width_in_luma_samples;
  503 + int pic_height_in_luma_samples;
  504 + unsigned char log2_min_luma_coding_block_size_minus3;
  505 + unsigned char log2_diff_max_min_luma_coding_block_size;
  506 + unsigned char log2_min_transform_block_size_minus2;
  507 + unsigned char log2_diff_max_min_transform_block_size;
  508 + unsigned char pcm_enabled_flag;
  509 + unsigned char log2_min_pcm_luma_coding_block_size_minus3;
  510 + unsigned char log2_diff_max_min_pcm_luma_coding_block_size;
  511 + unsigned char pcm_sample_bit_depth_luma_minus1;
  512 +
  513 + unsigned char pcm_sample_bit_depth_chroma_minus1;
  514 + unsigned char pcm_loop_filter_disabled_flag;
  515 + unsigned char strong_intra_smoothing_enabled_flag;
  516 + unsigned char max_transform_hierarchy_depth_intra;
  517 + unsigned char max_transform_hierarchy_depth_inter;
  518 + unsigned char amp_enabled_flag;
  519 + unsigned char separate_colour_plane_flag;
  520 + unsigned char log2_max_pic_order_cnt_lsb_minus4;
  521 +
  522 + unsigned char num_short_term_ref_pic_sets;
  523 + unsigned char long_term_ref_pics_present_flag;
  524 + unsigned char num_long_term_ref_pics_sps;
  525 + unsigned char sps_temporal_mvp_enabled_flag;
  526 + unsigned char sample_adaptive_offset_enabled_flag;
  527 + unsigned char scaling_list_enable_flag;
  528 + unsigned char IrapPicFlag;
  529 + unsigned char IdrPicFlag;
  530 +
  531 + unsigned char bit_depth_luma_minus8;
  532 + unsigned char bit_depth_chroma_minus8;
  533 + //sps/pps extension fields
  534 + unsigned char log2_max_transform_skip_block_size_minus2;
  535 + unsigned char log2_sao_offset_scale_luma;
  536 + unsigned char log2_sao_offset_scale_chroma;
  537 + unsigned char high_precision_offsets_enabled_flag;
  538 + unsigned char reserved1[10];
  539 +
  540 + // pps
  541 + unsigned char dependent_slice_segments_enabled_flag;
  542 + unsigned char slice_segment_header_extension_present_flag;
  543 + unsigned char sign_data_hiding_enabled_flag;
  544 + unsigned char cu_qp_delta_enabled_flag;
  545 + unsigned char diff_cu_qp_delta_depth;
  546 + signed char init_qp_minus26;
  547 + signed char pps_cb_qp_offset;
  548 + signed char pps_cr_qp_offset;
  549 +
  550 + unsigned char constrained_intra_pred_flag;
  551 + unsigned char weighted_pred_flag;
  552 + unsigned char weighted_bipred_flag;
  553 + unsigned char transform_skip_enabled_flag;
  554 + unsigned char transquant_bypass_enabled_flag;
  555 + unsigned char entropy_coding_sync_enabled_flag;
  556 + unsigned char log2_parallel_merge_level_minus2;
  557 + unsigned char num_extra_slice_header_bits;
  558 +
  559 + unsigned char loop_filter_across_tiles_enabled_flag;
  560 + unsigned char loop_filter_across_slices_enabled_flag;
  561 + unsigned char output_flag_present_flag;
  562 + unsigned char num_ref_idx_l0_default_active_minus1;
  563 + unsigned char num_ref_idx_l1_default_active_minus1;
  564 + unsigned char lists_modification_present_flag;
  565 + unsigned char cabac_init_present_flag;
  566 + unsigned char pps_slice_chroma_qp_offsets_present_flag;
  567 +
  568 + unsigned char deblocking_filter_override_enabled_flag;
  569 + unsigned char pps_deblocking_filter_disabled_flag;
  570 + signed char pps_beta_offset_div2;
  571 + signed char pps_tc_offset_div2;
  572 + unsigned char tiles_enabled_flag;
  573 + unsigned char uniform_spacing_flag;
  574 + unsigned char num_tile_columns_minus1;
  575 + unsigned char num_tile_rows_minus1;
  576 +
  577 + unsigned short column_width_minus1[21];
  578 + unsigned short row_height_minus1[21];
  579 +
  580 + // sps and pps extension HEVC-main 444
  581 + unsigned char sps_range_extension_flag;
  582 + unsigned char transform_skip_rotation_enabled_flag;
  583 + unsigned char transform_skip_context_enabled_flag;
  584 + unsigned char implicit_rdpcm_enabled_flag;
  585 +
  586 + unsigned char explicit_rdpcm_enabled_flag;
  587 + unsigned char extended_precision_processing_flag;
  588 + unsigned char intra_smoothing_disabled_flag;
  589 + unsigned char persistent_rice_adaptation_enabled_flag;
  590 +
  591 + unsigned char cabac_bypass_alignment_enabled_flag;
  592 + unsigned char pps_range_extension_flag;
  593 + unsigned char cross_component_prediction_enabled_flag;
  594 + unsigned char chroma_qp_offset_list_enabled_flag;
  595 +
  596 + unsigned char diff_cu_chroma_qp_offset_depth;
  597 + unsigned char chroma_qp_offset_list_len_minus1;
  598 + signed char cb_qp_offset_list[6];
  599 +
  600 + signed char cr_qp_offset_list[6];
  601 + unsigned char reserved2[2];
  602 +
  603 + unsigned int reserved3[8];
  604 +
  605 + // RefPicSets
  606 + int NumBitsForShortTermRPSInSlice;
  607 + int NumDeltaPocsOfRefRpsIdx;
  608 + int NumPocTotalCurr;
  609 + int NumPocStCurrBefore;
  610 + int NumPocStCurrAfter;
  611 + int NumPocLtCurr;
  612 + int CurrPicOrderCntVal;
  613 + int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference)
  614 + int PicOrderCntVal[16]; // [refpic]
  615 + unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference
  616 + unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)
  617 + unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15)
  618 + unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15)
  619 + unsigned char RefPicSetInterLayer0[8];
  620 + unsigned char RefPicSetInterLayer1[8];
  621 + unsigned int reserved4[12];
  622 +
  623 + // scaling lists (diag order)
  624 + unsigned char ScalingList4x4[6][16]; // [matrixId][i]
  625 + unsigned char ScalingList8x8[6][64]; // [matrixId][i]
  626 + unsigned char ScalingList16x16[6][64]; // [matrixId][i]
  627 + unsigned char ScalingList32x32[2][64]; // [matrixId][i]
  628 + unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]
  629 + unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]
  630 +} CUVIDHEVCPICPARAMS;
  631 +
  632 +
  633 +/***********************************************************/
  634 +//! \struct CUVIDVP8PICPARAMS
  635 +//! VP8 picture parameters
  636 +//! This structure is used in CUVIDPICPARAMS structure
  637 +/***********************************************************/
  638 +typedef struct _CUVIDVP8PICPARAMS
  639 +{
  640 + int width;
  641 + int height;
  642 + unsigned int first_partition_size;
  643 + //Frame Indexes
  644 + unsigned char LastRefIdx;
  645 + unsigned char GoldenRefIdx;
  646 + unsigned char AltRefIdx;
  647 + union {
  648 + struct {
  649 + unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */
  650 + unsigned char version : 3;
  651 + unsigned char show_frame : 1;
  652 + unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */
  653 + unsigned char Reserved2Bits : 2;
  654 + }vp8_frame_tag;
  655 + unsigned char wFrameTagFlags;
  656 + };
  657 + unsigned char Reserved1[4];
  658 + unsigned int Reserved2[3];
  659 +} CUVIDVP8PICPARAMS;
  660 +
  661 +/***********************************************************/
  662 +//! \struct CUVIDVP9PICPARAMS
  663 +//! VP9 picture parameters
  664 +//! This structure is used in CUVIDPICPARAMS structure
  665 +/***********************************************************/
  666 +typedef struct _CUVIDVP9PICPARAMS
  667 +{
  668 + unsigned int width;
  669 + unsigned int height;
  670 +
  671 + //Frame Indices
  672 + unsigned char LastRefIdx;
  673 + unsigned char GoldenRefIdx;
  674 + unsigned char AltRefIdx;
  675 + unsigned char colorSpace;
  676 +
  677 + unsigned short profile : 3;
  678 + unsigned short frameContextIdx : 2;
  679 + unsigned short frameType : 1;
  680 + unsigned short showFrame : 1;
  681 + unsigned short errorResilient : 1;
  682 + unsigned short frameParallelDecoding : 1;
  683 + unsigned short subSamplingX : 1;
  684 + unsigned short subSamplingY : 1;
  685 + unsigned short intraOnly : 1;
  686 + unsigned short allow_high_precision_mv : 1;
  687 + unsigned short refreshEntropyProbs : 1;
  688 + unsigned short reserved2Bits : 2;
  689 +
  690 + unsigned short reserved16Bits;
  691 +
  692 + unsigned char refFrameSignBias[4];
  693 +
  694 + unsigned char bitDepthMinus8Luma;
  695 + unsigned char bitDepthMinus8Chroma;
  696 + unsigned char loopFilterLevel;
  697 + unsigned char loopFilterSharpness;
  698 +
  699 + unsigned char modeRefLfEnabled;
  700 + unsigned char log2_tile_columns;
  701 + unsigned char log2_tile_rows;
  702 +
  703 + unsigned char segmentEnabled : 1;
  704 + unsigned char segmentMapUpdate : 1;
  705 + unsigned char segmentMapTemporalUpdate : 1;
  706 + unsigned char segmentFeatureMode : 1;
  707 + unsigned char reserved4Bits : 4;
  708 +
  709 +
  710 + unsigned char segmentFeatureEnable[8][4];
  711 + short segmentFeatureData[8][4];
  712 + unsigned char mb_segment_tree_probs[7];
  713 + unsigned char segment_pred_probs[3];
  714 + unsigned char reservedSegment16Bits[2];
  715 +
  716 + int qpYAc;
  717 + int qpYDc;
  718 + int qpChDc;
  719 + int qpChAc;
  720 +
  721 + unsigned int activeRefIdx[3];
  722 + unsigned int resetFrameContext;
  723 + unsigned int mcomp_filter_type;
  724 + unsigned int mbRefLfDelta[4];
  725 + unsigned int mbModeLfDelta[2];
  726 + unsigned int frameTagSize;
  727 + unsigned int offsetToDctParts;
  728 + unsigned int reserved128Bits[4];
  729 +
  730 +} CUVIDVP9PICPARAMS;
  731 +
  732 +/***********************************************************/
  733 +//! \struct CUVIDAV1PICPARAMS
  734 +//! AV1 picture parameters
  735 +//! This structure is used in CUVIDPICPARAMS structure
  736 +/***********************************************************/
  737 +typedef struct _CUVIDAV1PICPARAMS
  738 +{
  739 + unsigned int width; // coded width, if superres enabled then it is upscaled width
  740 + unsigned int height; // coded height
  741 + unsigned int frame_offset; // defined as order_hint in AV1 specification
  742 + int decodePicIdx; // decoded output pic index, if film grain enabled, it will keep decoded (without film grain) output
  743 + // It can be used as reference frame for future frames
  744 +
  745 + // sequence header
  746 + unsigned int profile : 3; // 0 = profile0, 1 = profile1, 2 = profile2
  747 + unsigned int use_128x128_superblock : 1; // superblock size 0:64x64, 1: 128x128
  748 + unsigned int subsampling_x : 1; // (subsampling_x, _y) 1,1 = 420, 1,0 = 422, 0,0 = 444
  749 + unsigned int subsampling_y : 1;
  750 + unsigned int mono_chrome : 1; // for monochrome content, mono_chrome = 1 and (subsampling_x, _y) should be 1,1
  751 + unsigned int bit_depth_minus8 : 4; // bit depth minus 8
  752 + unsigned int enable_filter_intra : 1; // tool enable in seq level, 0 : disable 1: frame header control
  753 + unsigned int enable_intra_edge_filter : 1; // intra edge filtering process, 0 : disable 1: enabled
  754 + unsigned int enable_interintra_compound : 1; // interintra, 0 : not present 1: present
  755 + unsigned int enable_masked_compound : 1; // 1: mode info for inter blocks may contain the syntax element compound_type.
  756 + // 0: syntax element compound_type will not be present
  757 + unsigned int enable_dual_filter : 1; // vertical and horiz filter selection, 1: enable and 0: disable
  758 + unsigned int enable_order_hint : 1; // order hint, and related tools, 1: enable and 0: disable
  759 + unsigned int order_hint_bits_minus1 : 3; // is used to compute OrderHintBits
  760 + unsigned int enable_jnt_comp : 1; // joint compound modes, 1: enable and 0: disable
  761 + unsigned int enable_superres : 1; // superres in seq level, 0 : disable 1: frame level control
  762 + unsigned int enable_cdef : 1; // cdef filtering in seq level, 0 : disable 1: frame level control
  763 + unsigned int enable_restoration : 1; // loop restoration filtering in seq level, 0 : disable 1: frame level control
  764 + unsigned int enable_fgs : 1; // defined as film_grain_params_present in AV1 specification
  765 + unsigned int reserved0_7bits : 7; // reserved bits; must be set to 0
  766 +
  767 + // frame header
  768 + unsigned int frame_type : 2 ; // 0:Key frame, 1:Inter frame, 2:intra only, 3:s-frame
  769 + unsigned int show_frame : 1 ; // show_frame = 1 implies that frame should be immediately output once decoded
  770 + unsigned int disable_cdf_update : 1; // CDF update during symbol decoding, 1: disabled, 0: enabled
  771 + unsigned int allow_screen_content_tools : 1; // 1: intra blocks may use palette encoding, 0: palette encoding is never used
  772 + unsigned int force_integer_mv : 1; // 1: motion vectors will always be integers, 0: can contain fractional bits
  773 + unsigned int coded_denom : 3; // coded_denom of the superres scale as specified in AV1 specification
  774 + unsigned int allow_intrabc : 1; // 1: intra block copy may be used, 0: intra block copy is not allowed
  775 + unsigned int allow_high_precision_mv : 1; // 1/8 precision mv enable
  776 + unsigned int interp_filter : 3; // interpolation filter. Refer to section 6.8.9 of the AV1 specification Version 1.0.0 with Errata 1
  777 + unsigned int switchable_motion_mode : 1; // defined as is_motion_mode_switchable in AV1 specification
  778 + unsigned int use_ref_frame_mvs : 1; // 1: current frame can use the previous frame mv information, 0: will not use.
  779 + unsigned int disable_frame_end_update_cdf : 1; // 1: indicates that the end of frame CDF update is disabled
  780 + unsigned int delta_q_present : 1; // quantizer index delta values are present in the block level
  781 + unsigned int delta_q_res : 2; // left shift which should be applied to decoded quantizer index delta values
  782 + unsigned int using_qmatrix : 1; // 1: quantizer matrix will be used to compute quantizers
  783 + unsigned int coded_lossless : 1; // 1: all segments use lossless coding
  784 + unsigned int use_superres : 1; // 1: superres enabled for frame
  785 + unsigned int tx_mode : 2; // 0: ONLY4x4,1:LARGEST,2:SELECT
  786 + unsigned int reference_mode : 1; // 0: SINGLE, 1: SELECT
  787 + unsigned int allow_warped_motion : 1; // 1: allow_warped_motion may be present, 0: allow_warped_motion will not be present
  788 + unsigned int reduced_tx_set : 1; // 1: frame is restricted to subset of the full set of transform types, 0: no such restriction
  789 + unsigned int skip_mode : 1; // 1: most of the mode info is skipped, 0: mode info is not skipped
  790 + unsigned int reserved1_3bits : 3; // reserved bits; must be set to 0
  791 +
  792 + // tiling info
  793 + unsigned int num_tile_cols : 8; // number of tiles across the frame., max is 64
  794 + unsigned int num_tile_rows : 8; // number of tiles down the frame., max is 64
  795 + unsigned int context_update_tile_id : 16; // specifies which tile to use for the CDF update
  796 + unsigned short tile_widths[64]; // Width of each column in superblocks
  797 + unsigned short tile_heights[64]; // height of each row in superblocks
  798 +
  799 + // CDEF - refer to section 6.10.14 of the AV1 specification Version 1.0.0 with Errata 1
  800 + unsigned char cdef_damping_minus_3 : 2; // controls the amount of damping in the deringing filter
  801 + unsigned char cdef_bits : 2; // the number of bits needed to specify which CDEF filter to apply
  802 + unsigned char reserved2_4bits : 4; // reserved bits; must be set to 0
  803 + unsigned char cdef_y_strength[8]; // 0-3 bits: y_pri_strength, 4-7 bits y_sec_strength
  804 + unsigned char cdef_uv_strength[8]; // 0-3 bits: uv_pri_strength, 4-7 bits uv_sec_strength
  805 +
  806 + // SkipModeFrames
  807 + unsigned char SkipModeFrame0 : 4; // specifies the frames to use for compound prediction when skip_mode is equal to 1.
  808 + unsigned char SkipModeFrame1 : 4;
  809 +
  810 + // qp information - refer to section 6.8.11 of the AV1 specification Version 1.0.0 with Errata 1
  811 + unsigned char base_qindex; // indicates the base frame qindex. Defined as base_q_idx in AV1 specification
  812 + char qp_y_dc_delta_q; // indicates the Y DC quantizer relative to base_q_idx. Defined as DeltaQYDc in AV1 specification
  813 + char qp_u_dc_delta_q; // indicates the U DC quantizer relative to base_q_idx. Defined as DeltaQUDc in AV1 specification
  814 + char qp_v_dc_delta_q; // indicates the V DC quantizer relative to base_q_idx. Defined as DeltaQVDc in AV1 specification
  815 + char qp_u_ac_delta_q; // indicates the U AC quantizer relative to base_q_idx. Defined as DeltaQUAc in AV1 specification
  816 + char qp_v_ac_delta_q; // indicates the V AC quantizer relative to base_q_idx. Defined as DeltaQVAc in AV1 specification
  817 + unsigned char qm_y; // specifies the level in the quantizer matrix that should be used for luma plane decoding
  818 + unsigned char qm_u; // specifies the level in the quantizer matrix that should be used for chroma U plane decoding
  819 + unsigned char qm_v; // specifies the level in the quantizer matrix that should be used for chroma V plane decoding
  820 +
  821 + // segmentation - refer to section 6.8.13 of the AV1 specification Version 1.0.0 with Errata 1
  822 + unsigned char segmentation_enabled : 1; // 1 indicates that this frame makes use of the segmentation tool
  823 + unsigned char segmentation_update_map : 1; // 1 indicates that the segmentation map are updated during the decoding of this frame
  824 + unsigned char segmentation_update_data : 1; // 1 indicates that new parameters are about to be specified for each segment
  825 + unsigned char segmentation_temporal_update : 1; // 1 indicates that the updates to the segmentation map are coded relative to the existing segmentation map
  826 + unsigned char reserved3_4bits : 4; // reserved bits; must be set to 0
  827 + short segmentation_feature_data[8][8]; // specifies the feature data for a segment feature
  828 + unsigned char segmentation_feature_mask[8]; // indicates that the corresponding feature is unused or feature value is coded
  829 +
  830 + // loopfilter - refer to section 6.8.10 of the AV1 specification Version 1.0.0 with Errata 1
  831 + unsigned char loop_filter_level[2]; // contains loop filter strength values
  832 + unsigned char loop_filter_level_u; // loop filter strength value of U plane
  833 + unsigned char loop_filter_level_v; // loop filter strength value of V plane
  834 + unsigned char loop_filter_sharpness; // indicates the sharpness level
  835 + char loop_filter_ref_deltas[8]; // contains the adjustment needed for the filter level based on the chosen reference frame
  836 + char loop_filter_mode_deltas[2]; // contains the adjustment needed for the filter level based on the chosen mode
  837 + unsigned char loop_filter_delta_enabled : 1; // indicates that the filter level depends on the mode and reference frame used to predict a block
  838 + unsigned char loop_filter_delta_update : 1; // indicates that additional syntax elements are present that specify which mode and
  839 + // reference frame deltas are to be updated
  840 + unsigned char delta_lf_present : 1; // specifies whether loop filter delta values are present in the block level
  841 + unsigned char delta_lf_res : 2; // specifies the left shift to apply to the decoded loop filter values
  842 + unsigned char delta_lf_multi : 1; // separate loop filter deltas for Hy,Vy,U,V edges
  843 + unsigned char reserved4_2bits : 2; // reserved bits; must be set to 0
  844 +
  845 + // restoration - refer to section 6.10.15 of the AV1 specification Version 1.0.0 with Errata 1
  846 + unsigned char lr_unit_size[3]; // specifies the size of loop restoration units: 0: 32, 1: 64, 2: 128, 3: 256
  847 + unsigned char lr_type[3] ; // used to compute FrameRestorationType
  848 +
  849 + // reference frames
  850 + unsigned char primary_ref_frame; // specifies which reference frame contains the CDF values and other state that should be
  851 + // loaded at the start of the frame
  852 + unsigned char ref_frame_map[8]; // frames in dpb that can be used as reference for current or future frames
  853 +
  854 + unsigned char temporal_layer_id : 4; // temporal layer id
  855 + unsigned char spatial_layer_id : 4; // spatial layer id
  856 +
  857 + unsigned char reserved5_32bits[4]; // reserved bits; must be set to 0
  858 +
  859 + // ref frame list
  860 + struct
  861 + {
  862 + unsigned int width;
  863 + unsigned int height;
  864 + unsigned char index;
  865 + unsigned char reserved24Bits[3]; // reserved bits; must be set to 0
  866 + } ref_frame[7]; // frames used as reference frame for current frame.
  867 +
  868 + // global motion
  869 + struct {
  870 + unsigned char invalid : 1;
  871 + unsigned char wmtype : 2; // defined as GmType in AV1 specification
  872 + unsigned char reserved5Bits : 5; // reserved bits; must be set to 0
  873 + char reserved24Bits[3]; // reserved bits; must be set to 0
  874 + int wmmat[6]; // defined as gm_params[] in AV1 specification
  875 + } global_motion[7]; // global motion params for reference frames
  876 +
  877 + // film grain params - refer to section 6.8.20 of the AV1 specification Version 1.0.0 with Errata 1
  878 + unsigned short apply_grain : 1;
  879 + unsigned short overlap_flag : 1;
  880 + unsigned short scaling_shift_minus8 : 2;
  881 + unsigned short chroma_scaling_from_luma : 1;
  882 + unsigned short ar_coeff_lag : 2;
  883 + unsigned short ar_coeff_shift_minus6 : 2;
  884 + unsigned short grain_scale_shift : 2;
  885 + unsigned short clip_to_restricted_range : 1;
  886 + unsigned short reserved6_4bits : 4; // reserved bits; must be set to 0
  887 + unsigned char num_y_points;
  888 + unsigned char scaling_points_y[14][2];
  889 + unsigned char num_cb_points;
  890 + unsigned char scaling_points_cb[10][2];
  891 + unsigned char num_cr_points;
  892 + unsigned char scaling_points_cr[10][2];
  893 + unsigned char reserved7_8bits; // reserved bits; must be set to 0
  894 + unsigned short random_seed;
  895 + short ar_coeffs_y[24];
  896 + short ar_coeffs_cb[25];
  897 + short ar_coeffs_cr[25];
  898 + unsigned char cb_mult;
  899 + unsigned char cb_luma_mult;
  900 + short cb_offset;
  901 + unsigned char cr_mult;
  902 + unsigned char cr_luma_mult;
  903 + short cr_offset;
  904 +
  905 + int reserved[7]; // reserved bits; must be set to 0
  906 +} CUVIDAV1PICPARAMS;
  907 +
  908 +/******************************************************************************************/
  909 +//! \struct CUVIDPICPARAMS
  910 +//! Picture parameters for decoding
  911 +//! This structure is used in cuvidDecodePicture API
  912 +//! IN for cuvidDecodePicture
  913 +/******************************************************************************************/
  914 +typedef struct _CUVIDPICPARAMS
  915 +{
  916 + int PicWidthInMbs; /**< IN: Coded frame size in macroblocks */
  917 + int FrameHeightInMbs; /**< IN: Coded frame height in macroblocks */
  918 + int CurrPicIdx; /**< IN: Output index of the current picture */
  919 + int field_pic_flag; /**< IN: 0=frame picture, 1=field picture */
  920 + int bottom_field_flag; /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */
  921 + int second_field; /**< IN: Second field of a complementary field pair */
  922 + // Bitstream data
  923 + unsigned int nBitstreamDataLen; /**< IN: Number of bytes in bitstream data buffer */
  924 + const unsigned char *pBitstreamData; /**< IN: Ptr to bitstream data for this picture (slice-layer) */
  925 + unsigned int nNumSlices; /**< IN: Number of slices in this picture */
  926 + const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within
  927 + the bitstream data buffer */
  928 + int ref_pic_flag; /**< IN: This picture is a reference picture */
  929 + int intra_pic_flag; /**< IN: This picture is entirely intra coded */
  930 + unsigned int Reserved[30]; /**< Reserved for future use */
  931 + // IN: Codec-specific data
  932 + union {
  933 + CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */
  934 + CUVIDH264PICPARAMS h264;
  935 + CUVIDVC1PICPARAMS vc1;
  936 + CUVIDMPEG4PICPARAMS mpeg4;
  937 + CUVIDJPEGPICPARAMS jpeg;
  938 + CUVIDHEVCPICPARAMS hevc;
  939 + CUVIDVP8PICPARAMS vp8;
  940 + CUVIDVP9PICPARAMS vp9;
  941 + CUVIDAV1PICPARAMS av1;
  942 + unsigned int CodecReserved[1024];
  943 + } CodecSpecific;
  944 +} CUVIDPICPARAMS;
  945 +
  946 +
  947 +/******************************************************/
  948 +//! \struct CUVIDPROCPARAMS
  949 +//! Picture parameters for postprocessing
  950 +//! This structure is used in cuvidMapVideoFrame API
  951 +/******************************************************/
  952 +typedef struct _CUVIDPROCPARAMS
  953 +{
  954 + int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored) */
  955 + int second_field; /**< IN: Output the second field (ignored if deinterlace mode is Weave) */
  956 + int top_field_first; /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */
  957 + int unpaired_field; /**< IN: Input only contains one field (2nd field is invalid) */
  958 + // The fields below are used for raw YUV input
  959 + unsigned int reserved_flags; /**< Reserved for future use (set to zero) */
  960 + unsigned int reserved_zero; /**< Reserved (set to zero) */
  961 + unsigned long long raw_input_dptr; /**< IN: Input CUdeviceptr for raw YUV extensions */
  962 + unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */
  963 + unsigned int raw_input_format; /**< IN: Input YUV format (cudaVideoCodec_enum) */
  964 + unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions */
  965 + unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */
  966 + unsigned int Reserved1; /**< Reserved for future use (set to zero) */
  967 + CUstream output_stream; /**< IN: stream object used by cuvidMapVideoFrame */
  968 + unsigned int Reserved[46]; /**< Reserved for future use (set to zero) */
  969 + unsigned long long *histogram_dptr; /**< OUT: Output CUdeviceptr for histogram extensions */
  970 + void *Reserved2[1]; /**< Reserved for future use (set to zero) */
  971 +} CUVIDPROCPARAMS;
  972 +
  973 +/*********************************************************************************************************/
  974 +//! \struct CUVIDGETDECODESTATUS
  975 +//! Struct for reporting decode status.
  976 +//! This structure is used in cuvidGetDecodeStatus API.
  977 +/*********************************************************************************************************/
  978 +typedef struct _CUVIDGETDECODESTATUS
  979 +{
  980 + cuvidDecodeStatus decodeStatus;
  981 + unsigned int reserved[31];
  982 + void *pReserved[8];
  983 +} CUVIDGETDECODESTATUS;
  984 +
  985 +/****************************************************/
  986 +//! \struct CUVIDRECONFIGUREDECODERINFO
  987 +//! Struct for decoder reset
  988 +//! This structure is used in cuvidReconfigureDecoder() API
  989 +/****************************************************/
  990 +typedef struct _CUVIDRECONFIGUREDECODERINFO
  991 +{
  992 + unsigned int ulWidth; /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at CUVIDDECODECREATEINFO */
  993 + unsigned int ulHeight; /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at CUVIDDECODECREATEINFO */
  994 + unsigned int ulTargetWidth; /**< IN: Post processed output width */
  995 + unsigned int ulTargetHeight; /**< IN: Post Processed output height */
  996 + unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */
  997 + unsigned int reserved1[12]; /**< Reserved for future use. Set to Zero */
  998 + /**
  999 + * IN: Area of frame to be displayed. Use-case : Source Cropping
  1000 + */
  1001 + struct {
  1002 + short left;
  1003 + short top;
  1004 + short right;
  1005 + short bottom;
  1006 + } display_area;
  1007 + /**
  1008 + * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion
  1009 + */
  1010 + struct {
  1011 + short left;
  1012 + short top;
  1013 + short right;
  1014 + short bottom;
  1015 + } target_rect;
  1016 + unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */
  1017 +} CUVIDRECONFIGUREDECODERINFO;
  1018 +
  1019 +
  1020 +/***********************************************************************************************************/
  1021 +//! VIDEO_DECODER
  1022 +//!
  1023 +//! In order to minimize decode latencies, there should be always at least 2 pictures in the decode
  1024 +//! queue at any time, in order to make sure that all decode engines are always busy.
  1025 +//!
  1026 +//! Overall data flow:
  1027 +//! - cuvidGetDecoderCaps(...)
  1028 +//! - cuvidCreateDecoder(...)
  1029 +//! - For each picture:
  1030 +//! + cuvidDecodePicture(N)
  1031 +//! + cuvidMapVideoFrame(N-4)
  1032 +//! + do some processing in cuda
  1033 +//! + cuvidUnmapVideoFrame(N-4)
  1034 +//! + cuvidDecodePicture(N+1)
  1035 +//! + cuvidMapVideoFrame(N-3)
  1036 +//! + ...
  1037 +//! - cuvidDestroyDecoder(...)
  1038 +//!
  1039 +//! NOTE:
  1040 +//! - When the cuda context is created from a D3D device, the D3D device must also be created
  1041 +//! with the D3DCREATE_MULTITHREADED flag.
  1042 +//! - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)
  1043 +//! - cuvidDecodePicture may block the calling thread if there are too many pictures pending
  1044 +//! in the decode queue
  1045 +/***********************************************************************************************************/
  1046 +
  1047 +
  1048 +/**********************************************************************************************************************/
  1049 +//! \fn CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc)
  1050 +//! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters.
  1051 +//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure
  1052 +//! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported
  1053 +//! If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0.
  1054 +//! E.g. on Geforce GTX 960:
  1055 +//! App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0;
  1056 +//! Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth = 48; nMinHeight = 16;
  1057 +//! nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536;
  1058 +//! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount
  1059 +/**********************************************************************************************************************/
  1060 +typedef CUresult CUDAAPI tcuvidGetDecoderCaps(CUVIDDECODECAPS *pdc);
  1061 +
  1062 +/*****************************************************************************************************/
  1063 +//! \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)
  1064 +//! Create the decoder object based on pdci. A handle to the created decoder is returned
  1065 +/*****************************************************************************************************/
  1066 +typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);
  1067 +
  1068 +/*****************************************************************************************************/
  1069 +//! \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)
  1070 +//! Destroy the decoder object
  1071 +/*****************************************************************************************************/
  1072 +typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);
  1073 +
  1074 +/*****************************************************************************************************/
  1075 +//! \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)
  1076 +//! Decode a single picture (field or frame)
  1077 +//! Kicks off HW decoding
  1078 +/*****************************************************************************************************/
  1079 +typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);
  1080 +
  1081 +/************************************************************************************************************/
  1082 +//! \fn CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx);
  1083 +//! Get the decode status for frame corresponding to nPicIdx
  1084 +//! API is supported for Maxwell and above generation GPUs.
  1085 +//! API is currently supported for HEVC, H264 and JPEG codecs.
  1086 +//! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec.
  1087 +/************************************************************************************************************/
  1088 +typedef CUresult CUDAAPI tcuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx, CUVIDGETDECODESTATUS* pDecodeStatus);
  1089 +
  1090 +/*********************************************************************************************************/
  1091 +//! \fn CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams)
  1092 +//! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params, display area
  1093 +//! params, target area params change for same codec. Must be called during CUVIDPARSERPARAMS::pfnSequenceCallback
  1094 +/*********************************************************************************************************/
  1095 +typedef CUresult CUDAAPI tcuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams);
  1096 +
  1097 +
  1098 +#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)
  1099 +/************************************************************************************************************************/
  1100 +//! \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr,
  1101 +//! unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
  1102 +//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
  1103 +//! pitch of the video frame
  1104 +/************************************************************************************************************************/
  1105 +typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx,
  1106 + unsigned int *pDevPtr, unsigned int *pPitch,
  1107 + CUVIDPROCPARAMS *pVPP);
  1108 +
  1109 +/*****************************************************************************************************/
  1110 +//! \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)
  1111 +//! Unmap a previously mapped video frame
  1112 +/*****************************************************************************************************/
  1113 +typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);
  1114 +#endif
  1115 +
  1116 +#if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
  1117 +/****************************************************************************************************************************/
  1118 +//! \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
  1119 +//! unsigned int * pPitch, CUVIDPROCPARAMS *pVPP);
  1120 +//! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated
  1121 +//! pitch of the video frame
  1122 +/****************************************************************************************************************************/
  1123 +typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,
  1124 + unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);
  1125 +
  1126 +/**************************************************************************************************/
  1127 +//! \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
  1128 +//! Unmap a previously mapped video frame
  1129 +/**************************************************************************************************/
  1130 +typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);
  1131 +
  1132 +#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)
  1133 +#define tcuvidMapVideoFrame tcuvidMapVideoFrame64
  1134 +#define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64
  1135 +#endif
  1136 +#endif
  1137 +
  1138 +
  1139 +/********************************************************************************************************************/
  1140 +//!
  1141 +//! Context-locking: to facilitate multi-threaded implementations, the following 4 functions
  1142 +//! provide a simple mutex-style host synchronization. If a non-NULL context is specified
  1143 +//! in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given
  1144 +//! context before making any cuda calls.
  1145 +//! A multi-threaded application could create a lock associated with a context handle so that
  1146 +//! multiple threads can safely share the same cuda context:
  1147 +//! - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context
  1148 +//! that can be passed to cuvidCtxLockCreate.
  1149 +//! - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section.
  1150 +//!
  1151 +//! NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video
  1152 +//! decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).
  1153 +/********************************************************************************************************************/
  1154 +
  1155 +/********************************************************************************************************************/
  1156 +//! \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)
  1157 +//! This API is used to create CtxLock object
  1158 +/********************************************************************************************************************/
  1159 +typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);
  1160 +
  1161 +/********************************************************************************************************************/
  1162 +//! \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)
  1163 +//! This API is used to free CtxLock object
  1164 +/********************************************************************************************************************/
  1165 +typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);
  1166 +
  1167 +/********************************************************************************************************************/
  1168 +//! \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)
  1169 +//! This API is used to acquire ctxlock
  1170 +/********************************************************************************************************************/
  1171 +typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);
  1172 +
  1173 +/********************************************************************************************************************/
  1174 +//! \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)
  1175 +//! This API is used to release ctxlock
  1176 +/********************************************************************************************************************/
  1177 +typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);
  1178 +
  1179 +/**********************************************************************************************/
  1180 +
  1181 +#if defined(__cplusplus)
  1182 +}
  1183 +#endif /* __cplusplus */
  1184 +
  1185 +#endif // __CUDA_VIDEO_H__
... ...
nv-codec-headers/include/ffnvcodec/dynlink_loader.h 0 → 100644
  1 +/*
  2 + * This copyright notice applies to this header file only:
  3 + *
  4 + * Copyright (c) 2016
  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 +#ifndef FFNV_CUDA_DYNLINK_LOADER_H
  29 +#define FFNV_CUDA_DYNLINK_LOADER_H
  30 +
  31 +#include <stdlib.h>
  32 +
  33 +#include "dynlink_cuda.h"
  34 +#include "dynlink_nvcuvid.h"
  35 +#include "nvEncodeAPI.h"
  36 +
  37 +#if defined(_WIN32) && (!defined(FFNV_LOAD_FUNC) || !defined(FFNV_SYM_FUNC) || !defined(FFNV_LIB_HANDLE))
  38 +# include <windows.h>
  39 +#endif
  40 +
  41 +#ifndef FFNV_LIB_HANDLE
  42 +# if defined(_WIN32)
  43 +# define FFNV_LIB_HANDLE HMODULE
  44 +# else
  45 +# define FFNV_LIB_HANDLE void*
  46 +# endif
  47 +#endif
  48 +
  49 +#if defined(_WIN32) || defined(__CYGWIN__)
  50 +# define CUDA_LIBNAME "nvcuda.dll"
  51 +# define NVCUVID_LIBNAME "nvcuvid.dll"
  52 +# if defined(_WIN64) || defined(__CYGWIN64__)
  53 +# define NVENC_LIBNAME "nvEncodeAPI64.dll"
  54 +# else
  55 +# define NVENC_LIBNAME "nvEncodeAPI.dll"
  56 +# endif
  57 +#else
  58 +# define CUDA_LIBNAME "libcuda.so.1"
  59 +# define NVCUVID_LIBNAME "libnvcuvid.so.1"
  60 +# define NVENC_LIBNAME "libnvidia-encode.so.1"
  61 +#endif
  62 +
  63 +#if !defined(FFNV_LOAD_FUNC) || !defined(FFNV_SYM_FUNC)
  64 +# ifdef _WIN32
  65 +# define FFNV_LOAD_FUNC(path) LoadLibrary(TEXT(path))
  66 +# define FFNV_SYM_FUNC(lib, sym) GetProcAddress((lib), (sym))
  67 +# define FFNV_FREE_FUNC(lib) FreeLibrary(lib)
  68 +# else
  69 +# include <dlfcn.h>
  70 +# define FFNV_LOAD_FUNC(path) dlopen((path), RTLD_LAZY)
  71 +# define FFNV_SYM_FUNC(lib, sym) dlsym((lib), (sym))
  72 +# define FFNV_FREE_FUNC(lib) dlclose(lib)
  73 +# endif
  74 +#endif
  75 +
  76 +#if !defined(FFNV_LOG_FUNC) || !defined(FFNV_DEBUG_LOG_FUNC)
  77 +# include <stdio.h>
  78 +# define FFNV_LOG_FUNC(logctx, msg, ...) fprintf(stderr, (msg), __VA_ARGS__)
  79 +# define FFNV_DEBUG_LOG_FUNC(logctx, msg, ...)
  80 +#endif
  81 +
  82 +#define LOAD_LIBRARY(l, path) \
  83 + do { \
  84 + if (!((l) = FFNV_LOAD_FUNC(path))) { \
  85 + FFNV_LOG_FUNC(logctx, "Cannot load %s\n", path); \
  86 + ret = -1; \
  87 + goto error; \
  88 + } \
  89 + FFNV_DEBUG_LOG_FUNC(logctx, "Loaded lib: %s\n", path); \
  90 + } while (0)
  91 +
  92 +#define LOAD_SYMBOL(fun, tp, symbol) \
  93 + do { \
  94 + if (!((f->fun) = (tp*)FFNV_SYM_FUNC(f->lib, symbol))) { \
  95 + FFNV_LOG_FUNC(logctx, "Cannot load %s\n", symbol); \
  96 + ret = -1; \
  97 + goto error; \
  98 + } \
  99 + FFNV_DEBUG_LOG_FUNC(logctx, "Loaded sym: %s\n", symbol); \
  100 + } while (0)
  101 +
  102 +#define LOAD_SYMBOL_OPT(fun, tp, symbol) \
  103 + do { \
  104 + if (!((f->fun) = (tp*)FFNV_SYM_FUNC(f->lib, symbol))) { \
  105 + FFNV_DEBUG_LOG_FUNC(logctx, "Cannot load optional %s\n", symbol); \
  106 + } else { \
  107 + FFNV_DEBUG_LOG_FUNC(logctx, "Loaded sym: %s\n", symbol); \
  108 + } \
  109 + } while (0)
  110 +
  111 +#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
  112 + T *f; \
  113 + int ret; \
  114 + \
  115 + n##_free_functions(functions); \
  116 + \
  117 + f = *functions = (T*)calloc(1, sizeof(*f)); \
  118 + if (!f) \
  119 + return -1; \
  120 + \
  121 + LOAD_LIBRARY(f->lib, N);
  122 +
  123 +#define GENERIC_LOAD_FUNC_FINALE(n) \
  124 + return 0; \
  125 +error: \
  126 + n##_free_functions(functions); \
  127 + return ret;
  128 +
  129 +#define GENERIC_FREE_FUNC() \
  130 + if (!functions) \
  131 + return; \
  132 + if (*functions && (*functions)->lib) \
  133 + FFNV_FREE_FUNC((*functions)->lib); \
  134 + free(*functions); \
  135 + *functions = NULL;
  136 +
  137 +#ifdef FFNV_DYNLINK_CUDA_H
  138 +typedef struct CudaFunctions {
  139 + tcuInit *cuInit;
  140 + tcuDeviceGetCount *cuDeviceGetCount;
  141 + tcuDeviceGet *cuDeviceGet;
  142 + tcuDeviceGetAttribute *cuDeviceGetAttribute;
  143 + tcuDeviceGetName *cuDeviceGetName;
  144 + tcuDeviceGetUuid *cuDeviceGetUuid;
  145 + tcuDeviceComputeCapability *cuDeviceComputeCapability;
  146 + tcuCtxCreate_v2 *cuCtxCreate;
  147 + tcuCtxSetLimit *cuCtxSetLimit;
  148 + tcuCtxPushCurrent_v2 *cuCtxPushCurrent;
  149 + tcuCtxPopCurrent_v2 *cuCtxPopCurrent;
  150 + tcuCtxDestroy_v2 *cuCtxDestroy;
  151 + tcuMemAlloc_v2 *cuMemAlloc;
  152 + tcuMemAllocPitch_v2 *cuMemAllocPitch;
  153 + tcuMemAllocManaged *cuMemAllocManaged;
  154 + tcuMemsetD8Async *cuMemsetD8Async;
  155 + tcuMemFree_v2 *cuMemFree;
  156 + tcuMemcpy *cuMemcpy;
  157 + tcuMemcpyAsync *cuMemcpyAsync;
  158 + tcuMemcpy2D_v2 *cuMemcpy2D;
  159 + tcuMemcpy2DAsync_v2 *cuMemcpy2DAsync;
  160 + tcuMemcpyHtoD_v2 *cuMemcpyHtoD;
  161 + tcuMemcpyHtoDAsync_v2 *cuMemcpyHtoDAsync;
  162 + tcuMemcpyDtoH_v2 *cuMemcpyDtoH;
  163 + tcuMemcpyDtoHAsync_v2 *cuMemcpyDtoHAsync;
  164 + tcuMemcpyDtoD_v2 *cuMemcpyDtoD;
  165 + tcuMemcpyDtoDAsync_v2 *cuMemcpyDtoDAsync;
  166 + tcuGetErrorName *cuGetErrorName;
  167 + tcuGetErrorString *cuGetErrorString;
  168 + tcuCtxGetDevice *cuCtxGetDevice;
  169 +
  170 + tcuDevicePrimaryCtxRetain *cuDevicePrimaryCtxRetain;
  171 + tcuDevicePrimaryCtxRelease *cuDevicePrimaryCtxRelease;
  172 + tcuDevicePrimaryCtxSetFlags *cuDevicePrimaryCtxSetFlags;
  173 + tcuDevicePrimaryCtxGetState *cuDevicePrimaryCtxGetState;
  174 + tcuDevicePrimaryCtxReset *cuDevicePrimaryCtxReset;
  175 +
  176 + tcuStreamCreate *cuStreamCreate;
  177 + tcuStreamQuery *cuStreamQuery;
  178 + tcuStreamSynchronize *cuStreamSynchronize;
  179 + tcuStreamDestroy_v2 *cuStreamDestroy;
  180 + tcuStreamAddCallback *cuStreamAddCallback;
  181 + tcuEventCreate *cuEventCreate;
  182 + tcuEventDestroy_v2 *cuEventDestroy;
  183 + tcuEventSynchronize *cuEventSynchronize;
  184 + tcuEventQuery *cuEventQuery;
  185 + tcuEventRecord *cuEventRecord;
  186 +
  187 + tcuLaunchKernel *cuLaunchKernel;
  188 + tcuLinkCreate *cuLinkCreate;
  189 + tcuLinkAddData *cuLinkAddData;
  190 + tcuLinkComplete *cuLinkComplete;
  191 + tcuLinkDestroy *cuLinkDestroy;
  192 + tcuModuleLoadData *cuModuleLoadData;
  193 + tcuModuleUnload *cuModuleUnload;
  194 + tcuModuleGetFunction *cuModuleGetFunction;
  195 + tcuModuleGetGlobal *cuModuleGetGlobal;
  196 + tcuTexObjectCreate *cuTexObjectCreate;
  197 + tcuTexObjectDestroy *cuTexObjectDestroy;
  198 +
  199 + tcuGLGetDevices_v2 *cuGLGetDevices;
  200 + tcuGraphicsGLRegisterImage *cuGraphicsGLRegisterImage;
  201 + tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource;
  202 + tcuGraphicsMapResources *cuGraphicsMapResources;
  203 + tcuGraphicsUnmapResources *cuGraphicsUnmapResources;
  204 + tcuGraphicsSubResourceGetMappedArray *cuGraphicsSubResourceGetMappedArray;
  205 + tcuGraphicsResourceGetMappedPointer *cuGraphicsResourceGetMappedPointer;
  206 +
  207 + tcuImportExternalMemory *cuImportExternalMemory;
  208 + tcuDestroyExternalMemory *cuDestroyExternalMemory;
  209 + tcuExternalMemoryGetMappedBuffer *cuExternalMemoryGetMappedBuffer;
  210 + tcuExternalMemoryGetMappedMipmappedArray *cuExternalMemoryGetMappedMipmappedArray;
  211 + tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy;
  212 +
  213 + tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel;
  214 +
  215 + tcuImportExternalSemaphore *cuImportExternalSemaphore;
  216 + tcuDestroyExternalSemaphore *cuDestroyExternalSemaphore;
  217 + tcuSignalExternalSemaphoresAsync *cuSignalExternalSemaphoresAsync;
  218 + tcuWaitExternalSemaphoresAsync *cuWaitExternalSemaphoresAsync;
  219 +
  220 + tcuArray3DCreate *cuArray3DCreate;
  221 + tcuArrayDestroy *cuArrayDestroy;
  222 +
  223 + tcuEGLStreamProducerConnect *cuEGLStreamProducerConnect;
  224 + tcuEGLStreamProducerDisconnect *cuEGLStreamProducerDisconnect;
  225 + tcuEGLStreamConsumerDisconnect *cuEGLStreamConsumerDisconnect;
  226 + tcuEGLStreamProducerPresentFrame *cuEGLStreamProducerPresentFrame;
  227 + tcuEGLStreamProducerReturnFrame *cuEGLStreamProducerReturnFrame;
  228 +
  229 +#if defined(_WIN32) || defined(__CYGWIN__)
  230 + tcuD3D11GetDevice *cuD3D11GetDevice;
  231 + tcuD3D11GetDevices *cuD3D11GetDevices;
  232 + tcuGraphicsD3D11RegisterResource *cuGraphicsD3D11RegisterResource;
  233 +#endif
  234 +
  235 + FFNV_LIB_HANDLE lib;
  236 +} CudaFunctions;
  237 +#else
  238 +typedef struct CudaFunctions CudaFunctions;
  239 +#endif
  240 +
  241 +typedef struct CuvidFunctions {
  242 + tcuvidGetDecoderCaps *cuvidGetDecoderCaps;
  243 + tcuvidCreateDecoder *cuvidCreateDecoder;
  244 + tcuvidDestroyDecoder *cuvidDestroyDecoder;
  245 + tcuvidDecodePicture *cuvidDecodePicture;
  246 + tcuvidGetDecodeStatus *cuvidGetDecodeStatus;
  247 + tcuvidReconfigureDecoder *cuvidReconfigureDecoder;
  248 + tcuvidMapVideoFrame *cuvidMapVideoFrame;
  249 + tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame;
  250 + tcuvidCtxLockCreate *cuvidCtxLockCreate;
  251 + tcuvidCtxLockDestroy *cuvidCtxLockDestroy;
  252 + tcuvidCtxLock *cuvidCtxLock;
  253 + tcuvidCtxUnlock *cuvidCtxUnlock;
  254 +
  255 +#if !defined(__APPLE__)
  256 + tcuvidCreateVideoSource *cuvidCreateVideoSource;
  257 + tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW;
  258 + tcuvidDestroyVideoSource *cuvidDestroyVideoSource;
  259 + tcuvidSetVideoSourceState *cuvidSetVideoSourceState;
  260 + tcuvidGetVideoSourceState *cuvidGetVideoSourceState;
  261 + tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat;
  262 + tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat;
  263 +#endif
  264 + tcuvidCreateVideoParser *cuvidCreateVideoParser;
  265 + tcuvidParseVideoData *cuvidParseVideoData;
  266 + tcuvidDestroyVideoParser *cuvidDestroyVideoParser;
  267 +
  268 + FFNV_LIB_HANDLE lib;
  269 +} CuvidFunctions;
  270 +
  271 +typedef NVENCSTATUS NVENCAPI tNvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList);
  272 +typedef NVENCSTATUS NVENCAPI tNvEncodeAPIGetMaxSupportedVersion(uint32_t* version);
  273 +
  274 +typedef struct NvencFunctions {
  275 + tNvEncodeAPICreateInstance *NvEncodeAPICreateInstance;
  276 + tNvEncodeAPIGetMaxSupportedVersion *NvEncodeAPIGetMaxSupportedVersion;
  277 +
  278 + FFNV_LIB_HANDLE lib;
  279 +} NvencFunctions;
  280 +
  281 +#ifdef FFNV_DYNLINK_CUDA_H
  282 +static inline void cuda_free_functions(CudaFunctions **functions)
  283 +{
  284 + GENERIC_FREE_FUNC();
  285 +}
  286 +#endif
  287 +
  288 +static inline void cuvid_free_functions(CuvidFunctions **functions)
  289 +{
  290 + GENERIC_FREE_FUNC();
  291 +}
  292 +
  293 +static inline void nvenc_free_functions(NvencFunctions **functions)
  294 +{
  295 + GENERIC_FREE_FUNC();
  296 +}
  297 +
  298 +#ifdef FFNV_DYNLINK_CUDA_H
  299 +static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
  300 +{
  301 + GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME);
  302 +
  303 + LOAD_SYMBOL(cuInit, tcuInit, "cuInit");
  304 + LOAD_SYMBOL(cuDeviceGetCount, tcuDeviceGetCount, "cuDeviceGetCount");
  305 + LOAD_SYMBOL(cuDeviceGet, tcuDeviceGet, "cuDeviceGet");
  306 + LOAD_SYMBOL(cuDeviceGetAttribute, tcuDeviceGetAttribute, "cuDeviceGetAttribute");
  307 + LOAD_SYMBOL(cuDeviceGetName, tcuDeviceGetName, "cuDeviceGetName");
  308 + LOAD_SYMBOL(cuDeviceComputeCapability, tcuDeviceComputeCapability, "cuDeviceComputeCapability");
  309 + LOAD_SYMBOL(cuCtxCreate, tcuCtxCreate_v2, "cuCtxCreate_v2");
  310 + LOAD_SYMBOL(cuCtxSetLimit, tcuCtxSetLimit, "cuCtxSetLimit");
  311 + LOAD_SYMBOL(cuCtxPushCurrent, tcuCtxPushCurrent_v2, "cuCtxPushCurrent_v2");
  312 + LOAD_SYMBOL(cuCtxPopCurrent, tcuCtxPopCurrent_v2, "cuCtxPopCurrent_v2");
  313 + LOAD_SYMBOL(cuCtxDestroy, tcuCtxDestroy_v2, "cuCtxDestroy_v2");
  314 + LOAD_SYMBOL(cuMemAlloc, tcuMemAlloc_v2, "cuMemAlloc_v2");
  315 + LOAD_SYMBOL(cuMemAllocPitch, tcuMemAllocPitch_v2, "cuMemAllocPitch_v2");
  316 + LOAD_SYMBOL(cuMemAllocManaged, tcuMemAllocManaged, "cuMemAllocManaged");
  317 + LOAD_SYMBOL(cuMemsetD8Async, tcuMemsetD8Async, "cuMemsetD8Async");
  318 + LOAD_SYMBOL(cuMemFree, tcuMemFree_v2, "cuMemFree_v2");
  319 + LOAD_SYMBOL(cuMemcpy, tcuMemcpy, "cuMemcpy");
  320 + LOAD_SYMBOL(cuMemcpyAsync, tcuMemcpyAsync, "cuMemcpyAsync");
  321 + LOAD_SYMBOL(cuMemcpy2D, tcuMemcpy2D_v2, "cuMemcpy2D_v2");
  322 + LOAD_SYMBOL(cuMemcpy2DAsync, tcuMemcpy2DAsync_v2, "cuMemcpy2DAsync_v2");
  323 + LOAD_SYMBOL(cuMemcpyHtoD, tcuMemcpyHtoD_v2, "cuMemcpyHtoD_v2");
  324 + LOAD_SYMBOL(cuMemcpyHtoDAsync, tcuMemcpyHtoDAsync_v2, "cuMemcpyHtoDAsync_v2");
  325 + LOAD_SYMBOL(cuMemcpyDtoH, tcuMemcpyDtoH_v2, "cuMemcpyDtoH_v2");
  326 + LOAD_SYMBOL(cuMemcpyDtoHAsync, tcuMemcpyDtoHAsync_v2, "cuMemcpyDtoHAsync_v2");
  327 + LOAD_SYMBOL(cuMemcpyDtoD, tcuMemcpyDtoD_v2, "cuMemcpyDtoD_v2");
  328 + LOAD_SYMBOL(cuMemcpyDtoDAsync, tcuMemcpyDtoDAsync_v2, "cuMemcpyDtoDAsync_v2");
  329 + LOAD_SYMBOL(cuGetErrorName, tcuGetErrorName, "cuGetErrorName");
  330 + LOAD_SYMBOL(cuGetErrorString, tcuGetErrorString, "cuGetErrorString");
  331 + LOAD_SYMBOL(cuCtxGetDevice, tcuCtxGetDevice, "cuCtxGetDevice");
  332 +
  333 + LOAD_SYMBOL(cuDevicePrimaryCtxRetain, tcuDevicePrimaryCtxRetain, "cuDevicePrimaryCtxRetain");
  334 + LOAD_SYMBOL(cuDevicePrimaryCtxRelease, tcuDevicePrimaryCtxRelease, "cuDevicePrimaryCtxRelease");
  335 + LOAD_SYMBOL(cuDevicePrimaryCtxSetFlags, tcuDevicePrimaryCtxSetFlags, "cuDevicePrimaryCtxSetFlags");
  336 + LOAD_SYMBOL(cuDevicePrimaryCtxGetState, tcuDevicePrimaryCtxGetState, "cuDevicePrimaryCtxGetState");
  337 + LOAD_SYMBOL(cuDevicePrimaryCtxReset, tcuDevicePrimaryCtxReset, "cuDevicePrimaryCtxReset");
  338 +
  339 + LOAD_SYMBOL(cuStreamCreate, tcuStreamCreate, "cuStreamCreate");
  340 + LOAD_SYMBOL(cuStreamQuery, tcuStreamQuery, "cuStreamQuery");
  341 + LOAD_SYMBOL(cuStreamSynchronize, tcuStreamSynchronize, "cuStreamSynchronize");
  342 + LOAD_SYMBOL(cuStreamDestroy, tcuStreamDestroy_v2, "cuStreamDestroy_v2");
  343 + LOAD_SYMBOL(cuStreamAddCallback, tcuStreamAddCallback, "cuStreamAddCallback");
  344 + LOAD_SYMBOL(cuEventCreate, tcuEventCreate, "cuEventCreate");
  345 + LOAD_SYMBOL(cuEventDestroy, tcuEventDestroy_v2, "cuEventDestroy_v2");
  346 + LOAD_SYMBOL(cuEventSynchronize, tcuEventSynchronize, "cuEventSynchronize");
  347 + LOAD_SYMBOL(cuEventQuery, tcuEventQuery, "cuEventQuery");
  348 + LOAD_SYMBOL(cuEventRecord, tcuEventRecord, "cuEventRecord");
  349 +
  350 + LOAD_SYMBOL(cuLaunchKernel, tcuLaunchKernel, "cuLaunchKernel");
  351 + LOAD_SYMBOL(cuLinkCreate, tcuLinkCreate, "cuLinkCreate");
  352 + LOAD_SYMBOL(cuLinkAddData, tcuLinkAddData, "cuLinkAddData");
  353 + LOAD_SYMBOL(cuLinkComplete, tcuLinkComplete, "cuLinkComplete");
  354 + LOAD_SYMBOL(cuLinkDestroy, tcuLinkDestroy, "cuLinkDestroy");
  355 + LOAD_SYMBOL(cuModuleLoadData, tcuModuleLoadData, "cuModuleLoadData");
  356 + LOAD_SYMBOL(cuModuleUnload, tcuModuleUnload, "cuModuleUnload");
  357 + LOAD_SYMBOL(cuModuleGetFunction, tcuModuleGetFunction, "cuModuleGetFunction");
  358 + LOAD_SYMBOL(cuModuleGetGlobal, tcuModuleGetGlobal, "cuModuleGetGlobal");
  359 + LOAD_SYMBOL(cuTexObjectCreate, tcuTexObjectCreate, "cuTexObjectCreate");
  360 + LOAD_SYMBOL(cuTexObjectDestroy, tcuTexObjectDestroy, "cuTexObjectDestroy");
  361 +
  362 + LOAD_SYMBOL(cuGLGetDevices, tcuGLGetDevices_v2, "cuGLGetDevices_v2");
  363 + LOAD_SYMBOL(cuGraphicsGLRegisterImage, tcuGraphicsGLRegisterImage, "cuGraphicsGLRegisterImage");
  364 + LOAD_SYMBOL(cuGraphicsUnregisterResource, tcuGraphicsUnregisterResource, "cuGraphicsUnregisterResource");
  365 + LOAD_SYMBOL(cuGraphicsMapResources, tcuGraphicsMapResources, "cuGraphicsMapResources");
  366 + LOAD_SYMBOL(cuGraphicsUnmapResources, tcuGraphicsUnmapResources, "cuGraphicsUnmapResources");
  367 + LOAD_SYMBOL(cuGraphicsSubResourceGetMappedArray, tcuGraphicsSubResourceGetMappedArray, "cuGraphicsSubResourceGetMappedArray");
  368 + LOAD_SYMBOL(cuGraphicsResourceGetMappedPointer, tcuGraphicsResourceGetMappedPointer, "cuGraphicsResourceGetMappedPointer_v2");
  369 +
  370 + LOAD_SYMBOL_OPT(cuDeviceGetUuid, tcuDeviceGetUuid, "cuDeviceGetUuid");
  371 + LOAD_SYMBOL_OPT(cuImportExternalMemory, tcuImportExternalMemory, "cuImportExternalMemory");
  372 + LOAD_SYMBOL_OPT(cuDestroyExternalMemory, tcuDestroyExternalMemory, "cuDestroyExternalMemory");
  373 + LOAD_SYMBOL_OPT(cuExternalMemoryGetMappedBuffer, tcuExternalMemoryGetMappedBuffer, "cuExternalMemoryGetMappedBuffer");
  374 + LOAD_SYMBOL_OPT(cuExternalMemoryGetMappedMipmappedArray, tcuExternalMemoryGetMappedMipmappedArray, "cuExternalMemoryGetMappedMipmappedArray");
  375 + LOAD_SYMBOL_OPT(cuMipmappedArrayGetLevel, tcuMipmappedArrayGetLevel, "cuMipmappedArrayGetLevel");
  376 + LOAD_SYMBOL_OPT(cuMipmappedArrayDestroy, tcuMipmappedArrayDestroy, "cuMipmappedArrayDestroy");
  377 +
  378 + LOAD_SYMBOL_OPT(cuImportExternalSemaphore, tcuImportExternalSemaphore, "cuImportExternalSemaphore");
  379 + LOAD_SYMBOL_OPT(cuDestroyExternalSemaphore, tcuDestroyExternalSemaphore, "cuDestroyExternalSemaphore");
  380 + LOAD_SYMBOL_OPT(cuSignalExternalSemaphoresAsync, tcuSignalExternalSemaphoresAsync, "cuSignalExternalSemaphoresAsync");
  381 + LOAD_SYMBOL_OPT(cuWaitExternalSemaphoresAsync, tcuWaitExternalSemaphoresAsync, "cuWaitExternalSemaphoresAsync");
  382 +
  383 + LOAD_SYMBOL(cuArray3DCreate, tcuArray3DCreate, "cuArray3DCreate_v2");
  384 + LOAD_SYMBOL(cuArrayDestroy, tcuArrayDestroy, "cuArrayDestroy");
  385 +
  386 + LOAD_SYMBOL_OPT(cuEGLStreamProducerConnect, tcuEGLStreamProducerConnect, "cuEGLStreamProducerConnect");
  387 + LOAD_SYMBOL_OPT(cuEGLStreamProducerDisconnect, tcuEGLStreamProducerDisconnect, "cuEGLStreamProducerDisconnect");
  388 + LOAD_SYMBOL_OPT(cuEGLStreamConsumerDisconnect, tcuEGLStreamConsumerDisconnect, "cuEGLStreamConsumerDisconnect");
  389 + LOAD_SYMBOL_OPT(cuEGLStreamProducerPresentFrame, tcuEGLStreamProducerPresentFrame, "cuEGLStreamProducerPresentFrame");
  390 + LOAD_SYMBOL_OPT(cuEGLStreamProducerReturnFrame, tcuEGLStreamProducerReturnFrame, "cuEGLStreamProducerReturnFrame");
  391 +
  392 +#if defined(_WIN32) || defined(__CYGWIN__)
  393 + LOAD_SYMBOL(cuD3D11GetDevice, tcuD3D11GetDevice, "cuD3D11GetDevice");
  394 + LOAD_SYMBOL(cuD3D11GetDevices, tcuD3D11GetDevices, "cuD3D11GetDevices");
  395 + LOAD_SYMBOL(cuGraphicsD3D11RegisterResource, tcuGraphicsD3D11RegisterResource, "cuGraphicsD3D11RegisterResource");
  396 +#endif
  397 +
  398 + GENERIC_LOAD_FUNC_FINALE(cuda);
  399 +}
  400 +#endif
  401 +
  402 +static inline int cuvid_load_functions(CuvidFunctions **functions, void *logctx)
  403 +{
  404 + GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
  405 +
  406 + LOAD_SYMBOL_OPT(cuvidGetDecoderCaps, tcuvidGetDecoderCaps, "cuvidGetDecoderCaps");
  407 + LOAD_SYMBOL(cuvidCreateDecoder, tcuvidCreateDecoder, "cuvidCreateDecoder");
  408 + LOAD_SYMBOL(cuvidDestroyDecoder, tcuvidDestroyDecoder, "cuvidDestroyDecoder");
  409 + LOAD_SYMBOL(cuvidDecodePicture, tcuvidDecodePicture, "cuvidDecodePicture");
  410 + LOAD_SYMBOL(cuvidGetDecodeStatus, tcuvidGetDecodeStatus, "cuvidGetDecodeStatus");
  411 + LOAD_SYMBOL(cuvidReconfigureDecoder, tcuvidReconfigureDecoder, "cuvidReconfigureDecoder");
  412 +#ifdef __CUVID_DEVPTR64
  413 + LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame64");
  414 + LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
  415 +#else
  416 + LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame");
  417 + LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
  418 +#endif
  419 + LOAD_SYMBOL(cuvidCtxLockCreate, tcuvidCtxLockCreate, "cuvidCtxLockCreate");
  420 + LOAD_SYMBOL(cuvidCtxLockDestroy, tcuvidCtxLockDestroy, "cuvidCtxLockDestroy");
  421 + LOAD_SYMBOL(cuvidCtxLock, tcuvidCtxLock, "cuvidCtxLock");
  422 + LOAD_SYMBOL(cuvidCtxUnlock, tcuvidCtxUnlock, "cuvidCtxUnlock");
  423 +
  424 +#if !defined(__APPLE__)
  425 + LOAD_SYMBOL(cuvidCreateVideoSource, tcuvidCreateVideoSource, "cuvidCreateVideoSource");
  426 + LOAD_SYMBOL(cuvidCreateVideoSourceW, tcuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
  427 + LOAD_SYMBOL(cuvidDestroyVideoSource, tcuvidDestroyVideoSource, "cuvidDestroyVideoSource");
  428 + LOAD_SYMBOL(cuvidSetVideoSourceState, tcuvidSetVideoSourceState, "cuvidSetVideoSourceState");
  429 + LOAD_SYMBOL(cuvidGetVideoSourceState, tcuvidGetVideoSourceState, "cuvidGetVideoSourceState");
  430 + LOAD_SYMBOL(cuvidGetSourceVideoFormat, tcuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
  431 + LOAD_SYMBOL(cuvidGetSourceAudioFormat, tcuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
  432 +#endif
  433 + LOAD_SYMBOL(cuvidCreateVideoParser, tcuvidCreateVideoParser, "cuvidCreateVideoParser");
  434 + LOAD_SYMBOL(cuvidParseVideoData, tcuvidParseVideoData, "cuvidParseVideoData");
  435 + LOAD_SYMBOL(cuvidDestroyVideoParser, tcuvidDestroyVideoParser, "cuvidDestroyVideoParser");
  436 +
  437 + GENERIC_LOAD_FUNC_FINALE(cuvid);
  438 +}
  439 +
  440 +static inline int nvenc_load_functions(NvencFunctions **functions, void *logctx)
  441 +{
  442 + GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME);
  443 +
  444 + LOAD_SYMBOL(NvEncodeAPICreateInstance, tNvEncodeAPICreateInstance, "NvEncodeAPICreateInstance");
  445 + LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, tNvEncodeAPIGetMaxSupportedVersion, "NvEncodeAPIGetMaxSupportedVersion");
  446 +
  447 + GENERIC_LOAD_FUNC_FINALE(nvenc);
  448 +}
  449 +
  450 +#undef GENERIC_LOAD_FUNC_PREAMBLE
  451 +#undef LOAD_LIBRARY
  452 +#undef LOAD_SYMBOL
  453 +#undef GENERIC_LOAD_FUNC_FINALE
  454 +#undef GENERIC_FREE_FUNC
  455 +#undef CUDA_LIBNAME
  456 +#undef NVCUVID_LIBNAME
  457 +#undef NVENC_LIBNAME
  458 +
  459 +#endif
  460 +
... ...
nv-codec-headers/include/ffnvcodec/dynlink_nvcuvid.h 0 → 100644
  1 +/*
  2 + * This copyright notice applies to this header file only:
  3 + *
  4 + * Copyright (c) 2010-2021 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 nvcuvid.h
  30 +//! NVDECODE API provides video decoding interface to NVIDIA GPU devices.
  31 +//! \date 2015-2020
  32 +//! This file contains the interface constants, structure definitions and function prototypes.
  33 +/********************************************************************************************************************/
  34 +
  35 +#if !defined(__NVCUVID_H__)
  36 +#define __NVCUVID_H__
  37 +
  38 +#include "dynlink_cuviddec.h"
  39 +
  40 +#if defined(__cplusplus)
  41 +extern "C" {
  42 +#endif /* __cplusplus */
  43 +
  44 +
  45 +/***********************************************/
  46 +//!
  47 +//! High-level helper APIs for video sources
  48 +//!
  49 +/***********************************************/
  50 +
  51 +typedef void *CUvideosource;
  52 +typedef void *CUvideoparser;
  53 +typedef long long CUvideotimestamp;
  54 +
  55 +
  56 +/************************************************************************/
  57 +//! \enum cudaVideoState
  58 +//! Video source state enums
  59 +//! Used in cuvidSetVideoSourceState and cuvidGetVideoSourceState APIs
  60 +/************************************************************************/
  61 +typedef enum {
  62 + cudaVideoState_Error = -1, /**< Error state (invalid source) */
  63 + cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */
  64 + cudaVideoState_Started = 1 /**< Source is running and delivering data */
  65 +} cudaVideoState;
  66 +
  67 +/************************************************************************/
  68 +//! \enum cudaAudioCodec
  69 +//! Audio compression enums
  70 +//! Used in CUAUDIOFORMAT structure
  71 +/************************************************************************/
  72 +typedef enum {
  73 + cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */
  74 + cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
  75 + cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
  76 + cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
  77 + cudaAudioCodec_LPCM, /**< PCM Audio */
  78 + cudaAudioCodec_AAC, /**< AAC Audio */
  79 +} cudaAudioCodec;
  80 +
  81 +/************************************************************************************************/
  82 +//! \ingroup STRUCTS
  83 +//! \struct CUVIDEOFORMAT
  84 +//! Video format
  85 +//! Used in cuvidGetSourceVideoFormat API
  86 +/************************************************************************************************/
  87 +typedef struct
  88 +{
  89 + cudaVideoCodec codec; /**< OUT: Compression format */
  90 + /**
  91 + * OUT: frame rate = numerator / denominator (for example: 30000/1001)
  92 + */
  93 + struct {
  94 + /**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */
  95 + unsigned int numerator;
  96 + /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */
  97 + unsigned int denominator;
  98 + } frame_rate;
  99 + unsigned char progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */
  100 + unsigned char bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */
  101 + unsigned char bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */
  102 + unsigned char min_num_decode_surfaces; /**< OUT: Minimum number of decode surfaces to be allocated for correct
  103 + decoding. The client can send this value in ulNumDecodeSurfaces
  104 + (in CUVIDDECODECREATEINFO structure).
  105 + This guarantees correct functionality and optimal video memory
  106 + usage but not necessarily the best performance, which depends on
  107 + the design of the overall application. The optimal number of
  108 + decode surfaces (in terms of performance and memory utilization)
  109 + should be decided by experimentation for each application, but it
  110 + cannot go below min_num_decode_surfaces.
  111 + If this value is used for ulNumDecodeSurfaces then it must be
  112 + returned to parser during sequence callback. */
  113 + unsigned int coded_width; /**< OUT: coded frame width in pixels */
  114 + unsigned int coded_height; /**< OUT: coded frame height in pixels */
  115 + /**
  116 + * area of the frame that should be displayed
  117 + * typical example:
  118 + * coded_width = 1920, coded_height = 1088
  119 + * display_area = { 0,0,1920,1080 }
  120 + */
  121 + struct {
  122 + int left; /**< OUT: left position of display rect */
  123 + int top; /**< OUT: top position of display rect */
  124 + int right; /**< OUT: right position of display rect */
  125 + int bottom; /**< OUT: bottom position of display rect */
  126 + } display_area;
  127 + cudaVideoChromaFormat chroma_format; /**< OUT: Chroma format */
  128 + unsigned int bitrate; /**< OUT: video bitrate (bps, 0=unknown) */
  129 + /**
  130 + * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc)
  131 + */
  132 + struct {
  133 + int x;
  134 + int y;
  135 + } display_aspect_ratio;
  136 + /**
  137 + * Video Signal Description
  138 + * Refer section E.2.1 (VUI parameters semantics) of H264 spec file
  139 + */
  140 + struct {
  141 + unsigned char video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified */
  142 + unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range */
  143 + unsigned char reserved_zero_bits : 4; /**< Reserved bits */
  144 + unsigned char color_primaries; /**< OUT: chromaticity coordinates of source primaries */
  145 + unsigned char transfer_characteristics; /**< OUT: opto-electronic transfer characteristic of the source picture */
  146 + unsigned char matrix_coefficients; /**< OUT: used in deriving luma and chroma signals from RGB primaries */
  147 + } video_signal_description;
  148 + unsigned int seqhdr_data_length; /**< OUT: Additional bytes following (CUVIDEOFORMATEX) */
  149 +} CUVIDEOFORMAT;
  150 +
  151 +/****************************************************************/
  152 +//! \ingroup STRUCTS
  153 +//! \struct CUVIDOPERATINGPOINTINFO
  154 +//! Operating point information of scalable bitstream
  155 +/****************************************************************/
  156 +typedef struct
  157 +{
  158 + cudaVideoCodec codec;
  159 + union
  160 + {
  161 + struct
  162 + {
  163 + unsigned char operating_points_cnt;
  164 + unsigned char reserved24_bits[3];
  165 + unsigned short operating_points_idc[32];
  166 + } av1;
  167 + unsigned char CodecReserved[1024];
  168 + };
  169 +} CUVIDOPERATINGPOINTINFO;
  170 +
  171 +/****************************************************************/
  172 +//! \ingroup STRUCTS
  173 +//! \struct CUVIDAV1SEQHDR
  174 +//! AV1 specific sequence header information
  175 +/****************************************************************/
  176 +typedef struct {
  177 + unsigned int max_width;
  178 + unsigned int max_height;
  179 + unsigned char reserved[1016];
  180 +} CUVIDAV1SEQHDR;
  181 +
  182 +/****************************************************************/
  183 +//! \ingroup STRUCTS
  184 +//! \struct CUVIDEOFORMATEX
  185 +//! Video format including raw sequence header information
  186 +//! Used in cuvidGetSourceVideoFormat API
  187 +/****************************************************************/
  188 +typedef struct
  189 +{
  190 + CUVIDEOFORMAT format; /**< OUT: CUVIDEOFORMAT structure */
  191 + union {
  192 + CUVIDAV1SEQHDR av1;
  193 + unsigned char raw_seqhdr_data[1024]; /**< OUT: Sequence header data */
  194 + };
  195 +} CUVIDEOFORMATEX;
  196 +
  197 +/****************************************************************/
  198 +//! \ingroup STRUCTS
  199 +//! \struct CUAUDIOFORMAT
  200 +//! Audio formats
  201 +//! Used in cuvidGetSourceAudioFormat API
  202 +/****************************************************************/
  203 +typedef struct
  204 +{
  205 + cudaAudioCodec codec; /**< OUT: Compression format */
  206 + unsigned int channels; /**< OUT: number of audio channels */
  207 + unsigned int samplespersec; /**< OUT: sampling frequency */
  208 + unsigned int bitrate; /**< OUT: For uncompressed, can also be used to determine bits per sample */
  209 + unsigned int reserved1; /**< Reserved for future use */
  210 + unsigned int reserved2; /**< Reserved for future use */
  211 +} CUAUDIOFORMAT;
  212 +
  213 +
  214 +/***************************************************************/
  215 +//! \enum CUvideopacketflags
  216 +//! Data packet flags
  217 +//! Used in CUVIDSOURCEDATAPACKET structure
  218 +/***************************************************************/
  219 +typedef enum {
  220 + CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
  221 + CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
  222 + CUVID_PKT_DISCONTINUITY = 0x04, /**< Set when a discontinuity has to be signalled */
  223 + CUVID_PKT_ENDOFPICTURE = 0x08, /**< Set when the packet contains exactly one frame or one field */
  224 + CUVID_PKT_NOTIFY_EOS = 0x10, /**< If this flag is set along with CUVID_PKT_ENDOFSTREAM, an additional (dummy)
  225 + display callback will be invoked with null value of CUVIDPARSERDISPINFO which
  226 + should be interpreted as end of the stream. */
  227 +} CUvideopacketflags;
  228 +
  229 +/*****************************************************************************/
  230 +//! \ingroup STRUCTS
  231 +//! \struct CUVIDSOURCEDATAPACKET
  232 +//! Data Packet
  233 +//! Used in cuvidParseVideoData API
  234 +//! IN for cuvidParseVideoData
  235 +/*****************************************************************************/
  236 +typedef struct _CUVIDSOURCEDATAPACKET
  237 +{
  238 + tcu_ulong flags; /**< IN: Combination of CUVID_PKT_XXX flags */
  239 + tcu_ulong payload_size; /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */
  240 + const unsigned char *payload; /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */
  241 + CUvideotimestamp timestamp; /**< IN: Presentation time stamp (10MHz clock), only valid if
  242 + CUVID_PKT_TIMESTAMP flag is set */
  243 +} CUVIDSOURCEDATAPACKET;
  244 +
  245 +// Callback for packet delivery
  246 +typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *);
  247 +
  248 +/**************************************************************************************************************************/
  249 +//! \ingroup STRUCTS
  250 +//! \struct CUVIDSOURCEPARAMS
  251 +//! Describes parameters needed in cuvidCreateVideoSource API
  252 +//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported
  253 +//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.
  254 +/**************************************************************************************************************************/
  255 +typedef struct _CUVIDSOURCEPARAMS
  256 +{
  257 + unsigned int ulClockRate; /**< IN: Time stamp units in Hz (0=default=10000000Hz) */
  258 + unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */
  259 + unsigned int uReserved : 31; /**< Reserved for future use - set to zero */
  260 + unsigned int uReserved1[6]; /**< Reserved for future use - set to zero */
  261 + void *pUserData; /**< IN: User private data passed in to the data handlers */
  262 + PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< IN: Called to deliver video packets */
  263 + PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< IN: Called to deliver audio packets. */
  264 + void *pvReserved2[8]; /**< Reserved for future use - set to NULL */
  265 +} CUVIDSOURCEPARAMS;
  266 +
  267 +
  268 +/**********************************************/
  269 +//! \ingroup ENUMS
  270 +//! \enum CUvideosourceformat_flags
  271 +//! CUvideosourceformat_flags
  272 +//! Used in cuvidGetSourceVideoFormat API
  273 +/**********************************************/
  274 +typedef enum {
  275 + CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
  276 +} CUvideosourceformat_flags;
  277 +
  278 +#if !defined(__APPLE__)
  279 +/***************************************************************************************************************************/
  280 +//! \ingroup FUNCTS
  281 +//! \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
  282 +//! Create CUvideosource object. CUvideosource spawns demultiplexer thread that provides two callbacks:
  283 +//! pfnVideoDataHandler() and pfnAudioDataHandler()
  284 +//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported
  285 +//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.
  286 +/***************************************************************************************************************************/
  287 +typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);
  288 +
  289 +/***************************************************************************************************************************/
  290 +//! \ingroup FUNCTS
  291 +//! \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
  292 +//! Create video source
  293 +/***************************************************************************************************************************/
  294 +typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);
  295 +
  296 +/********************************************************************/
  297 +//! \ingroup FUNCTS
  298 +//! \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
  299 +//! Destroy video source
  300 +/********************************************************************/
  301 +typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);
  302 +
  303 +/******************************************************************************************/
  304 +//! \ingroup FUNCTS
  305 +//! \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
  306 +//! Set video source state to:
  307 +//! cudaVideoState_Started - to signal the source to run and deliver data
  308 +//! cudaVideoState_Stopped - to stop the source from delivering the data
  309 +//! cudaVideoState_Error - invalid source
  310 +/******************************************************************************************/
  311 +typedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);
  312 +
  313 +/******************************************************************************************/
  314 +//! \ingroup FUNCTS
  315 +//! \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
  316 +//! Get video source state
  317 +//! Returns:
  318 +//! cudaVideoState_Started - if Source is running and delivering data
  319 +//! cudaVideoState_Stopped - if Source is stopped or reached end-of-stream
  320 +//! cudaVideoState_Error - if Source is in error state
  321 +/******************************************************************************************/
  322 +typedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj);
  323 +
  324 +/******************************************************************************************************************/
  325 +//! \ingroup FUNCTS
  326 +//! \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
  327 +//! Gets video source format in pvidfmt, flags is set to combination of CUvideosourceformat_flags as per requirement
  328 +/******************************************************************************************************************/
  329 +typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);
  330 +
  331 +/**************************************************************************************************************************/
  332 +//! \ingroup FUNCTS
  333 +//! \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
  334 +//! Get audio source format
  335 +//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported
  336 +//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.
  337 +/**************************************************************************************************************************/
  338 +typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);
  339 +
  340 +#endif
  341 +/**********************************************************************************/
  342 +//! \ingroup STRUCTS
  343 +//! \struct CUVIDPARSERDISPINFO
  344 +//! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture
  345 +/**********************************************************************************/
  346 +typedef struct _CUVIDPARSERDISPINFO
  347 +{
  348 + int picture_index; /**< OUT: Index of the current picture */
  349 + int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */
  350 + int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise */
  351 + int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling,
  352 + -1=unpaired field) */
  353 + CUvideotimestamp timestamp; /**< OUT: Presentation time stamp */
  354 +} CUVIDPARSERDISPINFO;
  355 +
  356 +/***********************************************************************************************************************/
  357 +//! Parser callbacks
  358 +//! The parser will call these synchronously from within cuvidParseVideoData(), whenever there is sequence change or a picture
  359 +//! is ready to be decoded and/or displayed. First argument in functions is "void *pUserData" member of structure CUVIDSOURCEPARAMS
  360 +//! Return values from these callbacks are interpreted as below. If the callbacks return failure, it will be propagated by
  361 +//! cuvidParseVideoData() to the application.
  362 +//! Parser picks default operating point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set or return value is
  363 +//! -1 or invalid operating point.
  364 +//! PFNVIDSEQUENCECALLBACK : 0: fail, 1: succeeded, > 1: override dpb size of parser (set by CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces
  365 +//! while creating parser)
  366 +//! PFNVIDDECODECALLBACK : 0: fail, >=1: succeeded
  367 +//! PFNVIDDISPLAYCALLBACK : 0: fail, >=1: succeeded
  368 +//! PFNVIDOPPOINTCALLBACK : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint, bit 10-10: outputAllLayers, bit 11-30: reserved)
  369 +/***********************************************************************************************************************/
  370 +typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *);
  371 +typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *);
  372 +typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *);
  373 +typedef int (CUDAAPI *PFNVIDOPPOINTCALLBACK)(void *, CUVIDOPERATINGPOINTINFO*);
  374 +
  375 +/**************************************/
  376 +//! \ingroup STRUCTS
  377 +//! \struct CUVIDPARSERPARAMS
  378 +//! Used in cuvidCreateVideoParser API
  379 +/**************************************/
  380 +typedef struct _CUVIDPARSERPARAMS
  381 +{
  382 + cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */
  383 + unsigned int ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */
  384 + unsigned int ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */
  385 + unsigned int ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always
  386 + IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */
  387 + unsigned int ulMaxDisplayDelay; /**< IN: Max display queue delay (improves pipelining of decode with display)
  388 + 0=no delay (recommended values: 2..4) */
  389 + unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */
  390 + unsigned int uReserved : 31; /**< Reserved for future use - set to zero */
  391 + unsigned int uReserved1[4]; /**< IN: Reserved for future use - set to 0 */
  392 + void *pUserData; /**< IN: User data for callbacks */
  393 + PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */
  394 + PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready to be decoded (decode order) */
  395 + PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be displayed (display order) */
  396 + PFNVIDOPPOINTCALLBACK pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get operating point of a AV1
  397 + scalable bitstream */
  398 + void *pvReserved2[6]; /**< Reserved for future use - set to NULL */
  399 + CUVIDEOFORMATEX *pExtVideoInfo; /**< IN: [Optional] sequence header data from system layer */
  400 +} CUVIDPARSERPARAMS;
  401 +
  402 +/************************************************************************************************/
  403 +//! \ingroup FUNCTS
  404 +//! \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
  405 +//! Create video parser object and initialize
  406 +/************************************************************************************************/
  407 +typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);
  408 +
  409 +/************************************************************************************************/
  410 +//! \ingroup FUNCTS
  411 +//! \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
  412 +//! Parse the video data from source data packet in pPacket
  413 +//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and
  414 +//! calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking of HW decoding
  415 +//! calls back pfnSequenceCallback with CUVIDEOFORMAT data for initial sequence header or when
  416 +//! the decoder encounters a video format change
  417 +//! calls back pfnDisplayPicture with CUVIDPARSERDISPINFO data to display a video frame
  418 +/************************************************************************************************/
  419 +typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);
  420 +
  421 +/************************************************************************************************/
  422 +//! \ingroup FUNCTS
  423 +//! \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
  424 +//! Destroy the video parser
  425 +/************************************************************************************************/
  426 +typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);
  427 +
  428 +/**********************************************************************************************/
  429 +
  430 +#if defined(__cplusplus)
  431 +}
  432 +#endif /* __cplusplus */
  433 +
  434 +#endif // __NVCUVID_H__
... ...
nv-codec-headers/include/ffnvcodec/nvEncodeAPI.h 0 → 100644
  1 +/*
  2 + * This copyright notice applies to this header file only:
  3 + *
  4 + * Copyright (c) 2010-2021 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-2020
  34 + * This file contains the interface constants, structure definitions and function prototypes.
  35 + */
  36 +
  37 +#ifndef _NV_ENCODEAPI_H_
  38 +#define _NV_ENCODEAPI_H_
  39 +
  40 +#include <stdlib.h>
  41 +
  42 +#ifdef _WIN32
  43 +#include <windows.h>
  44 +#endif
  45 +
  46 +#ifdef _MSC_VER
  47 +#ifndef _STDINT
  48 +typedef __int32 int32_t;
  49 +typedef unsigned __int32 uint32_t;
  50 +typedef __int64 int64_t;
  51 +typedef unsigned __int64 uint64_t;
  52 +typedef signed char int8_t;
  53 +typedef unsigned char uint8_t;
  54 +typedef short int16_t;
  55 +typedef unsigned short uint16_t;
  56 +#endif
  57 +#else
  58 +#include <stdint.h>
  59 +#endif
  60 +
  61 +#ifdef __cplusplus
  62 +extern "C" {
  63 +#endif
  64 +
  65 +/**
  66 + * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  67 + * @{
  68 + */
  69 +
  70 +#if defined(_WIN32) || defined(__CYGWIN__)
  71 +#define NVENCAPI __stdcall
  72 +#else
  73 +#define NVENCAPI
  74 +#endif
  75 +
  76 +#ifdef _WIN32
  77 +typedef RECT NVENC_RECT;
  78 +#else
  79 +#define NVENCAPI
  80 +// =========================================================================================
  81 +#if !defined(GUID) && !defined(GUID_DEFINED)
  82 +/*!
  83 + * \struct GUID
  84 + * Abstracts the GUID structure for non-windows platforms.
  85 + */
  86 +// =========================================================================================
  87 +typedef struct
  88 +{
  89 + uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */
  90 + uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */
  91 + uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */
  92 + uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits.
  93 + The remaining 6 bytes contain the final 12 hexadecimal digits. */
  94 +} GUID;
  95 +#endif // GUID
  96 +
  97 +/**
  98 + * \struct _NVENC_RECT
  99 + * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME.
  100 + */
  101 +typedef struct _NVENC_RECT
  102 +{
  103 + uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */
  104 + uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */
  105 + uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */
  106 + uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */
  107 +} NVENC_RECT;
  108 +
  109 +#endif // _WIN32
  110 +
  111 +/** @} */ /* End of GUID and NVENC_RECT structure grouping*/
  112 +
  113 +typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */
  114 +typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/
  115 +typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/
  116 +typedef void* NV_ENC_CUSTREAM_PTR; /**< Pointer to CUstream*/
  117 +
  118 +#define NVENCAPI_MAJOR_VERSION 11
  119 +#define NVENCAPI_MINOR_VERSION 1
  120 +
  121 +#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
  122 +
  123 +/**
  124 + * Macro to generate per-structure version for use with API.
  125 + */
  126 +#define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28))
  127 +
  128 +
  129 +#define NVENC_INFINITE_GOPLENGTH 0xffffffff
  130 +
  131 +#define NV_MAX_SEQ_HDR_LEN (512)
  132 +
  133 +#ifdef __GNUC__
  134 +#define NV_ENC_DEPRECATED __attribute__ ((deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION")))
  135 +#elif defined(_MSC_VER)
  136 +#define NV_ENC_DEPRECATED __declspec(deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION"))
  137 +#endif
  138 +
  139 +// =========================================================================================
  140 +// Encode Codec GUIDS supported by the NvEncodeAPI interface.
  141 +// =========================================================================================
  142 +
  143 +// {6BC82762-4E63-4ca4-AA85-1E50F321F6BF}
  144 +static const GUID NV_ENC_CODEC_H264_GUID =
  145 +{ 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } };
  146 +
  147 +// {790CDC88-4522-4d7b-9425-BDA9975F7603}
  148 +static const GUID NV_ENC_CODEC_HEVC_GUID =
  149 +{ 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } };
  150 +
  151 +
  152 +
  153 +// =========================================================================================
  154 +// * Encode Profile GUIDS supported by the NvEncodeAPI interface.
  155 +// =========================================================================================
  156 +
  157 +// {BFD6F8E7-233C-4341-8B3E-4818523803F4}
  158 +static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID =
  159 +{ 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } };
  160 +
  161 +// {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A}
  162 +static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID =
  163 +{ 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } };
  164 +
  165 +// {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D}
  166 +static const GUID NV_ENC_H264_PROFILE_MAIN_GUID =
  167 +{ 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } };
  168 +
  169 +// {E7CBC309-4F7A-4b89-AF2A-D537C92BE310}
  170 +static const GUID NV_ENC_H264_PROFILE_HIGH_GUID =
  171 +{ 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } };
  172 +
  173 +// {7AC663CB-A598-4960-B844-339B261A7D52}
  174 +static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID =
  175 +{ 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } };
  176 +
  177 +// {40847BF5-33F7-4601-9084-E8FE3C1DB8B7}
  178 +static const GUID NV_ENC_H264_PROFILE_STEREO_GUID =
  179 +{ 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } };
  180 +
  181 +// {B405AFAC-F32B-417B-89C4-9ABEED3E5978}
  182 +static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID =
  183 +{ 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } };
  184 +
  185 +// {AEC1BD87-E85B-48f2-84C3-98BCA6285072}
  186 +static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID =
  187 +{ 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } };
  188 +
  189 +// {B514C39A-B55B-40fa-878F-F1253B4DFDEC}
  190 +static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID =
  191 +{ 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } };
  192 +
  193 +// {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5}
  194 +static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID =
  195 +{ 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } };
  196 +
  197 +// For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only
  198 +// {51ec32b5-1b4c-453c-9cbd-b616bd621341}
  199 +static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID =
  200 +{ 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } };
  201 +
  202 +// =========================================================================================
  203 +// * Preset GUIDS supported by the NvEncodeAPI interface.
  204 +// =========================================================================================
  205 +// {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
  206 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_DEFAULT_GUID =
  207 +{ 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } };
  208 +
  209 +// {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
  210 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HP_GUID =
  211 +{ 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } };
  212 +
  213 +// {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
  214 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HQ_GUID =
  215 +{ 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } };
  216 +
  217 +// {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
  218 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_BD_GUID =
  219 +{ 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } };
  220 +
  221 +// {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
  222 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID =
  223 +{ 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } };
  224 +
  225 +// {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
  226 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID =
  227 +{ 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } };
  228 +
  229 +// {67082A44-4BAD-48FA-98EA-93056D150A58}
  230 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID =
  231 +{ 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } };
  232 +
  233 +// {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
  234 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID =
  235 +{ 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } };
  236 +
  237 +// {149998E7-2364-411d-82EF-179888093409}
  238 +NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID =
  239 +{ 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } };
  240 +
  241 +// Performance degrades and quality improves as we move from P1 to P7. Presets P3 to P7 for H264 and Presets P2 to P7 for HEVC have B frames enabled by default
  242 +// for HIGH_QUALITY and LOSSLESS tuning info, and will not work with Weighted Prediction enabled. In case Weighted Prediction is required, disable B frames by
  243 +// setting frameIntervalP = 1
  244 +// {FC0A8D3E-45F8-4CF8-80C7-298871590EBF}
  245 +static const GUID NV_ENC_PRESET_P1_GUID =
  246 +{ 0xfc0a8d3e, 0x45f8, 0x4cf8, { 0x80, 0xc7, 0x29, 0x88, 0x71, 0x59, 0xe, 0xbf } };
  247 +
  248 +// {F581CFB8-88D6-4381-93F0-DF13F9C27DAB}
  249 +static const GUID NV_ENC_PRESET_P2_GUID =
  250 +{ 0xf581cfb8, 0x88d6, 0x4381, { 0x93, 0xf0, 0xdf, 0x13, 0xf9, 0xc2, 0x7d, 0xab } };
  251 +
  252 +// {36850110-3A07-441F-94D5-3670631F91F6}
  253 +static const GUID NV_ENC_PRESET_P3_GUID =
  254 +{ 0x36850110, 0x3a07, 0x441f, { 0x94, 0xd5, 0x36, 0x70, 0x63, 0x1f, 0x91, 0xf6 } };
  255 +
  256 +// {90A7B826-DF06-4862-B9D2-CD6D73A08681}
  257 +static const GUID NV_ENC_PRESET_P4_GUID =
  258 +{ 0x90a7b826, 0xdf06, 0x4862, { 0xb9, 0xd2, 0xcd, 0x6d, 0x73, 0xa0, 0x86, 0x81 } };
  259 +
  260 +// {21C6E6B4-297A-4CBA-998F-B6CBDE72ADE3}
  261 +static const GUID NV_ENC_PRESET_P5_GUID =
  262 +{ 0x21c6e6b4, 0x297a, 0x4cba, { 0x99, 0x8f, 0xb6, 0xcb, 0xde, 0x72, 0xad, 0xe3 } };
  263 +
  264 +// {8E75C279-6299-4AB6-8302-0B215A335CF5}
  265 +static const GUID NV_ENC_PRESET_P6_GUID =
  266 +{ 0x8e75c279, 0x6299, 0x4ab6, { 0x83, 0x2, 0xb, 0x21, 0x5a, 0x33, 0x5c, 0xf5 } };
  267 +
  268 +// {84848C12-6F71-4C13-931B-53E283F57974}
  269 +static const GUID NV_ENC_PRESET_P7_GUID =
  270 +{ 0x84848c12, 0x6f71, 0x4c13, { 0x93, 0x1b, 0x53, 0xe2, 0x83, 0xf5, 0x79, 0x74 } };
  271 +
  272 +/**
  273 + * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  274 + * @{
  275 + */
  276 +
  277 +/**
  278 + * Input frame encode modes
  279 + */
  280 +typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE
  281 +{
  282 + NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */
  283 + NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */
  284 + NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */
  285 +} NV_ENC_PARAMS_FRAME_FIELD_MODE;
  286 +
  287 +/**
  288 + * Rate Control Modes
  289 + */
  290 +typedef enum _NV_ENC_PARAMS_RC_MODE
  291 +{
  292 + NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */
  293 + NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */
  294 + NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */
  295 + NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ = 0x8, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION +
  296 + lowDelayKeyFrameScale=1 */
  297 + NV_ENC_PARAMS_RC_CBR_HQ = 0x10, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
  298 + NV_ENC_PARAMS_RC_VBR_HQ = 0x20 /**< Deprecated, use NV_ENC_PARAMS_RC_VBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
  299 +} NV_ENC_PARAMS_RC_MODE;
  300 +
  301 +/**
  302 + * Multi Pass encoding
  303 + */
  304 +typedef enum _NV_ENC_MULTI_PASS
  305 +{
  306 + NV_ENC_MULTI_PASS_DISABLED = 0x0, /**< Single Pass */
  307 + NV_ENC_TWO_PASS_QUARTER_RESOLUTION = 0x1, /**< Two Pass encoding is enabled where first Pass is quarter resolution */
  308 + NV_ENC_TWO_PASS_FULL_RESOLUTION = 0x2, /**< Two Pass encoding is enabled where first Pass is full resolution */
  309 +} NV_ENC_MULTI_PASS;
  310 +
  311 +/**
  312 + * Emphasis Levels
  313 + */
  314 +typedef enum _NV_ENC_EMPHASIS_MAP_LEVEL
  315 +{
  316 + NV_ENC_EMPHASIS_MAP_LEVEL_0 = 0x0, /**< Emphasis Map Level 0, for zero Delta QP value */
  317 + NV_ENC_EMPHASIS_MAP_LEVEL_1 = 0x1, /**< Emphasis Map Level 1, for very low Delta QP value */
  318 + NV_ENC_EMPHASIS_MAP_LEVEL_2 = 0x2, /**< Emphasis Map Level 2, for low Delta QP value */
  319 + NV_ENC_EMPHASIS_MAP_LEVEL_3 = 0x3, /**< Emphasis Map Level 3, for medium Delta QP value */
  320 + NV_ENC_EMPHASIS_MAP_LEVEL_4 = 0x4, /**< Emphasis Map Level 4, for high Delta QP value */
  321 + NV_ENC_EMPHASIS_MAP_LEVEL_5 = 0x5 /**< Emphasis Map Level 5, for very high Delta QP value */
  322 +} NV_ENC_EMPHASIS_MAP_LEVEL;
  323 +
  324 +/**
  325 + * QP MAP MODE
  326 + */
  327 +typedef enum _NV_ENC_QP_MAP_MODE
  328 +{
  329 + NV_ENC_QP_MAP_DISABLED = 0x0, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap have no effect. */
  330 + NV_ENC_QP_MAP_EMPHASIS = 0x1, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as Emphasis level. Currently this is only supported for H264 */
  331 + NV_ENC_QP_MAP_DELTA = 0x2, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP delta map. */
  332 + NV_ENC_QP_MAP = 0x3, /**< Currently This is not supported. Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP value. */
  333 +} NV_ENC_QP_MAP_MODE;
  334 +
  335 +#define NV_ENC_PARAMS_RC_VBR_MINQP (NV_ENC_PARAMS_RC_MODE)0x4 /**< Deprecated */
  336 +#define NV_ENC_PARAMS_RC_2_PASS_QUALITY NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ /**< Deprecated */
  337 +#define NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP NV_ENC_PARAMS_RC_CBR_HQ /**< Deprecated */
  338 +#define NV_ENC_PARAMS_RC_2_PASS_VBR NV_ENC_PARAMS_RC_VBR_HQ /**< Deprecated */
  339 +#define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */
  340 +
  341 +/**
  342 + * Input picture structure
  343 + */
  344 +typedef enum _NV_ENC_PIC_STRUCT
  345 +{
  346 + NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */
  347 + NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */
  348 + NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */
  349 +} NV_ENC_PIC_STRUCT;
  350 +
  351 +/**
  352 + * Input picture type
  353 + */
  354 +typedef enum _NV_ENC_PIC_TYPE
  355 +{
  356 + NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */
  357 + NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */
  358 + NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */
  359 + NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */
  360 + NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */
  361 + NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */
  362 + NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */
  363 + NV_ENC_PIC_TYPE_NONREF_P = 0x07, /**< Non reference P picture */
  364 + NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */
  365 +} NV_ENC_PIC_TYPE;
  366 +
  367 +/**
  368 + * Motion vector precisions
  369 + */
  370 +typedef enum _NV_ENC_MV_PRECISION
  371 +{
  372 + NV_ENC_MV_PRECISION_DEFAULT = 0x0, /**< Driver selects Quarter-Pel motion vector precision by default */
  373 + NV_ENC_MV_PRECISION_FULL_PEL = 0x01, /**< Full-Pel motion vector precision */
  374 + NV_ENC_MV_PRECISION_HALF_PEL = 0x02, /**< Half-Pel motion vector precision */
  375 + NV_ENC_MV_PRECISION_QUARTER_PEL = 0x03 /**< Quarter-Pel motion vector precision */
  376 +} NV_ENC_MV_PRECISION;
  377 +
  378 +
  379 +/**
  380 + * Input buffer formats
  381 + */
  382 +typedef enum _NV_ENC_BUFFER_FORMAT
  383 +{
  384 + NV_ENC_BUFFER_FORMAT_UNDEFINED = 0x00000000, /**< Undefined buffer format */
  385 +
  386 + NV_ENC_BUFFER_FORMAT_NV12 = 0x00000001, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
  387 + NV_ENC_BUFFER_FORMAT_YV12 = 0x00000010, /**< Planar YUV [Y plane followed by V and U planes] */
  388 + NV_ENC_BUFFER_FORMAT_IYUV = 0x00000100, /**< Planar YUV [Y plane followed by U and V planes] */
  389 + NV_ENC_BUFFER_FORMAT_YUV444 = 0x00001000, /**< Planar YUV [Y plane followed by U and V planes] */
  390 + 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. */
  391 + 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. */
  392 + NV_ENC_BUFFER_FORMAT_ARGB = 0x01000000, /**< 8 bit Packed A8R8G8B8. This is a word-ordered format
  393 + where a pixel is represented by a 32-bit word with B
  394 + in the lowest 8 bits, G in the next 8 bits, R in the
  395 + 8 bits after that and A in the highest 8 bits. */
  396 + NV_ENC_BUFFER_FORMAT_ARGB10 = 0x02000000, /**< 10 bit Packed A2R10G10B10. This is a word-ordered format
  397 + where a pixel is represented by a 32-bit word with B
  398 + in the lowest 10 bits, G in the next 10 bits, R in the
  399 + 10 bits after that and A in the highest 2 bits. */
  400 + NV_ENC_BUFFER_FORMAT_AYUV = 0x04000000, /**< 8 bit Packed A8Y8U8V8. This is a word-ordered format
  401 + where a pixel is represented by a 32-bit word with V
  402 + in the lowest 8 bits, U in the next 8 bits, Y in the
  403 + 8 bits after that and A in the highest 8 bits. */
  404 + NV_ENC_BUFFER_FORMAT_ABGR = 0x10000000, /**< 8 bit Packed A8B8G8R8. This is a word-ordered format
  405 + where a pixel is represented by a 32-bit word with R
  406 + in the lowest 8 bits, G in the next 8 bits, B in the
  407 + 8 bits after that and A in the highest 8 bits. */
  408 + NV_ENC_BUFFER_FORMAT_ABGR10 = 0x20000000, /**< 10 bit Packed A2B10G10R10. This is a word-ordered format
  409 + where a pixel is represented by a 32-bit word with R
  410 + in the lowest 10 bits, G in the next 10 bits, B in the
  411 + 10 bits after that and A in the highest 2 bits. */
  412 + NV_ENC_BUFFER_FORMAT_U8 = 0x40000000, /**< Buffer format representing one-dimensional buffer.
  413 + This format should be used only when registering the
  414 + resource as output buffer, which will be used to write
  415 + the encoded bit stream or H.264 ME only mode output. */
  416 +} NV_ENC_BUFFER_FORMAT;
  417 +
  418 +#define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
  419 +#define NV_ENC_BUFFER_FORMAT_YV12_PL NV_ENC_BUFFER_FORMAT_YV12
  420 +#define NV_ENC_BUFFER_FORMAT_IYUV_PL NV_ENC_BUFFER_FORMAT_IYUV
  421 +#define NV_ENC_BUFFER_FORMAT_YUV444_PL NV_ENC_BUFFER_FORMAT_YUV444
  422 +
  423 +/**
  424 + * Encoding levels
  425 + */
  426 +typedef enum _NV_ENC_LEVEL
  427 +{
  428 + NV_ENC_LEVEL_AUTOSELECT = 0,
  429 +
  430 + NV_ENC_LEVEL_H264_1 = 10,
  431 + NV_ENC_LEVEL_H264_1b = 9,
  432 + NV_ENC_LEVEL_H264_11 = 11,
  433 + NV_ENC_LEVEL_H264_12 = 12,
  434 + NV_ENC_LEVEL_H264_13 = 13,
  435 + NV_ENC_LEVEL_H264_2 = 20,
  436 + NV_ENC_LEVEL_H264_21 = 21,
  437 + NV_ENC_LEVEL_H264_22 = 22,
  438 + NV_ENC_LEVEL_H264_3 = 30,
  439 + NV_ENC_LEVEL_H264_31 = 31,
  440 + NV_ENC_LEVEL_H264_32 = 32,
  441 + NV_ENC_LEVEL_H264_4 = 40,
  442 + NV_ENC_LEVEL_H264_41 = 41,
  443 + NV_ENC_LEVEL_H264_42 = 42,
  444 + NV_ENC_LEVEL_H264_5 = 50,
  445 + NV_ENC_LEVEL_H264_51 = 51,
  446 + NV_ENC_LEVEL_H264_52 = 52,
  447 + NV_ENC_LEVEL_H264_60 = 60,
  448 + NV_ENC_LEVEL_H264_61 = 61,
  449 + NV_ENC_LEVEL_H264_62 = 62,
  450 +
  451 + NV_ENC_LEVEL_HEVC_1 = 30,
  452 + NV_ENC_LEVEL_HEVC_2 = 60,
  453 + NV_ENC_LEVEL_HEVC_21 = 63,
  454 + NV_ENC_LEVEL_HEVC_3 = 90,
  455 + NV_ENC_LEVEL_HEVC_31 = 93,
  456 + NV_ENC_LEVEL_HEVC_4 = 120,
  457 + NV_ENC_LEVEL_HEVC_41 = 123,
  458 + NV_ENC_LEVEL_HEVC_5 = 150,
  459 + NV_ENC_LEVEL_HEVC_51 = 153,
  460 + NV_ENC_LEVEL_HEVC_52 = 156,
  461 + NV_ENC_LEVEL_HEVC_6 = 180,
  462 + NV_ENC_LEVEL_HEVC_61 = 183,
  463 + NV_ENC_LEVEL_HEVC_62 = 186,
  464 +
  465 + NV_ENC_TIER_HEVC_MAIN = 0,
  466 + NV_ENC_TIER_HEVC_HIGH = 1
  467 +} NV_ENC_LEVEL;
  468 +
  469 +/**
  470 + * Error Codes
  471 + */
  472 +typedef enum _NVENCSTATUS
  473 +{
  474 + /**
  475 + * This indicates that API call returned with no errors.
  476 + */
  477 + NV_ENC_SUCCESS,
  478 +
  479 + /**
  480 + * This indicates that no encode capable devices were detected.
  481 + */
  482 + NV_ENC_ERR_NO_ENCODE_DEVICE,
  483 +
  484 + /**
  485 + * This indicates that devices pass by the client is not supported.
  486 + */
  487 + NV_ENC_ERR_UNSUPPORTED_DEVICE,
  488 +
  489 + /**
  490 + * This indicates that the encoder device supplied by the client is not
  491 + * valid.
  492 + */
  493 + NV_ENC_ERR_INVALID_ENCODERDEVICE,
  494 +
  495 + /**
  496 + * This indicates that device passed to the API call is invalid.
  497 + */
  498 + NV_ENC_ERR_INVALID_DEVICE,
  499 +
  500 + /**
  501 + * This indicates that device passed to the API call is no longer available and
  502 + * needs to be reinitialized. The clients need to destroy the current encoder
  503 + * session by freeing the allocated input output buffers and destroying the device
  504 + * and create a new encoding session.
  505 + */
  506 + NV_ENC_ERR_DEVICE_NOT_EXIST,
  507 +
  508 + /**
  509 + * This indicates that one or more of the pointers passed to the API call
  510 + * is invalid.
  511 + */
  512 + NV_ENC_ERR_INVALID_PTR,
  513 +
  514 + /**
  515 + * This indicates that completion event passed in ::NvEncEncodePicture() call
  516 + * is invalid.
  517 + */
  518 + NV_ENC_ERR_INVALID_EVENT,
  519 +
  520 + /**
  521 + * This indicates that one or more of the parameter passed to the API call
  522 + * is invalid.
  523 + */
  524 + NV_ENC_ERR_INVALID_PARAM,
  525 +
  526 + /**
  527 + * This indicates that an API call was made in wrong sequence/order.
  528 + */
  529 + NV_ENC_ERR_INVALID_CALL,
  530 +
  531 + /**
  532 + * This indicates that the API call failed because it was unable to allocate
  533 + * enough memory to perform the requested operation.
  534 + */
  535 + NV_ENC_ERR_OUT_OF_MEMORY,
  536 +
  537 + /**
  538 + * This indicates that the encoder has not been initialized with
  539 + * ::NvEncInitializeEncoder() or that initialization has failed.
  540 + * The client cannot allocate input or output buffers or do any encoding
  541 + * related operation before successfully initializing the encoder.
  542 + */
  543 + NV_ENC_ERR_ENCODER_NOT_INITIALIZED,
  544 +
  545 + /**
  546 + * This indicates that an unsupported parameter was passed by the client.
  547 + */
  548 + NV_ENC_ERR_UNSUPPORTED_PARAM,
  549 +
  550 + /**
  551 + * This indicates that the ::NvEncLockBitstream() failed to lock the output
  552 + * buffer. This happens when the client makes a non blocking lock call to
  553 + * access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
  554 + * This is not a fatal error and client should retry the same operation after
  555 + * few milliseconds.
  556 + */
  557 + NV_ENC_ERR_LOCK_BUSY,
  558 +
  559 + /**
  560 + * This indicates that the size of the user buffer passed by the client is
  561 + * insufficient for the requested operation.
  562 + */
  563 + NV_ENC_ERR_NOT_ENOUGH_BUFFER,
  564 +
  565 + /**
  566 + * This indicates that an invalid struct version was used by the client.
  567 + */
  568 + NV_ENC_ERR_INVALID_VERSION,
  569 +
  570 + /**
  571 + * This indicates that ::NvEncMapInputResource() API failed to map the client
  572 + * provided input resource.
  573 + */
  574 + NV_ENC_ERR_MAP_FAILED,
  575 +
  576 + /**
  577 + * This indicates encode driver requires more input buffers to produce an output
  578 + * bitstream. If this error is returned from ::NvEncEncodePicture() API, this
  579 + * is not a fatal error. If the client is encoding with B frames then,
  580 + * ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
  581 + *
  582 + * A client operating in synchronous mode cannot call ::NvEncLockBitstream()
  583 + * API on the output bitstream buffer if ::NvEncEncodePicture() returned the
  584 + * ::NV_ENC_ERR_NEED_MORE_INPUT error code.
  585 + * The client must continue providing input frames until encode driver returns
  586 + * ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
  587 + * ::NvEncLockBitstream() API on the output buffers in the same order in which
  588 + * it has called ::NvEncEncodePicture().
  589 + */
  590 + NV_ENC_ERR_NEED_MORE_INPUT,
  591 +
  592 + /**
  593 + * This indicates that the HW encoder is busy encoding and is unable to encode
  594 + * the input. The client should call ::NvEncEncodePicture() again after few
  595 + * milliseconds.
  596 + */
  597 + NV_ENC_ERR_ENCODER_BUSY,
  598 +
  599 + /**
  600 + * This indicates that the completion event passed in ::NvEncEncodePicture()
  601 + * API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().
  602 + */
  603 + NV_ENC_ERR_EVENT_NOT_REGISTERD,
  604 +
  605 + /**
  606 + * This indicates that an unknown internal error has occurred.
  607 + */
  608 + NV_ENC_ERR_GENERIC,
  609 +
  610 + /**
  611 + * This indicates that the client is attempting to use a feature
  612 + * that is not available for the license type for the current system.
  613 + */
  614 + NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY,
  615 +
  616 + /**
  617 + * This indicates that the client is attempting to use a feature
  618 + * that is not implemented for the current version.
  619 + */
  620 + NV_ENC_ERR_UNIMPLEMENTED,
  621 +
  622 + /**
  623 + * This indicates that the ::NvEncRegisterResource API failed to register the resource.
  624 + */
  625 + NV_ENC_ERR_RESOURCE_REGISTER_FAILED,
  626 +
  627 + /**
  628 + * This indicates that the client is attempting to unregister a resource
  629 + * that has not been successfully registered.
  630 + */
  631 + NV_ENC_ERR_RESOURCE_NOT_REGISTERED,
  632 +
  633 + /**
  634 + * This indicates that the client is attempting to unmap a resource
  635 + * that has not been successfully mapped.
  636 + */
  637 + NV_ENC_ERR_RESOURCE_NOT_MAPPED,
  638 +
  639 +} NVENCSTATUS;
  640 +
  641 +/**
  642 + * Encode Picture encode flags.
  643 + */
  644 +typedef enum _NV_ENC_PIC_FLAGS
  645 +{
  646 + NV_ENC_PIC_FLAG_FORCEINTRA = 0x1, /**< Encode the current picture as an Intra picture */
  647 + NV_ENC_PIC_FLAG_FORCEIDR = 0x2, /**< Encode the current picture as an IDR picture.
  648 + This flag is only valid when Picture type decision is taken by the Encoder
  649 + [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  650 + NV_ENC_PIC_FLAG_OUTPUT_SPSPPS = 0x4, /**< Write the sequence and picture header in encoded bitstream of the current picture */
  651 + NV_ENC_PIC_FLAG_EOS = 0x8, /**< Indicates end of the input stream */
  652 +} NV_ENC_PIC_FLAGS;
  653 +
  654 +/**
  655 + * Memory heap to allocate input and output buffers.
  656 + */
  657 +typedef enum _NV_ENC_MEMORY_HEAP
  658 +{
  659 + NV_ENC_MEMORY_HEAP_AUTOSELECT = 0, /**< Memory heap to be decided by the encoder driver based on the usage */
  660 + NV_ENC_MEMORY_HEAP_VID = 1, /**< Memory heap is in local video memory */
  661 + NV_ENC_MEMORY_HEAP_SYSMEM_CACHED = 2, /**< Memory heap is in cached system memory */
  662 + NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED = 3 /**< Memory heap is in uncached system memory */
  663 +} NV_ENC_MEMORY_HEAP;
  664 +
  665 +/**
  666 + * B-frame used as reference modes
  667 + */
  668 +typedef enum _NV_ENC_BFRAME_REF_MODE
  669 +{
  670 + NV_ENC_BFRAME_REF_MODE_DISABLED = 0x0, /**< B frame is not used for reference */
  671 + NV_ENC_BFRAME_REF_MODE_EACH = 0x1, /**< Each B-frame will be used for reference. currently not supported for H.264 */
  672 + NV_ENC_BFRAME_REF_MODE_MIDDLE = 0x2, /**< Only(Number of B-frame)/2 th B-frame will be used for reference */
  673 +} NV_ENC_BFRAME_REF_MODE;
  674 +
  675 +/**
  676 + * H.264 entropy coding modes.
  677 + */
  678 +typedef enum _NV_ENC_H264_ENTROPY_CODING_MODE
  679 +{
  680 + NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT = 0x0, /**< Entropy coding mode is auto selected by the encoder driver */
  681 + NV_ENC_H264_ENTROPY_CODING_MODE_CABAC = 0x1, /**< Entropy coding mode is CABAC */
  682 + NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC = 0x2 /**< Entropy coding mode is CAVLC */
  683 +} NV_ENC_H264_ENTROPY_CODING_MODE;
  684 +
  685 +/**
  686 + * H.264 specific BDirect modes
  687 + */
  688 +typedef enum _NV_ENC_H264_BDIRECT_MODE
  689 +{
  690 + NV_ENC_H264_BDIRECT_MODE_AUTOSELECT = 0x0, /**< BDirect mode is auto selected by the encoder driver */
  691 + NV_ENC_H264_BDIRECT_MODE_DISABLE = 0x1, /**< Disable BDirect mode */
  692 + NV_ENC_H264_BDIRECT_MODE_TEMPORAL = 0x2, /**< Temporal BDirect mode */
  693 + NV_ENC_H264_BDIRECT_MODE_SPATIAL = 0x3 /**< Spatial BDirect mode */
  694 +} NV_ENC_H264_BDIRECT_MODE;
  695 +
  696 +/**
  697 + * H.264 specific FMO usage
  698 + */
  699 +typedef enum _NV_ENC_H264_FMO_MODE
  700 +{
  701 + NV_ENC_H264_FMO_AUTOSELECT = 0x0, /**< FMO usage is auto selected by the encoder driver */
  702 + NV_ENC_H264_FMO_ENABLE = 0x1, /**< Enable FMO */
  703 + NV_ENC_H264_FMO_DISABLE = 0x2, /**< Disable FMO */
  704 +} NV_ENC_H264_FMO_MODE;
  705 +
  706 +/**
  707 + * H.264 specific Adaptive Transform modes
  708 + */
  709 +typedef enum _NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
  710 +{
  711 + NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT = 0x0, /**< Adaptive Transform 8x8 mode is auto selected by the encoder driver*/
  712 + NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE = 0x1, /**< Adaptive Transform 8x8 mode disabled */
  713 + NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE = 0x2, /**< Adaptive Transform 8x8 mode should be used */
  714 +} NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE;
  715 +
  716 +/**
  717 + * Stereo frame packing modes.
  718 + */
  719 +typedef enum _NV_ENC_STEREO_PACKING_MODE
  720 +{
  721 + NV_ENC_STEREO_PACKING_MODE_NONE = 0x0, /**< No Stereo packing required */
  722 + NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD = 0x1, /**< Checkerboard mode for packing stereo frames */
  723 + NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE = 0x2, /**< Column Interleave mode for packing stereo frames */
  724 + NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE = 0x3, /**< Row Interleave mode for packing stereo frames */
  725 + NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE = 0x4, /**< Side-by-side mode for packing stereo frames */
  726 + NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM = 0x5, /**< Top-Bottom mode for packing stereo frames */
  727 + NV_ENC_STEREO_PACKING_MODE_FRAMESEQ = 0x6 /**< Frame Sequential mode for packing stereo frames */
  728 +} NV_ENC_STEREO_PACKING_MODE;
  729 +
  730 +/**
  731 + * Input Resource type
  732 + */
  733 +typedef enum _NV_ENC_INPUT_RESOURCE_TYPE
  734 +{
  735 + NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX = 0x0, /**< input resource type is a directx9 surface*/
  736 + NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR = 0x1, /**< input resource type is a cuda device pointer surface*/
  737 + NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY = 0x2, /**< input resource type is a cuda array surface.
  738 + This array must be a 2D array and the CUDA_ARRAY3D_SURFACE_LDST
  739 + flag must have been specified when creating it. */
  740 + NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX = 0x3 /**< input resource type is an OpenGL texture */
  741 +} NV_ENC_INPUT_RESOURCE_TYPE;
  742 +
  743 +/**
  744 + * Buffer usage
  745 + */
  746 +typedef enum _NV_ENC_BUFFER_USAGE
  747 +{
  748 + NV_ENC_INPUT_IMAGE = 0x0, /**< Registered surface will be used for input image */
  749 + NV_ENC_OUTPUT_MOTION_VECTOR = 0x1, /**< Registered surface will be used for output of H.264 ME only mode.
  750 + This buffer usage type is not supported for HEVC ME only mode. */
  751 + NV_ENC_OUTPUT_BITSTREAM = 0x2 /**< Registered surface will be used for output bitstream in encoding */
  752 +} NV_ENC_BUFFER_USAGE;
  753 +
  754 +/**
  755 + * Encoder Device type
  756 + */
  757 +typedef enum _NV_ENC_DEVICE_TYPE
  758 +{
  759 + NV_ENC_DEVICE_TYPE_DIRECTX = 0x0, /**< encode device type is a directx9 device */
  760 + NV_ENC_DEVICE_TYPE_CUDA = 0x1, /**< encode device type is a cuda device */
  761 + NV_ENC_DEVICE_TYPE_OPENGL = 0x2 /**< encode device type is an OpenGL device.
  762 + Use of this device type is supported only on Linux */
  763 +} NV_ENC_DEVICE_TYPE;
  764 +
  765 +/**
  766 + * Number of reference frames
  767 + */
  768 +typedef enum _NV_ENC_NUM_REF_FRAMES
  769 +{
  770 + NV_ENC_NUM_REF_FRAMES_AUTOSELECT = 0x0, /**< Number of reference frames is auto selected by the encoder driver */
  771 + NV_ENC_NUM_REF_FRAMES_1 = 0x1, /**< Number of reference frames equal to 1 */
  772 + NV_ENC_NUM_REF_FRAMES_2 = 0x2, /**< Number of reference frames equal to 2 */
  773 + NV_ENC_NUM_REF_FRAMES_3 = 0x3, /**< Number of reference frames equal to 3 */
  774 + NV_ENC_NUM_REF_FRAMES_4 = 0x4, /**< Number of reference frames equal to 4 */
  775 + NV_ENC_NUM_REF_FRAMES_5 = 0x5, /**< Number of reference frames equal to 5 */
  776 + NV_ENC_NUM_REF_FRAMES_6 = 0x6, /**< Number of reference frames equal to 6 */
  777 + NV_ENC_NUM_REF_FRAMES_7 = 0x7 /**< Number of reference frames equal to 7 */
  778 +} NV_ENC_NUM_REF_FRAMES;
  779 +
  780 +/**
  781 + * Encoder capabilities enumeration.
  782 + */
  783 +typedef enum _NV_ENC_CAPS
  784 +{
  785 + /**
  786 + * Maximum number of B-Frames supported.
  787 + */
  788 + NV_ENC_CAPS_NUM_MAX_BFRAMES,
  789 +
  790 + /**
  791 + * Rate control modes supported.
  792 + * \n The API return value is a bitmask of the values in NV_ENC_PARAMS_RC_MODE.
  793 + */
  794 + NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES,
  795 +
  796 + /**
  797 + * Indicates HW support for field mode encoding.
  798 + * \n 0 : Interlaced mode encoding is not supported.
  799 + * \n 1 : Interlaced field mode encoding is supported.
  800 + * \n 2 : Interlaced frame encoding and field mode encoding are both supported.
  801 + */
  802 + NV_ENC_CAPS_SUPPORT_FIELD_ENCODING,
  803 +
  804 + /**
  805 + * Indicates HW support for monochrome mode encoding.
  806 + * \n 0 : Monochrome mode not supported.
  807 + * \n 1 : Monochrome mode supported.
  808 + */
  809 + NV_ENC_CAPS_SUPPORT_MONOCHROME,
  810 +
  811 + /**
  812 + * Indicates HW support for FMO.
  813 + * \n 0 : FMO not supported.
  814 + * \n 1 : FMO supported.
  815 + */
  816 + NV_ENC_CAPS_SUPPORT_FMO,
  817 +
  818 + /**
  819 + * Indicates HW capability for Quarter pel motion estimation.
  820 + * \n 0 : Quarter-Pel Motion Estimation not supported.
  821 + * \n 1 : Quarter-Pel Motion Estimation supported.
  822 + */
  823 + NV_ENC_CAPS_SUPPORT_QPELMV,
  824 +
  825 + /**
  826 + * H.264 specific. Indicates HW support for BDirect modes.
  827 + * \n 0 : BDirect mode encoding not supported.
  828 + * \n 1 : BDirect mode encoding supported.
  829 + */
  830 + NV_ENC_CAPS_SUPPORT_BDIRECT_MODE,
  831 +
  832 + /**
  833 + * H264 specific. Indicates HW support for CABAC entropy coding mode.
  834 + * \n 0 : CABAC entropy coding not supported.
  835 + * \n 1 : CABAC entropy coding supported.
  836 + */
  837 + NV_ENC_CAPS_SUPPORT_CABAC,
  838 +
  839 + /**
  840 + * Indicates HW support for Adaptive Transform.
  841 + * \n 0 : Adaptive Transform not supported.
  842 + * \n 1 : Adaptive Transform supported.
  843 + */
  844 + NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM,
  845 +
  846 + /**
  847 + * Indicates HW support for Multi View Coding.
  848 + * \n 0 : Multi View Coding not supported.
  849 + * \n 1 : Multi View Coding supported.
  850 + */
  851 + NV_ENC_CAPS_SUPPORT_STEREO_MVC,
  852 +
  853 + /**
  854 + * Indicates HW support for encoding Temporal layers.
  855 + * \n 0 : Encoding Temporal layers not supported.
  856 + * \n 1 : Encoding Temporal layers supported.
  857 + */
  858 + NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS,
  859 +
  860 + /**
  861 + * Indicates HW support for Hierarchical P frames.
  862 + * \n 0 : Hierarchical P frames not supported.
  863 + * \n 1 : Hierarchical P frames supported.
  864 + */
  865 + NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES,
  866 +
  867 + /**
  868 + * Indicates HW support for Hierarchical B frames.
  869 + * \n 0 : Hierarchical B frames not supported.
  870 + * \n 1 : Hierarchical B frames supported.
  871 + */
  872 + NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES,
  873 +
  874 + /**
  875 + * Maximum Encoding level supported (See ::NV_ENC_LEVEL for details).
  876 + */
  877 + NV_ENC_CAPS_LEVEL_MAX,
  878 +
  879 + /**
  880 + * Minimum Encoding level supported (See ::NV_ENC_LEVEL for details).
  881 + */
  882 + NV_ENC_CAPS_LEVEL_MIN,
  883 +
  884 + /**
  885 + * Indicates HW support for separate colour plane encoding.
  886 + * \n 0 : Separate colour plane encoding not supported.
  887 + * \n 1 : Separate colour plane encoding supported.
  888 + */
  889 + NV_ENC_CAPS_SEPARATE_COLOUR_PLANE,
  890 +
  891 + /**
  892 + * Maximum output width supported.
  893 + */
  894 + NV_ENC_CAPS_WIDTH_MAX,
  895 +
  896 + /**
  897 + * Maximum output height supported.
  898 + */
  899 + NV_ENC_CAPS_HEIGHT_MAX,
  900 +
  901 + /**
  902 + * Indicates Temporal Scalability Support.
  903 + * \n 0 : Temporal SVC encoding not supported.
  904 + * \n 1 : Temporal SVC encoding supported.
  905 + */
  906 + NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC,
  907 +
  908 + /**
  909 + * Indicates Dynamic Encode Resolution Change Support.
  910 + * Support added from NvEncodeAPI version 2.0.
  911 + * \n 0 : Dynamic Encode Resolution Change not supported.
  912 + * \n 1 : Dynamic Encode Resolution Change supported.
  913 + */
  914 + NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE,
  915 +
  916 + /**
  917 + * Indicates Dynamic Encode Bitrate Change Support.
  918 + * Support added from NvEncodeAPI version 2.0.
  919 + * \n 0 : Dynamic Encode bitrate change not supported.
  920 + * \n 1 : Dynamic Encode bitrate change supported.
  921 + */
  922 + NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE,
  923 +
  924 + /**
  925 + * Indicates Forcing Constant QP On The Fly Support.
  926 + * Support added from NvEncodeAPI version 2.0.
  927 + * \n 0 : Forcing constant QP on the fly not supported.
  928 + * \n 1 : Forcing constant QP on the fly supported.
  929 + */
  930 + NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP,
  931 +
  932 + /**
  933 + * Indicates Dynamic rate control mode Change Support.
  934 + * \n 0 : Dynamic rate control mode change not supported.
  935 + * \n 1 : Dynamic rate control mode change supported.
  936 + */
  937 + NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE,
  938 +
  939 + /**
  940 + * Indicates Subframe readback support for slice-based encoding. If this feature is supported, it can be enabled by setting enableSubFrameWrite = 1.
  941 + * \n 0 : Subframe readback not supported.
  942 + * \n 1 : Subframe readback supported.
  943 + */
  944 + NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK,
  945 +
  946 + /**
  947 + * Indicates Constrained Encoding mode support.
  948 + * Support added from NvEncodeAPI version 2.0.
  949 + * \n 0 : Constrained encoding mode not supported.
  950 + * \n 1 : Constrained encoding mode supported.
  951 + * If this mode is supported client can enable this during initialization.
  952 + * Client can then force a picture to be coded as constrained picture where
  953 + * in-loop filtering is disabled across slice boundaries and prediction vectors for inter
  954 + * macroblocks in each slice will be restricted to the slice region.
  955 + */
  956 + NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING,
  957 +
  958 + /**
  959 + * Indicates Intra Refresh Mode Support.
  960 + * Support added from NvEncodeAPI version 2.0.
  961 + * \n 0 : Intra Refresh Mode not supported.
  962 + * \n 1 : Intra Refresh Mode supported.
  963 + */
  964 + NV_ENC_CAPS_SUPPORT_INTRA_REFRESH,
  965 +
  966 + /**
  967 + * Indicates Custom VBV Buffer Size support. It can be used for capping frame size.
  968 + * Support added from NvEncodeAPI version 2.0.
  969 + * \n 0 : Custom VBV buffer size specification from client, not supported.
  970 + * \n 1 : Custom VBV buffer size specification from client, supported.
  971 + */
  972 + NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE,
  973 +
  974 + /**
  975 + * Indicates Dynamic Slice Mode Support.
  976 + * Support added from NvEncodeAPI version 2.0.
  977 + * \n 0 : Dynamic Slice Mode not supported.
  978 + * \n 1 : Dynamic Slice Mode supported.
  979 + */
  980 + NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE,
  981 +
  982 + /**
  983 + * Indicates Reference Picture Invalidation Support.
  984 + * Support added from NvEncodeAPI version 2.0.
  985 + * \n 0 : Reference Picture Invalidation not supported.
  986 + * \n 1 : Reference Picture Invalidation supported.
  987 + */
  988 + NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION,
  989 +
  990 + /**
  991 + * Indicates support for Pre-Processing.
  992 + * The API return value is a bitmask of the values defined in ::NV_ENC_PREPROC_FLAGS
  993 + */
  994 + NV_ENC_CAPS_PREPROC_SUPPORT,
  995 +
  996 + /**
  997 + * Indicates support Async mode.
  998 + * \n 0 : Async Encode mode not supported.
  999 + * \n 1 : Async Encode mode supported.
  1000 + */
  1001 + NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT,
  1002 +
  1003 + /**
  1004 + * Maximum MBs per frame supported.
  1005 + */
  1006 + NV_ENC_CAPS_MB_NUM_MAX,
  1007 +
  1008 + /**
  1009 + * Maximum aggregate throughput in MBs per sec.
  1010 + */
  1011 + NV_ENC_CAPS_MB_PER_SEC_MAX,
  1012 +
  1013 + /**
  1014 + * Indicates HW support for YUV444 mode encoding.
  1015 + * \n 0 : YUV444 mode encoding not supported.
  1016 + * \n 1 : YUV444 mode encoding supported.
  1017 + */
  1018 + NV_ENC_CAPS_SUPPORT_YUV444_ENCODE,
  1019 +
  1020 + /**
  1021 + * Indicates HW support for lossless encoding.
  1022 + * \n 0 : lossless encoding not supported.
  1023 + * \n 1 : lossless encoding supported.
  1024 + */
  1025 + NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE,
  1026 +
  1027 + /**
  1028 + * Indicates HW support for Sample Adaptive Offset.
  1029 + * \n 0 : SAO not supported.
  1030 + * \n 1 : SAO encoding supported.
  1031 + */
  1032 + NV_ENC_CAPS_SUPPORT_SAO,
  1033 +
  1034 + /**
  1035 + * Indicates HW support for Motion Estimation Only Mode.
  1036 + * \n 0 : MEOnly Mode not supported.
  1037 + * \n 1 : MEOnly Mode supported for I and P frames.
  1038 + * \n 2 : MEOnly Mode supported for I, P and B frames.
  1039 + */
  1040 + NV_ENC_CAPS_SUPPORT_MEONLY_MODE,
  1041 +
  1042 + /**
  1043 + * Indicates HW support for lookahead encoding (enableLookahead=1).
  1044 + * \n 0 : Lookahead not supported.
  1045 + * \n 1 : Lookahead supported.
  1046 + */
  1047 + NV_ENC_CAPS_SUPPORT_LOOKAHEAD,
  1048 +
  1049 + /**
  1050 + * Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
  1051 + * \n 0 : Temporal AQ not supported.
  1052 + * \n 1 : Temporal AQ supported.
  1053 + */
  1054 + NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ,
  1055 + /**
  1056 + * Indicates HW support for 10 bit encoding.
  1057 + * \n 0 : 10 bit encoding not supported.
  1058 + * \n 1 : 10 bit encoding supported.
  1059 + */
  1060 + NV_ENC_CAPS_SUPPORT_10BIT_ENCODE,
  1061 + /**
  1062 + * Maximum number of Long Term Reference frames supported
  1063 + */
  1064 + NV_ENC_CAPS_NUM_MAX_LTR_FRAMES,
  1065 +
  1066 + /**
  1067 + * Indicates HW support for Weighted Prediction.
  1068 + * \n 0 : Weighted Prediction not supported.
  1069 + * \n 1 : Weighted Prediction supported.
  1070 + */
  1071 + NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION,
  1072 +
  1073 +
  1074 + /**
  1075 + * On managed (vGPU) platforms (Windows only), this API, in conjunction with other GRID Management APIs, can be used
  1076 + * to estimate the residual capacity of the hardware encoder on the GPU as a percentage of the total available encoder capacity.
  1077 + * This API can be called at any time; i.e. during the encode session or before opening the encode session.
  1078 + * If the available encoder capacity is returned as zero, applications may choose to switch to software encoding
  1079 + * and continue to call this API (e.g. polling once per second) until capacity becomes available.
  1080 + *
  1081 + * On bare metal (non-virtualized GPU) and linux platforms, this API always returns 100.
  1082 + */
  1083 + NV_ENC_CAPS_DYNAMIC_QUERY_ENCODER_CAPACITY,
  1084 +
  1085 + /**
  1086 + * Indicates B as reference support.
  1087 + * \n 0 : B as reference is not supported.
  1088 + * \n 1 : each B-Frame as reference is supported.
  1089 + * \n 2 : only Middle B-frame as reference is supported.
  1090 + */
  1091 + NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE,
  1092 +
  1093 + /**
  1094 + * Indicates HW support for Emphasis Level Map based delta QP computation.
  1095 + * \n 0 : Emphasis Level Map based delta QP not supported.
  1096 + * \n 1 : Emphasis Level Map based delta QP is supported.
  1097 + */
  1098 + NV_ENC_CAPS_SUPPORT_EMPHASIS_LEVEL_MAP,
  1099 +
  1100 + /**
  1101 + * Minimum input width supported.
  1102 + */
  1103 + NV_ENC_CAPS_WIDTH_MIN,
  1104 +
  1105 + /**
  1106 + * Minimum input height supported.
  1107 + */
  1108 + NV_ENC_CAPS_HEIGHT_MIN,
  1109 +
  1110 + /**
  1111 + * Indicates HW support for multiple reference frames.
  1112 + */
  1113 + NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES,
  1114 +
  1115 + /**
  1116 + * Indicates HW support for HEVC with alpha encoding.
  1117 + * \n 0 : HEVC with alpha encoding not supported.
  1118 + * \n 1 : HEVC with alpha encoding is supported.
  1119 + */
  1120 + NV_ENC_CAPS_SUPPORT_ALPHA_LAYER_ENCODING,
  1121 +
  1122 + /**
  1123 + * Indicates number of Encoding engines present on GPU.
  1124 + */
  1125 + NV_ENC_CAPS_NUM_ENCODER_ENGINES,
  1126 +
  1127 + /**
  1128 + * Indicates single slice intra refresh support.
  1129 + */
  1130 + NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH,
  1131 +
  1132 + /**
  1133 + * Reserved - Not to be used by clients.
  1134 + */
  1135 + NV_ENC_CAPS_EXPOSED_COUNT
  1136 +} NV_ENC_CAPS;
  1137 +
  1138 +/**
  1139 + * HEVC CU SIZE
  1140 + */
  1141 +typedef enum _NV_ENC_HEVC_CUSIZE
  1142 +{
  1143 + NV_ENC_HEVC_CUSIZE_AUTOSELECT = 0,
  1144 + NV_ENC_HEVC_CUSIZE_8x8 = 1,
  1145 + NV_ENC_HEVC_CUSIZE_16x16 = 2,
  1146 + NV_ENC_HEVC_CUSIZE_32x32 = 3,
  1147 + NV_ENC_HEVC_CUSIZE_64x64 = 4,
  1148 +}NV_ENC_HEVC_CUSIZE;
  1149 +
  1150 +/**
  1151 + * Input struct for querying Encoding capabilities.
  1152 + */
  1153 +typedef struct _NV_ENC_CAPS_PARAM
  1154 +{
  1155 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CAPS_PARAM_VER */
  1156 + NV_ENC_CAPS capsToQuery; /**< [in]: Specifies the encode capability to be queried. Client should pass a member for ::NV_ENC_CAPS enum. */
  1157 + uint32_t reserved[62]; /**< [in]: Reserved and must be set to 0 */
  1158 +} NV_ENC_CAPS_PARAM;
  1159 +
  1160 +/** NV_ENC_CAPS_PARAM struct version. */
  1161 +#define NV_ENC_CAPS_PARAM_VER NVENCAPI_STRUCT_VERSION(1)
  1162 +
  1163 +
  1164 +/**
  1165 + * Encoder Output parameters
  1166 + */
  1167 +typedef struct _NV_ENC_ENCODE_OUT_PARAMS
  1168 +{
  1169 + uint32_t version; /**< [out]: Struct version. */
  1170 + uint32_t bitstreamSizeInBytes; /**< [out]: Encoded bitstream size in bytes */
  1171 + uint32_t reserved[62]; /**< [out]: Reserved and must be set to 0 */
  1172 +} NV_ENC_ENCODE_OUT_PARAMS;
  1173 +
  1174 +/** NV_ENC_ENCODE_OUT_PARAMS struct version. */
  1175 +#define NV_ENC_ENCODE_OUT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1176 +
  1177 +/**
  1178 + * Creation parameters for input buffer.
  1179 + */
  1180 +typedef struct _NV_ENC_CREATE_INPUT_BUFFER
  1181 +{
  1182 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER */
  1183 + uint32_t width; /**< [in]: Input frame width */
  1184 + uint32_t height; /**< [in]: Input frame height */
  1185 + NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
  1186 + NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Input buffer format */
  1187 + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1188 + NV_ENC_INPUT_PTR inputBuffer; /**< [out]: Pointer to input buffer */
  1189 + void* pSysMemBuffer; /**< [in]: Pointer to existing system memory buffer */
  1190 + uint32_t reserved1[57]; /**< [in]: Reserved and must be set to 0 */
  1191 + void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  1192 +} NV_ENC_CREATE_INPUT_BUFFER;
  1193 +
  1194 +/** NV_ENC_CREATE_INPUT_BUFFER struct version. */
  1195 +#define NV_ENC_CREATE_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1196 +
  1197 +/**
  1198 + * Creation parameters for output bitstream buffer.
  1199 + */
  1200 +typedef struct _NV_ENC_CREATE_BITSTREAM_BUFFER
  1201 +{
  1202 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER */
  1203 + uint32_t size; /**< [in]: Deprecated. Do not use */
  1204 + NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
  1205 + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1206 + NV_ENC_OUTPUT_PTR bitstreamBuffer; /**< [out]: Pointer to the output bitstream buffer */
  1207 + void* bitstreamBufferPtr; /**< [out]: Reserved and should not be used */
  1208 + uint32_t reserved1[58]; /**< [in]: Reserved and should be set to 0 */
  1209 + void* reserved2[64]; /**< [in]: Reserved and should be set to NULL */
  1210 +} NV_ENC_CREATE_BITSTREAM_BUFFER;
  1211 +
  1212 +/** NV_ENC_CREATE_BITSTREAM_BUFFER struct version. */
  1213 +#define NV_ENC_CREATE_BITSTREAM_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1214 +
  1215 +/**
  1216 + * Structs needed for ME only mode.
  1217 + */
  1218 +typedef struct _NV_ENC_MVECTOR
  1219 +{
  1220 + int16_t mvx; /**< the x component of MV in quarter-pel units */
  1221 + int16_t mvy; /**< the y component of MV in quarter-pel units */
  1222 +} NV_ENC_MVECTOR;
  1223 +
  1224 +/**
  1225 + * Motion vector structure per macroblock for H264 motion estimation.
  1226 + */
  1227 +typedef struct _NV_ENC_H264_MV_DATA
  1228 +{
  1229 + NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors for 8x8 partition */
  1230 + uint8_t mbType; /**< 0 (I), 1 (P), 2 (IPCM), 3 (B) */
  1231 + uint8_t partitionType; /**< Specifies the block partition type. 0:16x16, 1:8x8, 2:16x8, 3:8x16 */
  1232 + uint16_t reserved; /**< reserved padding for alignment */
  1233 + uint32_t mbCost;
  1234 +} NV_ENC_H264_MV_DATA;
  1235 +
  1236 +/**
  1237 + * Motion vector structure per CU for HEVC motion estimation.
  1238 + */
  1239 +typedef struct _NV_ENC_HEVC_MV_DATA
  1240 +{
  1241 + NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors within a CU */
  1242 + uint8_t cuType; /**< 0 (I), 1(P) */
  1243 + uint8_t cuSize; /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
  1244 + uint8_t partitionMode; /**< The CU partition mode
  1245 + 0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
  1246 + 4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N) */
  1247 + uint8_t lastCUInCTB; /**< Marker to separate CUs in the current CTB from CUs in the next CTB */
  1248 +} NV_ENC_HEVC_MV_DATA;
  1249 +
  1250 +/**
  1251 + * Creation parameters for output motion vector buffer for ME only mode.
  1252 + */
  1253 +typedef struct _NV_ENC_CREATE_MV_BUFFER
  1254 +{
  1255 + uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_CREATE_MV_BUFFER_VER */
  1256 + NV_ENC_OUTPUT_PTR mvBuffer; /**< [out]: Pointer to the output motion vector buffer */
  1257 + uint32_t reserved1[255]; /**< [in]: Reserved and should be set to 0 */
  1258 + void* reserved2[63]; /**< [in]: Reserved and should be set to NULL */
  1259 +} NV_ENC_CREATE_MV_BUFFER;
  1260 +
  1261 +/** NV_ENC_CREATE_MV_BUFFER struct version*/
  1262 +#define NV_ENC_CREATE_MV_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1263 +
  1264 +/**
  1265 + * QP value for frames
  1266 + */
  1267 +typedef struct _NV_ENC_QP
  1268 +{
  1269 + uint32_t qpInterP; /**< [in]: Specifies QP value for P-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1270 + uint32_t qpInterB; /**< [in]: Specifies QP value for B-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1271 + uint32_t qpIntra; /**< [in]: Specifies QP value for Intra Frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1272 +} NV_ENC_QP;
  1273 +
  1274 +/**
  1275 + * Rate Control Configuration Parameters
  1276 + */
  1277 + typedef struct _NV_ENC_RC_PARAMS
  1278 + {
  1279 + uint32_t version;
  1280 + 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. */
  1281 + 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. */
  1282 + uint32_t averageBitRate; /**< [in]: Specifies the average bitrate(in bits/sec) used for encoding. */
  1283 + uint32_t maxBitRate; /**< [in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode. */
  1284 + uint32_t vbvBufferSize; /**< [in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size. */
  1285 + uint32_t vbvInitialDelay; /**< [in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay .*/
  1286 + uint32_t enableMinQP :1; /**< [in]: Set this to 1 if minimum QP used for rate control. */
  1287 + uint32_t enableMaxQP :1; /**< [in]: Set this to 1 if maximum QP used for rate control. */
  1288 + uint32_t enableInitialRCQP :1; /**< [in]: Set this to 1 if user supplied initial QP is used for rate control. */
  1289 + uint32_t enableAQ :1; /**< [in]: Set this to 1 to enable adaptive quantization (Spatial). */
  1290 + uint32_t reservedBitField1 :1; /**< [in]: Reserved bitfields and must be set to 0. */
  1291 + 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) */
  1292 + 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) */
  1293 + uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */
  1294 + uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ */
  1295 + uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */
  1296 + uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */
  1297 + uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */
  1298 + 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).
  1299 + If not set, strength is auto selected by driver. */
  1300 + uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */
  1301 + NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */
  1302 + NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */
  1303 + NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */
  1304 + 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].
  1305 + Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
  1306 + uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as the array index.
  1307 + Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
  1308 + uint8_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */
  1309 + uint8_t targetQualityLSB; /**< [in]: Fractional part of target quality (as 8.8 fixed point format) */
  1310 + uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-(31 - number of B frames).
  1311 + lookaheadDepth is only used if enableLookahead=1.*/
  1312 + uint8_t lowDelayKeyFrameScale; /**< [in]: Specifies the ratio of I frame bits to P frame bits in case of single frame VBV and CBR rate control mode,
  1313 + is set to 2 by default for low latency tuning info and 1 by default for ultra low latency tuning info */
  1314 + uint8_t reserved1[3];
  1315 + NV_ENC_QP_MAP_MODE qpMapMode; /**< [in]: This flag is used to interpret values in array specified by NV_ENC_PIC_PARAMS::qpDeltaMap.
  1316 + Set this to NV_ENC_QP_MAP_EMPHASIS to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as Emphasis Level Map.
  1317 + Emphasis Level can be assigned any value specified in enum NV_ENC_EMPHASIS_MAP_LEVEL.
  1318 + Emphasis Level Map is used to specify regions to be encoded at varying levels of quality.
  1319 + The hardware encoder adjusts the quantization within the image as per the provided emphasis map,
  1320 + by adjusting the quantization parameter (QP) assigned to each macroblock. This adjustment is commonly called “Delta QP”.
  1321 + 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.
  1322 + Since the Delta QP overrides rate control, enabling Emphasis Level Map may violate bitrate and VBV buffer size constraints.
  1323 + Emphasis Level Map is useful in situations where 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 buffer size constraints
  1324 + This feature is not supported when AQ( Spatial/Temporal) is enabled.
  1325 + This feature is only supported for H264 codec currently.
  1326 +
  1327 + Set this to NV_ENC_QP_MAP_DELTA to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as QP Delta. This specifies QP modifier to be applied on top of the QP chosen by rate control
  1328 +
  1329 + 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.
  1330 +
  1331 + Other values are reserved for future use.*/
  1332 + NV_ENC_MULTI_PASS multiPass; /**< [in]: This flag is used to enable multi-pass encoding for a given ::NV_ENC_PARAMS_RC_MODE. This flag is not valid for H264 and HEVC MEOnly mode */
  1333 + uint32_t alphaLayerBitrateRatio; /**< [in]: Specifies the ratio in which bitrate should be split between base and alpha layer. A value 'x' for this field will split the target bitrate in a ratio of x : 1 between base and alpha layer.
  1334 + The default split ratio is 15.*/
  1335 + int8_t cbQPIndexOffset; /**< [in]: Specifies the value of 'chroma_qp_index_offset' in H264 / 'pps_cb_qp_offset' in HEVC.*/
  1336 + int8_t crQPIndexOffset; /**< [in]: Specifies the value of 'second_chroma_qp_index_offset' in H264 / 'pps_cr_qp_offset' in HEVC.*/
  1337 + uint16_t reserved2;
  1338 + uint32_t reserved[4];
  1339 + } NV_ENC_RC_PARAMS;
  1340 +
  1341 +/** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */
  1342 +#define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1343 +
  1344 +
  1345 +
  1346 +/**
  1347 + * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  1348 + * H264 Video Usability Info parameters
  1349 + */
  1350 +typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  1351 +{
  1352 + uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */
  1353 + uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */
  1354 + uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
  1355 + uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
  1356 + uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
  1357 + uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
  1358 + uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
  1359 + uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
  1360 + 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). */
  1361 + uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
  1362 + uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
  1363 + uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
  1364 + uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
  1365 + uint32_t reserved[15];
  1366 +}NV_ENC_CONFIG_H264_VUI_PARAMETERS;
  1367 +
  1368 +typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS;
  1369 +
  1370 +/**
  1371 + * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1372 + * External motion vector hint counts per block type.
  1373 + * H264 supports multiple hint while HEVC supports one hint for each valid candidate.
  1374 + */
  1375 +typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1376 +{
  1377 + uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Supported for H264, HEVC. It Specifies the number of candidates per 16x16 block. */
  1378 + uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 16x8 block. */
  1379 + uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 8x16 block. */
  1380 + uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Supported for H264, HEVC. Specifies the number of candidates per 8x8 block. */
  1381 + uint32_t reserved : 16; /**< [in]: Reserved for padding. */
  1382 + uint32_t reserved1[3]; /**< [in]: Reserved for future use. */
  1383 +} NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE;
  1384 +
  1385 +
  1386 +/**
  1387 + * \struct _NVENC_EXTERNAL_ME_HINT
  1388 + * External Motion Vector hint structure for H264 and HEVC.
  1389 + */
  1390 +typedef struct _NVENC_EXTERNAL_ME_HINT
  1391 +{
  1392 + int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */
  1393 + int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/
  1394 + 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. */
  1395 + int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
  1396 + int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/
  1397 + int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */
  1398 + int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */
  1399 +} NVENC_EXTERNAL_ME_HINT;
  1400 +
  1401 +
  1402 +/**
  1403 + * \struct _NV_ENC_CONFIG_H264
  1404 + * H264 encoder configuration parameters
  1405 + */
  1406 +typedef struct _NV_ENC_CONFIG_H264
  1407 +{
  1408 + uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/
  1409 + uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/
  1410 + uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical P Frames */
  1411 + uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical B Frames */
  1412 + uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */
  1413 + 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,
  1414 + NV_ENC_PARAMS_RC_CBR_HQ, filler data is inserted if needed to achieve HRD bitrate */
  1415 + uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */
  1416 + uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */
  1417 + uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */
  1418 + uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
  1419 + 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 */
  1420 + uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
  1421 + Constrained encoding works only with rectangular slices.
  1422 + Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
  1423 + uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */
  1424 + uint32_t enableVFR :1; /**< [in]: Setting enableVFR=1 currently only sets the fixed_frame_rate_flag=0 in the VUI but otherwise
  1425 + has no impact on the encoder behavior. For more details please refer to E.1 VUI syntax of H.264 standard. Note, however, that NVENC does not support VFR encoding and rate control. */
  1426 + 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.
  1427 + LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
  1428 + Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future.
  1429 + LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
  1430 + ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
  1431 + for using LTR.
  1432 + Note that LTRs are not supported if encoding session is configured with B-frames */
  1433 + 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.
  1434 + Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */
  1435 + uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1436 + uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
  1437 + This flag will take effect only when one of the CBR rate
  1438 + control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
  1439 + NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
  1440 + NV_ENC_INITIALIZE_PARAMS::frameRateNum and
  1441 + NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
  1442 + values. Setting this field when
  1443 + NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
  1444 + is currently not supported and will make ::NvEncInitializeEncoder()
  1445 + return an error. */
  1446 + uint32_t disableSVCPrefixNalu :1; /**< [in]: Set to 1 to disable writing of SVC Prefix NALU preceding each slice in bitstream.
  1447 + Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
  1448 + uint32_t enableScalabilityInfoSEI :1; /**< [in]: Set to 1 to enable writing of Scalability Information SEI message preceding each IDR picture in bitstream
  1449 + Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
  1450 + uint32_t singleSliceIntraRefresh : 1; /**< [in]: Set to 1 to maintain single slice in frames during intra refresh.
  1451 + Check support for single slice intra refresh using ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps.
  1452 + This flag will be ignored if the value returned for ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps is false. */
  1453 + uint32_t reservedBitFields : 11; /**< [in]: Reserved bitfields and must be set to 0 */
  1454 + 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. */
  1455 + 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. */
  1456 + uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */
  1457 + uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2]. This flag corresponds
  1458 + to the flag disable_deblocking_filter_idc specified in section 7.4.3 of H.264 specification,
  1459 + which specifies whether the operation of the deblocking filter shall be disabled across some
  1460 + block edges of the slice and specifies for which edges the filtering is disabled. See section
  1461 + 7.4.3 of H.264 specification for more details.*/
  1462 + uint32_t numTemporalLayers; /**< [in]: Specifies number of temporal layers to be used for hierarchical coding / temporal SVC. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */
  1463 + uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
  1464 + uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
  1465 + 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. */
  1466 + NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */
  1467 + NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/
  1468 + 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. */
  1469 + NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signaled in frame packing arrangement SEI */
  1470 + uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1471 + Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1472 + 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 */
  1473 + uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default DPB size.
  1474 + The low latency application which wants to invalidate reference frame as an error resilience tool
  1475 + is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
  1476 + frames are invalidated. */
  1477 + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1478 + sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3 numSlices in Picture.
  1479 + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1480 + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1481 + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1482 + sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1483 + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1484 + sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1485 + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1486 + NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info parameters */
  1487 + uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames. This parameter has different meaning in two LTR modes.
  1488 + In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
  1489 + In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
  1490 + uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_H264::enableLTR for description of the two modes.
  1491 + Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
  1492 + be deprecated in future releases.
  1493 + Set to 0 when using "LTR Per Picture" mode of LTR operation. */
  1494 + uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
  1495 + Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/
  1496 + uint32_t maxTemporalLayers; /**< [in]: Specifies the maximum temporal layer used for temporal SVC / hierarchical coding.
  1497 + Defaut value of this field is NV_ENC_CAPS::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS. Note that the value NV_ENC_CONFIG_H264::maxNumRefFrames should
  1498 + be greater than or equal to (NV_ENC_CONFIG_H264::maxTemporalLayers - 2) * 2, for NV_ENC_CONFIG_H264::maxTemporalLayers >= 2.*/
  1499 + 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.*/
  1500 + NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
  1501 + Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1502 + NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
  1503 + Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1504 + uint32_t reserved1[267]; /**< [in]: Reserved and must be set to 0 */
  1505 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1506 +} NV_ENC_CONFIG_H264;
  1507 +
  1508 +/**
  1509 + * \struct _NV_ENC_CONFIG_HEVC
  1510 + * HEVC encoder configuration parameters to be set during initialization.
  1511 + */
  1512 +typedef struct _NV_ENC_CONFIG_HEVC
  1513 +{
  1514 + uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
  1515 + uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
  1516 + NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/
  1517 + 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.*/
  1518 + uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1519 + uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/
  1520 + uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */
  1521 + uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */
  1522 + uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */
  1523 + 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.
  1524 + LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
  1525 + Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future releases.
  1526 + LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
  1527 + ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
  1528 + for using LTR.
  1529 + Note that LTRs are not supported if encoding session is configured with B-frames */
  1530 + uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS, SPS and PPS signaling in the bitstream. */
  1531 + uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/
  1532 + 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 */
  1533 + uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/
  1534 + 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.*/
  1535 + uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
  1536 + This flag will take effect only when one of the CBR rate
  1537 + control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
  1538 + NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
  1539 + NV_ENC_INITIALIZE_PARAMS::frameRateNum and
  1540 + NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
  1541 + values. Setting this field when
  1542 + NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
  1543 + is currently not supported and will make ::NvEncInitializeEncoder()
  1544 + return an error. */
  1545 + uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
  1546 + Constrained encoding works only with rectangular slices.
  1547 + Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
  1548 + uint32_t enableAlphaLayerEncoding :1; /**< [in]: Set this to 1 to enable HEVC encode with alpha layer. */
  1549 + uint32_t singleSliceIntraRefresh : 1; /**< [in]: Set this to 1 to maintain single slice frames during intra refresh.
  1550 + Check support for single slice intra refresh using ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps.
  1551 + This flag will be ignored if the value returned for ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps is false. */
  1552 + uint32_t reserved : 14; /**< [in]: Reserved bitfields.*/
  1553 + 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. */
  1554 + uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1555 + Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1556 + 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 */
  1557 + uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
  1558 + uint32_t ltrNumFrames; /**< [in]: This parameter has different meaning in two LTR modes.
  1559 + In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
  1560 + In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
  1561 + uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set */
  1562 + uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
  1563 + uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
  1564 + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1565 + sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1566 + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1567 + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1568 + sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1569 + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1570 + sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1571 + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1572 + uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
  1573 + NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info parameters */
  1574 + uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_HEVC::enableLTR for description of the two modes.
  1575 + Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
  1576 + be deprecated in future releases.
  1577 + Set to 0 when using "LTR Per Picture" mode of LTR operation. */
  1578 + 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.*/
  1579 + NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
  1580 + Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1581 + NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
  1582 + Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1583 + uint32_t reserved1[214]; /**< [in]: Reserved and must be set to 0.*/
  1584 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1585 +} NV_ENC_CONFIG_HEVC;
  1586 +
  1587 +/**
  1588 + * \struct _NV_ENC_CONFIG_H264_MEONLY
  1589 + * H264 encoder configuration parameters for ME only Mode
  1590 + *
  1591 + */
  1592 +typedef struct _NV_ENC_CONFIG_H264_MEONLY
  1593 +{
  1594 + uint32_t disablePartition16x16 :1; /**< [in]: Disable Motion Estimation on 16x16 blocks*/
  1595 + uint32_t disablePartition8x16 :1; /**< [in]: Disable Motion Estimation on 8x16 blocks*/
  1596 + uint32_t disablePartition16x8 :1; /**< [in]: Disable Motion Estimation on 16x8 blocks*/
  1597 + uint32_t disablePartition8x8 :1; /**< [in]: Disable Motion Estimation on 8x8 blocks*/
  1598 + uint32_t disableIntraSearch :1; /**< [in]: Disable Intra search during Motion Estimation*/
  1599 + uint32_t bStereoEnable :1; /**< [in]: Enable Stereo Mode for Motion Estimation where each view is independently executed*/
  1600 + uint32_t reserved :26; /**< [in]: Reserved and must be set to 0 */
  1601 + uint32_t reserved1 [255]; /**< [in]: Reserved and must be set to 0 */
  1602 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1603 +} NV_ENC_CONFIG_H264_MEONLY;
  1604 +
  1605 +
  1606 +/**
  1607 + * \struct _NV_ENC_CONFIG_HEVC_MEONLY
  1608 + * HEVC encoder configuration parameters for ME only Mode
  1609 + *
  1610 + */
  1611 +typedef struct _NV_ENC_CONFIG_HEVC_MEONLY
  1612 +{
  1613 + uint32_t reserved [256]; /**< [in]: Reserved and must be set to 0 */
  1614 + void* reserved1[64]; /**< [in]: Reserved and must be set to NULL */
  1615 +} NV_ENC_CONFIG_HEVC_MEONLY;
  1616 +
  1617 +/**
  1618 + * \struct _NV_ENC_CODEC_CONFIG
  1619 + * Codec-specific encoder configuration parameters to be set during initialization.
  1620 + */
  1621 +typedef union _NV_ENC_CODEC_CONFIG
  1622 +{
  1623 + NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */
  1624 + NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */
  1625 + NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig; /**< [in]: Specifies the H.264-specific ME only encoder configuration. */
  1626 + NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig; /**< [in]: Specifies the HEVC-specific ME only encoder configuration. */
  1627 + uint32_t reserved[320]; /**< [in]: Reserved and must be set to 0 */
  1628 +} NV_ENC_CODEC_CONFIG;
  1629 +
  1630 +
  1631 +/**
  1632 + * \struct _NV_ENC_CONFIG
  1633 + * Encoder configuration parameters to be set during initialization.
  1634 + */
  1635 +typedef struct _NV_ENC_CONFIG
  1636 +{
  1637 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */
  1638 + 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. */
  1639 + 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. */
  1640 + 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. */
  1641 + uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */
  1642 + NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode.
  1643 + Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
  1644 + Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */
  1645 + NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */
  1646 + NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */
  1647 + NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */
  1648 + uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */
  1649 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1650 +} NV_ENC_CONFIG;
  1651 +
  1652 +/** macro for constructing the version field of ::_NV_ENC_CONFIG */
  1653 +#define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(7) | ( 1u<<31 ))
  1654 +
  1655 +/**
  1656 + * Tuning information of NVENC encoding (TuningInfo is not applicable to H264 and HEVC MEOnly mode).
  1657 + */
  1658 +typedef enum NV_ENC_TUNING_INFO
  1659 +{
  1660 + NV_ENC_TUNING_INFO_UNDEFINED = 0, /**< Undefined tuningInfo. Invalid value for encoding. */
  1661 + NV_ENC_TUNING_INFO_HIGH_QUALITY = 1, /**< Tune presets for latency tolerant encoding.*/
  1662 + NV_ENC_TUNING_INFO_LOW_LATENCY = 2, /**< Tune presets for low latency streaming.*/
  1663 + NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY = 3, /**< Tune presets for ultra low latency streaming.*/
  1664 + NV_ENC_TUNING_INFO_LOSSLESS = 4, /**< Tune presets for lossless encoding.*/
  1665 + NV_ENC_TUNING_INFO_COUNT /**< Count number of tuningInfos. Invalid value. */
  1666 +}NV_ENC_TUNING_INFO;
  1667 +
  1668 +/**
  1669 + * \struct _NV_ENC_INITIALIZE_PARAMS
  1670 + * Encode Session Initialization parameters.
  1671 + */
  1672 +typedef struct _NV_ENC_INITIALIZE_PARAMS
  1673 +{
  1674 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  1675 + 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. */
  1676 + 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. */
  1677 + uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */
  1678 + uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */
  1679 + uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */
  1680 + uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */
  1681 + uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1682 + uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1683 + uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */
  1684 + uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */
  1685 + 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 */
  1686 + uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals.
  1687 + If enableSubFrameWrite = 1, then the hardware encoder returns data as soon as a slice has completed encoding.
  1688 + This results in better encoding latency, but the downside is that the application has to keep polling via a call to nvEncLockBitstream API continuously to see if any encoded slice data is available.
  1689 + Use this mode if you feel that the marginal reduction in latency from sub-frame encoding is worth the increase in complexity due to CPU-based polling. */
  1690 + 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.
  1691 + NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
  1692 + uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/
  1693 + uint32_t enableWeightedPrediction :1; /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames (i.e. NV_ENC_CONFIG::frameIntervalP > 1 or preset >=P3 when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or
  1694 + tuningInfo = ::NV_ENC_TUNING_INFO_LOSSLESS. This is because preset >=p3 internally enables B frames when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or ::NV_ENC_TUNING_INFO_LOSSLESS). */
  1695 + uint32_t enableOutputInVidmem :1; /**< [in]: Set this to 1 to enable output of NVENC in video memory buffer created by application. This feature is not supported for HEVC ME only mode. */
  1696 + uint32_t reservedBitFields :26; /**< [in]: Reserved bitfields and must be set to 0 */
  1697 + uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */
  1698 + void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */
  1699 + 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.
  1700 + 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.
  1701 + 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. */
  1702 + uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session.
  1703 + Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */
  1704 + uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session.
  1705 + Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */
  1706 + 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.
  1707 + The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
  1708 + This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */
  1709 + NV_ENC_TUNING_INFO tuningInfo; /**< [in]: Tuning Info of NVENC encoding(TuningInfo is not applicable to H264 and HEVC meonly mode). */
  1710 + NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Specifies input buffer format. Client should set input buffer format only when D3D12 interface type is used. */
  1711 + uint32_t reserved[287]; /**< [in]: Reserved and must be set to 0 */
  1712 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1713 +} NV_ENC_INITIALIZE_PARAMS;
  1714 +
  1715 +/** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */
  1716 +#define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1u<<31 ))
  1717 +
  1718 +
  1719 +/**
  1720 + * \struct _NV_ENC_RECONFIGURE_PARAMS
  1721 + * Encode Session Reconfigured parameters.
  1722 + */
  1723 +typedef struct _NV_ENC_RECONFIGURE_PARAMS
  1724 +{
  1725 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */
  1726 + NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters.
  1727 + If reInitEncodeParams.encodeConfig is NULL and
  1728 + reInitEncodeParams.presetGUID is the same as the preset
  1729 + GUID specified on the call to NvEncInitializeEncoder(),
  1730 + EncodeAPI will continue to use the existing encode
  1731 + configuration.
  1732 + If reInitEncodeParams.encodeConfig is NULL and
  1733 + reInitEncodeParams.presetGUID is different from the preset
  1734 + GUID specified on the call to NvEncInitializeEncoder(),
  1735 + EncodeAPI will try to use the default configuration for
  1736 + the preset specified by reInitEncodeParams.presetGUID.
  1737 + In this case, reconfiguration may fail if the new
  1738 + configuration is incompatible with the existing
  1739 + configuration (e.g. the new configuration results in
  1740 + a change in the GOP structure). */
  1741 + 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.
  1742 + If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */
  1743 + 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
  1744 + [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  1745 + uint32_t reserved :30;
  1746 +
  1747 +}NV_ENC_RECONFIGURE_PARAMS;
  1748 +
  1749 +/** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */
  1750 +#define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1u<<31 ))
  1751 +
  1752 +/**
  1753 + * \struct _NV_ENC_PRESET_CONFIG
  1754 + * Encoder preset config
  1755 + */
  1756 +typedef struct _NV_ENC_PRESET_CONFIG
  1757 +{
  1758 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */
  1759 + NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */
  1760 + uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */
  1761 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1762 +}NV_ENC_PRESET_CONFIG;
  1763 +
  1764 +/** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */
  1765 +#define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1u<<31 ))
  1766 +
  1767 +
  1768 +/**
  1769 + * \struct _NV_ENC_PIC_PARAMS_MVC
  1770 + * MVC-specific parameters to be sent on a per-frame basis.
  1771 + */
  1772 +typedef struct _NV_ENC_PIC_PARAMS_MVC
  1773 +{
  1774 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_MVC_VER. */
  1775 + uint32_t viewID; /**< [in]: Specifies the view ID associated with the current input view. */
  1776 + uint32_t temporalID; /**< [in]: Specifies the temporal ID associated with the current input view. */
  1777 + uint32_t priorityID; /**< [in]: Specifies the priority ID associated with the current input view. Reserved and ignored by the NvEncodeAPI interface. */
  1778 + uint32_t reserved1[12]; /**< [in]: Reserved and must be set to 0. */
  1779 + void* reserved2[8]; /**< [in]: Reserved and must be set to NULL. */
  1780 +}NV_ENC_PIC_PARAMS_MVC;
  1781 +
  1782 +/** macro for constructing the version field of ::_NV_ENC_PIC_PARAMS_MVC */
  1783 +#define NV_ENC_PIC_PARAMS_MVC_VER NVENCAPI_STRUCT_VERSION(1)
  1784 +
  1785 +
  1786 +/**
  1787 + * \union _NV_ENC_PIC_PARAMS_H264_EXT
  1788 + * H264 extension picture parameters
  1789 + */
  1790 +typedef union _NV_ENC_PIC_PARAMS_H264_EXT
  1791 +{
  1792 + NV_ENC_PIC_PARAMS_MVC mvcPicParams; /**< [in]: Specifies the MVC picture parameters. */
  1793 + uint32_t reserved1[32]; /**< [in]: Reserved and must be set to 0. */
  1794 +}NV_ENC_PIC_PARAMS_H264_EXT;
  1795 +
  1796 +/**
  1797 + * \struct _NV_ENC_SEI_PAYLOAD
  1798 + * User SEI message
  1799 + */
  1800 +typedef struct _NV_ENC_SEI_PAYLOAD
  1801 +{
  1802 + uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */
  1803 + uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */
  1804 + uint8_t *payload; /**< [in] pointer to user data */
  1805 +} NV_ENC_SEI_PAYLOAD;
  1806 +
  1807 +#define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
  1808 +
  1809 +/**
  1810 + * \struct _NV_ENC_PIC_PARAMS_H264
  1811 + * H264 specific enc pic params. sent on a per frame basis.
  1812 + */
  1813 +typedef struct _NV_ENC_PIC_PARAMS_H264
  1814 +{
  1815 + uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1816 + uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */
  1817 + uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1818 + uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */
  1819 + uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1820 + When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1821 + forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1822 + 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.
  1823 + NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1824 + uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1825 + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1826 + uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1827 + uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1828 + uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1829 + uint8_t* sliceTypeData; /**< [in]: Deprecated. */
  1830 + uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */
  1831 + uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1832 + NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1833 + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1834 + sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
  1835 + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1836 + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1837 + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1838 + sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1839 + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1840 + sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1841 + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1842 + uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
  1843 + uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
  1844 + uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
  1845 + uint32_t forceIntraSliceCount; /**< [in]: Specifies the number of slices to be forced to Intra in the current picture.
  1846 + This option along with forceIntraSliceIdx[] array needs to be used with sliceMode = 3 only */
  1847 + uint32_t *forceIntraSliceIdx; /**< [in]: Slice indices to be forced to intra in the current picture. Each slice index should be <= num_slices_in_picture -1. Index starts from 0 for first slice.
  1848 + The number of entries in this array should be equal to forceIntraSliceCount */
  1849 + NV_ENC_PIC_PARAMS_H264_EXT h264ExtPicParams; /**< [in]: Specifies the H264 extension config parameters using this config. */
  1850 + uint32_t reserved [210]; /**< [in]: Reserved and must be set to 0. */
  1851 + void* reserved2[61]; /**< [in]: Reserved and must be set to NULL. */
  1852 +} NV_ENC_PIC_PARAMS_H264;
  1853 +
  1854 +/**
  1855 + * \struct _NV_ENC_PIC_PARAMS_HEVC
  1856 + * HEVC specific enc pic params. sent on a per frame basis.
  1857 + */
  1858 +typedef struct _NV_ENC_PIC_PARAMS_HEVC
  1859 +{
  1860 + uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1861 + uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1862 + uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
  1863 + uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1864 + When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1865 + forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1866 + 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.
  1867 + NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1868 + uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1869 + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1870 + uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1871 + uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1872 + uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1873 + 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.
  1874 + Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
  1875 + 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
  1876 + all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */
  1877 + 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 */
  1878 + uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1879 + sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1880 + When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1881 + When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1882 + uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1883 + sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1884 + sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1885 + sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1886 + sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1887 + uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/
  1888 + uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
  1889 + uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
  1890 + uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1891 + uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
  1892 + NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1893 + uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */
  1894 + void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
  1895 +} NV_ENC_PIC_PARAMS_HEVC;
  1896 +
  1897 +/**
  1898 + * Codec specific per-picture encoding parameters.
  1899 + */
  1900 +typedef union _NV_ENC_CODEC_PIC_PARAMS
  1901 +{
  1902 + NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */
  1903 + NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. */
  1904 + uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */
  1905 +} NV_ENC_CODEC_PIC_PARAMS;
  1906 +
  1907 +/**
  1908 + * \struct _NV_ENC_PIC_PARAMS
  1909 + * Encoding parameters that need to be sent on a per frame basis.
  1910 + */
  1911 +typedef struct _NV_ENC_PIC_PARAMS
  1912 +{
  1913 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */
  1914 + uint32_t inputWidth; /**< [in]: Specifies the input frame width */
  1915 + uint32_t inputHeight; /**< [in]: Specifies the input frame height */
  1916 + uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */
  1917 + uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR of encode picture flags. See ::NV_ENC_PIC_FLAGS enum. */
  1918 + uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */
  1919 + uint64_t inputTimeStamp; /**< [in]: Specifies opaque data which is associated with the encoded frame, but not actually encoded in the output bitstream.
  1920 + This opaque data can be used later to uniquely refer to the corresponding encoded frame. For example, it can be used
  1921 + for identifying the frame to be invalidated in the reference picture buffer, if lost at the client. */
  1922 + uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */
  1923 + NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
  1924 + NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the output buffer pointer.
  1925 + If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API.
  1926 + If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for NV_ENC_ENCODE_OUT_PARAMS struct and encoded bitstream data. Client
  1927 + should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this output buffer and assign it to NV_ENC_PIC_PARAMS::outputBitstream.
  1928 + First 256 bytes of this buffer should be interpreted as NV_ENC_ENCODE_OUT_PARAMS struct followed by encoded bitstream data. Recommended size for output buffer is sum of size of
  1929 + NV_ENC_ENCODE_OUT_PARAMS struct and twice the input frame size for lower resolution eg. CIF and 1.5 times the input frame size for higher resolutions. If encoded bitstream size is
  1930 + greater than the allocated buffer size for encoded bitstream, then the output buffer will have encoded bitstream data equal to buffer size. All CUDA operations on this buffer must use
  1931 + the default stream. */
  1932 + void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
  1933 + NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1934 + NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */
  1935 + 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. */
  1936 + NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */
  1937 + NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: For H264 and Hevc, 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.
  1938 + The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
  1939 + NVENC_EXTERNAL_ME_HINT* meExternalHints; /**< [in]: For H264 and Hevc, 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.
  1940 + The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
  1941 + + 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) */
  1942 + uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */
  1943 + void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */
  1944 + int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing value per MB for H264 and per CTB for HEVC in raster scan order for the current picture, which will be interpreted depending on NV_ENC_RC_PARAMS::qpMapMode.
  1945 + If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DELTA, qpDeltaMap specifies QP modifier per MB for H264 and per CTB for HEVC. This QP modifier will be applied on top of the QP chosen by rate control.
  1946 + If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_EMPHASIS, qpDeltaMap specifies Emphasis Level Map per MB for H264. This level value along with QP chosen by rate control is used to
  1947 + compute the QP modifier, which in turn is applied on top of QP chosen by rate control.
  1948 + If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DISABLED, value in qpDeltaMap will be ignored.*/
  1949 + 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 for H264 and picWidthInCtbs * picHeightInCtbs for HEVC */
  1950 + uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */
  1951 + 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.
  1952 + If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */
  1953 + NV_ENC_INPUT_PTR alphaBuffer; /**< [in]: Specifies the input alpha buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.
  1954 + Applicable only when encoding hevc with alpha layer is enabled. */
  1955 + uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */
  1956 + void* reserved4[59]; /**< [in]: Reserved and must be set to NULL */
  1957 +} NV_ENC_PIC_PARAMS;
  1958 +
  1959 +/** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */
  1960 +#define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1u<<31 ))
  1961 +
  1962 +
  1963 +/**
  1964 + * \struct _NV_ENC_MEONLY_PARAMS
  1965 + * MEOnly parameters that need to be sent on a per motion estimation basis.
  1966 + * NV_ENC_MEONLY_PARAMS::meExternalHints is supported for H264 only.
  1967 + */
  1968 +typedef struct _NV_ENC_MEONLY_PARAMS
  1969 +{
  1970 + uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/
  1971 + uint32_t inputWidth; /**< [in]: Specifies the input frame width */
  1972 + uint32_t inputHeight; /**< [in]: Specifies the input frame height */
  1973 + NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
  1974 + NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */
  1975 + NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the output buffer pointer.
  1976 + If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer.
  1977 + Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  1978 + If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for storing the motion vector data. The size of this buffer must
  1979 + be equal to total number of macroblocks multiplied by size of NV_ENC_H264_MV_DATA struct. Client should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this
  1980 + output buffer and assign it to NV_ENC_MEONLY_PARAMS::mvBuffer. All CUDA operations on this buffer must use the default stream. */
  1981 + NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1982 + void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of motion estimation
  1983 + of this Frame [only if operating in Asynchronous mode].
  1984 + Each output buffer should be associated with a distinct event pointer. */
  1985 + uint32_t viewID; /**< [in]: Specifies left or right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set.
  1986 + viewID can be 0,1 if bStereoEnable is set, 0 otherwise. */
  1987 + NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1988 + meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block for the current frame. meHintCountsPerBlock[0] is for L0 predictors.
  1989 + The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
  1990 + 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.
  1991 + The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
  1992 + + 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) */
  1993 + uint32_t reserved1[243]; /**< [in]: Reserved and must be set to 0 */
  1994 + void* reserved2[59]; /**< [in]: Reserved and must be set to NULL */
  1995 +} NV_ENC_MEONLY_PARAMS;
  1996 +
  1997 +/** NV_ENC_MEONLY_PARAMS struct version*/
  1998 +#define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(3)
  1999 +
  2000 +
  2001 +/**
  2002 + * \struct _NV_ENC_LOCK_BITSTREAM
  2003 + * Bitstream buffer lock parameters.
  2004 + */
  2005 +typedef struct _NV_ENC_LOCK_BITSTREAM
  2006 +{
  2007 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
  2008 + 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. */
  2009 + uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
  2010 + uint32_t getRCStats :1; /**< [in]: If this flag is set then lockBitstream call will add additional intra-inter MB count and average MVX, MVY */
  2011 + uint32_t reservedBitFields :29; /**< [in]: Reserved bit fields and must be set to 0 */
  2012 + void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */
  2013 + 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. */
  2014 + uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */
  2015 + uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */
  2016 + uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */
  2017 + uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr.
  2018 + When HEVC alpha layer encoding is enabled, this field reports the total encoded size in bytes i.e it is the encoded size of the base plus the alpha layer. */
  2019 + uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */
  2020 + uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */
  2021 + void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream.
  2022 + For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to
  2023 + NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */
  2024 + NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */
  2025 + NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */
  2026 + uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
  2027 + uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */
  2028 + uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
  2029 + 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. */
  2030 + uint32_t temporalId; /**< [out]: TemporalId value of the frame when using temporalSVC encoding */
  2031 + uint32_t reserved[12]; /**< [in]: Reserved and must be set to 0 */
  2032 + uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  2033 + uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  2034 + int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  2035 + int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  2036 + uint32_t alphaLayerSizeInBytes; /**< [out]: Number of bytes generated for the alpha layer in the encoded output. Applicable only when HEVC with alpha encoding is enabled. */
  2037 +
  2038 + uint32_t reserved1[218]; /**< [in]: Reserved and must be set to 0 */
  2039 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2040 +} NV_ENC_LOCK_BITSTREAM;
  2041 +
  2042 +/** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */
  2043 +#define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1)
  2044 +
  2045 +
  2046 +/**
  2047 + * \struct _NV_ENC_LOCK_INPUT_BUFFER
  2048 + * Uncompressed Input Buffer lock parameters.
  2049 + */
  2050 +typedef struct _NV_ENC_LOCK_INPUT_BUFFER
  2051 +{
  2052 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */
  2053 + 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. */
  2054 + uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */
  2055 + 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. */
  2056 + void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */
  2057 + uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */
  2058 + uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */
  2059 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2060 +} NV_ENC_LOCK_INPUT_BUFFER;
  2061 +
  2062 +/** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */
  2063 +#define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  2064 +
  2065 +
  2066 +/**
  2067 + * \struct _NV_ENC_MAP_INPUT_RESOURCE
  2068 + * Map an input resource to a Nvidia Encoder Input Buffer
  2069 + */
  2070 +typedef struct _NV_ENC_MAP_INPUT_RESOURCE
  2071 +{
  2072 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */
  2073 + uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */
  2074 + void* inputResource; /**< [in]: Deprecated. Do not use. */
  2075 + NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */
  2076 + 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. */
  2077 + 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. */
  2078 + uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */
  2079 + void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  2080 +} NV_ENC_MAP_INPUT_RESOURCE;
  2081 +
  2082 +/** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */
  2083 +#define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
  2084 +
  2085 +/**
  2086 + * \struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
  2087 + * NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type,
  2088 + * when NV_ENC_REGISTER_RESOURCE::resourceType is NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX
  2089 + */
  2090 +typedef struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
  2091 +{
  2092 + uint32_t texture; /**< [in]: The name of the texture to be used. */
  2093 + uint32_t target; /**< [in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D. */
  2094 +} NV_ENC_INPUT_RESOURCE_OPENGL_TEX;
  2095 +
  2096 +/** \struct NV_ENC_FENCE_POINT_D3D12
  2097 + * Fence and fence value for synchronization.
  2098 + */
  2099 +typedef struct _NV_ENC_FENCE_POINT_D3D12
  2100 +{
  2101 + void* pFence; /**< [in]: Pointer to ID3D12Fence. This fence object is used for synchronization. */
  2102 + uint64_t value; /**< [in]: Fence value to reach or exceed before the GPU operation or
  2103 + fence value to set the fence to, after the GPU operation. */
  2104 +} NV_ENC_FENCE_POINT_D3D12;
  2105 +
  2106 +/**
  2107 + * \struct _NV_ENC_INPUT_RESOURCE_D3D12
  2108 + * NV_ENC_PIC_PARAMS::inputBuffer and NV_ENC_PIC_PARAMS::alphaBuffer must be a pointer to a struct of this type,
  2109 + * when D3D12 interface is used
  2110 + */
  2111 +typedef struct _NV_ENC_INPUT_RESOURCE_D3D12
  2112 +{
  2113 + NV_ENC_REGISTERED_PTR pInputBuffer; /**< [in]: Specifies the input surface pointer. Client must use a pointer obtained from NvEncRegisterResource() in NV_ENC_REGISTER_RESOURCE::registeredResource
  2114 + when registering input surface. */
  2115 + NV_ENC_FENCE_POINT_D3D12 inputFencePoint; /**< [in]: Specifies the input fence and corresponding fence value to do GPU wait.
  2116 + This fence will be used to do GPU wait until the specified fence reaches or exceeds the specified value. */
  2117 + uint32_t reserved1[16]; /**< [in]: Reserved and must be set to 0. */
  2118 + void* reserved2[16]; /**< [in]: Reserved and must be set to NULL. */
  2119 +} NV_ENC_INPUT_RESOURCE_D3D12;
  2120 +
  2121 +/**
  2122 + * \struct _NV_ENC_OUTPUT_RESOURCE_D3D12
  2123 + * NV_ENC_PIC_PARAMS::outputBitstream and NV_ENC_LOCK_BITSTREAM::outputBitstream must be a pointer to a struct of this type,
  2124 + * when D3D12 interface is used
  2125 + */
  2126 +typedef struct _NV_ENC_OUTPUT_RESOURCE_D3D12
  2127 +{
  2128 + NV_ENC_REGISTERED_PTR pOutputBuffer; /**< [in]: Specifies the output buffer pointer. Client must use a pointer obtained from NvEncRegisterResource() in NV_ENC_REGISTER_RESOURCE::registeredResource
  2129 + when registering output bitstream buffer */
  2130 + NV_ENC_FENCE_POINT_D3D12 outputFencePoint; /**< [in]: Specifies the output fence and corresponding fence value to set after GPU operation is finished.*/
  2131 + uint32_t reserved1[16]; /**< [in]: Reserved and must be set to 0. */
  2132 + void* reserved2[16]; /**< [in]: Reserved and must be set to NULL. */
  2133 +} NV_ENC_OUTPUT_RESOURCE_D3D12;
  2134 +
  2135 +/**
  2136 + * \struct _NV_ENC_REGISTER_RESOURCE
  2137 + * Register a resource for future use with the Nvidia Video Encoder Interface.
  2138 + */
  2139 +typedef struct _NV_ENC_REGISTER_RESOURCE
  2140 +{
  2141 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */
  2142 + NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered.
  2143 + Supported values are
  2144 + ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX,
  2145 + ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR,
  2146 + ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */
  2147 + uint32_t width; /**< [in]: Input frame width. */
  2148 + uint32_t height; /**< [in]: Input frame height. */
  2149 + uint32_t pitch; /**< [in]: Input buffer pitch.
  2150 + For ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX resources, set this to 0.
  2151 + For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR resources, set this to
  2152 + the pitch as obtained from cuMemAllocPitch(), or to the width in
  2153 + bytes (if this resource was created by using cuMemAlloc()). This
  2154 + value must be a multiple of 4.
  2155 + For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY resources, set this to the
  2156 + width of the allocation in bytes (i.e.
  2157 + CUDA_ARRAY3D_DESCRIPTOR::Width * CUDA_ARRAY3D_DESCRIPTOR::NumChannels).
  2158 + For ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX resources, set this to the
  2159 + texture width multiplied by the number of components in the texture
  2160 + format. */
  2161 + uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
  2162 + void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */
  2163 + NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
  2164 + NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */
  2165 + NV_ENC_BUFFER_USAGE bufferUsage; /**< [in]: Usage of resource to be registered. */
  2166 + NV_ENC_FENCE_POINT_D3D12* pInputFencePoint; /**< [in]: Specifies the pointer to input fence and corresponding fence value to do GPU wait.
  2167 + To be used only when NV_ENC_REGISTER_RESOURCE::resourceToRegister represents D3D12 surface and
  2168 + NV_ENC_BUFFER_USAGE::bufferUsage is NV_ENC_INPUT_IMAGE.
  2169 + This fence will be used to do GPU wait until the specified fence reaches or exceeds the specified value. */
  2170 + NV_ENC_FENCE_POINT_D3D12* pOutputFencePoint; /**< [in]: Specifies the pointer to output fence and corresponding fence value to set after GPU operation is finished.
  2171 + To be used only when NV_ENC_REGISTER_RESOURCE::resourceToRegister represents D3D12 surface and
  2172 + NV_ENC_BUFFER_USAGE::bufferUsage is NV_ENC_INPUT_IMAGE. */
  2173 + uint32_t reserved1[247]; /**< [in]: Reserved and must be set to 0. */
  2174 + void* reserved2[60]; /**< [in]: Reserved and must be set to NULL. */
  2175 +} NV_ENC_REGISTER_RESOURCE;
  2176 +
  2177 +/** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */
  2178 +#define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3)
  2179 +
  2180 +/**
  2181 + * \struct _NV_ENC_STAT
  2182 + * Encode Stats structure.
  2183 + */
  2184 +typedef struct _NV_ENC_STAT
  2185 +{
  2186 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */
  2187 + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  2188 + NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */
  2189 + uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */
  2190 + uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */
  2191 + uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */
  2192 + uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */
  2193 + uint32_t picIdx; /**< [out]: Picture number */
  2194 + uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
  2195 + uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
  2196 + uint32_t reservedBitFields :31; /**< [in]: Reserved bit fields and must be set to 0 */
  2197 + uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
  2198 + uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. */
  2199 + uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. */
  2200 + int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. */
  2201 + int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. */
  2202 + uint32_t reserved1[226]; /**< [in]: Reserved and must be set to 0 */
  2203 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2204 +} NV_ENC_STAT;
  2205 +
  2206 +/** Macro for constructing the version field of ::_NV_ENC_STAT */
  2207 +#define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1)
  2208 +
  2209 +
  2210 +/**
  2211 + * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  2212 + * Sequence and picture paramaters payload.
  2213 + */
  2214 +typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  2215 +{
  2216 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  2217 + uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provided by the client */
  2218 + uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */
  2219 + uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */
  2220 + void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  2221 + It is the client's responsibility to manage this memory. */
  2222 + uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes. */
  2223 + uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */
  2224 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2225 +} NV_ENC_SEQUENCE_PARAM_PAYLOAD;
  2226 +
  2227 +/** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */
  2228 +#define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1)
  2229 +
  2230 +
  2231 +/**
  2232 + * Event registration/unregistration parameters.
  2233 + */
  2234 +typedef struct _NV_ENC_EVENT_PARAMS
  2235 +{
  2236 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */
  2237 + uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  2238 + void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */
  2239 + uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  2240 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2241 +} NV_ENC_EVENT_PARAMS;
  2242 +
  2243 +/** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */
  2244 +#define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  2245 +
  2246 +/**
  2247 + * Encoder Session Creation parameters
  2248 + */
  2249 +typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS
  2250 +{
  2251 + uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */
  2252 + NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */
  2253 + void* device; /**< [in]: Pointer to client device. */
  2254 + void* reserved; /**< [in]: Reserved and must be set to 0. */
  2255 + uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */
  2256 + uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  2257 + void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  2258 +} NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS;
  2259 +/** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */
  2260 +#define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  2261 +
  2262 +/** @} */ /* END ENCODER_STRUCTURE */
  2263 +
  2264 +
  2265 +/**
  2266 + * \addtogroup ENCODE_FUNC NvEncodeAPI Functions
  2267 + * @{
  2268 + */
  2269 +
  2270 +// NvEncOpenEncodeSession
  2271 +/**
  2272 + * \brief Opens an encoding session.
  2273 + *
  2274 + * Deprecated.
  2275 + *
  2276 + * \return
  2277 + * ::NV_ENC_ERR_INVALID_CALL\n
  2278 + *
  2279 + */
  2280 +NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder);
  2281 +
  2282 +// NvEncGetEncodeGuidCount
  2283 +/**
  2284 + * \brief Retrieves the number of supported encode GUIDs.
  2285 + *
  2286 + * The function returns the number of codec GUIDs supported by the NvEncodeAPI
  2287 + * interface.
  2288 + *
  2289 + * \param [in] encoder
  2290 + * Pointer to the NvEncodeAPI interface.
  2291 + * \param [out] encodeGUIDCount
  2292 + * Number of supported encode GUIDs.
  2293 + *
  2294 + * \return
  2295 + * ::NV_ENC_SUCCESS \n
  2296 + * ::NV_ENC_ERR_INVALID_PTR \n
  2297 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2298 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2299 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2300 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2301 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2302 + * ::NV_ENC_ERR_GENERIC \n
  2303 + *
  2304 + */
  2305 +NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount);
  2306 +
  2307 +
  2308 +// NvEncGetEncodeGUIDs
  2309 +/**
  2310 + * \brief Retrieves an array of supported encoder codec GUIDs.
  2311 + *
  2312 + * The function returns an array of codec GUIDs supported by the NvEncodeAPI interface.
  2313 + * The client must allocate an array where the NvEncodeAPI interface can
  2314 + * fill the supported GUIDs and pass the pointer in \p *GUIDs parameter.
  2315 + * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API.
  2316 + * The Nvidia Encoding interface returns the number of codec GUIDs it has actually
  2317 + * filled in the GUID array in the \p GUIDCount parameter.
  2318 + *
  2319 + * \param [in] encoder
  2320 + * Pointer to the NvEncodeAPI interface.
  2321 + * \param [in] guidArraySize
  2322 + * Number of GUIDs to retrieved. Should be set to the number retrieved using
  2323 + * ::NvEncGetEncodeGUIDCount.
  2324 + * \param [out] GUIDs
  2325 + * Array of supported Encode GUIDs.
  2326 + * \param [out] GUIDCount
  2327 + * Number of supported Encode GUIDs.
  2328 + *
  2329 + * \return
  2330 + * ::NV_ENC_SUCCESS \n
  2331 + * ::NV_ENC_ERR_INVALID_PTR \n
  2332 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2333 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2334 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2335 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2336 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2337 + * ::NV_ENC_ERR_GENERIC \n
  2338 + *
  2339 + */
  2340 +NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2341 +
  2342 +
  2343 +// NvEncGetEncodeProfileGuidCount
  2344 +/**
  2345 + * \brief Retrieves the number of supported profile GUIDs.
  2346 + *
  2347 + * The function returns the number of profile GUIDs supported for a given codec.
  2348 + * The client must first enumerate the codec GUIDs supported by the NvEncodeAPI
  2349 + * interface. After determining the codec GUID, it can query the NvEncodeAPI
  2350 + * interface to determine the number of profile GUIDs supported for a particular
  2351 + * codec GUID.
  2352 + *
  2353 + * \param [in] encoder
  2354 + * Pointer to the NvEncodeAPI interface.
  2355 + * \param [in] encodeGUID
  2356 + * The codec GUID for which the profile GUIDs are being enumerated.
  2357 + * \param [out] encodeProfileGUIDCount
  2358 + * Number of encode profiles supported for the given encodeGUID.
  2359 + *
  2360 + * \return
  2361 + * ::NV_ENC_SUCCESS \n
  2362 + * ::NV_ENC_ERR_INVALID_PTR \n
  2363 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2364 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2365 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2366 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2367 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2368 + * ::NV_ENC_ERR_GENERIC \n
  2369 + *
  2370 + */
  2371 +NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  2372 +
  2373 +
  2374 +// NvEncGetEncodeProfileGUIDs
  2375 +/**
  2376 + * \brief Retrieves an array of supported encode profile GUIDs.
  2377 + *
  2378 + * The function returns an array of supported profile GUIDs for a particular
  2379 + * codec GUID. The client must allocate an array where the NvEncodeAPI interface
  2380 + * can populate the profile GUIDs. The client can determine the array size using
  2381 + * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the
  2382 + * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID
  2383 + * parameter.
  2384 + *
  2385 + * \param [in] encoder
  2386 + * Pointer to the NvEncodeAPI interface.
  2387 + * \param [in] encodeGUID
  2388 + * The encode GUID whose profile GUIDs are being enumerated.
  2389 + * \param [in] guidArraySize
  2390 + * Number of GUIDs to be retrieved. Should be set to the number retrieved using
  2391 + * ::NvEncGetEncodeProfileGUIDCount.
  2392 + * \param [out] profileGUIDs
  2393 + * Array of supported Encode Profile GUIDs
  2394 + * \param [out] GUIDCount
  2395 + * Number of valid encode profile GUIDs in \p profileGUIDs array.
  2396 + *
  2397 + * \return
  2398 + * ::NV_ENC_SUCCESS \n
  2399 + * ::NV_ENC_ERR_INVALID_PTR \n
  2400 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2401 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2402 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2403 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2404 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2405 + * ::NV_ENC_ERR_GENERIC \n
  2406 + *
  2407 + */
  2408 +NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2409 +
  2410 +// NvEncGetInputFormatCount
  2411 +/**
  2412 + * \brief Retrieve the number of supported Input formats.
  2413 + *
  2414 + * The function returns the number of supported input formats. The client must
  2415 + * query the NvEncodeAPI interface to determine the supported input formats
  2416 + * before creating the input surfaces.
  2417 + *
  2418 + * \param [in] encoder
  2419 + * Pointer to the NvEncodeAPI interface.
  2420 + * \param [in] encodeGUID
  2421 + * Encode GUID, corresponding to which the number of supported input formats
  2422 + * is to be retrieved.
  2423 + * \param [out] inputFmtCount
  2424 + * Number of input formats supported for specified Encode GUID.
  2425 + *
  2426 + * \return
  2427 + * ::NV_ENC_SUCCESS \n
  2428 + * ::NV_ENC_ERR_INVALID_PTR \n
  2429 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2430 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2431 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2432 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2433 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2434 + * ::NV_ENC_ERR_GENERIC \n
  2435 + */
  2436 +NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  2437 +
  2438 +
  2439 +// NvEncGetInputFormats
  2440 +/**
  2441 + * \brief Retrieves an array of supported Input formats
  2442 + *
  2443 + * Returns an array of supported input formats The client must use the input
  2444 + * format to create input surface using ::NvEncCreateInputBuffer() API.
  2445 + *
  2446 + * \param [in] encoder
  2447 + * Pointer to the NvEncodeAPI interface.
  2448 + * \param [in] encodeGUID
  2449 + * Encode GUID, corresponding to which the number of supported input formats
  2450 + * is to be retrieved.
  2451 + *\param [in] inputFmtArraySize
  2452 + * Size input format count array passed in \p inputFmts.
  2453 + *\param [out] inputFmts
  2454 + * Array of input formats supported for this Encode GUID.
  2455 + *\param [out] inputFmtCount
  2456 + * The number of valid input format types returned by the NvEncodeAPI
  2457 + * interface in \p inputFmts array.
  2458 + *
  2459 + * \return
  2460 + * ::NV_ENC_SUCCESS \n
  2461 + * ::NV_ENC_ERR_INVALID_PTR \n
  2462 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2463 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2464 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2465 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2466 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2467 + * ::NV_ENC_ERR_GENERIC \n
  2468 + *
  2469 + */
  2470 +NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  2471 +
  2472 +
  2473 +// NvEncGetEncodeCaps
  2474 +/**
  2475 + * \brief Retrieves the capability value for a specified encoder attribute.
  2476 + *
  2477 + * The function returns the capability value for a given encoder attribute. The
  2478 + * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before
  2479 + * calling this function. The encoder attribute being queried are enumerated in
  2480 + * ::NV_ENC_CAPS_PARAM enum.
  2481 + *
  2482 + * \param [in] encoder
  2483 + * Pointer to the NvEncodeAPI interface.
  2484 + * \param [in] encodeGUID
  2485 + * Encode GUID, corresponding to which the capability attribute is to be retrieved.
  2486 + * \param [in] capsParam
  2487 + * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more
  2488 + * details.
  2489 + * \param [out] capsVal
  2490 + * The value corresponding to the capability attribute being queried.
  2491 + *
  2492 + * \return
  2493 + * ::NV_ENC_SUCCESS \n
  2494 + * ::NV_ENC_ERR_INVALID_PTR \n
  2495 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2496 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2497 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2498 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2499 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2500 + * ::NV_ENC_ERR_GENERIC \n
  2501 + */
  2502 +NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  2503 +
  2504 +
  2505 +// NvEncGetEncodePresetCount
  2506 +/**
  2507 + * \brief Retrieves the number of supported preset GUIDs.
  2508 + *
  2509 + * The function returns the number of preset GUIDs available for a given codec.
  2510 + * The client must validate the codec GUID using ::NvEncGetEncodeGUIDs() API
  2511 + * before calling this function.
  2512 + *
  2513 + * \param [in] encoder
  2514 + * Pointer to the NvEncodeAPI interface.
  2515 + * \param [in] encodeGUID
  2516 + * Encode GUID, corresponding to which the number of supported presets is to
  2517 + * be retrieved.
  2518 + * \param [out] encodePresetGUIDCount
  2519 + * Receives the number of supported preset GUIDs.
  2520 + *
  2521 + * \return
  2522 + * ::NV_ENC_SUCCESS \n
  2523 + * ::NV_ENC_ERR_INVALID_PTR \n
  2524 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2525 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2526 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2527 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2528 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2529 + * ::NV_ENC_ERR_GENERIC \n
  2530 + *
  2531 + */
  2532 +NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  2533 +
  2534 +
  2535 +// NvEncGetEncodePresetGUIDs
  2536 +/**
  2537 + * \brief Receives an array of supported encoder preset GUIDs.
  2538 + *
  2539 + * The function returns an array of encode preset GUIDs available for a given codec.
  2540 + * The client can directly use one of the preset GUIDs based upon the use case
  2541 + * or target device. The preset GUID chosen can be directly used in
  2542 + * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
  2543 + * Alternately client can also use the preset GUID to retrieve the encoding config
  2544 + * parameters being used by NvEncodeAPI interface for that given preset, using
  2545 + * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
  2546 + * as per its use case and send it to NvEncodeAPI interface as part of
  2547 + * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
  2548 + * API.
  2549 + *
  2550 + *
  2551 + * \param [in] encoder
  2552 + * Pointer to the NvEncodeAPI interface.
  2553 + * \param [in] encodeGUID
  2554 + * Encode GUID, corresponding to which the list of supported presets is to be
  2555 + * retrieved.
  2556 + * \param [in] guidArraySize
  2557 + * Size of array of preset GUIDs passed in \p preset GUIDs
  2558 + * \param [out] presetGUIDs
  2559 + * Array of supported Encode preset GUIDs from the NvEncodeAPI interface
  2560 + * to client.
  2561 + * \param [out] encodePresetGUIDCount
  2562 + * Receives the number of preset GUIDs returned by the NvEncodeAPI
  2563 + * interface.
  2564 + *
  2565 + * \return
  2566 + * ::NV_ENC_SUCCESS \n
  2567 + * ::NV_ENC_ERR_INVALID_PTR \n
  2568 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2569 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2570 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2571 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2572 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2573 + * ::NV_ENC_ERR_GENERIC \n
  2574 + *
  2575 + */
  2576 +NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  2577 +
  2578 +
  2579 +// NvEncGetEncodePresetConfig
  2580 +/**
  2581 + * \brief Returns a preset config structure supported for given preset GUID.
  2582 + *
  2583 + * The function returns a preset config structure for a given preset GUID. Before
  2584 + * using this function the client must enumerate the preset GUIDs available for
  2585 + * a given codec. The preset config structure can be modified by the client depending
  2586 + * upon its use case and can be then used to initialize the encoder using
  2587 + * ::NvEncInitializeEncoder() API. The client can use this function only if it
  2588 + * wants to modify the NvEncodeAPI preset configuration, otherwise it can
  2589 + * directly use the preset GUID.
  2590 + *
  2591 + * \param [in] encoder
  2592 + * Pointer to the NvEncodeAPI interface.
  2593 + * \param [in] encodeGUID
  2594 + * Encode GUID, corresponding to which the list of supported presets is to be
  2595 + * retrieved.
  2596 + * \param [in] presetGUID
  2597 + * Preset GUID, corresponding to which the Encoding configurations is to be
  2598 + * retrieved.
  2599 + * \param [out] presetConfig
  2600 + * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
  2601 +* more details.
  2602 + *
  2603 + * \return
  2604 + * ::NV_ENC_SUCCESS \n
  2605 + * ::NV_ENC_ERR_INVALID_PTR \n
  2606 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2607 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2608 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2609 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2610 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2611 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2612 + * ::NV_ENC_ERR_GENERIC \n
  2613 + *
  2614 + */
  2615 +NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  2616 +
  2617 +// NvEncGetEncodePresetConfigEx
  2618 +/**
  2619 + * \brief Returns a preset config structure supported for given preset GUID.
  2620 + *
  2621 + * The function returns a preset config structure for a given preset GUID and tuning info.
  2622 + * NvEncGetEncodePresetConfigEx() API is not applicable to H264 and HEVC meonly mode.
  2623 + * Before using this function the client must enumerate the preset GUIDs available for
  2624 + * a given codec. The preset config structure can be modified by the client depending
  2625 + * upon its use case and can be then used to initialize the encoder using
  2626 + * ::NvEncInitializeEncoder() API. The client can use this function only if it
  2627 + * wants to modify the NvEncodeAPI preset configuration, otherwise it can
  2628 + * directly use the preset GUID.
  2629 + *
  2630 + * \param [in] encoder
  2631 + * Pointer to the NvEncodeAPI interface.
  2632 + * \param [in] encodeGUID
  2633 + * Encode GUID, corresponding to which the list of supported presets is to be
  2634 + * retrieved.
  2635 + * \param [in] presetGUID
  2636 + * Preset GUID, corresponding to which the Encoding configurations is to be
  2637 + * retrieved.
  2638 + * \param [in] tuningInfo
  2639 + * tuning info, corresponding to which the Encoding configurations is to be
  2640 + * retrieved.
  2641 + * \param [out] presetConfig
  2642 + * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
  2643 + * more details.
  2644 + *
  2645 + * \return
  2646 + * ::NV_ENC_SUCCESS \n
  2647 + * ::NV_ENC_ERR_INVALID_PTR \n
  2648 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2649 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2650 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2651 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2652 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2653 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2654 + * ::NV_ENC_ERR_GENERIC \n
  2655 + *
  2656 + */
  2657 +NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfigEx (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
  2658 +
  2659 +// NvEncInitializeEncoder
  2660 +/**
  2661 + * \brief Initialize the encoder.
  2662 + *
  2663 + * This API must be used to initialize the encoder. The initialization parameter
  2664 + * is passed using \p *createEncodeParams The client must send the following
  2665 + * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
  2666 + * - NV_ENC_INITIALIZE_PARAMS::encodeGUID
  2667 + * - NV_ENC_INITIALIZE_PARAMS::encodeWidth
  2668 + * - NV_ENC_INITIALIZE_PARAMS::encodeHeight
  2669 + *
  2670 + * The client can pass a preset GUID directly to the NvEncodeAPI interface using
  2671 + * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
  2672 + * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
  2673 + * will be selected based on the preset GUID. The preset GUID must have been
  2674 + * validated by the client using ::NvEncGetEncodePresetGUIDs() API.
  2675 + * If the client passes a custom ::_NV_ENC_CONFIG structure through
  2676 + * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
  2677 + * based on the preset GUID. It is recommended that even if the client passes a custom config,
  2678 + * it should also send a preset GUID. In this case, the preset GUID passed by the client
  2679 + * will not override any of the custom config parameters programmed by the client,
  2680 + * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
  2681 + * which are not exposed to the client.
  2682 + *
  2683 + * There are two modes of operation for the encoder namely:
  2684 + * - Asynchronous mode
  2685 + * - Synchronous mode
  2686 + *
  2687 + * The client can select asynchronous or synchronous mode by setting the \p
  2688 + * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
  2689 + *\par Asynchronous mode of operation:
  2690 + * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
  2691 + * The client operating in asynchronous mode must allocate completion event object
  2692 + * for each output buffer and pass the completion event object in the
  2693 + * ::NvEncEncodePicture() API. The client can create another thread and wait on
  2694 + * the event object to be signaled by NvEncodeAPI interface on completion of the
  2695 + * encoding process for the output frame. This should unblock the main thread from
  2696 + * submitting work to the encoder. When the event is signaled the client can call
  2697 + * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
  2698 + * API. This is the preferred mode of operation.
  2699 + *
  2700 + * NOTE: Asynchronous mode is not supported on Linux.
  2701 + *
  2702 + *\par Synchronous mode of operation:
  2703 + * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
  2704 + * The client working in synchronous mode can work in a single threaded or multi
  2705 + * threaded mode. The client need not allocate any event objects. The client can
  2706 + * only lock the bitstream data after NvEncodeAPI interface has returned
  2707 + * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
  2708 + * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
  2709 + * client must not lock the output buffer in such case but should send the next
  2710 + * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
  2711 + * until it returns ::NV_ENC_SUCCESS. \n
  2712 + * The client must always lock the bitstream data in order in which it has submitted.
  2713 + * This is true for both asynchronous and synchronous mode.
  2714 + *
  2715 + *\par Picture type decision:
  2716 + * If the client is taking the picture type decision and it must disable the picture
  2717 + * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
  2718 + * to 0. In this case the client is required to send the picture in encoding
  2719 + * order to NvEncodeAPI by doing the re-ordering for B frames. \n
  2720 + * If the client doesn't want to take the picture type decision it can enable
  2721 + * picture type decision module in the NvEncodeAPI interface by setting
  2722 + * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
  2723 + * order.
  2724 + *
  2725 + * \param [in] encoder
  2726 + * Pointer to the NvEncodeAPI interface.
  2727 + * \param [in] createEncodeParams
  2728 + * Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
  2729 + *
  2730 + * \return
  2731 + * ::NV_ENC_SUCCESS \n
  2732 + * ::NV_ENC_ERR_INVALID_PTR \n
  2733 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2734 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2735 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2736 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2737 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2738 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2739 + * ::NV_ENC_ERR_GENERIC \n
  2740 + *
  2741 + */
  2742 +NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  2743 +
  2744 +
  2745 +// NvEncCreateInputBuffer
  2746 +/**
  2747 + * \brief Allocates Input buffer.
  2748 + *
  2749 + * This function is used to allocate an input buffer. The client must enumerate
  2750 + * the input buffer format before allocating the input buffer resources. The
  2751 + * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
  2752 + * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
  2753 + * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
  2754 + * client must be at least 4 more than the number of B frames being used for encoding.
  2755 + *
  2756 + * \param [in] encoder
  2757 + * Pointer to the NvEncodeAPI interface.
  2758 + * \param [in,out] createInputBufferParams
  2759 + * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
  2760 + *
  2761 + * \return
  2762 + * ::NV_ENC_SUCCESS \n
  2763 + * ::NV_ENC_ERR_INVALID_PTR \n
  2764 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2765 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2766 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2767 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2768 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2769 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2770 + * ::NV_ENC_ERR_GENERIC \n
  2771 + *
  2772 + */
  2773 +NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  2774 +
  2775 +
  2776 +// NvEncDestroyInputBuffer
  2777 +/**
  2778 + * \brief Release an input buffers.
  2779 + *
  2780 + * This function is used to free an input buffer. If the client has allocated
  2781 + * any input buffer using ::NvEncCreateInputBuffer() API, it must free those
  2782 + * input buffers by calling this function. The client must release the input
  2783 + * buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
  2784 + *
  2785 + * \param [in] encoder
  2786 + * Pointer to the NvEncodeAPI interface.
  2787 + * \param [in] inputBuffer
  2788 + * Pointer to the input buffer to be released.
  2789 + *
  2790 + * \return
  2791 + * ::NV_ENC_SUCCESS \n
  2792 + * ::NV_ENC_ERR_INVALID_PTR \n
  2793 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2794 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2795 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2796 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2797 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2798 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2799 + * ::NV_ENC_ERR_GENERIC \n
  2800 + *
  2801 + */
  2802 +NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2803 +
  2804 +// NvEncSetIOCudaStreams
  2805 +/**
  2806 + * \brief Set input and output CUDA stream for specified encoder attribute.
  2807 + *
  2808 + * Encoding may involve CUDA pre-processing on the input and post-processing on encoded output.
  2809 + * This function is used to set input and output CUDA streams to pipeline the CUDA pre-processing
  2810 + * and post-processing tasks. Clients should call this function before the call to
  2811 + * NvEncUnlockInputBuffer(). If this function is not called, the default CUDA stream is used for
  2812 + * input and output processing. After a successful call to this function, the streams specified
  2813 + * in that call will replace the previously-used streams.
  2814 + * This API is supported for NVCUVID interface only.
  2815 + *
  2816 + * \param [in] encoder
  2817 + * Pointer to the NvEncodeAPI interface.
  2818 + * \param [in] inputStream
  2819 + * Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::inputFrame for encode.
  2820 + * In case of ME-only mode, inputStream is used to process ::NV_ENC_MEONLY_PARAMS::inputBuffer and
  2821 + * ::NV_ENC_MEONLY_PARAMS::referenceFrame
  2822 + * \param [in] outputStream
  2823 + * Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::outputBuffer for encode.
  2824 + * In case of ME-only mode, outputStream is used to process ::NV_ENC_MEONLY_PARAMS::mvBuffer
  2825 + *
  2826 + * \return
  2827 + * ::NV_ENC_SUCCESS \n
  2828 + * ::NV_ENC_ERR_INVALID_PTR \n
  2829 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2830 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2831 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2832 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2833 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2834 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2835 + * ::NV_ENC_ERR_GENERIC \n
  2836 + */
  2837 +NVENCSTATUS NVENCAPI NvEncSetIOCudaStreams (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
  2838 +
  2839 +
  2840 +// NvEncCreateBitstreamBuffer
  2841 +/**
  2842 + * \brief Allocates an output bitstream buffer
  2843 + *
  2844 + * This function is used to allocate an output bitstream buffer and returns a
  2845 + * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
  2846 + * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
  2847 + * The client can only call this function after the encoder session has been
  2848 + * initialized using ::NvEncInitializeEncoder() API. The minimum number of output
  2849 + * buffers allocated by the client must be at least 4 more than the number of B
  2850 + * B frames being used for encoding. The client can only access the output
  2851 + * bitstream data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
  2852 + * function.
  2853 + *
  2854 + * \param [in] encoder
  2855 + * Pointer to the NvEncodeAPI interface.
  2856 + * \param [in,out] createBitstreamBufferParams
  2857 + * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
  2858 + *
  2859 + * \return
  2860 + * ::NV_ENC_SUCCESS \n
  2861 + * ::NV_ENC_ERR_INVALID_PTR \n
  2862 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2863 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2864 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2865 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2866 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2867 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2868 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2869 + * ::NV_ENC_ERR_GENERIC \n
  2870 + *
  2871 + */
  2872 +NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  2873 +
  2874 +
  2875 +// NvEncDestroyBitstreamBuffer
  2876 +/**
  2877 + * \brief Release a bitstream buffer.
  2878 + *
  2879 + * This function is used to release the output bitstream buffer allocated using
  2880 + * the ::NvEncCreateBitstreamBuffer() function. The client must release the output
  2881 + * bitstreamBuffer using this function before destroying the encoder session.
  2882 + *
  2883 + * \param [in] encoder
  2884 + * Pointer to the NvEncodeAPI interface.
  2885 + * \param [in] bitstreamBuffer
  2886 + * Pointer to the bitstream buffer being released.
  2887 + *
  2888 + * \return
  2889 + * ::NV_ENC_SUCCESS \n
  2890 + * ::NV_ENC_ERR_INVALID_PTR \n
  2891 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2892 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2893 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2894 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2895 + * ::NV_ENC_ERR_INVALID_PARAM \n
  2896 + * ::NV_ENC_ERR_INVALID_VERSION \n
  2897 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2898 + * ::NV_ENC_ERR_GENERIC \n
  2899 + *
  2900 + */
  2901 +NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2902 +
  2903 +// NvEncEncodePicture
  2904 +/**
  2905 + * \brief Submit an input picture for encoding.
  2906 + *
  2907 + * This function is used to submit an input picture buffer for encoding. The
  2908 + * encoding parameters are passed using \p *encodePicParams which is a pointer
  2909 + * to the ::_NV_ENC_PIC_PARAMS structure.
  2910 + *
  2911 + * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
  2912 + * send a valid value for the following fields.
  2913 + * - NV_ENC_PIC_PARAMS::pictureType
  2914 + * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
  2915 + * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
  2916 + * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
  2917 + *
  2918 + *\par MVC Encoding:
  2919 + * For MVC encoding the client must call encode picture API for each view separately
  2920 + * and must pass valid view id in NV_ENC_PIC_PARAMS_MVC::viewID field. Currently
  2921 + * NvEncodeAPI only support stereo MVC so client must send viewID as 0 for base
  2922 + * view and view ID as 1 for dependent view.
  2923 + *
  2924 + *\par Asynchronous Encoding
  2925 + * If the client has enabled asynchronous mode of encoding by setting
  2926 + * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
  2927 + * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
  2928 + * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
  2929 + * API commands from the main thread and then queue output buffers to be processed
  2930 + * to a secondary worker thread. Before the locking the output buffers in the
  2931 + * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
  2932 + * it has queued in ::NvEncEncodePicture() API call. The client must always process
  2933 + * completion event and the output buffer in the same order in which they have been
  2934 + * submitted for encoding. The NvEncodeAPI interface is responsible for any
  2935 + * re-ordering required for B frames and will always ensure that encoded bitstream
  2936 + * data is written in the same order in which output buffer is submitted.
  2937 + * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
  2938 + * some ::NvEncEncodePicture() API calls but the client must not treat it as a fatal error.
  2939 + * The NvEncodeAPI interface might not be able to submit an input picture buffer for encoding
  2940 + * immediately due to re-ordering for B frames.
  2941 + *\code
  2942 + The below example shows how asynchronous encoding in case of 1 B frames
  2943 + ------------------------------------------------------------------------
  2944 + Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  2945 + and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  2946 + keep a copy of the input buffers for re-ordering and it allocates following
  2947 + internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  2948 + and the client is not responsible for the allocating or freeing the memory of
  2949 + the internal buffers.
  2950 +
  2951 + a) The client main thread will queue the following encode frame calls.
  2952 + Note the picture type is unknown to the client, the decision is being taken by
  2953 + NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
  2954 + consisting of allocated input buffer, output buffer and output events in successive
  2955 + ::NvEncEncodePicture() API calls along with other required encode picture params.
  2956 + For example:
  2957 + 1st EncodePicture parameters - (I1, O1, E1)
  2958 + 2nd EncodePicture parameters - (I2, O2, E2)
  2959 + 3rd EncodePicture parameters - (I3, O3, E3)
  2960 +
  2961 + b) NvEncodeAPI SW will receive the following encode Commands from the client.
  2962 + The left side shows input from client in the form (Input buffer, Output Buffer,
  2963 + Output Event). The right hand side shows a possible picture type decision take by
  2964 + the NvEncodeAPI interface.
  2965 + (I1, O1, E1) ---P1 Frame
  2966 + (I2, O2, E2) ---B2 Frame
  2967 + (I3, O3, E3) ---P3 Frame
  2968 +
  2969 + c) NvEncodeAPI interface will make a copy of the input buffers to its internal
  2970 + buffers for re-ordering. These copies are done as part of nvEncEncodePicture
  2971 + function call from the client and NvEncodeAPI interface is responsible for
  2972 + synchronization of copy operation with the actual encoding operation.
  2973 + I1 --> NvI1
  2974 + I2 --> NvI2
  2975 + I3 --> NvI3
  2976 +
  2977 + d) The NvEncodeAPI encodes I1 as P frame and submits I1 to encoder HW and returns ::NV_ENC_SUCCESS.
  2978 + The NvEncodeAPI tries to encode I2 as B frame and fails with ::NV_ENC_ERR_NEED_MORE_INPUT error code.
  2979 + The error is not fatal and it notifies client that I2 is not submitted to encoder immediately.
  2980 + The NvEncodeAPI encodes I3 as P frame and submits I3 for encoding which will be used as backward
  2981 + reference frame for I2. The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS.
  2982 + Both the submission are part of the same ::NvEncEncodePicture() function call.
  2983 +
  2984 + e) After returning from ::NvEncEncodePicture() call , the client must queue the output
  2985 + bitstream processing work to the secondary thread. The output bitstream processing
  2986 + for asynchronous mode consist of first waiting on completion event(E1, E2..)
  2987 + and then locking the output bitstream buffer(O1, O2..) for reading the encoded
  2988 + data. The work queued to the secondary thread by the client is in the following order
  2989 + (I1, O1, E1)
  2990 + (I2, O2, E2)
  2991 + (I3, O3, E3)
  2992 + Note they are in the same order in which client calls ::NvEncEncodePicture() API
  2993 + in \p step a).
  2994 +
  2995 + f) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
  2996 + the following encode commands:
  2997 + (NvI1, O1, E1) ---P1 Frame
  2998 + (NvI3, O2, E2) ---P3 Frame
  2999 + (NvI2, O3, E3) ---B2 frame
  3000 +
  3001 + g) After the encoding operations are completed, the events will be signaled
  3002 + by NvEncodeAPI interface in the following order :
  3003 + (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signaled.
  3004 + (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signaled.
  3005 + (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signaled.
  3006 +
  3007 + h) The client must lock the bitstream data using ::NvEncLockBitstream() API in
  3008 + the order O1,O2,O3 to read the encoded data, after waiting for the events
  3009 + to be signaled in the same order i.e E1, E2 and E3.The output processing is
  3010 + done in the secondary thread in the following order:
  3011 + Waits on E1, copies encoded bitstream from O1
  3012 + Waits on E2, copies encoded bitstream from O2
  3013 + Waits on E3, copies encoded bitstream from O3
  3014 +
  3015 + -Note the client will receive the events signaling and output buffer in the
  3016 + same order in which they have submitted for encoding.
  3017 + -Note the LockBitstream will have picture type field which will notify the
  3018 + output picture type to the clients.
  3019 + -Note the input, output buffer and the output completion event are free to be
  3020 + reused once NvEncodeAPI interfaced has signaled the event and the client has
  3021 + copied the data from the output buffer.
  3022 +
  3023 + * \endcode
  3024 + *
  3025 + *\par Synchronous Encoding
  3026 + * The client can enable synchronous mode of encoding by setting
  3027 + * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
  3028 + * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
  3029 + * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
  3030 + * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
  3031 + * interface might not be able to submit an input picture buffer for encoding
  3032 + * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
  3033 + * submit the input picture which is decided to be encoded as B frame as it waits
  3034 + * for backward reference from temporally subsequent frames. This input picture
  3035 + * is buffered internally and waits for more input picture to arrive. The client
  3036 + * must not call ::NvEncLockBitstream() API on the output buffers whose
  3037 + * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
  3038 + * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
  3039 + * output bitstreams to read the encoded bitstream data. The following example
  3040 + * explains the scenario with synchronous encoding with 2 B frames.
  3041 + *\code
  3042 + The below example shows how synchronous encoding works in case of 1 B frames
  3043 + -----------------------------------------------------------------------------
  3044 + Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  3045 + and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  3046 + keep a copy of the input buffers for re-ordering and it allocates following
  3047 + internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  3048 + and the client is not responsible for the allocating or freeing the memory of
  3049 + the internal buffers.
  3050 +
  3051 + The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
  3052 + The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
  3053 + HW and returns ::NV_ENC_SUCCESS.
  3054 + The client can now read the encoded data by locking the output O1 by calling
  3055 + NvEncLockBitstream API.
  3056 +
  3057 + The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
  3058 + The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
  3059 + to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
  3060 + The error is not fatal and it notifies client that it cannot read the encoded
  3061 + data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
  3062 + more work to the NvEncodeAPI interface.
  3063 +
  3064 + The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
  3065 + The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
  3066 + encoding which will be used as backward reference frame for I2.
  3067 + The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
  3068 + the submission are part of the same ::NvEncEncodePicture() function call.
  3069 + The client can now read the encoded data for both the frames by locking the output
  3070 + O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
  3071 +
  3072 + The client must always lock the output in the same order in which it has submitted
  3073 + to receive the encoded bitstream in correct encoding order.
  3074 +
  3075 + * \endcode
  3076 + *
  3077 + * \param [in] encoder
  3078 + * Pointer to the NvEncodeAPI interface.
  3079 + * \param [in,out] encodePicParams
  3080 + * Pointer to the ::_NV_ENC_PIC_PARAMS structure.
  3081 + *
  3082 + * \return
  3083 + * ::NV_ENC_SUCCESS \n
  3084 + * ::NV_ENC_ERR_INVALID_PTR \n
  3085 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3086 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3087 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3088 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3089 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3090 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3091 + * ::NV_ENC_ERR_ENCODER_BUSY \n
  3092 + * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  3093 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3094 + * ::NV_ENC_ERR_GENERIC \n
  3095 + *
  3096 + */
  3097 +NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  3098 +
  3099 +
  3100 +// NvEncLockBitstream
  3101 +/**
  3102 + * \brief Lock output bitstream buffer
  3103 + *
  3104 + * This function is used to lock the bitstream buffer to read the encoded data.
  3105 + * The client can only access the encoded data by calling this function.
  3106 + * The pointer to client accessible encoded data is returned in the
  3107 + * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
  3108 + * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
  3109 + * The NvEncodeAPI interface also returns the output picture type and picture structure
  3110 + * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
  3111 + * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
  3112 + * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
  3113 + * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
  3114 + * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
  3115 + * retry the function after few milliseconds.
  3116 + *
  3117 + * \param [in] encoder
  3118 + * Pointer to the NvEncodeAPI interface.
  3119 + * \param [in,out] lockBitstreamBufferParams
  3120 + * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
  3121 + *
  3122 + * \return
  3123 + * ::NV_ENC_SUCCESS \n
  3124 + * ::NV_ENC_ERR_INVALID_PTR \n
  3125 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3126 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3127 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3128 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3129 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3130 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3131 + * ::NV_ENC_ERR_LOCK_BUSY \n
  3132 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3133 + * ::NV_ENC_ERR_GENERIC \n
  3134 + *
  3135 + */
  3136 +NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  3137 +
  3138 +
  3139 +// NvEncUnlockBitstream
  3140 +/**
  3141 + * \brief Unlock the output bitstream buffer
  3142 + *
  3143 + * This function is used to unlock the output bitstream buffer after the client
  3144 + * has read the encoded data from output buffer. The client must call this function
  3145 + * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
  3146 + * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
  3147 + * the function to fail.
  3148 + *
  3149 + * \param [in] encoder
  3150 + * Pointer to the NvEncodeAPI interface.
  3151 + * \param [in,out] bitstreamBuffer
  3152 + * bitstream buffer pointer being unlocked
  3153 + *
  3154 + * \return
  3155 + * ::NV_ENC_SUCCESS \n
  3156 + * ::NV_ENC_ERR_INVALID_PTR \n
  3157 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3158 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3159 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3160 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3161 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3162 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3163 + * ::NV_ENC_ERR_GENERIC \n
  3164 + *
  3165 + */
  3166 +NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  3167 +
  3168 +
  3169 +// NvLockInputBuffer
  3170 +/**
  3171 + * \brief Locks an input buffer
  3172 + *
  3173 + * This function is used to lock the input buffer to load the uncompressed YUV
  3174 + * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
  3175 + * it had previously allocated using ::NvEncCreateInputBuffer()in the
  3176 + * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
  3177 + * The NvEncodeAPI interface returns pointer to client accessible input buffer
  3178 + * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
  3179 + *
  3180 + * \param [in] encoder
  3181 + * Pointer to the NvEncodeAPI interface.
  3182 + * \param [in,out] lockInputBufferParams
  3183 + * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
  3184 + *
  3185 + * \return
  3186 + * \return
  3187 + * ::NV_ENC_SUCCESS \n
  3188 + * ::NV_ENC_ERR_INVALID_PTR \n
  3189 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3190 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3191 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3192 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3193 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3194 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3195 + * ::NV_ENC_ERR_LOCK_BUSY \n
  3196 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3197 + * ::NV_ENC_ERR_GENERIC \n
  3198 + *
  3199 + */
  3200 +NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  3201 +
  3202 +
  3203 +// NvUnlockInputBuffer
  3204 +/**
  3205 + * \brief Unlocks the input buffer
  3206 + *
  3207 + * This function is used to unlock the input buffer memory previously locked for
  3208 + * uploading YUV pixel data. The input buffer must be unlocked before being used
  3209 + * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
  3210 + *
  3211 + * \param [in] encoder
  3212 + * Pointer to the NvEncodeAPI interface.
  3213 + * \param [in] inputBuffer
  3214 + * Pointer to the input buffer that is being unlocked.
  3215 + *
  3216 + * \return
  3217 + * ::NV_ENC_SUCCESS \n
  3218 + * ::NV_ENC_ERR_INVALID_PTR \n
  3219 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3220 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3221 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3222 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3223 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3224 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3225 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3226 + * ::NV_ENC_ERR_GENERIC \n
  3227 + *
  3228 + *
  3229 + */
  3230 +NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  3231 +
  3232 +
  3233 +// NvEncGetEncodeStats
  3234 +/**
  3235 + * \brief Get encoding statistics.
  3236 + *
  3237 + * This function is used to retrieve the encoding statistics.
  3238 + * This API is not supported when encode device type is CUDA.
  3239 + *
  3240 + * \param [in] encoder
  3241 + * Pointer to the NvEncodeAPI interface.
  3242 + * \param [in,out] encodeStats
  3243 + * Pointer to the ::_NV_ENC_STAT structure.
  3244 + *
  3245 + * \return
  3246 + * ::NV_ENC_SUCCESS \n
  3247 + * ::NV_ENC_ERR_INVALID_PTR \n
  3248 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3249 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3250 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3251 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3252 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3253 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3254 + * ::NV_ENC_ERR_GENERIC \n
  3255 + *
  3256 + */
  3257 +NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
  3258 +
  3259 +
  3260 +// NvEncGetSequenceParams
  3261 +/**
  3262 + * \brief Get encoded sequence and picture header.
  3263 + *
  3264 + * This function can be used to retrieve the sequence and picture header out of
  3265 + * band. The client must call this function only after the encoder has been
  3266 + * initialized using ::NvEncInitializeEncoder() function. The client must
  3267 + * allocate the memory where the NvEncodeAPI interface can copy the bitstream
  3268 + * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
  3269 + * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  3270 + * The NvEncodeAPI interface will copy the bitstream header payload and returns
  3271 + * the actual size of the bitstream header in the field
  3272 + * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
  3273 + * The client must call ::NvEncGetSequenceParams() function from the same thread which is
  3274 + * being used to call ::NvEncEncodePicture() function.
  3275 + *
  3276 + * \param [in] encoder
  3277 + * Pointer to the NvEncodeAPI interface.
  3278 + * \param [in,out] sequenceParamPayload
  3279 + * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
  3280 + *
  3281 + * \return
  3282 + * ::NV_ENC_SUCCESS \n
  3283 + * ::NV_ENC_ERR_INVALID_PTR \n
  3284 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3285 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3286 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3287 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3288 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3289 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3290 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3291 + * ::NV_ENC_ERR_GENERIC \n
  3292 + *
  3293 + */
  3294 +NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3295 +
  3296 +// NvEncGetSequenceParamEx
  3297 +/**
  3298 + * \brief Get sequence and picture header.
  3299 + *
  3300 + * This function can be used to retrieve the sequence and picture header out of band, even when
  3301 + * encoder has not been initialized using ::NvEncInitializeEncoder() function.
  3302 + * The client must allocate the memory where the NvEncodeAPI interface can copy the bitstream
  3303 + * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
  3304 + * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  3305 + * If encoder has not been initialized using ::NvEncInitializeEncoder() function, client must
  3306 + * send NV_ENC_INITIALIZE_PARAMS as input. The NV_ENC_INITIALIZE_PARAMS passed must be same as the
  3307 + * one which will be used for initializing encoder using ::NvEncInitializeEncoder() function later.
  3308 + * If encoder is already initialized using ::NvEncInitializeEncoder() function, the provided
  3309 + * NV_ENC_INITIALIZE_PARAMS structure is ignored. The NvEncodeAPI interface will copy the bitstream
  3310 + * header payload and returns the actual size of the bitstream header in the field
  3311 + * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize. The client must call ::NvEncGetSequenceParamsEx()
  3312 + * function from the same thread which is being used to call ::NvEncEncodePicture() function.
  3313 + *
  3314 + * \param [in] encoder
  3315 + * Pointer to the NvEncodeAPI interface.
  3316 + * \param [in] encInitParams
  3317 + * Pointer to the _NV_ENC_INITIALIZE_PARAMS structure.
  3318 + * \param [in,out] sequenceParamPayload
  3319 + * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
  3320 + *
  3321 + * \return
  3322 + * ::NV_ENC_SUCCESS \n
  3323 + * ::NV_ENC_ERR_INVALID_PTR \n
  3324 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3325 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3326 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3327 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3328 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3329 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3330 + * ::NV_ENC_ERR_GENERIC \n
  3331 + *
  3332 + */
  3333 +NVENCSTATUS NVENCAPI NvEncGetSequenceParamEx (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3334 +
  3335 +// NvEncRegisterAsyncEvent
  3336 +/**
  3337 + * \brief Register event for notification to encoding completion.
  3338 + *
  3339 + * This function is used to register the completion event with NvEncodeAPI
  3340 + * interface. The event is required when the client has configured the encoder to
  3341 + * work in asynchronous mode. In this mode the client needs to send a completion
  3342 + * event with every output buffer. The NvEncodeAPI interface will signal the
  3343 + * completion of the encoding process using this event. Only after the event is
  3344 + * signaled the client can get the encoded data using ::NvEncLockBitstream() function.
  3345 + *
  3346 + * \param [in] encoder
  3347 + * Pointer to the NvEncodeAPI interface.
  3348 + * \param [in] eventParams
  3349 + * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  3350 + *
  3351 + * \return
  3352 + * ::NV_ENC_SUCCESS \n
  3353 + * ::NV_ENC_ERR_INVALID_PTR \n
  3354 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3355 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3356 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3357 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3358 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3359 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3360 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3361 + * ::NV_ENC_ERR_GENERIC \n
  3362 + *
  3363 + */
  3364 +NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3365 +
  3366 +
  3367 +// NvEncUnregisterAsyncEvent
  3368 +/**
  3369 + * \brief Unregister completion event.
  3370 + *
  3371 + * This function is used to unregister completion event which has been previously
  3372 + * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
  3373 + * all events before destroying the encoder using ::NvEncDestroyEncoder() function.
  3374 + *
  3375 + * \param [in] encoder
  3376 + * Pointer to the NvEncodeAPI interface.
  3377 + * \param [in] eventParams
  3378 + * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  3379 + *
  3380 + * \return
  3381 + * ::NV_ENC_SUCCESS \n
  3382 + * ::NV_ENC_ERR_INVALID_PTR \n
  3383 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3384 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3385 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3386 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3387 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3388 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3389 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3390 + * ::NV_ENC_ERR_GENERIC \n
  3391 + *
  3392 + */
  3393 +NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3394 +
  3395 +
  3396 +// NvEncMapInputResource
  3397 +/**
  3398 + * \brief Map an externally created input resource pointer for encoding.
  3399 + *
  3400 + * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
  3401 + * which can be used for encoding in the ::NvEncEncodePicture() function. The
  3402 + * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
  3403 + * The NvEncodeAPI interface also returns the buffer format of the mapped resource
  3404 + * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
  3405 + * This function provides synchronization guarantee that any graphics work submitted
  3406 + * on the input buffer is completed before the buffer is used for encoding. This is
  3407 + * also true for compute (i.e. CUDA) work, provided that the previous workload using
  3408 + * the input resource was submitted to the default stream.
  3409 + * The client should not access any input buffer while they are mapped by the encoder.
  3410 + * For D3D12 interface type, this function does not provide synchronization guarantee.
  3411 + *
  3412 + * \param [in] encoder
  3413 + * Pointer to the NvEncodeAPI interface.
  3414 + * \param [in,out] mapInputResParams
  3415 + * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
  3416 + *
  3417 + * \return
  3418 + * ::NV_ENC_SUCCESS \n
  3419 + * ::NV_ENC_ERR_INVALID_PTR \n
  3420 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3421 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3422 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3423 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3424 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3425 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3426 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3427 + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3428 + * ::NV_ENC_ERR_MAP_FAILED \n
  3429 + * ::NV_ENC_ERR_GENERIC \n
  3430 + *
  3431 + */
  3432 +NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  3433 +
  3434 +
  3435 +// NvEncUnmapInputResource
  3436 +/**
  3437 + * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
  3438 + *
  3439 + *
  3440 + * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
  3441 + * API. The mapping created using ::NvEncMapInputResource() should be invalidated
  3442 + * using this API before the external resource is destroyed by the client. The client
  3443 + * must unmap the buffer after ::NvEncLockBitstream() API returns successfully for encode
  3444 + * work submitted using the mapped input buffer.
  3445 + *
  3446 + *
  3447 + * \param [in] encoder
  3448 + * Pointer to the NvEncodeAPI interface.
  3449 + * \param [in] mappedInputBuffer
  3450 + * Pointer to the NV_ENC_INPUT_PTR
  3451 + *
  3452 + * \return
  3453 + * ::NV_ENC_SUCCESS \n
  3454 + * ::NV_ENC_ERR_INVALID_PTR \n
  3455 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3456 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3457 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3458 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3459 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3460 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3461 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3462 + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3463 + * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
  3464 + * ::NV_ENC_ERR_GENERIC \n
  3465 + *
  3466 + */
  3467 +NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  3468 +
  3469 +// NvEncDestroyEncoder
  3470 +/**
  3471 + * \brief Destroy Encoding Session
  3472 + *
  3473 + * Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
  3474 + * function. The client must flush the encoder before freeing any resources. In order
  3475 + * to flush the encoder the client must pass a NULL encode picture packet and either
  3476 + * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
  3477 + * for the flush event to be signaled by the encoder in asynchronous mode.
  3478 + * The client must free all the input and output resources created using the
  3479 + * NvEncodeAPI interface before destroying the encoder. If the client is operating
  3480 + * in asynchronous mode, it must also unregister the completion events previously
  3481 + * registered.
  3482 + *
  3483 + * \param [in] encoder
  3484 + * Pointer to the NvEncodeAPI interface.
  3485 + *
  3486 + * \return
  3487 + * ::NV_ENC_SUCCESS \n
  3488 + * ::NV_ENC_ERR_INVALID_PTR \n
  3489 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3490 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3491 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3492 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3493 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3494 + * ::NV_ENC_ERR_GENERIC \n
  3495 + *
  3496 + */
  3497 +NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
  3498 +
  3499 +// NvEncInvalidateRefFrames
  3500 +/**
  3501 + * \brief Invalidate reference frames
  3502 + *
  3503 + * Invalidates reference frame based on the time stamp provided by the client.
  3504 + * The encoder marks any reference frames or any frames which have been reconstructed
  3505 + * using the corrupt frame as invalid for motion estimation and uses older reference
  3506 + * frames for motion estimation. The encoded forces the current frame to be encoded
  3507 + * as an intra frame if no reference frames are left after invalidation process.
  3508 + * This is useful for low latency application for error resiliency. The client
  3509 + * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
  3510 + * that encoder can keep a backup of older reference frames in the DPB and can use them
  3511 + * for motion estimation when the newer reference frames have been invalidated.
  3512 + * This API can be called multiple times.
  3513 + *
  3514 + * \param [in] encoder
  3515 + * Pointer to the NvEncodeAPI interface.
  3516 + * \param [in] invalidRefFrameTimeStamp
  3517 + * Timestamp of the invalid reference frames which needs to be invalidated.
  3518 + *
  3519 + * \return
  3520 + * ::NV_ENC_SUCCESS \n
  3521 + * ::NV_ENC_ERR_INVALID_PTR \n
  3522 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3523 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3524 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3525 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3526 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3527 + * ::NV_ENC_ERR_GENERIC \n
  3528 + *
  3529 + */
  3530 +NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
  3531 +
  3532 +// NvEncOpenEncodeSessionEx
  3533 +/**
  3534 + * \brief Opens an encoding session.
  3535 + *
  3536 + * Opens an encoding session and returns a pointer to the encoder interface in
  3537 + * the \p **encoder parameter. The client should start encoding process by calling
  3538 + * this API first.
  3539 + * The client must pass a pointer to IDirect3DDevice9 device or CUDA context in the \p *device parameter.
  3540 + * For the OpenGL interface, \p device must be NULL. An OpenGL context must be current when
  3541 + * calling all NvEncodeAPI functions.
  3542 + * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
  3543 + * before exiting.
  3544 + *
  3545 + * \param [in] openSessionExParams
  3546 + * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
  3547 + * \param [out] encoder
  3548 + * Encode Session pointer to the NvEncodeAPI interface.
  3549 + * \return
  3550 + * ::NV_ENC_SUCCESS \n
  3551 + * ::NV_ENC_ERR_INVALID_PTR \n
  3552 + * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  3553 + * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  3554 + * ::NV_ENC_ERR_INVALID_DEVICE \n
  3555 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3556 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3557 + * ::NV_ENC_ERR_GENERIC \n
  3558 + *
  3559 + */
  3560 +NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  3561 +
  3562 +// NvEncRegisterResource
  3563 +/**
  3564 + * \brief Registers a resource with the Nvidia Video Encoder Interface.
  3565 + *
  3566 + * Registers a resource with the Nvidia Video Encoder Interface for book keeping.
  3567 + * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
  3568 + *
  3569 + * \param [in] encoder
  3570 + * Pointer to the NVEncodeAPI interface.
  3571 + *
  3572 + * \param [in] registerResParams
  3573 + * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
  3574 + *
  3575 + * \return
  3576 + * ::NV_ENC_SUCCESS \n
  3577 + * ::NV_ENC_ERR_INVALID_PTR \n
  3578 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3579 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3580 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3581 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3582 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3583 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3584 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3585 + * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
  3586 + * ::NV_ENC_ERR_GENERIC \n
  3587 + * ::NV_ENC_ERR_UNIMPLEMENTED \n
  3588 + *
  3589 + */
  3590 +NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  3591 +
  3592 +// NvEncUnregisterResource
  3593 +/**
  3594 + * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  3595 + *
  3596 + * Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  3597 + * The client is expected to unregister any resource that it has registered with the
  3598 + * Nvidia Video Encoder Interface before destroying the resource.
  3599 + *
  3600 + * \param [in] encoder
  3601 + * Pointer to the NVEncodeAPI interface.
  3602 + *
  3603 + * \param [in] registeredResource
  3604 + * The registered resource pointer that was returned in ::NvEncRegisterResource.
  3605 + *
  3606 + * \return
  3607 + * ::NV_ENC_SUCCESS \n
  3608 + * ::NV_ENC_ERR_INVALID_PTR \n
  3609 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3610 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3611 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3612 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3613 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3614 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3615 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3616 + * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3617 + * ::NV_ENC_ERR_GENERIC \n
  3618 + * ::NV_ENC_ERR_UNIMPLEMENTED \n
  3619 + *
  3620 + */
  3621 +NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
  3622 +
  3623 +// NvEncReconfigureEncoder
  3624 +/**
  3625 + * \brief Reconfigure an existing encoding session.
  3626 + *
  3627 + * Reconfigure an existing encoding session.
  3628 + * The client should call this API to change/reconfigure the parameter passed during
  3629 + * NvEncInitializeEncoder API call.
  3630 + * Currently Reconfiguration of following are not supported.
  3631 + * Change in GOP structure.
  3632 + * Change in sync-Async mode.
  3633 + * Change in MaxWidth & MaxHeight.
  3634 + * Change in PTD mode.
  3635 + *
  3636 + * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
  3637 + * is set while creating encoder session.
  3638 + *
  3639 + * \param [in] encoder
  3640 + * Pointer to the NVEncodeAPI interface.
  3641 + *
  3642 + * \param [in] reInitEncodeParams
  3643 + * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
  3644 + * \return
  3645 + * ::NV_ENC_SUCCESS \n
  3646 + * ::NV_ENC_ERR_INVALID_PTR \n
  3647 + * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  3648 + * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  3649 + * ::NV_ENC_ERR_INVALID_DEVICE \n
  3650 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3651 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3652 + * ::NV_ENC_ERR_GENERIC \n
  3653 + *
  3654 + */
  3655 +NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  3656 +
  3657 +
  3658 +
  3659 +// NvEncCreateMVBuffer
  3660 +/**
  3661 + * \brief Allocates output MV buffer for ME only mode.
  3662 + *
  3663 + * This function is used to allocate an output MV buffer. The size of the mvBuffer is
  3664 + * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
  3665 + * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
  3666 + * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
  3667 + * ::NvEncRunMotionEstimationOnly() API.
  3668 + * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  3669 + *
  3670 + * \param [in] encoder
  3671 + * Pointer to the NvEncodeAPI interface.
  3672 + * \param [in,out] createMVBufferParams
  3673 + * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure.
  3674 + *
  3675 + * \return
  3676 + * ::NV_ENC_SUCCESS \n
  3677 + * ::NV_ENC_ERR_INVALID_PTR \n
  3678 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3679 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3680 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3681 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3682 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3683 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3684 + * ::NV_ENC_ERR_GENERIC \n
  3685 + */
  3686 +NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  3687 +
  3688 +
  3689 +// NvEncDestroyMVBuffer
  3690 +/**
  3691 + * \brief Release an output MV buffer for ME only mode.
  3692 + *
  3693 + * This function is used to release the output MV buffer allocated using
  3694 + * the ::NvEncCreateMVBuffer() function. The client must release the output
  3695 + * mvBuffer using this function before destroying the encoder session.
  3696 + *
  3697 + * \param [in] encoder
  3698 + * Pointer to the NvEncodeAPI interface.
  3699 + * \param [in] mvBuffer
  3700 + * Pointer to the mvBuffer being released.
  3701 + *
  3702 + * \return
  3703 + * ::NV_ENC_SUCCESS \n
  3704 + * ::NV_ENC_ERR_INVALID_PTR \n
  3705 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3706 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3707 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3708 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3709 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3710 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3711 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3712 + * ::NV_ENC_ERR_GENERIC \n
  3713 + */
  3714 +NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  3715 +
  3716 +
  3717 +// NvEncRunMotionEstimationOnly
  3718 +/**
  3719 + * \brief Submit an input picture and reference frame for motion estimation in ME only mode.
  3720 + *
  3721 + * This function is used to submit the input frame and reference frame for motion
  3722 + * estimation. The ME parameters are passed using *meOnlyParams which is a pointer
  3723 + * to ::_NV_ENC_MEONLY_PARAMS structure.
  3724 + * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  3725 + * to get motion vector data.
  3726 + *
  3727 + * \param [in] encoder
  3728 + * Pointer to the NvEncodeAPI interface.
  3729 + * \param [in] meOnlyParams
  3730 + * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure.
  3731 + *
  3732 + * \return
  3733 + * ::NV_ENC_SUCCESS \n
  3734 + * ::NV_ENC_ERR_INVALID_PTR \n
  3735 + * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3736 + * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3737 + * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3738 + * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3739 + * ::NV_ENC_ERR_INVALID_PARAM \n
  3740 + * ::NV_ENC_ERR_INVALID_VERSION \n
  3741 + * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  3742 + * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3743 + * ::NV_ENC_ERR_GENERIC \n
  3744 + */
  3745 +NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  3746 +
  3747 +// NvEncodeAPIGetMaxSupportedVersion
  3748 +/**
  3749 + * \brief Get the largest NvEncodeAPI version supported by the driver.
  3750 + *
  3751 + * This function can be used by clients to determine if the driver supports
  3752 + * the NvEncodeAPI header the application was compiled with.
  3753 + *
  3754 + * \param [out] version
  3755 + * Pointer to the requested value. The 4 least significant bits in the returned
  3756 + * indicate the minor version and the rest of the bits indicate the major
  3757 + * version of the largest supported version.
  3758 + *
  3759 + * \return
  3760 + * ::NV_ENC_SUCCESS \n
  3761 + * ::NV_ENC_ERR_INVALID_PTR \n
  3762 + */
  3763 +NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version);
  3764 +
  3765 +
  3766 +// NvEncGetLastErrorString
  3767 +/**
  3768 + * \brief Get the description of the last error reported by the API.
  3769 + *
  3770 + * This function returns a null-terminated string that can be used by clients to better understand the reason
  3771 + * for failure of a previous API call.
  3772 + *
  3773 + * \param [in] encoder
  3774 + * Pointer to the NvEncodeAPI interface.
  3775 + *
  3776 + * \return
  3777 + * Pointer to buffer containing the details of the last error encountered by the API.
  3778 + */
  3779 +const char * NVENCAPI NvEncGetLastErrorString (void* encoder);
  3780 +
  3781 +
  3782 +/// \cond API PFN
  3783 +/*
  3784 + * Defines API function pointers
  3785 + */
  3786 +typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder);
  3787 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount);
  3788 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  3789 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  3790 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  3791 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  3792 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  3793 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  3794 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  3795 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  3796 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  3797 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIGEX) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
  3798 +typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  3799 +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  3800 +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  3801 +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  3802 +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  3803 +typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  3804 +typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  3805 +typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  3806 +typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  3807 +typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  3808 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats);
  3809 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3810 +typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3811 +typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3812 +typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  3813 +typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  3814 +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder);
  3815 +typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp);
  3816 +typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  3817 +typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  3818 +typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes);
  3819 +typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  3820 +
  3821 +typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  3822 +typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  3823 +typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  3824 +typedef const char * (NVENCAPI* PNVENCGETLASTERROR) (void* encoder);
  3825 +typedef NVENCSTATUS (NVENCAPI* PNVENCSETIOCUDASTREAMS) (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
  3826 +typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMEX) (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3827 +
  3828 +
  3829 +/// \endcond
  3830 +
  3831 +
  3832 +/** @} */ /* END ENCODE_FUNC */
  3833 +
  3834 +/**
  3835 + * \ingroup ENCODER_STRUCTURE
  3836 + * NV_ENCODE_API_FUNCTION_LIST
  3837 + */
  3838 +typedef struct _NV_ENCODE_API_FUNCTION_LIST
  3839 +{
  3840 + uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */
  3841 + uint32_t reserved; /**< [in]: Reserved and should be set to 0. */
  3842 + PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  3843 + PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */
  3844 + PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/
  3845 + PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */
  3846 + PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */
  3847 + PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */
  3848 + PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */
  3849 + PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */
  3850 + PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */
  3851 + PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */
  3852 + PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */
  3853 + PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */
  3854 + PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */
  3855 + PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */
  3856 + PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */
  3857 + PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */
  3858 + PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */
  3859 + PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */
  3860 + PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */
  3861 + PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */
  3862 + PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */
  3863 + PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */
  3864 + PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */
  3865 + PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */
  3866 + PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */
  3867 + PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */
  3868 + PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */
  3869 + PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */
  3870 + PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */
  3871 + PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  3872 + PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */
  3873 + PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */
  3874 + PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */
  3875 + void* reserved1;
  3876 + PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */
  3877 + PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */
  3878 + PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */
  3879 + PNVENCGETLASTERROR nvEncGetLastErrorString; /**< [out]: Client should access ::nvEncGetLastErrorString API through this pointer. */
  3880 + PNVENCSETIOCUDASTREAMS nvEncSetIOCudaStreams; /**< [out]: Client should access ::nvEncSetIOCudaStreams API through this pointer. */
  3881 + PNVENCGETENCODEPRESETCONFIGEX nvEncGetEncodePresetConfigEx; /**< [out]: Client should access ::NvEncGetEncodePresetConfigEx() API through this pointer. */
  3882 + PNVENCGETSEQUENCEPARAMEX nvEncGetSequenceParamEx; /**< [out]: Client should access ::NvEncGetSequenceParamEx() API through this pointer. */
  3883 + void* reserved2[277]; /**< [in]: Reserved and must be set to NULL */
  3884 +} NV_ENCODE_API_FUNCTION_LIST;
  3885 +
  3886 +/** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */
  3887 +#define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2)
  3888 +
  3889 +// NvEncodeAPICreateInstance
  3890 +/**
  3891 + * \ingroup ENCODE_FUNC
  3892 + * Entry Point to the NvEncodeAPI interface.
  3893 + *
  3894 + * Creates an instance of the NvEncodeAPI interface, and populates the
  3895 + * pFunctionList with function pointers to the API routines implemented by the
  3896 + * NvEncodeAPI interface.
  3897 + *
  3898 + * \param [out] functionList
  3899 + *
  3900 + * \return
  3901 + * ::NV_ENC_SUCCESS
  3902 + * ::NV_ENC_ERR_INVALID_PTR
  3903 + */
  3904 +NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList);
  3905 +
  3906 +#ifdef __cplusplus
  3907 +}
  3908 +#endif
  3909 +
  3910 +
  3911 +#endif
  3912 +
... ...