Disable Android specific threading settings in libvpx VP8 encoder

It used up to 3 threads for QVGA on Android before. This change disables Android-specific code path in NumberOfThreads() and uses the generic settings, which configure 1 thread for resolutions <=VGA, instead. The change is guarded by a killswitch.

For reference, frame encode time for VGA 512kbps using 1 thread on Pixel 2 (7 years old device; SD835) is ~5.5ms: https://chromeperf.appspot.com/report?sid=6e80c701ef6ff0d008a299fb122a16f0d2600ddfcd9981d3d75cd722c92b2869

Bug: webrtc:15828, b/316494683
Change-Id: I0e9571ede64c6cb77d529d21ccb0310ccb8bfdaf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/337601
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41770}
This commit is contained in:
Sergey Silkin 2024-02-20 10:35:35 +01:00 committed by WebRTC LUCI CQ
parent 0e9b8fe22b
commit 2a3db3131d
3 changed files with 24 additions and 17 deletions

View File

@ -98,6 +98,9 @@ ACTIVE_FIELD_TRIALS: FrozenSet[FieldTrial] = frozenset([
FieldTrial('WebRTC-LibvpxVp9Encoder-SvcFrameDropConfig',
'webrtc:15827',
date(2024, 9, 1)),
FieldTrial('WebRTC-LibvpxVp8Encoder-AndroidSpecificThreadingSettings',
'webrtc:15828',
date(2024, 9, 1)),
FieldTrial('WebRTC-Pacer-FastRetransmissions',
'chromium:1354491',
date(2024, 4, 1)),

View File

@ -317,7 +317,9 @@ LibvpxVp8Encoder::LibvpxVp8Encoder(std::unique_ptr<LibvpxInterface> interface,
variable_framerate_experiment_(ParseVariableFramerateConfig(
"WebRTC-VP8VariableFramerateScreenshare")),
framerate_controller_(variable_framerate_experiment_.framerate_limit),
max_frame_drop_interval_(ParseFrameDropInterval()) {
max_frame_drop_interval_(ParseFrameDropInterval()),
android_specific_threading_settings_(webrtc::field_trial::IsEnabled(
"WebRTC-LibvpxVp8Encoder-AndroidSpecificThreadingSettings")) {
// TODO(eladalon/ilnik): These reservations might be wasting memory.
// InitEncode() is resizing to the actual size, which might be smaller.
raw_images_.reserve(kMaxSimulcastStreams);
@ -783,20 +785,21 @@ int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
#if defined(WEBRTC_ANDROID)
if (width * height >= 320 * 180) {
if (cpus >= 4) {
// 3 threads for CPUs with 4 and more cores since most of times only 4
// cores will be active.
return 3;
} else if (cpus == 3 || cpus == 2) {
return 2;
} else {
return 1;
if (android_specific_threading_settings_) {
if (width * height >= 320 * 180) {
if (cpus >= 4) {
// 3 threads for CPUs with 4 and more cores since most of times only 4
// cores will be active.
return 3;
} else if (cpus == 3 || cpus == 2) {
return 2;
} else {
return 1;
}
}
return 1;
}
return 1;
#else
#if defined(WEBRTC_IOS)
#elif defined(WEBRTC_IOS)
std::string trial_string =
field_trial::FindFullName(kVP8IosMaxNumberOfThreadFieldTrial);
FieldTrialParameter<int> max_thread_number(
@ -823,11 +826,10 @@ int LibvpxVp8Encoder::NumberOfThreads(int width, int height, int cpus) {
return 3;
}
return 2;
} else {
// 1 thread for VGA or less.
return 1;
}
#endif
// 1 thread for VGA or less.
return 1;
}
int LibvpxVp8Encoder::InitAndSetControlSettings() {

View File

@ -157,6 +157,8 @@ class LibvpxVp8Encoder : public VideoEncoder {
const LibvpxVp8EncoderInfoSettings encoder_info_override_;
absl::optional<TimeDelta> max_frame_drop_interval_;
bool android_specific_threading_settings_;
};
} // namespace webrtc