diff options
author | Timo Rothenpieler <timo@rothenpieler.org> | 2022-11-02 19:02:56 +0100 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2022-11-05 18:35:33 +0100 |
commit | 28680e2f41b93b75863720e42397441dfcc29f94 (patch) | |
tree | cf8d5b19d53e1f8240ae5bca3f41ce68cea4890a /libavcodec | |
parent | e8850bc2a8590ac66346de7a6d4831d1778746d1 (diff) | |
download | ffmpeg-28680e2f41b93b75863720e42397441dfcc29f94.tar.gz |
avcodec/nvenc: only set b_ref_mode when explicitly requested
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/nvenc.c | 6 | ||||
-rw-r--r-- | libavcodec/nvenc_h264.c | 4 | ||||
-rw-r--r-- | libavcodec/nvenc_hevc.c | 4 |
3 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 3c6fce391d..73c05fcd37 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1199,7 +1199,8 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) h264->entropyCodingMode = ctx->coder; #ifdef NVENC_HAVE_BFRAME_REF_MODE - h264->useBFramesAsRef = ctx->b_ref_mode; + if (ctx->b_ref_mode >= 0) + h264->useBFramesAsRef = ctx->b_ref_mode; #endif #ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES @@ -1314,7 +1315,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) hevc->tier = ctx->tier; #ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE - hevc->useBFramesAsRef = ctx->b_ref_mode; + if (ctx->b_ref_mode >= 0) + hevc->useBFramesAsRef = ctx->b_ref_mode; #endif #ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index a178827291..a69358b03b 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -161,12 +161,12 @@ static const AVOption options[] = { { "ac", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CABAC }, 0, 0, VE, "coder" }, { "vlc", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC }, 0, 0, VE, "coder" }, #ifdef NVENC_HAVE_BFRAME_REF_MODE - { "b_ref_mode", "Use B frames as references", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, NV_ENC_BFRAME_REF_MODE_DISABLED, NV_ENC_BFRAME_REF_MODE_MIDDLE, VE, "b_ref_mode" }, + { "b_ref_mode", "Use B frames as references", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, NV_ENC_BFRAME_REF_MODE_MIDDLE, VE, "b_ref_mode" }, { "disabled", "B frames will not be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, 0, 0, VE, "b_ref_mode" }, { "each", "Each B frame will be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_EACH }, 0, 0, VE, "b_ref_mode" }, { "middle", "Only (number of B frames)/2 will be used for reference", 0,AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_MIDDLE }, 0, 0, VE, "b_ref_mode" }, #else - { "b_ref_mode", "(not supported)", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE, "b_ref_mode" }, + { "b_ref_mode", "(not supported)", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "b_ref_mode" }, { "disabled", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "b_ref_mode" }, { "each", "", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "b_ref_mode" }, { "middle", "", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, VE, "b_ref_mode" }, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index ae4d73e497..5ad423444a 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -141,12 +141,12 @@ static const AVOption options[] = { { "weighted_pred","Set 1 to enable weighted prediction", OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, #ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE - { "b_ref_mode", "Use B frames as references", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, NV_ENC_BFRAME_REF_MODE_DISABLED, NV_ENC_BFRAME_REF_MODE_MIDDLE, VE, "b_ref_mode" }, + { "b_ref_mode", "Use B frames as references", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, NV_ENC_BFRAME_REF_MODE_MIDDLE, VE, "b_ref_mode" }, { "disabled", "B frames will not be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, 0, 0, VE, "b_ref_mode" }, { "each", "Each B frame will be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_EACH }, 0, 0, VE, "b_ref_mode" }, { "middle", "Only (number of B frames)/2 will be used for reference", 0,AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_MIDDLE }, 0, 0, VE, "b_ref_mode" }, #else - { "b_ref_mode", "(not supported)", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE, "b_ref_mode" }, + { "b_ref_mode", "(not supported)", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "b_ref_mode" }, { "disabled", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "b_ref_mode" }, { "each", "", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "b_ref_mode" }, { "middle", "", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, VE, "b_ref_mode" }, |