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

Unified Diff: webrtc/video/vie_encoder_unittest.cc

Issue 2538913003: Remove limit on how often quality scaling downscales. (Closed)
Patch Set: size_t -> int Created 4 years 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
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/vie_encoder_unittest.cc
diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc
index 6cc25cfb80e925946ec1a897f915b6169fecbdf4..1bb904be7cc7f39983cca026707c5bd9c238709c 100644
--- a/webrtc/video/vie_encoder_unittest.cc
+++ b/webrtc/video/vie_encoder_unittest.cc
@@ -585,12 +585,15 @@ TEST_F(ViEEncoderTest,
int frame_width = 1280;
int frame_height = 720;
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(1, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(1);
// Trigger CPU overuse.
vie_encoder_->TriggerCpuOveruse();
video_source_.IncomingCapturedFrame(
- CreateFrame(1, frame_width, frame_height));
- sink_.WaitForEncodedFrame(1);
+ CreateFrame(2, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(2);
EXPECT_LT(video_source_.sink_wants().max_pixel_count.value_or(
std::numeric_limits<int>::max()),
frame_width * frame_height);
@@ -606,8 +609,8 @@ TEST_F(ViEEncoderTest,
EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count_step_up);
new_video_source.IncomingCapturedFrame(
- CreateFrame(2, frame_width, frame_height));
- sink_.WaitForEncodedFrame(2);
+ CreateFrame(3, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(3);
EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count);
EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count_step_up);
@@ -874,12 +877,17 @@ TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
EXPECT_FALSE(video_source_.sink_wants().max_pixel_count);
EXPECT_FALSE(video_source_.sink_wants().max_pixel_count_step_up);
- // Trigger scale down
- vie_encoder_->TriggerQualityLow();
video_source_.IncomingCapturedFrame(
CreateFrame(1, frame_width, frame_height));
sink_.WaitForEncodedFrame(1);
+ // Trigger scale down
+ vie_encoder_->TriggerQualityLow();
+
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(2, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(2);
+
// Expect a scale down.
EXPECT_TRUE(video_source_.sink_wants().max_pixel_count);
EXPECT_LT(*video_source_.sink_wants().max_pixel_count,
@@ -894,8 +902,8 @@ TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
// Trigger scale down
vie_encoder_->TriggerQualityLow();
new_video_source.IncomingCapturedFrame(
- CreateFrame(2, frame_width, frame_height));
- sink_.WaitForEncodedFrame(2);
+ CreateFrame(3, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(3);
// Expect no scaling
EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count);
@@ -903,8 +911,8 @@ TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
// Trigger scale up
vie_encoder_->TriggerQualityHigh();
new_video_source.IncomingCapturedFrame(
- CreateFrame(3, frame_width, frame_height));
- sink_.WaitForEncodedFrame(3);
+ CreateFrame(4, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(4);
// Expect nothing to change, still no scaling
EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count);
@@ -912,6 +920,26 @@ TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) {
vie_encoder_->Stop();
}
+TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) {
+ const int kTargetBitrateBps = 100000;
+ int frame_width = 1280;
+ int frame_height = 720;
+ // from vie_encoder.cc
+ const int kMinPixelsPerFrame = 120 * 90;
+ vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+
+ for (size_t i = 1; i <= 10; i++) {
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(i, frame_width, frame_height));
+ sink_.WaitForEncodedFrame(i);
+ // Trigger scale down
+ vie_encoder_->TriggerQualityLow();
+ EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame);
+ }
+
+ vie_encoder_->Stop();
+}
+
TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) {
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698