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}
diff --git a/experiments/field_trials.py b/experiments/field_trials.py
index 0273f89..57e03dd 100755
--- a/experiments/field_trials.py
+++ b/experiments/field_trials.py
@@ -98,6 +98,9 @@
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)),
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 52ef623..a9e3661 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -317,7 +317,9 @@
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::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 @@
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() {
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
index dad174c..5850aa4 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h
@@ -157,6 +157,8 @@
const LibvpxVp8EncoderInfoSettings encoder_info_override_;
absl::optional<TimeDelta> max_frame_drop_interval_;
+
+ bool android_specific_threading_settings_;
};
} // namespace webrtc