Make Android min-resolution rotation-agnostic.

Min resolution shouldn't have anything to do with CVO being enabled or
not, nor device rotation.

BUG=webrtc:5678
R=glaznev@webrtc.org
TBR=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1824083002 .

Cr-Commit-Position: refs/heads/master@{#12092}
This commit is contained in:
Peter Boström
2016-03-22 21:44:29 +01:00
parent 56036ffc45
commit 01bcbd0df6
3 changed files with 23 additions and 18 deletions

View File

@ -40,6 +40,9 @@ void QualityScaler::Init(int low_qp_threshold,
low_qp_threshold_ = low_qp_threshold;
high_qp_threshold_ = high_qp_threshold;
use_framerate_reduction_ = use_framerate_reduction;
downscale_shift_ = 0;
const int init_width = width;
const int init_height = height;
// TODO(glaznev): Investigate using thresholds for other resolutions
// or threshold tables.
if (initial_bitrate_kbps > 0 &&
@ -51,8 +54,7 @@ void QualityScaler::Init(int low_qp_threshold,
height /= 2;
}
}
res_.width = width;
res_.height = height;
UpdateTargetResolution(init_width, init_height);
target_framerate_ = -1;
}
@ -81,8 +83,6 @@ void QualityScaler::OnEncodeFrame(const VideoFrame& frame) {
// Should be set through InitEncode -> Should be set by now.
assert(low_qp_threshold_ >= 0);
assert(num_samples_ > 0);
res_.width = frame.width();
res_.height = frame.height();
// Update scale factor.
int avg_drop = 0;
@ -117,15 +117,7 @@ void QualityScaler::OnEncodeFrame(const VideoFrame& frame) {
AdjustScale(true);
}
}
assert(downscale_shift_ >= 0);
for (int shift = downscale_shift_;
shift > 0 && (res_.width / 2 >= min_width_) &&
(res_.height / 2 >= min_height_);
--shift) {
res_.width /= 2;
res_.height /= 2;
}
UpdateTargetResolution(frame.width(), frame.height());
}
QualityScaler::Resolution QualityScaler::GetScaledResolution() const {
@ -153,6 +145,19 @@ const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) {
return scaled_frame_;
}
void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) {
assert(downscale_shift_ >= 0);
res_.width = frame_width;
res_.height = frame_height;
for (int shift = downscale_shift_;
shift > 0 && (res_.width / 2 >= min_width_) &&
(res_.height / 2 >= min_height_);
--shift) {
res_.width /= 2;
res_.height /= 2;
}
}
void QualityScaler::ClearSamples() {
framedrop_percent_.Reset();
average_qp_.Reset();

View File

@ -44,6 +44,7 @@ class QualityScaler {
private:
void AdjustScale(bool up);
void UpdateTargetResolution(int frame_width, int frame_height);
void ClearSamples();
Scaler scaler_;