History

avcodec/nvenc: add initial QP value options

Konda Raju committed 9 years ago

Commit 5f44a4a1 parent a5492435 files · +35 −9Browse files

Unified · Split

5 files
  1. libavcodec/nvenc.c +25 −8
  2. libavcodec/nvenc.h +3 −0
  3. libavcodec/nvenc_h264.c +3 −0
  4. libavcodec/nvenc_hevc.c +3 −0
  5. libavcodec/version.h +1 −1
libavcodec/nvenc.c+25−8
@@ -547,16 +547,33 @@ static av_cold void set_vbr(AVCodecContext *avctx) · 546 unmodified lines
547547 }
548548
549549 rc->enableInitialRCQP = 1;
550− rc->initialRCQP.qpInterP = qp_inter_p;
551550
552− if (avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
553− rc->initialRCQP.qpIntra = av_clip(
554− qp_inter_p * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
555− rc->initialRCQP.qpInterB = av_clip(
556− qp_inter_p * fabs(avctx->b_quant_factor) + avctx->b_quant_offset + 0.5, 0, 51);
551+ if (ctx->init_qp_p < 0) {
552+ rc->initialRCQP.qpInterP = qp_inter_p;
557553 } else {
558− rc->initialRCQP.qpIntra = qp_inter_p;
559− rc->initialRCQP.qpInterB = qp_inter_p;
554+ rc->initialRCQP.qpInterP = ctx->init_qp_p;
555+ }
556+
557+ if (ctx->init_qp_i < 0) {
558+ if (avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
559+ rc->initialRCQP.qpIntra = av_clip(
560+ rc->initialRCQP.qpInterP * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
561+ } else {
562+ rc->initialRCQP.qpIntra = rc->initialRCQP.qpInterP;
563+ }
564+ } else {
565+ rc->initialRCQP.qpIntra = ctx->init_qp_i;
566+ }
567+
568+ if (ctx->init_qp_b < 0) {
569+ if (avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
570+ rc->initialRCQP.qpInterB = av_clip(
571+ rc->initialRCQP.qpInterP * fabs(avctx->b_quant_factor) + avctx->b_quant_offset + 0.5, 0, 51);
572+ } else {
573+ rc->initialRCQP.qpInterB = rc->initialRCQP.qpInterP;
574+ }
575+ } else {
576+ rc->initialRCQP.qpInterB = ctx->init_qp_b;
560577 }
561578 }
562579
libavcodec/nvenc.h+3−0
@@ -155,6 +155,9 @@ typedef struct NvencContext · 154 unmodified lines
155155 int quality;
156156 int aud;
157157 int bluray_compat;
158+ int init_qp_p;
159+ int init_qp_b;
160+ int init_qp_i;
158161 } NvencContext;
159162
160163 int ff_nvenc_encode_init(AVCodecContext *avctx);
libavcodec/nvenc_h264.c+3−0
@@ -109,6 +109,9 @@ static const AVOption options[] = { · 108 unmodified lines
109109 OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
110110 { "aud", "Use access unit delimiters", OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
111111 { "bluray-compat", "Bluray compatibility workarounds", OFFSET(bluray_compat),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
112+ { "init_qpP", "Initial QP value for P frame", OFFSET(init_qp_p), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
113+ { "init_qpB", "Initial QP value for B frame", OFFSET(init_qp_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
114+ { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
112115 { NULL }
113116 };
114117
libavcodec/nvenc_hevc.c+3−0
@@ -106,6 +106,9 @@ static const AVOption options[] = { · 105 unmodified lines
106106 OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
107107 { "aud", "Use access unit delimiters", OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
108108 { "bluray-compat", "Bluray compatibility workarounds", OFFSET(bluray_compat),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
109+ { "init_qpP", "Initial QP value for P frame", OFFSET(init_qp_p), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
110+ { "init_qpB", "Initial QP value for B frame", OFFSET(init_qp_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
111+ { "init_qpI", "Initial QP value for I frame", OFFSET(init_qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
109112 { NULL }
110113 };
111114
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 57
3131 #define LIBAVCODEC_VERSION_MINOR 81
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