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

Review-Url: https://codereview.webrtc.org/2488833004
Cr-Commit-Position: refs/heads/master@{#15023}
This commit is contained in:
sprang
2016-11-10 06:46:20 -08:00
committed by Commit bot
parent 9d1315a961
commit 647bf43dcb
64 changed files with 1705 additions and 857 deletions

View File

@ -640,8 +640,9 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
FakeEncoder(Clock::GetRealTimeClock()),
time_to_reconfigure_(false, false),
encoder_inits_(0),
last_set_bitrate_(0),
send_stream_(nullptr) {}
last_set_bitrate_kbps_(0),
send_stream_(nullptr),
frame_generator_(nullptr) {}
int32_t InitEncode(const VideoCodec* config,
int32_t number_of_cores,
@ -651,8 +652,9 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
// First time initialization. Frame size is known.
// |expected_bitrate| is affected by bandwidth estimation before the
// first frame arrives to the encoder.
uint32_t expected_bitrate =
last_set_bitrate_ > 0 ? last_set_bitrate_ : kInitialBitrateKbps;
uint32_t expected_bitrate = last_set_bitrate_kbps_ > 0
? last_set_bitrate_kbps_
: kInitialBitrateKbps;
EXPECT_EQ(expected_bitrate, config->startBitrate)
<< "Encoder not initialized at expected bitrate.";
EXPECT_EQ(kDefaultWidth, config->width);
@ -660,9 +662,8 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
} else if (encoder_inits_ == 2) {
EXPECT_EQ(2 * kDefaultWidth, config->width);
EXPECT_EQ(2 * kDefaultHeight, config->height);
EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps);
EXPECT_NEAR(config->startBitrate,
last_set_bitrate_,
EXPECT_GE(last_set_bitrate_kbps_, kReconfigureThresholdKbps);
EXPECT_NEAR(config->startBitrate, last_set_bitrate_kbps_,
kPermittedReconfiguredBitrateDiffKbps)
<< "Encoder reconfigured with bitrate too far away from last set.";
observation_complete_.Set();
@ -670,14 +671,14 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size);
}
int32_t SetRates(uint32_t new_target_bitrate_kbps,
uint32_t framerate) override {
last_set_bitrate_ = new_target_bitrate_kbps;
int32_t SetRateAllocation(const BitrateAllocation& rate_allocation,
uint32_t framerate) override {
last_set_bitrate_kbps_ = rate_allocation.get_sum_kbps();
if (encoder_inits_ == 1 &&
new_target_bitrate_kbps > kReconfigureThresholdKbps) {
rate_allocation.get_sum_kbps() > kReconfigureThresholdKbps) {
time_to_reconfigure_.Set();
}
return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate);
return FakeEncoder::SetRateAllocation(rate_allocation, framerate);
}
Call::Config GetSenderCallConfig() override {
@ -723,7 +724,7 @@ TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
private:
rtc::Event time_to_reconfigure_;
int encoder_inits_;
uint32_t last_set_bitrate_;
uint32_t last_set_bitrate_kbps_;
VideoSendStream* send_stream_;
test::FrameGeneratorCapturer* frame_generator_;
VideoEncoderConfig encoder_config_;