From 979c4426a476b6ff390bcae345ffad4c8793d24c Mon Sep 17 00:00:00 2001 From: Elad Alon Date: Wed, 17 Apr 2019 12:53:08 +0200 Subject: [PATCH] Rename "UpdateLayerConfig" to "NextFrameConfig" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename "UpdateLayerConfig" to the more appropriate "NextFrameConfig". Also update some comments in vp8_frame_buffer_controller.h. Bug: None Change-Id: Iba8227f84e33e5ebd28d2eeb10fe03e776036603 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133202 Commit-Queue: Elad Alon Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#27660} --- .../vp8_frame_buffer_controller.h | 33 +++---- api/video_codecs/vp8_temporal_layers.cc | 6 +- api/video_codecs/vp8_temporal_layers.h | 4 +- .../codecs/vp8/default_temporal_layers.cc | 4 +- .../codecs/vp8/default_temporal_layers.h | 6 +- .../vp8/default_temporal_layers_unittest.cc | 88 +++++++++---------- .../codecs/vp8/libvpx_vp8_encoder.cc | 2 +- .../codecs/vp8/screenshare_layers.cc | 4 +- .../codecs/vp8/screenshare_layers.h | 4 +- .../codecs/vp8/screenshare_layers_unittest.cc | 28 +++--- .../simulcast_rate_allocator_unittest.cc | 2 +- test/fake_vp8_encoder.cc | 4 +- 12 files changed, 94 insertions(+), 91 deletions(-) diff --git a/api/video_codecs/vp8_frame_buffer_controller.h b/api/video_codecs/vp8_frame_buffer_controller.h index f3d2b1a6ce..e41df8e724 100644 --- a/api/video_codecs/vp8_frame_buffer_controller.h +++ b/api/video_codecs/vp8_frame_buffer_controller.h @@ -25,7 +25,7 @@ namespace webrtc { // * Vp8FrameBufferController is not thread safe, synchronization is the // caller's responsibility. // * The encoder is assumed to encode all frames in order, and callbacks to -// PopulateCodecSpecific() / FrameEncoded() must happen in the same order. +// PopulateCodecSpecific() / OnEncodeDone() must happen in the same order. // // This means that in the case of pipelining encoders, it is OK to have a chain // of calls such as this: @@ -38,11 +38,15 @@ namespace webrtc { // - OnEncodeDone(timestampB, 0, ...) // - OnEncodeDone(timestampC, 1234, ...) // Note that UpdateLayerConfig() for a new frame can happen before -// FrameEncoded() for a previous one, but calls themselves must be both +// OnEncodeDone() for a previous one, but calls themselves must be both // synchronized (e.g. run on a task queue) and in order (per type). +// +// TODO(eladalon): Revise comment (referring to PopulateCodecSpecific in this +// context is not very meaningful). struct CodecSpecificInfo; +// TODO(eladalon): This configuration is temporal-layers specific; refactor. struct Vp8EncoderConfig { static constexpr size_t kMaxPeriodicity = 16; static constexpr size_t kMaxLayers = 5; @@ -90,37 +94,36 @@ class Vp8FrameBufferController { // OnEncodeDone() again when the frame has actually been encoded. virtual bool SupportsEncoderFrameDropping(size_t stream_index) const = 0; - // New target bitrate, per temporal layer. + // New target bitrate for a stream (each entry in + // |bitrates_bps| is for another temporal layer). virtual void OnRatesUpdated(size_t stream_index, const std::vector& bitrates_bps, int framerate_fps) = 0; // Called by the encoder before encoding a frame. |cfg| contains the current - // configuration. If the TemporalLayers instance wishes any part of that - // to be changed before the encode step, |cfg| should be changed and then - // return true. If false is returned, the encoder will proceed without - // updating the configuration. + // configuration. If the encoder wishes any part of that to be changed before + // the encode step, |cfg| should be changed and then return true. If false is + // returned, the encoder will proceed without updating the configuration. virtual bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) = 0; - // Returns the recommended VP8 encode flags needed, and moves the temporal - // pattern to the next frame. + // Returns the recommended VP8 encode flags needed. // The timestamp may be used as both a time and a unique identifier, and so // the caller must make sure no two frames use the same timestamp. // The timestamp uses a 90kHz RTP clock. // After calling this method, first call the actual encoder with the provided // frame configuration, and then OnEncodeDone() below. - virtual Vp8FrameConfig UpdateLayerConfig(size_t stream_index, - uint32_t rtp_timestamp) = 0; + virtual Vp8FrameConfig NextFrameConfig(size_t stream_index, + uint32_t rtp_timestamp) = 0; // Called after the encode step is done. |rtp_timestamp| must match the // parameter use in the UpdateLayerConfig() call. // |is_keyframe| must be true iff the encoder decided to encode this frame as // a keyframe. - // If |info| is not null, the TemporalLayers instance may update |info| with - // codec specific data such as temporal id. - // |qp| should indicate the frame-level QP this frame was encoded at. If the - // encoder does not support extracting this, |qp| should be set to 0. + // If |info| is not null, the encoder may update |info| with codec specific + // data such as temporal id. |qp| should indicate the frame-level QP this + // frame was encoded at. If the encoder does not support extracting this, |qp| + // should be set to 0. virtual void OnEncodeDone(size_t stream_index, uint32_t rtp_timestamp, size_t size_bytes, diff --git a/api/video_codecs/vp8_temporal_layers.cc b/api/video_codecs/vp8_temporal_layers.cc index 7a9cf37b6c..7f7d8ad3df 100644 --- a/api/video_codecs/vp8_temporal_layers.cc +++ b/api/video_codecs/vp8_temporal_layers.cc @@ -53,10 +53,10 @@ bool Vp8TemporalLayers::UpdateConfiguration(size_t stream_index, return controllers_[stream_index]->UpdateConfiguration(0, cfg); } -Vp8FrameConfig Vp8TemporalLayers::UpdateLayerConfig(size_t stream_index, - uint32_t rtp_timestamp) { +Vp8FrameConfig Vp8TemporalLayers::NextFrameConfig(size_t stream_index, + uint32_t rtp_timestamp) { RTC_DCHECK_LT(stream_index, controllers_.size()); - return controllers_[stream_index]->UpdateLayerConfig(0, rtp_timestamp); + return controllers_[stream_index]->NextFrameConfig(0, rtp_timestamp); } void Vp8TemporalLayers::OnEncodeDone(size_t stream_index, diff --git a/api/video_codecs/vp8_temporal_layers.h b/api/video_codecs/vp8_temporal_layers.h index f02d288f1c..3864705c98 100644 --- a/api/video_codecs/vp8_temporal_layers.h +++ b/api/video_codecs/vp8_temporal_layers.h @@ -45,8 +45,8 @@ class Vp8TemporalLayers final : public Vp8FrameBufferController { bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) override; - Vp8FrameConfig UpdateLayerConfig(size_t stream_index, - uint32_t rtp_timestamp) override; + Vp8FrameConfig NextFrameConfig(size_t stream_index, + uint32_t rtp_timestamp) override; void OnEncodeDone(size_t stream_index, uint32_t rtp_timestamp, diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.cc b/modules/video_coding/codecs/vp8/default_temporal_layers.cc index 31298fe7af..e315dc4788 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers.cc +++ b/modules/video_coding/codecs/vp8/default_temporal_layers.cc @@ -330,8 +330,8 @@ bool DefaultTemporalLayers::IsSyncFrame(const Vp8FrameConfig& config) const { return true; } -Vp8FrameConfig DefaultTemporalLayers::UpdateLayerConfig(size_t stream_index, - uint32_t timestamp) { +Vp8FrameConfig DefaultTemporalLayers::NextFrameConfig(size_t stream_index, + uint32_t timestamp) { RTC_DCHECK_LT(stream_index, StreamCount()); RTC_DCHECK_GT(num_layers_, 0); RTC_DCHECK_GT(temporal_pattern_.size(), 0); diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.h b/modules/video_coding/codecs/vp8/default_temporal_layers.h index 7a47650921..34ed711c87 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers.h +++ b/modules/video_coding/codecs/vp8/default_temporal_layers.h @@ -40,8 +40,8 @@ class DefaultTemporalLayers final : public Vp8FrameBufferController { // Returns the recommended VP8 encode flags needed. May refresh the decoder // and/or update the reference buffers. - Vp8FrameConfig UpdateLayerConfig(size_t stream_index, - uint32_t timestamp) override; + Vp8FrameConfig NextFrameConfig(size_t stream_index, + uint32_t timestamp) override; // New target bitrate, per temporal layer. void OnRatesUpdated(size_t stream_index, @@ -108,7 +108,7 @@ class DefaultTemporalLayers final : public Vp8FrameBufferController { // Bitmask of Vp8BufferReference flags, indicating which buffers this frame // updates. uint8_t updated_buffer_mask = 0; - // The frame config return by UpdateLayerConfig() for this frame. + // The frame config returned by NextFrameConfig() for this frame. DependencyInfo dependency_info; }; // Map from rtp timestamp to pending frame status. Reset on pattern loop. 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 54e71c48f4..8f01e597f6 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/default_temporal_layers_unittest.cc @@ -142,7 +142,7 @@ TEST_F(TemporalLayersTest, 2Layers) { for (size_t i = 0; i < kPatternSize * kRepetitions; ++i) { const size_t ind = i % kPatternSize; CodecSpecificInfo info; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); EXPECT_EQ(expected_flags[ind], LibvpxVp8Encoder::EncodeFlags(tl_config)) << i; tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, i == 0, kDefaultQp, @@ -197,7 +197,7 @@ TEST_F(TemporalLayersTest, 3Layers) { unsigned int timestamp = 0; for (int i = 0; i < 16; ++i) { CodecSpecificInfo info; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); EXPECT_EQ(expected_flags[i], LibvpxVp8Encoder::EncodeFlags(tl_config)) << i; tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, i == 0, kDefaultQp, &info); @@ -240,7 +240,7 @@ TEST_F(TemporalLayersTest, Alternative3Layers) { unsigned int timestamp = 0; for (int i = 0; i < 8; ++i) { CodecSpecificInfo info; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); EXPECT_EQ(expected_flags[i], LibvpxVp8Encoder::EncodeFlags(tl_config)) << i; tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, i == 0, kDefaultQp, &info); @@ -272,19 +272,19 @@ TEST_F(TemporalLayersTest, SearchOrder) { // Start with a key-frame. tl_config flags can be ignored. uint32_t timestamp = 0; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame. First one only references TL0. Updates altref. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_EQ(tl_config.first_reference, Vp8BufferReference::kLast); EXPECT_EQ(tl_config.second_reference, Vp8BufferReference::kNone); // TL1 frame. Can only reference TL0. Updated golden. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_EQ(tl_config.first_reference, Vp8BufferReference::kLast); @@ -292,7 +292,7 @@ TEST_F(TemporalLayersTest, SearchOrder) { // TL2 frame. Can reference all three buffers. Golden was the last to be // updated, the next to last was altref. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_EQ(tl_config.first_reference, Vp8BufferReference::kGolden); @@ -316,24 +316,24 @@ TEST_F(TemporalLayersTest, SearchOrderWithDrop) { // Start with a key-frame. tl_config flags can be ignored. uint32_t timestamp = 0; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame. First one only references TL0. Updates altref. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_EQ(tl_config.first_reference, Vp8BufferReference::kLast); EXPECT_EQ(tl_config.second_reference, Vp8BufferReference::kNone); // Dropped TL1 frame. Can only reference TL0. Should have updated golden. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, 0, false, 0, nullptr); // TL2 frame. Can normally reference all three buffers, but golden has not // been populated this cycle. Altref was last to be updated, before that last. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_EQ(tl_config.first_reference, Vp8BufferReference::kAltref); @@ -378,7 +378,7 @@ TEST_F(TemporalLayersTest, 4Layers) { uint32_t timestamp = 0; for (int i = 0; i < 16; ++i) { CodecSpecificInfo info; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); EXPECT_EQ(expected_flags[i], LibvpxVp8Encoder::EncodeFlags(tl_config)) << i; tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, i == 0, kDefaultQp, &info); @@ -409,21 +409,21 @@ TEST_F(TemporalLayersTest, DoesNotReferenceDroppedFrames) { // Start with a keyframe. uint32_t timestamp = 0; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, IgnoredCodecSpecificInfo()); // Dropped TL2 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, 0, false, 0, nullptr); // Dropped TL1 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, 0, false, 0, nullptr); // TL2 frame. Can reference all three buffers, valid since golden and altref // both contain the last keyframe. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); @@ -433,23 +433,23 @@ TEST_F(TemporalLayersTest, DoesNotReferenceDroppedFrames) { // Restart of cycle! // TL0 base layer frame, updating and referencing last. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame, updating altref. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // TL1 frame, updating golden. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame. Can still reference all buffer since they have been update this // cycle. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); @@ -459,21 +459,21 @@ TEST_F(TemporalLayersTest, DoesNotReferenceDroppedFrames) { // Restart of cycle! // TL0 base layer frame, updating and referencing last. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // Dropped TL2 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, 0, false, 0, nullptr); // Dropped TL1 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, 0, false, 0, nullptr); // TL2 frame. This time golden and altref contain data from the previous cycle // and cannot be referenced. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); @@ -496,40 +496,40 @@ TEST_F(TemporalLayersTest, DoesNotReferenceUnlessGuaranteedToExist) { // Start with a keyframe. uint32_t timestamp = 0; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, IgnoredCodecSpecificInfo()); // Do a full cycle of the pattern. for (int i = 0; i < 7; ++i) { - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); } // TL0 base layer frame, starting the cycle over. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // Encoder has a hiccup and builds a queue, so frame encoding is delayed. // TL1 frame, updating golden. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); // TL2 frame, that should be referencing golden, but we can't be certain it's // not going to be dropped, so that is not allowed. - tl_config = tl.UpdateLayerConfig(0, timestamp + 1); + tl_config = tl.NextFrameConfig(0, timestamp + 1); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); EXPECT_FALSE(tl_config.golden_buffer_flags & BufferFlags::kReference); EXPECT_FALSE(tl_config.arf_buffer_flags & BufferFlags::kReference); // TL0 base layer frame. - tl_config = tl.UpdateLayerConfig(0, timestamp + 2); + tl_config = tl.NextFrameConfig(0, timestamp + 2); // The previous four enqueued frames finally get encoded, and the updated // buffers are now OK to reference. @@ -544,7 +544,7 @@ TEST_F(TemporalLayersTest, DoesNotReferenceUnlessGuaranteedToExist) { IgnoredCodecSpecificInfo()); // TL2 frame, all buffers are now in a known good state, OK to reference. - tl_config = tl.UpdateLayerConfig(0, ++timestamp + 1); + tl_config = tl.NextFrameConfig(0, ++timestamp + 1); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); EXPECT_TRUE(tl_config.golden_buffer_flags & BufferFlags::kReference); EXPECT_FALSE(tl_config.arf_buffer_flags & BufferFlags::kReference); @@ -566,37 +566,37 @@ TEST_F(TemporalLayersTest, DoesNotReferenceUnlessGuaranteedToExistLongDelay) { // Start with a keyframe. uint32_t timestamp = 0; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, IgnoredCodecSpecificInfo()); // Do a full cycle of the pattern. for (int i = 0; i < 3; ++i) { - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); } // TL0 base layer frame, starting the cycle over. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // TL2 frame. - tl_config = tl.UpdateLayerConfig(0, ++timestamp); + tl_config = tl.NextFrameConfig(0, ++timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, IgnoredCodecSpecificInfo()); // Encoder has a hiccup and builds a queue, so frame encoding is delayed. // Encoded, but delayed frames in TL 1, 2. - tl_config = tl.UpdateLayerConfig(0, timestamp + 1); - tl_config = tl.UpdateLayerConfig(0, timestamp + 2); + tl_config = tl.NextFrameConfig(0, timestamp + 1); + tl_config = tl.NextFrameConfig(0, timestamp + 2); // Restart of the pattern! // Encoded, but delayed frames in TL 2, 1. - tl_config = tl.UpdateLayerConfig(0, timestamp + 3); - tl_config = tl.UpdateLayerConfig(0, timestamp + 4); + tl_config = tl.NextFrameConfig(0, timestamp + 3); + tl_config = tl.NextFrameConfig(0, timestamp + 4); // TL1 frame from last cycle is ready. tl.OnEncodeDone(0, timestamp + 1, kDefaultBytesPerFrame, false, kDefaultQp, @@ -608,7 +608,7 @@ TEST_F(TemporalLayersTest, DoesNotReferenceUnlessGuaranteedToExistLongDelay) { // TL2 frame, that should be referencing all buffers, but altref and golden // haven not been updated this cycle. (Don't be fooled by the late frames from // the last cycle!) - tl_config = tl.UpdateLayerConfig(0, timestamp + 5); + tl_config = tl.NextFrameConfig(0, timestamp + 5); EXPECT_TRUE(tl_config.last_buffer_flags & BufferFlags::kReference); EXPECT_FALSE(tl_config.golden_buffer_flags & BufferFlags::kReference); EXPECT_FALSE(tl_config.arf_buffer_flags & BufferFlags::kReference); @@ -646,7 +646,7 @@ TEST_F(TemporalLayersTest, KeyFrame) { for (int j = 1; j <= i; ++j) { // Since last frame was always a keyframe and thus index 0 in the pattern, // this loop starts at index 1. - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); EXPECT_EQ(expected_flags[j], LibvpxVp8Encoder::EncodeFlags(tl_config)) << j; tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, false, kDefaultQp, @@ -659,7 +659,7 @@ TEST_F(TemporalLayersTest, KeyFrame) { } CodecSpecificInfo info; - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp); tl.OnEncodeDone(0, timestamp, kDefaultBytesPerFrame, true, kDefaultQp, &info); EXPECT_TRUE(info.codecSpecific.VP8.layerSync) @@ -748,7 +748,7 @@ TEST_P(TemporalLayersReferenceTest, ValidFrameConfigs) { // updates |last|. std::vector tl_configs(kMaxPatternLength); for (int i = 0; i < kMaxPatternLength; ++i) { - Vp8FrameConfig tl_config = tl.UpdateLayerConfig(0, timestamp_); + Vp8FrameConfig tl_config = tl.NextFrameConfig(0, timestamp_); tl.OnEncodeDone(0, timestamp_, kDefaultBytesPerFrame, i == 0, kDefaultQp, IgnoredCodecSpecificInfo()); ++timestamp_; diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 3e43275fdb..44c2026a89 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -923,7 +923,7 @@ int LibvpxVp8Encoder::Encode(const VideoFrame& frame, Vp8FrameConfig tl_configs[kMaxSimulcastStreams]; for (size_t i = 0; i < encoders_.size(); ++i) { tl_configs[i] = - frame_buffer_controller_->UpdateLayerConfig(i, frame.timestamp()); + frame_buffer_controller_->NextFrameConfig(i, frame.timestamp()); if (tl_configs[i].drop_frame) { if (send_key_frame) { continue; diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc index 85fb6d7264..352300bd86 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc @@ -82,8 +82,8 @@ bool ScreenshareLayers::SupportsEncoderFrameDropping( return false; } -Vp8FrameConfig ScreenshareLayers::UpdateLayerConfig(size_t stream_index, - uint32_t timestamp) { +Vp8FrameConfig ScreenshareLayers::NextFrameConfig(size_t stream_index, + uint32_t timestamp) { RTC_DCHECK_LT(stream_index, StreamCount()); auto it = pending_frame_configs_.find(timestamp); diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.h b/modules/video_coding/codecs/vp8/screenshare_layers.h index c7bc5f46f8..06d45534fe 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.h +++ b/modules/video_coding/codecs/vp8/screenshare_layers.h @@ -42,8 +42,8 @@ class ScreenshareLayers final : public Vp8FrameBufferController { // Returns the recommended VP8 encode flags needed. May refresh the decoder // and/or update the reference buffers. - Vp8FrameConfig UpdateLayerConfig(size_t stream_index, - uint32_t rtp_timestamp) override; + Vp8FrameConfig NextFrameConfig(size_t stream_index, + uint32_t rtp_timestamp) override; // New target bitrate, per temporal layer. void OnRatesUpdated(size_t stream_index, diff --git a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc index b5ff190b8d..032c5280bd 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc @@ -85,7 +85,7 @@ class ScreenshareLayerTest : public ::testing::Test { } int ConfigureFrame(bool key_frame) { - tl_config_ = UpdateLayerConfig(0, timestamp_); + tl_config_ = NextFrameConfig(0, timestamp_); EXPECT_EQ(0, tl_config_.encoder_layer_id) << "ScreenshareLayers always encodes using the bitrate allocator for " "layer 0, but may reference different buffers and packetize " @@ -99,10 +99,10 @@ class ScreenshareLayerTest : public ::testing::Test { return flags; } - Vp8FrameConfig UpdateLayerConfig(size_t stream_index, uint32_t timestamp) { + Vp8FrameConfig NextFrameConfig(size_t stream_index, uint32_t timestamp) { int64_t timestamp_ms = timestamp / 90; clock_.AdvanceTime(TimeDelta::ms(timestamp_ms - rtc::TimeMillis())); - return layers_->UpdateLayerConfig(stream_index, timestamp); + return layers_->NextFrameConfig(stream_index, timestamp); } int FrameSizeForBitrate(int bitrate_kbps) { @@ -245,7 +245,7 @@ TEST_F(ScreenshareLayerTest, 2LayersSyncAfterTimeout) { for (int i = 0; i < kNumFrames; ++i) { CodecSpecificInfo info; - tl_config_ = UpdateLayerConfig(0, timestamp_); + tl_config_ = NextFrameConfig(0, timestamp_); config_updated_ = layers_->UpdateConfiguration(0, &cfg_); // Simulate TL1 being at least 8 qp steps better. @@ -486,8 +486,8 @@ TEST_F(ScreenshareLayerTest, RespectsMaxIntervalBetweenFrames) { layers_->OnRatesUpdated(0, layer_rates, kFrameRate); layers_->UpdateConfiguration(0, &cfg_); - EXPECT_EQ(kTl0Flags, LibvpxVp8Encoder::EncodeFlags( - UpdateLayerConfig(0, kStartTimestamp))); + EXPECT_EQ(kTl0Flags, + LibvpxVp8Encoder::EncodeFlags(NextFrameConfig(0, kStartTimestamp))); layers_->OnEncodeDone(0, kStartTimestamp, kLargeFrameSizeBytes, false, kDefaultQp, IgnoredCodecSpecificInfo()); @@ -502,12 +502,12 @@ TEST_F(ScreenshareLayerTest, RespectsMaxIntervalBetweenFrames) { // any later, the frame will be dropped anyway by the frame rate throttling // logic. EXPECT_TRUE( - UpdateLayerConfig(0, kTwoSecondsLater - kTimestampDelta5Fps).drop_frame); + NextFrameConfig(0, kTwoSecondsLater - kTimestampDelta5Fps).drop_frame); // More than two seconds has passed since last frame, one should be emitted // even if bitrate target is then exceeded. EXPECT_EQ(kTl0Flags, LibvpxVp8Encoder::EncodeFlags( - UpdateLayerConfig(0, kTwoSecondsLater + 90))); + NextFrameConfig(0, kTwoSecondsLater + 90))); } TEST_F(ScreenshareLayerTest, UpdatesHistograms) { @@ -520,7 +520,7 @@ TEST_F(ScreenshareLayerTest, UpdatesHistograms) { for (int64_t timestamp = 0; timestamp < kTimestampDelta5Fps * 5 * metrics::kMinRunTimeInSeconds; timestamp += kTimestampDelta5Fps) { - tl_config_ = UpdateLayerConfig(0, timestamp); + tl_config_ = NextFrameConfig(0, timestamp); if (tl_config_.drop_frame) { dropped_frame = true; continue; @@ -609,7 +609,7 @@ TEST_F(ScreenshareLayerTest, RespectsConfiguredFramerate) { // Send at regular rate - no drops expected. for (int64_t i = 0; i < kTestSpanMs; i += kFrameIntervalsMs) { - if (UpdateLayerConfig(0, timestamp).drop_frame) { + if (NextFrameConfig(0, timestamp).drop_frame) { ++num_discarded_frames; } else { size_t frame_size_bytes = kDefaultTl0BitrateKbps * kFrameIntervalsMs / 8; @@ -627,7 +627,7 @@ TEST_F(ScreenshareLayerTest, RespectsConfiguredFramerate) { num_input_frames = 0; num_discarded_frames = 0; for (int64_t i = 0; i < kTestSpanMs; i += kFrameIntervalsMs / 2) { - if (UpdateLayerConfig(0, timestamp).drop_frame) { + if (NextFrameConfig(0, timestamp).drop_frame) { ++num_discarded_frames; } else { size_t frame_size_bytes = kDefaultTl0BitrateKbps * kFrameIntervalsMs / 8; @@ -669,7 +669,7 @@ TEST_F(ScreenshareLayerTest, DropOnTooShortFrameInterval) { // Add a large gap, so there's plenty of room in the rate tracker. timestamp_ += kTimestampDelta5Fps * 3; - EXPECT_FALSE(UpdateLayerConfig(0, timestamp_).drop_frame); + EXPECT_FALSE(NextFrameConfig(0, timestamp_).drop_frame); layers_->OnEncodeDone(0, timestamp_, frame_size_, false, kDefaultQp, IgnoredCodecSpecificInfo()); @@ -677,11 +677,11 @@ TEST_F(ScreenshareLayerTest, DropOnTooShortFrameInterval) { // frame just before this limit. const int64_t kMinFrameInterval = (kTimestampDelta5Fps * 85) / 100; timestamp_ += kMinFrameInterval - 90; - EXPECT_TRUE(UpdateLayerConfig(0, timestamp_).drop_frame); + EXPECT_TRUE(NextFrameConfig(0, timestamp_).drop_frame); // Try again at the limit, now it should pass. timestamp_ += 90; - EXPECT_FALSE(UpdateLayerConfig(0, timestamp_).drop_frame); + EXPECT_FALSE(NextFrameConfig(0, timestamp_).drop_frame); } TEST_F(ScreenshareLayerTest, AdjustsBitrateWhenDroppingFrames) { diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc index 6a6604bd55..eefb743d63 100644 --- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc +++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc @@ -37,7 +37,7 @@ constexpr uint32_t kSimulcastScreenshareMaxBitrateKbps = 1250; class MockTemporalLayers : public Vp8FrameBufferController { public: - MOCK_METHOD2(UpdateLayerConfig, Vp8FrameConfig(size_t, uint32_t)); + MOCK_METHOD2(NextFrameConfig, Vp8FrameConfig(size_t, uint32_t)); MOCK_METHOD3(OnRatesUpdated, void(size_t, const std::vector&, int)); MOCK_METHOD2(UpdateConfiguration, bool(size_t, Vp8EncoderConfig*)); MOCK_METHOD6(OnEncodeDone, diff --git a/test/fake_vp8_encoder.cc b/test/fake_vp8_encoder.cc index b714b4d8f3..dd60a48197 100644 --- a/test/fake_vp8_encoder.cc +++ b/test/fake_vp8_encoder.cc @@ -93,8 +93,8 @@ std::unique_ptr FakeVP8Encoder::EncodeHook( CodecSpecificInfo* codec_specific) { RTC_DCHECK_RUN_ON(&sequence_checker_); uint8_t stream_idx = encoded_image->SpatialIndex().value_or(0); - frame_buffer_controller_->UpdateLayerConfig(stream_idx, - encoded_image->Timestamp()); + frame_buffer_controller_->NextFrameConfig(stream_idx, + encoded_image->Timestamp()); PopulateCodecSpecific(codec_specific, encoded_image->size(), encoded_image->_frameType, stream_idx, encoded_image->Timestamp());