blob: 14833c00b127978cb6b65e924c8c0449a9d323ea [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
Danil Chapovalov0a1d1892018-06-21 11:48:25 +020013#include "absl/types/optional.h"
Åsa Perssona945aee2018-04-24 16:53:25 +020014#include "api/video_codecs/video_encoder.h"
Åsa Perssona945aee2018-04-24 16:53:25 +020015
16namespace webrtc {
17class QualityScalingExperiment {
18 public:
19 struct Settings {
20 int vp8_low; // VP8: low QP threshold.
21 int vp8_high; // VP8: high QP threshold.
22 int vp9_low; // VP9: low QP threshold.
23 int vp9_high; // VP9: high QP threshold.
24 int h264_low; // H264: low QP threshold.
25 int h264_high; // H264: high QP threshold.
26 int generic_low; // Generic: low QP threshold.
27 int generic_high; // Generic: high QP threshold.
28 float alpha_high; // |alpha_| for ExpFilter used when checking high QP.
29 float alpha_low; // |alpha_| for ExpFilter used when checking low QP.
30 int drop; // >0 sets |use_all_drop_reasons| to true.
31 };
32
33 // Used by QualityScaler.
34 struct Config {
35 float alpha_high = 0.9995f;
36 float alpha_low = 0.9999f;
37 // If set, all type of dropped frames are used.
38 // Otherwise only dropped frames by MediaOptimization are used.
39 bool use_all_drop_reasons = false;
40 };
41
42 // Returns true if the experiment is enabled.
43 static bool Enabled();
44
45 // Returns settings from field trial.
Danil Chapovalov0a1d1892018-06-21 11:48:25 +020046 static absl::optional<Settings> ParseSettings();
Åsa Perssona945aee2018-04-24 16:53:25 +020047
48 // Returns QpThresholds for the |codec_type|.
Danil Chapovalov0a1d1892018-06-21 11:48:25 +020049 static absl::optional<VideoEncoder::QpThresholds> GetQpThresholds(
Åsa Perssona945aee2018-04-24 16:53:25 +020050 VideoCodecType codec_type);
51
52 // Returns parsed values. If the parsing fails, default values are returned.
53 static Config GetConfig();
54};
55
56} // namespace webrtc
57
58#endif // RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_