nvenc: Reduce the number of pre-allocated device memory
The hard-coded upper bound 32 (or 48 depending on resolution) might waste GPU memory and high resolution encoding causes OUT-OF-MEMORY allocation error quite easily. This commit calculates the number of required pre-allocated device memory based on encoding options and it can reduce the amount of device memory used by nvenc.