Rename "UpdateLayerConfig" to "NextFrameConfig"

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 <eladalon@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27660}
This commit is contained in:
Elad Alon 2019-04-17 12:53:08 +02:00 committed by Commit Bot
parent 123ee9be8f
commit 979c4426a4
12 changed files with 94 additions and 91 deletions

View file

@ -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<uint32_t>& 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,
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,

View file

@ -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,
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,

View file

@ -45,7 +45,7 @@ class Vp8TemporalLayers final : public Vp8FrameBufferController {
bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) override;
Vp8FrameConfig UpdateLayerConfig(size_t stream_index,
Vp8FrameConfig NextFrameConfig(size_t stream_index,
uint32_t rtp_timestamp) override;
void OnEncodeDone(size_t stream_index,

View file

@ -330,7 +330,7 @@ bool DefaultTemporalLayers::IsSyncFrame(const Vp8FrameConfig& config) const {
return true;
}
Vp8FrameConfig DefaultTemporalLayers::UpdateLayerConfig(size_t stream_index,
Vp8FrameConfig DefaultTemporalLayers::NextFrameConfig(size_t stream_index,
uint32_t timestamp) {
RTC_DCHECK_LT(stream_index, StreamCount());
RTC_DCHECK_GT(num_layers_, 0);

View file

@ -40,7 +40,7 @@ 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,
Vp8FrameConfig NextFrameConfig(size_t stream_index,
uint32_t timestamp) override;
// New target bitrate, per temporal layer.
@ -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.

View file

@ -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<Vp8FrameConfig> 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_;

View file

@ -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;

View file

@ -82,7 +82,7 @@ bool ScreenshareLayers::SupportsEncoderFrameDropping(
return false;
}
Vp8FrameConfig ScreenshareLayers::UpdateLayerConfig(size_t stream_index,
Vp8FrameConfig ScreenshareLayers::NextFrameConfig(size_t stream_index,
uint32_t timestamp) {
RTC_DCHECK_LT(stream_index, StreamCount());

View file

@ -42,7 +42,7 @@ 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,
Vp8FrameConfig NextFrameConfig(size_t stream_index,
uint32_t rtp_timestamp) override;
// New target bitrate, per temporal layer.

View file

@ -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) {

View file

@ -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<uint32_t>&, int));
MOCK_METHOD2(UpdateConfiguration, bool(size_t, Vp8EncoderConfig*));
MOCK_METHOD6(OnEncodeDone,

View file

@ -93,7 +93,7 @@ std::unique_ptr<RTPFragmentationHeader> 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,
frame_buffer_controller_->NextFrameConfig(stream_idx,
encoded_image->Timestamp());
PopulateCodecSpecific(codec_specific, encoded_image->size(),
encoded_image->_frameType, stream_idx,