Revert of Issue 2434073003: Extract bitrate allocation ... (patchset #4 id:60001 of https://codereview.webrtc.org/2488833004/ )
Reason for revert: Seems to be causing flakiness in perf test: FullStackTest.ScreenshareSlidesVP8_2TL_LossyNet Original issue's description: > Reland of Issue 2434073003: Extract bitrate allocation ... > > This is a reland of https://codereview.webrtc.org/2434073003/ including > some fixes for failing test cases. > > Original description: > > Extract bitrate allocation of spatial/temporal layers out of codec impl. > > This CL makes a number of intervowen changes: > > * Add BitrateAllocation struct, that contains a codec independent view > of how the target bitrate is distributed over spatial and temporal > layers. > > * Adds the BitrateAllocator interface, which takes a bitrate and frame > rate and produces a BitrateAllocation. > > * A default (non layered) implementation is added, and > SimulcastRateAllocator is extended to fully handle VP8 allocation. > This includes capturing TemporalLayer instances created by the > encoder. > > * ViEEncoder now owns both the bitrate allocator and the temporal layer > factories for VP8. This allows allocation to happen fully outside of > the encoder implementation. > > This refactoring will make it possible for ViEEncoder to signal the > full picture of target bitrates to the RTCP module. > > BUG=webrtc:6301 > > Committed: https://crrev.com/647bf43dcb2fd16fccf276bd94dc4400728bb405 > Cr-Commit-Position: refs/heads/master@{#15023} TBR=mflodman@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:6301 Review-Url: https://codereview.webrtc.org/2491393002 Cr-Commit-Position: refs/heads/master@{#15026}
This commit is contained in:
@ -19,8 +19,6 @@
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
#include "webrtc/modules/video_coding/test/test_util.h"
|
||||
#include "webrtc/modules/video_coding/video_coding_impl.h"
|
||||
#include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h"
|
||||
#include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/frame_generator.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
@ -198,10 +196,6 @@ class TestVideoSender : public ::testing::Test {
|
||||
};
|
||||
|
||||
class TestVideoSenderWithMockEncoder : public TestVideoSender {
|
||||
public:
|
||||
TestVideoSenderWithMockEncoder() {}
|
||||
~TestVideoSenderWithMockEncoder() override {}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
TestVideoSender::SetUp();
|
||||
@ -218,7 +212,6 @@ class TestVideoSenderWithMockEncoder : public TestVideoSender {
|
||||
generator_.reset(
|
||||
new EmptyFrameGenerator(settings_.width, settings_.height));
|
||||
EXPECT_EQ(0, sender_->RegisterSendCodec(&settings_, 1, 1200));
|
||||
rate_allocator_.reset(new DefaultVideoBitrateAllocator(settings_));
|
||||
}
|
||||
|
||||
void TearDown() override { sender_.reset(); }
|
||||
@ -268,7 +261,6 @@ class TestVideoSenderWithMockEncoder : public TestVideoSender {
|
||||
|
||||
VideoCodec settings_;
|
||||
NiceMock<MockVideoEncoder> encoder_;
|
||||
std::unique_ptr<DefaultVideoBitrateAllocator> rate_allocator_;
|
||||
};
|
||||
|
||||
TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequests) {
|
||||
@ -299,19 +291,14 @@ TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequests) {
|
||||
}
|
||||
|
||||
TEST_F(TestVideoSenderWithMockEncoder, TestSetRate) {
|
||||
const uint32_t new_bitrate_kbps = settings_.startBitrate + 300;
|
||||
BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
|
||||
new_bitrate_kbps * 1000, settings_.maxFramerate);
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200,
|
||||
rate_allocator_.get());
|
||||
const uint32_t new_bitrate = settings_.startBitrate + 300;
|
||||
EXPECT_CALL(encoder_, SetRates(new_bitrate, _)).Times(1).WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(new_bitrate * 1000, 0, 200);
|
||||
AddFrame();
|
||||
|
||||
// Expect no call to encoder_.SetRates if the new bitrate is zero.
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0);
|
||||
sender_->SetChannelParameters(0, 0, 200, rate_allocator_.get());
|
||||
EXPECT_CALL(encoder_, SetRates(new_bitrate, _)).Times(0);
|
||||
sender_->SetChannelParameters(0, 0, 200);
|
||||
AddFrame();
|
||||
}
|
||||
|
||||
@ -342,19 +329,13 @@ TEST_F(TestVideoSenderWithMockEncoder, TestEncoderParametersForInternalSource) {
|
||||
EXPECT_EQ(0, sender_->RegisterSendCodec(&settings_, 1, 1200));
|
||||
// Update encoder bitrate parameters. We expect that to immediately call
|
||||
// SetRates on the encoder without waiting for AddFrame processing.
|
||||
const uint32_t new_bitrate_kbps = settings_.startBitrate + 300;
|
||||
BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation(
|
||||
new_bitrate_kbps * 1000, settings_.maxFramerate);
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200,
|
||||
rate_allocator_.get());
|
||||
const uint32_t new_bitrate = settings_.startBitrate + 300;
|
||||
EXPECT_CALL(encoder_, SetRates(new_bitrate, _)).Times(1).WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(new_bitrate * 1000, 0, 200);
|
||||
}
|
||||
|
||||
TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) {
|
||||
sender_->SetChannelParameters(settings_.startBitrate * 1000, 0, 200,
|
||||
rate_allocator_.get());
|
||||
sender_->SetChannelParameters(settings_.startBitrate * 1000, 0, 200);
|
||||
const int64_t kRateStatsWindowMs = 2000;
|
||||
const uint32_t kInputFps = 20;
|
||||
int64_t start_time = clock_.TimeInMilliseconds();
|
||||
@ -362,9 +343,7 @@ TEST_F(TestVideoSenderWithMockEncoder, EncoderFramerateUpdatedViaProcess) {
|
||||
AddFrame();
|
||||
clock_.AdvanceTimeMilliseconds(1000 / kInputFps);
|
||||
}
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(_, kInputFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0));
|
||||
sender_->Process();
|
||||
AddFrame();
|
||||
}
|
||||
@ -382,29 +361,23 @@ TEST_F(TestVideoSenderWithMockEncoder,
|
||||
EXPECT_CALL(encoder_, SetChannelParameters(kLossRate, kRtt))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(settings_.startBitrate * 1000, kLossRate, kRtt,
|
||||
rate_allocator_.get());
|
||||
sender_->SetChannelParameters(settings_.startBitrate * 1000, kLossRate, kRtt);
|
||||
while (clock_.TimeInMilliseconds() < start_time + kRateStatsWindowMs) {
|
||||
AddFrame();
|
||||
clock_.AdvanceTimeMilliseconds(1000 / kInputFps);
|
||||
}
|
||||
// After process, input framerate should be updated but not ChannelParameters
|
||||
// as they are the same as before.
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(_, kInputFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
EXPECT_CALL(encoder_, SetRates(_, kInputFps)).Times(1).WillOnce(Return(0));
|
||||
sender_->Process();
|
||||
AddFrame();
|
||||
// Call to SetChannelParameters with changed bitrate should call encoder
|
||||
// SetRates but not encoder SetChannelParameters (that are unchanged).
|
||||
uint32_t new_bitrate_bps = 2 * settings_.startBitrate * 1000;
|
||||
BitrateAllocation new_rate_allocation =
|
||||
rate_allocator_->GetAllocation(new_bitrate_bps, kInputFps);
|
||||
EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, kInputFps))
|
||||
EXPECT_CALL(encoder_, SetRates(2 * settings_.startBitrate, kInputFps))
|
||||
.Times(1)
|
||||
.WillOnce(Return(0));
|
||||
sender_->SetChannelParameters(new_bitrate_bps, kLossRate, kRtt,
|
||||
rate_allocator_.get());
|
||||
sender_->SetChannelParameters(2 * settings_.startBitrate * 1000, kLossRate,
|
||||
kRtt);
|
||||
AddFrame();
|
||||
}
|
||||
|
||||
@ -427,12 +400,6 @@ class TestVideoSenderWithVp8 : public TestVideoSender {
|
||||
codec_.minBitrate = 10;
|
||||
codec_.startBitrate = codec_bitrate_kbps_;
|
||||
codec_.maxBitrate = codec_bitrate_kbps_;
|
||||
|
||||
TemporalLayersFactory* tl_factory = new TemporalLayersFactory();
|
||||
rate_allocator_.reset(new SimulcastRateAllocator(
|
||||
codec_, std::unique_ptr<TemporalLayersFactory>(tl_factory)));
|
||||
codec_.VP8()->tl_factory = tl_factory;
|
||||
|
||||
encoder_.reset(VP8Encoder::Create());
|
||||
sender_->RegisterExternalEncoder(encoder_.get(), codec_.plType, false);
|
||||
EXPECT_EQ(0, sender_->RegisterSendCodec(&codec_, 1, 1200));
|
||||
@ -458,9 +425,8 @@ class TestVideoSenderWithVp8 : public TestVideoSender {
|
||||
// Note: SetChannelParameters fails if less than 2 frames are in the
|
||||
// buffer since it will fail to calculate the framerate.
|
||||
if (i != 0) {
|
||||
EXPECT_EQ(VCM_OK,
|
||||
sender_->SetChannelParameters(available_bitrate_kbps_ * 1000,
|
||||
0, 200, rate_allocator_.get()));
|
||||
EXPECT_EQ(VCM_OK, sender_->SetChannelParameters(
|
||||
available_bitrate_kbps_ * 1000, 0, 200));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,7 +447,6 @@ class TestVideoSenderWithVp8 : public TestVideoSender {
|
||||
VideoCodec codec_;
|
||||
int codec_bitrate_kbps_;
|
||||
int available_bitrate_kbps_;
|
||||
std::unique_ptr<SimulcastRateAllocator> rate_allocator_;
|
||||
};
|
||||
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
@ -511,15 +476,11 @@ TEST_F(TestVideoSenderWithVp8, MAYBE_FixedTemporalLayersStrategy) {
|
||||
#endif
|
||||
TEST_F(TestVideoSenderWithVp8, MAYBE_RealTimeTemporalLayersStrategy) {
|
||||
VideoCodec codec = MakeVp8VideoCodec(352, 288, 3);
|
||||
RealTimeTemporalLayersFactory realtime_tl_factory;
|
||||
codec.VP8()->tl_factory = &realtime_tl_factory;
|
||||
codec.minBitrate = 10;
|
||||
codec.startBitrate = codec_bitrate_kbps_;
|
||||
codec.maxBitrate = codec_bitrate_kbps_;
|
||||
|
||||
TemporalLayersFactory* tl_factory = new RealTimeTemporalLayersFactory();
|
||||
rate_allocator_.reset(new SimulcastRateAllocator(
|
||||
codec, std::unique_ptr<TemporalLayersFactory>(tl_factory)));
|
||||
codec.VP8()->tl_factory = tl_factory;
|
||||
|
||||
EXPECT_EQ(0, sender_->RegisterSendCodec(&codec, 1, 1200));
|
||||
|
||||
const int low_b = codec_bitrate_kbps_ * 0.4;
|
||||
|
||||
Reference in New Issue
Block a user