Handle zero number of spatial layers at calculation of VP9 SVC padding.

Bug: chromium:923330
Change-Id: I66e3b17e5a22b7de9d9b83d5dda486ec5b4364fc
Reviewed-on: https://webrtc-review.googlesource.com/c/119600
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26388}
This commit is contained in:
Sergey Silkin 2019-01-24 11:32:55 +01:00 committed by Commit Bot
parent f8e7ccb967
commit a67a9d9256
2 changed files with 12 additions and 0 deletions

View File

@ -227,6 +227,9 @@ uint32_t SvcRateAllocator::GetMaxBitrateBps(const VideoCodec& codec) {
uint32_t SvcRateAllocator::GetPaddingBitrateBps(const VideoCodec& codec) {
const size_t num_spatial_layers = GetNumActiveSpatialLayers(codec);
if (num_spatial_layers == 0) {
return 0; // All layers are deactivated.
}
if (codec.mode == VideoCodecMode::kRealtimeVideo) {
float scale_factor = 0.0;

View File

@ -188,6 +188,15 @@ TEST(SvcRateAllocatorTest, DeativateLayers) {
}
}
TEST(SvcRateAllocatorTest, NoPaddingIfAllLayersAreDeactivated) {
VideoCodec codec = Configure(1280, 720, 3, 1, false);
EXPECT_EQ(codec.VP9()->numberOfSpatialLayers, 3U);
// Deactivation of base layer deactivates all layers.
codec.spatialLayers[0].active = false;
uint32_t padding_bps = SvcRateAllocator::GetPaddingBitrateBps(codec);
EXPECT_EQ(padding_bps, 0U);
}
class SvcRateAllocatorTestParametrizedContentType
: public testing::Test,
public testing::WithParamInterface<bool> {