From 2afff37ba007429cd1cb65369ee815bceee6f3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85sa=20Persson?= Date: Thu, 11 Feb 2021 17:31:11 +0100 Subject: [PATCH] Update field trial for allowing cropped resolution when limiting max layers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make max_ratio:0.1 default. BUG: webrtc:12459 Change-Id: Ia938836f2b95467fce66a38f2525b1d2be1a352b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206803 Commit-Queue: Åsa Persson Reviewed-by: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#33261} --- media/engine/simulcast.cc | 4 +++- media/engine/simulcast_unittest.cc | 34 +++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/media/engine/simulcast.cc b/media/engine/simulcast.cc index 6b3ed71553..ebc6a240fe 100644 --- a/media/engine/simulcast.cc +++ b/media/engine/simulcast.cc @@ -42,6 +42,8 @@ constexpr webrtc::DataRate Interpolate(const webrtc::DataRate& a, constexpr char kUseLegacySimulcastLayerLimitFieldTrial[] = "WebRTC-LegacySimulcastLayerLimit"; +constexpr double kDefaultMaxRoundupRate = 0.1; + // TODO(webrtc:12415): Flip this to a kill switch when this feature launches. bool EnableLowresBitrateInterpolation( const webrtc::WebRtcKeyValueConfig& trials) { @@ -209,7 +211,7 @@ SimulcastFormat InterpolateSimulcastFormat( static_cast(total_pixels_up - total_pixels_down); // Use upper resolution if |rate| is below the configured threshold. - size_t max_layers = (max_roundup_rate && rate < max_roundup_rate.value()) + size_t max_layers = (rate < max_roundup_rate.value_or(kDefaultMaxRoundupRate)) ? formats[index - 1].max_layers : formats[index].max_layers; webrtc::DataRate max_bitrate = Interpolate(formats[index - 1].max_bitrate, diff --git a/media/engine/simulcast_unittest.cc b/media/engine/simulcast_unittest.cc index 98ee109d1a..47a9db75a1 100644 --- a/media/engine/simulcast_unittest.cc +++ b/media/engine/simulcast_unittest.cc @@ -377,7 +377,9 @@ TEST(SimulcastTest, BitratesForCloseToStandardResolution) { } } -TEST(SimulcastTest, MaxLayers) { +TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) { + test::ScopedFieldTrials field_trials( + "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.0/"); FieldTrialBasedConfig trials; const size_t kMinLayers = 1; const int kMaxLayers = 3; @@ -403,9 +405,8 @@ TEST(SimulcastTest, MaxLayers) { EXPECT_EQ(1u, streams.size()); } -TEST(SimulcastTest, MaxLayersWithFieldTrial) { - test::ScopedFieldTrials field_trials( - "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.1/"); +TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) { + // Default: "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.1/" FieldTrialBasedConfig trials; const size_t kMinLayers = 1; const int kMaxLayers = 3; @@ -420,7 +421,7 @@ TEST(SimulcastTest, MaxLayersWithFieldTrial) { kBitratePriority, kQpMax, !kScreenshare, true, trials); EXPECT_EQ(3u, streams.size()); - streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 510, + streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 508, kBitratePriority, kQpMax, !kScreenshare, true, trials); EXPECT_EQ(2u, streams.size()); @@ -439,6 +440,29 @@ TEST(SimulcastTest, MaxLayersWithFieldTrial) { EXPECT_EQ(1u, streams.size()); } +TEST(SimulcastTest, MaxLayersWithRoundUpRatio) { + test::ScopedFieldTrials field_trials( + "WebRTC-SimulcastLayerLimitRoundUp/max_ratio:0.13/"); + FieldTrialBasedConfig trials; + const size_t kMinLayers = 1; + const int kMaxLayers = 3; + + std::vector streams; + streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 270, + kBitratePriority, kQpMax, !kScreenshare, + true, trials); + EXPECT_EQ(2u, streams.size()); + // Lowest cropped height where max layers from higher resolution is used. + streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 252, + kBitratePriority, kQpMax, !kScreenshare, + true, trials); + EXPECT_EQ(2u, streams.size()); + streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 250, + kBitratePriority, kQpMax, !kScreenshare, + true, trials); + EXPECT_EQ(1u, streams.size()); +} + TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) { // TODO(webrtc:12415): Remove when feature launches. test::ScopedFieldTrials field_trials(