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
743743 rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
744744 }
745745
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+
746755 avctx->qmin = -1;
747756 avctx->qmax = -1;
748757 }
libavcodec/nvenc.h+7−0
@@ -70,6 +70,11 @@ typedef void ID3D11Device; · 69 unmodified lines
7070 #define NVENC_HAVE_H264_LVL6
7171 #endif
7272
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+
7378 typedef struct NvencSurface
7479 {
7580 NV_ENC_INPUT_PTR input_surface;
@@ -213,6 +218,8 @@ typedef struct NvencContext · 137 unmodified lines
213218 int init_qp_b;
214219 int init_qp_i;
215220 int cqp;
221+ int qp_cb_offset;
222+ int qp_cr_offset;
216223 int weighted_pred;
217224 int coder;
218225 int b_ref_mode;
libavcodec/nvenc_h264.c+4−0
@@ -147,6 +147,10 @@ static const AVOption options[] = { · 146 unmodified lines
147147 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
148148 { "qp", "Constant quantization parameter rate control method",
149149 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 },
150154 { "weighted_pred","Set 1 to enable weighted prediction",
151155 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
152156 { "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
134134 { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
135135 { "qp", "Constant quantization parameter rate control method",
136136 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 },
137141 { "weighted_pred","Set 1 to enable weighted prediction",
138142 OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
139143 #ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 59
3131 #define LIBAVCODEC_VERSION_MINOR 4
32−#define LIBAVCODEC_VERSION_MICRO 100
32+#define LIBAVCODEC_VERSION_MICRO 101
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3535 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