From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sat, 20 Jan 2018 21:17:27 +0100
Subject: openH264: enable ARM/ARM64 optimizations

Enable the optimizations not only for ChromeOS but for all compatbile ARM/ARM64 architectures
Limit threads auto-detect only for iOS
---
 content/renderer/media_recorder/h264_encoder.cc |  6 ++---
 third_party/openh264/BUILD.gn                   | 31 +++++++++++++++++++------
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/content/renderer/media_recorder/h264_encoder.cc b/content/renderer/media_recorder/h264_encoder.cc
--- a/content/renderer/media_recorder/h264_encoder.cc
+++ b/content/renderer/media_recorder/h264_encoder.cc
@@ -150,11 +150,11 @@ void H264Encoder::ConfigureEncoderOnEncodingTaskRunner(const gfx::Size& size) {
     init_params.iRCMode = RC_OFF_MODE;
   }
 
-#if defined(OS_CHROMEOS)
-  init_params.iMultipleThreadIdc = 0;
-#else
+#if defined(OS_MACOSX)
   // Threading model: Set to 1 due to https://crbug.com/583348.
   init_params.iMultipleThreadIdc = 1;
+#else
+  init_params.iMultipleThreadIdc = 0;
 #endif
 
   // TODO(mcasas): consider reducing complexity if there are few CPUs available.
diff --git a/third_party/openh264/BUILD.gn b/third_party/openh264/BUILD.gn
--- a/third_party/openh264/BUILD.gn
+++ b/third_party/openh264/BUILD.gn
@@ -16,11 +16,16 @@ config("config") {
     # HAVE_NEON and __chromeos__ are needed for enabling NEON on ChromeOS
     # devices.
     defines += [
-      "HAVE_NEON",
       "__chromeos__",
     ]
   }
 
+  if (target_cpu == "arm" || target_cpu == "arm64") {
+    defines += [
+      "HAVE_NEON",
+    ]
+  }
+
   # GCC and clang flags. MSVS (is_win && !is_clang) does not use cflags.
   if (!is_win || is_clang) {
     cflags += [
@@ -125,8 +130,12 @@ if (use_assembler) {
 
 source_set("common") {
   sources = openh264_common_sources
-  if (is_chromeos && target_cpu == "arm") {
-    sources += openh264_common_sources_asm_arm
+  if (is_chromeos || is_android) {
+    if (target_cpu == "arm") {
+      sources += openh264_common_sources_asm_arm
+    } else if (target_cpu == "arm64") {
+      sources += openh264_common_sources_asm_arm64
+    }
   }
   include_dirs = openh264_common_include_dirs
 
@@ -151,8 +160,12 @@ source_set("common") {
 
 source_set("processing") {
   sources = openh264_processing_sources
-  if (is_chromeos && target_cpu == "arm") {
-    sources += openh264_processing_sources_asm_arm
+  if (is_chromeos || is_android) {
+    if (target_cpu == "arm") {
+      sources += openh264_processing_sources_asm_arm
+    } else if (target_cpu == "arm64") {
+      sources += openh264_processing_sources_asm_arm64
+    }
   }
   include_dirs = openh264_processing_include_dirs
 
@@ -170,8 +183,12 @@ source_set("processing") {
 
 source_set("encoder") {
   sources = openh264_encoder_sources
-  if (is_chromeos && target_cpu == "arm") {
-    sources += openh264_encoder_sources_asm_arm
+  if (is_chromeos || is_android) {
+    if (target_cpu == "arm") {
+      sources += openh264_encoder_sources_asm_arm
+    } else if (target_cpu == "arm64") {
+      sources += openh264_encoder_sources_asm_arm64
+    }
   }
   include_dirs = openh264_encoder_include_dirs
 
-- 
2.11.0

