[FFmpeg-cvslog] libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv

Wenbin Chen git at videolan.org
Tue Aug 23 08:07:47 EEST 2022


ffmpeg | branch: master | Wenbin Chen <wenbin.chen-at-intel.com at ffmpeg.org> | Wed Aug 17 15:07:19 2022 +0800| [ae7d19680b7e7a401773c619e7c36f3faaf94d0d] | committer: Haihao Xiang

libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv

Add adaptive_i/b feature to hevc_qsv. Adaptive_i allows changing of
frame type from P and B to I. Adaptive_b allows changing of frame type
frome B to P.

Signed-off-by: Wenbin Chen <wenbin.chen at intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae7d19680b7e7a401773c619e7c36f3faaf94d0d
---

 doc/encoders.texi        | 7 +++++++
 libavcodec/qsvenc.c      | 9 ++++-----
 libavcodec/qsvenc_hevc.c | 2 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6d73f74196..fed798ff42 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3543,6 +3543,13 @@ Setting this flag turns on or off LowDelayBRC feautre in qsv plugin, which provi
 more accurate bitrate control to minimize the variance of bitstream size frame
 by frame. Value: -1-default 0-off 1-on
 
+ at item @var{adaptive_i}
+This flag controls insertion of I frames by the QSV encoder. Turn ON this flag
+to allow changing of frame type from P and B to I.
+
+ at item @var{adaptive_b}
+This flag controls changing of frame type from B to P.
+
 @item @var{p_strategy}
 Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 4831640868..ca5e6f0b6e 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -816,11 +816,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
 
             q->extco2.LookAheadDS = q->look_ahead_downsampling;
             q->extco2.RepeatPPS   = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
-
-            if (q->adaptive_i >= 0)
-                q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
-            if (q->adaptive_b >= 0)
-                q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
         }
 
         if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) {
@@ -840,6 +835,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
 
             if (q->b_strategy >= 0)
                 q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF;
+            if (q->adaptive_i >= 0)
+                q->extco2.AdaptiveI = q->adaptive_i ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
+            if (q->adaptive_b >= 0)
+                q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
             if ((avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) ||
                 (q->max_qp_i >= 0 && q->min_qp_i >= 0 && q->min_qp_i > q->max_qp_i) ||
                 (q->max_qp_p >= 0 && q->min_qp_p >= 0 && q->min_qp_p > q->max_qp_p) ||
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index e11f5dec4a..19f028c078 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -233,6 +233,8 @@ static const AVOption options[] = {
     QSV_OPTION_DBLK_IDC
     QSV_OPTION_LOW_DELAY_BRC
     QSV_OPTION_MAX_MIN_QP
+    QSV_OPTION_ADAPTIVE_I
+    QSV_OPTION_ADAPTIVE_B
 
     { "idr_interval", "Distance (in I-frames) between IDR frames", OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, VE, "idr_interval" },
     { "begin_only", "Output an IDR-frame only at the beginning of the stream", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "idr_interval" },



More information about the ffmpeg-cvslog mailing list