I’m trying to knock up a version of the cudaDecodeGL sample application but on a live source, rendering in OpenGL. I’ve got a really simple first step application which is crashing on a call to cuvidCreateDecoder. First I create the CUDA context:
g_oDevice = cutGetMaxGflopsDeviceId();
cutilGLDeviceInitDrv ( g_oDevice, argcp, argv );
cutilDrvSafeCallNoSync( cuGLCtxCreate( &g_oContext, CU_CTX_BLOCKING_SYNC, g_oDevice ));
// Create the Video Context Lock (used for synchronization)
cutilDrvSafeCallNoSync( cuvidCtxLockCreate ( &cuCtxLock, g_oContext ));
This block works for my live encoder project. Then very simply I try to create a decoder context:
memset ( (void*)&decodeParams, 0, sizeof ( CUVIDDECODECREATEINFO ));
decodeParams.CodecType = cudaVideoCodec_H264;
decodeParams.ulWidth = GL_IMAGE_WIDTH;
decodeParams.ulHeight = GL_IMAGE_HEIGHT;
decodeParams.ulNumDecodeSurfaces = 20; // MAX_FRM_CNT;
// Limit decode memory to 24MB (16M pixels at 4:2:0 = 24M bytes)
while ( decodeParams.ulNumDecodeSurfaces * decodeParams.ulWidth * decodeParams.ulHeight > 16*1024*1024 )
{
decodeParams.ulNumDecodeSurfaces--;
}
decodeParams.ChromaFormat = cudaVideoChromaFormat_420;
decodeParams.OutputFormat = cudaVideoSurfaceFormat_NV12;
decodeParams.DeinterlaceMode = cudaVideoDeinterlaceMode_Adaptive;
// Output format
decodeParams.ulTargetWidth = GL_IMAGE_WIDTH;
decodeParams.ulTargetHeight = GL_IMAGE_HEIGHT;
decodeParams.ulNumOutputSurfaces = 2;
decodeParams.ulCreationFlags = cudaVideoCreate_Default;
decodeParams.vidLock = cuCtxLock;
CUresult result = cuvidCreateDecoder( pDecoder, &decodeParams );
So all basically hard coded results, look good in the debugger. I never get a return from creating the decoder, and there is no stack trace (it dies somewhere in nvcuvid.dll).
I have the latest CUDA 3.2, my encoder project works and the cudaDecodeGL project seems to run correctly. Is there maybe a missing step between creating the context and the decoder?
Thanks!
This was a stupid error on my part. Calls to cuvidCreateDecoder expect that the decoder object already has memory assigned to it, my decleration was:
CUvideodecoder *oDecoder_;
It just needed to be a member variable, that or allocated before the call
CUvideodecoder pDecoder;
I’m trying to knock up a version of the cudaDecodeGL sample application but on a live source, rendering in OpenGL. I’ve got a really simple first step application which is crashing on a call to cuvidCreateDecoder. First I create the CUDA context:
g_oDevice = cutGetMaxGflopsDeviceId();
cutilGLDeviceInitDrv ( g_oDevice, argcp, argv );
cutilDrvSafeCallNoSync( cuGLCtxCreate( &g_oContext, CU_CTX_BLOCKING_SYNC, g_oDevice ));
// Create the Video Context Lock (used for synchronization)
cutilDrvSafeCallNoSync( cuvidCtxLockCreate ( &cuCtxLock, g_oContext ));
This block works for my live encoder project. Then very simply I try to create a decoder context:
memset ( (void*)&decodeParams, 0, sizeof ( CUVIDDECODECREATEINFO ));
decodeParams.CodecType = cudaVideoCodec_H264;
decodeParams.ulWidth = GL_IMAGE_WIDTH;
decodeParams.ulHeight = GL_IMAGE_HEIGHT;
decodeParams.ulNumDecodeSurfaces = 20; // MAX_FRM_CNT;
// Limit decode memory to 24MB (16M pixels at 4:2:0 = 24M bytes)
while ( decodeParams.ulNumDecodeSurfaces * decodeParams.ulWidth * decodeParams.ulHeight > 16*1024*1024 )
{
decodeParams.ulNumDecodeSurfaces--;
}
decodeParams.ChromaFormat = cudaVideoChromaFormat_420;
decodeParams.OutputFormat = cudaVideoSurfaceFormat_NV12;
decodeParams.DeinterlaceMode = cudaVideoDeinterlaceMode_Adaptive;
// Output format
decodeParams.ulTargetWidth = GL_IMAGE_WIDTH;
decodeParams.ulTargetHeight = GL_IMAGE_HEIGHT;
decodeParams.ulNumOutputSurfaces = 2;
decodeParams.ulCreationFlags = cudaVideoCreate_Default;
decodeParams.vidLock = cuCtxLock;
CUresult result = cuvidCreateDecoder( pDecoder, &decodeParams );
So all basically hard coded results, look good in the debugger. I never get a return from creating the decoder, and there is no stack trace (it dies somewhere in nvcuvid.dll).
I have the latest CUDA 3.2, my encoder project works and the cudaDecodeGL project seems to run correctly. Is there maybe a missing step between creating the context and the decoder?
Thanks!