RateControlSettings: add option to set max QP for libvpx vp8.

Bug: none
Change-Id: Ia662068fe179faebc1df0aaa7f37b6e989b6525f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135569
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27888}
This commit is contained in:
Åsa Persson 2019-05-08 14:44:12 +02:00 committed by Commit Bot
parent ea5cbb5d1a
commit d7dd49ff3d
4 changed files with 30 additions and 1 deletions

View file

@ -560,6 +560,10 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst,
if (inst->qpMax >= vpx_configs_[0].rc_min_quantizer) { if (inst->qpMax >= vpx_configs_[0].rc_min_quantizer) {
qp_max_ = inst->qpMax; qp_max_ = inst->qpMax;
} }
if (rate_control_settings_.LibvpxVp8QpMax()) {
qp_max_ = std::max(rate_control_settings_.LibvpxVp8QpMax().value(),
static_cast<int>(vpx_configs_[0].rc_min_quantizer));
}
vpx_configs_[0].rc_max_quantizer = qp_max_; vpx_configs_[0].rc_max_quantizer = qp_max_;
vpx_configs_[0].rc_undershoot_pct = 100; vpx_configs_[0].rc_undershoot_pct = 100;
vpx_configs_[0].rc_overshoot_pct = 15; vpx_configs_[0].rc_overshoot_pct = 15;

View file

@ -66,6 +66,7 @@ RateControlSettings::RateControlSettings(
congestion_window_pushback_("MinBitrate"), congestion_window_pushback_("MinBitrate"),
pacing_factor_("pacing_factor"), pacing_factor_("pacing_factor"),
alr_probing_("alr_probing", false), alr_probing_("alr_probing", false),
vp8_qp_max_("vp8_qp_max"),
trust_vp8_( trust_vp8_(
"trust_vp8", "trust_vp8",
IsEnabled(key_value_config, kVp8TrustedRateControllerFieldTrialName)), IsEnabled(key_value_config, kVp8TrustedRateControllerFieldTrialName)),
@ -90,7 +91,7 @@ RateControlSettings::RateControlSettings(
ParseFieldTrial({&congestion_window_, &congestion_window_pushback_}, ParseFieldTrial({&congestion_window_, &congestion_window_pushback_},
key_value_config->Lookup("WebRTC-CongestionWindow")); key_value_config->Lookup("WebRTC-CongestionWindow"));
ParseFieldTrial( ParseFieldTrial(
{&pacing_factor_, &alr_probing_, &trust_vp8_, &trust_vp9_, {&pacing_factor_, &alr_probing_, &vp8_qp_max_, &trust_vp8_, &trust_vp9_,
&video_hysteresis_, &screenshare_hysteresis_, &probe_max_allocation_, &video_hysteresis_, &screenshare_hysteresis_, &probe_max_allocation_,
&bitrate_adjuster_, &adjuster_use_headroom_, &vp8_s0_boost_, &bitrate_adjuster_, &adjuster_use_headroom_, &vp8_s0_boost_,
&vp8_dynamic_rate_, &vp9_dynamic_rate_}, &vp8_dynamic_rate_, &vp9_dynamic_rate_},
@ -138,6 +139,14 @@ bool RateControlSettings::UseAlrProbing() const {
return alr_probing_.Get(); return alr_probing_.Get();
} }
absl::optional<int> RateControlSettings::LibvpxVp8QpMax() const {
if (vp8_qp_max_ && (vp8_qp_max_.Value() < 0 || vp8_qp_max_.Value() > 63)) {
RTC_LOG(LS_WARNING) << "Unsupported vp8_qp_max_ value, ignored.";
return absl::nullopt;
}
return vp8_qp_max_.GetOptional();
}
bool RateControlSettings::LibvpxVp8TrustedRateController() const { bool RateControlSettings::LibvpxVp8TrustedRateController() const {
return trust_vp8_.Get(); return trust_vp8_.Get();
} }

View file

@ -40,6 +40,7 @@ class RateControlSettings final {
absl::optional<double> GetPacingFactor() const; absl::optional<double> GetPacingFactor() const;
bool UseAlrProbing() const; bool UseAlrProbing() const;
absl::optional<int> LibvpxVp8QpMax() const;
bool LibvpxVp8TrustedRateController() const; bool LibvpxVp8TrustedRateController() const;
bool Vp8BoostBaseLayerQuality() const; bool Vp8BoostBaseLayerQuality() const;
bool Vp8DynamicRateSettings() const; bool Vp8DynamicRateSettings() const;
@ -67,6 +68,7 @@ class RateControlSettings final {
FieldTrialOptional<int> congestion_window_pushback_; FieldTrialOptional<int> congestion_window_pushback_;
FieldTrialOptional<double> pacing_factor_; FieldTrialOptional<double> pacing_factor_;
FieldTrialParameter<bool> alr_probing_; FieldTrialParameter<bool> alr_probing_;
FieldTrialOptional<int> vp8_qp_max_;
FieldTrialParameter<bool> trust_vp8_; FieldTrialParameter<bool> trust_vp8_;
FieldTrialParameter<bool> trust_vp9_; FieldTrialParameter<bool> trust_vp9_;
FieldTrialParameter<double> video_hysteresis_; FieldTrialParameter<double> video_hysteresis_;

View file

@ -65,6 +65,20 @@ TEST(RateControlSettingsTest, AlrProbing) {
EXPECT_TRUE(RateControlSettings::ParseFromFieldTrials().UseAlrProbing()); EXPECT_TRUE(RateControlSettings::ParseFromFieldTrials().UseAlrProbing());
} }
TEST(RateControlSettingsTest, LibvpxVp8QpMax) {
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax());
test::ScopedFieldTrials field_trials(
"WebRTC-VideoRateControl/vp8_qp_max:50/");
EXPECT_EQ(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax(), 50);
}
TEST(RateControlSettingsTest, DoesNotGetTooLargeLibvpxVp8QpMaxValue) {
test::ScopedFieldTrials field_trials(
"WebRTC-VideoRateControl/vp8_qp_max:70/");
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax());
}
TEST(RateControlSettingsTest, LibvpxTrustedRateController) { TEST(RateControlSettingsTest, LibvpxTrustedRateController) {
const RateControlSettings settings_before = const RateControlSettings settings_before =
RateControlSettings::ParseFromFieldTrials(); RateControlSettings::ParseFromFieldTrials();