History

lavc/qsvenc: update the selection of bitrate control method

The default method is changed to CQP

Haihao Xiang committed 2 years ago

Commit d263fce1 parent 57fbe928 files · +54 −25Browse files

Unified · Split

8 files
  1. Changelog +1 −0
  2. doc/encoders.texi +5 −2
  3. libavcodec/qsvenc.c +43 −18
  4. libavcodec/qsvenc_av1.c +1 −1
  5. libavcodec/qsvenc_h264.c +1 −1
  6. libavcodec/qsvenc_hevc.c +1 −1
  7. libavcodec/qsvenc_mpeg2.c +1 −1
  8. libavcodec/qsvenc_vp9.c +1 −1
Changelog+1−0
@@ -27,6 +27,7 @@ version <next>: · 26 unmodified lines
27- a C11-compliant compiler is now required; note that this requirement27- a C11-compliant compiler is now required; note that this requirement
28 will be bumped to C17 in the near future, so consider updating your28 will be bumped to C17 in the near future, so consider updating your
29 build environment if it lacks C17 support29 build environment if it lacks C17 support
30- Change the default bitrate control method from VBR to CQP for QSV encoders.
30 31
31version 6.1:32version 6.1:
32- libaribcaption decoder33- libaribcaption decoder
doc/encoders.texi+5−2
@@ -3338,8 +3338,8 @@ quality range is 1 to 51, with 1 being the best quality. · 3337 unmodified lines
3338@end itemize3338@end itemize
3339 3339
3340@item3340@item
3341Otherwise, a bitrate-based mode is used. For all of those, you should specify at3341Otherwise when the desired average bitrate is specified with the @option{b}
3342least the desired average bitrate with the @option{b} option.3342option, a bitrate-based mode is used.
3343@itemize @minus3343@itemize @minus
3344@item3344@item
3345@var{LA} - VBR with lookahead, when the @option{look_ahead} option is specified.3345@var{LA} - VBR with lookahead, when the @option{look_ahead} option is specified.
@@ -3360,6 +3360,9 @@ than the average bitrate. · 14 unmodified lines
3360@option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This3360@option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This
3361mode is available for H264 and HEVC on Windows.3361mode is available for H264 and HEVC on Windows.
3362@end itemize3362@end itemize
3363
3364@item
3365Otherwise the default ratecontrol method @var{CQP} is used.
3363@end itemize3366@end itemize
3364 3367
3365Note that depending on your system, a different mode than the one you specified3368Note that depending on your system, a different mode than the one you specified
libavcodec/qsvenc.c+43−18
@@ -597,6 +597,13 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 596 unmodified lines
597 else if (want_vcm) {597 else if (want_vcm) {
598 rc_mode = MFX_RATECONTROL_VCM;598 rc_mode = MFX_RATECONTROL_VCM;
599 rc_desc = "video conferencing mode (VCM)";599 rc_desc = "video conferencing mode (VCM)";
600
601 if (!avctx->bit_rate) {
602 av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method without "
603 "setting bitrate. Please use the b option to set the desired "
604 "bitrate.\n", rc_desc);
605 return AVERROR(EINVAL);
606 }
600 }607 }
601#endif608#endif
602 else if (want_la) {609 else if (want_la) {
@@ -606,32 +613,50 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) · 3 unmodified lines
606 if (avctx->global_quality > 0) {613 if (avctx->global_quality > 0) {
607 rc_mode = MFX_RATECONTROL_LA_ICQ;614 rc_mode = MFX_RATECONTROL_LA_ICQ;
608 rc_desc = "intelligent constant quality with lookahead (LA_ICQ)";615 rc_desc = "intelligent constant quality with lookahead (LA_ICQ)";
616 } else if (!avctx->bit_rate) {
617 av_log(avctx, AV_LOG_ERROR, "Using the %s ratecontrol method without "
618 "setting bitrate. Please use the b option to set the desired "
619 "bitrate.\n", rc_desc);
620 return AVERROR(EINVAL);
609 }621 }
610 }622 }
611 else if (avctx->global_quality > 0 && !avctx->rc_max_rate) {623 else if (avctx->global_quality > 0 && !avctx->rc_max_rate) {
612 rc_mode = MFX_RATECONTROL_ICQ;624 rc_mode = MFX_RATECONTROL_ICQ;
613 rc_desc = "intelligent constant quality (ICQ)";625 rc_desc = "intelligent constant quality (ICQ)";
614 }626 }
615 else if (avctx->rc_max_rate == avctx->bit_rate) {627 else if (avctx->bit_rate) {
616 rc_mode = MFX_RATECONTROL_CBR;628 if (avctx->rc_max_rate == avctx->bit_rate) {
617 rc_desc = "constant bitrate (CBR)";629 rc_mode = MFX_RATECONTROL_CBR;
618 }630 rc_desc = "constant bitrate (CBR)";
631 }
619#if QSV_HAVE_AVBR632#if QSV_HAVE_AVBR
620 else if (!avctx->rc_max_rate &&633 else if (!avctx->rc_max_rate &&
621 (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) &&634 (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) &&
622 q->avbr_accuracy &&635 q->avbr_accuracy &&
623 q->avbr_convergence) {636 q->avbr_convergence) {
624 rc_mode = MFX_RATECONTROL_AVBR;637 rc_mode = MFX_RATECONTROL_AVBR;
625 rc_desc = "average variable bitrate (AVBR)";638 rc_desc = "average variable bitrate (AVBR)";
626 }639 }
627#endif640#endif
628 else if (avctx->global_quality > 0) {641 else if (avctx->global_quality > 0) {
629 rc_mode = MFX_RATECONTROL_QVBR;642 rc_mode = MFX_RATECONTROL_QVBR;
630 rc_desc = "constant quality with VBR algorithm (QVBR)";643 rc_desc = "constant quality with VBR algorithm (QVBR)";
631 }644 } else {
632 else {645 rc_mode = MFX_RATECONTROL_VBR;
633 rc_mode = MFX_RATECONTROL_VBR;646 rc_desc = "variable bitrate (VBR)";
634 rc_desc = "variable bitrate (VBR)";647 }
648 } else {
649 rc_mode = MFX_RATECONTROL_CQP;
650 rc_desc = "constant quantization parameter (CQP)";
651 if (avctx->codec_id == AV_CODEC_ID_AV1)
652 avctx->global_quality = FF_QP2LAMBDA * 128;
653 else
654 avctx->global_quality = FF_QP2LAMBDA * 26;
655 av_log(avctx, AV_LOG_WARNING, "Using the constant quantization "
656 "parameter (CQP) by default. Please use the global_quality "
657 "option and other options for a quality-based mode or the b "
658 "option and other options for a bitrate-based mode if the "
659 "default is not the desired choice.\n");
635 }660 }
636 661
637 q->param.mfx.RateControlMethod = rc_mode;662 q->param.mfx.RateControlMethod = rc_mode;
libavcodec/qsvenc_av1.c+1−1
@@ -129,7 +129,7 @@ static const AVClass class = { · 128 unmodified lines
129};129};
130 130
131static const FFCodecDefault qsv_enc_defaults[] = {131static const FFCodecDefault qsv_enc_defaults[] = {
132 { "b", "1M" },132 { "b", "0" },
133 { "g", "-1" },133 { "g", "-1" },
134 { "bf", "-1" },134 { "bf", "-1" },
135 { "refs", "0" },135 { "refs", "0" },
libavcodec/qsvenc_h264.c+1−1
@@ -178,7 +178,7 @@ static const AVClass class = { · 177 unmodified lines
178};178};
179 179
180static const FFCodecDefault qsv_enc_defaults[] = {180static const FFCodecDefault qsv_enc_defaults[] = {
181 { "b", "1M" },181 { "b", "0" },
182 { "refs", "0" },182 { "refs", "0" },
183 { "g", "-1" },183 { "g", "-1" },
184 { "bf", "-1" },184 { "bf", "-1" },
libavcodec/qsvenc_hevc.c+1−1
@@ -374,7 +374,7 @@ static const AVClass class = { · 373 unmodified lines
374};374};
375 375
376static const FFCodecDefault qsv_enc_defaults[] = {376static const FFCodecDefault qsv_enc_defaults[] = {
377 { "b", "1M" },377 { "b", "0" },
378 { "refs", "0" },378 { "refs", "0" },
379 { "g", "248" },379 { "g", "248" },
380 { "bf", "-1" },380 { "bf", "-1" },
libavcodec/qsvenc_mpeg2.c+1−1
@@ -82,7 +82,7 @@ static const AVClass class = { · 81 unmodified lines
82};82};
83 83
84static const FFCodecDefault qsv_enc_defaults[] = {84static const FFCodecDefault qsv_enc_defaults[] = {
85 { "b", "1M" },85 { "b", "0" },
86 { "refs", "0" },86 { "refs", "0" },
87 // same as the x264 default87 // same as the x264 default
88 { "g", "250" },88 { "g", "250" },
libavcodec/qsvenc_vp9.c+1−1
@@ -93,7 +93,7 @@ static const AVClass class = { · 92 unmodified lines
93};93};
94 94
95static const FFCodecDefault qsv_enc_defaults[] = {95static const FFCodecDefault qsv_enc_defaults[] = {
96 { "b", "1M" },96 { "b", "0" },
97 { "refs", "0" },97 { "refs", "0" },
98 { "g", "250" },98 { "g", "250" },
99 { "trellis", "-1" },99 { "trellis", "-1" },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t