Update VideoBitrateAllocator allocate to take a struct with more fields
We want to evaluate more data in order to make better choices in the
bitrate allocators.
In order to freely update the parameter list without
breaking the API many times for projects customizing them, we'll use a
struct instead.
Bug: webrtc:10126
Change-Id: I443f86781c5134950294cdd1e3197a47447cf973
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141418
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28748}
diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index 7564e85..5ec1187 100644
--- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -294,8 +294,9 @@
}
SimulcastRateAllocator init_allocator(codec_);
- VideoBitrateAllocation allocation = init_allocator.GetAllocation(
- codec_.startBitrate * 1000, codec_.maxFramerate);
+ VideoBitrateAllocation allocation =
+ init_allocator.Allocate(VideoBitrateAllocationParameters(
+ DataRate::kbps(codec_.startBitrate), codec_.maxFramerate));
SetRates(RateControlParameters(allocation, codec_.maxFramerate));
return WEBRTC_VIDEO_CODEC_OK;
}
diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc
index 9b0903b..7952510 100644
--- a/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/modules/video_coding/codecs/test/videoprocessor.cc
@@ -305,8 +305,9 @@
void VideoProcessor::SetRates(size_t bitrate_kbps, double framerate_fps) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
framerate_fps_ = framerate_fps;
- bitrate_allocation_ = bitrate_allocator_->GetAllocation(
- static_cast<uint32_t>(bitrate_kbps * 1000), framerate_fps_);
+ bitrate_allocation_ =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ static_cast<uint32_t>(bitrate_kbps * 1000), framerate_fps_));
encoder_->SetRates(
VideoEncoder::RateControlParameters(bitrate_allocation_, framerate_fps_));
}
diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc b/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc
index dd123cf..9085afd 100644
--- a/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc
+++ b/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc
@@ -96,7 +96,9 @@
codec.simulcastStream[0].numberOfTemporalLayers = num_temporal_layers;
codec.simulcastStream[0].active = true;
SimulcastRateAllocator allocator(codec);
- return allocator.GetAllocation(target_bitrate_kbps, framerate_fps)
+ return allocator
+ .Allocate(
+ VideoBitrateAllocationParameters(target_bitrate_kbps, framerate_fps))
.GetTemporalLayerAllocation(0);
}
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index ff2c801..892d6ff 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -642,8 +642,9 @@
// at position 0 and they have highest resolution at position 0.
const size_t stream_idx_cfg_0 = encoders_.size() - 1;
SimulcastRateAllocator init_allocator(codec_);
- VideoBitrateAllocation allocation = init_allocator.GetAllocation(
- inst->startBitrate * 1000, inst->maxFramerate);
+ VideoBitrateAllocation allocation =
+ init_allocator.Allocate(VideoBitrateAllocationParameters(
+ inst->startBitrate * 1000, inst->maxFramerate));
std::vector<uint32_t> stream_bitrates;
for (int i = 0; i == 0 || i < inst->numberOfSimulcastStreams; ++i) {
uint32_t bitrate = allocation.GetSpatialLayerSum(i) / 1000;
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator.cc b/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
index dcbd03e..5aa414e 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator.cc
@@ -103,18 +103,18 @@
RTC_DCHECK_GT(codec.VP9().numberOfTemporalLayers, 0u);
}
-VideoBitrateAllocation SvcRateAllocator::GetAllocation(
- uint32_t total_bitrate_bps,
- uint32_t framerate_fps) {
+VideoBitrateAllocation SvcRateAllocator::Allocate(
+ VideoBitrateAllocationParameters parameters) {
+ DataRate total_bitrate = parameters.total_bitrate;
if (codec_.maxBitrate != 0) {
- total_bitrate_bps = std::min(total_bitrate_bps, codec_.maxBitrate * 1000);
+ total_bitrate = std::min(total_bitrate, DataRate::kbps(codec_.maxBitrate));
}
if (codec_.spatialLayers[0].targetBitrate == 0) {
// Delegate rate distribution to VP9 encoder wrapper if bitrate thresholds
// are not set.
VideoBitrateAllocation bitrate_allocation;
- bitrate_allocation.SetBitrate(0, 0, total_bitrate_bps);
+ bitrate_allocation.SetBitrate(0, 0, total_bitrate.bps());
return bitrate_allocation;
}
@@ -124,9 +124,9 @@
}
if (codec_.mode == VideoCodecMode::kRealtimeVideo) {
- return GetAllocationNormalVideo(total_bitrate_bps, num_spatial_layers);
+ return GetAllocationNormalVideo(total_bitrate.bps(), num_spatial_layers);
} else {
- return GetAllocationScreenSharing(total_bitrate_bps, num_spatial_layers);
+ return GetAllocationScreenSharing(total_bitrate.bps(), num_spatial_layers);
}
}
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator.h b/modules/video_coding/codecs/vp9/svc_rate_allocator.h
index 79bb56b..e410964 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator.h
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator.h
@@ -26,8 +26,8 @@
public:
explicit SvcRateAllocator(const VideoCodec& codec);
- VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
- uint32_t framerate_fps) override;
+ VideoBitrateAllocation Allocate(
+ VideoBitrateAllocationParameters parameters) override;
static uint32_t GetMaxBitrateBps(const VideoCodec& codec);
static uint32_t GetPaddingBitrateBps(const VideoCodec& codec);
diff --git a/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc b/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
index 71392a9..c0febb8 100644
--- a/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
+++ b/modules/video_coding/codecs/vp9/svc_rate_allocator_unittest.cc
@@ -52,7 +52,8 @@
VideoCodec codec = Configure(320, 180, 3, 3, false);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation =
+ allocator.Allocate(VideoBitrateAllocationParameters(1000 * 1000, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_EQ(allocation.GetSpatialLayerSum(1), 0u);
@@ -62,7 +63,8 @@
VideoCodec codec = Configure(640, 360, 3, 3, false);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation =
+ allocator.Allocate(VideoBitrateAllocationParameters(1000 * 1000, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0u);
@@ -73,7 +75,8 @@
VideoCodec codec = Configure(1280, 720, 3, 3, false);
SvcRateAllocator allocator = SvcRateAllocator(codec);
- VideoBitrateAllocation allocation = allocator.GetAllocation(1000 * 1000, 30);
+ VideoBitrateAllocation allocation =
+ allocator.Allocate(VideoBitrateAllocationParameters(1000 * 1000, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0u);
@@ -87,8 +90,8 @@
const SpatialLayer* layers = codec.spatialLayers;
- VideoBitrateAllocation allocation =
- allocator.GetAllocation(layers[0].minBitrate * 1000 / 2, 30);
+ VideoBitrateAllocation allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(layers[0].minBitrate * 1000 / 2, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_LT(allocation.GetSpatialLayerSum(0), layers[0].minBitrate * 1000);
@@ -104,8 +107,9 @@
size_t min_bitrate_for_640x360_layer_kbps =
layers[0].minBitrate + layers[1].minBitrate;
- VideoBitrateAllocation allocation = allocator.GetAllocation(
- min_bitrate_for_640x360_layer_kbps * 1000 - 1, 30);
+ VideoBitrateAllocation allocation =
+ allocator.Allocate(VideoBitrateAllocationParameters(
+ min_bitrate_for_640x360_layer_kbps * 1000 - 1, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_EQ(allocation.GetSpatialLayerSum(1), 0u);
@@ -120,8 +124,9 @@
size_t min_bitrate_for_1280x720_layer_kbps =
layers[0].minBitrate + layers[1].minBitrate + layers[2].minBitrate;
- VideoBitrateAllocation allocation = allocator.GetAllocation(
- min_bitrate_for_1280x720_layer_kbps * 1000 - 1, 30);
+ VideoBitrateAllocation allocation =
+ allocator.Allocate(VideoBitrateAllocationParameters(
+ min_bitrate_for_1280x720_layer_kbps * 1000 - 1, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0u);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0u);
@@ -135,8 +140,8 @@
const SpatialLayer* layers = codec.spatialLayers;
const uint32_t link_mbps = 100;
- VideoBitrateAllocation allocation =
- allocator.GetAllocation(link_mbps * 1000000, 30);
+ VideoBitrateAllocation allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(link_mbps * 1000000, 30));
EXPECT_EQ(allocation.get_sum_kbps(),
layers[0].maxBitrate + layers[1].maxBitrate + layers[2].maxBitrate);
@@ -153,13 +158,13 @@
EXPECT_LE(codec.VP9()->numberOfSpatialLayers, 3U);
- VideoBitrateAllocation allocation =
- allocator.GetAllocation(layers[0].minBitrate * 1000, 30);
+ VideoBitrateAllocation allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(layers[0].minBitrate * 1000, 30));
EXPECT_EQ(allocation.GetSpatialLayerSum(0) / 1000, layers[0].minBitrate);
EXPECT_EQ(allocation.GetSpatialLayerSum(1), 0UL);
- allocation = allocator.GetAllocation(
- (layers[0].targetBitrate + layers[1].minBitrate) * 1000, 30);
+ allocation = allocator.Allocate(VideoBitrateAllocationParameters(
+ (layers[0].targetBitrate + layers[1].minBitrate) * 1000, 30));
EXPECT_EQ(allocation.GetSpatialLayerSum(0) / 1000, layers[0].targetBitrate);
EXPECT_EQ(allocation.GetSpatialLayerSum(1) / 1000, layers[1].minBitrate);
}
@@ -173,8 +178,8 @@
SvcRateAllocator allocator = SvcRateAllocator(codec);
- VideoBitrateAllocation allocation =
- allocator.GetAllocation(10 * 1000 * 1000, 30);
+ VideoBitrateAllocation allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(10 * 1000 * 1000, 30));
// Ensure layers spatial_idx < deactivated_idx are activated.
for (int spatial_idx = 0; spatial_idx < deactivated_idx; ++spatial_idx) {
@@ -227,14 +232,15 @@
uint32_t padding_bitrate_bps = SvcRateAllocator::GetPaddingBitrateBps(codec);
- VideoBitrateAllocation allocation =
- allocator.GetAllocation(padding_bitrate_bps, 30);
+ VideoBitrateAllocation allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(padding_bitrate_bps, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0UL);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0UL);
EXPECT_GT(allocation.GetSpatialLayerSum(2), 0UL);
// Allocate 90% of padding bitrate. Top layer should be disabled.
- allocation = allocator.GetAllocation(9 * padding_bitrate_bps / 10, 30);
+ allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(9 * padding_bitrate_bps / 10, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0UL);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0UL);
EXPECT_EQ(allocation.GetSpatialLayerSum(2), 0UL);
@@ -243,12 +249,14 @@
codec.spatialLayers[2].active = false;
padding_bitrate_bps = SvcRateAllocator::GetPaddingBitrateBps(codec);
- allocation = allocator.GetAllocation(padding_bitrate_bps, 30);
+ allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(padding_bitrate_bps, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0UL);
EXPECT_GT(allocation.GetSpatialLayerSum(1), 0UL);
EXPECT_EQ(allocation.GetSpatialLayerSum(2), 0UL);
- allocation = allocator.GetAllocation(9 * padding_bitrate_bps / 10, 30);
+ allocation = allocator.Allocate(
+ VideoBitrateAllocationParameters(9 * padding_bitrate_bps / 10, 30));
EXPECT_GT(allocation.GetSpatialLayerSum(0), 0UL);
EXPECT_EQ(allocation.GetSpatialLayerSum(1), 0UL);
EXPECT_EQ(allocation.GetSpatialLayerSum(2), 0UL);
diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc
index 9f46ade..a0f410f 100644
--- a/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -659,8 +659,9 @@
}
SvcRateAllocator init_allocator(codec_);
- current_bitrate_allocation_ = init_allocator.GetAllocation(
- inst->startBitrate * 1000, inst->maxFramerate);
+ current_bitrate_allocation_ =
+ init_allocator.Allocate(VideoBitrateAllocationParameters(
+ inst->startBitrate * 1000, inst->maxFramerate));
if (!SetSvcRates(current_bitrate_allocation_)) {
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator.cc b/modules/video_coding/utility/default_video_bitrate_allocator.cc
index 6d3ca53..bbb15cd 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator.cc
+++ b/modules/video_coding/utility/default_video_bitrate_allocator.cc
@@ -25,14 +25,13 @@
// TODO(http://crbug.com/webrtc/9671): Do not split bitrate between simulcast
// streams, but allocate everything to the first stream.
-VideoBitrateAllocation DefaultVideoBitrateAllocator::GetAllocation(
- uint32_t total_bitrate_bps,
- uint32_t framerate) {
+VideoBitrateAllocation DefaultVideoBitrateAllocator::Allocate(
+ VideoBitrateAllocationParameters parameters) {
VideoBitrateAllocation allocation;
- if (total_bitrate_bps == 0 || !codec_.active)
+ if (parameters.total_bitrate.IsZero() || !codec_.active)
return allocation;
- uint32_t allocated_bitrate_bps = total_bitrate_bps;
+ uint32_t allocated_bitrate_bps = parameters.total_bitrate.bps();
allocated_bitrate_bps =
std::max(allocated_bitrate_bps, codec_.minBitrate * 1000);
if (codec_.maxBitrate > 0) {
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator.h b/modules/video_coding/utility/default_video_bitrate_allocator.h
index de5c23f..c3eb670 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator.h
+++ b/modules/video_coding/utility/default_video_bitrate_allocator.h
@@ -24,8 +24,8 @@
explicit DefaultVideoBitrateAllocator(const VideoCodec& codec);
~DefaultVideoBitrateAllocator() override;
- VideoBitrateAllocation GetAllocation(uint32_t total_bitrate,
- uint32_t framerate) override;
+ VideoBitrateAllocation Allocate(
+ VideoBitrateAllocationParameters parameters) override;
private:
const VideoCodec codec_;
diff --git a/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc b/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
index 4a4ad73..ed0cb5f 100644
--- a/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
+++ b/modules/video_coding/utility/default_video_bitrate_allocator_unittest.cc
@@ -42,7 +42,7 @@
TEST_F(DefaultVideoBitrateAllocatorTest, ZeroIsOff) {
VideoBitrateAllocation allocation =
- allocator_->GetAllocation(0, kMaxFramerate);
+ allocator_->Allocate(VideoBitrateAllocationParameters(0, kMaxFramerate));
EXPECT_EQ(0u, allocation.get_sum_bps());
}
@@ -50,41 +50,45 @@
codec_.active = false;
allocator_.reset(new DefaultVideoBitrateAllocator(codec_));
VideoBitrateAllocation allocation =
- allocator_->GetAllocation(1, kMaxFramerate);
+ allocator_->Allocate(VideoBitrateAllocationParameters(1, kMaxFramerate));
EXPECT_EQ(0u, allocation.get_sum_bps());
}
TEST_F(DefaultVideoBitrateAllocatorTest, CapsToMin) {
VideoBitrateAllocation allocation =
- allocator_->GetAllocation(1, kMaxFramerate);
+ allocator_->Allocate(VideoBitrateAllocationParameters(1, kMaxFramerate));
EXPECT_EQ(kMinBitrateBps, allocation.get_sum_bps());
- allocation = allocator_->GetAllocation(kMinBitrateBps - 1, kMaxFramerate);
+ allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMinBitrateBps - 1, kMaxFramerate));
EXPECT_EQ(kMinBitrateBps, allocation.get_sum_bps());
- allocation = allocator_->GetAllocation(kMinBitrateBps, kMaxFramerate);
+ allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMinBitrateBps, kMaxFramerate));
EXPECT_EQ(kMinBitrateBps, allocation.get_sum_bps());
}
TEST_F(DefaultVideoBitrateAllocatorTest, CapsToMax) {
- VideoBitrateAllocation allocation =
- allocator_->GetAllocation(kMaxBitrateBps, kMaxFramerate);
+ VideoBitrateAllocation allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMaxBitrateBps, kMaxFramerate));
EXPECT_EQ(kMaxBitrateBps, allocation.get_sum_bps());
- allocation = allocator_->GetAllocation(kMaxBitrateBps + 1, kMaxFramerate);
+ allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMaxBitrateBps + 1, kMaxFramerate));
EXPECT_EQ(kMaxBitrateBps, allocation.get_sum_bps());
- allocation = allocator_->GetAllocation(std::numeric_limits<uint32_t>::max(),
- kMaxFramerate);
+ allocation = allocator_->Allocate(VideoBitrateAllocationParameters(
+ std::numeric_limits<uint32_t>::max(), kMaxFramerate));
EXPECT_EQ(kMaxBitrateBps, allocation.get_sum_bps());
}
TEST_F(DefaultVideoBitrateAllocatorTest, GoodInBetween) {
- VideoBitrateAllocation allocation =
- allocator_->GetAllocation(kMinBitrateBps + 1, kMaxFramerate);
+ VideoBitrateAllocation allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMinBitrateBps + 1, kMaxFramerate));
EXPECT_EQ(kMinBitrateBps + 1, allocation.get_sum_bps());
- allocation = allocator_->GetAllocation(kMaxBitrateBps - 1, kMaxFramerate);
+ allocation = allocator_->Allocate(
+ VideoBitrateAllocationParameters(kMaxBitrateBps - 1, kMaxFramerate));
EXPECT_EQ(kMaxBitrateBps - 1, allocation.get_sum_bps());
}
} // namespace webrtc
diff --git a/modules/video_coding/utility/simulcast_rate_allocator.cc b/modules/video_coding/utility/simulcast_rate_allocator.cc
index ced01a7..1124241 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator.cc
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <algorithm>
+#include <cmath>
#include <cstdint>
#include <numeric>
#include <string>
@@ -63,13 +64,13 @@
SimulcastRateAllocator::~SimulcastRateAllocator() = default;
-VideoBitrateAllocation SimulcastRateAllocator::GetAllocation(
- uint32_t total_bitrate_bps,
- uint32_t framerate) {
+VideoBitrateAllocation SimulcastRateAllocator::Allocate(
+ VideoBitrateAllocationParameters parameters) {
VideoBitrateAllocation allocated_bitrates_bps;
- DistributeAllocationToSimulcastLayers(total_bitrate_bps,
+ DistributeAllocationToSimulcastLayers(parameters.total_bitrate.bps(),
&allocated_bitrates_bps);
- DistributeAllocationToTemporalLayers(framerate, &allocated_bitrates_bps);
+ DistributeAllocationToTemporalLayers(std::ceil(parameters.framerate),
+ &allocated_bitrates_bps);
return allocated_bitrates_bps;
}
diff --git a/modules/video_coding/utility/simulcast_rate_allocator.h b/modules/video_coding/utility/simulcast_rate_allocator.h
index 1d865a9..ea9211b 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator.h
+++ b/modules/video_coding/utility/simulcast_rate_allocator.h
@@ -28,8 +28,8 @@
explicit SimulcastRateAllocator(const VideoCodec& codec);
~SimulcastRateAllocator() override;
- VideoBitrateAllocation GetAllocation(uint32_t total_bitrate_bps,
- uint32_t framerate) override;
+ VideoBitrateAllocation Allocate(
+ VideoBitrateAllocationParameters parameters) override;
const VideoCodec& GetCodec() const;
static float GetTemporalRateAllocation(int num_layers, int temporal_id);
diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
index d2918fb..2c2b7c7 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
@@ -132,7 +132,8 @@
}
VideoBitrateAllocation GetAllocation(uint32_t target_bitrate) {
- return allocator_->GetAllocation(target_bitrate * 1000U, kDefaultFrameRate);
+ return allocator_->Allocate(VideoBitrateAllocationParameters(
+ DataRate::kbps(target_bitrate), kDefaultFrameRate));
}
protected:
@@ -563,8 +564,9 @@
SetupConferenceScreenshare(GetParam());
CreateAllocator();
- VideoBitrateAllocation allocation = allocator_->GetAllocation(
- kLegacyScreenshareTargetBitrateKbps * 1000, kFramerateFps);
+ VideoBitrateAllocation allocation =
+ allocator_->Allocate(VideoBitrateAllocationParameters(
+ kLegacyScreenshareTargetBitrateKbps * 1000, kFramerateFps));
// All allocation should go in TL0.
EXPECT_EQ(kLegacyScreenshareTargetBitrateKbps, allocation.get_sum_kbps());
@@ -580,7 +582,8 @@
(kLegacyScreenshareTargetBitrateKbps + kLegacyScreenshareMaxBitrateKbps) /
2;
VideoBitrateAllocation allocation =
- allocator_->GetAllocation(target_bitrate_kbps * 1000, kFramerateFps);
+ allocator_->Allocate(VideoBitrateAllocationParameters(
+ target_bitrate_kbps * 1000, kFramerateFps));
// Fill TL0, then put the rest in TL1.
EXPECT_EQ(target_bitrate_kbps, allocation.get_sum_kbps());
@@ -595,8 +598,9 @@
SetupConferenceScreenshare(false);
CreateAllocator();
- VideoBitrateAllocation allocation = allocator_->GetAllocation(
- kLegacyScreenshareMaxBitrateKbps * 2000, kFramerateFps);
+ VideoBitrateAllocation allocation =
+ allocator_->Allocate(VideoBitrateAllocationParameters(
+ kLegacyScreenshareMaxBitrateKbps * 2000, kFramerateFps));
// Fill both TL0 and TL1, but no more.
EXPECT_EQ(kLegacyScreenshareMaxBitrateKbps, allocation.get_sum_kbps());
@@ -618,7 +622,8 @@
(kLegacyScreenshareTargetBitrateKbps + kLegacyScreenshareMaxBitrateKbps) /
2;
VideoBitrateAllocation allocation =
- allocator_->GetAllocation(target_bitrate_kbps * 1000, kFramerateFps);
+ allocator_->Allocate(VideoBitrateAllocationParameters(
+ target_bitrate_kbps * 1000, kFramerateFps));
EXPECT_EQ(0U, allocation.get_sum_kbps());
}
diff --git a/modules/video_coding/utility/simulcast_test_fixture_impl.cc b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
index 404e6f6..7d94182 100644
--- a/modules/video_coding/utility/simulcast_test_fixture_impl.cc
+++ b/modules/video_coding/utility/simulcast_test_fixture_impl.cc
@@ -302,7 +302,8 @@
void SimulcastTestFixtureImpl::SetRates(uint32_t bitrate_kbps, uint32_t fps) {
encoder_->SetRates(VideoEncoder::RateControlParameters(
- rate_allocator_->GetAllocation(bitrate_kbps * 1000, fps),
+ rate_allocator_->Allocate(
+ VideoBitrateAllocationParameters(bitrate_kbps * 1000, fps)),
static_cast<double>(fps)));
}
diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc
index 25ef3e7..ca1da2c 100644
--- a/modules/video_coding/video_codec_initializer_unittest.cc
+++ b/modules/video_coding/video_codec_initializer_unittest.cc
@@ -151,8 +151,9 @@
streams_.push_back(DefaultStream());
EXPECT_TRUE(InitializeCodec());
- VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
- kDefaultTargetBitrateBps, kDefaultFrameRate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ kDefaultTargetBitrateBps, kDefaultFrameRate));
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
EXPECT_EQ(kDefaultTargetBitrateBps, bitrate_allocation.get_sum_bps());
@@ -165,8 +166,9 @@
streams_.push_back(inactive_stream);
EXPECT_TRUE(InitializeCodec());
- VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
- kDefaultTargetBitrateBps, kDefaultFrameRate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ kDefaultTargetBitrateBps, kDefaultFrameRate));
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
EXPECT_EQ(0U, bitrate_allocation.get_sum_bps());
@@ -179,8 +181,9 @@
EXPECT_EQ(1u, codec_out_.numberOfSimulcastStreams);
EXPECT_EQ(2u, codec_out_.VP8()->numberOfTemporalLayers);
- VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
- kScreenshareCodecTargetBitrateBps, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ kScreenshareCodecTargetBitrateBps, kScreenshareDefaultFramerate));
EXPECT_EQ(kScreenshareCodecTargetBitrateBps,
bitrate_allocation.get_sum_bps());
EXPECT_EQ(kScreenshareTl0BitrateBps, bitrate_allocation.GetBitrate(0, 0));
@@ -198,8 +201,9 @@
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t max_bitrate_bps =
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
- VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
- max_bitrate_bps, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ max_bitrate_bps, kScreenshareDefaultFramerate));
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
bitrate_allocation.GetSpatialLayerSum(0));
@@ -222,8 +226,9 @@
EXPECT_EQ(1u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t target_bitrate =
streams_[0].target_bitrate_bps + streams_[1].target_bitrate_bps;
- VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->GetAllocation(
- target_bitrate, kScreenshareDefaultFramerate);
+ VideoBitrateAllocation bitrate_allocation =
+ bitrate_allocator_->Allocate(VideoBitrateAllocationParameters(
+ target_bitrate, kScreenshareDefaultFramerate));
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].max_bitrate_bps),
@@ -245,8 +250,8 @@
EXPECT_EQ(3u, codec_out_.VP8()->numberOfTemporalLayers);
const uint32_t max_bitrate_bps =
streams_[0].target_bitrate_bps + streams_[1].max_bitrate_bps;
- VideoBitrateAllocation bitrate_allocation =
- bitrate_allocator_->GetAllocation(max_bitrate_bps, kDefaultFrameRate);
+ VideoBitrateAllocation bitrate_allocation = bitrate_allocator_->Allocate(
+ VideoBitrateAllocationParameters(max_bitrate_bps, kDefaultFrameRate));
EXPECT_EQ(max_bitrate_bps, bitrate_allocation.get_sum_bps());
EXPECT_EQ(static_cast<uint32_t>(streams_[0].target_bitrate_bps),
bitrate_allocation.GetSpatialLayerSum(0));