# CUDA Video Decoder crash Simple decoder application crash

**URL:** <https://forums.developer.nvidia.com/t/cuda-video-decoder-crash-simple-decoder-application-crash/21213>\
**Category:** CUDA Programming and Performance\
**Created:** [February 24, 2011, 11:44am UTC](https://forums.developer.nvidia.com/t/cuda-video-decoder-crash-simple-decoder-application-crash/21213 "2011-02-24T11:44:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![norris.j](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@norris.j](https://forums.developer.nvidia.com/u/norris.j)\
**Post date:** [February 24, 2011, 11:44am UTC](https://forums.developer.nvidia.com/t/cuda-video-decoder-crash-simple-decoder-application-crash/21213/1 "2011-02-24T11:44:53Z")

</div>

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:

```auto
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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![norris.j](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@norris.j](https://forums.developer.nvidia.com/u/norris.j)\
**Post date:** [February 24, 2011, 2:56pm UTC](https://forums.developer.nvidia.com/t/cuda-video-decoder-crash-simple-decoder-application-crash/21213/2 "2011-02-24T14:56:21Z")

</div>

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:

```auto
CUvideodecoder *oDecoder_;

```

It just needed to be a member variable, that or allocated before the call

```auto
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:
> 
> ```auto
> 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:
> 
> ```auto
> 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!
