Remove bitrate_priority argument from GetSimulcastConfig()

This is a cleanup of simulcast.cc. bitrate_priority is not needed to decide simulcast config. Move setting of bitrate priority in VideoStream one level up, to EncoderStreamFactory::CreateEncoderStreams().

Bug: webrtc:351644568
Change-Id: I002d728ccf8d141fe4bbb32b390129ce57c830cd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/357101
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42629}
This commit is contained in:
Sergey Silkin 2024-07-12 14:24:48 +02:00 committed by WebRTC LUCI CQ
parent cd8b36bb9f
commit c0a32fe01b
8 changed files with 109 additions and 110 deletions

View File

@ -9591,9 +9591,8 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test {
if (num_configured_streams > 1 || conference_mode) {
expected_streams = GetSimulcastConfig(
/*min_layers=*/1, num_configured_streams, capture_width,
capture_height, webrtc::kDefaultBitratePriority,
kDefaultVideoMaxQpVpx, screenshare && conference_mode, true,
field_trials_, webrtc::kVideoCodecVP8);
capture_height, kDefaultVideoMaxQpVpx, screenshare && conference_mode,
true, field_trials_, webrtc::kVideoCodecVP8);
if (screenshare && conference_mode) {
for (const webrtc::VideoStream& stream : expected_streams) {
// Never scale screen content.

View File

@ -72,7 +72,6 @@ namespace {
using VideoStatistics = VideoCodecTestStats::VideoStatistics;
const int kBaseKeyFrameInterval = 3000;
const double kBitratePriority = 1.0;
const int kDefaultMaxFramerateFps = 30;
const int kMaxQp = 56;
@ -80,7 +79,7 @@ void ConfigureSimulcast(VideoCodec* codec_settings) {
FieldTrialBasedConfig trials;
const std::vector<webrtc::VideoStream> streams = cricket::GetSimulcastConfig(
/*min_layer=*/1, codec_settings->numberOfSimulcastStreams,
codec_settings->width, codec_settings->height, kBitratePriority, kMaxQp,
codec_settings->width, codec_settings->height, kMaxQp,
/* is_screenshare = */ false, true, trials, webrtc::kVideoCodecVP8);
for (size_t i = 0; i < streams.size(); ++i) {

View File

@ -1298,7 +1298,7 @@ void ConfigureSimulcast(VideoCodec* vc) {
const std::vector<webrtc::VideoStream> streams = cricket::GetSimulcastConfig(
/*min_layer=*/1, num_spatial_layers, vc->width, vc->height,
/*bitrate_priority=*/1.0, cricket::kDefaultVideoMaxQpVpx,
cricket::kDefaultVideoMaxQpVpx,
/*is_screenshare=*/false, /*temporal_layers_supported=*/true,
field_trials, webrtc::kVideoCodecVP8);

View File

@ -149,15 +149,23 @@ std::vector<webrtc::VideoStream> EncoderStreamFactory::CreateEncoderStreams(
}
}
std::vector<webrtc::VideoStream> streams;
if (is_simulcast ||
webrtc::SimulcastUtility::IsConferenceModeScreenshare(encoder_config)) {
return CreateSimulcastOrConferenceModeScreenshareStreams(
streams = CreateSimulcastOrConferenceModeScreenshareStreams(
trials, frame_width, frame_height, encoder_config,
experimental_min_bitrate);
} else {
streams = CreateDefaultVideoStreams(
frame_width, frame_height, encoder_config, experimental_min_bitrate);
}
return CreateDefaultVideoStreams(frame_width, frame_height, encoder_config,
experimental_min_bitrate);
// The bitrate priority currently implemented on a per-sender level, so we
// just set it for the first simulcast layer.
RTC_DCHECK_GT(streams.size(), 0);
streams[0].bitrate_priority = encoder_config.bitrate_priority;
return streams;
}
std::vector<webrtc::VideoStream>
@ -320,8 +328,7 @@ EncoderStreamFactory::CreateSimulcastOrConferenceModeScreenshareStreams(
// or use the regular simulcast configuration path which is generic.
layers = GetSimulcastConfig(
FindRequiredActiveLayers(encoder_config),
encoder_config.number_of_streams, width, height,
encoder_config.bitrate_priority, encoder_config.max_qp,
encoder_config.number_of_streams, width, height, encoder_config.max_qp,
webrtc::SimulcastUtility::IsConferenceModeScreenshare(encoder_config),
temporal_layers_supported, trials, encoder_config.codec_type);
// Allow an experiment to override the minimum bitrate for the lowest

View File

@ -79,4 +79,21 @@ TEST(EncoderStreamFactory, SinglecastRequestedResolutionWithAdaptation) {
}));
}
TEST(EncoderStreamFactory, BitratePriority) {
constexpr double kBitratePriority = 0.123;
ExplicitKeyValueConfig field_trials("");
VideoEncoder::EncoderInfo encoder_info;
auto factory = rtc::make_ref_counted<EncoderStreamFactory>(encoder_info);
VideoEncoderConfig encoder_config;
encoder_config.number_of_streams = 2;
encoder_config.bitrate_priority = kBitratePriority;
encoder_config.simulcast_layers = {
LayerWithRequestedResolution({.width = 320, .height = 180}),
LayerWithRequestedResolution({.width = 640, .height = 360})};
auto streams =
factory->CreateEncoderStreams(field_trials, 640, 360, encoder_config);
ASSERT_EQ(streams.size(), 2u);
EXPECT_EQ(streams[0].bitrate_priority, kBitratePriority);
EXPECT_FALSE(streams[1].bitrate_priority);
}
} // namespace webrtc

View File

@ -332,7 +332,6 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
size_t max_layers,
int width,
int height,
double bitrate_priority,
int max_qp,
bool is_screenshare_with_conference_mode,
bool temporal_layers_supported,
@ -344,8 +343,8 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
const bool base_heavy_tl3_rate_alloc =
webrtc::RateControlSettings(trials).Vp8BaseHeavyTl3RateAllocation();
if (is_screenshare_with_conference_mode) {
return GetScreenshareLayers(max_layers, width, height, bitrate_priority,
max_qp, temporal_layers_supported,
return GetScreenshareLayers(max_layers, width, height, max_qp,
temporal_layers_supported,
base_heavy_tl3_rate_alloc, trials);
} else {
// Some applications rely on the old behavior limiting the simulcast layer
@ -354,8 +353,8 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
max_layers = LimitSimulcastLayerCount(width, height, min_layers, max_layers,
trials, codec);
return GetNormalSimulcastLayers(max_layers, width, height, bitrate_priority,
max_qp, temporal_layers_supported,
return GetNormalSimulcastLayers(max_layers, width, height, max_qp,
temporal_layers_supported,
base_heavy_tl3_rate_alloc, trials, codec);
}
}
@ -364,7 +363,6 @@ std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
size_t layer_count,
int width,
int height,
double bitrate_priority,
int max_qp,
bool temporal_layers_supported,
bool base_heavy_tl3_rate_alloc,
@ -437,12 +435,7 @@ std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
break;
}
}
// Currently the relative bitrate priority of the sender is controlled by
// the value of the lowest VideoStream.
// TODO(bugs.webrtc.org/8630): The web specification describes being able to
// control relative bitrate for each individual simulcast layer, but this
// is currently just implemented per rtp sender.
layers[0].bitrate_priority = bitrate_priority;
return layers;
}
@ -450,7 +443,6 @@ std::vector<webrtc::VideoStream> GetScreenshareLayers(
size_t max_layers,
int width,
int height,
double bitrate_priority,
int max_qp,
bool temporal_layers_supported,
bool base_heavy_tl3_rate_alloc,
@ -504,9 +496,6 @@ std::vector<webrtc::VideoStream> GetScreenshareLayers(
layers[1].max_bitrate_bps = max_bitrate_bps;
}
// The bitrate priority currently implemented on a per-sender level, so we
// just set it for the first simulcast layer.
layers[0].bitrate_priority = bitrate_priority;
return layers;
}

View File

@ -41,7 +41,6 @@ std::vector<webrtc::VideoStream> GetSimulcastConfig(
size_t max_layers,
int width,
int height,
double bitrate_priority,
int max_qp,
bool is_screenshare_with_conference_mode,
bool temporal_layers_supported,
@ -53,7 +52,6 @@ std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
size_t max_layers,
int width,
int height,
double bitrate_priority,
int max_qp,
bool temporal_layers_supported,
bool base_heavy_tl3_rate_alloc,
@ -65,7 +63,6 @@ std::vector<webrtc::VideoStream> GetScreenshareLayers(
size_t max_layers,
int width,
int height,
double bitrate_priority,
int max_qp,
bool temporal_layers_supported,
bool base_heavy_tl3_rate_alloc,

View File

@ -20,7 +20,6 @@ namespace {
using test::ExplicitKeyValueConfig;
constexpr int kQpMax = 55;
constexpr double kBitratePriority = 2.0;
constexpr bool kScreenshare = true;
constexpr int kDefaultTemporalLayers = 3; // Value from simulcast.cc.
@ -88,8 +87,8 @@ TEST(SimulcastTest, GetConfig) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 1280, 720, kBitratePriority, kQpMax,
!kScreenshare, true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 1280, 720, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
EXPECT_EQ(320u, streams[0].width);
@ -108,10 +107,6 @@ TEST(SimulcastTest, GetConfig) {
EXPECT_EQ(kExpected[i].max_bitrate_bps, streams[i].max_bitrate_bps);
EXPECT_TRUE(streams[i].active);
}
// Currently set on lowest stream.
EXPECT_EQ(kBitratePriority, streams[0].bitrate_priority);
EXPECT_FALSE(streams[1].bitrate_priority);
EXPECT_FALSE(streams[2].bitrate_priority);
}
TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) {
@ -123,8 +118,8 @@ TEST(SimulcastTest, GetConfigWithBaseHeavyVP8TL3RateAllocation) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 1280, 720, kBitratePriority, kQpMax,
!kScreenshare, true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 1280, 720, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kExpected[0].min_bitrate_bps, streams[0].min_bitrate_bps);
EXPECT_EQ(static_cast<int>(0.4 * kExpected[0].target_bitrate_bps / 0.6),
@ -144,8 +139,8 @@ TEST(SimulcastTest, GetConfigWithLimitedMaxLayers) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 2;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 1280, 720, kBitratePriority, kQpMax,
!kScreenshare, true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 1280, 720, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
EXPECT_EQ(640u, streams[0].width);
@ -161,8 +156,8 @@ TEST(SimulcastTest, GetConfigWithLimitedMaxLayersForResolution) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 800, 600, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 800, 600, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
EXPECT_EQ(400u, streams[0].width);
@ -178,8 +173,8 @@ TEST(SimulcastTest, GetConfigWithLowResolutionScreenshare) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 100, 100, kBitratePriority, kQpMax, kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 100, 100, kQpMax, kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
// Simulcast streams number is never decreased for screenshare,
// even for very low resolution.
@ -193,8 +188,8 @@ TEST(SimulcastTest, GetConfigWithNotLimitedMaxLayersForResolution) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 800, 600, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 800, 600, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
EXPECT_EQ(200u, streams[0].width);
@ -211,8 +206,8 @@ TEST(SimulcastTest, GetConfigWithNormalizedResolution) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 2;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 640 + 1, 360 + 1, kBitratePriority, kQpMax,
!kScreenshare, true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 640 + 1, 360 + 1, kQpMax, !kScreenshare, true,
trials, webrtc::kVideoCodecVP8);
// Must be divisible by |2 ^ (num_layers - 1)|.
EXPECT_EQ(kMaxLayers, streams.size());
@ -229,8 +224,8 @@ TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy4) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 2;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 709, 501, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 709, 501, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
// Must be divisible by |2 ^ 2|.
EXPECT_EQ(kMaxLayers, streams.size());
@ -247,8 +242,8 @@ TEST(SimulcastTest, GetConfigWithNormalizedResolutionDivisibleBy8) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 2;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 709, 501, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 709, 501, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
// Must be divisible by |2 ^ 3|.
EXPECT_EQ(kMaxLayers, streams.size());
@ -265,18 +260,18 @@ TEST(SimulcastTest, GetConfigForLegacyLayerLimit) {
const size_t kMinLayers = 1;
const int kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 320, 180, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 320, 180, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(1u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 640, 360,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 1920, 1080,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
}
@ -287,18 +282,18 @@ TEST(SimulcastTest, GetConfigForLegacyLayerLimitWithRequiredHD) {
const size_t kMinLayers = 3; // "HD" layer must be present!
const int kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 320, 180, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 320, 180, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 640, 360,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 1920, 1080,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
}
@ -307,8 +302,8 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcast) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 1400, 800, kBitratePriority, kQpMax, kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 1400, 800, kQpMax, kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_GT(streams.size(), 1u);
for (size_t i = 0; i < streams.size(); ++i) {
@ -329,8 +324,8 @@ TEST(SimulcastTest, GetConfigForScreenshareSimulcastWithLimitedMaxLayers) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 1;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 1400, 800, kBitratePriority, kQpMax, kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 1400, 800, kQpMax, kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
}
@ -340,8 +335,8 @@ TEST(SimulcastTest, AveragesBitratesForNonStandardResolution) {
const size_t kMinLayers = 1;
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, 900, 800, kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, 900, 800, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
EXPECT_EQ(900u, streams[2].width);
@ -362,8 +357,8 @@ TEST(SimulcastTest, BitratesForCloseToStandardResolution) {
const std::vector<VideoStream> kExpectedNear = GetSimulcastBitrates720p();
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
kMinLayers, kMaxLayers, kWidth, kHeight, kBitratePriority, kQpMax,
!kScreenshare, true, trials, webrtc::kVideoCodecVP8);
kMinLayers, kMaxLayers, kWidth, kHeight, kQpMax, !kScreenshare, true,
trials, webrtc::kVideoCodecVP8);
EXPECT_EQ(kMaxLayers, streams.size());
EXPECT_EQ(kWidth, streams[2].width);
@ -387,22 +382,22 @@ TEST(SimulcastTest, MaxLayersWithRoundUpDisabled) {
std::vector<VideoStream> streams;
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 540,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
// <960x540: 2 layers
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 539,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 270,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
// <480x270: 1 layer
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 269,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(1u, streams.size());
}
@ -414,30 +409,30 @@ TEST(SimulcastTest, MaxLayersWithDefaultRoundUpRatio) {
std::vector<VideoStream> streams;
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 540,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
// Lowest cropped height where max layers from higher resolution is used.
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 512,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(3u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 960, 508,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 270,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
// Lowest cropped height where max layers from higher resolution is used.
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 256,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 254,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(1u, streams.size());
}
@ -450,17 +445,17 @@ TEST(SimulcastTest, MaxLayersWithRoundUpRatio) {
std::vector<VideoStream> streams;
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 270,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
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, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(2u, streams.size());
streams = cricket::GetSimulcastConfig(kMinLayers, kMaxLayers, 480, 250,
kBitratePriority, kQpMax, !kScreenshare,
true, trials, webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
EXPECT_EQ(1u, streams.size());
}
@ -472,8 +467,7 @@ TEST(SimulcastTest, BitratesInterpolatedForResBelow180p) {
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
/* min_layers = */ 1, kMaxLayers, /* width = */ 960, /* height = */ 540,
kBitratePriority, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials, webrtc::kVideoCodecVP8);
ASSERT_EQ(streams.size(), kMaxLayers);
EXPECT_EQ(240u, streams[0].width);
@ -490,7 +484,7 @@ TEST(SimulcastTest, BitratesConsistentForVerySmallRes) {
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
/* min_layers = */ 1, /* max_layers = */ 3, /* width = */ 1,
/* height = */ 1, kBitratePriority, kQpMax, !kScreenshare, true, trials,
/* height = */ 1, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
ASSERT_TRUE(!streams.empty());
@ -509,8 +503,7 @@ TEST(SimulcastTest,
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
/* min_layers = */ 1, kMaxLayers, /* width = */ 960, /* height = */ 540,
kBitratePriority, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
kQpMax, !kScreenshare, true, trials, webrtc::kVideoCodecVP8);
ASSERT_EQ(streams.size(), kMaxLayers);
EXPECT_EQ(240u, streams[0].width);
@ -526,12 +519,12 @@ TEST(SimulcastTest, BitratesBasedOnCodec) {
const size_t kMaxLayers = 3;
std::vector<VideoStream> streams_vp8 = cricket::GetSimulcastConfig(
/* min_layers = */ 1, /* max_layers = */ 3, /* width = */ 1280,
/* height = */ 720, kBitratePriority, kQpMax, !kScreenshare, true, trials,
/* height = */ 720, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP8);
std::vector<VideoStream> streams_vp9 = cricket::GetSimulcastConfig(
/* min_layers = */ 1, /* max_layers = */ 3, /* width = */ 1280,
/* height = */ 720, kBitratePriority, kQpMax, !kScreenshare, true, trials,
/* height = */ 720, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP9);
ASSERT_EQ(streams_vp8.size(), kMaxLayers);
@ -562,8 +555,7 @@ TEST(SimulcastTest, BitratesForVP9) {
std::vector<VideoStream> streams = cricket::GetSimulcastConfig(
/* min_layers = */ 1, kMaxLayers, /* width = */ 1280, /* height = */ 720,
kBitratePriority, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP9);
kQpMax, !kScreenshare, true, trials, webrtc::kVideoCodecVP9);
ASSERT_EQ(streams.size(), kMaxLayers);
EXPECT_EQ(1280u, streams[2].width);
@ -574,8 +566,7 @@ TEST(SimulcastTest, BitratesForVP9) {
streams = cricket::GetSimulcastConfig(
/* min_layers = */ 1, kMaxLayers, /* width = */ 1276, /* height = */ 716,
kBitratePriority, kQpMax, !kScreenshare, true, trials,
webrtc::kVideoCodecVP9);
kQpMax, !kScreenshare, true, trials, webrtc::kVideoCodecVP9);
ASSERT_EQ(streams.size(), kMaxLayers);
EXPECT_EQ(1276u, streams[2].width);