diff --git a/experiments/field_trials.py b/experiments/field_trials.py index 0273f89057..57e03dda1f 100755 --- a/experiments/field_trials.py +++ b/experiments/field_trials.py @@ -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)), diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 52ef6231ea..a9e3661e8e 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 @@ LibvpxVp8Encoder::LibvpxVp8Encoder(std::unique_ptr 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 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() { diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h index dad174ceff..5850aa46e9 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 @@ class LibvpxVp8Encoder : public VideoEncoder { const LibvpxVp8EncoderInfoSettings encoder_info_override_; absl::optional max_frame_drop_interval_; + + bool android_specific_threading_settings_; }; } // namespace webrtc