@@ -120,12 +120,11 @@ static UniqueCUvideodecoder createDecoder(CUVIDEOFORMAT* videoFormat) {
120120 decoder_info.display_area .top = videoFormat->display_area .top ;
121121 decoder_info.display_area .bottom = videoFormat->display_area .bottom ;
122122
123- CUvideodecoder rawDecoder ;
124- result = cuvidCreateDecoder (&rawDecoder , &decoder_info);
123+ CUvideodecoder* decoder = new CUvideodecoder () ;
124+ result = cuvidCreateDecoder (decoder , &decoder_info);
125125 TORCH_CHECK (
126126 result == CUDA_SUCCESS, " Failed to create NVDEC decoder: " , result);
127-
128- return UniqueCUvideodecoder (rawDecoder, CUvideoDecoderDeleter{});
127+ return UniqueCUvideodecoder (decoder, CUvideoDecoderDeleter{});
129128}
130129
131130} // namespace
@@ -317,7 +316,7 @@ int BetaCudaDeviceInterface::frameReadyForDecoding(CUVIDPICPARAMS* pPicParams) {
317316 TORCH_CHECK (decoder_, " Decoder not initialized before picture decode" );
318317
319318 // Send frame to be decoded by NVDEC - non-blocking call.
320- CUresult result = cuvidDecodePicture (decoder_.get (), pPicParams);
319+ CUresult result = cuvidDecodePicture (* decoder_.get (), pPicParams);
321320 if (result != CUDA_SUCCESS) {
322321 return 0 ; // Yes, you're reading that right, 0 mean error.
323322 }
@@ -383,11 +382,7 @@ int BetaCudaDeviceInterface::receiveFrame(
383382 // blocking calls that waits until the frame is fully decoded and ready to be
384383 // used.
385384 CUresult result = cuvidMapVideoFrame (
386- static_cast <CUvideodecoder>(decoder_.get ()),
387- dispInfo.picture_index ,
388- &framePtr,
389- &pitch,
390- &procParams);
385+ *decoder_.get (), dispInfo.picture_index , &framePtr, &pitch, &procParams);
391386
392387 if (result != CUDA_SUCCESS) {
393388 return AVERROR_EXTERNAL;
@@ -397,7 +392,7 @@ int BetaCudaDeviceInterface::receiveFrame(
397392
398393 // Unmap the frame so that the decoder can reuse its corresponding output
399394 // surface. Whether this is blocking is unclear?
400- cuvidUnmapVideoFrame (static_cast <CUvideodecoder>( decoder_.get () ), framePtr);
395+ cuvidUnmapVideoFrame (* decoder_.get (), framePtr);
401396 // TODONVDEC P0: Get clarity on this:
402397 // We assume that the framePtr is still valid after unmapping. That framePtr
403398 // is now part of the avFrame, which we'll return to the caller, and the
0 commit comments