summaryrefslogtreecommitdiff
path: root/libavcodec/qsvenc.c
diff options
context:
space:
mode:
authorSven Dueking <sven@nablet.com>2015-08-21 09:17:35 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-08-30 16:00:05 +0200
commit67e87f8050cb8cc61e016cb77be137c18653cbfe (patch)
tree4ede49b83737a56f4cdf9755f54a67e47e279016 /libavcodec/qsvenc.c
parentdead1964ea8c4a87adb098c2c1abb2778b01831f (diff)
avcodec/qsv : Added look ahead rate control mode
Reviewed-by: Ivan Uskov <ivan.uskov@nablet.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r--libavcodec/qsvenc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 1532258d49..1aeab03d04 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -107,8 +107,16 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->param.mfx.RateControlMethod = MFX_RATECONTROL_CBR;
ratecontrol_desc = "constant bitrate (CBR)";
} else if (!avctx->rc_max_rate) {
- q->param.mfx.RateControlMethod = MFX_RATECONTROL_AVBR;
- ratecontrol_desc = "average variable bitrate (AVBR)";
+#if QSV_VERSION_ATLEAST(1,7)
+ if (q->look_ahead) {
+ q->param.mfx.RateControlMethod = MFX_RATECONTROL_LA;
+ ratecontrol_desc = "lookahead (LA)";
+ } else
+#endif
+ {
+ q->param.mfx.RateControlMethod = MFX_RATECONTROL_AVBR;
+ ratecontrol_desc = "average variable bitrate (AVBR)";
+ }
} else {
q->param.mfx.RateControlMethod = MFX_RATECONTROL_VBR;
ratecontrol_desc = "variable bitrate (VBR)";
@@ -132,6 +140,9 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
break;
case MFX_RATECONTROL_AVBR:
+#if QSV_VERSION_ATLEAST(1,7)
+ case MFX_RATECONTROL_LA:
+#endif
q->param.mfx.TargetKbps = avctx->bit_rate / 1000;
q->param.mfx.Convergence = q->avbr_convergence;
q->param.mfx.Accuracy = q->avbr_accuracy;
@@ -151,6 +162,22 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->extparam[0] = (mfxExtBuffer *)&q->extco;
+#if QSV_VERSION_ATLEAST(1,6)
+ q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
+ q->extco2.Header.BufferSz = sizeof(q->extco2);
+
+#if QSV_VERSION_ATLEAST(1,7)
+ // valid value range is from 10 to 100 inclusive
+ // to instruct the encoder to use the default value this should be set to zero
+ q->extco2.LookAheadDepth = q->look_ahead_depth != 0 ? FFMAX(10, q->look_ahead_depth) : 0;
+#endif
+#if QSV_VERSION_ATLEAST(1,8)
+ q->extco2.LookAheadDS = q->look_ahead_downsampling;
+#endif
+
+ q->extparam[1] = (mfxExtBuffer *)&q->extco2;
+
+#endif
q->param.ExtParam = q->extparam;
q->param.NumExtParam = FF_ARRAY_ELEMS(q->extparam);
}