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

Side by Side Diff: webrtc/video/video_stream_encoder_unittest.cc

Issue 3000693003: Move kMinPixelsPerFrame constant in VideoStreamEncoder to VideoEncoder::ScalingSettings. (Closed)
Patch Set: rebase Created 3 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « webrtc/video/video_stream_encoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 11 matching lines...) Expand all
22 #include "webrtc/system_wrappers/include/sleep.h" 22 #include "webrtc/system_wrappers/include/sleep.h"
23 #include "webrtc/test/encoder_settings.h" 23 #include "webrtc/test/encoder_settings.h"
24 #include "webrtc/test/fake_encoder.h" 24 #include "webrtc/test/fake_encoder.h"
25 #include "webrtc/test/frame_generator.h" 25 #include "webrtc/test/frame_generator.h"
26 #include "webrtc/test/gmock.h" 26 #include "webrtc/test/gmock.h"
27 #include "webrtc/test/gtest.h" 27 #include "webrtc/test/gtest.h"
28 #include "webrtc/video/send_statistics_proxy.h" 28 #include "webrtc/video/send_statistics_proxy.h"
29 #include "webrtc/video/video_stream_encoder.h" 29 #include "webrtc/video/video_stream_encoder.h"
30 30
31 namespace { 31 namespace {
32 // TODO(kthelgason): Lower this limit when better testing
33 // on MediaCodec and fallback implementations are in place.
34 const int kMinPixelsPerFrame = 320 * 180; 32 const int kMinPixelsPerFrame = 320 * 180;
35 const int kMinFramerateFps = 2; 33 const int kMinFramerateFps = 2;
36 const int64_t kFrameTimeoutMs = 100; 34 const int64_t kFrameTimeoutMs = 100;
37 const unsigned char kNumSlDummy = 0; 35 const unsigned char kNumSlDummy = 0;
38 } // namespace 36 } // namespace
39 37
40 namespace webrtc { 38 namespace webrtc {
41 39
42 using DegredationPreference = VideoSendStream::DegradationPreference; 40 using DegredationPreference = VideoSendStream::DegradationPreference;
43 using ScaleReason = AdaptationObserverInterface::AdaptReason; 41 using ScaleReason = AdaptationObserverInterface::AdaptReason;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 473 }
476 474
477 void BlockNextEncode() { 475 void BlockNextEncode() {
478 rtc::CritScope lock(&local_crit_sect_); 476 rtc::CritScope lock(&local_crit_sect_);
479 block_next_encode_ = true; 477 block_next_encode_ = true;
480 } 478 }
481 479
482 VideoEncoder::ScalingSettings GetScalingSettings() const override { 480 VideoEncoder::ScalingSettings GetScalingSettings() const override {
483 rtc::CritScope lock(&local_crit_sect_); 481 rtc::CritScope lock(&local_crit_sect_);
484 if (quality_scaling_) 482 if (quality_scaling_)
485 return VideoEncoder::ScalingSettings(true, 1, 2); 483 return VideoEncoder::ScalingSettings(true, 1, 2, kMinPixelsPerFrame);
486 return VideoEncoder::ScalingSettings(false); 484 return VideoEncoder::ScalingSettings(false);
487 } 485 }
488 486
489 void ContinueEncode() { continue_encode_event_.Set(); } 487 void ContinueEncode() { continue_encode_event_.Set(); }
490 488
491 void CheckLastTimeStampsMatch(int64_t ntp_time_ms, 489 void CheckLastTimeStampsMatch(int64_t ntp_time_ms,
492 uint32_t timestamp) const { 490 uint32_t timestamp) const {
493 rtc::CritScope lock(&local_crit_sect_); 491 rtc::CritScope lock(&local_crit_sect_);
494 EXPECT_EQ(timestamp_, timestamp); 492 EXPECT_EQ(timestamp_, timestamp);
495 EXPECT_EQ(ntp_time_ms_, ntp_time_ms); 493 EXPECT_EQ(ntp_time_ms_, ntp_time_ms);
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 } 1900 }
1903 1901
1904 TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) { 1902 TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) {
1905 const int kWidth = 1280; 1903 const int kWidth = 1280;
1906 const int kHeight = 720; 1904 const int kHeight = 720;
1907 const size_t kNumFrames = 10; 1905 const size_t kNumFrames = 10;
1908 1906
1909 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); 1907 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
1910 1908
1911 // Enable adapter, expected input resolutions when downscaling: 1909 // Enable adapter, expected input resolutions when downscaling:
1912 // 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (min resolution limit) 1910 // 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (kMinPixelsPerFrame)
1913 video_source_.set_adaptation_enabled(true); 1911 video_source_.set_adaptation_enabled(true);
1914 1912
1915 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); 1913 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
1916 EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes); 1914 EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
1917 1915
1918 int downscales = 0; 1916 int downscales = 0;
1919 for (size_t i = 1; i <= kNumFrames; i++) { 1917 for (size_t i = 1; i <= kNumFrames; i++) {
1920 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); 1918 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
1921 WaitForEncodedFrame(i); 1919 WaitForEncodedFrame(i);
1922 1920
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 // Bitrate observer should not be called. 3271 // Bitrate observer should not be called.
3274 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); 3272 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0);
3275 video_source_.IncomingCapturedFrame( 3273 video_source_.IncomingCapturedFrame(
3276 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); 3274 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight));
3277 ExpectDroppedFrame(); 3275 ExpectDroppedFrame();
3278 3276
3279 video_stream_encoder_->Stop(); 3277 video_stream_encoder_->Stop();
3280 } 3278 }
3281 3279
3282 } // namespace webrtc 3280 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_stream_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698