From db0d5861726e5cb1d753a72963bb1c76c35c1506 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Thu, 28 Apr 2022 19:26:22 +0200 Subject: [PATCH] Enable variable_start_scale_factor_ by default. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:14007 Change-Id: I1c803b4a530209ae9b47a9bd91379621f17fe685 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260186 Reviewed-by: Åsa Persson Reviewed-by: Erik Språng Commit-Queue: Ying Wang Cr-Commit-Position: refs/heads/main@{#36697} --- media/base/video_adapter.cc | 2 +- media/base/video_adapter_unittest.cc | 54 +++----------------------- video/video_stream_encoder_unittest.cc | 8 ++-- 3 files changed, 10 insertions(+), 54 deletions(-) diff --git a/media/base/video_adapter.cc b/media/base/video_adapter.cc index 4785dfcfe2..bad40b8988 100644 --- a/media/base/video_adapter.cc +++ b/media/base/video_adapter.cc @@ -132,7 +132,7 @@ VideoAdapter::VideoAdapter(int source_resolution_alignment) adaption_changes_(0), previous_width_(0), previous_height_(0), - variable_start_scale_factor_(webrtc::field_trial::IsEnabled( + variable_start_scale_factor_(!webrtc::field_trial::IsDisabled( "WebRTC-Video-VariableStartScaleFactor")), source_resolution_alignment_(source_resolution_alignment), resolution_alignment_(source_resolution_alignment), diff --git a/media/base/video_adapter_unittest.cc b/media/base/video_adapter_unittest.cc index 347e24d905..af3585916e 100644 --- a/media/base/video_adapter_unittest.cc +++ b/media/base/video_adapter_unittest.cc @@ -147,21 +147,10 @@ class VideoAdapterTest : public ::testing::Test, const bool use_new_format_request_; }; -class VideoAdapterTestVariableStartScale : public VideoAdapterTest { - public: - VideoAdapterTestVariableStartScale() - : VideoAdapterTest("WebRTC-Video-VariableStartScaleFactor/Enabled/", - /*source_resolution_alignment=*/1) {} -}; - INSTANTIATE_TEST_SUITE_P(OnOutputFormatRequests, VideoAdapterTest, ::testing::Values(true, false)); -INSTANTIATE_TEST_SUITE_P(OnOutputFormatRequests, - VideoAdapterTestVariableStartScale, - ::testing::Values(true, false)); - // Do not adapt the frame rate or the resolution. Expect no frame drop, no // cropping, and no resolution change. TEST_P(VideoAdapterTest, AdaptNothing) { @@ -955,8 +944,8 @@ TEST_P(VideoAdapterTest, TestAdaptToVerySmallResolution) { EXPECT_TRUE(adapter_.AdaptFrameResolution( w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); - EXPECT_EQ(180, out_width_); - EXPECT_EQ(99, out_height_); + EXPECT_EQ(160, out_width_); + EXPECT_EQ(90, out_height_); } TEST_P(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) { @@ -1053,7 +1042,7 @@ TEST(VideoAdapterTestMultipleOrientation, TestForcePortrait) { EXPECT_EQ(640, out_height); } -TEST_P(VideoAdapterTest, AdaptResolutionInSteps) { +TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst3_4) { const int kWidth = 1280; const int kHeight = 720; OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 16:9 aspect. @@ -1081,40 +1070,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInSteps) { } } -// Scale factors are 3/4, 2/3, 3/4, 2/3, ... (see test above). -// In VideoAdapterTestVariableStartScale, first scale factor depends on -// resolution. May start with: -// - 2/3 (if width/height multiple of 3) or -// - 2/3, 2/3 (if width/height multiple of 9). -TEST_P(VideoAdapterTestVariableStartScale, AdaptResolutionInStepsFirst3_4) { - const int kWidth = 1280; - const int kHeight = 720; - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 16:9 aspect. - - // Scale factors: 3/4, 2/3, 3/4, 2/3, ... - // Scale : 3/4, 1/2, 3/8, 1/4, 3/16, 1/8. - const int kExpectedWidths[] = {960, 640, 480, 320, 240, 160}; - const int kExpectedHeights[] = {540, 360, 270, 180, 135, 90}; - - int request_width = kWidth; - int request_height = kHeight; - - for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { - // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, - request_width * request_height - 1, - std::numeric_limits::max())); - EXPECT_TRUE(adapter_.AdaptFrameResolution(kWidth, kHeight, 0, - &cropped_width_, &cropped_height_, - &out_width_, &out_height_)); - EXPECT_EQ(kExpectedWidths[i], out_width_); - EXPECT_EQ(kExpectedHeights[i], out_height_); - request_width = out_width_; - request_height = out_height_; - } -} - -TEST_P(VideoAdapterTestVariableStartScale, AdaptResolutionInStepsFirst2_3) { +TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2_3) { const int kWidth = 1920; const int kHeight = 1080; OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 16:9 aspect. @@ -1142,7 +1098,7 @@ TEST_P(VideoAdapterTestVariableStartScale, AdaptResolutionInStepsFirst2_3) { } } -TEST_P(VideoAdapterTestVariableStartScale, AdaptResolutionInStepsFirst2x2_3) { +TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2x2_3) { const int kWidth = 1440; const int kHeight = 1080; OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 4:3 aspect. diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 4082fd2dbf..334c773372 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -6918,10 +6918,10 @@ TEST_F(VideoStreamEncoderTest, TEST_F(VideoStreamEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) { const int kFrameWidth = 1920; const int kFrameHeight = 1080; - // 3/4 of 1920. - const int kAdaptedFrameWidth = 1440; - // 3/4 of 1080 rounded down to multiple of 4. - const int kAdaptedFrameHeight = 808; + // 2/3 of 1920. + const int kAdaptedFrameWidth = 1280; + // 2/3 of 1080. + const int kAdaptedFrameHeight = 720; const int kFramerate = 24; video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(