• Miroslav Slugeň's avatar
    avcodec/nvenc: better surface allocation alghoritm, fix rc_lookahead · de2faec2
    Miroslav Slugeň authored
    User selectable surfaces are not working correctly, if you set number of
    surfaces on cmdline, it will always use minimum 32 or 48 depends on
    selected resolution, but in nvenc it is not necessary to use so many
    surfaces.
    
    So from now you can define as low as 1 surface and nvenc will still
    work, it will ofcourse lower GPU memory usage by 95% and async_delay to zero
    
    That was the easy part, now littlebit more...
    
    Next part of this patch is to always prefer rc_lookahead to be more
    important for number of surfaces, than user defined surfaces value.
    Maximum rc_lookahead from nvidia documentation is 32, but could increase
    in future generations so there is no limit for this yet. Value
    async_depth is still accepted and prefered over rc_lookahead.
    
    There were also bug when you request more than rc_lookahead > 31, it
    will always set maximum 31, because surface numbers recalculation was
    after setting lookahead, which is now fixed.
    
    Results:
    If you set -rc_lookahead 32 and -bf 3 it will now use only 40 surfaces
    and lower GPU memory usage by 20%, also it will now increase PSNR by 0.012dB
    
    Two more comments:
    
    1. from my internal test, i don't understand addition of 4 more surfaces
    when lookahead is calculated, i didn't used this and everything works as
    with those 4 more extra surfaces, does anybody know what is going on
    there? I looks like it was used for B frames which are calculated
    separately, because B frames maximum is 4.
    
    2. rc_lookahead is defined default to -1, but in test condition if
    (ctx->rc_lookahead) which sets lookahead it will be always true, i don't
    know if this is intended behavior, so in default behavior is lookahead
    always on!
    
    This is default condition when rc_lokkahead is -1 (not defined on
    cmdline), whis is maybe something that is not intended:
    ctx->encode_config.rcParams.enableLookahead = 1;
    ctx->encode_config.rcParams.lookaheadDepth  = 0;
    ctx->encode_config.rcParams.disableIadapt   = 0;
    ctx->encode_config.rcParams.disableBadapt   = 0;
    Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
    de2faec2
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
arch.mak Loading commit data...
cmdutils.c Loading commit data...
cmdutils.h Loading commit data...
cmdutils_common_opts.h Loading commit data...
cmdutils_opencl.c Loading commit data...
common.mak Loading commit data...
configure Loading commit data...
ffmpeg.c Loading commit data...
ffmpeg.h Loading commit data...
ffmpeg_cuvid.c Loading commit data...
ffmpeg_dxva2.c Loading commit data...
ffmpeg_filter.c Loading commit data...
ffmpeg_opt.c Loading commit data...
ffmpeg_qsv.c Loading commit data...
ffmpeg_vaapi.c Loading commit data...
ffmpeg_vdpau.c Loading commit data...
ffmpeg_videotoolbox.c Loading commit data...
ffplay.c Loading commit data...
ffprobe.c Loading commit data...
ffserver.c Loading commit data...
ffserver_config.c Loading commit data...
ffserver_config.h Loading commit data...
library.mak Loading commit data...
version.sh Loading commit data...