Reduce CPU usage with Linux NVENC

The internal assembly routines inside libswscale perform the
RGB->YUV conversion using a fully planar output format, then
have to perform an additional YUV420->NV12 conversion step.

NVENC can directly consume YUV420 input frames, so we can
completely avoid this NV12 conversion and save quite a bit of
CPU time in the process.
This commit is contained in:
Cameron Gutman 2021-07-10 11:24:13 -05:00
parent 61be0eb051
commit a7171d77db

View File

@ -409,11 +409,13 @@ static encoder_t nvenc {
#ifdef _WIN32
AV_HWDEVICE_TYPE_D3D11VA,
AV_PIX_FMT_D3D11,
AV_PIX_FMT_NV12, AV_PIX_FMT_P010,
#else
AV_HWDEVICE_TYPE_CUDA,
AV_PIX_FMT_CUDA,
// Fully planar YUV formats are more efficient for sws_scale()
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P10,
#endif
AV_PIX_FMT_NV12, AV_PIX_FMT_P010,
{
{
{ "forced-idr"s, 1 },