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

Unified Diff: webrtc/video/vie_encoder_unittest.cc

Issue 2936393002: Add cropping to VIEEncoder to match simulcast streams resolution (Closed)
Patch Set: Fix typo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/vie_encoder_unittest.cc
diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc
index b143e4d54624b405419fd42bc22cf97d66d10590..976cf47bb2fa504033b226c41733257c8804aab3 100644
--- a/webrtc/video/vie_encoder_unittest.cc
+++ b/webrtc/video/vie_encoder_unittest.cc
@@ -166,6 +166,7 @@ class VideoStreamFactory
const int framerate_;
};
+
class AdaptingFrameForwarder : public test::FrameForwarder {
public:
AdaptingFrameForwarder() : adaptation_enabled_(false) {}
@@ -2944,4 +2945,71 @@ TEST_F(ViEEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Resolution) {
vie_encoder_->Stop();
}
+TEST_F(ViEEncoderTest, AcceptsFullHdAdaptedDownSimulcastFrames) {
+ // Simulates simulcast behavior and makes highest stream resolutions divisible
+ // by 4.
+ class CroppingVideoStreamFactory
+ : public VideoEncoderConfig::VideoStreamFactoryInterface {
+ public:
+ explicit CroppingVideoStreamFactory(size_t num_temporal_layers,
+ int framerate)
+ : num_temporal_layers_(num_temporal_layers), framerate_(framerate) {
+ EXPECT_GT(num_temporal_layers, 0u);
+ EXPECT_GT(framerate, 0);
+ }
+
+ private:
+ std::vector<VideoStream> CreateEncoderStreams(
+ int width,
+ int height,
+ const VideoEncoderConfig& encoder_config) override {
+ std::vector<VideoStream> streams =
+ test::CreateVideoStreams(width - width % 4, height - height % 4,
+ encoder_config);
+ for (VideoStream& stream : streams) {
+ stream.temporal_layer_thresholds_bps.resize(num_temporal_layers_ - 1);
+ stream.max_framerate = framerate_;
+ }
+ return streams;
+ }
+
+ const size_t num_temporal_layers_;
+ const int framerate_;
+ };
+
+ 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;
+ const int kFramerate = 24;
+
+ vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ // Trigger reconfigure encoder (without resetting the entire instance).
+ VideoEncoderConfig video_encoder_config;
+ video_encoder_config.max_bitrate_bps = kTargetBitrateBps;
+ video_encoder_config.number_of_streams = 1;
+ video_encoder_config.video_stream_factory =
+ new rtc::RefCountedObject<CroppingVideoStreamFactory>(1, kFramerate);
+ vie_encoder_->ConfigureEncoder(std::move(video_encoder_config),
+ kMaxPayloadLength, false);
+ vie_encoder_->WaitUntilTaskQueueIsIdle();
+
+ video_source_.set_adaptation_enabled(true);
+
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(1, kFrameWidth, kFrameHeight));
+ sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight);
+
+ // Trigger CPU overuse, downscale by 3/4.
+ vie_encoder_->TriggerCpuOveruse();
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(2, kFrameWidth, kFrameHeight));
+ sink_.WaitForEncodedFrame(kAdaptedFrameWidth, kAdaptedFrameHeight);
+
+ vie_encoder_->Stop();
+}
+
+
} // namespace webrtc
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698