History

avcodec/nvenc: add chroma qp offset support

Ricardo Monteiro committed 5 years ago

Commit e56f6e51 parent 5ad436f5 files · +25 −1Browse files

Unified · Split

5 files
  1. libavcodec/nvenc.c +9 −0
  2. libavcodec/nvenc.h +7 −0
  3. libavcodec/nvenc_h264.c +4 −0
  4. libavcodec/nvenc_hevc.c +4 −0
  5. libavcodec/version.h +1 −1
libavcodec/nvenc.c+9−0
@@ -743,6 +743,15 @@ static av_cold void set_constqp(AVCodecContext *avctx) · 742 unmodified lines
743 rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);743 rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
744 }744 }
745 745
746#ifdef NVENC_HAVE_QP_CHROMA_OFFSETS
747 rc->cbQPIndexOffset = ctx->qp_cb_offset;
748 rc->crQPIndexOffset = ctx->qp_cr_offset;
749#else
750 if (ctx->qp_cb_offset || ctx->qp_cr_offset) {
751 av_log(avctx, AV_LOG_WARNING, "Failed setting QP CB/CR offsets, SDK 11.1 or greater required at compile time.\n");
752 }
753#endif
754
746 avctx->qmin = -1;755 avctx->qmin = -1;
747 avctx->qmax = -1;756 avctx->qmax = -1;
748}757}
libavcodec/nvenc.h+7−0
@@ -70,6 +70,11 @@ typedef void ID3D11Device; · 69 unmodified lines
70#define NVENC_HAVE_H264_LVL670#define NVENC_HAVE_H264_LVL6
71#endif71#endif
72 72
73// SDK 11.1 compile time feature checks
74#if NVENCAPI_CHECK_VERSION(11, 1)
75#define NVENC_HAVE_QP_CHROMA_OFFSETS
76#endif
77
73typedef struct NvencSurface78typedef struct NvencSurface
74{79{
75 NV_ENC_INPUT_PTR input_surface;80 NV_ENC_INPUT_PTR input_surface;
@@ -213,6 +218,8 @@ typedef struct NvencContext · 137 unmodified lines
213 int init_qp_b;218 int init_qp_b;
214 int init_qp_i;219 int init_qp_i;
215 int cqp;220 int cqp;
221 int qp_cb_offset;
222 int qp_cr_offset;
216 int weighted_pred;223 int weighted_pred;
217 int coder;224 int coder;
218 int b_ref_mode;225 int b_ref_mode;
libavcodec/nvenc_h264.c+4−0
@@ -147,6 +147,10 @@ static const AVOption options[] = { · 146 unmodified lines
147 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },147 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
148 { "qp", "Constant quantization parameter rate control method",148 { "qp", "Constant quantization parameter rate control method",
149 OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },149 OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
150 { "qp_cb_offset", "Quantization parameter offset for cb channel",
151 OFFSET(qp_cb_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
152 { "qp_cr_offset", "Quantization parameter offset for cr channel",
153 OFFSET(qp_cr_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
150 { "weighted_pred","Set 1 to enable weighted prediction",154 { "weighted_pred","Set 1 to enable weighted prediction",
151 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },155 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
152 { "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 },-1, 2, VE, "coder" },156 { "coder", "Coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 },-1, 2, VE, "coder" },
libavcodec/nvenc_hevc.c+4−0
@@ -134,6 +134,10 @@ static const AVOption options[] = { · 133 unmodified lines
134 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },134 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
135 { "qp", "Constant quantization parameter rate control method",135 { "qp", "Constant quantization parameter rate control method",
136 OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },136 OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
137 { "qp_cb_offset", "Quantization parameter offset for cb channel",
138 OFFSET(qp_cb_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
139 { "qp_cr_offset", "Quantization parameter offset for cr channel",
140 OFFSET(qp_cr_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, -12, 12, VE },
137 { "weighted_pred","Set 1 to enable weighted prediction",141 { "weighted_pred","Set 1 to enable weighted prediction",
138 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },142 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
139#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE143#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 29
30#define LIBAVCODEC_VERSION_MAJOR 5930#define LIBAVCODEC_VERSION_MAJOR 59
31#define LIBAVCODEC_VERSION_MINOR 431#define LIBAVCODEC_VERSION_MINOR 4
32#define LIBAVCODEC_VERSION_MICRO 10032#define LIBAVCODEC_VERSION_MICRO 101
33 33
34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \34#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 LIBAVCODEC_VERSION_MINOR, \35 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t