Fix target bitrate handling for a single layer VP9 screenshare

For a single layer vp9, the target bitrate was not set correctly. This
may cause a problem for screenshare case, since target bitrate is
respected in that case. If it were less than a min bitrate, the only
spatial layer was permanently disabled.

Bug: webrtc:10257
Change-Id: I0980349adfc2970f810acc51a3e2a31ecbb2bbd2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125681
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26970}
This commit is contained in:
Ilya Nikolaevskiy
2019-03-05 10:08:35 +01:00
committed by Commit Bot
parent 977b3351b9
commit 9ef5e056f9
3 changed files with 14 additions and 0 deletions

View File

@ -203,6 +203,7 @@ VideoBitrateAllocation SvcRateAllocator::GetAllocationScreenSharing(
codec_.spatialLayers[sl_idx].minBitrate * 1000;
const size_t target_bitrate_bps =
codec_.spatialLayers[sl_idx].targetBitrate * 1000;
RTC_DCHECK_LE(min_bitrate_bps, target_bitrate_bps);
const size_t bitrate_bps = std::min(left_bitrate_bps, target_bitrate_bps);
if (bitrate_bps >= min_bitrate_bps) {

View File

@ -190,6 +190,7 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
if (no_spatial_layering) {
// Use codec's bitrate limits.
spatial_layers.back().minBitrate = video_codec.minBitrate;
spatial_layers.back().targetBitrate = video_codec.maxBitrate;
spatial_layers.back().maxBitrate = video_codec.maxBitrate;
}

View File

@ -296,6 +296,18 @@ TEST_F(VideoCodecInitializerTest,
kDefaultMaxBitrateBps / 1000);
}
TEST_F(VideoCodecInitializerTest,
Vp9SingleSpatialLayerTargetBitrateIsEqualToCodecMaxBitrate) {
SetUpFor(VideoCodecType::kVideoCodecVP9, 1, 1, true);
VideoStream stream = DefaultStream();
stream.num_temporal_layers = 1;
streams_.push_back(stream);
EXPECT_TRUE(InitializeCodec());
EXPECT_EQ(codec_out_.spatialLayers[0].targetBitrate,
kDefaultMaxBitrateBps / 1000);
}
TEST_F(VideoCodecInitializerTest,
Vp9KeepBitrateLimitsIfNumberOfSpatialLayersIsReducedToOne) {
// Request 3 spatial layers for 320x180 input. Actual number of layers will be