Restrict ARM-specific VP8/VP9/AV1 settings to mobile platforms
ARM-specific settings were intended to be used on mobile ARM devices which may not be powerful enough. But the settings were also applied to ARM-based Macs. This changes restricts ARM-specific settings to Android and iOS platforms.
Bug: none
Change-Id: I68764b4c0679db07399bba5923f4a6be89c5ad80
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/321861
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Jerome Jiang <jianj@google.com>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40884}
diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
index 9a8d57d..4ff22bf 100644
--- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
+++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
@@ -41,6 +41,11 @@
#include "third_party/libaom/source/libaom/aom/aom_encoder.h"
#include "third_party/libaom/source/libaom/aom/aomcx.h"
+#if (defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64)) && \
+ (defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS))
+#define MOBILE_ARM
+#endif
+
#define SET_ENCODER_PARAM_OR_RETURN_ERROR(param_id, param_value) \
do { \
if (!SetEncoderControlParameters(param_id, param_value)) { \
@@ -413,8 +418,7 @@
return 2;
} else {
// Use 2 threads for low res on ARM.
-#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
+#ifdef MOBILE_ARM
if (width * height >= 320 * 180 && number_of_cores > 2) {
return 2;
}
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 1ff3f09..52ef623 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -44,6 +44,11 @@
#include "third_party/libyuv/include/libyuv/scale.h"
#include "vpx/vp8cx.h"
+#if (defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64)) && \
+ (defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS))
+#define MOBILE_ARM
+#endif
+
namespace webrtc {
namespace {
#if defined(WEBRTC_IOS)
@@ -744,8 +749,7 @@
}
int LibvpxVp8Encoder::GetCpuSpeed(int width, int height) {
-#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
+#ifdef MOBILE_ARM
// On mobile platform, use a lower speed setting for lower resolutions for
// CPUs with 4 or more cores.
RTC_DCHECK_GT(number_of_cores_, 0);
@@ -850,12 +854,10 @@
// for getting the denoised frame from the encoder and using that
// when encoding lower resolution streams. Would it work with the
// multi-res encoding feature?
+#ifdef MOBILE_ARM
denoiserState denoiser_state = kDenoiserOnYOnly;
-#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
- denoiser_state = kDenoiserOnYOnly;
#else
- denoiser_state = kDenoiserOnAdaptive;
+ denoiserState denoiser_state = kDenoiserOnAdaptive;
#endif
libvpx_->codec_control(
&encoders_[0], VP8E_SET_NOISE_SENSITIVITY,
diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
index 4850c26..e26169f 100644
--- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
+++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc
@@ -47,6 +47,11 @@
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
+#if (defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64)) && \
+ (defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS))
+#define MOBILE_ARM
+#endif
+
namespace webrtc {
namespace {
@@ -201,13 +206,12 @@
}
bool AllowDenoising() {
- // Do not enable the denoiser on ARM since optimization is pending.
- // Denoiser is on by default on other platforms.
-#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \
- !defined(ANDROID)
- return true;
-#else
+#ifdef MOBILE_ARM
+ // Keep the denoiser disabled on mobile ARM devices. It increases encode time
+ // by up to 16%.
return false;
+#else
+ return true;
#endif
}
@@ -766,9 +770,8 @@
} else if (width * height >= 640 * 360 && number_of_cores > 2) {
return 2;
} else {
-// Use 2 threads for low res on ARM.
-#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
- defined(WEBRTC_ANDROID)
+// Use 2 threads for low res on mobile ARM.
+#ifdef MOBILE_ARM
if (width * height >= 320 * 180 && number_of_cores > 2) {
return 2;
}
@@ -1998,7 +2001,7 @@
LibvpxVp9Encoder::GetDefaultPerformanceFlags() {
PerformanceFlags flags;
flags.use_per_layer_speed = true;
-#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID)
+#ifdef MOBILE_ARM
// Speed 8 on all layers for all resolutions.
flags.settings_by_resolution[0] = {.base_layer_speed = 8,
.high_layer_speed = 8,
diff --git a/video/pc_full_stack_tests.cc b/video/pc_full_stack_tests.cc
index 83b0683..d7e7a4b 100644
--- a/video/pc_full_stack_tests.cc
+++ b/video/pc_full_stack_tests.cc
@@ -182,9 +182,7 @@
}
// VP9 2nd profile isn't supported on android arm and arm 64.
-#if (defined(WEBRTC_ANDROID) && \
- (defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM))) || \
- (defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64))
+#if defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM)
#define MAYBE_Pc_Generator_Net_Delay_0_0_Plr_0_VP9Profile2 \
DISABLED_Pc_Generator_Net_Delay_0_0_Plr_0_VP9Profile2
#else