diff --git a/rtc_base/experiments/balanced_degradation_settings.cc b/rtc_base/experiments/balanced_degradation_settings.cc index bfb0a5f1c0..3afbc3f531 100644 --- a/rtc_base/experiments/balanced_degradation_settings.cc +++ b/rtc_base/experiments/balanced_degradation_settings.cc @@ -32,6 +32,7 @@ std::vector DefaultConfigs() { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, {480 * 270, 10, @@ -41,6 +42,7 @@ std::vector DefaultConfigs() { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, {640 * 480, 15, @@ -50,6 +52,7 @@ std::vector DefaultConfigs() { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}}; } @@ -118,13 +121,15 @@ bool IsValid(const std::vector& configs) { if (!IsValid(configs[i].vp8, configs[i - 1].vp8) || !IsValid(configs[i].vp9, configs[i - 1].vp9) || !IsValid(configs[i].h264, configs[i - 1].h264) || + !IsValid(configs[i].av1, configs[i - 1].av1) || !IsValid(configs[i].generic, configs[i - 1].generic)) { return false; } } for (const auto& config : configs) { if (!IsValidConfig(config.vp8) || !IsValidConfig(config.vp9) || - !IsValidConfig(config.h264) || !IsValidConfig(config.generic)) { + !IsValidConfig(config.h264) || !IsValidConfig(config.av1) || + !IsValidConfig(config.generic)) { return false; } } @@ -158,6 +163,10 @@ absl::optional GetThresholds( low = config.h264.GetQpLow(); high = config.h264.GetQpHigh(); break; + case kVideoCodecAV1: + low = config.av1.GetQpLow(); + high = config.av1.GetQpHigh(); + break; case kVideoCodecGeneric: low = config.generic.GetQpLow(); high = config.generic.GetQpHigh(); @@ -191,6 +200,9 @@ int GetFps(VideoCodecType type, case kVideoCodecH264: fps = config->h264.GetFps(); break; + case kVideoCodecAV1: + fps = config->av1.GetFps(); + break; case kVideoCodecGeneric: fps = config->generic.GetFps(); break; @@ -229,6 +241,7 @@ BalancedDegradationSettings::Config::Config(int pixels, CodecTypeSpecific vp8, CodecTypeSpecific vp9, CodecTypeSpecific h264, + CodecTypeSpecific av1, CodecTypeSpecific generic) : pixels(pixels), fps(fps), @@ -238,6 +251,7 @@ BalancedDegradationSettings::Config::Config(int pixels, vp8(vp8), vp9(vp9), h264(h264), + av1(av1), generic(generic) {} BalancedDegradationSettings::BalancedDegradationSettings() { @@ -265,6 +279,11 @@ BalancedDegradationSettings::BalancedDegradationSettings() { [](Config* c) { return &c->h264.qp_high; }), FieldTrialStructMember("h264_fps", [](Config* c) { return &c->h264.fps; }), + FieldTrialStructMember("av1_qp_low", + [](Config* c) { return &c->av1.qp_low; }), + FieldTrialStructMember("av1_qp_high", + [](Config* c) { return &c->av1.qp_high; }), + FieldTrialStructMember("av1_fps", [](Config* c) { return &c->av1.fps; }), FieldTrialStructMember("generic_qp_low", [](Config* c) { return &c->generic.qp_low; }), FieldTrialStructMember("generic_qp_high", diff --git a/rtc_base/experiments/balanced_degradation_settings.h b/rtc_base/experiments/balanced_degradation_settings.h index 31d07810f6..8b5dbdabba 100644 --- a/rtc_base/experiments/balanced_degradation_settings.h +++ b/rtc_base/experiments/balanced_degradation_settings.h @@ -52,12 +52,14 @@ class BalancedDegradationSettings { CodecTypeSpecific vp8, CodecTypeSpecific vp9, CodecTypeSpecific h264, + CodecTypeSpecific av1, CodecTypeSpecific generic); bool operator==(const Config& o) const { return pixels == o.pixels && fps == o.fps && kbps == o.kbps && kbps_res == o.kbps_res && fps_diff == o.fps_diff && vp8 == o.vp8 && - vp9 == o.vp9 && h264 == o.h264 && generic == o.generic; + vp9 == o.vp9 && h264 == o.h264 && av1 == o.av1 && + generic == o.generic; } int pixels = 0; // Video frame size. @@ -71,6 +73,7 @@ class BalancedDegradationSettings { CodecTypeSpecific vp8; CodecTypeSpecific vp9; CodecTypeSpecific h264; + CodecTypeSpecific av1; CodecTypeSpecific generic; }; diff --git a/rtc_base/experiments/balanced_degradation_settings_unittest.cc b/rtc_base/experiments/balanced_degradation_settings_unittest.cc index 7399bf27a6..591476b96d 100644 --- a/rtc_base/experiments/balanced_degradation_settings_unittest.cc +++ b/rtc_base/experiments/balanced_degradation_settings_unittest.cc @@ -31,6 +31,7 @@ void VerifyIsDefault( {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 480 * 270, @@ -41,6 +42,7 @@ void VerifyIsDefault( {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 640 * 480, @@ -51,6 +53,7 @@ void VerifyIsDefault( {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}})); } } // namespace @@ -67,6 +70,7 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP8, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP9, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecH264, 1)); + EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecAV1, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecGeneric, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecMultiplex, 1)); } @@ -87,6 +91,7 @@ TEST(BalancedDegradationSettings, GetsConfig) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 22, @@ -97,6 +102,7 @@ TEST(BalancedDegradationSettings, GetsConfig) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 33, @@ -107,6 +113,7 @@ TEST(BalancedDegradationSettings, GetsConfig) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}})); } @@ -138,7 +145,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { webrtc::test::ScopedFieldTrials field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|8|9,vp9_fps:9|10|11," - "h264_fps:11|12|13,generic_fps:13|14|15/"); + "h264_fps:11|12|13,av1_fps:1|2|3,generic_fps:13|14|15/"); BalancedDegradationSettings settings; EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( @@ -151,6 +158,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { {0, 0, 7}, {0, 0, 9}, {0, 0, 11}, + {0, 0, 1}, {0, 0, 13}}, BalancedDegradationSettings::Config{ 2000, @@ -161,6 +169,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { {0, 0, 8}, {0, 0, 10}, {0, 0, 12}, + {0, 0, 2}, {0, 0, 14}}, BalancedDegradationSettings::Config{ 3000, @@ -171,6 +180,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { {0, 0, 9}, {0, 0, 11}, {0, 0, 13}, + {0, 0, 3}, {0, 0, 15}})); } @@ -310,6 +320,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 22, @@ -320,6 +331,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}}, BalancedDegradationSettings::Config{ 33, @@ -330,6 +342,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}})); } @@ -461,6 +474,7 @@ TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP8, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP9, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecH264, 1)); + EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecAV1, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecGeneric, 1)); } @@ -469,8 +483,8 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88," "vp8_qp_high:90|91|92,vp9_qp_low:27|28|29,vp9_qp_high:120|130|140," - "h264_qp_low:12|13|14,h264_qp_high:20|30|40,generic_qp_low:7|6|5," - "generic_qp_high:22|23|24/"); + "h264_qp_low:12|13|14,h264_qp_high:20|30|40,av1_qp_low:2|3|4," + "av1_qp_high:11|33|44,generic_qp_low:7|6|5,generic_qp_high:22|23|24/"); BalancedDegradationSettings settings; EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( @@ -483,6 +497,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { {89, 90, 0}, {27, 120, 0}, {12, 20, 0}, + {2, 11, 0}, {7, 22, 0}}, BalancedDegradationSettings::Config{ 2000, @@ -493,6 +508,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { {90, 91, 0}, {28, 130, 0}, {13, 30, 0}, + {3, 33, 0}, {6, 23, 0}}, BalancedDegradationSettings::Config{ 3000, @@ -503,6 +519,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { {88, 92, 0}, {29, 140, 0}, {14, 40, 0}, + {4, 44, 0}, {5, 24, 0}})); }