[FFmpeg-devel] [PATCH] avcodec/cuviddec: update amount of decoder surfaces from within sequence decode callback

Michael Diesel not.michael.diesel at gmail.com
Wed Aug 9 00:55:09 EEST 2023


Hello ,
after this patch I get stutter in the output video when using h264_cuvid 
as decoder

With "surfaces" as -1 will result :
     CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces = 5 = 
CUVID_DEFAULT_NUM_SURFACES
     CUVIDDECODECREATEINFO::ulNumDecodeSurfaces = 8 = 
format->min_num_decode_surfaces + 3

As per NVDEC Video Decoder API Programming Guide / Creating a parser , 
the two values should be equal.

cuvid_handle_video_sequence/pfnSequenceCallback should return a value :
">1: succeeded, and driver should override 
CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces with this return value"

Something like:
     if(ctx->cuparseinfo.ulMaxNumDecodeSurfaces != 
cuinfo.ulNumDecodeSurfaces)
         return cuinfo.ulNumDecodeSurfaces;
     else
         return 1;

This solves partially the problem , there's still occasional stutter , a 
value of 8 is not sufficient.
On my test system 12 is the magic number.

Timo Rothenpieler wrote:
> applied with minor amendments.
> 
> Turned the if-statements around, we don't do them that way around in 
> ffmpeg code.
> And switched the surfaces option to have a default of -1, to not rely on 
> a magic value of 25. That could surprise users who happen to request 25 
> surfaces.



More information about the ffmpeg-devel mailing list