NVCUVID decoder - number of required decoding surfaces

When decoding various formats (MPEG-4, H264) using the NVCUVID decoder, I want to allocate the minimum number of decode surfaces necessary, however I’ve been unable to figure out how to determine this number as it appears to be stream dependent.

I came across the following recommendation from NVIDIA, recommending how many surfaces are needed when using the VDPAU API - does the same recommendation apply to NVCUVID as well?

“At a bare minimum, the application must allocate one video surface for each reference frame that the stream can use (2 for MPEG or VC-1, a variable stream-dependent number for H.264) plus one surface for the picture currently being decoded.”

Thanks,

Erin