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}
This commit is contained in:
Sergey Silkin 2023-10-06 13:18:41 +02:00 committed by WebRTC LUCI CQ
parent f166fe245c
commit a4b2b95f99
4 changed files with 28 additions and 21 deletions

View File

@ -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 @@ int LibaomAv1Encoder::NumberOfThreads(int width,
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;
}

View File

@ -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::InitEncode(const VideoCodec* inst,
}
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 @@ int LibvpxVp8Encoder::InitAndSetControlSettings() {
// 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,

View File

@ -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 @@ vpx_svc_ref_frame_config_t Vp9References(
}
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 @@ int LibvpxVp9Encoder::NumberOfThreads(int width,
} 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::PerformanceFlags
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,

View File

@ -182,9 +182,7 @@ TEST(PCGenericDescriptorTest,
}
// 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