Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc

Issue 2489843002: Revert of Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
index 678b150db2748188fbc65a91ac29b88f11cac40a..9a06c0ac5f69c7530086cc741623c6d791b42491 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
@@ -93,6 +93,12 @@
TEST_F(TestSimulcastEncoderAdapter, TestSpatioTemporalLayers321PatternEncoder) {
TestVp8Simulcast::TestSpatioTemporalLayers321PatternEncoder();
+}
+
+// TODO(ronghuawu): Enable this test when SkipEncodingUnusedStreams option is
+// implemented for SimulcastEncoderAdapter.
+TEST_F(TestSimulcastEncoderAdapter, DISABLED_TestSkipEncodingUnusedStreams) {
+ TestVp8Simulcast::TestSkipEncodingUnusedStreams();
}
TEST_F(TestSimulcastEncoderAdapter, DISABLED_TestRPSIEncoder) {
@@ -126,9 +132,8 @@
int32_t Release() /* override */ { return 0; }
- int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
- uint32_t framerate) {
- last_set_bitrate_ = bitrate_allocation;
+ int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) /* override */ {
+ last_set_bitrate_ = static_cast<int32_t>(newBitRate);
return 0;
}
@@ -155,13 +160,13 @@
void set_supports_native_handle(bool enabled) {
supports_native_handle_ = enabled;
}
- BitrateAllocation last_set_bitrate() const { return last_set_bitrate_; }
+ int32_t last_set_bitrate() const { return last_set_bitrate_; }
MOCK_CONST_METHOD0(ImplementationName, const char*());
private:
bool supports_native_handle_ = false;
- BitrateAllocation last_set_bitrate_;
+ int32_t last_set_bitrate_ = -1;
VideoCodec codec_;
EncodedImageCallback* callback_;
@@ -268,9 +273,6 @@
void SetupCodec() {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- rate_allocator_.reset(new SimulcastRateAllocator(codec_, nullptr));
- tl_factory_.SetListener(rate_allocator_.get());
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
adapter_->RegisterEncodeCompleteCallback(this);
}
@@ -299,6 +301,7 @@
EXPECT_EQ(ref.VP8().automaticResizeOn, target.VP8().automaticResizeOn);
EXPECT_EQ(ref.VP8().frameDroppingOn, target.VP8().frameDroppingOn);
EXPECT_EQ(ref.VP8().keyFrameInterval, target.VP8().keyFrameInterval);
+ EXPECT_EQ(ref.VP8().tl_factory, target.VP8().tl_factory);
EXPECT_EQ(ref.qpMax, target.qpMax);
EXPECT_EQ(0, target.numberOfSimulcastStreams);
EXPECT_EQ(ref.mode, target.mode);
@@ -311,7 +314,6 @@
*ref_codec = codec_;
ref_codec->VP8()->numberOfTemporalLayers =
kTestTemporalLayerProfile[stream_index];
- ref_codec->codecSpecific.VP8.tl_factory = &tl_factory_;
ref_codec->width = codec_.simulcastStream[stream_index].width;
ref_codec->height = codec_.simulcastStream[stream_index].height;
ref_codec->maxBitrate = codec_.simulcastStream[stream_index].maxBitrate;
@@ -355,8 +357,6 @@
int last_encoded_image_width_;
int last_encoded_image_height_;
int last_encoded_image_simulcast_index_;
- TemporalLayersFactory tl_factory_;
- std::unique_ptr<SimulcastRateAllocator> rate_allocator_;
};
TEST_F(TestSimulcastEncoderAdapterFake, InitEncode) {
@@ -376,7 +376,7 @@
SetupCodec();
// Set bitrates so that we send all layers.
- adapter_->SetRateAllocation(rate_allocator_->GetAllocation(1200, 30), 30);
+ adapter_->SetRates(1200, 30);
// At this point, the simulcast encoder adapter should have 3 streams: HD,
// quarter HD, and quarter quarter HD. We're going to mostly ignore the exact
@@ -409,7 +409,6 @@
TEST_F(TestSimulcastEncoderAdapterFake, SupportsNativeHandleForSingleStreams) {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
codec_.numberOfSimulcastStreams = 1;
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
adapter_->RegisterEncodeCompleteCallback(this);
@@ -423,37 +422,27 @@
TEST_F(TestSimulcastEncoderAdapterFake, SetRatesUnderMinBitrate) {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
codec_.minBitrate = 50;
codec_.numberOfSimulcastStreams = 1;
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
- rate_allocator_.reset(new SimulcastRateAllocator(codec_, nullptr));
// Above min should be respected.
- BitrateAllocation target_bitrate =
- rate_allocator_->GetAllocation(codec_.minBitrate * 1000, 30);
- adapter_->SetRateAllocation(target_bitrate, 30);
- EXPECT_EQ(target_bitrate,
- helper_->factory()->encoders()[0]->last_set_bitrate());
+ adapter_->SetRates(100, 30);
+ EXPECT_EQ(100, helper_->factory()->encoders()[0]->last_set_bitrate());
// Below min but non-zero should be replaced with the min bitrate.
- BitrateAllocation too_low_bitrate =
- rate_allocator_->GetAllocation((codec_.minBitrate - 1) * 1000, 30);
- adapter_->SetRateAllocation(too_low_bitrate, 30);
- EXPECT_EQ(target_bitrate,
- helper_->factory()->encoders()[0]->last_set_bitrate());
+ adapter_->SetRates(15, 30);
+ EXPECT_EQ(50, helper_->factory()->encoders()[0]->last_set_bitrate());
// Zero should be passed on as is, since it means "pause".
- adapter_->SetRateAllocation(BitrateAllocation(), 30);
- EXPECT_EQ(BitrateAllocation(),
- helper_->factory()->encoders()[0]->last_set_bitrate());
+ adapter_->SetRates(0, 30);
+ EXPECT_EQ(0, helper_->factory()->encoders()[0]->last_set_bitrate());
}
TEST_F(TestSimulcastEncoderAdapterFake, SupportsImplementationName) {
EXPECT_STREQ("SimulcastEncoderAdapter", adapter_->ImplementationName());
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
std::vector<const char*> encoder_names;
encoder_names.push_back("codec1");
encoder_names.push_back("codec2");
@@ -476,7 +465,6 @@
SupportsNativeHandleForMultipleStreams) {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
codec_.numberOfSimulcastStreams = 3;
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
adapter_->RegisterEncodeCompleteCallback(this);
@@ -505,7 +493,6 @@
NativeHandleForwardingForMultipleStreams) {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
codec_.numberOfSimulcastStreams = 3;
// High start bitrate, so all streams are enabled.
codec_.startBitrate = 3000;
@@ -530,7 +517,6 @@
TEST_F(TestSimulcastEncoderAdapterFake, TestFailureReturnCodesFromEncodeCalls) {
TestVp8Simulcast::DefaultSettings(
&codec_, static_cast<const int*>(kTestTemporalLayerProfile));
- codec_.codecSpecific.VP8.tl_factory = &tl_factory_;
codec_.numberOfSimulcastStreams = 3;
EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
adapter_->RegisterEncodeCompleteCallback(this);

Powered by Google App Engine
This is Rietveld 408576698