Stop using VideoCodec.targetBitrate for vp8 screenshare config

This is a step toward simplifying the VideoCodec struct and removing the
targetBitrate. The hard-coded values now reside in
SimulcastRateAllocator.

A follow-up will do away with the field altogether.

Bug: webrtc:9504
Change-Id: I74d483682309d363048fbbbd31e0607d7242f504
Reviewed-on: https://webrtc-review.googlesource.com/87424
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23876}
This commit is contained in:
Erik Språng
2018-07-06 16:32:20 +02:00
committed by Commit Bot
parent 2ffafa8244
commit 5e898d612e
10 changed files with 18 additions and 27 deletions

View File

@ -30,7 +30,6 @@ class DefaultVideoBitrateAllocatorTest : public ::testing::Test {
codec_.codecType = kVideoCodecVP8;
codec_.minBitrate = kMinBitrateBps / 1000;
codec_.maxBitrate = kMaxBitrateBps / 1000;
codec_.targetBitrate = (kMinBitrateBps + kMaxBitrateBps) / 2000;
codec_.maxFramerate = kMaxFramerate;
allocator_.reset(new DefaultVideoBitrateAllocator(codec_));
}

View File

@ -34,6 +34,9 @@ static const float
static const float kShort3TlRateAllocation[kMaxTemporalStreams] = {
0.6f, 0.8f, 1.0f, 1.0f // 3 layers {60%, 20%, 20%}
};
const uint32_t kLegacyScreenshareTl0BitrateKbps = 200;
const uint32_t kLegacyScreenshareTl1BitrateKbps = 1000;
} // namespace
float SimulcastRateAllocator::GetTemporalRateAllocation(int num_layers,
@ -164,7 +167,6 @@ void SimulcastRateAllocator::DistributeAllocationToTemporalLayers(
// with legacy mode for simulcast stream 0.
const bool conference_screenshare_mode =
codec_.mode == VideoCodecMode::kScreensharing &&
codec_.targetBitrate > 0 &&
((num_spatial_streams == 1 && num_temporal_streams == 2) || // Legacy.
(num_spatial_streams > 1 && simulcast_id == 0)); // Simulcast.
if (conference_screenshare_mode) {
@ -173,9 +175,10 @@ void SimulcastRateAllocator::DistributeAllocationToTemporalLayers(
// to allow for a different max bitrate, so if the codec can't meet
// the target we still allow it to overshoot up to the max before dropping
// frames. This hack should be improved.
int tl0_bitrate = std::min(codec_.targetBitrate, target_bitrate_kbps);
max_bitrate_kbps = std::min(codec_.maxBitrate, target_bitrate_kbps);
target_bitrate_kbps = tl0_bitrate;
max_bitrate_kbps =
std::min(kLegacyScreenshareTl1BitrateKbps, target_bitrate_kbps);
target_bitrate_kbps =
std::min(kLegacyScreenshareTl0BitrateKbps, target_bitrate_kbps);
} else if (num_spatial_streams == 1) {
max_bitrate_kbps = codec_.maxBitrate;
} else {

View File

@ -24,10 +24,11 @@ namespace webrtc {
namespace {
using ::testing::_;
constexpr uint32_t kMinBitrateKbps = 50;
constexpr uint32_t kTargetBitrateKbps = 100;
constexpr uint32_t kMaxBitrateKbps = 1000;
constexpr uint32_t kFramerateFps = 5;
constexpr uint32_t kMinBitrateKbps = 50;
// These correspond to kLegacyScreenshareTl(0|1)BitrateKbps in cc.
constexpr uint32_t kTargetBitrateKbps = 200;
constexpr uint32_t kMaxBitrateKbps = 1000;
class MockTemporalLayers : public TemporalLayers {
public:
@ -52,7 +53,6 @@ class SimulcastRateAllocatorTest : public ::testing::TestWithParam<bool> {
memset(&codec_, 0, sizeof(VideoCodec));
codec_.codecType = kVideoCodecVP8;
codec_.minBitrate = kMinBitrateKbps;
codec_.targetBitrate = kTargetBitrateKbps;
codec_.maxBitrate = kMaxBitrateKbps;
codec_.active = true;
CreateAllocator();
@ -481,7 +481,6 @@ class ScreenshareRateAllocationTest : public SimulcastRateAllocatorTest {
codec_.simulcastStream[0].active = active;
} else {
codec_.numberOfSimulcastStreams = 0;
codec_.targetBitrate = kTargetBitrateKbps;
codec_.VP8()->numberOfTemporalLayers = 2;
codec_.active = active;
}