diff options
author | Ilya Nikolaevskiy <ilnik@webrtc.org> | 2020-06-05 12:36:32 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-08 19:00:30 +0000 |
commit | 09eb6e249d4e1f926dfa586bff9cc0de1c4cdefa (patch) | |
tree | 16c8a8d3396f5f1ebde9dee274bbedcd29250dea /video | |
parent | 9766b890a88b82ea29290bbe860380cd5aa86ef0 (diff) | |
download | webrtc-09eb6e249d4e1f926dfa586bff9cc0de1c4cdefa.tar.gz |
[VP9 SVC] Round spatial layers dimensions to ensure integer scaling factors are used
Bug: webrtc:11652
Change-Id: Id3642d607f62b72a567d521d9874b8588c2ce429
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176517
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31465}
Diffstat (limited to 'video')
-rw-r--r-- | video/video_stream_encoder.cc | 7 | ||||
-rw-r--r-- | video/video_stream_encoder_unittest.cc | 30 |
2 files changed, 37 insertions, 0 deletions
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 23569bea27..20a8476635 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -588,6 +588,13 @@ void VideoStreamEncoder::ReconfigureEncoder() { RTC_LOG(LS_ERROR) << "Failed to create encoder configuration."; } + if (encoder_config_.codec_type == kVideoCodecVP9) { + // Spatial layers configuration might impose some parity restrictions, + // thus some cropping might be needed. + crop_width_ = last_frame_info_->width - codec.width; + crop_height_ = last_frame_info_->height - codec.height; + } + char log_stream_buf[4 * 1024]; rtc::SimpleStringBuilder log_stream(log_stream_buf); log_stream << "ReconfigureEncoder:\n"; diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 6ce6265ba2..b50975aecf 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -5917,4 +5917,34 @@ TEST_F(VideoStreamEncoderTest, AutomaticAnimationDetection) { video_stream_encoder_->Stop(); } +TEST_F(VideoStreamEncoderTest, ConfiguresVp9SvcAtOddResolutions) { + const int kWidth = 720; // 540p adapted down. + const int kHeight = 405; + const int kNumFrames = 3; + // Works on screenshare mode. + ResetEncoder("VP9", /*num_streams=*/1, /*num_temporal_layers=*/1, + /*num_spatial_layers=*/2, /*screenshare=*/true); + + video_source_.set_adaptation_enabled(true); + + video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources( + DataRate::BitsPerSec(kTargetBitrateBps), + DataRate::BitsPerSec(kTargetBitrateBps), + DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0); + + VideoFrame frame = CreateFrame(1, kWidth, kHeight); + + // Pass enough frames with the full update to trigger animation detection. + for (int i = 0; i < kNumFrames; ++i) { + int64_t timestamp_ms = + fake_clock_.TimeNanos() / rtc::kNumNanosecsPerMillisec; + frame.set_ntp_time_ms(timestamp_ms); + frame.set_timestamp_us(timestamp_ms * 1000); + video_source_.IncomingCapturedFrame(frame); + WaitForEncodedFrame(timestamp_ms); + } + + video_stream_encoder_->Stop(); +} + } // namespace webrtc |