1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-06-04 05:57:49 +02:00

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@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
Wenbin Chen 2022-08-17 15:07:19 +08:00 committed by Haihao Xiang
parent f23e3ce858
commit ae7d19680b
3 changed files with 13 additions and 5 deletions

View File

@ -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 more accurate bitrate control to minimize the variance of bitstream size frame
by frame. Value: -1-default 0-off 1-on 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} @item @var{p_strategy}
Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0). Enable P-pyramid: 0-default 1-simple 2-pyramid(bf need to be set to 0).

View File

@ -816,11 +816,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->extco2.LookAheadDS = q->look_ahead_downsampling; q->extco2.LookAheadDS = q->look_ahead_downsampling;
q->extco2.RepeatPPS = q->repeat_pps ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; 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) { 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) if (q->b_strategy >= 0)
q->extco2.BRefType = q->b_strategy ? MFX_B_REF_PYRAMID : MFX_B_REF_OFF; 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) || 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_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) || (q->max_qp_p >= 0 && q->min_qp_p >= 0 && q->min_qp_p > q->max_qp_p) ||

View File

@ -233,6 +233,8 @@ static const AVOption options[] = {
QSV_OPTION_DBLK_IDC QSV_OPTION_DBLK_IDC
QSV_OPTION_LOW_DELAY_BRC QSV_OPTION_LOW_DELAY_BRC
QSV_OPTION_MAX_MIN_QP 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" }, { "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" }, { "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" },