From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sun, 16 Dec 2018 15:24:19 +0100
Subject: AV1 codec support

libaom build fixes (requires -fPIC)
Report AV1 as playable on Android
---
 media/base/mime_util_internal.cc                                    | 6 +++++-
 third_party/libaom/BUILD.gn                                         | 6 ++++--
 third_party/libaom/libaom_srcs.gni                                  | 5 +++++
 .../source/config/linux/arm-neon-cpu-detect/config/aom_config.asm   | 2 +-
 .../source/config/linux/arm-neon-cpu-detect/config/aom_config.h     | 2 +-
 .../libaom/source/config/linux/arm-neon/config/aom_config.asm       | 2 +-
 third_party/libaom/source/config/linux/arm-neon/config/aom_config.h | 2 +-
 third_party/libaom/source/config/linux/arm/config/aom_config.asm    | 2 +-
 third_party/libaom/source/config/linux/arm/config/aom_config.h      | 2 +-
 third_party/libaom/source/config/linux/arm64/config/aom_config.asm  | 2 +-
 third_party/libaom/source/config/linux/arm64/config/aom_config.h    | 2 +-
 .../libaom/source/config/linux/generic/config/aom_config.asm        | 2 +-
 third_party/libaom/source/config/linux/generic/config/aom_config.h  | 2 +-
 third_party/libaom/source/config/linux/x64/config/aom_config.asm    | 2 +-
 third_party/libaom/source/config/linux/x64/config/aom_config.h      | 2 +-
 15 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/media/base/mime_util_internal.cc b/media/base/mime_util_internal.cc
--- a/media/base/mime_util_internal.cc
+++ b/media/base/mime_util_internal.cc
@@ -539,9 +539,13 @@ bool MimeUtil::IsCodecSupportedOnAndroid(
     case THEORA:
       return false;
 
-    // AV1 is not supported on Android yet.
+    // AV1 is supported on Android.
     case AV1:
+#if BUILDFLAG(ENABLE_AV1_DECODER)
+      return true;
+#else
       return false;
+#endif
 
     // ----------------------------------------------------------------------
     // The remaining codecs may be supported depending on platform abilities.
diff --git a/third_party/libaom/BUILD.gn b/third_party/libaom/BUILD.gn
--- a/third_party/libaom/BUILD.gn
+++ b/third_party/libaom/BUILD.gn
@@ -74,7 +74,7 @@ if (enable_libaom_decoder) {
       sources = aom_dsp_common_asm_sse2
       sources += aom_dsp_common_asm_ssse3
       sources += aom_ports_asm_x86
-      defines = [ "CHROMIUM" ]
+      defines = [ "CHROMIUM", "PIC" ]
       include_dirs = libaom_include_dirs
     }
 
@@ -158,7 +158,7 @@ if (enable_libaom_decoder) {
       configs += [ "//build/config/compiler:no_chromium_code" ]
       if (current_cpu == "arm") {
         configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
-        cflags = [ "-mfpu=neon" ]
+        cflags = [ "-mfpu=neon", "-fPIC" ]
       }
       configs += [ ":libaom_config" ]
 
@@ -203,6 +203,8 @@ if (enable_libaom_decoder) {
     if (current_cpu == "arm64" || cpu_arch_full == "arm-neon" ||
         cpu_arch_full == "arm-neon-cpu-detect") {
       deps += [ ":libaom_intrinsics_neon" ]
+      # will detect CPU
+      sources += aom_ports_arm_sources
     }
     if (is_android) {
       deps += [ "//third_party/android_tools:cpu_features" ]
diff --git a/third_party/libaom/libaom_srcs.gni b/third_party/libaom/libaom_srcs.gni
--- a/third_party/libaom/libaom_srcs.gni
+++ b/third_party/libaom/libaom_srcs.gni
@@ -488,6 +488,11 @@ aom_mem_sources = [
 
 aom_ports_asm_x86 = [ "//third_party/libaom/source/libaom/aom_ports/emms.asm" ]
 
+aom_ports_arm_sources = [
+  "//third_party/libaom/source/libaom/aom_ports/arm_cpudetect.c",
+  "//third_party/libaom/source/libaom/aom_ports/arm.h",
+ ]
+
 aom_rtcd_sources = [
   "//third_party/libaom/source/libaom/aom_dsp/aom_dsp_rtcd_defs.pl",
   "//third_party/libaom/source/libaom/aom_dsp/aom_dsp_rtcd.c",
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.asm
@@ -45,7 +45,7 @@ CONFIG_MULTITHREAD equ 1
 CONFIG_NORMAL_TILE_MODE equ 1
 CONFIG_ONE_PASS_SVM equ 0
 CONFIG_OS_SUPPORT equ 1
-CONFIG_PIC equ 0
+CONFIG_PIC equ 1
 CONFIG_RD_DEBUG equ 0
 CONFIG_RUNTIME_CPU_DETECT equ 1
 CONFIG_SHARED equ 0
diff --git a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h
--- a/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/arm-neon-cpu-detect/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 1
 #define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.asm
@@ -45,7 +45,7 @@ CONFIG_MULTITHREAD equ 1
 CONFIG_NORMAL_TILE_MODE equ 1
 CONFIG_ONE_PASS_SVM equ 0
 CONFIG_OS_SUPPORT equ 1
-CONFIG_PIC equ 0
+CONFIG_PIC equ 1
 CONFIG_RD_DEBUG equ 0
 CONFIG_RUNTIME_CPU_DETECT equ 0
 CONFIG_SHARED equ 0
diff --git a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h
--- a/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/arm-neon/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 0
 #define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_config.asm b/third_party/libaom/source/config/linux/arm/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/arm/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/arm/config/aom_config.asm
@@ -45,7 +45,7 @@ CONFIG_MULTITHREAD equ 1
 CONFIG_NORMAL_TILE_MODE equ 1
 CONFIG_ONE_PASS_SVM equ 0
 CONFIG_OS_SUPPORT equ 1
-CONFIG_PIC equ 0
+CONFIG_PIC equ 1
 CONFIG_RD_DEBUG equ 0
 CONFIG_RUNTIME_CPU_DETECT equ 0
 CONFIG_SHARED equ 0
diff --git a/third_party/libaom/source/config/linux/arm/config/aom_config.h b/third_party/libaom/source/config/linux/arm/config/aom_config.h
--- a/third_party/libaom/source/config/linux/arm/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/arm/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 0
 #define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/arm64/config/aom_config.asm b/third_party/libaom/source/config/linux/arm64/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/arm64/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/arm64/config/aom_config.asm
@@ -45,7 +45,7 @@ CONFIG_MULTITHREAD equ 1
 CONFIG_NORMAL_TILE_MODE equ 1
 CONFIG_ONE_PASS_SVM equ 0
 CONFIG_OS_SUPPORT equ 1
-CONFIG_PIC equ 0
+CONFIG_PIC equ 1
 CONFIG_RD_DEBUG equ 0
 CONFIG_RUNTIME_CPU_DETECT equ 0
 CONFIG_SHARED equ 0
diff --git a/third_party/libaom/source/config/linux/arm64/config/aom_config.h b/third_party/libaom/source/config/linux/arm64/config/aom_config.h
--- a/third_party/libaom/source/config/linux/arm64/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/arm64/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 0
 #define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_config.asm b/third_party/libaom/source/config/linux/generic/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/generic/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/generic/config/aom_config.asm
@@ -45,7 +45,7 @@ CONFIG_MULTITHREAD equ 1
 CONFIG_NORMAL_TILE_MODE equ 1
 CONFIG_ONE_PASS_SVM equ 0
 CONFIG_OS_SUPPORT equ 1
-CONFIG_PIC equ 0
+CONFIG_PIC equ 1
 CONFIG_RD_DEBUG equ 0
 CONFIG_RUNTIME_CPU_DETECT equ 1
 CONFIG_SHARED equ 0
diff --git a/third_party/libaom/source/config/linux/generic/config/aom_config.h b/third_party/libaom/source/config/linux/generic/config/aom_config.h
--- a/third_party/libaom/source/config/linux/generic/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/generic/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 1
 #define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_config.asm b/third_party/libaom/source/config/linux/x64/config/aom_config.asm
--- a/third_party/libaom/source/config/linux/x64/config/aom_config.asm
+++ b/third_party/libaom/source/config/linux/x64/config/aom_config.asm
@@ -35,7 +35,7 @@
 %define CONFIG_NORMAL_TILE_MODE 1
 %define CONFIG_ONE_PASS_SVM 0
 %define CONFIG_OS_SUPPORT 1
-%define CONFIG_PIC 0
+%define CONFIG_PIC 1
 %define CONFIG_RD_DEBUG 0
 %define CONFIG_RUNTIME_CPU_DETECT 1
 %define CONFIG_SHARED 0
diff --git a/third_party/libaom/source/config/linux/x64/config/aom_config.h b/third_party/libaom/source/config/linux/x64/config/aom_config.h
--- a/third_party/libaom/source/config/linux/x64/config/aom_config.h
+++ b/third_party/libaom/source/config/linux/x64/config/aom_config.h
@@ -47,7 +47,7 @@
 #define CONFIG_NORMAL_TILE_MODE 1
 #define CONFIG_ONE_PASS_SVM 0
 #define CONFIG_OS_SUPPORT 1
-#define CONFIG_PIC 0
+#define CONFIG_PIC 1
 #define CONFIG_RD_DEBUG 0
 #define CONFIG_RUNTIME_CPU_DETECT 1
 #define CONFIG_SHARED 0
-- 
2.11.0

