1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker *
4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker */
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker #include <string>
12*d9f75844SAndroid Build Coastguard Worker
13*d9f75844SAndroid Build Coastguard Worker #include "api/test/video/function_video_encoder_factory.h"
14*d9f75844SAndroid Build Coastguard Worker #include "media/engine/internal_encoder_factory.h"
15*d9f75844SAndroid Build Coastguard Worker #include "modules/video_coding/codecs/h264/include/h264.h"
16*d9f75844SAndroid Build Coastguard Worker #include "modules/video_coding/codecs/vp8/include/vp8.h"
17*d9f75844SAndroid Build Coastguard Worker #include "modules/video_coding/codecs/vp9/include/vp9.h"
18*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/experiments/encoder_info_settings.h"
19*d9f75844SAndroid Build Coastguard Worker #include "test/call_test.h"
20*d9f75844SAndroid Build Coastguard Worker #include "test/field_trial.h"
21*d9f75844SAndroid Build Coastguard Worker #include "test/frame_generator_capturer.h"
22*d9f75844SAndroid Build Coastguard Worker #include "video/config/encoder_stream_factory.h"
23*d9f75844SAndroid Build Coastguard Worker
24*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
25*d9f75844SAndroid Build Coastguard Worker namespace {
26*d9f75844SAndroid Build Coastguard Worker constexpr int kInitialWidth = 1280;
27*d9f75844SAndroid Build Coastguard Worker constexpr int kInitialHeight = 720;
28*d9f75844SAndroid Build Coastguard Worker constexpr int kLowStartBps = 100000;
29*d9f75844SAndroid Build Coastguard Worker constexpr int kHighStartBps = 1000000;
30*d9f75844SAndroid Build Coastguard Worker constexpr int kDefaultVgaMinStartBps = 500000; // From video_stream_encoder.cc
31*d9f75844SAndroid Build Coastguard Worker constexpr TimeDelta kTimeout =
32*d9f75844SAndroid Build Coastguard Worker TimeDelta::Seconds(10); // Some tests are expected to time out.
33*d9f75844SAndroid Build Coastguard Worker
SetEncoderSpecific(VideoEncoderConfig * encoder_config,VideoCodecType type,bool automatic_resize,size_t num_spatial_layers)34*d9f75844SAndroid Build Coastguard Worker void SetEncoderSpecific(VideoEncoderConfig* encoder_config,
35*d9f75844SAndroid Build Coastguard Worker VideoCodecType type,
36*d9f75844SAndroid Build Coastguard Worker bool automatic_resize,
37*d9f75844SAndroid Build Coastguard Worker size_t num_spatial_layers) {
38*d9f75844SAndroid Build Coastguard Worker if (type == kVideoCodecVP8) {
39*d9f75844SAndroid Build Coastguard Worker VideoCodecVP8 vp8 = VideoEncoder::GetDefaultVp8Settings();
40*d9f75844SAndroid Build Coastguard Worker vp8.automaticResizeOn = automatic_resize;
41*d9f75844SAndroid Build Coastguard Worker encoder_config->encoder_specific_settings =
42*d9f75844SAndroid Build Coastguard Worker rtc::make_ref_counted<VideoEncoderConfig::Vp8EncoderSpecificSettings>(
43*d9f75844SAndroid Build Coastguard Worker vp8);
44*d9f75844SAndroid Build Coastguard Worker } else if (type == kVideoCodecVP9) {
45*d9f75844SAndroid Build Coastguard Worker VideoCodecVP9 vp9 = VideoEncoder::GetDefaultVp9Settings();
46*d9f75844SAndroid Build Coastguard Worker vp9.automaticResizeOn = automatic_resize;
47*d9f75844SAndroid Build Coastguard Worker vp9.numberOfSpatialLayers = num_spatial_layers;
48*d9f75844SAndroid Build Coastguard Worker encoder_config->encoder_specific_settings =
49*d9f75844SAndroid Build Coastguard Worker rtc::make_ref_counted<VideoEncoderConfig::Vp9EncoderSpecificSettings>(
50*d9f75844SAndroid Build Coastguard Worker vp9);
51*d9f75844SAndroid Build Coastguard Worker }
52*d9f75844SAndroid Build Coastguard Worker }
53*d9f75844SAndroid Build Coastguard Worker } // namespace
54*d9f75844SAndroid Build Coastguard Worker
55*d9f75844SAndroid Build Coastguard Worker class QualityScalingTest : public test::CallTest {
56*d9f75844SAndroid Build Coastguard Worker protected:
57*d9f75844SAndroid Build Coastguard Worker const std::string kPrefix = "WebRTC-Video-QualityScaling/Enabled-";
58*d9f75844SAndroid Build Coastguard Worker const std::string kEnd = ",0,0,0.9995,0.9999,1/";
59*d9f75844SAndroid Build Coastguard Worker const absl::optional<VideoEncoder::ResolutionBitrateLimits>
60*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8 =
61*d9f75844SAndroid Build Coastguard Worker EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsForResolution(
62*d9f75844SAndroid Build Coastguard Worker kVideoCodecVP8,
63*d9f75844SAndroid Build Coastguard Worker 1280 * 720);
64*d9f75844SAndroid Build Coastguard Worker const absl::optional<VideoEncoder::ResolutionBitrateLimits>
65*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits360pVp9 =
66*d9f75844SAndroid Build Coastguard Worker EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsForResolution(
67*d9f75844SAndroid Build Coastguard Worker kVideoCodecVP9,
68*d9f75844SAndroid Build Coastguard Worker 640 * 360);
69*d9f75844SAndroid Build Coastguard Worker const absl::optional<VideoEncoder::ResolutionBitrateLimits>
70*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp9 =
71*d9f75844SAndroid Build Coastguard Worker EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsForResolution(
72*d9f75844SAndroid Build Coastguard Worker kVideoCodecVP9,
73*d9f75844SAndroid Build Coastguard Worker 1280 * 720);
74*d9f75844SAndroid Build Coastguard Worker };
75*d9f75844SAndroid Build Coastguard Worker
76*d9f75844SAndroid Build Coastguard Worker class ScalingObserver : public test::SendTest {
77*d9f75844SAndroid Build Coastguard Worker protected:
78*d9f75844SAndroid Build Coastguard Worker struct TestParams {
79*d9f75844SAndroid Build Coastguard Worker bool active;
80*d9f75844SAndroid Build Coastguard Worker absl::optional<ScalabilityMode> scalability_mode;
81*d9f75844SAndroid Build Coastguard Worker };
ScalingObserver(const std::string & payload_name,const std::vector<TestParams> & test_params,int start_bps,bool automatic_resize,bool expect_scaling)82*d9f75844SAndroid Build Coastguard Worker ScalingObserver(const std::string& payload_name,
83*d9f75844SAndroid Build Coastguard Worker const std::vector<TestParams>& test_params,
84*d9f75844SAndroid Build Coastguard Worker int start_bps,
85*d9f75844SAndroid Build Coastguard Worker bool automatic_resize,
86*d9f75844SAndroid Build Coastguard Worker bool expect_scaling)
87*d9f75844SAndroid Build Coastguard Worker : SendTest(expect_scaling ? kTimeout * 4 : kTimeout),
88*d9f75844SAndroid Build Coastguard Worker encoder_factory_(
89*d9f75844SAndroid Build Coastguard Worker [](const SdpVideoFormat& format) -> std::unique_ptr<VideoEncoder> {
90*d9f75844SAndroid Build Coastguard Worker if (format.name == "VP8")
91*d9f75844SAndroid Build Coastguard Worker return VP8Encoder::Create();
92*d9f75844SAndroid Build Coastguard Worker if (format.name == "VP9")
93*d9f75844SAndroid Build Coastguard Worker return VP9Encoder::Create();
94*d9f75844SAndroid Build Coastguard Worker if (format.name == "H264")
95*d9f75844SAndroid Build Coastguard Worker return H264Encoder::Create(cricket::VideoCodec("H264"));
96*d9f75844SAndroid Build Coastguard Worker RTC_DCHECK_NOTREACHED() << format.name;
97*d9f75844SAndroid Build Coastguard Worker return nullptr;
98*d9f75844SAndroid Build Coastguard Worker }),
99*d9f75844SAndroid Build Coastguard Worker payload_name_(payload_name),
100*d9f75844SAndroid Build Coastguard Worker test_params_(test_params),
101*d9f75844SAndroid Build Coastguard Worker start_bps_(start_bps),
102*d9f75844SAndroid Build Coastguard Worker automatic_resize_(automatic_resize),
103*d9f75844SAndroid Build Coastguard Worker expect_scaling_(expect_scaling) {}
104*d9f75844SAndroid Build Coastguard Worker
105*d9f75844SAndroid Build Coastguard Worker DegradationPreference degradation_preference_ =
106*d9f75844SAndroid Build Coastguard Worker DegradationPreference::MAINTAIN_FRAMERATE;
107*d9f75844SAndroid Build Coastguard Worker
108*d9f75844SAndroid Build Coastguard Worker private:
ModifySenderBitrateConfig(BitrateConstraints * bitrate_config)109*d9f75844SAndroid Build Coastguard Worker void ModifySenderBitrateConfig(BitrateConstraints* bitrate_config) override {
110*d9f75844SAndroid Build Coastguard Worker bitrate_config->start_bitrate_bps = start_bps_;
111*d9f75844SAndroid Build Coastguard Worker }
112*d9f75844SAndroid Build Coastguard Worker
ModifyVideoDegradationPreference(DegradationPreference * degradation_preference)113*d9f75844SAndroid Build Coastguard Worker void ModifyVideoDegradationPreference(
114*d9f75844SAndroid Build Coastguard Worker DegradationPreference* degradation_preference) override {
115*d9f75844SAndroid Build Coastguard Worker *degradation_preference = degradation_preference_;
116*d9f75844SAndroid Build Coastguard Worker }
117*d9f75844SAndroid Build Coastguard Worker
GetNumVideoStreams() const118*d9f75844SAndroid Build Coastguard Worker size_t GetNumVideoStreams() const override {
119*d9f75844SAndroid Build Coastguard Worker return (payload_name_ == "VP9") ? 1 : test_params_.size();
120*d9f75844SAndroid Build Coastguard Worker }
121*d9f75844SAndroid Build Coastguard Worker
ModifyVideoConfigs(VideoSendStream::Config * send_config,std::vector<VideoReceiveStreamInterface::Config> * receive_configs,VideoEncoderConfig * encoder_config)122*d9f75844SAndroid Build Coastguard Worker void ModifyVideoConfigs(
123*d9f75844SAndroid Build Coastguard Worker VideoSendStream::Config* send_config,
124*d9f75844SAndroid Build Coastguard Worker std::vector<VideoReceiveStreamInterface::Config>* receive_configs,
125*d9f75844SAndroid Build Coastguard Worker VideoEncoderConfig* encoder_config) override {
126*d9f75844SAndroid Build Coastguard Worker VideoEncoder::EncoderInfo encoder_info;
127*d9f75844SAndroid Build Coastguard Worker send_config->encoder_settings.encoder_factory = &encoder_factory_;
128*d9f75844SAndroid Build Coastguard Worker send_config->rtp.payload_name = payload_name_;
129*d9f75844SAndroid Build Coastguard Worker send_config->rtp.payload_type = test::CallTest::kVideoSendPayloadType;
130*d9f75844SAndroid Build Coastguard Worker encoder_config->video_format.name = payload_name_;
131*d9f75844SAndroid Build Coastguard Worker const VideoCodecType codec_type = PayloadStringToCodecType(payload_name_);
132*d9f75844SAndroid Build Coastguard Worker encoder_config->codec_type = codec_type;
133*d9f75844SAndroid Build Coastguard Worker encoder_config->video_stream_factory =
134*d9f75844SAndroid Build Coastguard Worker rtc::make_ref_counted<cricket::EncoderStreamFactory>(
135*d9f75844SAndroid Build Coastguard Worker payload_name_, /*max_qp=*/0, /*is_screenshare=*/false,
136*d9f75844SAndroid Build Coastguard Worker /*conference_mode=*/false, encoder_info);
137*d9f75844SAndroid Build Coastguard Worker encoder_config->max_bitrate_bps =
138*d9f75844SAndroid Build Coastguard Worker std::max(start_bps_, encoder_config->max_bitrate_bps);
139*d9f75844SAndroid Build Coastguard Worker if (payload_name_ == "VP9") {
140*d9f75844SAndroid Build Coastguard Worker // Simulcast layers indicates which spatial layers are active.
141*d9f75844SAndroid Build Coastguard Worker encoder_config->simulcast_layers.resize(test_params_.size());
142*d9f75844SAndroid Build Coastguard Worker encoder_config->simulcast_layers[0].max_bitrate_bps =
143*d9f75844SAndroid Build Coastguard Worker encoder_config->max_bitrate_bps;
144*d9f75844SAndroid Build Coastguard Worker }
145*d9f75844SAndroid Build Coastguard Worker double scale_factor = 1.0;
146*d9f75844SAndroid Build Coastguard Worker for (int i = test_params_.size() - 1; i >= 0; --i) {
147*d9f75844SAndroid Build Coastguard Worker VideoStream& stream = encoder_config->simulcast_layers[i];
148*d9f75844SAndroid Build Coastguard Worker stream.active = test_params_[i].active;
149*d9f75844SAndroid Build Coastguard Worker stream.scalability_mode = test_params_[i].scalability_mode;
150*d9f75844SAndroid Build Coastguard Worker stream.scale_resolution_down_by = scale_factor;
151*d9f75844SAndroid Build Coastguard Worker scale_factor *= (payload_name_ == "VP9") ? 1.0 : 2.0;
152*d9f75844SAndroid Build Coastguard Worker }
153*d9f75844SAndroid Build Coastguard Worker encoder_config->frame_drop_enabled = true;
154*d9f75844SAndroid Build Coastguard Worker SetEncoderSpecific(encoder_config, codec_type, automatic_resize_,
155*d9f75844SAndroid Build Coastguard Worker test_params_.size());
156*d9f75844SAndroid Build Coastguard Worker }
157*d9f75844SAndroid Build Coastguard Worker
PerformTest()158*d9f75844SAndroid Build Coastguard Worker void PerformTest() override { EXPECT_EQ(expect_scaling_, Wait()); }
159*d9f75844SAndroid Build Coastguard Worker
160*d9f75844SAndroid Build Coastguard Worker test::FunctionVideoEncoderFactory encoder_factory_;
161*d9f75844SAndroid Build Coastguard Worker const std::string payload_name_;
162*d9f75844SAndroid Build Coastguard Worker const std::vector<TestParams> test_params_;
163*d9f75844SAndroid Build Coastguard Worker const int start_bps_;
164*d9f75844SAndroid Build Coastguard Worker const bool automatic_resize_;
165*d9f75844SAndroid Build Coastguard Worker const bool expect_scaling_;
166*d9f75844SAndroid Build Coastguard Worker };
167*d9f75844SAndroid Build Coastguard Worker
168*d9f75844SAndroid Build Coastguard Worker class DownscalingObserver
169*d9f75844SAndroid Build Coastguard Worker : public ScalingObserver,
170*d9f75844SAndroid Build Coastguard Worker public test::FrameGeneratorCapturer::SinkWantsObserver {
171*d9f75844SAndroid Build Coastguard Worker public:
DownscalingObserver(const std::string & payload_name,const std::vector<TestParams> & test_params,int start_bps,bool automatic_resize,bool expect_downscale)172*d9f75844SAndroid Build Coastguard Worker DownscalingObserver(const std::string& payload_name,
173*d9f75844SAndroid Build Coastguard Worker const std::vector<TestParams>& test_params,
174*d9f75844SAndroid Build Coastguard Worker int start_bps,
175*d9f75844SAndroid Build Coastguard Worker bool automatic_resize,
176*d9f75844SAndroid Build Coastguard Worker bool expect_downscale)
177*d9f75844SAndroid Build Coastguard Worker : ScalingObserver(payload_name,
178*d9f75844SAndroid Build Coastguard Worker test_params,
179*d9f75844SAndroid Build Coastguard Worker start_bps,
180*d9f75844SAndroid Build Coastguard Worker automatic_resize,
181*d9f75844SAndroid Build Coastguard Worker expect_downscale) {}
182*d9f75844SAndroid Build Coastguard Worker
183*d9f75844SAndroid Build Coastguard Worker private:
OnFrameGeneratorCapturerCreated(test::FrameGeneratorCapturer * frame_generator_capturer)184*d9f75844SAndroid Build Coastguard Worker void OnFrameGeneratorCapturerCreated(
185*d9f75844SAndroid Build Coastguard Worker test::FrameGeneratorCapturer* frame_generator_capturer) override {
186*d9f75844SAndroid Build Coastguard Worker frame_generator_capturer->SetSinkWantsObserver(this);
187*d9f75844SAndroid Build Coastguard Worker frame_generator_capturer->ChangeResolution(kInitialWidth, kInitialHeight);
188*d9f75844SAndroid Build Coastguard Worker }
189*d9f75844SAndroid Build Coastguard Worker
OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame> * sink,const rtc::VideoSinkWants & wants)190*d9f75844SAndroid Build Coastguard Worker void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
191*d9f75844SAndroid Build Coastguard Worker const rtc::VideoSinkWants& wants) override {
192*d9f75844SAndroid Build Coastguard Worker if (wants.max_pixel_count < kInitialWidth * kInitialHeight)
193*d9f75844SAndroid Build Coastguard Worker observation_complete_.Set();
194*d9f75844SAndroid Build Coastguard Worker }
195*d9f75844SAndroid Build Coastguard Worker };
196*d9f75844SAndroid Build Coastguard Worker
197*d9f75844SAndroid Build Coastguard Worker class UpscalingObserver
198*d9f75844SAndroid Build Coastguard Worker : public ScalingObserver,
199*d9f75844SAndroid Build Coastguard Worker public test::FrameGeneratorCapturer::SinkWantsObserver {
200*d9f75844SAndroid Build Coastguard Worker public:
UpscalingObserver(const std::string & payload_name,const std::vector<TestParams> & test_params,int start_bps,bool automatic_resize,bool expect_upscale)201*d9f75844SAndroid Build Coastguard Worker UpscalingObserver(const std::string& payload_name,
202*d9f75844SAndroid Build Coastguard Worker const std::vector<TestParams>& test_params,
203*d9f75844SAndroid Build Coastguard Worker int start_bps,
204*d9f75844SAndroid Build Coastguard Worker bool automatic_resize,
205*d9f75844SAndroid Build Coastguard Worker bool expect_upscale)
206*d9f75844SAndroid Build Coastguard Worker : ScalingObserver(payload_name,
207*d9f75844SAndroid Build Coastguard Worker test_params,
208*d9f75844SAndroid Build Coastguard Worker start_bps,
209*d9f75844SAndroid Build Coastguard Worker automatic_resize,
210*d9f75844SAndroid Build Coastguard Worker expect_upscale) {}
211*d9f75844SAndroid Build Coastguard Worker
SetDegradationPreference(DegradationPreference preference)212*d9f75844SAndroid Build Coastguard Worker void SetDegradationPreference(DegradationPreference preference) {
213*d9f75844SAndroid Build Coastguard Worker degradation_preference_ = preference;
214*d9f75844SAndroid Build Coastguard Worker }
215*d9f75844SAndroid Build Coastguard Worker
216*d9f75844SAndroid Build Coastguard Worker private:
OnFrameGeneratorCapturerCreated(test::FrameGeneratorCapturer * frame_generator_capturer)217*d9f75844SAndroid Build Coastguard Worker void OnFrameGeneratorCapturerCreated(
218*d9f75844SAndroid Build Coastguard Worker test::FrameGeneratorCapturer* frame_generator_capturer) override {
219*d9f75844SAndroid Build Coastguard Worker frame_generator_capturer->SetSinkWantsObserver(this);
220*d9f75844SAndroid Build Coastguard Worker frame_generator_capturer->ChangeResolution(kInitialWidth, kInitialHeight);
221*d9f75844SAndroid Build Coastguard Worker }
222*d9f75844SAndroid Build Coastguard Worker
OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame> * sink,const rtc::VideoSinkWants & wants)223*d9f75844SAndroid Build Coastguard Worker void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
224*d9f75844SAndroid Build Coastguard Worker const rtc::VideoSinkWants& wants) override {
225*d9f75844SAndroid Build Coastguard Worker if (wants.max_pixel_count > last_wants_.max_pixel_count) {
226*d9f75844SAndroid Build Coastguard Worker if (wants.max_pixel_count == std::numeric_limits<int>::max())
227*d9f75844SAndroid Build Coastguard Worker observation_complete_.Set();
228*d9f75844SAndroid Build Coastguard Worker }
229*d9f75844SAndroid Build Coastguard Worker last_wants_ = wants;
230*d9f75844SAndroid Build Coastguard Worker }
231*d9f75844SAndroid Build Coastguard Worker
232*d9f75844SAndroid Build Coastguard Worker rtc::VideoSinkWants last_wants_;
233*d9f75844SAndroid Build Coastguard Worker };
234*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForHighQp_Vp8)235*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp8) {
236*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
237*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
238*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,1,0,0,0,0" + kEnd);
239*d9f75844SAndroid Build Coastguard Worker
240*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps,
241*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
242*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
243*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
244*d9f75844SAndroid Build Coastguard Worker }
245*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForHighQpIfScalingOff_Vp8)246*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp8) {
247*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
248*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
249*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,1,0,0,0,0" + kEnd);
250*d9f75844SAndroid Build Coastguard Worker
251*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps,
252*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/false,
253*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
254*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
255*d9f75844SAndroid Build Coastguard Worker }
256*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForNormalQp_Vp8)257*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForNormalQp_Vp8) {
258*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
259*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
260*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
261*d9f75844SAndroid Build Coastguard Worker
262*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}}, kHighStartBps,
263*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
264*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
265*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
266*d9f75844SAndroid Build Coastguard Worker }
267*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrate_Vp8)268*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp8) {
269*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
270*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
271*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
272*d9f75844SAndroid Build Coastguard Worker
273*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}}, kLowStartBps,
274*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
275*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
276*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
277*d9f75844SAndroid Build Coastguard Worker }
278*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrateAndThenUp)279*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrateAndThenUp) {
280*d9f75844SAndroid Build Coastguard Worker // qp_low:127, qp_high:127 -> kLowQp
281*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(
282*d9f75844SAndroid Build Coastguard Worker field_trials_,
283*d9f75844SAndroid Build Coastguard Worker kPrefix + "127,127,0,0,0,0" + kEnd +
284*d9f75844SAndroid Build Coastguard Worker "WebRTC-Video-BalancedDegradationSettings/"
285*d9f75844SAndroid Build Coastguard Worker "pixels:230400|921600,fps:20|30,kbps:300|500/"); // should not affect
286*d9f75844SAndroid Build Coastguard Worker
287*d9f75844SAndroid Build Coastguard Worker UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1,
288*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true, /*expect_upscale=*/true);
289*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
290*d9f75844SAndroid Build Coastguard Worker }
291*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownAndThenUpWithBalanced)292*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownAndThenUpWithBalanced) {
293*d9f75844SAndroid Build Coastguard Worker // qp_low:127, qp_high:127 -> kLowQp
294*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(
295*d9f75844SAndroid Build Coastguard Worker field_trials_, kPrefix + "127,127,0,0,0,0" + kEnd +
296*d9f75844SAndroid Build Coastguard Worker "WebRTC-Video-BalancedDegradationSettings/"
297*d9f75844SAndroid Build Coastguard Worker "pixels:230400|921600,fps:20|30,kbps:300|499/");
298*d9f75844SAndroid Build Coastguard Worker
299*d9f75844SAndroid Build Coastguard Worker UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1,
300*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true, /*expect_upscale=*/true);
301*d9f75844SAndroid Build Coastguard Worker test.SetDegradationPreference(DegradationPreference::BALANCED);
302*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
303*d9f75844SAndroid Build Coastguard Worker }
304*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownButNotUpWithBalancedIfBitrateNotEnough)305*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownButNotUpWithBalancedIfBitrateNotEnough) {
306*d9f75844SAndroid Build Coastguard Worker // qp_low:127, qp_high:127 -> kLowQp
307*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(
308*d9f75844SAndroid Build Coastguard Worker field_trials_, kPrefix + "127,127,0,0,0,0" + kEnd +
309*d9f75844SAndroid Build Coastguard Worker "WebRTC-Video-BalancedDegradationSettings/"
310*d9f75844SAndroid Build Coastguard Worker "pixels:230400|921600,fps:20|30,kbps:300|500/");
311*d9f75844SAndroid Build Coastguard Worker
312*d9f75844SAndroid Build Coastguard Worker UpscalingObserver test("VP8", {{.active = true}}, kDefaultVgaMinStartBps - 1,
313*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true, /*expect_upscale=*/false);
314*d9f75844SAndroid Build Coastguard Worker test.SetDegradationPreference(DegradationPreference::BALANCED);
315*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
316*d9f75844SAndroid Build Coastguard Worker }
317*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrate_Simulcast)318*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_Simulcast) {
319*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
320*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
321*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
322*d9f75844SAndroid Build Coastguard Worker
323*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}, {.active = true}},
324*d9f75844SAndroid Build Coastguard Worker kLowStartBps,
325*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/false,
326*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
327*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
328*d9f75844SAndroid Build Coastguard Worker }
329*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForHighQp_HighestStreamActive_Vp8)330*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForHighQp_HighestStreamActive_Vp8) {
331*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
332*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
333*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,1,0,0,0,0" + kEnd);
334*d9f75844SAndroid Build Coastguard Worker
335*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
336*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = false}, {.active = false}, {.active = true}},
337*d9f75844SAndroid Build Coastguard Worker kHighStartBps,
338*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
339*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
340*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
341*d9f75844SAndroid Build Coastguard Worker }
342*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrate_HighestStreamActive_Vp8)343*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
344*d9f75844SAndroid Build Coastguard Worker AdaptsDownForLowStartBitrate_HighestStreamActive_Vp8) {
345*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
346*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
347*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
348*d9f75844SAndroid Build Coastguard Worker
349*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
350*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = false}, {.active = false}, {.active = true}},
351*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8->min_start_bitrate_bps - 1,
352*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
353*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
354*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
355*d9f75844SAndroid Build Coastguard Worker }
356*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownButNotUpWithMinStartBitrateLimit)357*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimit) {
358*d9f75844SAndroid Build Coastguard Worker // qp_low:127, qp_high:127 -> kLowQp
359*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
360*d9f75844SAndroid Build Coastguard Worker kPrefix + "127,127,0,0,0,0" + kEnd);
361*d9f75844SAndroid Build Coastguard Worker
362*d9f75844SAndroid Build Coastguard Worker UpscalingObserver test("VP8", {{.active = false}, {.active = true}},
363*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8->min_start_bitrate_bps - 1,
364*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true, /*expect_upscale=*/false);
365*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
366*d9f75844SAndroid Build Coastguard Worker }
367*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8)368*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8) {
369*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
370*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
371*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
372*d9f75844SAndroid Build Coastguard Worker
373*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
374*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = false}, {.active = false}, {.active = true}},
375*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8->min_start_bitrate_bps,
376*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
377*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
378*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
379*d9f75844SAndroid Build Coastguard Worker }
380*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrateIfDefaultLimitsDisabled_Vp8)381*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
382*d9f75844SAndroid Build Coastguard Worker NoAdaptDownForLowStartBitrateIfDefaultLimitsDisabled_Vp8) {
383*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
384*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(
385*d9f75844SAndroid Build Coastguard Worker field_trials_, kPrefix + "1,127,0,0,0,0" + kEnd +
386*d9f75844SAndroid Build Coastguard Worker "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/");
387*d9f75844SAndroid Build Coastguard Worker
388*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
389*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = false}, {.active = false}, {.active = true}},
390*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8->min_start_bitrate_bps - 1,
391*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
392*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
393*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
394*d9f75844SAndroid Build Coastguard Worker }
395*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrate_OneStreamSinglecastLimitsNotUsed_Vp8)396*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
397*d9f75844SAndroid Build Coastguard Worker NoAdaptDownForLowStartBitrate_OneStreamSinglecastLimitsNotUsed_Vp8) {
398*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
399*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
400*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
401*d9f75844SAndroid Build Coastguard Worker
402*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}},
403*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp8->min_start_bitrate_bps - 1,
404*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
405*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
406*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
407*d9f75844SAndroid Build Coastguard Worker }
408*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForHighQp_LowestStreamActive_Vp8)409*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp8) {
410*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
411*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
412*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,1,0,0,0,0" + kEnd);
413*d9f75844SAndroid Build Coastguard Worker
414*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
415*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = true}, {.active = false}, {.active = false}},
416*d9f75844SAndroid Build Coastguard Worker kHighStartBps,
417*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
418*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
419*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
420*d9f75844SAndroid Build Coastguard Worker }
421*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp8)422*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
423*d9f75844SAndroid Build Coastguard Worker NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp8) {
424*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
425*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
426*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
427*d9f75844SAndroid Build Coastguard Worker
428*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
429*d9f75844SAndroid Build Coastguard Worker "VP8", {{.active = true}, {.active = false}, {.active = false}},
430*d9f75844SAndroid Build Coastguard Worker kLowStartBps,
431*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
432*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
433*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
434*d9f75844SAndroid Build Coastguard Worker }
435*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrateIfScalingOff_Vp8)436*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfScalingOff_Vp8) {
437*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:127 -> kNormalQp
438*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
439*d9f75844SAndroid Build Coastguard Worker kPrefix + "1,127,0,0,0,0" + kEnd);
440*d9f75844SAndroid Build Coastguard Worker
441*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP8", {{.active = true}}, kLowStartBps,
442*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/false,
443*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
444*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
445*d9f75844SAndroid Build Coastguard Worker }
446*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForHighQp_Vp9)447*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp9) {
448*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
449*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
450*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,1,0,0" + kEnd);
451*d9f75844SAndroid Build Coastguard Worker
452*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP9", {{.active = true}}, kHighStartBps,
453*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
454*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
455*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
456*d9f75844SAndroid Build Coastguard Worker }
457*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForHighQpIfScalingOff_Vp9)458*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp9) {
459*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
460*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(
461*d9f75844SAndroid Build Coastguard Worker field_trials_,
462*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Disabled/");
463*d9f75844SAndroid Build Coastguard Worker
464*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP9", {{.active = true}}, kHighStartBps,
465*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
466*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
467*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
468*d9f75844SAndroid Build Coastguard Worker }
469*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrate_Vp9)470*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp9) {
471*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:255 -> kNormalQp
472*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
473*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,255,0,0" + kEnd);
474*d9f75844SAndroid Build Coastguard Worker
475*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("VP9", {{.active = true}}, kLowStartBps,
476*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
477*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
478*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
479*d9f75844SAndroid Build Coastguard Worker }
480*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForHighStartBitrate_Vp9)481*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForHighStartBitrate_Vp9) {
482*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
483*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = false}, {.active = false}, {.active = true}},
484*d9f75844SAndroid Build Coastguard Worker kHighStartBps,
485*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
486*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
487*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
488*d9f75844SAndroid Build Coastguard Worker }
489*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForHighQp_LowestStreamActive_Vp9)490*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp9) {
491*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
492*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
493*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,1,0,0" + kEnd);
494*d9f75844SAndroid Build Coastguard Worker
495*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
496*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = true}, {.active = false}, {.active = false}},
497*d9f75844SAndroid Build Coastguard Worker kHighStartBps,
498*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
499*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
500*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
501*d9f75844SAndroid Build Coastguard Worker }
502*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp9)503*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
504*d9f75844SAndroid Build Coastguard Worker NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp9) {
505*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:255 -> kNormalQp
506*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
507*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,255,0,0" + kEnd);
508*d9f75844SAndroid Build Coastguard Worker
509*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
510*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = true}, {.active = false}, {.active = false}},
511*d9f75844SAndroid Build Coastguard Worker kLowStartBps,
512*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
513*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
514*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
515*d9f75844SAndroid Build Coastguard Worker }
516*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForHighQp_MiddleStreamActive_Vp9)517*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForHighQp_MiddleStreamActive_Vp9) {
518*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
519*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
520*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,1,0,0" + kEnd);
521*d9f75844SAndroid Build Coastguard Worker
522*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
523*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = false}, {.active = true}, {.active = false}},
524*d9f75844SAndroid Build Coastguard Worker kHighStartBps,
525*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
526*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
527*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
528*d9f75844SAndroid Build Coastguard Worker }
529*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrate_MiddleStreamActive_Vp9)530*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
531*d9f75844SAndroid Build Coastguard Worker AdaptsDownForLowStartBitrate_MiddleStreamActive_Vp9) {
532*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:255 -> kNormalQp
533*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
534*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,255,0,0" + kEnd);
535*d9f75844SAndroid Build Coastguard Worker
536*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
537*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = false}, {.active = true}, {.active = false}},
538*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits360pVp9->min_start_bitrate_bps - 1,
539*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
540*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
541*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
542*d9f75844SAndroid Build Coastguard Worker }
543*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9)544*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9) {
545*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:255 -> kNormalQp
546*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
547*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,255,0,0" + kEnd);
548*d9f75844SAndroid Build Coastguard Worker
549*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
550*d9f75844SAndroid Build Coastguard Worker "VP9", {{.active = false}, {.active = true}, {.active = false}},
551*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits360pVp9->min_start_bitrate_bps,
552*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
553*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
554*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
555*d9f75844SAndroid Build Coastguard Worker }
556*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownButNotUpWithMinStartBitrateLimitWithScalabilityMode_VP9)557*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
558*d9f75844SAndroid Build Coastguard Worker AdaptsDownButNotUpWithMinStartBitrateLimitWithScalabilityMode_VP9) {
559*d9f75844SAndroid Build Coastguard Worker // qp_low:255, qp_high:255 -> kLowQp
560*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
561*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,255,255,0,0" + kEnd);
562*d9f75844SAndroid Build Coastguard Worker
563*d9f75844SAndroid Build Coastguard Worker UpscalingObserver test(
564*d9f75844SAndroid Build Coastguard Worker "VP9",
565*d9f75844SAndroid Build Coastguard Worker {{.active = true, .scalability_mode = ScalabilityMode::kL1T3},
566*d9f75844SAndroid Build Coastguard Worker {.active = false}},
567*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp9->min_start_bitrate_bps - 1,
568*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true, /*expect_upscale=*/false);
569*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
570*d9f75844SAndroid Build Coastguard Worker }
571*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,NoAdaptDownForLowStartBitrateIfBitrateEnoughWithScalabilityMode_Vp9)572*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest,
573*d9f75844SAndroid Build Coastguard Worker NoAdaptDownForLowStartBitrateIfBitrateEnoughWithScalabilityMode_Vp9) {
574*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:255 -> kNormalQp
575*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
576*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,1,255,0,0" + kEnd);
577*d9f75844SAndroid Build Coastguard Worker
578*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test(
579*d9f75844SAndroid Build Coastguard Worker "VP9",
580*d9f75844SAndroid Build Coastguard Worker {{.active = true, .scalability_mode = ScalabilityMode::kL1T3},
581*d9f75844SAndroid Build Coastguard Worker {.active = false},
582*d9f75844SAndroid Build Coastguard Worker {.active = false}},
583*d9f75844SAndroid Build Coastguard Worker kSinglecastLimits720pVp9->min_start_bitrate_bps,
584*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
585*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/false);
586*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
587*d9f75844SAndroid Build Coastguard Worker }
588*d9f75844SAndroid Build Coastguard Worker
589*d9f75844SAndroid Build Coastguard Worker #if defined(WEBRTC_USE_H264)
TEST_F(QualityScalingTest,AdaptsDownForHighQp_H264)590*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForHighQp_H264) {
591*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:1 -> kHighQp
592*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
593*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,0,0,1,1" + kEnd);
594*d9f75844SAndroid Build Coastguard Worker
595*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("H264", {{.active = true}}, kHighStartBps,
596*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
597*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
598*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
599*d9f75844SAndroid Build Coastguard Worker }
600*d9f75844SAndroid Build Coastguard Worker
TEST_F(QualityScalingTest,AdaptsDownForLowStartBitrate_H264)601*d9f75844SAndroid Build Coastguard Worker TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_H264) {
602*d9f75844SAndroid Build Coastguard Worker // qp_low:1, qp_high:51 -> kNormalQp
603*d9f75844SAndroid Build Coastguard Worker test::ScopedKeyValueConfig field_trials(field_trials_,
604*d9f75844SAndroid Build Coastguard Worker kPrefix + "0,0,0,0,1,51" + kEnd);
605*d9f75844SAndroid Build Coastguard Worker
606*d9f75844SAndroid Build Coastguard Worker DownscalingObserver test("H264", {{.active = true}}, kLowStartBps,
607*d9f75844SAndroid Build Coastguard Worker /*automatic_resize=*/true,
608*d9f75844SAndroid Build Coastguard Worker /*expect_downscale=*/true);
609*d9f75844SAndroid Build Coastguard Worker RunBaseTest(&test);
610*d9f75844SAndroid Build Coastguard Worker }
611*d9f75844SAndroid Build Coastguard Worker #endif // defined(WEBRTC_USE_H264)
612*d9f75844SAndroid Build Coastguard Worker
613*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc
614