Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "media/engine/videoencodersoftwarefallbackwrapper.h" |
magjed | 614d5b7 | 2016-11-15 06:30:54 -0800 | [diff] [blame] | 12 | |
| 13 | #include <utility> |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "api/video/i420_buffer.h" |
Magnus Jedvert | ee92d62 | 2017-11-13 15:26:17 +0100 | [diff] [blame] | 16 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "modules/video_coding/codecs/vp8/simulcast_rate_allocator.h" |
| 18 | #include "modules/video_coding/codecs/vp8/temporal_layers.h" |
| 19 | #include "modules/video_coding/include/video_codec_interface.h" |
| 20 | #include "modules/video_coding/include/video_error_codes.h" |
| 21 | #include "rtc_base/checks.h" |
| 22 | #include "rtc_base/fakeclock.h" |
| 23 | #include "test/field_trial.h" |
| 24 | #include "test/gtest.h" |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 27 | namespace { |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 28 | const int kWidth = 320; |
| 29 | const int kHeight = 240; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 30 | const int kNumCores = 2; |
| 31 | const uint32_t kFramerate = 30; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 32 | const size_t kMaxPayloadSize = 800; |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 33 | const int kDefaultMinPixelsPerFrame = 320 * 180; |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 34 | const int kLowThreshold = 10; |
| 35 | const int kHighThreshold = 20; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 36 | } // namespace |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 37 | |
| 38 | class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test { |
| 39 | protected: |
| 40 | VideoEncoderSoftwareFallbackWrapperTest() |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 41 | : VideoEncoderSoftwareFallbackWrapperTest("") {} |
| 42 | explicit VideoEncoderSoftwareFallbackWrapperTest( |
| 43 | const std::string& field_trials) |
| 44 | : override_field_trials_(field_trials), |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 45 | fake_encoder_(new CountingFakeEncoder()), |
Magnus Jedvert | ee92d62 | 2017-11-13 15:26:17 +0100 | [diff] [blame] | 46 | fallback_wrapper_(std::unique_ptr<VideoEncoder>(VP8Encoder::Create()), |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 47 | std::unique_ptr<VideoEncoder>(fake_encoder_)) {} |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 48 | |
| 49 | class CountingFakeEncoder : public VideoEncoder { |
| 50 | public: |
| 51 | int32_t InitEncode(const VideoCodec* codec_settings, |
| 52 | int32_t number_of_cores, |
| 53 | size_t max_payload_size) override { |
| 54 | ++init_encode_count_; |
| 55 | return init_encode_return_code_; |
| 56 | } |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame] | 57 | int32_t Encode(const VideoFrame& frame, |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 58 | const CodecSpecificInfo* codec_specific_info, |
pbos | 22993e1 | 2015-10-19 02:39:06 -0700 | [diff] [blame] | 59 | const std::vector<FrameType>* frame_types) override { |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 60 | ++encode_count_; |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 61 | if (encode_complete_callback_ && |
| 62 | encode_return_code_ == WEBRTC_VIDEO_CODEC_OK) { |
| 63 | CodecSpecificInfo info; |
| 64 | info.codec_name = ImplementationName(); |
| 65 | encode_complete_callback_->OnEncodedImage(EncodedImage(), &info, |
| 66 | nullptr); |
| 67 | } |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 68 | return encode_return_code_; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | int32_t RegisterEncodeCompleteCallback( |
| 72 | EncodedImageCallback* callback) override { |
| 73 | encode_complete_callback_ = callback; |
| 74 | return WEBRTC_VIDEO_CODEC_OK; |
| 75 | } |
| 76 | |
| 77 | int32_t Release() override { |
| 78 | ++release_count_; |
| 79 | return WEBRTC_VIDEO_CODEC_OK; |
| 80 | } |
| 81 | |
| 82 | int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override { |
| 83 | ++set_channel_parameters_count_; |
| 84 | return WEBRTC_VIDEO_CODEC_OK; |
| 85 | } |
| 86 | |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 87 | int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation, |
| 88 | uint32_t framerate) override { |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 89 | ++set_rates_count_; |
| 90 | return WEBRTC_VIDEO_CODEC_OK; |
| 91 | } |
| 92 | |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 93 | bool SupportsNativeHandle() const override { |
| 94 | ++supports_native_handle_count_; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 95 | return supports_native_handle_; |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 96 | } |
| 97 | |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 98 | const char* ImplementationName() const override { |
| 99 | return "fake-encoder"; |
| 100 | } |
| 101 | |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 102 | VideoEncoder::ScalingSettings GetScalingSettings() const override { |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 103 | return VideoEncoder::ScalingSettings(true, kLowThreshold, kHighThreshold); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 106 | int init_encode_count_ = 0; |
| 107 | int32_t init_encode_return_code_ = WEBRTC_VIDEO_CODEC_OK; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 108 | int32_t encode_return_code_ = WEBRTC_VIDEO_CODEC_OK; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 109 | int encode_count_ = 0; |
| 110 | EncodedImageCallback* encode_complete_callback_ = nullptr; |
| 111 | int release_count_ = 0; |
| 112 | int set_channel_parameters_count_ = 0; |
| 113 | int set_rates_count_ = 0; |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 114 | mutable int supports_native_handle_count_ = 0; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 115 | bool supports_native_handle_ = false; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | class FakeEncodedImageCallback : public EncodedImageCallback { |
| 119 | public: |
Sergey Ulanov | 525df3f | 2016-08-02 17:46:41 -0700 | [diff] [blame] | 120 | Result OnEncodedImage( |
| 121 | const EncodedImage& encoded_image, |
| 122 | const CodecSpecificInfo* codec_specific_info, |
| 123 | const RTPFragmentationHeader* fragmentation) override { |
| 124 | ++callback_count_; |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 125 | last_codec_name_ = codec_specific_info->codec_name; |
Sergey Ulanov | 525df3f | 2016-08-02 17:46:41 -0700 | [diff] [blame] | 126 | return Result(Result::OK, callback_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 127 | } |
| 128 | int callback_count_ = 0; |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 129 | std::string last_codec_name_; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | void UtilizeFallbackEncoder(); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 133 | void FallbackFromEncodeRequest(); |
| 134 | void EncodeFrame(); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 135 | void EncodeFrame(int expected_ret); |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 136 | void CheckLastEncoderName(const char* expected_name) { |
| 137 | EXPECT_STREQ(expected_name, callback_.last_codec_name_.c_str()); |
| 138 | } |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 139 | |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 140 | test::ScopedFieldTrials override_field_trials_; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 141 | FakeEncodedImageCallback callback_; |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 142 | // |fake_encoder_| is owned and released by |fallback_wrapper_|. |
| 143 | CountingFakeEncoder* fake_encoder_; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 144 | VideoEncoderSoftwareFallbackWrapper fallback_wrapper_; |
| 145 | VideoCodec codec_ = {}; |
nisse | 64ec8f8 | 2016-09-27 00:17:25 -0700 | [diff] [blame] | 146 | std::unique_ptr<VideoFrame> frame_; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 147 | std::unique_ptr<SimulcastRateAllocator> rate_allocator_; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 148 | }; |
| 149 | |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 150 | void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() { |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 151 | EncodeFrame(WEBRTC_VIDEO_CODEC_OK); |
| 152 | } |
| 153 | |
| 154 | void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame(int expected_ret) { |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 155 | rtc::scoped_refptr<I420Buffer> buffer = |
| 156 | I420Buffer::Create(codec_.width, codec_.height); |
nisse | af91689 | 2017-01-10 07:44:26 -0800 | [diff] [blame] | 157 | I420Buffer::SetBlack(buffer); |
nisse | 776870a | 2016-09-21 03:52:16 -0700 | [diff] [blame] | 158 | std::vector<FrameType> types(1, kVideoFrameKey); |
nisse | 64ec8f8 | 2016-09-27 00:17:25 -0700 | [diff] [blame] | 159 | |
| 160 | frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0)); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 161 | EXPECT_EQ(expected_ret, fallback_wrapper_.Encode(*frame_, nullptr, &types)); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 164 | void VideoEncoderSoftwareFallbackWrapperTest::UtilizeFallbackEncoder() { |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 165 | fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 166 | EXPECT_EQ(&callback_, fake_encoder_->encode_complete_callback_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 167 | |
| 168 | // Register with failing fake encoder. Should succeed with VP8 fallback. |
| 169 | codec_.codecType = kVideoCodecVP8; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 170 | codec_.maxFramerate = kFramerate; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 171 | codec_.width = kWidth; |
| 172 | codec_.height = kHeight; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 173 | codec_.VP8()->numberOfTemporalLayers = 1; |
| 174 | std::unique_ptr<TemporalLayersFactory> tl_factory( |
| 175 | new TemporalLayersFactory()); |
| 176 | codec_.VP8()->tl_factory = tl_factory.get(); |
| 177 | rate_allocator_.reset( |
| 178 | new SimulcastRateAllocator(codec_, std::move(tl_factory))); |
| 179 | |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 180 | fake_encoder_->init_encode_return_code_ = WEBRTC_VIDEO_CODEC_ERROR; |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 181 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 182 | fallback_wrapper_.InitEncode(&codec_, kNumCores, kMaxPayloadSize)); |
| 183 | EXPECT_EQ( |
| 184 | WEBRTC_VIDEO_CODEC_OK, |
| 185 | fallback_wrapper_.SetRateAllocation( |
| 186 | rate_allocator_->GetAllocation(300000, kFramerate), kFramerate)); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 187 | |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 188 | int callback_count = callback_.callback_count_; |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 189 | int encode_count = fake_encoder_->encode_count_; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 190 | EncodeFrame(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 191 | EXPECT_EQ(encode_count, fake_encoder_->encode_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 192 | EXPECT_EQ(callback_count + 1, callback_.callback_count_); |
| 193 | } |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 194 | |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 195 | void VideoEncoderSoftwareFallbackWrapperTest::FallbackFromEncodeRequest() { |
| 196 | fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); |
| 197 | codec_.codecType = kVideoCodecVP8; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 198 | codec_.maxFramerate = kFramerate; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 199 | codec_.width = kWidth; |
| 200 | codec_.height = kHeight; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 201 | codec_.VP8()->numberOfTemporalLayers = 1; |
| 202 | std::unique_ptr<TemporalLayersFactory> tl_factory( |
| 203 | new TemporalLayersFactory()); |
| 204 | codec_.VP8()->tl_factory = tl_factory.get(); |
| 205 | rate_allocator_.reset( |
| 206 | new SimulcastRateAllocator(codec_, std::move(tl_factory))); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 207 | fallback_wrapper_.InitEncode(&codec_, 2, kMaxPayloadSize); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 208 | EXPECT_EQ( |
| 209 | WEBRTC_VIDEO_CODEC_OK, |
| 210 | fallback_wrapper_.SetRateAllocation( |
| 211 | rate_allocator_->GetAllocation(300000, kFramerate), kFramerate)); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 212 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 213 | |
| 214 | // Have the non-fallback encoder request a software fallback. |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 215 | fake_encoder_->encode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 216 | int callback_count = callback_.callback_count_; |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 217 | int encode_count = fake_encoder_->encode_count_; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 218 | EncodeFrame(); |
| 219 | // Single encode request, which returned failure. |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 220 | EXPECT_EQ(encode_count + 1, fake_encoder_->encode_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 221 | EXPECT_EQ(callback_count + 1, callback_.callback_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, InitializesEncoder) { |
| 225 | VideoCodec codec = {}; |
| 226 | fallback_wrapper_.InitEncode(&codec, 2, kMaxPayloadSize); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 227 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 228 | } |
| 229 | |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 230 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, EncodeRequestsFallback) { |
| 231 | FallbackFromEncodeRequest(); |
| 232 | // After fallback, further encodes shouldn't hit the fake encoder. |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 233 | int encode_count = fake_encoder_->encode_count_; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 234 | EncodeFrame(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 235 | EXPECT_EQ(encode_count, fake_encoder_->encode_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 238 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, CanUtilizeFallbackEncoder) { |
| 239 | UtilizeFallbackEncoder(); |
| 240 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 241 | } |
| 242 | |
| 243 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 244 | InternalEncoderReleasedDuringFallback) { |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 245 | EXPECT_EQ(0, fake_encoder_->release_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 246 | UtilizeFallbackEncoder(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 247 | EXPECT_EQ(1, fake_encoder_->release_count_); |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 248 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 249 | // No extra release when the fallback is released. |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 250 | EXPECT_EQ(1, fake_encoder_->release_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 254 | InternalEncoderNotEncodingDuringFallback) { |
| 255 | UtilizeFallbackEncoder(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 256 | int encode_count = fake_encoder_->encode_count_; |
noahric | b1ce663 | 2015-10-21 23:54:51 -0700 | [diff] [blame] | 257 | EncodeFrame(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 258 | EXPECT_EQ(encode_count, fake_encoder_->encode_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 259 | |
| 260 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 261 | } |
| 262 | |
| 263 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 264 | CanRegisterCallbackWhileUsingFallbackEncoder) { |
| 265 | UtilizeFallbackEncoder(); |
| 266 | // Registering an encode-complete callback should still work when fallback |
| 267 | // encoder is being used. |
| 268 | FakeEncodedImageCallback callback2; |
| 269 | fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 270 | EXPECT_EQ(&callback2, fake_encoder_->encode_complete_callback_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 271 | |
| 272 | // Encoding a frame using the fallback should arrive at the new callback. |
Peter Boström | 49e196a | 2015-10-23 15:58:18 +0200 | [diff] [blame] | 273 | std::vector<FrameType> types(1, kVideoFrameKey); |
nisse | 64ec8f8 | 2016-09-27 00:17:25 -0700 | [diff] [blame] | 274 | frame_->set_timestamp(frame_->timestamp() + 1000); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 275 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
nisse | 64ec8f8 | 2016-09-27 00:17:25 -0700 | [diff] [blame] | 276 | fallback_wrapper_.Encode(*frame_, nullptr, &types)); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 277 | |
| 278 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 279 | } |
| 280 | |
| 281 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 282 | SetChannelParametersForwardedDuringFallback) { |
| 283 | UtilizeFallbackEncoder(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 284 | EXPECT_EQ(0, fake_encoder_->set_channel_parameters_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 285 | fallback_wrapper_.SetChannelParameters(1, 1); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 286 | EXPECT_EQ(1, fake_encoder_->set_channel_parameters_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 287 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 288 | } |
| 289 | |
| 290 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 291 | SetRatesForwardedDuringFallback) { |
| 292 | UtilizeFallbackEncoder(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 293 | EXPECT_EQ(1, fake_encoder_->set_rates_count_); |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 294 | fallback_wrapper_.SetRateAllocation(BitrateAllocation(), 1); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 295 | EXPECT_EQ(2, fake_encoder_->set_rates_count_); |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 296 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 297 | } |
| 298 | |
| 299 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 300 | SupportsNativeHandleForwardedWithoutFallback) { |
| 301 | fallback_wrapper_.SupportsNativeHandle(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 302 | EXPECT_EQ(1, fake_encoder_->supports_native_handle_count_); |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 306 | SupportsNativeHandleNotForwardedDuringFallback) { |
| 307 | UtilizeFallbackEncoder(); |
| 308 | fallback_wrapper_.SupportsNativeHandle(); |
magjed | f52d34d | 2017-08-29 00:58:52 -0700 | [diff] [blame] | 309 | EXPECT_EQ(0, fake_encoder_->supports_native_handle_count_); |
Peter Boström | eb66e80 | 2015-06-05 11:08:03 +0200 | [diff] [blame] | 310 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 311 | } |
| 312 | |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 313 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, ReportsImplementationName) { |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 314 | codec_.width = kWidth; |
| 315 | codec_.height = kHeight; |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 316 | fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 317 | fallback_wrapper_.InitEncode(&codec_, kNumCores, kMaxPayloadSize); |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 318 | EncodeFrame(); |
| 319 | CheckLastEncoderName("fake-encoder"); |
| 320 | } |
| 321 | |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 322 | TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 323 | ReportsFallbackImplementationName) { |
| 324 | UtilizeFallbackEncoder(); |
| 325 | // Hard coded expected value since libvpx is the software implementation name |
| 326 | // for VP8. Change accordingly if the underlying implementation does. |
perkj | 275afc5 | 2016-09-01 00:21:16 -0700 | [diff] [blame] | 327 | CheckLastEncoderName("libvpx"); |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 328 | } |
| 329 | |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 330 | namespace { |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 331 | const int kBitrateKbps = 200; |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 332 | const int kMinPixelsPerFrame = 1; |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 333 | const char kFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 334 | } // namespace |
| 335 | |
| 336 | class ForcedFallbackTest : public VideoEncoderSoftwareFallbackWrapperTest { |
| 337 | public: |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 338 | explicit ForcedFallbackTest(const std::string& field_trials) |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 339 | : VideoEncoderSoftwareFallbackWrapperTest(field_trials) {} |
| 340 | |
| 341 | ~ForcedFallbackTest() override {} |
| 342 | |
| 343 | protected: |
| 344 | void SetUp() override { |
| 345 | clock_.SetTimeMicros(1234); |
| 346 | ConfigureVp8Codec(); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | void TearDown() override { |
| 350 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 351 | } |
| 352 | |
| 353 | void ConfigureVp8Codec() { |
| 354 | fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); |
| 355 | std::unique_ptr<TemporalLayersFactory> tl_factory( |
| 356 | new TemporalLayersFactory()); |
| 357 | codec_.codecType = kVideoCodecVP8; |
| 358 | codec_.maxFramerate = kFramerate; |
| 359 | codec_.width = kWidth; |
| 360 | codec_.height = kHeight; |
| 361 | codec_.VP8()->numberOfTemporalLayers = 1; |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 362 | codec_.VP8()->automaticResizeOn = true; |
| 363 | codec_.VP8()->frameDroppingOn = true; |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 364 | codec_.VP8()->tl_factory = tl_factory.get(); |
| 365 | rate_allocator_.reset( |
| 366 | new SimulcastRateAllocator(codec_, std::move(tl_factory))); |
| 367 | } |
| 368 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 369 | void InitEncode(int width, int height) { |
| 370 | codec_.width = width; |
| 371 | codec_.height = height; |
| 372 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.InitEncode( |
| 373 | &codec_, kNumCores, kMaxPayloadSize)); |
| 374 | SetRateAllocation(kBitrateKbps); |
| 375 | } |
| 376 | |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 377 | void SetRateAllocation(uint32_t bitrate_kbps) { |
| 378 | EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.SetRateAllocation( |
| 379 | rate_allocator_->GetAllocation( |
| 380 | bitrate_kbps * 1000, kFramerate), |
| 381 | kFramerate)); |
| 382 | } |
| 383 | |
| 384 | void EncodeFrameAndVerifyLastName(const char* expected_name) { |
| 385 | EncodeFrameAndVerifyLastName(expected_name, WEBRTC_VIDEO_CODEC_OK); |
| 386 | } |
| 387 | |
| 388 | void EncodeFrameAndVerifyLastName(const char* expected_name, |
| 389 | int expected_ret) { |
| 390 | EncodeFrame(expected_ret); |
| 391 | CheckLastEncoderName(expected_name); |
| 392 | } |
| 393 | |
| 394 | rtc::ScopedFakeClock clock_; |
| 395 | }; |
| 396 | |
| 397 | class ForcedFallbackTestEnabled : public ForcedFallbackTest { |
| 398 | public: |
| 399 | ForcedFallbackTestEnabled() |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 400 | : ForcedFallbackTest(std::string(kFieldTrial) + "/Enabled-" + |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 401 | std::to_string(kMinPixelsPerFrame) + "," + |
| 402 | std::to_string(kWidth * kHeight) + ",30000/") {} |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | class ForcedFallbackTestDisabled : public ForcedFallbackTest { |
| 406 | public: |
| 407 | ForcedFallbackTestDisabled() |
Steve Anton | e78bcb9 | 2017-10-31 09:53:08 -0700 | [diff] [blame] | 408 | : ForcedFallbackTest(std::string(kFieldTrial) + "/Disabled/") {} |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 409 | }; |
| 410 | |
| 411 | TEST_F(ForcedFallbackTestDisabled, NoFallbackWithoutFieldTrial) { |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 412 | // Resolution above max threshold. |
| 413 | InitEncode(kWidth + 1, kHeight); |
| 414 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 415 | EncodeFrameAndVerifyLastName("fake-encoder"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 416 | |
| 417 | // Resolution at max threshold. |
| 418 | InitEncode(kWidth, kHeight); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 419 | EncodeFrameAndVerifyLastName("fake-encoder"); |
| 420 | } |
| 421 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 422 | TEST_F(ForcedFallbackTestEnabled, FallbackIfAtMaxResolutionLimit) { |
| 423 | // Resolution above max threshold. |
| 424 | InitEncode(kWidth + 1, kHeight); |
| 425 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 426 | EncodeFrameAndVerifyLastName("fake-encoder"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 427 | |
| 428 | // Resolution at max threshold. |
| 429 | InitEncode(kWidth, kHeight); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 430 | EncodeFrameAndVerifyLastName("libvpx"); |
| 431 | } |
| 432 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 433 | TEST_F(ForcedFallbackTestEnabled, FallbackIsKeptWhenInitEncodeIsCalled) { |
| 434 | // Resolution above max threshold. |
| 435 | InitEncode(kWidth + 1, kHeight); |
| 436 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 437 | EncodeFrameAndVerifyLastName("fake-encoder"); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 438 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 439 | // Resolution at max threshold. |
| 440 | InitEncode(kWidth, kHeight); |
| 441 | EncodeFrameAndVerifyLastName("libvpx"); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 442 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 443 | // Re-initialize encoder, still expect fallback. |
| 444 | InitEncode(kWidth / 2, kHeight / 2); |
| 445 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); // No change. |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 446 | EncodeFrameAndVerifyLastName("libvpx"); |
| 447 | } |
| 448 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 449 | TEST_F(ForcedFallbackTestEnabled, FallbackIsEndedWhenResolutionIsTooLarge) { |
| 450 | // Resolution above max threshold. |
| 451 | InitEncode(kWidth + 1, kHeight); |
| 452 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 453 | EncodeFrameAndVerifyLastName("fake-encoder"); |
| 454 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 455 | // Resolution at max threshold. |
| 456 | InitEncode(kWidth, kHeight); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 457 | EncodeFrameAndVerifyLastName("libvpx"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 458 | |
| 459 | // Re-initialize encoder with a larger resolution, expect no fallback. |
| 460 | InitEncode(kWidth + 1, kHeight); |
| 461 | EXPECT_EQ(2, fake_encoder_->init_encode_count_); |
| 462 | EncodeFrameAndVerifyLastName("fake-encoder"); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 465 | TEST_F(ForcedFallbackTestEnabled, FallbackIsEndedForNonValidSettings) { |
| 466 | // Resolution at max threshold. |
| 467 | InitEncode(kWidth, kHeight); |
| 468 | EncodeFrameAndVerifyLastName("libvpx"); |
| 469 | |
| 470 | // Re-initialize encoder with invalid setting, expect no fallback. |
| 471 | codec_.VP8()->numberOfTemporalLayers = 2; |
| 472 | InitEncode(kWidth, kHeight); |
| 473 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 474 | EncodeFrameAndVerifyLastName("fake-encoder"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 475 | |
| 476 | // Re-initialize encoder with valid setting but fallback disabled from now on. |
| 477 | codec_.VP8()->numberOfTemporalLayers = 1; |
| 478 | InitEncode(kWidth, kHeight); |
| 479 | EXPECT_EQ(2, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 480 | EncodeFrameAndVerifyLastName("fake-encoder"); |
| 481 | } |
| 482 | |
| 483 | TEST_F(ForcedFallbackTestEnabled, MultipleStartEndFallback) { |
| 484 | const int kNumRuns = 5; |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 485 | for (int i = 1; i <= kNumRuns; ++i) { |
| 486 | // Resolution at max threshold. |
| 487 | InitEncode(kWidth, kHeight); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 488 | EncodeFrameAndVerifyLastName("libvpx"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 489 | // Resolution above max threshold. |
| 490 | InitEncode(kWidth + 1, kHeight); |
| 491 | EXPECT_EQ(i, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 492 | EncodeFrameAndVerifyLastName("fake-encoder"); |
| 493 | } |
| 494 | } |
| 495 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 496 | TEST_F(ForcedFallbackTestDisabled, GetScaleSettings) { |
| 497 | // Resolution above max threshold. |
| 498 | InitEncode(kWidth + 1, kHeight); |
| 499 | EXPECT_EQ(1, fake_encoder_->init_encode_count_); |
asapersson | 22c76c4 | 2017-08-16 00:53:59 -0700 | [diff] [blame] | 500 | EncodeFrameAndVerifyLastName("fake-encoder"); |
| 501 | |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 502 | // Default min pixels per frame should be used. |
| 503 | const auto settings = fallback_wrapper_.GetScalingSettings(); |
| 504 | EXPECT_TRUE(settings.enabled); |
| 505 | EXPECT_EQ(kDefaultMinPixelsPerFrame, settings.min_pixels_per_frame); |
| 506 | } |
| 507 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 508 | TEST_F(ForcedFallbackTestEnabled, GetScaleSettingsWithNoFallback) { |
| 509 | // Resolution above max threshold. |
| 510 | InitEncode(kWidth + 1, kHeight); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 511 | EncodeFrameAndVerifyLastName("fake-encoder"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 512 | |
| 513 | // Configured min pixels per frame should be used. |
| 514 | const auto settings = fallback_wrapper_.GetScalingSettings(); |
| 515 | EXPECT_TRUE(settings.enabled); |
| 516 | EXPECT_EQ(kMinPixelsPerFrame, settings.min_pixels_per_frame); |
| 517 | ASSERT_TRUE(settings.thresholds); |
| 518 | EXPECT_EQ(kLowThreshold, settings.thresholds->low); |
| 519 | EXPECT_EQ(kHighThreshold, settings.thresholds->high); |
| 520 | } |
| 521 | |
| 522 | TEST_F(ForcedFallbackTestEnabled, GetScaleSettingsWithFallback) { |
| 523 | // Resolution at max threshold. |
| 524 | InitEncode(kWidth, kHeight); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 525 | EncodeFrameAndVerifyLastName("libvpx"); |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 526 | |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 527 | // Configured min pixels per frame should be used. |
| 528 | const auto settings = fallback_wrapper_.GetScalingSettings(); |
| 529 | EXPECT_TRUE(settings.enabled); |
| 530 | EXPECT_EQ(kMinPixelsPerFrame, settings.min_pixels_per_frame); |
| 531 | } |
| 532 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 533 | TEST_F(ForcedFallbackTestEnabled, ScalingDisabledIfResizeOff) { |
| 534 | // Resolution at max threshold. |
| 535 | codec_.VP8()->automaticResizeOn = false; |
| 536 | InitEncode(kWidth, kHeight); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 537 | EncodeFrameAndVerifyLastName("libvpx"); |
| 538 | |
Åsa Persson | 45bbc8a | 2017-11-13 10:16:47 +0100 | [diff] [blame] | 539 | // Should be disabled for automatic resize off. |
| 540 | const auto settings = fallback_wrapper_.GetScalingSettings(); |
| 541 | EXPECT_FALSE(settings.enabled); |
asapersson | 142fcc9 | 2017-08-17 08:58:54 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Peter Boström | 4d71ede | 2015-05-19 23:09:35 +0200 | [diff] [blame] | 544 | } // namespace webrtc |