1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec/nvenc: add chroma qp offset support

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
This commit is contained in:
Ricardo Monteiro 2021-08-03 17:02:26 +02:00 committed by Timo Rothenpieler
parent 5ad436fcb9
commit e56f6e59b6
5 changed files with 25 additions and 1 deletions

View File

@ -743,6 +743,15 @@ static av_cold void set_constqp(AVCodecContext *avctx)
rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
}
#ifdef NVENC_HAVE_QP_CHROMA_OFFSETS
rc->cbQPIndexOffset = ctx->qp_cb_offset;
rc->crQPIndexOffset = ctx->qp_cr_offset;
#else
if (ctx->qp_cb_offset || ctx->qp_cr_offset) {
av_log(avctx, AV_LOG_WARNING, "Failed setting QP CB/CR offsets, SDK 11.1 or greater required at compile time.\n");
}
#endif
avctx->qmin = -1;
avctx->qmax = -1;
}

View File

@ -70,6 +70,11 @@ typedef void ID3D11Device;
#define NVENC_HAVE_H264_LVL6
#endif
// SDK 11.1 compile time feature checks
#if NVENCAPI_CHECK_VERSION(11, 1)
#define NVENC_HAVE_QP_CHROMA_OFFSETS
#endif
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
@ -213,6 +218,8 @@ typedef struct NvencContext
int init_qp_b;
int init_qp_i;
int cqp;
int qp_cb_offset;
int qp_cr_offset;
int weighted_pred;
int coder;
int b_ref_mode;

View File

@ -147,6 +147,10 @@ static const AVOption options[] = {
{ "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp", "Constant quantization parameter rate control method",
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp_cb_offset", "Quantization parameter offset for cb channel",
OFFSET(qp_cb_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
{ "qp_cr_offset", "Quantization parameter offset for cr channel",
OFFSET(qp_cr_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
{ "weighted_pred","Set 1 to enable weighted prediction",
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 },-1, 2, VE, "coder" },

View File

@ -134,6 +134,10 @@ static const AVOption options[] = {
{ "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp", "Constant quantization parameter rate control method",
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "qp_cb_offset", "Quantization parameter offset for cb channel",
OFFSET(qp_cb_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
{ "qp_cr_offset", "Quantization parameter offset for cr channel",
OFFSET(qp_cr_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
{ "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

View File

@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 59
#define LIBAVCODEC_VERSION_MINOR 4
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \