Add field trial for normalized simulcast size.
The width/height of the highest simulcast layer is divisible by 2^exponent. The exponent is allowed to be set through the field trial. Bug: none Change-Id: I2ec0af2deb6e3a176f705a2ad1c250a35b086701 Reviewed-on: https://webrtc-review.googlesource.com/c/104067 Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25159}
This commit is contained in:
parent
09256c17b4
commit
1a35fbd9c3
@ -323,6 +323,7 @@ rtc_static_library("rtc_audio_video") {
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_task_queue",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/experiments:normalize_simulcast_size_experiment",
|
||||
"../system_wrappers",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "media/engine/simulcast.h"
|
||||
#include "modules/video_coding/utility/simulcast_rate_allocator.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
#include "rtc_base/experiments/normalize_simulcast_size_experiment.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
@ -140,7 +141,13 @@ int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
// Simulcast stream width and height must both be dividable by
|
||||
// |2 ^ (simulcast_layers - 1)|.
|
||||
int NormalizeSimulcastSize(int size, size_t simulcast_layers) {
|
||||
const int base2_exponent = static_cast<int>(simulcast_layers) - 1;
|
||||
int base2_exponent = static_cast<int>(simulcast_layers) - 1;
|
||||
const absl::optional<int> experimental_base2_exponent =
|
||||
webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent();
|
||||
if (experimental_base2_exponent &&
|
||||
(size > (1 << *experimental_base2_exponent))) {
|
||||
base2_exponent = *experimental_base2_exponent;
|
||||
}
|
||||
return ((size >> base2_exponent) << base2_exponent);
|
||||
}
|
||||
|
||||
|
||||
@ -179,7 +179,7 @@ TEST(SimulcastTest, GetConfigWithNormalizedResolution) {
|
||||
kMaxLayers, 640 + 1, 360 + 1, kMaxBitrateBps, kBitratePriority, kQpMax,
|
||||
kMaxFps, !kScreenshare);
|
||||
|
||||
// Must be dividable by |2 ^ (num_layers - 1)|.
|
||||
// Must be divisible by |2 ^ (num_layers - 1)|.
|
||||
EXPECT_EQ(kMaxLayers, streams.size());
|
||||
EXPECT_EQ(320u, streams[0].width);
|
||||
EXPECT_EQ(180u, streams[0].height);
|
||||
@ -187,6 +187,40 @@ TEST(SimulcastTest, GetConfigWithNormalizedResolution) {
|
||||
EXPECT_EQ(360u, streams[1].height);
|
||||
}
|
||||
|
||||
TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy4) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-2/");
|
||||
|
||||
const size_t kMaxLayers = 2;
|
||||
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
|
||||
kMaxLayers, 709, 501, kMaxBitrateBps, kBitratePriority, kQpMax, kMaxFps,
|
||||
!kScreenshare);
|
||||
|
||||
// Must be divisible by |2 ^ 2|.
|
||||
EXPECT_EQ(kMaxLayers, streams.size());
|
||||
EXPECT_EQ(354u, streams[0].width);
|
||||
EXPECT_EQ(250u, streams[0].height);
|
||||
EXPECT_EQ(708u, streams[1].width);
|
||||
EXPECT_EQ(500u, streams[1].height);
|
||||
}
|
||||
|
||||
TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy8) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-3/");
|
||||
|
||||
const size_t kMaxLayers = 2;
|
||||
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
|
||||
kMaxLayers, 709, 501, kMaxBitrateBps, kBitratePriority, kQpMax, kMaxFps,
|
||||
!kScreenshare);
|
||||
|
||||
// Must be divisible by |2 ^ 3|.
|
||||
EXPECT_EQ(kMaxLayers, streams.size());
|
||||
EXPECT_EQ(352u, streams[0].width);
|
||||
EXPECT_EQ(248u, streams[0].height);
|
||||
EXPECT_EQ(704u, streams[1].width);
|
||||
EXPECT_EQ(496u, streams[1].height);
|
||||
}
|
||||
|
||||
TEST(SimulcastTest, GetConfigForScreenshare) {
|
||||
const size_t kMaxLayers = 3;
|
||||
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
|
||||
|
||||
@ -63,6 +63,18 @@ rtc_static_library("quality_scaling_experiment") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("normalize_simulcast_size_experiment") {
|
||||
sources = [
|
||||
"normalize_simulcast_size_experiment.cc",
|
||||
"normalize_simulcast_size_experiment.h",
|
||||
]
|
||||
deps = [
|
||||
"../:rtc_base_approved",
|
||||
"../../system_wrappers:field_trial",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("rtt_mult_experiment") {
|
||||
sources = [
|
||||
"rtt_mult_experiment.cc",
|
||||
@ -82,12 +94,14 @@ if (rtc_include_tests) {
|
||||
"congestion_controller_experiment_unittest.cc",
|
||||
"field_trial_parser_unittest.cc",
|
||||
"field_trial_units_unittest.cc",
|
||||
"normalize_simulcast_size_experiment_unittest.cc",
|
||||
"quality_scaling_experiment_unittest.cc",
|
||||
"rtt_mult_experiment_unittest.cc",
|
||||
]
|
||||
deps = [
|
||||
":congestion_controller_experiment",
|
||||
":field_trial_parser",
|
||||
":normalize_simulcast_size_experiment",
|
||||
":quality_scaling_experiment",
|
||||
":rtt_mult_experiment",
|
||||
"../:rtc_base_tests_main",
|
||||
|
||||
47
rtc_base/experiments/normalize_simulcast_size_experiment.cc
Normal file
47
rtc_base/experiments/normalize_simulcast_size_experiment.cc
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/experiments/normalize_simulcast_size_experiment.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "rtc_base/logging.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
constexpr char kFieldTrial[] = "WebRTC-NormalizeSimulcastResolution";
|
||||
constexpr int kMinSetting = 0;
|
||||
constexpr int kMaxSetting = 5;
|
||||
} // namespace
|
||||
|
||||
absl::optional<int> NormalizeSimulcastSizeExperiment::GetBase2Exponent() {
|
||||
if (!webrtc::field_trial::IsEnabled(kFieldTrial))
|
||||
return absl::nullopt;
|
||||
|
||||
const std::string group = webrtc::field_trial::FindFullName(kFieldTrial);
|
||||
if (group.empty())
|
||||
return absl::nullopt;
|
||||
|
||||
int exponent;
|
||||
if (sscanf(group.c_str(), "Enabled-%d", &exponent) != 1) {
|
||||
RTC_LOG(LS_WARNING) << "No parameter provided.";
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
if (exponent < kMinSetting || exponent > kMaxSetting) {
|
||||
RTC_LOG(LS_WARNING) << "Unsupported exp value provided, value ignored.";
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
return absl::optional<int>(exponent);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
25
rtc_base/experiments/normalize_simulcast_size_experiment.h
Normal file
25
rtc_base/experiments/normalize_simulcast_size_experiment.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_
|
||||
#define RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace webrtc {
|
||||
class NormalizeSimulcastSizeExperiment {
|
||||
public:
|
||||
// Returns the base two exponent from field trial.
|
||||
static absl::optional<int> GetBase2Exponent();
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/experiments/normalize_simulcast_size_experiment.h"
|
||||
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "test/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponent) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-2/");
|
||||
EXPECT_EQ(2, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponentWithTwoParameters) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-3-4/");
|
||||
EXPECT_EQ(3, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponentFailsIfNotEnabled) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Disabled/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForInvalidFieldTrial) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-invalid/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForNegativeOutOfBoundValue) {
|
||||
// Supported range: [0, 5].
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled--1/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForPositiveOutOfBoundValue) {
|
||||
// Supported range: [0, 5].
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-6/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
Loading…
x
Reference in New Issue
Block a user