Skip to content
Snippets Groups Projects
Commit 5c02d282 authored by Timo Rothenpieler's avatar Timo Rothenpieler
Browse files

compat/cuda: add dynamic loader

parent d316b21d
No related branches found
No related tags found
No related merge requests found
/*
* This copyright notice applies to this header file only:
*
* Copyright (c) 2016
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the software, and to permit persons to whom the
* software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined(AV_COMPAT_DYNLINK_CUDA_H) && !defined(CUDA_VERSION)
#define AV_COMPAT_DYNLINK_CUDA_H
#include <stddef.h>
#define CUDA_VERSION 7050
#if defined(_WIN32) || defined(__CYGWIN__)
#define CUDAAPI __stdcall
#else
#define CUDAAPI
#endif
#define CU_CTX_SCHED_BLOCKING_SYNC 4
typedef int CUdevice;
typedef void* CUarray;
typedef void* CUcontext;
#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
typedef unsigned long long CUdeviceptr;
#else
typedef unsigned int CUdeviceptr;
#endif
typedef enum cudaError_enum {
CUDA_SUCCESS = 0
} CUresult;
typedef enum CUmemorytype_enum {
CU_MEMORYTYPE_HOST = 1,
CU_MEMORYTYPE_DEVICE = 2
} CUmemorytype;
typedef struct CUDA_MEMCPY2D_st {
size_t srcXInBytes;
size_t srcY;
CUmemorytype srcMemoryType;
const void *srcHost;
CUdeviceptr srcDevice;
CUarray srcArray;
size_t srcPitch;
size_t dstXInBytes;
size_t dstY;
CUmemorytype dstMemoryType;
void *dstHost;
CUdeviceptr dstDevice;
CUarray dstArray;
size_t dstPitch;
size_t WidthInBytes;
size_t Height;
} CUDA_MEMCPY2D;
typedef CUresult CUDAAPI tcuInit(unsigned int Flags);
typedef CUresult CUDAAPI tcuDeviceGetCount(int *count);
typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
typedef CUresult CUDAAPI tcuCtxPushCurrent_v2(CUcontext *pctx);
typedef CUresult CUDAAPI tcuCtxPopCurrent_v2(CUcontext *pctx);
typedef CUresult CUDAAPI tcuCtxDestroy_v2(CUcontext ctx);
typedef CUresult CUDAAPI tcuMemAlloc_v2(CUdeviceptr *dptr, size_t bytesize);
typedef CUresult CUDAAPI tcuMemFree_v2(CUdeviceptr dptr);
typedef CUresult CUDAAPI tcuMemcpy2D_v2(const CUDA_MEMCPY2D *pcopy);
typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char** pstr);
typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char** pstr);
#endif
This diff is collapsed.
/*
* This copyright notice applies to this header file only:
*
* Copyright (c) 2016
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the software, and to permit persons to whom the
* software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef AV_COMPAT_CUDA_DYNLINK_LOADER_H
#define AV_COMPAT_CUDA_DYNLINK_LOADER_H
#include "compat/cuda/dynlink_cuda.h"
#include "compat/cuda/dynlink_nvcuvid.h"
#include "compat/nvenc/nvEncodeAPI.h"
#include "compat/w32dlfcn.h"
#include "libavutil/log.h"
#include "libavutil/error.h"
#if defined(_WIN32)
# define LIB_HANDLE HMODULE
#else
# define LIB_HANDLE void*
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
# define CUDA_LIBNAME "nvcuda.dll"
# define NVCUVID_LIBNAME "nvcuvid.dll"
# if ARCH_X86_64
# define NVENC_LIBNAME "nvEncodeAPI64.dll"
# else
# define NVENC_LIBNAME "nvEncodeAPI.dll"
# endif
#else
# define CUDA_LIBNAME "libcuda.so.1"
# define NVCUVID_LIBNAME "libnvcuvid.so.1"
# define NVENC_LIBNAME "libnvidia-encode.so.1"
#endif
#define LOAD_LIBRARY(l, path) \
do { \
if (!((l) = dlopen(path, RTLD_LAZY))) { \
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", path); \
ret = AVERROR_UNKNOWN; \
goto error; \
} \
av_log(NULL, AV_LOG_TRACE, "Loaded lib: %s\n", path); \
} while (0)
#define LOAD_SYMBOL(fun, symbol) \
do { \
if (!((f->fun) = dlsym(f->lib, symbol))) { \
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
ret = AVERROR_UNKNOWN; \
goto error; \
} \
av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
} while (0)
#define GENERIC_LOAD_FUNC_PREAMBLE(T, n, N) \
T *f; \
int ret; \
\
n##_free_functions(functions); \
\
f = *functions = av_mallocz(sizeof(*f)); \
if (!f) \
return AVERROR(ENOMEM); \
\
LOAD_LIBRARY(f->lib, N);
#define GENERIC_LOAD_FUNC_FINALE(n) \
return 0; \
error: \
n##_free_functions(functions); \
return ret;
#define GENERIC_FREE_FUNC() \
if (!functions) \
return; \
if (*functions && (*functions)->lib) \
dlclose((*functions)->lib); \
av_freep(functions);
#ifdef AV_COMPAT_DYNLINK_CUDA_H
typedef struct CudaFunctions {
tcuInit *cuInit;
tcuDeviceGetCount *cuDeviceGetCount;
tcuDeviceGet *cuDeviceGet;
tcuDeviceGetName *cuDeviceGetName;
tcuDeviceComputeCapability *cuDeviceComputeCapability;
tcuCtxCreate_v2 *cuCtxCreate;
tcuCtxPushCurrent_v2 *cuCtxPushCurrent;
tcuCtxPopCurrent_v2 *cuCtxPopCurrent;
tcuCtxDestroy_v2 *cuCtxDestroy;
tcuMemAlloc_v2 *cuMemAlloc;
tcuMemFree_v2 *cuMemFree;
tcuMemcpy2D_v2 *cuMemcpy2D;
tcuGetErrorName *cuGetErrorName;
tcuGetErrorString *cuGetErrorString;
LIB_HANDLE lib;
} CudaFunctions;
#else
typedef struct CudaFunctions CudaFunctions;
#endif
typedef struct CuvidFunctions {
tcuvidCreateDecoder *cuvidCreateDecoder;
tcuvidDestroyDecoder *cuvidDestroyDecoder;
tcuvidDecodePicture *cuvidDecodePicture;
tcuvidMapVideoFrame *cuvidMapVideoFrame;
tcuvidUnmapVideoFrame *cuvidUnmapVideoFrame;
tcuvidCtxLockCreate *cuvidCtxLockCreate;
tcuvidCtxLockDestroy *cuvidCtxLockDestroy;
tcuvidCtxLock *cuvidCtxLock;
tcuvidCtxUnlock *cuvidCtxUnlock;
tcuvidCreateVideoSource *cuvidCreateVideoSource;
tcuvidCreateVideoSourceW *cuvidCreateVideoSourceW;
tcuvidDestroyVideoSource *cuvidDestroyVideoSource;
tcuvidSetVideoSourceState *cuvidSetVideoSourceState;
tcuvidGetVideoSourceState *cuvidGetVideoSourceState;
tcuvidGetSourceVideoFormat *cuvidGetSourceVideoFormat;
tcuvidGetSourceAudioFormat *cuvidGetSourceAudioFormat;
tcuvidCreateVideoParser *cuvidCreateVideoParser;
tcuvidParseVideoData *cuvidParseVideoData;
tcuvidDestroyVideoParser *cuvidDestroyVideoParser;
LIB_HANDLE lib;
} CuvidFunctions;
typedef struct NvencFunctions {
NVENCSTATUS (NVENCAPI *NvEncodeAPICreateInstance)(NV_ENCODE_API_FUNCTION_LIST *functionList);
NVENCSTATUS (NVENCAPI *NvEncodeAPIGetMaxSupportedVersion)(uint32_t* version);
LIB_HANDLE lib;
} NvencFunctions;
#ifdef AV_COMPAT_DYNLINK_CUDA_H
static inline void cuda_free_functions(CudaFunctions **functions)
{
GENERIC_FREE_FUNC();
}
#endif
static inline void cuvid_free_functions(CuvidFunctions **functions)
{
GENERIC_FREE_FUNC();
}
static inline void nvenc_free_functions(NvencFunctions **functions)
{
GENERIC_FREE_FUNC();
}
#ifdef AV_COMPAT_DYNLINK_CUDA_H
static inline int cuda_load_functions(CudaFunctions **functions)
{
GENERIC_LOAD_FUNC_PREAMBLE(CudaFunctions, cuda, CUDA_LIBNAME);
LOAD_SYMBOL(cuInit, "cuInit");
LOAD_SYMBOL(cuDeviceGetCount, "cuDeviceGetCount");
LOAD_SYMBOL(cuDeviceGet, "cuDeviceGet");
LOAD_SYMBOL(cuDeviceGetName, "cuDeviceGetName");
LOAD_SYMBOL(cuDeviceComputeCapability, "cuDeviceComputeCapability");
LOAD_SYMBOL(cuCtxCreate, "cuCtxCreate_v2");
LOAD_SYMBOL(cuCtxPushCurrent, "cuCtxPushCurrent_v2");
LOAD_SYMBOL(cuCtxPopCurrent, "cuCtxPopCurrent_v2");
LOAD_SYMBOL(cuCtxDestroy, "cuCtxDestroy_v2");
LOAD_SYMBOL(cuMemAlloc, "cuMemAlloc_v2");
LOAD_SYMBOL(cuMemFree, "cuMemFree_v2");
LOAD_SYMBOL(cuMemcpy2D, "cuMemcpy2D_v2");
LOAD_SYMBOL(cuGetErrorName, "cuGetErrorName");
LOAD_SYMBOL(cuGetErrorString, "cuGetErrorString");
GENERIC_LOAD_FUNC_FINALE(cuda);
}
#endif
static inline int cuvid_load_functions(CuvidFunctions **functions)
{
GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
LOAD_SYMBOL(cuvidCreateDecoder, "cuvidCreateDecoder");
LOAD_SYMBOL(cuvidDestroyDecoder, "cuvidDestroyDecoder");
LOAD_SYMBOL(cuvidDecodePicture, "cuvidDecodePicture");
#ifdef __CUVID_DEVPTR64
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame64");
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
#else
LOAD_SYMBOL(cuvidMapVideoFrame, "cuvidMapVideoFrame");
LOAD_SYMBOL(cuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
#endif
LOAD_SYMBOL(cuvidCtxLockCreate, "cuvidCtxLockCreate");
LOAD_SYMBOL(cuvidCtxLockDestroy, "cuvidCtxLockDestroy");
LOAD_SYMBOL(cuvidCtxLock, "cuvidCtxLock");
LOAD_SYMBOL(cuvidCtxUnlock, "cuvidCtxUnlock");
LOAD_SYMBOL(cuvidCreateVideoSource, "cuvidCreateVideoSource");
LOAD_SYMBOL(cuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
LOAD_SYMBOL(cuvidDestroyVideoSource, "cuvidDestroyVideoSource");
LOAD_SYMBOL(cuvidSetVideoSourceState, "cuvidSetVideoSourceState");
LOAD_SYMBOL(cuvidGetVideoSourceState, "cuvidGetVideoSourceState");
LOAD_SYMBOL(cuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
LOAD_SYMBOL(cuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
LOAD_SYMBOL(cuvidCreateVideoParser, "cuvidCreateVideoParser");
LOAD_SYMBOL(cuvidParseVideoData, "cuvidParseVideoData");
LOAD_SYMBOL(cuvidDestroyVideoParser, "cuvidDestroyVideoParser");
GENERIC_LOAD_FUNC_FINALE(cuvid);
}
static inline int nvenc_load_functions(NvencFunctions **functions)
{
GENERIC_LOAD_FUNC_PREAMBLE(NvencFunctions, nvenc, NVENC_LIBNAME);
LOAD_SYMBOL(NvEncodeAPICreateInstance, "NvEncodeAPICreateInstance");
LOAD_SYMBOL(NvEncodeAPIGetMaxSupportedVersion, "NvEncodeAPIGetMaxSupportedVersion");
GENERIC_LOAD_FUNC_FINALE(nvenc);
}
#undef GENERIC_LOAD_FUNC_PREAMBLE
#undef LOAD_LIBRARY
#undef LOAD_SYMBOL
#undef GENERIC_LOAD_FUNC_FINALE
#undef GENERIC_FREE_FUNC
#undef CUDA_LIBNAME
#undef NVCUVID_LIBNAME
#undef NVENC_LIBNAME
#undef LIB_HANDLE
#endif
/*
* This copyright notice applies to this header file only:
*
* Copyright (c) 2010-2016 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the software, and to permit persons to whom the
* software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file nvcuvid.h
* NvCuvid API provides Video Decoding interface to NVIDIA GPU devices.
* \date 2015-2015
* This file contains the interface constants, structure definitions and function prototypes.
*/
#if !defined(__NVCUVID_H__)
#define __NVCUVID_H__
#include "compat/cuda/dynlink_cuviddec.h"
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
////////////////////////////////////////////////////////////////////////////////////////////////
//
// High-level helper APIs for video sources
//
typedef void *CUvideosource;
typedef void *CUvideoparser;
typedef long long CUvideotimestamp;
/**
* \addtogroup VIDEO_PARSER Video Parser
* @{
*/
/*!
* \enum cudaVideoState
* Video Source State
*/
typedef enum {
cudaVideoState_Error = -1, /**< Error state (invalid source) */
cudaVideoState_Stopped = 0, /**< Source is stopped (or reached end-of-stream) */
cudaVideoState_Started = 1 /**< Source is running and delivering data */
} cudaVideoState;
/*!
* \enum cudaAudioCodec
* Audio compression
*/
typedef enum {
cudaAudioCodec_MPEG1=0, /**< MPEG-1 Audio */
cudaAudioCodec_MPEG2, /**< MPEG-2 Audio */
cudaAudioCodec_MP3, /**< MPEG-1 Layer III Audio */
cudaAudioCodec_AC3, /**< Dolby Digital (AC3) Audio */
cudaAudioCodec_LPCM /**< PCM Audio */
} cudaAudioCodec;
/*!
* \struct CUVIDEOFORMAT
* Video format
*/
typedef struct
{
cudaVideoCodec codec; /**< Compression format */
/**
* frame rate = numerator / denominator (for example: 30000/1001)
*/
struct {
unsigned int numerator; /**< frame rate numerator (0 = unspecified or variable frame rate) */
unsigned int denominator; /**< frame rate denominator (0 = unspecified or variable frame rate) */
} frame_rate;
unsigned char progressive_sequence; /**< 0=interlaced, 1=progressive */
unsigned char bit_depth_luma_minus8; /**< high bit depth Luma */
unsigned char bit_depth_chroma_minus8; /**< high bit depth Chroma */
unsigned char reserved1; /**< Reserved for future use */
unsigned int coded_width; /**< coded frame width */
unsigned int coded_height; /**< coded frame height */
/**
* area of the frame that should be displayed
* typical example:
* coded_width = 1920, coded_height = 1088
* display_area = { 0,0,1920,1080 }
*/
struct {
int left; /**< left position of display rect */
int top; /**< top position of display rect */
int right; /**< right position of display rect */
int bottom; /**< bottom position of display rect */
} display_area;
cudaVideoChromaFormat chroma_format; /**< Chroma format */
unsigned int bitrate; /**< video bitrate (bps, 0=unknown) */
/**
* Display Aspect Ratio = x:y (4:3, 16:9, etc)
*/
struct {
int x;
int y;
} display_aspect_ratio;
/**
* Video Signal Description
*/
struct {
unsigned char video_format : 3;
unsigned char video_full_range_flag : 1;
unsigned char reserved_zero_bits : 4;
unsigned char color_primaries;
unsigned char transfer_characteristics;
unsigned char matrix_coefficients;
} video_signal_description;
unsigned int seqhdr_data_length; /**< Additional bytes following (CUVIDEOFORMATEX) */
} CUVIDEOFORMAT;
/*!
* \struct CUVIDEOFORMATEX
* Video format including raw sequence header information
*/
typedef struct
{
CUVIDEOFORMAT format;
unsigned char raw_seqhdr_data[1024];
} CUVIDEOFORMATEX;
/*!
* \struct CUAUDIOFORMAT
* Audio Formats
*/
typedef struct
{
cudaAudioCodec codec; /**< Compression format */
unsigned int channels; /**< number of audio channels */
unsigned int samplespersec; /**< sampling frequency */
unsigned int bitrate; /**< For uncompressed, can also be used to determine bits per sample */
unsigned int reserved1; /**< Reserved for future use */
unsigned int reserved2; /**< Reserved for future use */
} CUAUDIOFORMAT;
/*!
* \enum CUvideopacketflags
* Data packet flags
*/
typedef enum {
CUVID_PKT_ENDOFSTREAM = 0x01, /**< Set when this is the last packet for this stream */
CUVID_PKT_TIMESTAMP = 0x02, /**< Timestamp is valid */
CUVID_PKT_DISCONTINUITY = 0x04 /**< Set when a discontinuity has to be signalled */
} CUvideopacketflags;
/*!
* \struct CUVIDSOURCEDATAPACKET
* Data Packet
*/
typedef struct _CUVIDSOURCEDATAPACKET
{
unsigned long flags; /**< Combination of CUVID_PKT_XXX flags */
unsigned long payload_size; /**< number of bytes in the payload (may be zero if EOS flag is set) */
const unsigned char *payload; /**< Pointer to packet payload data (may be NULL if EOS flag is set) */
CUvideotimestamp timestamp; /**< Presentation timestamp (10MHz clock), only valid if CUVID_PKT_TIMESTAMP flag is set */
} CUVIDSOURCEDATAPACKET;
// Callback for packet delivery
typedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *);
/*!
* \struct CUVIDSOURCEPARAMS
* Source Params
*/
typedef struct _CUVIDSOURCEPARAMS
{
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
unsigned int uReserved1[7]; /**< Reserved for future use - set to zero */
void *pUserData; /**< Parameter passed in to the data handlers */
PFNVIDSOURCECALLBACK pfnVideoDataHandler; /**< Called to deliver audio packets */
PFNVIDSOURCECALLBACK pfnAudioDataHandler; /**< Called to deliver video packets */
void *pvReserved2[8]; /**< Reserved for future use - set to NULL */
} CUVIDSOURCEPARAMS;
/*!
* \enum CUvideosourceformat_flags
* CUvideosourceformat_flags
*/
typedef enum {
CUVID_FMT_EXTFORMATINFO = 0x100 /**< Return extended format structure (CUVIDEOFORMATEX) */
} CUvideosourceformat_flags;
#if !defined(__APPLE__)
/**
* \fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)
* Create Video Source
*/
typedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);
/**
* \fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)
* Create Video Source
*/
typedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);
/**
* \fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)
* Destroy Video Source
*/
typedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);
/**
* \fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)
* Set Video Source state
*/
typedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);
/**
* \fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)
* Get Video Source state
*/
typedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj);
/**
* \fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)
* Get Video Source Format
*/
typedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);
/**
* \fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)
* Set Video Source state
*/
typedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);
#endif
/**
* \struct CUVIDPARSERDISPINFO
*/
typedef struct _CUVIDPARSERDISPINFO
{
int picture_index; /**< */
int progressive_frame; /**< */
int top_field_first; /**< */
int repeat_first_field; /**< Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling, -1=unpaired field) */
CUvideotimestamp timestamp; /**< */
} CUVIDPARSERDISPINFO;
//
// Parser callbacks
// The parser will call these synchronously from within cuvidParseVideoData(), whenever a picture is ready to
// be decoded and/or displayed.
//
typedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *);
typedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *);
typedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *);
/**
* \struct CUVIDPARSERPARAMS
*/
typedef struct _CUVIDPARSERPARAMS
{
cudaVideoCodec CodecType; /**< cudaVideoCodec_XXX */
unsigned int ulMaxNumDecodeSurfaces; /**< Max # of decode surfaces (parser will cycle through these) */
unsigned int ulClockRate; /**< Timestamp units in Hz (0=default=10000000Hz) */
unsigned int ulErrorThreshold; /**< % Error threshold (0-100) for calling pfnDecodePicture (100=always call pfnDecodePicture even if picture bitstream is fully corrupted) */
unsigned int ulMaxDisplayDelay; /**< Max display queue delay (improves pipelining of decode with display) - 0=no delay (recommended values: 2..4) */
unsigned int uReserved1[5]; /**< Reserved for future use - set to 0 */
void *pUserData; /**< User data for callbacks */
PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< Called before decoding frames and/or whenever there is a format change */
PFNVIDDECODECALLBACK pfnDecodePicture; /**< Called when a picture is ready to be decoded (decode order) */
PFNVIDDISPLAYCALLBACK pfnDisplayPicture; /**< Called whenever a picture is ready to be displayed (display order) */
void *pvReserved2[7]; /**< Reserved for future use - set to NULL */
CUVIDEOFORMATEX *pExtVideoInfo; /**< [Optional] sequence header data from system layer */
} CUVIDPARSERPARAMS;
/**
* \fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)
*/
typedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);
/**
* \fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)
*/
typedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);
/**
* \fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)
*/
typedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);
/** @} */ /* END VIDEO_PARSER */
////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif // __NVCUVID_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment