X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqsvenc.c;h=1aeab03d04d6ea62e1e782fbb2eb5690c7532f8c;hb=194dd155582d5b71fc3bb78ef77ce64d3f6c521d;hp=57f5fe419935d9fbcf69377ac213aca1a66d68f9;hpb=1ce298dac51cb948a7170ed28e8290530cf150f4;p=ffmpeg diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 57f5fe41993..1aeab03d04d 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)"; @@ -121,7 +129,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) case MFX_RATECONTROL_VBR: q->param.mfx.InitialDelayInKB = avctx->rc_initial_buffer_occupancy / 1000; q->param.mfx.TargetKbps = avctx->bit_rate / 1000; - q->param.mfx.MaxKbps = avctx->bit_rate / 1000; + q->param.mfx.MaxKbps = avctx->rc_max_rate / 1000; break; case MFX_RATECONTROL_CQP: quant = avctx->global_quality / FF_QP2LAMBDA; @@ -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; @@ -146,8 +157,27 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco.CAVLC = avctx->coder_type == FF_CODER_TYPE_VLC ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; + q->extco.PicTimingSEI = q->pic_timing_sei ? + MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; + 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); }