avcodec/nvenc: add chroma qp offset support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
This commit is contained in:
parent
5ad436fcb9
commit
e56f6e59b6
@ -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);
|
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->qmin = -1;
|
||||||
avctx->qmax = -1;
|
avctx->qmax = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,11 @@ typedef void ID3D11Device;
|
|||||||
#define NVENC_HAVE_H264_LVL6
|
#define NVENC_HAVE_H264_LVL6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// SDK 11.1 compile time feature checks
|
||||||
|
#if NVENCAPI_CHECK_VERSION(11, 1)
|
||||||
|
#define NVENC_HAVE_QP_CHROMA_OFFSETS
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct NvencSurface
|
typedef struct NvencSurface
|
||||||
{
|
{
|
||||||
NV_ENC_INPUT_PTR input_surface;
|
NV_ENC_INPUT_PTR input_surface;
|
||||||
@ -213,6 +218,8 @@ typedef struct NvencContext
|
|||||||
int init_qp_b;
|
int init_qp_b;
|
||||||
int init_qp_i;
|
int init_qp_i;
|
||||||
int cqp;
|
int cqp;
|
||||||
|
int qp_cb_offset;
|
||||||
|
int qp_cr_offset;
|
||||||
int weighted_pred;
|
int weighted_pred;
|
||||||
int coder;
|
int coder;
|
||||||
int b_ref_mode;
|
int b_ref_mode;
|
||||||
|
|||||||
@ -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 },
|
{ "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",
|
{ "qp", "Constant quantization parameter rate control method",
|
||||||
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
|
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",
|
{ "weighted_pred","Set 1 to enable weighted prediction",
|
||||||
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
|
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" },
|
{ "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 },-1, 2, VE, "coder" },
|
||||||
|
|||||||
@ -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 },
|
{ "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",
|
{ "qp", "Constant quantization parameter rate control method",
|
||||||
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
|
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",
|
{ "weighted_pred","Set 1 to enable weighted prediction",
|
||||||
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
|
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
|
||||||
#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
|
#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#define LIBAVCODEC_VERSION_MAJOR 59
|
#define LIBAVCODEC_VERSION_MAJOR 59
|
||||||
#define LIBAVCODEC_VERSION_MINOR 4
|
#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, \
|
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||||
LIBAVCODEC_VERSION_MINOR, \
|
LIBAVCODEC_VERSION_MINOR, \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user