Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: webrtc/modules/video_coding/utility/quality_scaler.cc

Issue 2309743002: Move the QP scaling thresholds to the relevant encoders (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/utility/quality_scaler.cc
diff --git a/webrtc/modules/video_coding/utility/quality_scaler.cc b/webrtc/modules/video_coding/utility/quality_scaler.cc
index 7ef7c575ba4b699210fca7c4e40f0b557a54d440..0696bbbf705b60c4e34d246c0d402d3d7b504e09 100644
--- a/webrtc/modules/video_coding/utility/quality_scaler.cc
+++ b/webrtc/modules/video_coding/utility/quality_scaler.cc
@@ -14,6 +14,8 @@
#include <algorithm>
+#include "webrtc/base/checks.h"
+
// TODO(kthelgason): Some versions of Android have issues with log2.
// See https://code.google.com/p/android/issues/detail?id=212634 for details
#if defined(WEBRTC_ANDROID)
@@ -38,22 +40,15 @@ static const int kVgaBitrateThresholdKbps = 500;
static const int kVgaNumPixels = 700 * 500; // 640x480
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;
-#if defined(WEBRTC_IOS)
-const int QualityScaler::kLowH264QpThreshold = 32;
-const int QualityScaler::kBadH264QpThreshold = 42;
-#else
-const int QualityScaler::kLowH264QpThreshold = 24;
-const int QualityScaler::kBadH264QpThreshold = 37;
-#endif
+// QP scaling threshold defaults:
+static const int kLowH264QpThreshold = 28;
+static const int kHighH264QpThreshold = 39;
+// 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 = 29;
+static const int kHighVp8QpThreshold = 95;
+} // namespace
// Default values. Should immediately get set to something more sensible.
QualityScaler::QualityScaler()
@@ -61,14 +56,24 @@ QualityScaler::QualityScaler()
framedrop_percent_(kMeasureSecondsUpscale * 30),
low_qp_threshold_(-1) {}
-void QualityScaler::Init(int low_qp_threshold,
- int high_qp_threshold,
+void QualityScaler::Init(VideoCodecType codec_type,
int initial_bitrate_kbps,
int width,
int height,
int fps) {
- low_qp_threshold_ = low_qp_threshold;
- high_qp_threshold_ = high_qp_threshold;
+ ClearSamples();
pbos-webrtc 2016/09/19 14:06:57 Have this function just get low/high thresholds an
+ switch (codec_type) {
+ case kVideoCodecH264:
+ low_qp_threshold_ = kLowH264QpThreshold;
+ high_qp_threshold_ = kHighH264QpThreshold;
+ break;
+ case kVideoCodecVP8:
+ low_qp_threshold_ = kLowVp8QpThreshold;
+ high_qp_threshold_ = kHighVp8QpThreshold;
+ break;
+ default:
+ RTC_NOTREACHED() << "Invalid codec type for QualityScaler.";
+ }
downscale_shift_ = 0;
fast_rampup_ = true;
@@ -94,6 +99,18 @@ void QualityScaler::Init(int low_qp_threshold,
ReportFramerate(fps);
}
+void QualityScaler::Init(VideoCodecType codec_type,
+ int initial_bitrate_kbps,
+ int width,
+ int height,
+ int fps,
+ int highQpThreshold,
pbos-webrtc 2016/09/19 14:06:57 high_qp_threshold, same for low
+ int lowQpThreshold) {
+ Init(codec_type, initial_bitrate_kbps, width, height, fps);
+ low_qp_threshold_ = highQpThreshold;
+ high_qp_threshold_ = lowQpThreshold;
+}
+
// Report framerate(fps) to estimate # of samples.
void QualityScaler::ReportFramerate(int framerate) {
// Use a faster window for upscaling initially.

Powered by Google App Engine
This is Rietveld 408576698