Commit 1a7ea45f authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜

nvcodec: Fix crash on 32-bit Windows

We weren't using the correct calling convention when calling CUDA and
CUVID APIs. `CUDAAPI` is `__stdcall` on Windows. This was working fine
on x64 because `__stdcall` is ignored and there's no special calling
convention. However, on x86, we need to use `__stdcall`.
parent 7e93ae06
This diff is collapsed.
......@@ -31,116 +31,116 @@ gboolean gst_cuda_load_library (void);
/* cuda.h */
G_GNUC_INTERNAL
CUresult CuInit (unsigned int Flags);
CUresult CUDAAPI CuInit (unsigned int Flags);
G_GNUC_INTERNAL
CUresult CuGetErrorName (CUresult error,
const char **pStr);
CUresult CUDAAPI CuGetErrorName (CUresult error,
const char **pStr);
G_GNUC_INTERNAL
CUresult CuGetErrorString (CUresult error,
const char **pStr);
CUresult CUDAAPI CuGetErrorString (CUresult error,
const char **pStr);
G_GNUC_INTERNAL
CUresult CuCtxCreate (CUcontext * pctx,
unsigned int flags,
CUdevice dev);
CUresult CUDAAPI CuCtxCreate (CUcontext * pctx,
unsigned int flags,
CUdevice dev);
G_GNUC_INTERNAL
CUresult CuCtxDestroy (CUcontext ctx);
CUresult CUDAAPI CuCtxDestroy (CUcontext ctx);
G_GNUC_INTERNAL
CUresult CuCtxPopCurrent (CUcontext * pctx);
CUresult CUDAAPI CuCtxPopCurrent (CUcontext * pctx);
G_GNUC_INTERNAL
CUresult CuCtxPushCurrent (CUcontext ctx);
CUresult CUDAAPI CuCtxPushCurrent (CUcontext ctx);
G_GNUC_INTERNAL
CUresult CuGraphicsMapResources (unsigned int count,
CUgraphicsResource * resources,
CUstream hStream);
CUresult CUDAAPI CuGraphicsMapResources (unsigned int count,
CUgraphicsResource * resources,
CUstream hStream);
G_GNUC_INTERNAL
CUresult CuGraphicsUnmapResources (unsigned int count,
CUgraphicsResource * resources,
CUstream hStream);
CUresult CUDAAPI CuGraphicsUnmapResources (unsigned int count,
CUgraphicsResource * resources,
CUstream hStream);
G_GNUC_INTERNAL
CUresult CuGraphicsSubResourceGetMappedArray (CUarray * pArray,
CUgraphicsResource resource,
unsigned int arrayIndex,
unsigned int mipLevel);
CUresult CUDAAPI CuGraphicsSubResourceGetMappedArray (CUarray * pArray,
CUgraphicsResource resource,
unsigned int arrayIndex,
unsigned int mipLevel);
G_GNUC_INTERNAL
CUresult CuGraphicsResourceGetMappedPointer (CUdeviceptr * pDevPtr,
size_t * pSize,
CUgraphicsResource resource);
CUresult CUDAAPI CuGraphicsResourceGetMappedPointer (CUdeviceptr * pDevPtr,
size_t * pSize,
CUgraphicsResource resource);
G_GNUC_INTERNAL
CUresult CuGraphicsUnregisterResource (CUgraphicsResource resource);
CUresult CUDAAPI CuGraphicsUnregisterResource (CUgraphicsResource resource);
G_GNUC_INTERNAL
CUresult CuMemAlloc (CUdeviceptr * dptr,
unsigned int bytesize);
CUresult CUDAAPI CuMemAlloc (CUdeviceptr * dptr,
unsigned int bytesize);
G_GNUC_INTERNAL
CUresult CuMemAllocPitch (CUdeviceptr * dptr,
size_t * pPitch,
size_t WidthInBytes,
size_t Height,
unsigned int ElementSizeBytes);
CUresult CUDAAPI CuMemAllocPitch (CUdeviceptr * dptr,
size_t * pPitch,
size_t WidthInBytes,
size_t Height,
unsigned int ElementSizeBytes);
G_GNUC_INTERNAL
CUresult CuMemcpy2D (const CUDA_MEMCPY2D * pCopy);
CUresult CUDAAPI CuMemcpy2D (const CUDA_MEMCPY2D * pCopy);
G_GNUC_INTERNAL
CUresult CuMemcpy2DAsync (const CUDA_MEMCPY2D *pCopy, CUstream hStream);
CUresult CUDAAPI CuMemcpy2DAsync (const CUDA_MEMCPY2D *pCopy, CUstream hStream);
G_GNUC_INTERNAL
CUresult CuMemFree (CUdeviceptr dptr);
CUresult CUDAAPI CuMemFree (CUdeviceptr dptr);
G_GNUC_INTERNAL
CUresult CuStreamCreate (CUstream *phStream,
unsigned int Flags);
CUresult CUDAAPI CuStreamCreate (CUstream *phStream,
unsigned int Flags);
G_GNUC_INTERNAL
CUresult CuStreamDestroy (CUstream hStream);
CUresult CUDAAPI CuStreamDestroy (CUstream hStream);
G_GNUC_INTERNAL
CUresult CuStreamSynchronize (CUstream hStream);
CUresult CUDAAPI CuStreamSynchronize (CUstream hStream);
G_GNUC_INTERNAL
CUresult CuDeviceGet (CUdevice * device,
int ordinal);
CUresult CUDAAPI CuDeviceGet (CUdevice * device,
int ordinal);
G_GNUC_INTERNAL
CUresult CuDeviceGetCount (int *count);
CUresult CUDAAPI CuDeviceGetCount (int *count);
G_GNUC_INTERNAL
CUresult CuDeviceGetName (char *name,
int len,
CUdevice dev);
CUresult CUDAAPI CuDeviceGetName (char *name,
int len,
CUdevice dev);
G_GNUC_INTERNAL
CUresult CuDeviceGetAttribute (int *pi,
CUdevice_attribute attrib,
CUdevice dev);
CUresult CUDAAPI CuDeviceGetAttribute (int *pi,
CUdevice_attribute attrib,
CUdevice dev);
/* cudaGL.h */
G_GNUC_INTERNAL
CUresult CuGraphicsGLRegisterImage (CUgraphicsResource * pCudaResource,
unsigned int image,
unsigned int target,
unsigned int Flags);
CUresult CUDAAPI CuGraphicsGLRegisterImage (CUgraphicsResource * pCudaResource,
unsigned int image,
unsigned int target,
unsigned int Flags);
G_GNUC_INTERNAL
CUresult CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource,
unsigned int buffer,
unsigned int Flags);
CUresult CUDAAPI CuGraphicsGLRegisterBuffer (CUgraphicsResource * pCudaResource,
unsigned int buffer,
unsigned int Flags);
G_GNUC_INTERNAL
CUresult CuGraphicsResourceSetMapFlags (CUgraphicsResource resource,
unsigned int flags);
CUresult CUDAAPI CuGraphicsResourceSetMapFlags (CUgraphicsResource resource,
unsigned int flags);
G_END_DECLS
#endif /* __GST_CUDA_LOADER_H__ */
......@@ -44,25 +44,29 @@ typedef struct _GstnvdecCuvidVTable
{
gboolean loaded;
CUresult (*CuvidCtxLockCreate) (CUvideoctxlock * pLock, CUcontext ctx);
CUresult (*CuvidCtxLockDestroy) (CUvideoctxlock lck);
CUresult (*CuvidCtxLock) (CUvideoctxlock lck, unsigned int reserved_flags);
CUresult (*CuvidCtxUnlock) (CUvideoctxlock lck,
CUresult (CUDAAPI * CuvidCtxLockCreate) (CUvideoctxlock * pLock,
CUcontext ctx);
CUresult (CUDAAPI * CuvidCtxLockDestroy) (CUvideoctxlock lck);
CUresult (CUDAAPI * CuvidCtxLock) (CUvideoctxlock lck,
unsigned int reserved_flags);
CUresult (*CuvidCreateDecoder) (CUvideodecoder * phDecoder,
CUresult (CUDAAPI * CuvidCtxUnlock) (CUvideoctxlock lck,
unsigned int reserved_flags);
CUresult (CUDAAPI * CuvidCreateDecoder) (CUvideodecoder * phDecoder,
CUVIDDECODECREATEINFO * pdci);
CUresult (*CuvidDestroyDecoder) (CUvideodecoder hDecoder);
CUresult (*CuvidDecodePicture) (CUvideodecoder hDecoder,
CUresult (CUDAAPI * CuvidDestroyDecoder) (CUvideodecoder hDecoder);
CUresult (CUDAAPI * CuvidDecodePicture) (CUvideodecoder hDecoder,
CUVIDPICPARAMS * pPicParams);
CUresult (*CuvidCreateVideoParser) (CUvideoparser * pObj,
CUresult (CUDAAPI * CuvidCreateVideoParser) (CUvideoparser * pObj,
CUVIDPARSERPARAMS * pParams);
CUresult (*CuvidParseVideoData) (CUvideoparser obj,
CUresult (CUDAAPI * CuvidParseVideoData) (CUvideoparser obj,
CUVIDSOURCEDATAPACKET * pPacket);
CUresult (*CuvidDestroyVideoParser) (CUvideoparser obj);
CUresult (*CuvidMapVideoFrame) (CUvideodecoder hDecoder, int nPicIdx,
guintptr * pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS * pVPP);
CUresult (*CuvidUnmapVideoFrame) (CUvideodecoder hDecoder, guintptr DevPtr);
CUresult (*CuvidGetDecoderCaps) (CUVIDDECODECAPS * pdc);
CUresult (CUDAAPI * CuvidDestroyVideoParser) (CUvideoparser obj);
CUresult (CUDAAPI * CuvidMapVideoFrame) (CUvideodecoder hDecoder,
int nPicIdx, guintptr * pDevPtr, unsigned int *pPitch,
CUVIDPROCPARAMS * pVPP);
CUresult (CUDAAPI * CuvidUnmapVideoFrame) (CUvideodecoder hDecoder,
guintptr DevPtr);
CUresult (CUDAAPI * CuvidGetDecoderCaps) (CUVIDDECODECAPS * pdc);
} GstnvdecCuvidVTable;
static GstnvdecCuvidVTable gst_cuvid_vtable = { 0, };
......@@ -115,7 +119,7 @@ gst_cuvid_can_get_decoder_caps (void)
return ! !gst_cuvid_vtable.CuvidGetDecoderCaps;
}
CUresult
CUresult CUDAAPI
CuvidCtxLockCreate (CUvideoctxlock * pLock, CUcontext ctx)
{
g_assert (gst_cuvid_vtable.CuvidCtxLockCreate != NULL);
......@@ -123,7 +127,7 @@ CuvidCtxLockCreate (CUvideoctxlock * pLock, CUcontext ctx)
return gst_cuvid_vtable.CuvidCtxLockCreate (pLock, ctx);
}
CUresult
CUresult CUDAAPI
CuvidCtxLockDestroy (CUvideoctxlock lck)
{
g_assert (gst_cuvid_vtable.CuvidCtxLockDestroy != NULL);
......@@ -131,7 +135,7 @@ CuvidCtxLockDestroy (CUvideoctxlock lck)
return gst_cuvid_vtable.CuvidCtxLockDestroy (lck);
}
CUresult
CUresult CUDAAPI
CuvidCtxLock (CUvideoctxlock lck, unsigned int reserved_flags)
{
g_assert (gst_cuvid_vtable.CuvidCtxLock != NULL);
......@@ -139,7 +143,7 @@ CuvidCtxLock (CUvideoctxlock lck, unsigned int reserved_flags)
return gst_cuvid_vtable.CuvidCtxLock (lck, reserved_flags);
}
CUresult
CUresult CUDAAPI
CuvidCtxUnlock (CUvideoctxlock lck, unsigned int reserved_flags)
{
g_assert (gst_cuvid_vtable.CuvidCtxLockDestroy != NULL);
......@@ -147,7 +151,7 @@ CuvidCtxUnlock (CUvideoctxlock lck, unsigned int reserved_flags)
return gst_cuvid_vtable.CuvidCtxUnlock (lck, reserved_flags);
}
CUresult
CUresult CUDAAPI
CuvidCreateDecoder (CUvideodecoder * phDecoder, CUVIDDECODECREATEINFO * pdci)
{
g_assert (gst_cuvid_vtable.CuvidCreateDecoder != NULL);
......@@ -155,7 +159,7 @@ CuvidCreateDecoder (CUvideodecoder * phDecoder, CUVIDDECODECREATEINFO * pdci)
return gst_cuvid_vtable.CuvidCreateDecoder (phDecoder, pdci);
}
CUresult
CUresult CUDAAPI
CuvidDestroyDecoder (CUvideodecoder hDecoder)
{
g_assert (gst_cuvid_vtable.CuvidDestroyDecoder != NULL);
......@@ -163,7 +167,7 @@ CuvidDestroyDecoder (CUvideodecoder hDecoder)
return gst_cuvid_vtable.CuvidDestroyDecoder (hDecoder);
}
CUresult
CUresult CUDAAPI
CuvidDecodePicture (CUvideodecoder hDecoder, CUVIDPICPARAMS * pPicParams)
{
g_assert (gst_cuvid_vtable.CuvidDecodePicture != NULL);
......@@ -171,7 +175,7 @@ CuvidDecodePicture (CUvideodecoder hDecoder, CUVIDPICPARAMS * pPicParams)
return gst_cuvid_vtable.CuvidDecodePicture (hDecoder, pPicParams);
}
CUresult
CUresult CUDAAPI
CuvidCreateVideoParser (CUvideoparser * pObj, CUVIDPARSERPARAMS * pParams)
{
g_assert (gst_cuvid_vtable.CuvidCreateVideoParser != NULL);
......@@ -179,7 +183,7 @@ CuvidCreateVideoParser (CUvideoparser * pObj, CUVIDPARSERPARAMS * pParams)
return gst_cuvid_vtable.CuvidCreateVideoParser (pObj, pParams);
}
CUresult
CUresult CUDAAPI
CuvidParseVideoData (CUvideoparser obj, CUVIDSOURCEDATAPACKET * pPacket)
{
g_assert (gst_cuvid_vtable.CuvidParseVideoData != NULL);
......@@ -187,7 +191,7 @@ CuvidParseVideoData (CUvideoparser obj, CUVIDSOURCEDATAPACKET * pPacket)
return gst_cuvid_vtable.CuvidParseVideoData (obj, pPacket);
}
CUresult
CUresult CUDAAPI
CuvidDestroyVideoParser (CUvideoparser obj)
{
g_assert (gst_cuvid_vtable.CuvidDestroyVideoParser != NULL);
......@@ -195,7 +199,7 @@ CuvidDestroyVideoParser (CUvideoparser obj)
return gst_cuvid_vtable.CuvidDestroyVideoParser (obj);
}
CUresult
CUresult CUDAAPI
CuvidMapVideoFrame (CUvideodecoder hDecoder, int nPicIdx,
guintptr * pDevPtr, unsigned int *pPitch, CUVIDPROCPARAMS * pVPP)
{
......@@ -205,7 +209,7 @@ CuvidMapVideoFrame (CUvideodecoder hDecoder, int nPicIdx,
pPitch, pVPP);
}
CUresult
CUresult CUDAAPI
CuvidUnmapVideoFrame (CUvideodecoder hDecoder, guintptr DevPtr)
{
g_assert (gst_cuvid_vtable.CuvidUnmapVideoFrame != NULL);
......@@ -213,7 +217,7 @@ CuvidUnmapVideoFrame (CUvideodecoder hDecoder, guintptr DevPtr)
return gst_cuvid_vtable.CuvidUnmapVideoFrame (hDecoder, DevPtr);
}
CUresult
CUresult CUDAAPI
CuvidGetDecoderCaps (CUVIDDECODECAPS * pdc)
{
g_assert (gst_cuvid_vtable.CuvidGetDecoderCaps != NULL);
......
......@@ -21,6 +21,7 @@
#define __GST_CUVID_LOADER_H__
#include <gst/gst.h>
#include "stub/cuda.h"
#include "nvcuvid.h"
G_BEGIN_DECLS
......@@ -33,53 +34,54 @@ G_GNUC_INTERNAL
gboolean gst_cuvid_can_get_decoder_caps (void);
G_GNUC_INTERNAL
CUresult CuvidCtxLockCreate (CUvideoctxlock * pLock, CUcontext ctx);
CUresult CUDAAPI CuvidCtxLockCreate (CUvideoctxlock * pLock,
CUcontext ctx);
G_GNUC_INTERNAL
CUresult CuvidCtxLockDestroy (CUvideoctxlock lck);
CUresult CUDAAPI CuvidCtxLockDestroy (CUvideoctxlock lck);
G_GNUC_INTERNAL
CUresult CuvidCtxLock (CUvideoctxlock lck,
unsigned int reserved_flags);
CUresult CUDAAPI CuvidCtxLock (CUvideoctxlock lck,
unsigned int reserved_flags);
G_GNUC_INTERNAL
CUresult CuvidCtxUnlock (CUvideoctxlock lck,
unsigned int reserved_flags);
CUresult CUDAAPI CuvidCtxUnlock (CUvideoctxlock lck,
unsigned int reserved_flags);
G_GNUC_INTERNAL
CUresult CuvidCreateDecoder (CUvideodecoder * phDecoder,
CUVIDDECODECREATEINFO * pdci);
CUresult CUDAAPI CuvidCreateDecoder (CUvideodecoder * phDecoder,
CUVIDDECODECREATEINFO * pdci);
G_GNUC_INTERNAL
CUresult CuvidDestroyDecoder (CUvideodecoder hDecoder);
CUresult CUDAAPI CuvidDestroyDecoder (CUvideodecoder hDecoder);
G_GNUC_INTERNAL
CUresult CuvidDecodePicture (CUvideodecoder hDecoder,
CUVIDPICPARAMS * pPicParams);
CUresult CUDAAPI CuvidDecodePicture (CUvideodecoder hDecoder,
CUVIDPICPARAMS * pPicParams);
G_GNUC_INTERNAL
CUresult CuvidCreateVideoParser (CUvideoparser * pObj,
CUVIDPARSERPARAMS * pParams);
CUresult CUDAAPI CuvidCreateVideoParser (CUvideoparser * pObj,
CUVIDPARSERPARAMS * pParams);
G_GNUC_INTERNAL
CUresult CuvidParseVideoData (CUvideoparser obj,
CUVIDSOURCEDATAPACKET * pPacket);
CUresult CUDAAPI CuvidParseVideoData (CUvideoparser obj,
CUVIDSOURCEDATAPACKET * pPacket);
G_GNUC_INTERNAL
CUresult CuvidDestroyVideoParser (CUvideoparser obj);
CUresult CUDAAPI CuvidDestroyVideoParser (CUvideoparser obj);
G_GNUC_INTERNAL
CUresult CuvidMapVideoFrame (CUvideodecoder hDecoder,
int nPicIdx,
guintptr * pDevPtr,
unsigned int *pPitch,
CUVIDPROCPARAMS * pVPP);
CUresult CUDAAPI CuvidMapVideoFrame (CUvideodecoder hDecoder,
int nPicIdx,
guintptr * pDevPtr,
unsigned int *pPitch,
CUVIDPROCPARAMS * pVPP);
G_GNUC_INTERNAL
CUresult CuvidUnmapVideoFrame (CUvideodecoder hDecoder,
guintptr DevPtr);
CUresult CUDAAPI CuvidUnmapVideoFrame (CUvideodecoder hDecoder,
guintptr DevPtr);
G_GNUC_INTERNAL
CUresult CuvidGetDecoderCaps (CUVIDDECODECAPS * pdc);
CUresult CUDAAPI CuvidGetDecoderCaps (CUVIDDECODECAPS * pdc);
G_END_DECLS
#endif /* __GST_CUVID_LOADER_H__ */
......@@ -93,7 +93,12 @@ typedef struct
} CUDA_MEMCPY2D;
#define CUDA_VERSION 10000
#ifdef _WIN32
#define CUDAAPI __stdcall
#else
#define CUDAAPI
#endif
#define cuCtxCreate cuCtxCreate_v2
#define cuCtxDestroy cuCtxDestroy_v2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment