From 2c8a2964fddb9b92c47a7868b2ef9fe95e755083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Mon, 18 Apr 2016 12:58:02 +0200 Subject: [PATCH] Tune QP-based quality thresholds. Increases measure time for downscale back to 5 seconds, this is required to not over-react on hand-waving or quick device rotations. Also increase max thresholds for QP a bit to not overreact when quality still looks somewhat OK. Min thresholds for H264 seemed very low and are increased to be sure that we can go back up again. The window is still quite big with the increased max QP. Also changes libvpx thresholds to use the same thresholds as the encoder, they were excessively low before and wouldn't adapt on bad QPs at all before (but rely on >60% framedropping based on bitrates to go down). BUG=webrtc:5678 R=stefan@webrtc.org TBR=glaznev@webrtc.org Review URL: https://codereview.webrtc.org/1894083002 . Cr-Commit-Position: refs/heads/master@{#12403} --- webrtc/api/java/jni/androidmediaencoder_jni.cc | 6 +++--- webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc | 4 ++-- webrtc/modules/video_coding/utility/quality_scaler.cc | 2 +- .../modules/video_coding/utility/quality_scaler_unittest.cc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc index 1530f003dc..69060f8508 100644 --- a/webrtc/api/java/jni/androidmediaencoder_jni.cc +++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc @@ -376,15 +376,15 @@ int32_t MediaCodecVideoEncoder::InitEncode( // always = 127. Note that in SW, QP is that of the user-level range [0, // 63]. const int kLowQpThreshold = 29; - const int kBadQpThreshold = 90; + const int kBadQpThreshold = 100; quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, codec_settings->startBitrate, codec_settings->width, codec_settings->height, codec_settings->maxFramerate); } else if (codecType_ == kVideoCodecH264) { // H264 QP is in the range [0, 51]. - const int kLowQpThreshold = 21; - const int kBadQpThreshold = 33; + const int kLowQpThreshold = 24; + const int kBadQpThreshold = 39; quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, codec_settings->startBitrate, codec_settings->width, codec_settings->height, diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index 4ab939a4a7..abe58e3626 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -604,8 +604,8 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst, // 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 = 23; - const int kDisabledBadQpThreshold = 128; + const int kLowQpThreshold = 29; + const int kDisabledBadQpThreshold = 100; // TODO(glaznev/sprang): consider passing codec initial bitrate to quality // scaler to avoid starting with HD for low initial bitrates. quality_scaler_.Init(kLowQpThreshold, kDisabledBadQpThreshold, false, 0, 0, 0, diff --git a/webrtc/modules/video_coding/utility/quality_scaler.cc b/webrtc/modules/video_coding/utility/quality_scaler.cc index 42f3e287a9..0e1f1d4248 100644 --- a/webrtc/modules/video_coding/utility/quality_scaler.cc +++ b/webrtc/modules/video_coding/utility/quality_scaler.cc @@ -13,10 +13,10 @@ namespace webrtc { namespace { static const int kMinFps = 5; -static const int kMeasureSecondsDownscale = 3; // Threshold constant used until first downscale (to permit fast rampup). static const int kMeasureSecondsFastUpscale = 2; static const int kMeasureSecondsUpscale = 5; +static const int kMeasureSecondsDownscale = 5; static const int kFramedropPercentThreshold = 60; static const int kHdResolutionThreshold = 700 * 500; static const int kHdBitrateThresholdKbps = 500; diff --git a/webrtc/modules/video_coding/utility/quality_scaler_unittest.cc b/webrtc/modules/video_coding/utility/quality_scaler_unittest.cc index ecd678edb6..0f761c7d17 100644 --- a/webrtc/modules/video_coding/utility/quality_scaler_unittest.cc +++ b/webrtc/modules/video_coding/utility/quality_scaler_unittest.cc @@ -29,9 +29,9 @@ static const int kDisabledBadQpThreshold = 64; static const int kLowInitialBitrateKbps = 300; // These values need to be in sync with corresponding constants // in quality_scaler.cc -static const int kMeasureSecondsDownscale = 3; static const int kMeasureSecondsFastUpscale = 2; static const int kMeasureSecondsUpscale = 5; +static const int kMeasureSecondsDownscale = 5; static const int kMinDownscaleDimension = 140; } // namespace