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

Unified Diff: webrtc/video/vie_encoder.cc

Issue 2690023002: Fix nits in vie_encoder (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | webrtc/video/vie_encoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/vie_encoder.cc
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc
index 73e4207109961a66b1db59d567338d2d3bb8390e..ca48596dbee831ed762ad35714125cda40731545 100644
--- a/webrtc/video/vie_encoder.cc
+++ b/webrtc/video/vie_encoder.cc
@@ -217,10 +217,12 @@ class ViEEncoder::VideoSourceProxy {
// task queue.
return;
}
- // The input video frame size will have a resolution with "one step up"
- // pixels than |max_pixel_count_step_up| where "one step up" depends on
- // how the source can scale the input frame size. We still cap the step up
- // to be at most twice the number of pixels.
+ // On step down we request at most 3/5 the pixel count of the previous
+ // resolution, so in order to take "one step up" we request a resolution as
+ // close as possible to 5/3 of the current resolution. The actual pixel
+ // count selected depends on the capabilities of the source. In order to not
+ // take a too large step up, we cap the requested pixel count to be at most
+ // four time the current number of pixels.
sink_wants_.target_pixel_count = rtc::Optional<int>((pixel_count * 5) / 3);
sink_wants_.max_pixel_count = rtc::Optional<int>(pixel_count * 4);
if (source_)
@@ -741,10 +743,9 @@ void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps,
void ViEEncoder::AdaptDown(AdaptReason reason) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
- if (degradation_preference_ != DegradationPreference::kBalanced ||
- !last_frame_info_) {
+ if (degradation_preference_ != DegradationPreference::kBalanced)
return;
- }
+ RTC_DCHECK(static_cast<bool>(last_frame_info_));
int current_pixel_count = last_frame_info_->pixel_count();
if (last_adaptation_request_ &&
last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptDown &&
@@ -780,12 +781,12 @@ void ViEEncoder::AdaptDown(AdaptReason reason) {
void ViEEncoder::AdaptUp(AdaptReason reason) {
RTC_DCHECK_RUN_ON(&encoder_queue_);
if (scale_counter_[reason] == 0 ||
- degradation_preference_ != DegradationPreference::kBalanced ||
- !last_frame_info_) {
+ degradation_preference_ != DegradationPreference::kBalanced) {
return;
}
// Only scale if resolution is higher than last time we requested higher
// resolution.
+ RTC_DCHECK(static_cast<bool>(last_frame_info_));
int current_pixel_count = last_frame_info_->pixel_count();
if (last_adaptation_request_ &&
last_adaptation_request_->mode_ == AdaptationRequest::Mode::kAdaptUp &&
« no previous file with comments | « no previous file | webrtc/video/vie_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698