123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
- #define MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
- #include <stddef.h>
- #include <stdint.h>
- #include <memory>
- #include "absl/types/optional.h"
- #include "api/scoped_refptr.h"
- #include "api/video_codecs/video_encoder.h"
- #include "rtc_base/experiments/quality_scaling_experiment.h"
- #include "rtc_base/numerics/moving_average.h"
- #include "rtc_base/ref_count.h"
- #include "rtc_base/ref_counted_object.h"
- #include "rtc_base/synchronization/sequence_checker.h"
- #include "rtc_base/system/no_unique_address.h"
- #include "rtc_base/task_queue.h"
- namespace webrtc {
- class QualityScalerQpUsageHandlerCallbackInterface;
- class QualityScalerQpUsageHandlerInterface;
- class QualityScaler {
- public:
-
-
-
- QualityScaler(QualityScalerQpUsageHandlerInterface* handler,
- VideoEncoder::QpThresholds thresholds);
- virtual ~QualityScaler();
-
- void ReportDroppedFrameByMediaOpt();
- void ReportDroppedFrameByEncoder();
-
- void ReportQp(int qp, int64_t time_sent_us);
- void SetQpThresholds(VideoEncoder::QpThresholds thresholds);
- bool QpFastFilterLow() const;
-
- protected:
- QualityScaler(QualityScalerQpUsageHandlerInterface* handler,
- VideoEncoder::QpThresholds thresholds,
- int64_t sampling_period_ms);
- private:
- class QpSmoother;
- class CheckQpTask;
- class CheckQpTaskHandlerCallback;
- enum class CheckQpResult {
- kInsufficientSamples,
- kNormalQp,
- kHighQp,
- kLowQp,
- };
-
-
-
-
- void StartNextCheckQpTask();
- CheckQpResult CheckQp() const;
- void ClearSamples();
- std::unique_ptr<CheckQpTask> pending_qp_task_ RTC_GUARDED_BY(&task_checker_);
- QualityScalerQpUsageHandlerInterface* const handler_
- RTC_GUARDED_BY(&task_checker_);
- RTC_NO_UNIQUE_ADDRESS SequenceChecker task_checker_;
- VideoEncoder::QpThresholds thresholds_ RTC_GUARDED_BY(&task_checker_);
- const int64_t sampling_period_ms_;
- bool fast_rampup_ RTC_GUARDED_BY(&task_checker_);
- rtc::MovingAverage average_qp_ RTC_GUARDED_BY(&task_checker_);
- rtc::MovingAverage framedrop_percent_media_opt_
- RTC_GUARDED_BY(&task_checker_);
- rtc::MovingAverage framedrop_percent_all_ RTC_GUARDED_BY(&task_checker_);
-
- 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_);
- const size_t min_frames_needed_;
- const double initial_scale_factor_;
- const absl::optional<double> scale_factor_;
- };
- class QualityScalerQpUsageHandlerInterface {
- public:
- virtual ~QualityScalerQpUsageHandlerInterface();
- virtual void OnReportQpUsageHigh() = 0;
- virtual void OnReportQpUsageLow() = 0;
- };
- }
- #endif
|