* [FFmpeg-devel] [PATCH] libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv
@ 2022-08-17 7:07 Wenbin Chen
2022-08-23 5:11 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: Wenbin Chen @ 2022-08-17 7:07 UTC (permalink / raw)
To: ffmpeg-devel
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@intel.com>
---
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
+@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.
+
+@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" },
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv
2022-08-17 7:07 [FFmpeg-devel] [PATCH] libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv Wenbin Chen
@ 2022-08-23 5:11 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2022-08-23 5:11 UTC (permalink / raw)
To: ffmpeg-devel
On Wed, 2022-08-17 at 15:07 +0800, Wenbin Chen wrote:
> 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@intel.com>
> ---
> 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
>
> +@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.
> +
> +@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" },
Applied, thx
-Haihao
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-23 5:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17 7:07 [FFmpeg-devel] [PATCH] libavcodec/qsvenc: Add adaptive_i/b to hevc_qsv Wenbin Chen
2022-08-23 5:11 ` Xiang, Haihao
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git