mirror of https://git.ffmpeg.org/ffmpeg.git
lavc/qsvenc: update the selection of bitrate control method
The default method is changed to CQP Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
parent
57fbe929f3
commit
d263fce2b2
|
@ -27,6 +27,7 @@ version <next>:
|
|||
- a C11-compliant compiler is now required; note that this requirement
|
||||
will be bumped to C17 in the near future, so consider updating your
|
||||
build environment if it lacks C17 support
|
||||
- Change the default bitrate control method from VBR to CQP for QSV encoders.
|
||||
|
||||
version 6.1:
|
||||
- libaribcaption decoder
|
||||
|
|
|
@ -3338,8 +3338,8 @@ quality range is 1 to 51, with 1 being the best quality.
|
|||
@end itemize
|
||||
|
||||
@item
|
||||
Otherwise, a bitrate-based mode is used. For all of those, you should specify at
|
||||
least the desired average bitrate with the @option{b} option.
|
||||
Otherwise when the desired average bitrate is specified with the @option{b}
|
||||
option, a bitrate-based mode is used.
|
||||
@itemize @minus
|
||||
@item
|
||||
@var{LA} - VBR with lookahead, when the @option{look_ahead} option is specified.
|
||||
|
@ -3360,6 +3360,9 @@ than the average bitrate.
|
|||
@option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This
|
||||
mode is available for H264 and HEVC on Windows.
|
||||
@end itemize
|
||||
|
||||
@item
|
||||
Otherwise the default ratecontrol method @var{CQP} is used.
|
||||
@end itemize
|
||||
|
||||
Note that depending on your system, a different mode than the one you specified
|
||||
|
|
|
@ -597,6 +597,13 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
|
|||
else if (want_vcm) {
|
||||
rc_mode = MFX_RATECONTROL_VCM;
|
||||
rc_desc = "video conferencing mode (VCM)";
|
||||
|
||||
if (!avctx->bit_rate) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method without "
|
||||
"setting bitrate. Please use the b option to set the desired "
|
||||
"bitrate.\n", rc_desc);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (want_la) {
|
||||
|
@ -606,32 +613,50 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
|
|||
if (avctx->global_quality > 0) {
|
||||
rc_mode = MFX_RATECONTROL_LA_ICQ;
|
||||
rc_desc = "intelligent constant quality with lookahead (LA_ICQ)";
|
||||
} else if (!avctx->bit_rate) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method without "
|
||||
"setting bitrate. Please use the b option to set the desired "
|
||||
"bitrate.\n", rc_desc);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
else if (avctx->global_quality > 0 && !avctx->rc_max_rate) {
|
||||
rc_mode = MFX_RATECONTROL_ICQ;
|
||||
rc_desc = "intelligent constant quality (ICQ)";
|
||||
}
|
||||
else if (avctx->rc_max_rate == avctx->bit_rate) {
|
||||
rc_mode = MFX_RATECONTROL_CBR;
|
||||
rc_desc = "constant bitrate (CBR)";
|
||||
}
|
||||
else if (avctx->bit_rate) {
|
||||
if (avctx->rc_max_rate == avctx->bit_rate) {
|
||||
rc_mode = MFX_RATECONTROL_CBR;
|
||||
rc_desc = "constant bitrate (CBR)";
|
||||
}
|
||||
#if QSV_HAVE_AVBR
|
||||
else if (!avctx->rc_max_rate &&
|
||||
(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) &&
|
||||
q->avbr_accuracy &&
|
||||
q->avbr_convergence) {
|
||||
rc_mode = MFX_RATECONTROL_AVBR;
|
||||
rc_desc = "average variable bitrate (AVBR)";
|
||||
}
|
||||
else if (!avctx->rc_max_rate &&
|
||||
(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) &&
|
||||
q->avbr_accuracy &&
|
||||
q->avbr_convergence) {
|
||||
rc_mode = MFX_RATECONTROL_AVBR;
|
||||
rc_desc = "average variable bitrate (AVBR)";
|
||||
}
|
||||
#endif
|
||||
else if (avctx->global_quality > 0) {
|
||||
rc_mode = MFX_RATECONTROL_QVBR;
|
||||
rc_desc = "constant quality with VBR algorithm (QVBR)";
|
||||
}
|
||||
else {
|
||||
rc_mode = MFX_RATECONTROL_VBR;
|
||||
rc_desc = "variable bitrate (VBR)";
|
||||
else if (avctx->global_quality > 0) {
|
||||
rc_mode = MFX_RATECONTROL_QVBR;
|
||||
rc_desc = "constant quality with VBR algorithm (QVBR)";
|
||||
} else {
|
||||
rc_mode = MFX_RATECONTROL_VBR;
|
||||
rc_desc = "variable bitrate (VBR)";
|
||||
}
|
||||
} else {
|
||||
rc_mode = MFX_RATECONTROL_CQP;
|
||||
rc_desc = "constant quantization parameter (CQP)";
|
||||
if (avctx->codec_id == AV_CODEC_ID_AV1)
|
||||
avctx->global_quality = FF_QP2LAMBDA * 128;
|
||||
else
|
||||
avctx->global_quality = FF_QP2LAMBDA * 26;
|
||||
av_log(avctx, AV_LOG_WARNING, "Using the constant quantization "
|
||||
"parameter (CQP) by default. Please use the global_quality "
|
||||
"option and other options for a quality-based mode or the b "
|
||||
"option and other options for a bitrate-based mode if the "
|
||||
"default is not the desired choice.\n");
|
||||
}
|
||||
|
||||
q->param.mfx.RateControlMethod = rc_mode;
|
||||
|
|
|
@ -129,7 +129,7 @@ static const AVClass class = {
|
|||
};
|
||||
|
||||
static const FFCodecDefault qsv_enc_defaults[] = {
|
||||
{ "b", "1M" },
|
||||
{ "b", "0" },
|
||||
{ "g", "-1" },
|
||||
{ "bf", "-1" },
|
||||
{ "refs", "0" },
|
||||
|
|
|
@ -178,7 +178,7 @@ static const AVClass class = {
|
|||
};
|
||||
|
||||
static const FFCodecDefault qsv_enc_defaults[] = {
|
||||
{ "b", "1M" },
|
||||
{ "b", "0" },
|
||||
{ "refs", "0" },
|
||||
{ "g", "-1" },
|
||||
{ "bf", "-1" },
|
||||
|
|
|
@ -374,7 +374,7 @@ static const AVClass class = {
|
|||
};
|
||||
|
||||
static const FFCodecDefault qsv_enc_defaults[] = {
|
||||
{ "b", "1M" },
|
||||
{ "b", "0" },
|
||||
{ "refs", "0" },
|
||||
{ "g", "248" },
|
||||
{ "bf", "-1" },
|
||||
|
|
|
@ -82,7 +82,7 @@ static const AVClass class = {
|
|||
};
|
||||
|
||||
static const FFCodecDefault qsv_enc_defaults[] = {
|
||||
{ "b", "1M" },
|
||||
{ "b", "0" },
|
||||
{ "refs", "0" },
|
||||
// same as the x264 default
|
||||
{ "g", "250" },
|
||||
|
|
|
@ -93,7 +93,7 @@ static const AVClass class = {
|
|||
};
|
||||
|
||||
static const FFCodecDefault qsv_enc_defaults[] = {
|
||||
{ "b", "1M" },
|
||||
{ "b", "0" },
|
||||
{ "refs", "0" },
|
||||
{ "g", "250" },
|
||||
{ "trellis", "-1" },
|
||||
|
|
Loading…
Reference in New Issue