From 486b0401c5cc0c2f83b77bcf555cf309342b4e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Wed, 2 Jun 2021 11:07:50 +0200 Subject: [PATCH] Make VP8 DefaultTemporalLayers always report TL count even with no rate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If at creation of a VP8 encoder there is not enough bitrate to enable a given spatial layer - the configuration won't be updated to indicate the correct temporal layer count. This means GetEncoderInfo() will indicate lack of temporal layer support, which triggers issues with rate allocation. This CL fixes that by always setting an initial bitrate of 0bps. Bug: webrtc:12788 Change-Id: I10974e85446b58e597d2ca415eaf2550306ce986 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/220929 Commit-Queue: Erik Språng Reviewed-by: Per Kjellander Cr-Commit-Position: refs/heads/master@{#34198} --- .../codecs/vp8/default_temporal_layers.cc | 3 ++- .../vp8/default_temporal_layers_unittest.cc | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.cc b/modules/video_coding/codecs/vp8/default_temporal_layers.cc index e2d9b1ebd2..c84d9acb1c 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers.cc +++ b/modules/video_coding/codecs/vp8/default_temporal_layers.cc @@ -265,7 +265,8 @@ DefaultTemporalLayers::DefaultTemporalLayers(int number_of_temporal_layers) temporal_ids_(GetTemporalIds(num_layers_)), temporal_pattern_(GetDependencyInfo(num_layers_)), is_static_buffer_(DetermineStaticBuffers(temporal_pattern_)), - pattern_idx_(kUninitializedPatternIndex) { + pattern_idx_(kUninitializedPatternIndex), + new_bitrates_bps_(std::vector(num_layers_, 0u)) { RTC_CHECK_GE(kMaxTemporalStreams, number_of_temporal_layers); RTC_CHECK_GE(number_of_temporal_layers, 0); RTC_CHECK_LE(number_of_temporal_layers, 4); diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc b/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc index 64ad40ab76..a18ac40e7d 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc @@ -687,6 +687,25 @@ TEST_F(TemporalLayersTest, KeyFrame) { } } +TEST_F(TemporalLayersTest, SetsTlCountOnFirstConfigUpdate) { + // Create an instance and fetch config update without setting any rate. + constexpr int kNumLayers = 2; + DefaultTemporalLayers tl(kNumLayers); + Vp8EncoderConfig config = tl.UpdateConfiguration(0); + + // Config should indicate correct number of temporal layers, but zero bitrate. + ASSERT_TRUE(config.temporal_layer_config.has_value()); + EXPECT_EQ(config.temporal_layer_config->ts_number_layers, + uint32_t{kNumLayers}); + std::array + kZeroRate = {}; + EXPECT_EQ(config.temporal_layer_config->ts_target_bitrate, kZeroRate); + + // On second call, no new update. + config = tl.UpdateConfiguration(0); + EXPECT_FALSE(config.temporal_layer_config.has_value()); +} + class TemporalLayersReferenceTest : public TemporalLayersTest, public ::testing::WithParamInterface { public: