webrtc/rtc_base/experiments/cpu_speed_experiment.h
Jared Siskin 802e8e5fdb Format /rtc_base
git ls-files | grep -e  "\(\.h\|\.cc\)$" | grep -e  "^rtc_base/" | xargs clang-format -i ; git cl format
after landing: add to .git-blame-ignore-revs

Bug: webrtc:15082
Change-Id: I152228f7c7926adf95d2f3fbbe4178556fd75d0d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/302061
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39914}
2023-04-21 06:17:42 +00:00

64 lines
2 KiB
C++

/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_
#define RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_
#include <vector>
#include "absl/types/optional.h"
#include "rtc_base/experiments/field_trial_parser.h"
namespace webrtc {
class CpuSpeedExperiment {
public:
CpuSpeedExperiment();
~CpuSpeedExperiment();
// Example:
// WebRTC-VP8-CpuSpeed-Arm/pixels:100|200|300,cpu_speed:-1|-2|-3/
// pixels <= 100 -> cpu speed: -1
// pixels <= 200 -> cpu speed: -2
// pixels <= 300 -> cpu speed: -3
// WebRTC-VP8-CpuSpeed-Arm/pixels:100|200|300,cpu_speed:-1|-2|-3/,
// cpu_speed_le_cores:-4|-5|-6,cores:3/
// If `num_cores` > 3
// pixels <= 100 -> cpu speed: -1
// pixels <= 200 -> cpu speed: -2
// pixels <= 300 -> cpu speed: -3
// else
// pixels <= 100 -> cpu speed: -4
// pixels <= 200 -> cpu speed: -5
// pixels <= 300 -> cpu speed: -6
struct Config {
int pixels = 0; // The video frame size.
int cpu_speed = 0; // The `cpu_speed` to be used if the frame size is less
// than or equal to `pixels`.
// Optional.
int cpu_speed_le_cores = 0; // Same as `cpu_speed` above but only used if
// `num_cores` <= `cores_`.
};
// Gets the cpu speed based on `pixels` and `num_cores`.
absl::optional<int> GetValue(int pixels, int num_cores) const;
private:
std::vector<Config> configs_;
// Threshold for when to use `cpu_speed_le_cores`.
FieldTrialOptional<int> cores_;
};
} // namespace webrtc
#endif // RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_