├── .gitignore ├── Makefile ├── README ├── ffnvcodec.pc.in └── include └── ffnvcodec ├── dynlink_cuda.h ├── dynlink_cuviddec.h ├── dynlink_loader.h ├── dynlink_nvcuvid.h └── nvEncodeAPI.h /.gitignore: -------------------------------------------------------------------------------- 1 | ffnvcodec.pc 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 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 | 24 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | FFmpeg version of headers required to interface with Nvidias codec APIs. 2 | 3 | Corresponds to Video Codec SDK version 13.0.19. 4 | 5 | Minimum required driver versions: 6 | Linux: 570.0 or newer 7 | Windows: 570.0 or newer 8 | -------------------------------------------------------------------------------- /ffnvcodec.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@@PREFIX@@ 2 | includedir=${prefix}/include 3 | 4 | Name: ffnvcodec 5 | Description: FFmpeg version of Nvidia Codec SDK headers 6 | Version: 13.0.19.1 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /include/ffnvcodec/dynlink_cuda.h: -------------------------------------------------------------------------------- 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 32 | #include 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_ARRAY_DESCRIPTOR_st { 363 | size_t Width; 364 | size_t Height; 365 | 366 | CUarray_format Format; 367 | unsigned int NumChannels; 368 | } CUDA_ARRAY_DESCRIPTOR; 369 | 370 | typedef struct CUDA_ARRAY3D_DESCRIPTOR_st { 371 | size_t Width; 372 | size_t Height; 373 | size_t Depth; 374 | 375 | CUarray_format Format; 376 | unsigned int NumChannels; 377 | unsigned int Flags; 378 | } CUDA_ARRAY3D_DESCRIPTOR; 379 | 380 | typedef struct CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC_st { 381 | unsigned long long offset; 382 | CUDA_ARRAY3D_DESCRIPTOR arrayDesc; 383 | unsigned int numLevels; 384 | unsigned int reserved[16]; 385 | } CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC; 386 | 387 | #define CU_EGL_FRAME_MAX_PLANES 3 388 | typedef struct CUeglFrame_st { 389 | union { 390 | CUarray pArray[CU_EGL_FRAME_MAX_PLANES]; 391 | void* pPitch[CU_EGL_FRAME_MAX_PLANES]; 392 | } frame; 393 | unsigned int width; 394 | unsigned int height; 395 | unsigned int depth; 396 | unsigned int pitch; 397 | unsigned int planeCount; 398 | unsigned int numChannels; 399 | CUeglFrameType frameType; 400 | CUeglColorFormat eglColorFormat; 401 | CUarray_format cuFormat; 402 | } CUeglFrame; 403 | 404 | #define CU_STREAM_DEFAULT 0 405 | #define CU_STREAM_NON_BLOCKING 1 406 | 407 | #define CU_EVENT_DEFAULT 0 408 | #define CU_EVENT_BLOCKING_SYNC 1 409 | #define CU_EVENT_DISABLE_TIMING 2 410 | 411 | #define CU_EVENT_WAIT_DEFAULT 0 412 | #define CU_EVENT_WAIT_EXTERNAL 1 413 | 414 | #define CU_TRSF_READ_AS_INTEGER 1 415 | 416 | typedef void CUDAAPI CUstreamCallback(CUstream hStream, CUresult status, void *userdata); 417 | 418 | typedef CUresult CUDAAPI tcuInit(unsigned int Flags); 419 | typedef CUresult CUDAAPI tcuDriverGetVersion(int *driverVersion); 420 | typedef CUresult CUDAAPI tcuDeviceGetCount(int *count); 421 | typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal); 422 | typedef CUresult CUDAAPI tcuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev); 423 | typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev); 424 | typedef CUresult CUDAAPI tcuDeviceGetUuid(CUuuid *uuid, CUdevice dev); 425 | typedef CUresult CUDAAPI tcuDeviceGetUuid_v2(CUuuid *uuid, CUdevice dev); 426 | typedef CUresult CUDAAPI tcuDeviceGetLuid(char* luid, unsigned int* deviceNodeMask, CUdevice dev); 427 | typedef CUresult CUDAAPI tcuDeviceGetByPCIBusId(CUdevice* dev, const char* pciBusId); 428 | typedef CUresult CUDAAPI tcuDeviceGetPCIBusId(char* pciBusId, int len, CUdevice dev); 429 | typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev); 430 | typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev); 431 | typedef CUresult CUDAAPI tcuCtxGetCurrent(CUcontext *pctx); 432 | typedef CUresult CUDAAPI tcuCtxSetLimit(CUlimit limit, size_t value); 433 | typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext pctx); 434 | typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx); 435 | typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx); 436 | typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize); 437 | typedef CUresult CUDAAPI tcuMemAllocPitch_v2(CUdeviceptr *dptr, size_t *pPitch, size_t WidthInBytes, size_t Height, unsigned int ElementSizeBytes); 438 | typedef CUresult CUDAAPI tcuMemAllocManaged(CUdeviceptr *dptr, size_t bytesize, unsigned int flags); 439 | typedef CUresult CUDAAPI tcuMemsetD8Async(CUdeviceptr dstDevice, unsigned char uc, size_t N, CUstream hStream); 440 | typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr); 441 | typedef CUresult CUDAAPI tcuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t bytesize); 442 | typedef CUresult CUDAAPI tcuMemcpyAsync(CUdeviceptr dst, CUdeviceptr src, size_t bytesize, CUstream hStream); 443 | typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy); 444 | typedef CUresult CUDAAPI tcuMemcpy2DAsync_v2(const CUDA_MEMCPY2D *pcopy, CUstream hStream); 445 | typedef CUresult CUDAAPI tcuMemcpyHtoD_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount); 446 | typedef CUresult CUDAAPI tcuMemcpyHtoDAsync_v2(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount, CUstream hStream); 447 | typedef CUresult CUDAAPI tcuMemcpyDtoH_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount); 448 | typedef CUresult CUDAAPI tcuMemcpyDtoHAsync_v2(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream); 449 | typedef CUresult CUDAAPI tcuMemcpyDtoD_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount); 450 | typedef CUresult CUDAAPI tcuMemcpyDtoDAsync_v2(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream); 451 | typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr); 452 | typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr); 453 | typedef CUresult CUDAAPI tcuCtxGetDevice(CUdevice *device); 454 | 455 | typedef CUresult CUDAAPI tcuDevicePrimaryCtxRetain(CUcontext *pctx, CUdevice dev); 456 | typedef CUresult CUDAAPI tcuDevicePrimaryCtxRelease(CUdevice dev); 457 | typedef CUresult CUDAAPI tcuDevicePrimaryCtxSetFlags(CUdevice dev, unsigned int flags); 458 | typedef CUresult CUDAAPI tcuDevicePrimaryCtxGetState(CUdevice dev, unsigned int *flags, int *active); 459 | typedef CUresult CUDAAPI tcuDevicePrimaryCtxReset(CUdevice dev); 460 | 461 | typedef CUresult CUDAAPI tcuStreamCreate(CUstream *phStream, unsigned int flags); 462 | typedef CUresult CUDAAPI tcuStreamQuery(CUstream hStream); 463 | typedef CUresult CUDAAPI tcuStreamSynchronize(CUstream hStream); 464 | typedef CUresult CUDAAPI tcuStreamDestroy_v2(CUstream hStream); 465 | typedef CUresult CUDAAPI tcuStreamAddCallback(CUstream hStream, CUstreamCallback *callback, void *userdata, unsigned int flags); 466 | typedef CUresult CUDAAPI tcuStreamWaitEvent(CUstream hStream, CUevent hEvent, unsigned int flags); 467 | typedef CUresult CUDAAPI tcuEventCreate(CUevent *phEvent, unsigned int flags); 468 | typedef CUresult CUDAAPI tcuEventDestroy_v2(CUevent hEvent); 469 | typedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent); 470 | typedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent); 471 | typedef CUresult CUDAAPI tcuEventRecord(CUevent hEvent, CUstream hStream); 472 | 473 | 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); 474 | typedef CUresult CUDAAPI tcuLinkCreate(unsigned int numOptions, CUjit_option* options, void** optionValues, CUlinkState* stateOut); 475 | typedef CUresult CUDAAPI tcuLinkAddData(CUlinkState state, CUjitInputType type, void* data, size_t size, const char* name, unsigned int numOptions, CUjit_option* options, void** optionValues); 476 | typedef CUresult CUDAAPI tcuLinkComplete(CUlinkState state, void** cubinOut, size_t* sizeOut); 477 | typedef CUresult CUDAAPI tcuLinkDestroy(CUlinkState state); 478 | typedef CUresult CUDAAPI tcuModuleLoadData(CUmodule* module, const void* image); 479 | typedef CUresult CUDAAPI tcuModuleUnload(CUmodule hmod); 480 | typedef CUresult CUDAAPI tcuModuleGetFunction(CUfunction* hfunc, CUmodule hmod, const char* name); 481 | typedef CUresult CUDAAPI tcuModuleGetGlobal(CUdeviceptr *dptr, size_t *bytes, CUmodule hmod, const char* name); 482 | typedef CUresult CUDAAPI tcuTexObjectCreate(CUtexObject* pTexObject, const CUDA_RESOURCE_DESC* pResDesc, const CUDA_TEXTURE_DESC* pTexDesc, const CUDA_RESOURCE_VIEW_DESC* pResViewDesc); 483 | typedef CUresult CUDAAPI tcuTexObjectDestroy(CUtexObject texObject); 484 | 485 | typedef CUresult CUDAAPI tcuGLGetDevices_v2(unsigned int* pCudaDeviceCount, CUdevice* pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList); 486 | typedef CUresult CUDAAPI tcuGraphicsGLRegisterImage(CUgraphicsResource* pCudaResource, GLuint image, GLenum target, unsigned int Flags); 487 | typedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource); 488 | typedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream); 489 | typedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource* resources, CUstream hStream); 490 | typedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray* pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel); 491 | typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer(CUdeviceptr *devPtrOut, size_t *sizeOut, CUgraphicsResource resource); 492 | 493 | typedef CUresult CUDAAPI tcuImportExternalMemory(CUexternalMemory* extMem_out, const CUDA_EXTERNAL_MEMORY_HANDLE_DESC* memHandleDesc); 494 | typedef CUresult CUDAAPI tcuDestroyExternalMemory(CUexternalMemory extMem); 495 | typedef CUresult CUDAAPI tcuExternalMemoryGetMappedBuffer(CUdeviceptr* devPtr, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_BUFFER_DESC* bufferDesc); 496 | typedef CUresult CUDAAPI tcuExternalMemoryGetMappedMipmappedArray(CUmipmappedArray* mipmap, CUexternalMemory extMem, const CUDA_EXTERNAL_MEMORY_MIPMAPPED_ARRAY_DESC* mipmapDesc); 497 | typedef CUresult CUDAAPI tcuMipmappedArrayGetLevel(CUarray* pLevelArray, CUmipmappedArray hMipmappedArray, unsigned int level); 498 | typedef CUresult CUDAAPI tcuMipmappedArrayDestroy(CUmipmappedArray hMipmappedArray); 499 | 500 | typedef CUresult CUDAAPI tcuImportExternalSemaphore(CUexternalSemaphore* extSem_out, const CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC* semHandleDesc); 501 | typedef CUresult CUDAAPI tcuDestroyExternalSemaphore(CUexternalSemaphore extSem); 502 | typedef CUresult CUDAAPI tcuSignalExternalSemaphoresAsync(const CUexternalSemaphore* extSemArray, const CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS* paramsArray, unsigned int numExtSems, CUstream stream); 503 | typedef CUresult CUDAAPI tcuWaitExternalSemaphoresAsync(const CUexternalSemaphore* extSemArray, const CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS* paramsArray, unsigned int numExtSems, CUstream stream); 504 | 505 | typedef CUresult CUDAAPI tcuArrayCreate(CUarray *pHandle, const CUDA_ARRAY_DESCRIPTOR* pAllocateArray); 506 | typedef CUresult CUDAAPI tcuArray3DCreate(CUarray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR* pAllocateArray); 507 | typedef CUresult CUDAAPI tcuArrayDestroy(CUarray hArray); 508 | 509 | typedef CUresult CUDAAPI tcuEGLStreamProducerConnect(CUeglStreamConnection* conn, ffnv_EGLStreamKHR stream, ffnv_EGLint width, ffnv_EGLint height); 510 | typedef CUresult CUDAAPI tcuEGLStreamProducerDisconnect(CUeglStreamConnection* conn); 511 | typedef CUresult CUDAAPI tcuEGLStreamConsumerDisconnect(CUeglStreamConnection* conn); 512 | typedef CUresult CUDAAPI tcuEGLStreamProducerPresentFrame(CUeglStreamConnection* conn, CUeglFrame eglframe, CUstream* pStream); 513 | typedef CUresult CUDAAPI tcuEGLStreamProducerReturnFrame(CUeglStreamConnection* conn, CUeglFrame* eglframe, CUstream* pStream); 514 | 515 | typedef CUresult CUDAAPI tcuD3D11GetDevice(CUdevice *device, void *dxgiAdapter); 516 | typedef CUresult CUDAAPI tcuD3D11GetDevices(unsigned int *deviceCountOut, CUdevice *devices, unsigned int deviceCount, void *d3d11device, CUd3d11DeviceList listType); 517 | typedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource(CUgraphicsResource *cudaResourceOut, void *d3d11Resource, unsigned int flags); 518 | #endif 519 | -------------------------------------------------------------------------------- /include/ffnvcodec/dynlink_cuviddec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This copyright notice applies to this header file only: 3 | * 4 | * Copyright (c) 2010-2024 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 13 44 | #define NVDECAPI_MINOR_VERSION 0 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_NV16=4, /**< Semi-Planar YUV 422 [Y plane followed by interleaved UV plane] */ 101 | cudaVideoSurfaceFormat_P216=5 /**< 16 bit Semi-Planar YUV 422[Y plane followed by interleaved UV plane]. 102 | Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0) */ 103 | } cudaVideoSurfaceFormat; 104 | 105 | /******************************************************************************************************************/ 106 | //! \enum cudaVideoDeinterlaceMode 107 | //! Deinterlacing mode enums 108 | //! These enums are used in CUVIDDECODECREATEINFO structure 109 | //! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing 110 | //! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes 111 | /******************************************************************************************************************/ 112 | typedef enum cudaVideoDeinterlaceMode_enum { 113 | cudaVideoDeinterlaceMode_Weave=0, /**< Weave both fields (no deinterlacing) */ 114 | cudaVideoDeinterlaceMode_Bob, /**< Drop one field */ 115 | cudaVideoDeinterlaceMode_Adaptive /**< Adaptive deinterlacing */ 116 | } cudaVideoDeinterlaceMode; 117 | 118 | /**************************************************************************************************************/ 119 | //! \enum cudaVideoChromaFormat 120 | //! Chroma format enums 121 | //! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures 122 | /**************************************************************************************************************/ 123 | typedef enum cudaVideoChromaFormat_enum { 124 | cudaVideoChromaFormat_Monochrome=0, /**< MonoChrome */ 125 | cudaVideoChromaFormat_420, /**< YUV 4:2:0 */ 126 | cudaVideoChromaFormat_422, /**< YUV 4:2:2 */ 127 | cudaVideoChromaFormat_444 /**< YUV 4:4:4 */ 128 | } cudaVideoChromaFormat; 129 | 130 | /*************************************************************************************************************/ 131 | //! \enum cudaVideoCreateFlags 132 | //! Decoder flag enums to select preferred decode path 133 | //! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible 134 | /*************************************************************************************************************/ 135 | typedef enum cudaVideoCreateFlags_enum { 136 | cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */ 137 | cudaVideoCreate_PreferCUDA = 0x01, /**< Use CUDA-based decoder (requires valid vidLock object for multi-threading) */ 138 | cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */ 139 | cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */ 140 | } cudaVideoCreateFlags; 141 | 142 | 143 | /*************************************************************************/ 144 | //! \enum cuvidDecodeStatus 145 | //! Decode status enums 146 | //! These enums are used in CUVIDGETDECODESTATUS structure 147 | /*************************************************************************/ 148 | typedef enum cuvidDecodeStatus_enum 149 | { 150 | cuvidDecodeStatus_Invalid = 0, // Decode status is not valid 151 | cuvidDecodeStatus_InProgress = 1, // Decode is in progress 152 | cuvidDecodeStatus_Success = 2, // Decode is completed without any errors 153 | // 3 to 7 enums are reserved for future use 154 | cuvidDecodeStatus_Error = 8, // Decode is completed with an error (error is not concealed) 155 | cuvidDecodeStatus_Error_Concealed = 9, // Decode is completed with an error and error is concealed 156 | } cuvidDecodeStatus; 157 | 158 | /**************************************************************************************************************/ 159 | //! \struct CUVIDDECODECAPS; 160 | //! This structure is used in cuvidGetDecoderCaps API 161 | /**************************************************************************************************************/ 162 | typedef struct _CUVIDDECODECAPS 163 | { 164 | cudaVideoCodec eCodecType; /**< IN: cudaVideoCodec_XXX */ 165 | cudaVideoChromaFormat eChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */ 166 | unsigned int nBitDepthMinus8; /**< IN: The Value "BitDepth minus 8" */ 167 | unsigned int reserved1[3]; /**< Reserved for future use - set to zero */ 168 | 169 | unsigned char bIsSupported; /**< OUT: 1 if codec supported, 0 if not supported */ 170 | unsigned char nNumNVDECs; /**< OUT: Number of NVDECs that can support IN params */ 171 | unsigned short nOutputFormatMask; /**< OUT: each bit represents corresponding cudaVideoSurfaceFormat enum */ 172 | unsigned int nMaxWidth; /**< OUT: Max supported coded width in pixels */ 173 | unsigned int nMaxHeight; /**< OUT: Max supported coded height in pixels */ 174 | unsigned int nMaxMBCount; /**< OUT: Max supported macroblock count 175 | CodedWidth*CodedHeight/256 must be <= nMaxMBCount */ 176 | unsigned short nMinWidth; /**< OUT: Min supported coded width in pixels */ 177 | unsigned short nMinHeight; /**< OUT: Min supported coded height in pixels */ 178 | unsigned char bIsHistogramSupported; /**< OUT: 1 if Y component histogram output is supported, 0 if not 179 | Note: histogram is computed on original picture data before 180 | any post-processing like scaling, cropping, etc. is applied */ 181 | unsigned char nCounterBitDepth; /**< OUT: histogram counter bit depth */ 182 | unsigned short nMaxHistogramBins; /**< OUT: Max number of histogram bins */ 183 | unsigned int reserved3[10]; /**< Reserved for future use - set to zero */ 184 | } CUVIDDECODECAPS; 185 | 186 | /**************************************************************************************************************/ 187 | //! \struct CUVIDDECODECREATEINFO 188 | //! This structure is used in cuvidCreateDecoder API 189 | /**************************************************************************************************************/ 190 | typedef struct _CUVIDDECODECREATEINFO 191 | { 192 | tcu_ulong ulWidth; /**< IN: Coded sequence width in pixels */ 193 | tcu_ulong ulHeight; /**< IN: Coded sequence height in pixels */ 194 | tcu_ulong ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ 195 | cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */ 196 | cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */ 197 | tcu_ulong ulCreationFlags; /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX) */ 198 | tcu_ulong bitDepthMinus8; /**< IN: The value "BitDepth minus 8" */ 199 | tcu_ulong ulIntraDecodeOnly; /**< IN: Set 1 only if video has all intra frames (default value is 0). This will 200 | optimize video memory for Intra frames only decoding. The support is limited 201 | to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which 202 | are not supported. However decoding might fail if the flag is enabled in case 203 | of supported codecs for regular bit streams having P and/or B frames. */ 204 | tcu_ulong ulMaxWidth; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder */ 205 | tcu_ulong ulMaxHeight; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */ 206 | tcu_ulong Reserved1; /**< Reserved for future use - set to zero */ 207 | /** 208 | * IN: area of the frame that should be displayed 209 | */ 210 | struct { 211 | short left; 212 | short top; 213 | short right; 214 | short bottom; 215 | } display_area; 216 | 217 | cudaVideoSurfaceFormat OutputFormat; /**< IN: cudaVideoSurfaceFormat_XXX */ 218 | cudaVideoDeinterlaceMode DeinterlaceMode; /**< IN: cudaVideoDeinterlaceMode_XXX */ 219 | tcu_ulong ulTargetWidth; /**< IN: Post-processed output width (Should be aligned to 2) */ 220 | tcu_ulong ulTargetHeight; /**< IN: Post-processed output height (Should be aligned to 2) */ 221 | tcu_ulong ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped */ 222 | CUvideoctxlock vidLock; /**< IN: If non-NULL, context lock used for synchronizing ownership of 223 | the cuda context. Needed for cudaVideoCreate_PreferCUDA decode */ 224 | /** 225 | * IN: target rectangle in the output frame (for aspect ratio conversion) 226 | * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used 227 | */ 228 | struct { 229 | short left; 230 | short top; 231 | short right; 232 | short bottom; 233 | } target_rect; 234 | 235 | tcu_ulong enableHistogram; /**< IN: enable histogram output, if supported */ 236 | tcu_ulong Reserved2[4]; /**< Reserved for future use - set to zero */ 237 | } CUVIDDECODECREATEINFO; 238 | 239 | /*********************************************************/ 240 | //! \struct CUVIDH264DPBENTRY 241 | //! H.264 DPB entry 242 | //! This structure is used in CUVIDH264PICPARAMS structure 243 | /*********************************************************/ 244 | typedef struct _CUVIDH264DPBENTRY 245 | { 246 | int PicIdx; /**< picture index of reference frame */ 247 | int FrameIdx; /**< frame_num(short-term) or LongTermFrameIdx(long-term) */ 248 | int is_long_term; /**< 0=short term reference, 1=long term reference */ 249 | int not_existing; /**< non-existing reference frame (corresponding PicIdx should be set to -1) */ 250 | int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields */ 251 | int FieldOrderCnt[2]; /**< field order count of top and bottom fields */ 252 | } CUVIDH264DPBENTRY; 253 | 254 | /************************************************************/ 255 | //! \struct CUVIDH264MVCEXT 256 | //! H.264 MVC picture parameters ext 257 | //! This structure is used in CUVIDH264PICPARAMS structure 258 | /************************************************************/ 259 | typedef struct _CUVIDH264MVCEXT 260 | { 261 | int num_views_minus1; /**< Max number of coded views minus 1 in video : Range - 0 to 1023 */ 262 | int view_id; /**< view identifier */ 263 | unsigned char inter_view_flag; /**< 1 if used for inter-view prediction, 0 if not */ 264 | unsigned char num_inter_view_refs_l0; /**< number of inter-view ref pics in RefPicList0 */ 265 | unsigned char num_inter_view_refs_l1; /**< number of inter-view ref pics in RefPicList1 */ 266 | unsigned char MVCReserved8Bits; /**< Reserved bits */ 267 | int InterViewRefsL0[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList0 */ 268 | int InterViewRefsL1[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList1 */ 269 | } CUVIDH264MVCEXT; 270 | 271 | /*********************************************************/ 272 | //! \struct CUVIDH264SVCEXT 273 | //! H.264 SVC picture parameters ext 274 | //! This structure is used in CUVIDH264PICPARAMS structure 275 | /*********************************************************/ 276 | typedef struct _CUVIDH264SVCEXT 277 | { 278 | unsigned char profile_idc; 279 | unsigned char level_idc; 280 | unsigned char DQId; 281 | unsigned char DQIdMax; 282 | unsigned char disable_inter_layer_deblocking_filter_idc; 283 | unsigned char ref_layer_chroma_phase_y_plus1; 284 | signed char inter_layer_slice_alpha_c0_offset_div2; 285 | signed char inter_layer_slice_beta_offset_div2; 286 | 287 | unsigned short DPBEntryValidFlag; 288 | unsigned char inter_layer_deblocking_filter_control_present_flag; 289 | unsigned char extended_spatial_scalability_idc; 290 | unsigned char adaptive_tcoeff_level_prediction_flag; 291 | unsigned char slice_header_restriction_flag; 292 | unsigned char chroma_phase_x_plus1_flag; 293 | unsigned char chroma_phase_y_plus1; 294 | 295 | unsigned char tcoeff_level_prediction_flag; 296 | unsigned char constrained_intra_resampling_flag; 297 | unsigned char ref_layer_chroma_phase_x_plus1_flag; 298 | unsigned char store_ref_base_pic_flag; 299 | unsigned char Reserved8BitsA; 300 | unsigned char Reserved8BitsB; 301 | 302 | short scaled_ref_layer_left_offset; 303 | short scaled_ref_layer_top_offset; 304 | short scaled_ref_layer_right_offset; 305 | short scaled_ref_layer_bottom_offset; 306 | unsigned short Reserved16Bits; 307 | struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded. 308 | Linked list ends at the target layer. */ 309 | int bRefBaseLayer; /**< whether to store ref base pic */ 310 | } CUVIDH264SVCEXT; 311 | 312 | /******************************************************/ 313 | //! \struct CUVIDH264PICPARAMS 314 | //! H.264 picture parameters 315 | //! This structure is used in CUVIDPICPARAMS structure 316 | /******************************************************/ 317 | typedef struct _CUVIDH264PICPARAMS 318 | { 319 | // SPS 320 | int log2_max_frame_num_minus4; 321 | int pic_order_cnt_type; 322 | int log2_max_pic_order_cnt_lsb_minus4; 323 | int delta_pic_order_always_zero_flag; 324 | int frame_mbs_only_flag; 325 | int direct_8x8_inference_flag; 326 | int num_ref_frames; 327 | unsigned char residual_colour_transform_flag; 328 | unsigned char bit_depth_luma_minus8; 329 | unsigned char bit_depth_chroma_minus8; 330 | unsigned char qpprime_y_zero_transform_bypass_flag; 331 | // PPS 332 | int entropy_coding_mode_flag; 333 | int pic_order_present_flag; 334 | int num_ref_idx_l0_active_minus1; 335 | int num_ref_idx_l1_active_minus1; 336 | int weighted_pred_flag; 337 | int weighted_bipred_idc; 338 | int pic_init_qp_minus26; 339 | int deblocking_filter_control_present_flag; 340 | int redundant_pic_cnt_present_flag; 341 | int transform_8x8_mode_flag; 342 | int MbaffFrameFlag; 343 | int constrained_intra_pred_flag; 344 | int chroma_qp_index_offset; 345 | int second_chroma_qp_index_offset; 346 | int ref_pic_flag; 347 | int frame_num; 348 | int CurrFieldOrderCnt[2]; 349 | // DPB 350 | CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB 351 | // Quantization Matrices (raster-order) 352 | unsigned char WeightScale4x4[6][16]; 353 | unsigned char WeightScale8x8[2][64]; 354 | // FMO/ASO 355 | unsigned char fmo_aso_enable; 356 | unsigned char num_slice_groups_minus1; 357 | unsigned char slice_group_map_type; 358 | signed char pic_init_qs_minus26; 359 | unsigned int slice_group_change_rate_minus1; 360 | union 361 | { 362 | unsigned long long slice_group_map_addr; 363 | const unsigned char *pMb2SliceGroupMap; 364 | } fmo; 365 | unsigned int mb_adaptive_frame_field_flag : 2; // bit 0 represent SPS flag mb_adaptive_frame_field_flag 366 | // if bit 1 is not set, flag is ignored. Bit 1 is set to maintain backward compatibility 367 | unsigned int Reserved1 : 30; 368 | unsigned int Reserved[11]; 369 | // SVC/MVC 370 | union 371 | { 372 | CUVIDH264MVCEXT mvcext; 373 | CUVIDH264SVCEXT svcext; 374 | }; 375 | } CUVIDH264PICPARAMS; 376 | 377 | 378 | /********************************************************/ 379 | //! \struct CUVIDMPEG2PICPARAMS 380 | //! MPEG-2 picture parameters 381 | //! This structure is used in CUVIDPICPARAMS structure 382 | /********************************************************/ 383 | typedef struct _CUVIDMPEG2PICPARAMS 384 | { 385 | int ForwardRefIdx; // Picture index of forward reference (P/B-frames) 386 | int BackwardRefIdx; // Picture index of backward reference (B-frames) 387 | int picture_coding_type; 388 | int full_pel_forward_vector; 389 | int full_pel_backward_vector; 390 | int f_code[2][2]; 391 | int intra_dc_precision; 392 | int frame_pred_frame_dct; 393 | int concealment_motion_vectors; 394 | int q_scale_type; 395 | int intra_vlc_format; 396 | int alternate_scan; 397 | int top_field_first; 398 | // Quantization matrices (raster order) 399 | unsigned char QuantMatrixIntra[64]; 400 | unsigned char QuantMatrixInter[64]; 401 | } CUVIDMPEG2PICPARAMS; 402 | 403 | // MPEG-4 has VOP types instead of Picture types 404 | #define I_VOP 0 405 | #define P_VOP 1 406 | #define B_VOP 2 407 | #define S_VOP 3 408 | 409 | /*******************************************************/ 410 | //! \struct CUVIDMPEG4PICPARAMS 411 | //! MPEG-4 picture parameters 412 | //! This structure is used in CUVIDPICPARAMS structure 413 | /*******************************************************/ 414 | typedef struct _CUVIDMPEG4PICPARAMS 415 | { 416 | int ForwardRefIdx; // Picture index of forward reference (P/B-frames) 417 | int BackwardRefIdx; // Picture index of backward reference (B-frames) 418 | // VOL 419 | int video_object_layer_width; 420 | int video_object_layer_height; 421 | int vop_time_increment_bitcount; 422 | int top_field_first; 423 | int resync_marker_disable; 424 | int quant_type; 425 | int quarter_sample; 426 | int short_video_header; 427 | int divx_flags; 428 | // VOP 429 | int vop_coding_type; 430 | int vop_coded; 431 | int vop_rounding_type; 432 | int alternate_vertical_scan_flag; 433 | int interlaced; 434 | int vop_fcode_forward; 435 | int vop_fcode_backward; 436 | int trd[2]; 437 | int trb[2]; 438 | // Quantization matrices (raster order) 439 | unsigned char QuantMatrixIntra[64]; 440 | unsigned char QuantMatrixInter[64]; 441 | int gmc_enabled; 442 | } CUVIDMPEG4PICPARAMS; 443 | 444 | /********************************************************/ 445 | //! \struct CUVIDVC1PICPARAMS 446 | //! VC1 picture parameters 447 | //! This structure is used in CUVIDPICPARAMS structure 448 | /********************************************************/ 449 | typedef struct _CUVIDVC1PICPARAMS 450 | { 451 | int ForwardRefIdx; /**< Picture index of forward reference (P/B-frames) */ 452 | int BackwardRefIdx; /**< Picture index of backward reference (B-frames) */ 453 | int FrameWidth; /**< Actual frame width */ 454 | int FrameHeight; /**< Actual frame height */ 455 | // PICTURE 456 | int intra_pic_flag; /**< Set to 1 for I,BI frames */ 457 | int ref_pic_flag; /**< Set to 1 for I,P frames */ 458 | int progressive_fcm; /**< Progressive frame */ 459 | // SEQUENCE 460 | int profile; 461 | int postprocflag; 462 | int pulldown; 463 | int interlace; 464 | int tfcntrflag; 465 | int finterpflag; 466 | int psf; 467 | int multires; 468 | int syncmarker; 469 | int rangered; 470 | int maxbframes; 471 | // ENTRYPOINT 472 | int panscan_flag; 473 | int refdist_flag; 474 | int extended_mv; 475 | int dquant; 476 | int vstransform; 477 | int loopfilter; 478 | int fastuvmc; 479 | int overlap; 480 | int quantizer; 481 | int extended_dmv; 482 | int range_mapy_flag; 483 | int range_mapy; 484 | int range_mapuv_flag; 485 | int range_mapuv; 486 | int rangeredfrm; // range reduction state 487 | } CUVIDVC1PICPARAMS; 488 | 489 | /***********************************************************/ 490 | //! \struct CUVIDJPEGPICPARAMS 491 | //! JPEG picture parameters 492 | //! This structure is used in CUVIDPICPARAMS structure 493 | /***********************************************************/ 494 | typedef struct _CUVIDJPEGPICPARAMS 495 | { 496 | unsigned char numComponents; 497 | unsigned char bitDepth; 498 | unsigned char quantizationTableSelector[4]; 499 | unsigned int scanOffset[4]; 500 | unsigned int scanSize[4]; 501 | 502 | unsigned short restartInterval; 503 | unsigned char componentIdentifier[4]; 504 | 505 | unsigned char hasQMatrix; 506 | unsigned char hasHuffman; 507 | unsigned short quantvals[4][64]; 508 | 509 | unsigned char bits_ac[4][16]; 510 | unsigned char table_ac[4][256]; // there can only be max of 162 ac symbols 511 | 512 | unsigned char bits_dc[4][16]; 513 | unsigned char table_dc[4][256]; // there can only be max of 12 dc symbols 514 | } CUVIDJPEGPICPARAMS; 515 | 516 | 517 | /*******************************************************/ 518 | //! \struct CUVIDHEVCPICPARAMS 519 | //! HEVC picture parameters 520 | //! This structure is used in CUVIDPICPARAMS structure 521 | /*******************************************************/ 522 | typedef struct _CUVIDHEVCPICPARAMS 523 | { 524 | // sps 525 | int pic_width_in_luma_samples; 526 | int pic_height_in_luma_samples; 527 | unsigned char log2_min_luma_coding_block_size_minus3; 528 | unsigned char log2_diff_max_min_luma_coding_block_size; 529 | unsigned char log2_min_transform_block_size_minus2; 530 | unsigned char log2_diff_max_min_transform_block_size; 531 | unsigned char pcm_enabled_flag; 532 | unsigned char log2_min_pcm_luma_coding_block_size_minus3; 533 | unsigned char log2_diff_max_min_pcm_luma_coding_block_size; 534 | unsigned char pcm_sample_bit_depth_luma_minus1; 535 | 536 | unsigned char pcm_sample_bit_depth_chroma_minus1; 537 | unsigned char pcm_loop_filter_disabled_flag; 538 | unsigned char strong_intra_smoothing_enabled_flag; 539 | unsigned char max_transform_hierarchy_depth_intra; 540 | unsigned char max_transform_hierarchy_depth_inter; 541 | unsigned char amp_enabled_flag; 542 | unsigned char separate_colour_plane_flag; 543 | unsigned char log2_max_pic_order_cnt_lsb_minus4; 544 | 545 | unsigned char num_short_term_ref_pic_sets; 546 | unsigned char long_term_ref_pics_present_flag; 547 | unsigned char num_long_term_ref_pics_sps; 548 | unsigned char sps_temporal_mvp_enabled_flag; 549 | unsigned char sample_adaptive_offset_enabled_flag; 550 | unsigned char scaling_list_enable_flag; 551 | unsigned char IrapPicFlag; 552 | unsigned char IdrPicFlag; 553 | 554 | unsigned char bit_depth_luma_minus8; 555 | unsigned char bit_depth_chroma_minus8; 556 | //sps/pps extension fields 557 | unsigned char log2_max_transform_skip_block_size_minus2; 558 | unsigned char log2_sao_offset_scale_luma; 559 | unsigned char log2_sao_offset_scale_chroma; 560 | unsigned char high_precision_offsets_enabled_flag; 561 | unsigned char reserved1[10]; 562 | 563 | // pps 564 | unsigned char dependent_slice_segments_enabled_flag; 565 | unsigned char slice_segment_header_extension_present_flag; 566 | unsigned char sign_data_hiding_enabled_flag; 567 | unsigned char cu_qp_delta_enabled_flag; 568 | unsigned char diff_cu_qp_delta_depth; 569 | signed char init_qp_minus26; 570 | signed char pps_cb_qp_offset; 571 | signed char pps_cr_qp_offset; 572 | 573 | unsigned char constrained_intra_pred_flag; 574 | unsigned char weighted_pred_flag; 575 | unsigned char weighted_bipred_flag; 576 | unsigned char transform_skip_enabled_flag; 577 | unsigned char transquant_bypass_enabled_flag; 578 | unsigned char entropy_coding_sync_enabled_flag; 579 | unsigned char log2_parallel_merge_level_minus2; 580 | unsigned char num_extra_slice_header_bits; 581 | 582 | unsigned char loop_filter_across_tiles_enabled_flag; 583 | unsigned char loop_filter_across_slices_enabled_flag; 584 | unsigned char output_flag_present_flag; 585 | unsigned char num_ref_idx_l0_default_active_minus1; 586 | unsigned char num_ref_idx_l1_default_active_minus1; 587 | unsigned char lists_modification_present_flag; 588 | unsigned char cabac_init_present_flag; 589 | unsigned char pps_slice_chroma_qp_offsets_present_flag; 590 | 591 | unsigned char deblocking_filter_override_enabled_flag; 592 | unsigned char pps_deblocking_filter_disabled_flag; 593 | signed char pps_beta_offset_div2; 594 | signed char pps_tc_offset_div2; 595 | unsigned char tiles_enabled_flag; 596 | unsigned char uniform_spacing_flag; 597 | unsigned char num_tile_columns_minus1; 598 | unsigned char num_tile_rows_minus1; 599 | 600 | unsigned short column_width_minus1[21]; 601 | unsigned short row_height_minus1[21]; 602 | 603 | // sps and pps extension HEVC-main 444 604 | unsigned char sps_range_extension_flag; 605 | unsigned char transform_skip_rotation_enabled_flag; 606 | unsigned char transform_skip_context_enabled_flag; 607 | unsigned char implicit_rdpcm_enabled_flag; 608 | 609 | unsigned char explicit_rdpcm_enabled_flag; 610 | unsigned char extended_precision_processing_flag; 611 | unsigned char intra_smoothing_disabled_flag; 612 | unsigned char persistent_rice_adaptation_enabled_flag; 613 | 614 | unsigned char cabac_bypass_alignment_enabled_flag; 615 | unsigned char pps_range_extension_flag; 616 | unsigned char cross_component_prediction_enabled_flag; 617 | unsigned char chroma_qp_offset_list_enabled_flag; 618 | 619 | unsigned char diff_cu_chroma_qp_offset_depth; 620 | unsigned char chroma_qp_offset_list_len_minus1; 621 | signed char cb_qp_offset_list[6]; 622 | 623 | signed char cr_qp_offset_list[6]; 624 | unsigned char reserved2[2]; 625 | 626 | unsigned int reserved3[8]; 627 | 628 | // RefPicSets 629 | int NumBitsForShortTermRPSInSlice; 630 | int NumDeltaPocsOfRefRpsIdx; 631 | int NumPocTotalCurr; 632 | int NumPocStCurrBefore; 633 | int NumPocStCurrAfter; 634 | int NumPocLtCurr; 635 | int CurrPicOrderCntVal; 636 | int RefPicIdx[16]; // [refpic] Indices of valid reference pictures (-1 if unused for reference) 637 | int PicOrderCntVal[16]; // [refpic] 638 | unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference 639 | unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15) 640 | unsigned char RefPicSetStCurrAfter[8]; // [0..NumPocStCurrAfter-1] -> refpic (0..15) 641 | unsigned char RefPicSetLtCurr[8]; // [0..NumPocLtCurr-1] -> refpic (0..15) 642 | unsigned char RefPicSetInterLayer0[8]; 643 | unsigned char RefPicSetInterLayer1[8]; 644 | unsigned int reserved4[12]; 645 | 646 | // scaling lists (diag order) 647 | unsigned char ScalingList4x4[6][16]; // [matrixId][i] 648 | unsigned char ScalingList8x8[6][64]; // [matrixId][i] 649 | unsigned char ScalingList16x16[6][64]; // [matrixId][i] 650 | unsigned char ScalingList32x32[2][64]; // [matrixId][i] 651 | unsigned char ScalingListDCCoeff16x16[6]; // [matrixId] 652 | unsigned char ScalingListDCCoeff32x32[2]; // [matrixId] 653 | } CUVIDHEVCPICPARAMS; 654 | 655 | 656 | /***********************************************************/ 657 | //! \struct CUVIDVP8PICPARAMS 658 | //! VP8 picture parameters 659 | //! This structure is used in CUVIDPICPARAMS structure 660 | /***********************************************************/ 661 | typedef struct _CUVIDVP8PICPARAMS 662 | { 663 | int width; 664 | int height; 665 | unsigned int first_partition_size; 666 | //Frame Indexes 667 | unsigned char LastRefIdx; 668 | unsigned char GoldenRefIdx; 669 | unsigned char AltRefIdx; 670 | union { 671 | struct { 672 | unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME */ 673 | unsigned char version : 3; 674 | unsigned char show_frame : 1; 675 | unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */ 676 | unsigned char Reserved2Bits : 2; 677 | }vp8_frame_tag; 678 | unsigned char wFrameTagFlags; 679 | }; 680 | unsigned char Reserved1[4]; 681 | unsigned int Reserved2[3]; 682 | } CUVIDVP8PICPARAMS; 683 | 684 | /***********************************************************/ 685 | //! \struct CUVIDVP9PICPARAMS 686 | //! VP9 picture parameters 687 | //! This structure is used in CUVIDPICPARAMS structure 688 | /***********************************************************/ 689 | typedef struct _CUVIDVP9PICPARAMS 690 | { 691 | unsigned int width; 692 | unsigned int height; 693 | 694 | //Frame Indices 695 | unsigned char LastRefIdx; 696 | unsigned char GoldenRefIdx; 697 | unsigned char AltRefIdx; 698 | unsigned char colorSpace; 699 | 700 | unsigned short profile : 3; 701 | unsigned short frameContextIdx : 2; 702 | unsigned short frameType : 1; 703 | unsigned short showFrame : 1; 704 | unsigned short errorResilient : 1; 705 | unsigned short frameParallelDecoding : 1; 706 | unsigned short subSamplingX : 1; 707 | unsigned short subSamplingY : 1; 708 | unsigned short intraOnly : 1; 709 | unsigned short allow_high_precision_mv : 1; 710 | unsigned short refreshEntropyProbs : 1; 711 | unsigned short reserved2Bits : 2; 712 | 713 | unsigned short reserved16Bits; 714 | 715 | unsigned char refFrameSignBias[4]; 716 | 717 | unsigned char bitDepthMinus8Luma; 718 | unsigned char bitDepthMinus8Chroma; 719 | unsigned char loopFilterLevel; 720 | unsigned char loopFilterSharpness; 721 | 722 | unsigned char modeRefLfEnabled; 723 | unsigned char log2_tile_columns; 724 | unsigned char log2_tile_rows; 725 | 726 | unsigned char segmentEnabled : 1; 727 | unsigned char segmentMapUpdate : 1; 728 | unsigned char segmentMapTemporalUpdate : 1; 729 | unsigned char segmentFeatureMode : 1; 730 | unsigned char reserved4Bits : 4; 731 | 732 | 733 | unsigned char segmentFeatureEnable[8][4]; 734 | short segmentFeatureData[8][4]; 735 | unsigned char mb_segment_tree_probs[7]; 736 | unsigned char segment_pred_probs[3]; 737 | unsigned char reservedSegment16Bits[2]; 738 | 739 | int qpYAc; 740 | int qpYDc; 741 | int qpChDc; 742 | int qpChAc; 743 | 744 | unsigned int activeRefIdx[3]; 745 | unsigned int resetFrameContext; 746 | unsigned int mcomp_filter_type; 747 | unsigned int mbRefLfDelta[4]; 748 | unsigned int mbModeLfDelta[2]; 749 | unsigned int frameTagSize; 750 | unsigned int offsetToDctParts; 751 | unsigned int reserved128Bits[4]; 752 | 753 | } CUVIDVP9PICPARAMS; 754 | 755 | /***********************************************************/ 756 | //! \struct CUVIDAV1PICPARAMS 757 | //! AV1 picture parameters 758 | //! This structure is used in CUVIDPICPARAMS structure 759 | /***********************************************************/ 760 | typedef struct _CUVIDAV1PICPARAMS 761 | { 762 | unsigned int width; // coded width, if superres enabled then it is upscaled width 763 | unsigned int height; // coded height 764 | unsigned int frame_offset; // defined as order_hint in AV1 specification 765 | int decodePicIdx; // decoded output pic index, if film grain enabled, it will keep decoded (without film grain) output 766 | // It can be used as reference frame for future frames 767 | 768 | // sequence header 769 | unsigned int profile : 3; // 0 = profile0, 1 = profile1, 2 = profile2 770 | unsigned int use_128x128_superblock : 1; // superblock size 0:64x64, 1: 128x128 771 | unsigned int subsampling_x : 1; // (subsampling_x, _y) 1,1 = 420, 1,0 = 422, 0,0 = 444 772 | unsigned int subsampling_y : 1; 773 | unsigned int mono_chrome : 1; // for monochrome content, mono_chrome = 1 and (subsampling_x, _y) should be 1,1 774 | unsigned int bit_depth_minus8 : 4; // bit depth minus 8 775 | unsigned int enable_filter_intra : 1; // tool enable in seq level, 0 : disable 1: frame header control 776 | unsigned int enable_intra_edge_filter : 1; // intra edge filtering process, 0 : disable 1: enabled 777 | unsigned int enable_interintra_compound : 1; // interintra, 0 : not present 1: present 778 | unsigned int enable_masked_compound : 1; // 1: mode info for inter blocks may contain the syntax element compound_type. 779 | // 0: syntax element compound_type will not be present 780 | unsigned int enable_dual_filter : 1; // vertical and horiz filter selection, 1: enable and 0: disable 781 | unsigned int enable_order_hint : 1; // order hint, and related tools, 1: enable and 0: disable 782 | unsigned int order_hint_bits_minus1 : 3; // is used to compute OrderHintBits 783 | unsigned int enable_jnt_comp : 1; // joint compound modes, 1: enable and 0: disable 784 | unsigned int enable_superres : 1; // superres in seq level, 0 : disable 1: frame level control 785 | unsigned int enable_cdef : 1; // cdef filtering in seq level, 0 : disable 1: frame level control 786 | unsigned int enable_restoration : 1; // loop restoration filtering in seq level, 0 : disable 1: frame level control 787 | unsigned int enable_fgs : 1; // defined as film_grain_params_present in AV1 specification 788 | unsigned int reserved0_7bits : 7; // reserved bits; must be set to 0 789 | 790 | // frame header 791 | unsigned int frame_type : 2 ; // 0:Key frame, 1:Inter frame, 2:intra only, 3:s-frame 792 | unsigned int show_frame : 1 ; // show_frame = 1 implies that frame should be immediately output once decoded 793 | unsigned int disable_cdf_update : 1; // CDF update during symbol decoding, 1: disabled, 0: enabled 794 | unsigned int allow_screen_content_tools : 1; // 1: intra blocks may use palette encoding, 0: palette encoding is never used 795 | unsigned int force_integer_mv : 1; // 1: motion vectors will always be integers, 0: can contain fractional bits 796 | unsigned int coded_denom : 3; // coded_denom of the superres scale as specified in AV1 specification 797 | unsigned int allow_intrabc : 1; // 1: intra block copy may be used, 0: intra block copy is not allowed 798 | unsigned int allow_high_precision_mv : 1; // 1/8 precision mv enable 799 | unsigned int interp_filter : 3; // interpolation filter. Refer to section 6.8.9 of the AV1 specification Version 1.0.0 with Errata 1 800 | unsigned int switchable_motion_mode : 1; // defined as is_motion_mode_switchable in AV1 specification 801 | unsigned int use_ref_frame_mvs : 1; // 1: current frame can use the previous frame mv information, 0: will not use. 802 | unsigned int disable_frame_end_update_cdf : 1; // 1: indicates that the end of frame CDF update is disabled 803 | unsigned int delta_q_present : 1; // quantizer index delta values are present in the block level 804 | unsigned int delta_q_res : 2; // left shift which should be applied to decoded quantizer index delta values 805 | unsigned int using_qmatrix : 1; // 1: quantizer matrix will be used to compute quantizers 806 | unsigned int coded_lossless : 1; // 1: all segments use lossless coding 807 | unsigned int use_superres : 1; // 1: superres enabled for frame 808 | unsigned int tx_mode : 2; // 0: ONLY4x4,1:LARGEST,2:SELECT 809 | unsigned int reference_mode : 1; // 0: SINGLE, 1: SELECT 810 | unsigned int allow_warped_motion : 1; // 1: allow_warped_motion may be present, 0: allow_warped_motion will not be present 811 | unsigned int reduced_tx_set : 1; // 1: frame is restricted to subset of the full set of transform types, 0: no such restriction 812 | unsigned int skip_mode : 1; // 1: most of the mode info is skipped, 0: mode info is not skipped 813 | unsigned int reserved1_3bits : 3; // reserved bits; must be set to 0 814 | 815 | // tiling info 816 | unsigned int num_tile_cols : 8; // number of tiles across the frame., max is 64 817 | unsigned int num_tile_rows : 8; // number of tiles down the frame., max is 64 818 | unsigned int context_update_tile_id : 16; // specifies which tile to use for the CDF update 819 | unsigned short tile_widths[64]; // Width of each column in superblocks 820 | unsigned short tile_heights[64]; // height of each row in superblocks 821 | 822 | // CDEF - refer to section 6.10.14 of the AV1 specification Version 1.0.0 with Errata 1 823 | unsigned char cdef_damping_minus_3 : 2; // controls the amount of damping in the deringing filter 824 | unsigned char cdef_bits : 2; // the number of bits needed to specify which CDEF filter to apply 825 | unsigned char reserved2_4bits : 4; // reserved bits; must be set to 0 826 | unsigned char cdef_y_strength[8]; // 0-3 bits: y_pri_strength, 4-7 bits y_sec_strength 827 | unsigned char cdef_uv_strength[8]; // 0-3 bits: uv_pri_strength, 4-7 bits uv_sec_strength 828 | 829 | // SkipModeFrames 830 | unsigned char SkipModeFrame0 : 4; // specifies the frames to use for compound prediction when skip_mode is equal to 1. 831 | unsigned char SkipModeFrame1 : 4; 832 | 833 | // qp information - refer to section 6.8.11 of the AV1 specification Version 1.0.0 with Errata 1 834 | unsigned char base_qindex; // indicates the base frame qindex. Defined as base_q_idx in AV1 specification 835 | char qp_y_dc_delta_q; // indicates the Y DC quantizer relative to base_q_idx. Defined as DeltaQYDc in AV1 specification 836 | char qp_u_dc_delta_q; // indicates the U DC quantizer relative to base_q_idx. Defined as DeltaQUDc in AV1 specification 837 | char qp_v_dc_delta_q; // indicates the V DC quantizer relative to base_q_idx. Defined as DeltaQVDc in AV1 specification 838 | char qp_u_ac_delta_q; // indicates the U AC quantizer relative to base_q_idx. Defined as DeltaQUAc in AV1 specification 839 | char qp_v_ac_delta_q; // indicates the V AC quantizer relative to base_q_idx. Defined as DeltaQVAc in AV1 specification 840 | unsigned char qm_y; // specifies the level in the quantizer matrix that should be used for luma plane decoding 841 | unsigned char qm_u; // specifies the level in the quantizer matrix that should be used for chroma U plane decoding 842 | unsigned char qm_v; // specifies the level in the quantizer matrix that should be used for chroma V plane decoding 843 | 844 | // segmentation - refer to section 6.8.13 of the AV1 specification Version 1.0.0 with Errata 1 845 | unsigned char segmentation_enabled : 1; // 1 indicates that this frame makes use of the segmentation tool 846 | unsigned char segmentation_update_map : 1; // 1 indicates that the segmentation map are updated during the decoding of this frame 847 | unsigned char segmentation_update_data : 1; // 1 indicates that new parameters are about to be specified for each segment 848 | unsigned char segmentation_temporal_update : 1; // 1 indicates that the updates to the segmentation map are coded relative to the existing segmentation map 849 | unsigned char reserved3_4bits : 4; // reserved bits; must be set to 0 850 | short segmentation_feature_data[8][8]; // specifies the feature data for a segment feature 851 | unsigned char segmentation_feature_mask[8]; // indicates that the corresponding feature is unused or feature value is coded 852 | 853 | // loopfilter - refer to section 6.8.10 of the AV1 specification Version 1.0.0 with Errata 1 854 | unsigned char loop_filter_level[2]; // contains loop filter strength values 855 | unsigned char loop_filter_level_u; // loop filter strength value of U plane 856 | unsigned char loop_filter_level_v; // loop filter strength value of V plane 857 | unsigned char loop_filter_sharpness; // indicates the sharpness level 858 | char loop_filter_ref_deltas[8]; // contains the adjustment needed for the filter level based on the chosen reference frame 859 | char loop_filter_mode_deltas[2]; // contains the adjustment needed for the filter level based on the chosen mode 860 | unsigned char loop_filter_delta_enabled : 1; // indicates that the filter level depends on the mode and reference frame used to predict a block 861 | unsigned char loop_filter_delta_update : 1; // indicates that additional syntax elements are present that specify which mode and 862 | // reference frame deltas are to be updated 863 | unsigned char delta_lf_present : 1; // specifies whether loop filter delta values are present in the block level 864 | unsigned char delta_lf_res : 2; // specifies the left shift to apply to the decoded loop filter values 865 | unsigned char delta_lf_multi : 1; // separate loop filter deltas for Hy,Vy,U,V edges 866 | unsigned char reserved4_2bits : 2; // reserved bits; must be set to 0 867 | 868 | // restoration - refer to section 6.10.15 of the AV1 specification Version 1.0.0 with Errata 1 869 | unsigned char lr_unit_size[3]; // specifies the size of loop restoration units: 0: 32, 1: 64, 2: 128, 3: 256 870 | unsigned char lr_type[3] ; // used to compute FrameRestorationType 871 | 872 | // reference frames 873 | unsigned char primary_ref_frame; // specifies which reference frame contains the CDF values and other state that should be 874 | // loaded at the start of the frame 875 | unsigned char ref_frame_map[8]; // frames in dpb that can be used as reference for current or future frames 876 | 877 | unsigned char temporal_layer_id : 4; // temporal layer id 878 | unsigned char spatial_layer_id : 4; // spatial layer id 879 | 880 | unsigned char reserved5_32bits[4]; // reserved bits; must be set to 0 881 | 882 | // ref frame list 883 | struct 884 | { 885 | unsigned int width; 886 | unsigned int height; 887 | unsigned char index; 888 | unsigned char reserved24Bits[3]; // reserved bits; must be set to 0 889 | } ref_frame[7]; // frames used as reference frame for current frame. 890 | 891 | // global motion 892 | struct { 893 | unsigned char invalid : 1; 894 | unsigned char wmtype : 2; // defined as GmType in AV1 specification 895 | unsigned char reserved5Bits : 5; // reserved bits; must be set to 0 896 | char reserved24Bits[3]; // reserved bits; must be set to 0 897 | int wmmat[6]; // defined as gm_params[] in AV1 specification 898 | } global_motion[7]; // global motion params for reference frames 899 | 900 | // film grain params - refer to section 6.8.20 of the AV1 specification Version 1.0.0 with Errata 1 901 | unsigned short apply_grain : 1; 902 | unsigned short overlap_flag : 1; 903 | unsigned short scaling_shift_minus8 : 2; 904 | unsigned short chroma_scaling_from_luma : 1; 905 | unsigned short ar_coeff_lag : 2; 906 | unsigned short ar_coeff_shift_minus6 : 2; 907 | unsigned short grain_scale_shift : 2; 908 | unsigned short clip_to_restricted_range : 1; 909 | unsigned short reserved6_4bits : 4; // reserved bits; must be set to 0 910 | unsigned char num_y_points; 911 | unsigned char scaling_points_y[14][2]; 912 | unsigned char num_cb_points; 913 | unsigned char scaling_points_cb[10][2]; 914 | unsigned char num_cr_points; 915 | unsigned char scaling_points_cr[10][2]; 916 | unsigned char reserved7_8bits; // reserved bits; must be set to 0 917 | unsigned short random_seed; 918 | short ar_coeffs_y[24]; 919 | short ar_coeffs_cb[25]; 920 | short ar_coeffs_cr[25]; 921 | unsigned char cb_mult; 922 | unsigned char cb_luma_mult; 923 | short cb_offset; 924 | unsigned char cr_mult; 925 | unsigned char cr_luma_mult; 926 | short cr_offset; 927 | 928 | int reserved[7]; // reserved bits; must be set to 0 929 | } CUVIDAV1PICPARAMS; 930 | 931 | /******************************************************************************************/ 932 | //! \struct CUVIDPICPARAMS 933 | //! Picture parameters for decoding 934 | //! This structure is used in cuvidDecodePicture API 935 | //! IN for cuvidDecodePicture 936 | /******************************************************************************************/ 937 | typedef struct _CUVIDPICPARAMS 938 | { 939 | int PicWidthInMbs; /**< IN: Coded frame size in macroblocks */ 940 | int FrameHeightInMbs; /**< IN: Coded frame height in macroblocks */ 941 | int CurrPicIdx; /**< IN: Output index of the current picture */ 942 | int field_pic_flag; /**< IN: 0=frame picture, 1=field picture */ 943 | int bottom_field_flag; /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */ 944 | int second_field; /**< IN: Second field of a complementary field pair */ 945 | // Bitstream data 946 | unsigned int nBitstreamDataLen; /**< IN: Number of bytes in bitstream data buffer */ 947 | const unsigned char *pBitstreamData; /**< IN: Ptr to bitstream data for this picture (slice-layer) */ 948 | unsigned int nNumSlices; /**< IN: Number of slices in this picture */ 949 | const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within 950 | the bitstream data buffer */ 951 | int ref_pic_flag; /**< IN: This picture is a reference picture */ 952 | int intra_pic_flag; /**< IN: This picture is entirely intra coded */ 953 | unsigned int Reserved[30]; /**< Reserved for future use */ 954 | // IN: Codec-specific data 955 | union { 956 | CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */ 957 | CUVIDH264PICPARAMS h264; 958 | CUVIDVC1PICPARAMS vc1; 959 | CUVIDMPEG4PICPARAMS mpeg4; 960 | CUVIDJPEGPICPARAMS jpeg; 961 | CUVIDHEVCPICPARAMS hevc; 962 | CUVIDVP8PICPARAMS vp8; 963 | CUVIDVP9PICPARAMS vp9; 964 | CUVIDAV1PICPARAMS av1; 965 | unsigned int CodecReserved[1024]; 966 | } CodecSpecific; 967 | } CUVIDPICPARAMS; 968 | 969 | 970 | /******************************************************/ 971 | //! \struct CUVIDPROCPARAMS 972 | //! Picture parameters for postprocessing 973 | //! This structure is used in cuvidMapVideoFrame API 974 | /******************************************************/ 975 | typedef struct _CUVIDPROCPARAMS 976 | { 977 | int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored) */ 978 | int second_field; /**< IN: Output the second field (ignored if deinterlace mode is Weave) */ 979 | int top_field_first; /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */ 980 | int unpaired_field; /**< IN: Input only contains one field (2nd field is invalid) */ 981 | // The fields below are used for raw YUV input 982 | unsigned int reserved_flags; /**< Reserved for future use (set to zero) */ 983 | unsigned int reserved_zero; /**< Reserved (set to zero) */ 984 | unsigned long long raw_input_dptr; /**< IN: Input CUdeviceptr for raw YUV extensions */ 985 | unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately) */ 986 | unsigned int raw_input_format; /**< IN: Input YUV format (cudaVideoCodec_enum) */ 987 | unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions */ 988 | unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */ 989 | unsigned int Reserved1; /**< Reserved for future use (set to zero) */ 990 | CUstream output_stream; /**< IN: stream object used by cuvidMapVideoFrame */ 991 | unsigned int Reserved[46]; /**< Reserved for future use (set to zero) */ 992 | unsigned long long *histogram_dptr; /**< OUT: Output CUdeviceptr for histogram extensions */ 993 | void *Reserved2[1]; /**< Reserved for future use (set to zero) */ 994 | } CUVIDPROCPARAMS; 995 | 996 | /*********************************************************************************************************/ 997 | //! \struct CUVIDGETDECODESTATUS 998 | //! Struct for reporting decode status. 999 | //! This structure is used in cuvidGetDecodeStatus API. 1000 | /*********************************************************************************************************/ 1001 | typedef struct _CUVIDGETDECODESTATUS 1002 | { 1003 | cuvidDecodeStatus decodeStatus; 1004 | unsigned int reserved[31]; 1005 | void *pReserved[8]; 1006 | } CUVIDGETDECODESTATUS; 1007 | 1008 | /****************************************************/ 1009 | //! \struct CUVIDRECONFIGUREDECODERINFO 1010 | //! Struct for decoder reset 1011 | //! This structure is used in cuvidReconfigureDecoder() API 1012 | /****************************************************/ 1013 | typedef struct _CUVIDRECONFIGUREDECODERINFO 1014 | { 1015 | unsigned int ulWidth; /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at CUVIDDECODECREATEINFO */ 1016 | unsigned int ulHeight; /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at CUVIDDECODECREATEINFO */ 1017 | unsigned int ulTargetWidth; /**< IN: Post processed output width */ 1018 | unsigned int ulTargetHeight; /**< IN: Post Processed output height */ 1019 | unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */ 1020 | unsigned int reserved1[12]; /**< Reserved for future use. Set to Zero */ 1021 | /** 1022 | * IN: Area of frame to be displayed. Use-case : Source Cropping 1023 | */ 1024 | struct { 1025 | short left; 1026 | short top; 1027 | short right; 1028 | short bottom; 1029 | } display_area; 1030 | /** 1031 | * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion 1032 | */ 1033 | struct { 1034 | short left; 1035 | short top; 1036 | short right; 1037 | short bottom; 1038 | } target_rect; 1039 | unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */ 1040 | } CUVIDRECONFIGUREDECODERINFO; 1041 | 1042 | 1043 | /***********************************************************************************************************/ 1044 | //! VIDEO_DECODER 1045 | //! 1046 | //! In order to minimize decode latencies, there should be always at least 2 pictures in the decode 1047 | //! queue at any time, in order to make sure that all decode engines are always busy. 1048 | //! 1049 | //! Overall data flow: 1050 | //! - cuvidGetDecoderCaps(...) 1051 | //! - cuvidCreateDecoder(...) 1052 | //! - For each picture: 1053 | //! + cuvidDecodePicture(N) 1054 | //! + cuvidMapVideoFrame(N-4) 1055 | //! + do some processing in cuda 1056 | //! + cuvidUnmapVideoFrame(N-4) 1057 | //! + cuvidDecodePicture(N+1) 1058 | //! + cuvidMapVideoFrame(N-3) 1059 | //! + ... 1060 | //! - cuvidDestroyDecoder(...) 1061 | //! 1062 | //! NOTE: 1063 | //! - When the cuda context is created from a D3D device, the D3D device must also be created 1064 | //! with the D3DCREATE_MULTITHREADED flag. 1065 | //! - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces) 1066 | //! - cuvidDecodePicture may block the calling thread if there are too many pictures pending 1067 | //! in the decode queue 1068 | /***********************************************************************************************************/ 1069 | 1070 | 1071 | /**********************************************************************************************************************/ 1072 | //! \fn CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc) 1073 | //! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters. 1074 | //! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure 1075 | //! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported 1076 | //! If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0. 1077 | //! E.g. on Geforce GTX 960: 1078 | //! App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0; 1079 | //! Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth = 48; nMinHeight = 16; 1080 | //! nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536; 1081 | //! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount 1082 | /**********************************************************************************************************************/ 1083 | typedef CUresult CUDAAPI tcuvidGetDecoderCaps(CUVIDDECODECAPS *pdc); 1084 | 1085 | /*****************************************************************************************************/ 1086 | //! \fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci) 1087 | //! Create the decoder object based on pdci. A handle to the created decoder is returned 1088 | /*****************************************************************************************************/ 1089 | typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci); 1090 | 1091 | /*****************************************************************************************************/ 1092 | //! \fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder) 1093 | //! Destroy the decoder object 1094 | /*****************************************************************************************************/ 1095 | typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder); 1096 | 1097 | /*****************************************************************************************************/ 1098 | //! \fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams) 1099 | //! Decode a single picture (field or frame) 1100 | //! Kicks off HW decoding 1101 | /*****************************************************************************************************/ 1102 | typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams); 1103 | 1104 | /************************************************************************************************************/ 1105 | //! \fn CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx); 1106 | //! Get the decode status for frame corresponding to nPicIdx 1107 | //! API is supported for Maxwell and above generation GPUs. 1108 | //! API is currently supported for HEVC, H264 and JPEG codecs. 1109 | //! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec. 1110 | /************************************************************************************************************/ 1111 | typedef CUresult CUDAAPI tcuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx, CUVIDGETDECODESTATUS* pDecodeStatus); 1112 | 1113 | /*********************************************************************************************************/ 1114 | //! \fn CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams) 1115 | //! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params, display area 1116 | //! params, target area params change for same codec. Must be called during CUVIDPARSERPARAMS::pfnSequenceCallback 1117 | /*********************************************************************************************************/ 1118 | typedef CUresult CUDAAPI tcuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams); 1119 | 1120 | 1121 | #if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL) 1122 | /************************************************************************************************************************/ 1123 | //! \fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr, 1124 | //! unsigned int *pPitch, CUVIDPROCPARAMS *pVPP); 1125 | //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated 1126 | //! pitch of the video frame 1127 | /************************************************************************************************************************/ 1128 | typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, 1129 | unsigned int *pDevPtr, unsigned int *pPitch, 1130 | CUVIDPROCPARAMS *pVPP); 1131 | 1132 | /*****************************************************************************************************/ 1133 | //! \fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr) 1134 | //! Unmap a previously mapped video frame 1135 | /*****************************************************************************************************/ 1136 | typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr); 1137 | #endif 1138 | 1139 | /****************************************************************************************************************************/ 1140 | //! \fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, 1141 | //! unsigned int * pPitch, CUVIDPROCPARAMS *pVPP); 1142 | //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and associated 1143 | //! pitch of the video frame 1144 | /****************************************************************************************************************************/ 1145 | typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr, 1146 | unsigned int *pPitch, CUVIDPROCPARAMS *pVPP); 1147 | 1148 | /**************************************************************************************************/ 1149 | //! \fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr); 1150 | //! Unmap a previously mapped video frame 1151 | /**************************************************************************************************/ 1152 | typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr); 1153 | 1154 | #if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL) 1155 | #define tcuvidMapVideoFrame tcuvidMapVideoFrame64 1156 | #define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64 1157 | #endif 1158 | 1159 | 1160 | 1161 | /********************************************************************************************************************/ 1162 | //! 1163 | //! Context-locking: to facilitate multi-threaded implementations, the following 4 functions 1164 | //! provide a simple mutex-style host synchronization. If a non-NULL context is specified 1165 | //! in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given 1166 | //! context before making any cuda calls. 1167 | //! A multi-threaded application could create a lock associated with a context handle so that 1168 | //! multiple threads can safely share the same cuda context: 1169 | //! - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context 1170 | //! that can be passed to cuvidCtxLockCreate. 1171 | //! - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section. 1172 | //! 1173 | //! NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video 1174 | //! decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls). 1175 | /********************************************************************************************************************/ 1176 | 1177 | /********************************************************************************************************************/ 1178 | //! \fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx) 1179 | //! This API is used to create CtxLock object 1180 | /********************************************************************************************************************/ 1181 | typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx); 1182 | 1183 | /********************************************************************************************************************/ 1184 | //! \fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck) 1185 | //! This API is used to free CtxLock object 1186 | /********************************************************************************************************************/ 1187 | typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck); 1188 | 1189 | /********************************************************************************************************************/ 1190 | //! \fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags) 1191 | //! This API is used to acquire ctxlock 1192 | /********************************************************************************************************************/ 1193 | typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags); 1194 | 1195 | /********************************************************************************************************************/ 1196 | //! \fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags) 1197 | //! This API is used to release ctxlock 1198 | /********************************************************************************************************************/ 1199 | typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags); 1200 | 1201 | /**********************************************************************************************/ 1202 | 1203 | #if defined(__cplusplus) 1204 | } 1205 | #endif /* __cplusplus */ 1206 | 1207 | #endif // __CUDA_VIDEO_H__ 1208 | -------------------------------------------------------------------------------- /include/ffnvcodec/dynlink_loader.h: -------------------------------------------------------------------------------- 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 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 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 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 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 | tcuDriverGetVersion *cuDriverGetVersion; 141 | tcuDeviceGetCount *cuDeviceGetCount; 142 | tcuDeviceGet *cuDeviceGet; 143 | tcuDeviceGetAttribute *cuDeviceGetAttribute; 144 | tcuDeviceGetName *cuDeviceGetName; 145 | tcuDeviceGetUuid *cuDeviceGetUuid; 146 | tcuDeviceGetUuid_v2 *cuDeviceGetUuid_v2; 147 | tcuDeviceGetLuid *cuDeviceGetLuid; 148 | tcuDeviceGetByPCIBusId *cuDeviceGetByPCIBusId; 149 | tcuDeviceGetPCIBusId *cuDeviceGetPCIBusId; 150 | tcuDeviceComputeCapability *cuDeviceComputeCapability; 151 | tcuCtxCreate_v2 *cuCtxCreate; 152 | tcuCtxGetCurrent *cuCtxGetCurrent; 153 | tcuCtxSetLimit *cuCtxSetLimit; 154 | tcuCtxPushCurrent_v2 *cuCtxPushCurrent; 155 | tcuCtxPopCurrent_v2 *cuCtxPopCurrent; 156 | tcuCtxDestroy_v2 *cuCtxDestroy; 157 | tcuMemAlloc_v2 *cuMemAlloc; 158 | tcuMemAllocPitch_v2 *cuMemAllocPitch; 159 | tcuMemAllocManaged *cuMemAllocManaged; 160 | tcuMemsetD8Async *cuMemsetD8Async; 161 | tcuMemFree_v2 *cuMemFree; 162 | tcuMemcpy *cuMemcpy; 163 | tcuMemcpyAsync *cuMemcpyAsync; 164 | tcuMemcpy2D_v2 *cuMemcpy2D; 165 | tcuMemcpy2DAsync_v2 *cuMemcpy2DAsync; 166 | tcuMemcpyHtoD_v2 *cuMemcpyHtoD; 167 | tcuMemcpyHtoDAsync_v2 *cuMemcpyHtoDAsync; 168 | tcuMemcpyDtoH_v2 *cuMemcpyDtoH; 169 | tcuMemcpyDtoHAsync_v2 *cuMemcpyDtoHAsync; 170 | tcuMemcpyDtoD_v2 *cuMemcpyDtoD; 171 | tcuMemcpyDtoDAsync_v2 *cuMemcpyDtoDAsync; 172 | tcuGetErrorName *cuGetErrorName; 173 | tcuGetErrorString *cuGetErrorString; 174 | tcuCtxGetDevice *cuCtxGetDevice; 175 | 176 | tcuDevicePrimaryCtxRetain *cuDevicePrimaryCtxRetain; 177 | tcuDevicePrimaryCtxRelease *cuDevicePrimaryCtxRelease; 178 | tcuDevicePrimaryCtxSetFlags *cuDevicePrimaryCtxSetFlags; 179 | tcuDevicePrimaryCtxGetState *cuDevicePrimaryCtxGetState; 180 | tcuDevicePrimaryCtxReset *cuDevicePrimaryCtxReset; 181 | 182 | tcuStreamCreate *cuStreamCreate; 183 | tcuStreamQuery *cuStreamQuery; 184 | tcuStreamSynchronize *cuStreamSynchronize; 185 | tcuStreamDestroy_v2 *cuStreamDestroy; 186 | tcuStreamAddCallback *cuStreamAddCallback; 187 | tcuStreamWaitEvent *cuStreamWaitEvent; 188 | tcuEventCreate *cuEventCreate; 189 | tcuEventDestroy_v2 *cuEventDestroy; 190 | tcuEventSynchronize *cuEventSynchronize; 191 | tcuEventQuery *cuEventQuery; 192 | tcuEventRecord *cuEventRecord; 193 | 194 | tcuLaunchKernel *cuLaunchKernel; 195 | tcuLinkCreate *cuLinkCreate; 196 | tcuLinkAddData *cuLinkAddData; 197 | tcuLinkComplete *cuLinkComplete; 198 | tcuLinkDestroy *cuLinkDestroy; 199 | tcuModuleLoadData *cuModuleLoadData; 200 | tcuModuleUnload *cuModuleUnload; 201 | tcuModuleGetFunction *cuModuleGetFunction; 202 | tcuModuleGetGlobal *cuModuleGetGlobal; 203 | tcuTexObjectCreate *cuTexObjectCreate; 204 | tcuTexObjectDestroy *cuTexObjectDestroy; 205 | 206 | tcuGLGetDevices_v2 *cuGLGetDevices; 207 | tcuGraphicsGLRegisterImage *cuGraphicsGLRegisterImage; 208 | tcuGraphicsUnregisterResource *cuGraphicsUnregisterResource; 209 | tcuGraphicsMapResources *cuGraphicsMapResources; 210 | tcuGraphicsUnmapResources *cuGraphicsUnmapResources; 211 | tcuGraphicsSubResourceGetMappedArray *cuGraphicsSubResourceGetMappedArray; 212 | tcuGraphicsResourceGetMappedPointer *cuGraphicsResourceGetMappedPointer; 213 | 214 | tcuImportExternalMemory *cuImportExternalMemory; 215 | tcuDestroyExternalMemory *cuDestroyExternalMemory; 216 | tcuExternalMemoryGetMappedBuffer *cuExternalMemoryGetMappedBuffer; 217 | tcuExternalMemoryGetMappedMipmappedArray *cuExternalMemoryGetMappedMipmappedArray; 218 | tcuMipmappedArrayDestroy *cuMipmappedArrayDestroy; 219 | 220 | tcuMipmappedArrayGetLevel *cuMipmappedArrayGetLevel; 221 | 222 | tcuImportExternalSemaphore *cuImportExternalSemaphore; 223 | tcuDestroyExternalSemaphore *cuDestroyExternalSemaphore; 224 | tcuSignalExternalSemaphoresAsync *cuSignalExternalSemaphoresAsync; 225 | tcuWaitExternalSemaphoresAsync *cuWaitExternalSemaphoresAsync; 226 | 227 | tcuArrayCreate *cuArrayCreate; 228 | tcuArray3DCreate *cuArray3DCreate; 229 | tcuArrayDestroy *cuArrayDestroy; 230 | 231 | tcuEGLStreamProducerConnect *cuEGLStreamProducerConnect; 232 | tcuEGLStreamProducerDisconnect *cuEGLStreamProducerDisconnect; 233 | tcuEGLStreamConsumerDisconnect *cuEGLStreamConsumerDisconnect; 234 | tcuEGLStreamProducerPresentFrame *cuEGLStreamProducerPresentFrame; 235 | tcuEGLStreamProducerReturnFrame *cuEGLStreamProducerReturnFrame; 236 | 237 | #if defined(_WIN32) || defined(__CYGWIN__) 238 | tcuD3D11GetDevice *cuD3D11GetDevice; 239 | tcuD3D11GetDevices *cuD3D11GetDevices; 240 | tcuGraphicsD3D11RegisterResource *cuGraphicsD3D11RegisterResource; 241 | #endif 242 | 243 | FFNV_LIB_HANDLE lib; 244 | } CudaFunctions; 245 | #else 246 | typedef struct CudaFunctions CudaFunctions; 247 | #endif 248 | 249 | typedef struct CuvidFunctions { 250 | tcuvidGetDecoderCaps *cuvidGetDecoderCaps; 251 | tcuvidCreateDecoder *cuvidCreateDecoder; 252 | tcuvidDestroyDecoder *cuvidDestroyDecoder; 253 | tcuvidDecodePicture *cuvidDecodePicture; 254 | tcuvidGetDecodeStatus *cuvidGetDecodeStatus; 255 | tcuvidReconfigureDecoder *cuvidReconfigureDecoder; 256 | tcuvidMapVideoFrame *cuvidMapVideoFrame; 257 | tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame; 258 | tcuvidCtxLockCreate *cuvidCtxLockCreate; 259 | tcuvidCtxLockDestroy *cuvidCtxLockDestroy; 260 | tcuvidCtxLock *cuvidCtxLock; 261 | tcuvidCtxUnlock *cuvidCtxUnlock; 262 | 263 | #if !defined(__APPLE__) 264 | tcuvidCreateVideoSource *cuvidCreateVideoSource; 265 | tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW; 266 | tcuvidDestroyVideoSource *cuvidDestroyVideoSource; 267 | tcuvidSetVideoSourceState *cuvidSetVideoSourceState; 268 | tcuvidGetVideoSourceState *cuvidGetVideoSourceState; 269 | tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat; 270 | tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat; 271 | #endif 272 | tcuvidCreateVideoParser *cuvidCreateVideoParser; 273 | tcuvidParseVideoData *cuvidParseVideoData; 274 | tcuvidDestroyVideoParser *cuvidDestroyVideoParser; 275 | 276 | FFNV_LIB_HANDLE lib; 277 | } CuvidFunctions; 278 | 279 | typedef NVENCSTATUS NVENCAPI tNvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList); 280 | typedef NVENCSTATUS NVENCAPI tNvEncodeAPIGetMaxSupportedVersion(uint32_t* version); 281 | 282 | typedef struct NvencFunctions { 283 | tNvEncodeAPICreateInstance *NvEncodeAPICreateInstance; 284 | tNvEncodeAPIGetMaxSupportedVersion *NvEncodeAPIGetMaxSupportedVersion; 285 | 286 | FFNV_LIB_HANDLE lib; 287 | } NvencFunctions; 288 | 289 | #ifdef FFNV_DYNLINK_CUDA_H 290 | static inline void cuda_free_functions(CudaFunctions **functions) 291 | { 292 | GENERIC_FREE_FUNC(); 293 | } 294 | #endif 295 | 296 | static inline void cuvid_free_functions(CuvidFunctions **functions) 297 | { 298 | GENERIC_FREE_FUNC(); 299 | } 300 | 301 | static inline void nvenc_free_functions(NvencFunctions **functions) 302 | { 303 | GENERIC_FREE_FUNC(); 304 | } 305 | 306 | #ifdef FFNV_DYNLINK_CUDA_H 307 | static inline int cuda_load_functions(CudaFunctions **functions, void *logctx) 308 | { 309 | GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME); 310 | 311 | LOAD_SYMBOL(cuInit, tcuInit, "cuInit"); 312 | LOAD_SYMBOL(cuDriverGetVersion, tcuDriverGetVersion, "cuDriverGetVersion"); 313 | LOAD_SYMBOL(cuDeviceGetCount, tcuDeviceGetCount, "cuDeviceGetCount"); 314 | LOAD_SYMBOL(cuDeviceGet, tcuDeviceGet, "cuDeviceGet"); 315 | LOAD_SYMBOL(cuDeviceGetAttribute, tcuDeviceGetAttribute, "cuDeviceGetAttribute"); 316 | LOAD_SYMBOL(cuDeviceGetName, tcuDeviceGetName, "cuDeviceGetName"); 317 | LOAD_SYMBOL(cuDeviceComputeCapability, tcuDeviceComputeCapability, "cuDeviceComputeCapability"); 318 | LOAD_SYMBOL(cuCtxCreate, tcuCtxCreate_v2, "cuCtxCreate_v2"); 319 | LOAD_SYMBOL(cuCtxGetCurrent, tcuCtxGetCurrent, "cuCtxGetCurrent"); 320 | LOAD_SYMBOL(cuCtxSetLimit, tcuCtxSetLimit, "cuCtxSetLimit"); 321 | LOAD_SYMBOL(cuCtxPushCurrent, tcuCtxPushCurrent_v2, "cuCtxPushCurrent_v2"); 322 | LOAD_SYMBOL(cuCtxPopCurrent, tcuCtxPopCurrent_v2, "cuCtxPopCurrent_v2"); 323 | LOAD_SYMBOL(cuCtxDestroy, tcuCtxDestroy_v2, "cuCtxDestroy_v2"); 324 | LOAD_SYMBOL(cuMemAlloc, tcuMemAlloc_v2, "cuMemAlloc_v2"); 325 | LOAD_SYMBOL(cuMemAllocPitch, tcuMemAllocPitch_v2, "cuMemAllocPitch_v2"); 326 | LOAD_SYMBOL(cuMemAllocManaged, tcuMemAllocManaged, "cuMemAllocManaged"); 327 | LOAD_SYMBOL(cuMemsetD8Async, tcuMemsetD8Async, "cuMemsetD8Async"); 328 | LOAD_SYMBOL(cuMemFree, tcuMemFree_v2, "cuMemFree_v2"); 329 | LOAD_SYMBOL(cuMemcpy, tcuMemcpy, "cuMemcpy"); 330 | LOAD_SYMBOL(cuMemcpyAsync, tcuMemcpyAsync, "cuMemcpyAsync"); 331 | LOAD_SYMBOL(cuMemcpy2D, tcuMemcpy2D_v2, "cuMemcpy2D_v2"); 332 | LOAD_SYMBOL(cuMemcpy2DAsync, tcuMemcpy2DAsync_v2, "cuMemcpy2DAsync_v2"); 333 | LOAD_SYMBOL(cuMemcpyHtoD, tcuMemcpyHtoD_v2, "cuMemcpyHtoD_v2"); 334 | LOAD_SYMBOL(cuMemcpyHtoDAsync, tcuMemcpyHtoDAsync_v2, "cuMemcpyHtoDAsync_v2"); 335 | LOAD_SYMBOL(cuMemcpyDtoH, tcuMemcpyDtoH_v2, "cuMemcpyDtoH_v2"); 336 | LOAD_SYMBOL(cuMemcpyDtoHAsync, tcuMemcpyDtoHAsync_v2, "cuMemcpyDtoHAsync_v2"); 337 | LOAD_SYMBOL(cuMemcpyDtoD, tcuMemcpyDtoD_v2, "cuMemcpyDtoD_v2"); 338 | LOAD_SYMBOL(cuMemcpyDtoDAsync, tcuMemcpyDtoDAsync_v2, "cuMemcpyDtoDAsync_v2"); 339 | LOAD_SYMBOL(cuGetErrorName, tcuGetErrorName, "cuGetErrorName"); 340 | LOAD_SYMBOL(cuGetErrorString, tcuGetErrorString, "cuGetErrorString"); 341 | LOAD_SYMBOL(cuCtxGetDevice, tcuCtxGetDevice, "cuCtxGetDevice"); 342 | 343 | LOAD_SYMBOL(cuDevicePrimaryCtxRetain, tcuDevicePrimaryCtxRetain, "cuDevicePrimaryCtxRetain"); 344 | LOAD_SYMBOL(cuDevicePrimaryCtxRelease, tcuDevicePrimaryCtxRelease, "cuDevicePrimaryCtxRelease"); 345 | LOAD_SYMBOL(cuDevicePrimaryCtxSetFlags, tcuDevicePrimaryCtxSetFlags, "cuDevicePrimaryCtxSetFlags"); 346 | LOAD_SYMBOL(cuDevicePrimaryCtxGetState, tcuDevicePrimaryCtxGetState, "cuDevicePrimaryCtxGetState"); 347 | LOAD_SYMBOL(cuDevicePrimaryCtxReset, tcuDevicePrimaryCtxReset, "cuDevicePrimaryCtxReset"); 348 | 349 | LOAD_SYMBOL(cuStreamCreate, tcuStreamCreate, "cuStreamCreate"); 350 | LOAD_SYMBOL(cuStreamQuery, tcuStreamQuery, "cuStreamQuery"); 351 | LOAD_SYMBOL(cuStreamSynchronize, tcuStreamSynchronize, "cuStreamSynchronize"); 352 | LOAD_SYMBOL(cuStreamDestroy, tcuStreamDestroy_v2, "cuStreamDestroy_v2"); 353 | LOAD_SYMBOL(cuStreamAddCallback, tcuStreamAddCallback, "cuStreamAddCallback"); 354 | LOAD_SYMBOL(cuStreamWaitEvent, tcuStreamWaitEvent, "cuStreamWaitEvent"); 355 | LOAD_SYMBOL(cuEventCreate, tcuEventCreate, "cuEventCreate"); 356 | LOAD_SYMBOL(cuEventDestroy, tcuEventDestroy_v2, "cuEventDestroy_v2"); 357 | LOAD_SYMBOL(cuEventSynchronize, tcuEventSynchronize, "cuEventSynchronize"); 358 | LOAD_SYMBOL(cuEventQuery, tcuEventQuery, "cuEventQuery"); 359 | LOAD_SYMBOL(cuEventRecord, tcuEventRecord, "cuEventRecord"); 360 | 361 | LOAD_SYMBOL(cuLaunchKernel, tcuLaunchKernel, "cuLaunchKernel"); 362 | LOAD_SYMBOL(cuLinkCreate, tcuLinkCreate, "cuLinkCreate"); 363 | LOAD_SYMBOL(cuLinkAddData, tcuLinkAddData, "cuLinkAddData"); 364 | LOAD_SYMBOL(cuLinkComplete, tcuLinkComplete, "cuLinkComplete"); 365 | LOAD_SYMBOL(cuLinkDestroy, tcuLinkDestroy, "cuLinkDestroy"); 366 | LOAD_SYMBOL(cuModuleLoadData, tcuModuleLoadData, "cuModuleLoadData"); 367 | LOAD_SYMBOL(cuModuleUnload, tcuModuleUnload, "cuModuleUnload"); 368 | LOAD_SYMBOL(cuModuleGetFunction, tcuModuleGetFunction, "cuModuleGetFunction"); 369 | LOAD_SYMBOL(cuModuleGetGlobal, tcuModuleGetGlobal, "cuModuleGetGlobal"); 370 | LOAD_SYMBOL(cuTexObjectCreate, tcuTexObjectCreate, "cuTexObjectCreate"); 371 | LOAD_SYMBOL(cuTexObjectDestroy, tcuTexObjectDestroy, "cuTexObjectDestroy"); 372 | 373 | LOAD_SYMBOL(cuGLGetDevices, tcuGLGetDevices_v2, "cuGLGetDevices_v2"); 374 | LOAD_SYMBOL(cuGraphicsGLRegisterImage, tcuGraphicsGLRegisterImage, "cuGraphicsGLRegisterImage"); 375 | LOAD_SYMBOL(cuGraphicsUnregisterResource, tcuGraphicsUnregisterResource, "cuGraphicsUnregisterResource"); 376 | LOAD_SYMBOL(cuGraphicsMapResources, tcuGraphicsMapResources, "cuGraphicsMapResources"); 377 | LOAD_SYMBOL(cuGraphicsUnmapResources, tcuGraphicsUnmapResources, "cuGraphicsUnmapResources"); 378 | LOAD_SYMBOL(cuGraphicsSubResourceGetMappedArray, tcuGraphicsSubResourceGetMappedArray, "cuGraphicsSubResourceGetMappedArray"); 379 | LOAD_SYMBOL(cuGraphicsResourceGetMappedPointer, tcuGraphicsResourceGetMappedPointer, "cuGraphicsResourceGetMappedPointer_v2"); 380 | 381 | LOAD_SYMBOL_OPT(cuDeviceGetUuid, tcuDeviceGetUuid, "cuDeviceGetUuid"); 382 | LOAD_SYMBOL_OPT(cuDeviceGetUuid_v2, tcuDeviceGetUuid_v2, "cuDeviceGetUuid_v2"); 383 | LOAD_SYMBOL_OPT(cuDeviceGetLuid, tcuDeviceGetLuid, "cuDeviceGetLuid"); 384 | LOAD_SYMBOL_OPT(cuDeviceGetByPCIBusId, tcuDeviceGetByPCIBusId, "cuDeviceGetByPCIBusId"); 385 | LOAD_SYMBOL_OPT(cuDeviceGetPCIBusId, tcuDeviceGetPCIBusId, "cuDeviceGetPCIBusId"); 386 | LOAD_SYMBOL_OPT(cuImportExternalMemory, tcuImportExternalMemory, "cuImportExternalMemory"); 387 | LOAD_SYMBOL_OPT(cuDestroyExternalMemory, tcuDestroyExternalMemory, "cuDestroyExternalMemory"); 388 | LOAD_SYMBOL_OPT(cuExternalMemoryGetMappedBuffer, tcuExternalMemoryGetMappedBuffer, "cuExternalMemoryGetMappedBuffer"); 389 | LOAD_SYMBOL_OPT(cuExternalMemoryGetMappedMipmappedArray, tcuExternalMemoryGetMappedMipmappedArray, "cuExternalMemoryGetMappedMipmappedArray"); 390 | LOAD_SYMBOL_OPT(cuMipmappedArrayGetLevel, tcuMipmappedArrayGetLevel, "cuMipmappedArrayGetLevel"); 391 | LOAD_SYMBOL_OPT(cuMipmappedArrayDestroy, tcuMipmappedArrayDestroy, "cuMipmappedArrayDestroy"); 392 | 393 | LOAD_SYMBOL_OPT(cuImportExternalSemaphore, tcuImportExternalSemaphore, "cuImportExternalSemaphore"); 394 | LOAD_SYMBOL_OPT(cuDestroyExternalSemaphore, tcuDestroyExternalSemaphore, "cuDestroyExternalSemaphore"); 395 | LOAD_SYMBOL_OPT(cuSignalExternalSemaphoresAsync, tcuSignalExternalSemaphoresAsync, "cuSignalExternalSemaphoresAsync"); 396 | LOAD_SYMBOL_OPT(cuWaitExternalSemaphoresAsync, tcuWaitExternalSemaphoresAsync, "cuWaitExternalSemaphoresAsync"); 397 | 398 | LOAD_SYMBOL(cuArrayCreate, tcuArrayCreate, "cuArrayCreate_v2"); 399 | LOAD_SYMBOL(cuArray3DCreate, tcuArray3DCreate, "cuArray3DCreate_v2"); 400 | LOAD_SYMBOL(cuArrayDestroy, tcuArrayDestroy, "cuArrayDestroy"); 401 | 402 | LOAD_SYMBOL_OPT(cuEGLStreamProducerConnect, tcuEGLStreamProducerConnect, "cuEGLStreamProducerConnect"); 403 | LOAD_SYMBOL_OPT(cuEGLStreamProducerDisconnect, tcuEGLStreamProducerDisconnect, "cuEGLStreamProducerDisconnect"); 404 | LOAD_SYMBOL_OPT(cuEGLStreamConsumerDisconnect, tcuEGLStreamConsumerDisconnect, "cuEGLStreamConsumerDisconnect"); 405 | LOAD_SYMBOL_OPT(cuEGLStreamProducerPresentFrame, tcuEGLStreamProducerPresentFrame, "cuEGLStreamProducerPresentFrame"); 406 | LOAD_SYMBOL_OPT(cuEGLStreamProducerReturnFrame, tcuEGLStreamProducerReturnFrame, "cuEGLStreamProducerReturnFrame"); 407 | 408 | #if defined(_WIN32) || defined(__CYGWIN__) 409 | LOAD_SYMBOL(cuD3D11GetDevice, tcuD3D11GetDevice, "cuD3D11GetDevice"); 410 | LOAD_SYMBOL(cuD3D11GetDevices, tcuD3D11GetDevices, "cuD3D11GetDevices"); 411 | LOAD_SYMBOL(cuGraphicsD3D11RegisterResource, tcuGraphicsD3D11RegisterResource, "cuGraphicsD3D11RegisterResource"); 412 | #endif 413 | 414 | GENERIC_LOAD_FUNC_FINALE(cuda); 415 | } 416 | #endif 417 | 418 | static inline int cuvid_load_functions(CuvidFunctions **functions, void *logctx) 419 | { 420 | GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME); 421 | 422 | LOAD_SYMBOL_OPT(cuvidGetDecoderCaps, tcuvidGetDecoderCaps, "cuvidGetDecoderCaps"); 423 | LOAD_SYMBOL(cuvidCreateDecoder, tcuvidCreateDecoder, "cuvidCreateDecoder"); 424 | LOAD_SYMBOL(cuvidDestroyDecoder, tcuvidDestroyDecoder, "cuvidDestroyDecoder"); 425 | LOAD_SYMBOL(cuvidDecodePicture, tcuvidDecodePicture, "cuvidDecodePicture"); 426 | LOAD_SYMBOL(cuvidGetDecodeStatus, tcuvidGetDecodeStatus, "cuvidGetDecodeStatus"); 427 | LOAD_SYMBOL(cuvidReconfigureDecoder, tcuvidReconfigureDecoder, "cuvidReconfigureDecoder"); 428 | #ifdef __CUVID_DEVPTR64 429 | LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame64"); 430 | LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64"); 431 | #else 432 | LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame"); 433 | LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame"); 434 | #endif 435 | LOAD_SYMBOL(cuvidCtxLockCreate, tcuvidCtxLockCreate, "cuvidCtxLockCreate"); 436 | LOAD_SYMBOL(cuvidCtxLockDestroy, tcuvidCtxLockDestroy, "cuvidCtxLockDestroy"); 437 | LOAD_SYMBOL(cuvidCtxLock, tcuvidCtxLock, "cuvidCtxLock"); 438 | LOAD_SYMBOL(cuvidCtxUnlock, tcuvidCtxUnlock, "cuvidCtxUnlock"); 439 | 440 | #if !defined(__APPLE__) 441 | LOAD_SYMBOL(cuvidCreateVideoSource, tcuvidCreateVideoSource, "cuvidCreateVideoSource"); 442 | LOAD_SYMBOL(cuvidCreateVideoSourceW, tcuvidCreateVideoSourceW, "cuvidCreateVideoSourceW"); 443 | LOAD_SYMBOL(cuvidDestroyVideoSource, tcuvidDestroyVideoSource, "cuvidDestroyVideoSource"); 444 | LOAD_SYMBOL(cuvidSetVideoSourceState, tcuvidSetVideoSourceState, "cuvidSetVideoSourceState"); 445 | LOAD_SYMBOL(cuvidGetVideoSourceState, tcuvidGetVideoSourceState, "cuvidGetVideoSourceState"); 446 | LOAD_SYMBOL(cuvidGetSourceVideoFormat, tcuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat"); 447 | LOAD_SYMBOL(cuvidGetSourceAudioFormat, tcuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat"); 448 | #endif 449 | LOAD_SYMBOL(cuvidCreateVideoParser, tcuvidCreateVideoParser, "cuvidCreateVideoParser"); 450 | LOAD_SYMBOL(cuvidParseVideoData, tcuvidParseVideoData, "cuvidParseVideoData"); 451 | LOAD_SYMBOL(cuvidDestroyVideoParser, tcuvidDestroyVideoParser, "cuvidDestroyVideoParser"); 452 | 453 | GENERIC_LOAD_FUNC_FINALE(cuvid); 454 | } 455 | 456 | static inline int nvenc_load_functions(NvencFunctions **functions, void *logctx) 457 | { 458 | GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME); 459 | 460 | LOAD_SYMBOL(NvEncodeAPICreateInstance, tNvEncodeAPICreateInstance, "NvEncodeAPICreateInstance"); 461 | LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, tNvEncodeAPIGetMaxSupportedVersion, "NvEncodeAPIGetMaxSupportedVersion"); 462 | 463 | GENERIC_LOAD_FUNC_FINALE(nvenc); 464 | } 465 | 466 | #undef GENERIC_LOAD_FUNC_PREAMBLE 467 | #undef LOAD_LIBRARY 468 | #undef LOAD_SYMBOL 469 | #undef GENERIC_LOAD_FUNC_FINALE 470 | #undef GENERIC_FREE_FUNC 471 | #undef CUDA_LIBNAME 472 | #undef NVCUVID_LIBNAME 473 | #undef NVENC_LIBNAME 474 | 475 | #endif 476 | 477 | -------------------------------------------------------------------------------- /include/ffnvcodec/dynlink_nvcuvid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This copyright notice applies to this header file only: 3 | * 4 | * Copyright (c) 2010-2024 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-2024 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 | #define MAX_CLOCK_TS 3 45 | 46 | /***********************************************/ 47 | //! 48 | //! High-level helper APIs for video sources 49 | //! 50 | /***********************************************/ 51 | 52 | typedef void *CUvideosource; 53 | typedef void *CUvideoparser; 54 | typedef long long CUvideotimestamp; 55 | 56 | 57 | /************************************************************************/ 58 | //! \enum cudaVideoState 59 | //! Video source state enums 60 | //! Used in cuvidSetVideoSourceState and cuvidGetVideoSourceState APIs 61 | /************************************************************************/ 62 | typedef enum { 63 | cudaVideoState_Error = -1, /**< Error state (invalid source) */ 64 | cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */ 65 | cudaVideoState_Started = 1 /**< Source is running and delivering data */ 66 | } cudaVideoState; 67 | 68 | /************************************************************************/ 69 | //! \enum cudaAudioCodec 70 | //! Audio compression enums 71 | //! Used in CUAUDIOFORMAT structure 72 | /************************************************************************/ 73 | typedef enum { 74 | cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */ 75 | cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */ 76 | cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */ 77 | cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */ 78 | cudaAudioCodec_LPCM, /**< PCM Audio */ 79 | cudaAudioCodec_AAC, /**< AAC Audio */ 80 | } cudaAudioCodec; 81 | 82 | /************************************************************************/ 83 | //! \ingroup STRUCTS 84 | //! \struct TIMECODESET 85 | //! Used to store Time code set extracted from H264 and HEVC codecs 86 | /************************************************************************/ 87 | typedef struct _TIMECODESET 88 | { 89 | unsigned int time_offset_value; 90 | unsigned short n_frames; 91 | unsigned char clock_timestamp_flag; 92 | unsigned char units_field_based_flag; 93 | unsigned char counting_type; 94 | unsigned char full_timestamp_flag; 95 | unsigned char discontinuity_flag; 96 | unsigned char cnt_dropped_flag; 97 | unsigned char seconds_value; 98 | unsigned char minutes_value; 99 | unsigned char hours_value; 100 | unsigned char seconds_flag; 101 | unsigned char minutes_flag; 102 | unsigned char hours_flag; 103 | unsigned char time_offset_length; 104 | unsigned char reserved; 105 | } TIMECODESET; 106 | 107 | /************************************************************************/ 108 | //! \ingroup STRUCTS 109 | //! \struct TIMECODE 110 | //! Used to extract Time code in H264 and HEVC codecs 111 | /************************************************************************/ 112 | typedef struct _TIMECODE 113 | { 114 | TIMECODESET time_code_set[MAX_CLOCK_TS]; 115 | unsigned char num_clock_ts; 116 | } TIMECODE; 117 | 118 | /**********************************************************************************/ 119 | //! \ingroup STRUCTS 120 | //! \struct SEIMASTERINGDISPLAYINFO 121 | //! Used to extract mastering display color volume SEI in H264 and HEVC codecs 122 | /**********************************************************************************/ 123 | typedef struct _SEIMASTERINGDISPLAYINFO 124 | { 125 | unsigned short display_primaries_x[3]; 126 | unsigned short display_primaries_y[3]; 127 | unsigned short white_point_x; 128 | unsigned short white_point_y; 129 | unsigned int max_display_mastering_luminance; 130 | unsigned int min_display_mastering_luminance; 131 | } SEIMASTERINGDISPLAYINFO; 132 | 133 | /**********************************************************************************/ 134 | //! \ingroup STRUCTS 135 | //! \struct SEICONTENTLIGHTLEVELINFO 136 | //! Used to extract content light level info SEI in H264 and HEVC codecs 137 | /**********************************************************************************/ 138 | typedef struct _SEICONTENTLIGHTLEVELINFO 139 | { 140 | unsigned short max_content_light_level; 141 | unsigned short max_pic_average_light_level; 142 | unsigned int reserved; 143 | } SEICONTENTLIGHTLEVELINFO; 144 | 145 | /**********************************************************************************/ 146 | //! \ingroup STRUCTS 147 | //! \struct TIMECODEMPEG2 148 | //! Used to extract Time code in MPEG2 codec 149 | /**********************************************************************************/ 150 | typedef struct _TIMECODEMPEG2 151 | { 152 | unsigned char drop_frame_flag; 153 | unsigned char time_code_hours; 154 | unsigned char time_code_minutes; 155 | unsigned char marker_bit; 156 | unsigned char time_code_seconds; 157 | unsigned char time_code_pictures; 158 | } TIMECODEMPEG2; 159 | 160 | /**********************************************************************************/ 161 | //! \ingroup STRUCTS 162 | //! \struct SEIALTERNATIVETRANSFERCHARACTERISTICS 163 | //! Used to extract alternative transfer characteristics SEI in H264 and HEVC codecs 164 | /**********************************************************************************/ 165 | typedef struct _SEIALTERNATIVETRANSFERCHARACTERISTICS 166 | { 167 | unsigned char preferred_transfer_characteristics; 168 | } SEIALTERNATIVETRANSFERCHARACTERISTICS; 169 | 170 | /**********************************************************************************/ 171 | //! \ingroup STRUCTS 172 | //! \struct CUSEIMESSAGE; 173 | //! Used in CUVIDSEIMESSAGEINFO structure 174 | /**********************************************************************************/ 175 | typedef struct _CUSEIMESSAGE 176 | { 177 | unsigned char sei_message_type; /**< OUT: SEI Message Type */ 178 | unsigned char reserved[3]; 179 | unsigned int sei_message_size; /**< OUT: SEI Message Size */ 180 | } CUSEIMESSAGE; 181 | 182 | /************************************************************************************************/ 183 | //! \ingroup STRUCTS 184 | //! \struct CUVIDEOFORMAT 185 | //! Video format 186 | //! Used in cuvidGetSourceVideoFormat API 187 | /************************************************************************************************/ 188 | typedef struct 189 | { 190 | cudaVideoCodec codec; /**< OUT: Compression format */ 191 | /** 192 | * OUT: frame rate = numerator / denominator (for example: 30000/1001) 193 | */ 194 | struct { 195 | /**< OUT: frame rate numerator (0 = unspecified or variable frame rate) */ 196 | unsigned int numerator; 197 | /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */ 198 | unsigned int denominator; 199 | } frame_rate; 200 | unsigned char progressive_sequence; /**< OUT: 0=interlaced, 1=progressive */ 201 | unsigned char bit_depth_luma_minus8; /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ 202 | unsigned char bit_depth_chroma_minus8; /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */ 203 | unsigned char min_num_decode_surfaces; /**< OUT: Minimum number of decode surfaces to be allocated for correct 204 | decoding. The client can send this value in ulNumDecodeSurfaces 205 | (in CUVIDDECODECREATEINFO structure). 206 | This guarantees correct functionality and optimal video memory 207 | usage but not necessarily the best performance, which depends on 208 | the design of the overall application. The optimal number of 209 | decode surfaces (in terms of performance and memory utilization) 210 | should be decided by experimentation for each application, but it 211 | cannot go below min_num_decode_surfaces. 212 | If this value is used for ulNumDecodeSurfaces then it must be 213 | returned to parser during sequence callback. */ 214 | unsigned int coded_width; /**< OUT: coded frame width in pixels */ 215 | unsigned int coded_height; /**< OUT: coded frame height in pixels */ 216 | /** 217 | * area of the frame that should be displayed 218 | * typical example: 219 | * coded_width = 1920, coded_height = 1088 220 | * display_area = { 0,0,1920,1080 } 221 | */ 222 | struct { 223 | int left; /**< OUT: left position of display rect */ 224 | int top; /**< OUT: top position of display rect */ 225 | int right; /**< OUT: right position of display rect */ 226 | int bottom; /**< OUT: bottom position of display rect */ 227 | } display_area; 228 | cudaVideoChromaFormat chroma_format; /**< OUT: Chroma format */ 229 | unsigned int bitrate; /**< OUT: video bitrate (bps, 0=unknown) */ 230 | /** 231 | * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc) 232 | */ 233 | struct { 234 | int x; 235 | int y; 236 | } display_aspect_ratio; 237 | /** 238 | * Video Signal Description 239 | * Refer section E.2.1 (VUI parameters semantics) of H264 spec file 240 | */ 241 | struct { 242 | unsigned char video_format : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified */ 243 | unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range */ 244 | unsigned char reserved_zero_bits : 4; /**< Reserved bits */ 245 | unsigned char color_primaries; /**< OUT: chromaticity coordinates of source primaries */ 246 | unsigned char transfer_characteristics; /**< OUT: opto-electronic transfer characteristic of the source picture */ 247 | unsigned char matrix_coefficients; /**< OUT: used in deriving luma and chroma signals from RGB primaries */ 248 | } video_signal_description; 249 | unsigned int seqhdr_data_length; /**< OUT: Additional bytes following (CUVIDEOFORMATEX) */ 250 | } CUVIDEOFORMAT; 251 | 252 | /****************************************************************/ 253 | //! \ingroup STRUCTS 254 | //! \struct CUVIDOPERATINGPOINTINFO 255 | //! Operating point information of scalable bitstream 256 | /****************************************************************/ 257 | typedef struct 258 | { 259 | cudaVideoCodec codec; 260 | union 261 | { 262 | struct 263 | { 264 | unsigned char operating_points_cnt; 265 | unsigned char reserved24_bits[3]; 266 | unsigned short operating_points_idc[32]; 267 | } av1; 268 | unsigned char CodecReserved[1024]; 269 | }; 270 | } CUVIDOPERATINGPOINTINFO; 271 | 272 | /**********************************************************************************/ 273 | //! \ingroup STRUCTS 274 | //! \struct CUVIDSEIMESSAGEINFO 275 | //! Used in cuvidParseVideoData API with PFNVIDSEIMSGCALLBACK pfnGetSEIMsg 276 | /**********************************************************************************/ 277 | typedef struct _CUVIDSEIMESSAGEINFO 278 | { 279 | void *pSEIData; /**< OUT: SEI Message Data */ 280 | CUSEIMESSAGE *pSEIMessage; /**< OUT: SEI Message Info */ 281 | unsigned int sei_message_count; /**< OUT: SEI Message Count */ 282 | unsigned int picIdx; /**< OUT: SEI Message Pic Index */ 283 | } CUVIDSEIMESSAGEINFO; 284 | 285 | /****************************************************************/ 286 | //! \ingroup STRUCTS 287 | //! \struct CUVIDAV1SEQHDR 288 | //! AV1 specific sequence header information 289 | /****************************************************************/ 290 | typedef struct { 291 | unsigned int max_width; 292 | unsigned int max_height; 293 | unsigned char reserved[1016]; 294 | } CUVIDAV1SEQHDR; 295 | 296 | /****************************************************************/ 297 | //! \ingroup STRUCTS 298 | //! \struct CUVIDEOFORMATEX 299 | //! Video format including raw sequence header information 300 | //! Used in cuvidGetSourceVideoFormat API 301 | /****************************************************************/ 302 | typedef struct 303 | { 304 | CUVIDEOFORMAT format; /**< OUT: CUVIDEOFORMAT structure */ 305 | union { 306 | CUVIDAV1SEQHDR av1; 307 | unsigned char raw_seqhdr_data[1024]; /**< OUT: Sequence header data */ 308 | }; 309 | } CUVIDEOFORMATEX; 310 | 311 | /****************************************************************/ 312 | //! \ingroup STRUCTS 313 | //! \struct CUAUDIOFORMAT 314 | //! Audio formats 315 | //! Used in cuvidGetSourceAudioFormat API 316 | /****************************************************************/ 317 | typedef struct 318 | { 319 | cudaAudioCodec codec; /**< OUT: Compression format */ 320 | unsigned int channels; /**< OUT: number of audio channels */ 321 | unsigned int samplespersec; /**< OUT: sampling frequency */ 322 | unsigned int bitrate; /**< OUT: For uncompressed, can also be used to determine bits per sample */ 323 | unsigned int reserved1; /**< Reserved for future use */ 324 | unsigned int reserved2; /**< Reserved for future use */ 325 | } CUAUDIOFORMAT; 326 | 327 | 328 | /***************************************************************/ 329 | //! \enum CUvideopacketflags 330 | //! Data packet flags 331 | //! Used in CUVIDSOURCEDATAPACKET structure 332 | /***************************************************************/ 333 | typedef enum { 334 | CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */ 335 | CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */ 336 | CUVID_PKT_DISCONTINUITY = 0x04, /**< Set when a discontinuity has to be signalled */ 337 | CUVID_PKT_ENDOFPICTURE = 0x08, /**< Set when the packet contains exactly one frame or one field */ 338 | CUVID_PKT_NOTIFY_EOS = 0x10, /**< If this flag is set along with CUVID_PKT_ENDOFSTREAM, an additional (dummy) 339 | display callback will be invoked with null value of CUVIDPARSERDISPINFO which 340 | should be interpreted as end of the stream. */ 341 | } CUvideopacketflags; 342 | 343 | /*****************************************************************************/ 344 | //! \ingroup STRUCTS 345 | //! \struct CUVIDSOURCEDATAPACKET 346 | //! Data Packet 347 | //! Used in cuvidParseVideoData API 348 | //! IN for cuvidParseVideoData 349 | /*****************************************************************************/ 350 | typedef struct _CUVIDSOURCEDATAPACKET 351 | { 352 | tcu_ulong flags; /**< IN: Combination of CUVID_PKT_XXX flags */ 353 | tcu_ulong payload_size; /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */ 354 | const unsigned char *payload; /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */ 355 | CUvideotimestamp timestamp; /**< IN: Presentation time stamp (10MHz clock), only valid if 356 | CUVID_PKT_TIMESTAMP flag is set */ 357 | } CUVIDSOURCEDATAPACKET; 358 | 359 | // Callback for packet delivery 360 | typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *); 361 | 362 | /**************************************************************************************************************************/ 363 | //! \ingroup STRUCTS 364 | //! \struct CUVIDSOURCEPARAMS 365 | //! Describes parameters needed in cuvidCreateVideoSource API 366 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported 367 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. 368 | /**************************************************************************************************************************/ 369 | typedef struct _CUVIDSOURCEPARAMS 370 | { 371 | unsigned int ulClockRate; /**< IN: Time stamp units in Hz (0=default=10000000Hz) */ 372 | unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */ 373 | unsigned int uReserved : 31; /**< Reserved for future use - set to zero */ 374 | unsigned int uReserved1[6]; /**< Reserved for future use - set to zero */ 375 | void *pUserData; /**< IN: User private data passed in to the data handlers */ 376 | PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< IN: Called to deliver video packets */ 377 | PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< IN: Called to deliver audio packets. */ 378 | void *pvReserved2[8]; /**< Reserved for future use - set to NULL */ 379 | } CUVIDSOURCEPARAMS; 380 | 381 | 382 | /**********************************************/ 383 | //! \ingroup ENUMS 384 | //! \enum CUvideosourceformat_flags 385 | //! CUvideosourceformat_flags 386 | //! Used in cuvidGetSourceVideoFormat API 387 | /**********************************************/ 388 | typedef enum { 389 | CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */ 390 | } CUvideosourceformat_flags; 391 | 392 | #if !defined(__APPLE__) 393 | /***************************************************************************************************************************/ 394 | //! \ingroup FUNCTS 395 | //! \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams) 396 | //! Create CUvideosource object. CUvideosource spawns demultiplexer thread that provides two callbacks: 397 | //! pfnVideoDataHandler() and pfnAudioDataHandler() 398 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported 399 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. 400 | /***************************************************************************************************************************/ 401 | typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams); 402 | 403 | /***************************************************************************************************************************/ 404 | //! \ingroup FUNCTS 405 | //! \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams) 406 | //! Create video source 407 | /***************************************************************************************************************************/ 408 | typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams); 409 | 410 | /********************************************************************/ 411 | //! \ingroup FUNCTS 412 | //! \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj) 413 | //! Destroy video source 414 | /********************************************************************/ 415 | typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj); 416 | 417 | /******************************************************************************************/ 418 | //! \ingroup FUNCTS 419 | //! \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state) 420 | //! Set video source state to: 421 | //! cudaVideoState_Started - to signal the source to run and deliver data 422 | //! cudaVideoState_Stopped - to stop the source from delivering the data 423 | //! cudaVideoState_Error - invalid source 424 | /******************************************************************************************/ 425 | typedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state); 426 | 427 | /******************************************************************************************/ 428 | //! \ingroup FUNCTS 429 | //! \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj) 430 | //! Get video source state 431 | //! Returns: 432 | //! cudaVideoState_Started - if Source is running and delivering data 433 | //! cudaVideoState_Stopped - if Source is stopped or reached end-of-stream 434 | //! cudaVideoState_Error - if Source is in error state 435 | /******************************************************************************************/ 436 | typedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj); 437 | 438 | /******************************************************************************************************************/ 439 | //! \ingroup FUNCTS 440 | //! \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags) 441 | //! Gets video source format in pvidfmt, flags is set to combination of CUvideosourceformat_flags as per requirement 442 | /******************************************************************************************************************/ 443 | typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags); 444 | 445 | /**************************************************************************************************************************/ 446 | //! \ingroup FUNCTS 447 | //! \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags) 448 | //! Get audio source format 449 | //! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported 450 | //! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed. 451 | /**************************************************************************************************************************/ 452 | typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags); 453 | 454 | #endif 455 | /**********************************************************************************/ 456 | //! \ingroup STRUCTS 457 | //! \struct CUVIDPARSERDISPINFO 458 | //! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture 459 | /**********************************************************************************/ 460 | typedef struct _CUVIDPARSERDISPINFO 461 | { 462 | int picture_index; /**< OUT: Index of the current picture */ 463 | int progressive_frame; /**< OUT: 1 if progressive frame; 0 otherwise */ 464 | int top_field_first; /**< OUT: 1 if top field is displayed first; 0 otherwise */ 465 | int repeat_first_field; /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, 466 | -1=unpaired field) */ 467 | CUvideotimestamp timestamp; /**< OUT: Presentation time stamp */ 468 | } CUVIDPARSERDISPINFO; 469 | 470 | /***********************************************************************************************************************/ 471 | //! Parser callbacks 472 | //! The parser will call these synchronously from within cuvidParseVideoData(), whenever there is sequence change or a picture 473 | //! is ready to be decoded and/or displayed. First argument in functions is "void *pUserData" member of structure CUVIDSOURCEPARAMS 474 | //! Return values from these callbacks are interpreted as below. If the callbacks return failure, it will be propagated by 475 | //! cuvidParseVideoData() to the application. 476 | //! Parser picks default operating point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set or return value is 477 | //! -1 or invalid operating point. 478 | //! PFNVIDSEQUENCECALLBACK : 0: fail, 1: succeeded, > 1: override dpb size of parser (set by CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces 479 | //! while creating parser) 480 | //! PFNVIDDECODECALLBACK : 0: fail, >=1: succeeded 481 | //! PFNVIDDISPLAYCALLBACK : 0: fail, >=1: succeeded 482 | //! PFNVIDOPPOINTCALLBACK : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint, bit 10-10: outputAllLayers, bit 11-30: reserved) 483 | //! PFNVIDSEIMSGCALLBACK : 0: fail, >=1: succeeded 484 | /***********************************************************************************************************************/ 485 | typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *); 486 | typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *); 487 | typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *); 488 | typedef int (CUDAAPI *PFNVIDOPPOINTCALLBACK)(void *, CUVIDOPERATINGPOINTINFO*); 489 | typedef int (CUDAAPI *PFNVIDSEIMSGCALLBACK) (void *, CUVIDSEIMESSAGEINFO *); 490 | 491 | /**************************************/ 492 | //! \ingroup STRUCTS 493 | //! \struct CUVIDPARSERPARAMS 494 | //! Used in cuvidCreateVideoParser API 495 | /**************************************/ 496 | typedef struct _CUVIDPARSERPARAMS 497 | { 498 | cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX */ 499 | unsigned int ulMaxNumDecodeSurfaces; /**< IN: Max # of decode surfaces (parser will cycle through these) */ 500 | unsigned int ulClockRate; /**< IN: Timestamp units in Hz (0=default=10000000Hz) */ 501 | unsigned int ulErrorThreshold; /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always 502 | IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */ 503 | unsigned int ulMaxDisplayDelay; /**< IN: Max display queue delay (improves pipelining of decode with display) 504 | 0=no delay (recommended values: 2..4) */ 505 | unsigned int bAnnexb : 1; /**< IN: AV1 annexB stream */ 506 | unsigned int bMemoryOptimize : 1; /**< IN: Utilize minimum picIdx from dpb to allow memory saving at the 507 | decoder layer, use cuvidReconfigureDecoder() to increase the 508 | decode surfaces if needed (perf may get impacted) */ 509 | unsigned int uReserved : 30; /**< Reserved for future use - set to zero */ 510 | unsigned int uReserved1[4]; /**< IN: Reserved for future use - set to 0 */ 511 | void *pUserData; /**< IN: User data for callbacks */ 512 | PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */ 513 | PFNVIDDECODECALLBACK pfnDecodePicture; /**< IN: Called when a picture is ready to be decoded (decode order) */ 514 | PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< IN: Called whenever a picture is ready to be displayed (display order) */ 515 | PFNVIDOPPOINTCALLBACK pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get operating point of a AV1 516 | scalable bitstream */ 517 | PFNVIDSEIMSGCALLBACK pfnGetSEIMsg; /**< IN: Called when all SEI messages are parsed for particular frame */ 518 | void *pvReserved2[5]; /**< Reserved for future use - set to NULL */ 519 | CUVIDEOFORMATEX *pExtVideoInfo; /**< IN: [Optional] sequence header data from system layer */ 520 | } CUVIDPARSERPARAMS; 521 | 522 | /************************************************************************************************/ 523 | //! \ingroup FUNCTS 524 | //! \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams) 525 | //! Create video parser object and initialize 526 | /************************************************************************************************/ 527 | typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams); 528 | 529 | /************************************************************************************************/ 530 | //! \ingroup FUNCTS 531 | //! \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket) 532 | //! Parse the video data from source data packet in pPacket 533 | //! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and 534 | //! calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking of HW decoding 535 | //! calls back pfnSequenceCallback with CUVIDEOFORMAT data for initial sequence header or when 536 | //! the decoder encounters a video format change 537 | //! calls back pfnDisplayPicture with CUVIDPARSERDISPINFO data to display a video frame 538 | /************************************************************************************************/ 539 | typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket); 540 | 541 | /************************************************************************************************/ 542 | //! \ingroup FUNCTS 543 | //! \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj) 544 | //! Destroy the video parser 545 | /************************************************************************************************/ 546 | typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj); 547 | 548 | /**********************************************************************************************/ 549 | 550 | #if defined(__cplusplus) 551 | } 552 | #endif /* __cplusplus */ 553 | 554 | #endif // __NVCUVID_H__ 555 | --------------------------------------------------------------------------------