Replace DataSize and DataRate factories with newer versions
This is search and replace change: find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataSize::Bytes<\(.*\)>()/DataSize::Bytes(\1)/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataSize::bytes/DataSize::Bytes/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::BitsPerSec<\(.*\)>()/DataRate::BitsPerSec(\1)/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::BytesPerSec<\(.*\)>()/DataRate::BytesPerSec(\1)/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::KilobitsPerSec<\(.*\)>()/DataRate::KilobitsPerSec(\1)/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::bps/DataRate::BitsPerSec/g" find . -type f \( -name "*.h" -o -name "*.cc" \) | xargs sed -i -e "s/DataRate::kbps/DataRate::KilobitsPerSec/g" git cl format Bug: webrtc:9709 Change-Id: I65aaca69474ba038c1fe2dd8dc30d3f8e7b94c29 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168647 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30545}
This commit is contained in:
committed by
Commit Bot
parent
701bd172d8
commit
cad3e0e2fa
@ -87,7 +87,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
|
||||
DataRate left_in_stable_allocation = stable_bitrate;
|
||||
|
||||
if (codec_.maxBitrate) {
|
||||
DataRate max_rate = DataRate::kbps(codec_.maxBitrate);
|
||||
DataRate max_rate = DataRate::KilobitsPerSec(codec_.maxBitrate);
|
||||
left_in_total_allocation = std::min(left_in_total_allocation, max_rate);
|
||||
left_in_stable_allocation = std::min(left_in_stable_allocation, max_rate);
|
||||
}
|
||||
@ -97,7 +97,8 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
|
||||
if (codec_.active) {
|
||||
allocated_bitrates->SetBitrate(
|
||||
0, 0,
|
||||
std::max(DataRate::kbps(codec_.minBitrate), left_in_total_allocation)
|
||||
std::max(DataRate::KilobitsPerSec(codec_.minBitrate),
|
||||
left_in_total_allocation)
|
||||
.bps());
|
||||
}
|
||||
return;
|
||||
@ -129,7 +130,7 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
|
||||
// Always allocate enough bitrate for the minimum bitrate of the first
|
||||
// active layer. Suspending below min bitrate is controlled outside the
|
||||
// codec implementation and is not overridden by this.
|
||||
DataRate min_rate = DataRate::kbps(
|
||||
DataRate min_rate = DataRate::KilobitsPerSec(
|
||||
codec_.simulcastStream[layer_index[active_layer]].minBitrate);
|
||||
left_in_total_allocation = std::max(left_in_total_allocation, min_rate);
|
||||
left_in_stable_allocation = std::max(left_in_stable_allocation, min_rate);
|
||||
@ -157,8 +158,8 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
|
||||
}
|
||||
// If we can't allocate to the current layer we can't allocate to higher
|
||||
// layers because they require a higher minimum bitrate.
|
||||
DataRate min_bitrate = DataRate::kbps(stream.minBitrate);
|
||||
DataRate target_bitrate = DataRate::kbps(stream.targetBitrate);
|
||||
DataRate min_bitrate = DataRate::KilobitsPerSec(stream.minBitrate);
|
||||
DataRate target_bitrate = DataRate::KilobitsPerSec(stream.targetBitrate);
|
||||
double hysteresis_factor =
|
||||
codec_.mode == VideoCodecMode::kRealtimeVideo
|
||||
? stable_rate_settings_.GetVideoHysteresisFactor()
|
||||
@ -193,11 +194,11 @@ void SimulcastRateAllocator::DistributeAllocationToSimulcastLayers(
|
||||
// better idea of possible performance implications.
|
||||
if (left_in_total_allocation > DataRate::Zero()) {
|
||||
const SimulcastStream& stream = codec_.simulcastStream[top_active_layer];
|
||||
DataRate initial_layer_rate =
|
||||
DataRate::bps(allocated_bitrates->GetSpatialLayerSum(top_active_layer));
|
||||
DataRate additional_allocation =
|
||||
std::min(left_in_total_allocation,
|
||||
DataRate::kbps(stream.maxBitrate) - initial_layer_rate);
|
||||
DataRate initial_layer_rate = DataRate::BitsPerSec(
|
||||
allocated_bitrates->GetSpatialLayerSum(top_active_layer));
|
||||
DataRate additional_allocation = std::min(
|
||||
left_in_total_allocation,
|
||||
DataRate::KilobitsPerSec(stream.maxBitrate) - initial_layer_rate);
|
||||
allocated_bitrates->SetBitrate(
|
||||
top_active_layer, 0,
|
||||
(initial_layer_rate + additional_allocation).bps());
|
||||
|
||||
@ -133,7 +133,7 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
|
||||
|
||||
VideoBitrateAllocation GetAllocation(uint32_t target_bitrate) {
|
||||
return allocator_->Allocate(VideoBitrateAllocationParameters(
|
||||
DataRate::kbps(target_bitrate), kDefaultFrameRate));
|
||||
DataRate::KilobitsPerSec(target_bitrate), kDefaultFrameRate));
|
||||
}
|
||||
|
||||
VideoBitrateAllocation GetAllocation(DataRate target_rate,
|
||||
@ -143,15 +143,18 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
|
||||
}
|
||||
|
||||
DataRate MinRate(size_t layer_index) const {
|
||||
return DataRate::kbps(codec_.simulcastStream[layer_index].minBitrate);
|
||||
return DataRate::KilobitsPerSec(
|
||||
codec_.simulcastStream[layer_index].minBitrate);
|
||||
}
|
||||
|
||||
DataRate TargetRate(size_t layer_index) const {
|
||||
return DataRate::kbps(codec_.simulcastStream[layer_index].targetBitrate);
|
||||
return DataRate::KilobitsPerSec(
|
||||
codec_.simulcastStream[layer_index].targetBitrate);
|
||||
}
|
||||
|
||||
DataRate MaxRate(size_t layer_index) const {
|
||||
return DataRate::kbps(codec_.simulcastStream[layer_index].maxBitrate);
|
||||
return DataRate::KilobitsPerSec(
|
||||
codec_.simulcastStream[layer_index].maxBitrate);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -590,8 +593,8 @@ TEST_F(SimulcastRateAllocatorTest, StableRate) {
|
||||
// Let stable rate go to a bitrate below what is needed for two streams.
|
||||
uint32_t expected[] = {MaxRate(0).kbps<uint32_t>(), 0};
|
||||
ExpectEqual(expected,
|
||||
GetAllocation(volatile_rate,
|
||||
TargetRate(0) + MinRate(1) - DataRate::bps(1)));
|
||||
GetAllocation(volatile_rate, TargetRate(0) + MinRate(1) -
|
||||
DataRate::BitsPerSec(1)));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user