Make quality scaler downscale faster.

Include dropped frames by the encoder in the frame drop percentage.

To react faster at low framerates:
- Use ExpFilter instead of MovingAverage to filter QP values.
- Reduce sampling interval while waiting for minimum number of needed frames (when not in fast rampup mode).

A separate slower ExpFilter is used for upscaling.

Bug: webrtc:9169
Change-Id: If7ff6c3bd4201fda2da67125889838fe96ce7061
Reviewed-on: https://webrtc-review.googlesource.com/70761
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23014}
This commit is contained in:
Åsa Persson
2018-04-24 16:53:25 +02:00
committed by Commit Bot
parent c79268f15a
commit a945aee72e
11 changed files with 504 additions and 35 deletions

View File

@ -11,12 +11,14 @@
#ifndef MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
#define MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
#include <memory>
#include <utility>
#include "api/optional.h"
#include "api/video_codecs/video_encoder.h"
#include "common_types.h" // NOLINT(build/include)
#include "modules/video_coding/utility/moving_average.h"
#include "rtc_base/experiments/quality_scaling_experiment.h"
#include "rtc_base/sequenced_task_checker.h"
namespace webrtc {
@ -49,8 +51,9 @@ class QualityScaler {
QualityScaler(AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds);
virtual ~QualityScaler();
// Should be called each time the encoder drops a frame.
void ReportDroppedFrame();
// Should be called each time a frame is dropped at encoding.
void ReportDroppedFrameByMediaOpt();
void ReportDroppedFrameByEncoder();
// Inform the QualityScaler of the last seen QP.
void ReportQp(int qp);
@ -62,6 +65,7 @@ class QualityScaler {
private:
class CheckQpTask;
class QpSmoother;
void CheckQp();
void ClearSamples();
void ReportQpLow();
@ -76,7 +80,15 @@ class QualityScaler {
const int64_t sampling_period_ms_;
bool fast_rampup_ RTC_GUARDED_BY(&task_checker_);
MovingAverage average_qp_ RTC_GUARDED_BY(&task_checker_);
MovingAverage framedrop_percent_ RTC_GUARDED_BY(&task_checker_);
MovingAverage framedrop_percent_media_opt_ RTC_GUARDED_BY(&task_checker_);
MovingAverage framedrop_percent_all_ RTC_GUARDED_BY(&task_checker_);
// Used by QualityScalingExperiment.
const bool experiment_enabled_;
QualityScalingExperiment::Config config_ RTC_GUARDED_BY(&task_checker_);
std::unique_ptr<QpSmoother> qp_smoother_high_ RTC_GUARDED_BY(&task_checker_);
std::unique_ptr<QpSmoother> qp_smoother_low_ RTC_GUARDED_BY(&task_checker_);
bool observed_enough_frames_ RTC_GUARDED_BY(&task_checker_);
};
} // namespace webrtc