blob: 6f24d6bfd74f4b8cf28e5624fa5731468e20d6fb [file] [log] [blame]
Åsa Perssona945aee2018-04-24 16:53:25 +02001/*
2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#ifndef RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
11#define RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
12
13#include "api/optional.h"
14#include "api/video_codecs/video_encoder.h"
15#include "common_types.h" // NOLINT(build/include)
16
17namespace webrtc {
18class QualityScalingExperiment {
19 public:
20 struct Settings {
21 int vp8_low; // VP8: low QP threshold.
22 int vp8_high; // VP8: high QP threshold.
23 int vp9_low; // VP9: low QP threshold.
24 int vp9_high; // VP9: high QP threshold.
25 int h264_low; // H264: low QP threshold.
26 int h264_high; // H264: high QP threshold.
27 int generic_low; // Generic: low QP threshold.
28 int generic_high; // Generic: high QP threshold.
29 float alpha_high; // |alpha_| for ExpFilter used when checking high QP.
30 float alpha_low; // |alpha_| for ExpFilter used when checking low QP.
31 int drop; // >0 sets |use_all_drop_reasons| to true.
32 };
33
34 // Used by QualityScaler.
35 struct Config {
36 float alpha_high = 0.9995f;
37 float alpha_low = 0.9999f;
38 // If set, all type of dropped frames are used.
39 // Otherwise only dropped frames by MediaOptimization are used.
40 bool use_all_drop_reasons = false;
41 };
42
43 // Returns true if the experiment is enabled.
44 static bool Enabled();
45
46 // Returns settings from field trial.
47 static rtc::Optional<Settings> ParseSettings();
48
49 // Returns QpThresholds for the |codec_type|.
50 static rtc::Optional<VideoEncoder::QpThresholds> GetQpThresholds(
51 VideoCodecType codec_type);
52
53 // Returns parsed values. If the parsing fails, default values are returned.
54 static Config GetConfig();
55};
56
57} // namespace webrtc
58
59#endif // RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_