[FFmpeg-cvslog] libavcodec/qsvenc: Add pic_timing_sei reset support to qsv
Wenbin Chen
git at videolan.org
Fri Sep 30 04:27:52 EEST 2022
ffmpeg | branch: master | Wenbin Chen <wenbin.chen-at-intel.com at ffmpeg.org> | Fri Sep 23 10:44:12 2022 +0800| [3771d54989d761cab02bbd8a7c03dbc2add05a81] | committer: Haihao Xiang
libavcodec/qsvenc: Add pic_timing_sei reset support to qsv
Signed-off-by: Wenbin Chen <wenbin.chen at intel.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3771d54989d761cab02bbd8a7c03dbc2add05a81
---
doc/encoders.texi | 4 ++++
libavcodec/qsvenc.c | 21 +++++++++++++++++++++
libavcodec/qsvenc.h | 2 ++
3 files changed, 27 insertions(+)
diff --git a/doc/encoders.texi b/doc/encoders.texi
index e8ee676473..1a5216f8eb 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3371,6 +3371,10 @@ Change this value to reset qsv codec's framerate configuration.
@item @var{rc_initial_buffer_occupancy}
@item @var{rc_max_rate}
Change these value to reset qsv codec's bitrate control configuration.
+
+ at item @var{pic_timing_sei}
+Supported in h264_qsv and hevc_qsv.
+Change this value to reset qsv codec's pic_timing_sei configuration.
@end table
@subsection H264 options
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 54ed2a5f63..398fa6ff22 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -784,6 +784,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->extco.PicTimingSEI = q->pic_timing_sei ?
MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
+ q->old_pic_timing_sei = q->pic_timing_sei;
if (q->rdo >= 0)
q->extco.RateDistortionOpt = q->rdo > 0 ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
@@ -1900,6 +1901,25 @@ static int update_bitrate(AVCodecContext *avctx, QSVEncContext *q)
return updated;
}
+static int update_pic_timing_sei(AVCodecContext *avctx, QSVEncContext *q)
+{
+ int updated = 0;
+
+ if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC)
+ return 0;
+
+ UPDATE_PARAM(q->old_pic_timing_sei, q->pic_timing_sei);
+ if (!updated)
+ return 0;
+
+ q->extco.PicTimingSEI = q->pic_timing_sei ?
+ MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN;
+ av_log(avctx, AV_LOG_DEBUG, "Reset PicTimingSEI: %s\n",
+ print_threestate(q->extco.PicTimingSEI));
+
+ return updated;
+}
+
static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
const AVFrame *frame)
{
@@ -1915,6 +1935,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q,
needReset |= update_low_delay_brc(avctx, q);
needReset |= update_frame_rate(avctx, q);
needReset |= update_bitrate(avctx, q);
+ needReset |= update_pic_timing_sei(avctx, q);
ret = update_min_max_qp(avctx, q);
if (ret < 0)
return ret;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 6e1132d2e3..486c996fc6 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -278,6 +278,8 @@ typedef struct QSVEncContext {
int old_rc_buffer_size;
int old_rc_initial_buffer_occupancy;
int old_rc_max_rate;
+ // This is used for SEI Timing reset
+ int old_pic_timing_sei;
} QSVEncContext;
int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q);
More information about the ffmpeg-cvslog
mailing list