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:
@ -388,21 +388,13 @@ int32_t MediaCodecVideoEncoder::InitEncode(
|
|||||||
|
|
||||||
if (scale_) {
|
if (scale_) {
|
||||||
if (codecType_ == kVideoCodecVP8) {
|
if (codecType_ == kVideoCodecVP8) {
|
||||||
// QP is obtained from VP8-bitstream for HW, so the QP corresponds to the
|
quality_scaler_.Init(
|
||||||
// (internal) range: [0, 127]. And we cannot change QP_max in HW, so it is
|
QualityScaler::kLowVp8QpThreshold, QualityScaler::kBadVp8QpThreshold,
|
||||||
// always = 127. Note that in SW, QP is that of the user-level range [0,
|
codec_settings->startBitrate, codec_settings->width,
|
||||||
// 63].
|
codec_settings->height, codec_settings->maxFramerate);
|
||||||
const int kLowQpThreshold = 29;
|
|
||||||
const int kBadQpThreshold = 90;
|
|
||||||
quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold,
|
|
||||||
codec_settings->startBitrate, codec_settings->width,
|
|
||||||
codec_settings->height,
|
|
||||||
codec_settings->maxFramerate);
|
|
||||||
} else if (codecType_ == kVideoCodecH264) {
|
} else if (codecType_ == kVideoCodecH264) {
|
||||||
// H264 QP is in the range [0, 51].
|
quality_scaler_.Init(QualityScaler::kLowH264QpThreshold,
|
||||||
const int kLowQpThreshold = 22;
|
QualityScaler::kBadH264QpThreshold,
|
||||||
const int kBadQpThreshold = 35;
|
|
||||||
quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold,
|
|
||||||
codec_settings->startBitrate, codec_settings->width,
|
codec_settings->startBitrate, codec_settings->width,
|
||||||
codec_settings->height,
|
codec_settings->height,
|
||||||
codec_settings->maxFramerate);
|
codec_settings->maxFramerate);
|
||||||
|
|||||||
@ -598,15 +598,9 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rps_.Init();
|
rps_.Init();
|
||||||
// QP thresholds are chosen to be high enough to be hit in practice when
|
quality_scaler_.Init(QualityScaler::kLowVp8QpThreshold,
|
||||||
// quality is good, but also low enough to not cause a flip-flop behavior
|
QualityScaler::kBadVp8QpThreshold, codec_.startBitrate,
|
||||||
// (e.g. going up in resolution shouldn't give so bad quality that we should
|
codec_.width, codec_.height, codec_.maxFramerate);
|
||||||
// go back down).
|
|
||||||
const int kLowQpThreshold = 29;
|
|
||||||
const int kBadQpThreshold = 100;
|
|
||||||
quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold,
|
|
||||||
codec_.startBitrate, codec_.width, codec_.height,
|
|
||||||
codec_.maxFramerate);
|
|
||||||
|
|
||||||
// Only apply scaling to improve for single-layer streams. The scaling metrics
|
// 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.
|
// use frame drops as a signal and is only applicable when we drop frames.
|
||||||
|
|||||||
@ -30,6 +30,16 @@ static const int kQvgaBitrateThresholdKbps = 250;
|
|||||||
static const int kQvgaNumPixels = 400 * 300; // 320x240
|
static const int kQvgaNumPixels = 400 * 300; // 320x240
|
||||||
} // namespace
|
} // 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) {}
|
QualityScaler::QualityScaler() : low_qp_threshold_(-1) {}
|
||||||
|
|
||||||
void QualityScaler::Init(int low_qp_threshold,
|
void QualityScaler::Init(int low_qp_threshold,
|
||||||
|
|||||||
@ -37,6 +37,15 @@ class QualityScaler {
|
|||||||
const VideoFrame& GetScaledFrame(const VideoFrame& frame);
|
const VideoFrame& GetScaledFrame(const VideoFrame& frame);
|
||||||
int downscale_shift() const { return downscale_shift_; }
|
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:
|
private:
|
||||||
void AdjustScale(bool up);
|
void AdjustScale(bool up);
|
||||||
void UpdateTargetResolution(int frame_width, int frame_height);
|
void UpdateTargetResolution(int frame_width, int frame_height);
|
||||||
|
|||||||
Reference in New Issue
Block a user