diff options
author | Wenbin Chen <wenbin.chen-at-intel.com@ffmpeg.org> | 2022-09-06 17:22:54 +0800 |
---|---|---|
committer | Haihao Xiang <haihao.xiang@intel.com> | 2022-09-09 09:39:44 +0800 |
commit | d60f657a50773ae8371585539bf484aa072bfc71 (patch) | |
tree | 725e666af51638dc0194abf8b437a19337f6bf66 /libavcodec/qsvenc.c | |
parent | c679de9be0d76e4eadc42f68421a569ff304c3e6 (diff) | |
download | ffmpeg-d60f657a50773ae8371585539bf484aa072bfc71.tar.gz |
libavcodec/qsvenc: Add gop_size reset support to qsvenc
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r-- | libavcodec/qsvenc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index b1f49e95fa..58b6284b30 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -639,6 +639,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.CodecProfile = q->profile; q->param.mfx.TargetUsage = avctx->compression_level; q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + q->old_gop_size = avctx->gop_size; q->param.mfx.GopRefDist = FFMAX(-1, avctx->max_b_frames) + 1; q->param.mfx.GopOptFlag = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? MFX_GOP_CLOSED : MFX_GOP_STRICT; @@ -1697,6 +1698,20 @@ static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + UPDATE_PARAM(q->old_gop_size, avctx->gop_size); + if (!updated) + return 0; + + q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + av_log(avctx, AV_LOG_DEBUG, "reset GopPicSize to %d\n", + q->param.mfx.GopPicSize); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1707,6 +1722,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset = update_qp(avctx, q); needReset |= update_max_frame_size(avctx, q); + needReset |= update_gop_size(avctx, q); if (!needReset) return 0; |