Unify hardware and software QP thresholds.

Uses current libvpx (slightly older) thresholds to maintain a larger
window of stable QP, but maintains the newer H264 thresholds.

BUG=
R=glaznev@webrtc.org, mflodman@webrtc.org

Review-Url: https://codereview.webrtc.org/1966213002
Cr-Commit-Position: refs/heads/master@{#12734}
This commit is contained in:
pbos
2016-05-13 11:05:35 -07:00
committed by Commit bot
parent fb1dd43ac1
commit 1f53452ca6
4 changed files with 28 additions and 23 deletions

View File

@ -598,15 +598,9 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
}
rps_.Init();
// QP thresholds are chosen to be high enough to be hit in practice when
// quality is good, but also low enough to not cause a flip-flop behavior
// (e.g. going up in resolution shouldn't give so bad quality that we should
// go back down).
const int kLowQpThreshold = 29;
const int kBadQpThreshold = 100;
quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold,
codec_.startBitrate, codec_.width, codec_.height,
codec_.maxFramerate);
quality_scaler_.Init(QualityScaler::kLowVp8QpThreshold,
QualityScaler::kBadVp8QpThreshold, codec_.startBitrate,
codec_.width, codec_.height, codec_.maxFramerate);
// Only apply scaling to improve for single-layer streams. The scaling metrics
// use frame drops as a signal and is only applicable when we drop frames.

View File

@ -30,6 +30,16 @@ static const int kQvgaBitrateThresholdKbps = 250;
static const int kQvgaNumPixels = 400 * 300; // 320x240
} // namespace
// QP thresholds are chosen to be high enough to be hit in practice when quality
// is good, but also low enough to not cause a flip-flop behavior (e.g. going up
// in resolution shouldn't give so bad quality that we should go back down).
const int QualityScaler::kLowVp8QpThreshold = 29;
const int QualityScaler::kBadVp8QpThreshold = 95;
const int QualityScaler::kLowH264QpThreshold = 22;
const int QualityScaler::kBadH264QpThreshold = 35;
QualityScaler::QualityScaler() : low_qp_threshold_(-1) {}
void QualityScaler::Init(int low_qp_threshold,

View File

@ -37,6 +37,15 @@ class QualityScaler {
const VideoFrame& GetScaledFrame(const VideoFrame& frame);
int downscale_shift() const { return downscale_shift_; }
// QP is obtained from VP8-bitstream for HW, so the QP corresponds to the
// bitstream range of [0, 127] and not the user-level range of [0,63].
static const int kLowVp8QpThreshold;
static const int kBadVp8QpThreshold;
// H264 QP is in the range [0, 51].
static const int kLowH264QpThreshold;
static const int kBadH264QpThreshold;
private:
void AdjustScale(bool up);
void UpdateTargetResolution(int frame_width, int frame_height);