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:
parent
56036ffc45
commit
01bcbd0df6
@ -354,8 +354,7 @@ int32_t MediaCodecVideoEncoder::InitEncode(
|
||||
const webrtc::VideoCodec* codec_settings,
|
||||
int32_t /* number_of_cores */,
|
||||
size_t /* max_payload_size */) {
|
||||
const int kMinWidth = 320;
|
||||
const int kMinHeight = 180;
|
||||
const int kMinDimension = 180;
|
||||
if (codec_settings == NULL) {
|
||||
ALOGE << "NULL VideoCodec instance";
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
@ -398,11 +397,11 @@ int32_t MediaCodecVideoEncoder::InitEncode(
|
||||
RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds.";
|
||||
scale_ = false;
|
||||
}
|
||||
quality_scaler_.SetMinResolution(kMinWidth, kMinHeight);
|
||||
quality_scaler_.SetMinResolution(kMinDimension, kMinDimension);
|
||||
quality_scaler_.ReportFramerate(codec_settings->maxFramerate);
|
||||
QualityScaler::Resolution res = quality_scaler_.GetScaledResolution();
|
||||
init_width = std::max(res.width, kMinWidth);
|
||||
init_height = std::max(res.height, kMinHeight);
|
||||
init_width = std::max(res.width, kMinDimension);
|
||||
init_height = std::max(res.height, kMinDimension);
|
||||
ALOGD << "Scaled resolution: " << init_width << " x " << init_height;
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -44,6 +44,7 @@ class QualityScaler {
|
||||
|
||||
private:
|
||||
void AdjustScale(bool up);
|
||||
void UpdateTargetResolution(int frame_width, int frame_height);
|
||||
void ClearSamples();
|
||||
|
||||
Scaler scaler_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user