diff options
author | Erwin Jansen <jansene@google.com> | 2021-06-30 07:29:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-06-30 07:29:26 +0000 |
commit | 059cdc5996938f5f6b5343b6c969c12098275587 (patch) | |
tree | 6eacaffe4bebf8e00c290c1e1839e084b0c52e88 /call/adaptation/video_stream_adapter.cc | |
parent | 97e54a7e73c7b24e464ef06ef3c3b3716f21bb15 (diff) | |
parent | 16be34ae72cdb525c88c2b31b21b976f35fe36d8 (diff) | |
download | webrtc-059cdc5996938f5f6b5343b6c969c12098275587.tar.gz |
Merge "Merge upstream-master and enable ARM64" into emu-master-devemu-31-stable-releaseemu-31-release
Diffstat (limited to 'call/adaptation/video_stream_adapter.cc')
-rw-r--r-- | call/adaptation/video_stream_adapter.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/call/adaptation/video_stream_adapter.cc b/call/adaptation/video_stream_adapter.cc index 6620eff311..64e1a77786 100644 --- a/call/adaptation/video_stream_adapter.cc +++ b/call/adaptation/video_stream_adapter.cc @@ -416,8 +416,10 @@ VideoStreamAdapter::AdaptIfFpsDiffInsufficient( const VideoStreamInputState& input_state, const RestrictionsWithCounters& restrictions) const { RTC_DCHECK_EQ(degradation_preference_, DegradationPreference::BALANCED); + int frame_size_pixels = input_state.single_active_stream_pixels().value_or( + input_state.frame_size_pixels().value()); absl::optional<int> min_fps_diff = - balanced_settings_.MinFpsDiff(input_state.frame_size_pixels().value()); + balanced_settings_.MinFpsDiff(frame_size_pixels); if (current_restrictions_.counters.fps_adaptations < restrictions.counters.fps_adaptations && min_fps_diff && input_state.frames_per_second() > 0) { @@ -502,9 +504,10 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseFramerate( if (degradation_preference_ == DegradationPreference::MAINTAIN_RESOLUTION) { max_frame_rate = GetLowerFrameRateThan(input_state.frames_per_second()); } else if (degradation_preference_ == DegradationPreference::BALANCED) { - max_frame_rate = - balanced_settings_.MinFps(input_state.video_codec_type(), - input_state.frame_size_pixels().value()); + int frame_size_pixels = input_state.single_active_stream_pixels().value_or( + input_state.frame_size_pixels().value()); + max_frame_rate = balanced_settings_.MinFps(input_state.video_codec_type(), + frame_size_pixels); } else { RTC_NOTREACHED(); max_frame_rate = GetLowerFrameRateThan(input_state.frames_per_second()); @@ -561,12 +564,21 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseFramerate( if (degradation_preference_ == DegradationPreference::MAINTAIN_RESOLUTION) { max_frame_rate = GetHigherFrameRateThan(input_state.frames_per_second()); } else if (degradation_preference_ == DegradationPreference::BALANCED) { - max_frame_rate = - balanced_settings_.MaxFps(input_state.video_codec_type(), - input_state.frame_size_pixels().value()); + int frame_size_pixels = input_state.single_active_stream_pixels().value_or( + input_state.frame_size_pixels().value()); + max_frame_rate = balanced_settings_.MaxFps(input_state.video_codec_type(), + frame_size_pixels); + // Temporary fix for cases when there are fewer framerate adaptation steps + // up than down. Make number of down/up steps equal. + if (max_frame_rate == std::numeric_limits<int>::max() && + current_restrictions.counters.fps_adaptations > 1) { + // Do not unrestrict framerate to allow additional adaptation up steps. + RTC_LOG(LS_INFO) << "Modifying framerate due to remaining fps count."; + max_frame_rate -= current_restrictions.counters.fps_adaptations; + } // In BALANCED, the max_frame_rate must be checked before proceeding. This // is because the MaxFps might be the current Fps and so the balanced - // settings may want to scale up the resolution.= + // settings may want to scale up the resolution. if (!CanIncreaseFrameRateTo(max_frame_rate, current_restrictions.restrictions)) { return Adaptation::Status::kLimitReached; |