summaryrefslogtreecommitdiffstats
path: root/third_party/aom/build
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/aom/build
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/aom/build')
-rw-r--r--third_party/aom/build/cmake/aom_config.c.template13
-rw-r--r--third_party/aom/build/cmake/aom_config_defaults.cmake235
-rw-r--r--third_party/aom/build/cmake/aom_configure.cmake489
-rw-r--r--third_party/aom/build/cmake/aom_experiment_deps.cmake24
-rw-r--r--third_party/aom/build/cmake/aom_install.cmake98
-rw-r--r--third_party/aom/build/cmake/aom_optimization.cmake279
-rw-r--r--third_party/aom/build/cmake/compiler_flags.cmake385
-rw-r--r--third_party/aom/build/cmake/compiler_tests.cmake179
-rw-r--r--third_party/aom/build/cmake/cpu.cmake108
-rw-r--r--third_party/aom/build/cmake/dist.cmake64
-rw-r--r--third_party/aom/build/cmake/exports.cmake76
-rw-r--r--third_party/aom/build/cmake/exports_sources.cmake35
-rw-r--r--third_party/aom/build/cmake/generate_aom_config_templates.cmake92
-rw-r--r--third_party/aom/build/cmake/generate_exports.cmake69
-rw-r--r--third_party/aom/build/cmake/pkg_config.cmake69
-rwxr-xr-xthird_party/aom/build/cmake/rtcd.pl430
-rw-r--r--third_party/aom/build/cmake/sanitizers.cmake46
-rw-r--r--third_party/aom/build/cmake/toolchains/android.cmake53
-rw-r--r--third_party/aom/build/cmake/toolchains/arm-ios-common.cmake24
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-ios.cmake23
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-linux-clang.cmake30
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake40
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-macos.cmake16
-rw-r--r--third_party/aom/build/cmake/toolchains/arm64-mingw-gcc.cmake36
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7-ios.cmake31
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake46
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7-mingw-gcc.cmake39
-rw-r--r--third_party/aom/build/cmake/toolchains/armv7s-ios.cmake31
-rw-r--r--third_party/aom/build/cmake/toolchains/i686-linux-gcc.cmake34
-rw-r--r--third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake24
-rw-r--r--third_party/aom/build/cmake/toolchains/ppc-linux-gcc.cmake36
-rw-r--r--third_party/aom/build/cmake/toolchains/riscv-linux-gcc.cmake36
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake28
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-linux.cmake20
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-macos.cmake19
-rw-r--r--third_party/aom/build/cmake/toolchains/x86-mingw-gcc.cmake40
-rw-r--r--third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake25
-rw-r--r--third_party/aom/build/cmake/toolchains/x86_64-macos.cmake16
-rw-r--r--third_party/aom/build/cmake/toolchains/x86_64-mingw-gcc.cmake37
-rw-r--r--third_party/aom/build/cmake/util.cmake173
-rw-r--r--third_party/aom/build/cmake/version.cmake67
-rwxr-xr-xthird_party/aom/build/cmake/version.pl114
42 files changed, 3729 insertions, 0 deletions
diff --git a/third_party/aom/build/cmake/aom_config.c.template b/third_party/aom/build/cmake/aom_config.c.template
new file mode 100644
index 0000000000..93a6d8f1ad
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_config.c.template
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) @year@, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+#include "aom/aom_codec.h"
+static const char* const cfg = "${AOM_CMAKE_CONFIG}";
+const char *aom_codec_build_config(void) {return cfg;}
diff --git a/third_party/aom/build/cmake/aom_config_defaults.cmake b/third_party/aom/build/cmake/aom_config_defaults.cmake
new file mode 100644
index 0000000000..da7de4b0f4
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_config_defaults.cmake
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2016, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
+# This file sets default values for libaom configuration variables. All libaom
+# config variables are added to the CMake variable cache via the macros provided
+# in util.cmake.
+
+#
+# The variables in this section of the file are detected at configuration time,
+# but can be overridden via the use of CONFIG_* and ENABLE_* values also defined
+# in this file.
+#
+
+set_aom_detect_var(INLINE "" "Sets INLINE value for current target.")
+
+# CPUs.
+set_aom_detect_var(AOM_ARCH_AARCH64 0 "Enables AArch64 architecture.")
+set_aom_detect_var(AOM_ARCH_ARM 0 "Enables ARM architecture.")
+set_aom_detect_var(AOM_ARCH_PPC 0 "Enables PPC architecture.")
+set_aom_detect_var(AOM_ARCH_X86 0 "Enables X86 architecture.")
+set_aom_detect_var(AOM_ARCH_X86_64 0 "Enables X86_64 architecture.")
+
+# Arm/AArch64 feature flags.
+set_aom_detect_var(HAVE_NEON 0 "Enables Neon intrinsics optimizations.")
+set_aom_detect_var(HAVE_ARM_CRC32 0 "Enables Arm CRC32 optimizations.")
+set_aom_detect_var(HAVE_NEON_DOTPROD 0
+ "Enables Armv8.2-A Neon dotprod intrinsics optimizations.")
+set_aom_detect_var(HAVE_NEON_I8MM 0
+ "Enables Armv8.2-A Neon i8mm intrinsics optimizations.")
+set_aom_detect_var(HAVE_SVE 0 "Enables Armv8.2-A SVE intrinsics optimizations.")
+
+# PPC feature flags.
+set_aom_detect_var(HAVE_VSX 0 "Enables VSX optimizations.")
+
+# x86/x86_64 feature flags.
+set_aom_detect_var(HAVE_MMX 0 "Enables MMX optimizations. ")
+set_aom_detect_var(HAVE_SSE 0 "Enables SSE optimizations.")
+set_aom_detect_var(HAVE_SSE2 0 "Enables SSE2 optimizations.")
+set_aom_detect_var(HAVE_SSE3 0 "Enables SSE3 optimizations.")
+set_aom_detect_var(HAVE_SSSE3 0 "Enables SSSE3 optimizations.")
+set_aom_detect_var(HAVE_SSE4_1 0 "Enables SSE 4.1 optimizations.")
+set_aom_detect_var(HAVE_SSE4_2 0 "Enables SSE 4.2 optimizations.")
+set_aom_detect_var(HAVE_AVX 0 "Enables AVX optimizations.")
+set_aom_detect_var(HAVE_AVX2 0 "Enables AVX2 optimizations.")
+
+# Flags describing the build environment.
+set_aom_detect_var(HAVE_FEXCEPT 0
+ "Internal flag, GNU fenv.h present for target.")
+set_aom_detect_var(HAVE_PTHREAD_H 0 "Internal flag, target pthread support.")
+set_aom_detect_var(HAVE_UNISTD_H 0
+ "Internal flag, unistd.h present for target.")
+set_aom_detect_var(HAVE_WXWIDGETS 0 "WxWidgets present.")
+
+#
+# Variables in this section can be set from the CMake command line or from
+# within the CMake GUI. The variables control libaom features.
+#
+
+# Build configuration flags.
+set_aom_config_var(AOM_RTCD_FLAGS ""
+ "Arguments to pass to rtcd.pl. Separate with ';'")
+set_aom_config_var(CONFIG_AV1_DECODER 1 "Enable AV1 decoder.")
+set_aom_config_var(CONFIG_AV1_ENCODER 1 "Enable AV1 encoder.")
+set_aom_config_var(CONFIG_BIG_ENDIAN 0 "Internal flag.")
+set_aom_config_var(CONFIG_FPMT_TEST 0 "Enable FPMT testing.")
+set_aom_config_var(CONFIG_GCC 0 "Building with GCC (detect).")
+set_aom_config_var(CONFIG_GCOV 0 "Enable gcov support.")
+set_aom_config_var(CONFIG_GPROF 0 "Enable gprof support.")
+set_aom_config_var(CONFIG_LIBYUV 1 "Enables libyuv scaling/conversion support.")
+
+set_aom_config_var(CONFIG_AV1_HIGHBITDEPTH 1
+ "Build with high bitdepth support.")
+set_aom_config_var(CONFIG_AV1_TEMPORAL_DENOISING 0
+ "Build with temporal denoising support.")
+set_aom_config_var(CONFIG_MULTITHREAD 1 "Multithread support.")
+set_aom_config_var(CONFIG_OS_SUPPORT 0 "Internal flag.")
+set_aom_config_var(CONFIG_PIC 0 "Build with PIC enabled.")
+set_aom_config_var(CONFIG_REALTIME_ONLY 0
+ "Build for RTC-only. See aomcx.h for all disabled features.")
+set_aom_config_var(CONFIG_RUNTIME_CPU_DETECT 1 "Runtime CPU detection support.")
+set_aom_config_var(CONFIG_SHARED 0 "Build shared libs.")
+set_aom_config_var(CONFIG_WEBM_IO 1 "Enables WebM support.")
+
+# Debugging flags.
+set_aom_config_var(CONFIG_DEBUG 0 "Enable debug-only code.")
+set_aom_config_var(CONFIG_EXCLUDE_SIMD_MISMATCH 0
+ "Exclude mismatch in SIMD functions for testing/debugging.")
+set_aom_config_var(CONFIG_MISMATCH_DEBUG 0 "Mismatch debugging flag.")
+
+# AV1 feature flags.
+set_aom_config_var(CONFIG_ACCOUNTING 0 "Enables bit accounting.")
+set_aom_config_var(CONFIG_ANALYZER 0 "Enables bit stream analyzer.")
+set_aom_config_var(CONFIG_COEFFICIENT_RANGE_CHECKING 0
+ "Coefficient range check.")
+set_aom_config_var(CONFIG_DENOISE 1
+ "Denoise/noise modeling support in encoder.")
+set_aom_config_var(CONFIG_INSPECTION 0 "Enables bitstream inspection.")
+set_aom_config_var(CONFIG_INTERNAL_STATS 0 "Enables internal encoder stats.")
+set_aom_config_var(FORCE_HIGHBITDEPTH_DECODING 0
+ "Force high bitdepth decoding pipeline on 8-bit input.")
+mark_as_advanced(FORCE_HIGHBITDEPTH_DECODING)
+set_aom_config_var(CONFIG_MAX_DECODE_PROFILE 2
+ "Max profile to support decoding.")
+set_aom_config_var(
+ CONFIG_NORMAL_TILE_MODE 0
+ "Only enables general decoding (disables large scale tile decoding).")
+set_aom_config_var(CONFIG_SIZE_LIMIT 0 "Limit max decode width/height.")
+set_aom_config_var(CONFIG_SPATIAL_RESAMPLING 1 "Spatial resampling.")
+set_aom_config_var(CONFIG_TUNE_BUTTERAUGLI 0
+ "Enable encoding tuning for Butteraugli.")
+set_aom_config_var(CONFIG_TUNE_VMAF 0 "Enable encoding tuning for VMAF.")
+set_aom_config_var(DECODE_HEIGHT_LIMIT 0 "Set limit for decode height.")
+set_aom_config_var(DECODE_WIDTH_LIMIT 0 "Set limit for decode width.")
+set_aom_config_var(STATIC_LINK_JXL 0 "Statically link the JPEG-XL library.")
+
+# AV1 experiment flags.
+set_aom_config_var(CONFIG_BITRATE_ACCURACY 0
+ "AV1 experiment: Improve bitrate accuracy.")
+set_aom_config_var(
+ CONFIG_BITRATE_ACCURACY_BL 0
+ "AV1 experiment: Baseline of improve bitrate accuracy experiment.")
+set_aom_config_var(CONFIG_BITSTREAM_DEBUG 0
+ "AV1 experiment: Bitstream debugging.")
+set_aom_config_var(
+ CONFIG_COLLECT_COMPONENT_TIMING 0
+ "AV1 experiment: Collect encoding component timing information.")
+set_aom_config_var(
+ CONFIG_COLLECT_PARTITION_STATS 0
+ "AV1 experiment: Collect partition timing stats. Can be 1 or 2.")
+set_aom_config_var(CONFIG_COLLECT_RD_STATS 0 "AV1 experiment.")
+set_aom_config_var(
+ CONFIG_DISABLE_FULL_PIXEL_SPLIT_8X8 1
+ "AV1 experiment: Disable full_pixel_motion_search_based_split on BLOCK_8X8.")
+set_aom_config_var(CONFIG_ENTROPY_STATS 0 "AV1 experiment.")
+set_aom_config_var(CONFIG_INTER_STATS_ONLY 0 "AV1 experiment.")
+set_aom_config_var(CONFIG_NN_V2 0
+ "AV1 experiment: Fully-connected neural nets ver.2.")
+set_aom_config_var(CONFIG_OPTICAL_FLOW_API 0
+ "AV1 experiment: for optical flow API.")
+set_aom_config_var(CONFIG_PARTITION_SEARCH_ORDER 0
+ "AV1 experiment: Use alternative partition search order.")
+set_aom_config_var(CONFIG_RATECTRL_LOG 0
+ "AV1 experiment: Log rate control decision.")
+set_aom_config_var(CONFIG_RD_COMMAND 0
+ "AV1 experiment: Use external rdmult and q_index.")
+set_aom_config_var(CONFIG_RD_DEBUG 0 "AV1 experiment.")
+set_aom_config_var(
+ CONFIG_RT_ML_PARTITIONING 0
+ "AV1 experiment: Build with ML-based partitioning for Real Time.")
+set_aom_config_var(CONFIG_SPEED_STATS 0 "AV1 experiment.")
+set_aom_config_var(CONFIG_TFLITE 0
+ "AV1 experiment: Enable tensorflow lite library.")
+set_aom_config_var(CONFIG_THREE_PASS 0
+ "AV1 experiment: Enable three-pass encoding.")
+set_aom_config_var(CONFIG_OUTPUT_FRAME_SIZE 0
+ "AV1 experiment: Output frame size information.")
+set_aom_config_var(
+ CONFIG_SALIENCY_MAP 0
+ "AV1 experiment: Enable saliency map based encoding tuning for VMAF.")
+set_aom_config_var(CONFIG_CWG_C013 0
+ "AV1 experiment: Support for 7.x and 8.x levels.")
+# Add this change to make aomenc reported PSNR consistent with libvmaf result.
+set_aom_config_var(CONFIG_LIBVMAF_PSNR_PEAK 1
+ "Use libvmaf PSNR peak for 10- and 12-bit")
+
+#
+# Variables in this section control optional features of the build system.
+#
+set_aom_option_var(ENABLE_CCACHE "Enable ccache support." OFF)
+set_aom_option_var(ENABLE_DECODE_PERF_TESTS "Enables decoder performance tests"
+ OFF)
+set_aom_option_var(ENABLE_DISTCC "Enable distcc support." OFF)
+set_aom_option_var(ENABLE_DOCS
+ "Enable documentation generation (doxygen required)." ON)
+set_aom_option_var(ENABLE_ENCODE_PERF_TESTS "Enables encoder performance tests"
+ OFF)
+set_aom_option_var(ENABLE_EXAMPLES "Enables build of example code." ON)
+set_aom_option_var(ENABLE_GOMA "Enable goma support." OFF)
+set_aom_option_var(
+ ENABLE_IDE_TEST_HOSTING
+ "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
+set_aom_option_var(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
+set_aom_option_var(ENABLE_TESTDATA "Enables unit test data download targets."
+ ON)
+set_aom_option_var(ENABLE_TESTS "Enables unit tests." ON)
+set_aom_option_var(ENABLE_TOOLS "Enable applications in tools sub directory."
+ ON)
+set_aom_option_var(ENABLE_WERROR "Converts warnings to errors at compile time."
+ OFF)
+
+# Arm/AArch64 assembly/intrinsics flags.
+set_aom_option_var(ENABLE_NEON
+ "Enables Neon optimizations on Arm/AArch64 targets." ON)
+set_aom_option_var(ENABLE_ARM_CRC32 "Enables Arm CRC32 optimizations." ON)
+set_aom_option_var(
+ ENABLE_NEON_DOTPROD
+ "Enables Armv8.2-A Neon dotprod optimizations on AArch64 targets." ON)
+set_aom_option_var(
+ ENABLE_NEON_I8MM
+ "Enables Armv8.2-A Neon i8mm optimizations on AArch64 targets." ON)
+set_aom_option_var(ENABLE_SVE
+ "Enables Armv8.2-A SVE optimizations on AArch64 targets." ON)
+
+# VSX intrinsics flags.
+set_aom_option_var(ENABLE_VSX "Enables VSX optimizations on PowerPC targets."
+ ON)
+
+# x86/x86_64 assembly/intrinsics flags.
+set_aom_option_var(ENABLE_MMX "Enables MMX optimizations on x86/x86_64 targets."
+ ON)
+set_aom_option_var(ENABLE_SSE "Enables SSE optimizations on x86/x86_64 targets."
+ ON)
+set_aom_option_var(ENABLE_SSE2
+ "Enables SSE2 optimizations on x86/x86_64 targets." ON)
+set_aom_option_var(ENABLE_SSE3
+ "Enables SSE3 optimizations on x86/x86_64 targets." ON)
+set_aom_option_var(ENABLE_SSSE3
+ "Enables SSSE3 optimizations on x86/x86_64 targets." ON)
+set_aom_option_var(ENABLE_SSE4_1
+ "Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
+set_aom_option_var(ENABLE_SSE4_2
+ "Enables SSE4_2 optimizations on x86/x86_64 targets." ON)
+set_aom_option_var(ENABLE_AVX "Enables AVX optimizations on x86/x86_64 targets."
+ ON)
+set_aom_option_var(ENABLE_AVX2
+ "Enables AVX2 optimizations on x86/x86_64 targets." ON)
diff --git a/third_party/aom/build/cmake/aom_configure.cmake b/third_party/aom/build/cmake/aom_configure.cmake
new file mode 100644
index 0000000000..917e7cac5d
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_configure.cmake
@@ -0,0 +1,489 @@
+#
+# Copyright (c) 2016, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_
+set(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_ 1)
+
+include(FindThreads)
+
+include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+include("${AOM_ROOT}/build/cmake/aom_experiment_deps.cmake")
+include("${AOM_ROOT}/build/cmake/aom_optimization.cmake")
+include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
+include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
+if(DEFINED CONFIG_LOWBITDEPTH)
+ message(WARNING "CONFIG_LOWBITDEPTH has been removed. \
+ Use -DFORCE_HIGHBITDEPTH_DECODING=1 instead of -DCONFIG_LOWBITDEPTH=0 \
+ and -DFORCE_HIGHBITDEPTH_DECODING=0 instead of -DCONFIG_LOWBITDEPTH=1.")
+ if(NOT CONFIG_LOWBITDEPTH)
+ set(FORCE_HIGHBITDEPTH_DECODING
+ 1
+ CACHE STRING "${cmake_cmdline_helpstring}" FORCE)
+ endif()
+endif()
+
+if(FORCE_HIGHBITDEPTH_DECODING AND NOT CONFIG_AV1_HIGHBITDEPTH)
+ change_config_and_warn(CONFIG_AV1_HIGHBITDEPTH 1
+ "FORCE_HIGHBITDEPTH_DECODING")
+endif()
+
+if(CONFIG_THREE_PASS AND NOT CONFIG_AV1_DECODER)
+ change_config_and_warn(CONFIG_THREE_PASS 0 "CONFIG_AV1_DECODER=0")
+endif()
+
+# Generate the user config settings.
+list(APPEND aom_build_vars ${AOM_CONFIG_VARS} ${AOM_OPTION_VARS})
+foreach(cache_var ${aom_build_vars})
+ get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING)
+ if(cache_var_helpstring STREQUAL cmake_cmdline_helpstring)
+ set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}")
+ endif()
+endforeach()
+string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
+
+# Detect target CPU.
+if(NOT AOM_TARGET_CPU)
+ string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" cpu_lowercase)
+ if(cpu_lowercase STREQUAL "amd64" OR cpu_lowercase STREQUAL "x86_64")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(AOM_TARGET_CPU "x86")
+ elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(AOM_TARGET_CPU "x86_64")
+ else()
+ message(
+ FATAL_ERROR "--- Unexpected pointer size (${CMAKE_SIZEOF_VOID_P}) for\n"
+ " CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}\n"
+ " CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}\n"
+ " CMAKE_GENERATOR=${CMAKE_GENERATOR}\n")
+ endif()
+ elseif(cpu_lowercase STREQUAL "i386" OR cpu_lowercase STREQUAL "x86")
+ set(AOM_TARGET_CPU "x86")
+ elseif(cpu_lowercase MATCHES "^arm")
+ set(AOM_TARGET_CPU "${cpu_lowercase}")
+ elseif(cpu_lowercase MATCHES "aarch64")
+ set(AOM_TARGET_CPU "arm64")
+ elseif(cpu_lowercase MATCHES "^ppc")
+ set(AOM_TARGET_CPU "ppc")
+ else()
+ message(WARNING "The architecture ${CMAKE_SYSTEM_PROCESSOR} is not "
+ "supported, falling back to the generic target")
+ set(AOM_TARGET_CPU "generic")
+ endif()
+endif()
+
+if(CMAKE_TOOLCHAIN_FILE) # Add toolchain file to config string.
+ if(IS_ABSOLUTE "${CMAKE_TOOLCHAIN_FILE}")
+ file(RELATIVE_PATH toolchain_path "${AOM_CONFIG_DIR}"
+ "${CMAKE_TOOLCHAIN_FILE}")
+ else()
+ set(toolchain_path "${CMAKE_TOOLCHAIN_FILE}")
+ endif()
+ set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${toolchain_path}\\\"")
+ set(AOM_CMAKE_CONFIG "${toolchain_string} ${AOM_CMAKE_CONFIG}")
+else()
+
+ # Add detected CPU to the config string.
+ set(AOM_CMAKE_CONFIG "-DAOM_TARGET_CPU=${AOM_TARGET_CPU} ${AOM_CMAKE_CONFIG}")
+endif()
+set(AOM_CMAKE_CONFIG "-G \\\"${CMAKE_GENERATOR}\\\" ${AOM_CMAKE_CONFIG}")
+file(RELATIVE_PATH source_path "${AOM_CONFIG_DIR}" "${AOM_ROOT}")
+set(AOM_CMAKE_CONFIG "cmake ${source_path} ${AOM_CMAKE_CONFIG}")
+string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
+
+message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}")
+set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME})
+
+string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lowercase)
+if(build_type_lowercase STREQUAL "debug")
+ set(CONFIG_DEBUG 1)
+endif()
+
+if(BUILD_SHARED_LIBS)
+ set(CONFIG_PIC 1)
+ set(CONFIG_SHARED 1)
+elseif(NOT CONFIG_PIC)
+ # Update the variable only when it does not carry the CMake assigned help
+ # string for variables specified via the command line. This allows the user to
+ # force CONFIG_PIC=0.
+ unset(cache_helpstring)
+ get_property(cache_helpstring CACHE CONFIG_PIC PROPERTY HELPSTRING)
+ if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
+ aom_check_c_compiles("pie_check" "
+ #if !(__pie__ || __PIE__)
+ #error Neither __pie__ or __PIE__ are set
+ #endif
+ extern void unused(void);
+ void unused(void) {}" HAVE_PIE)
+
+ if(HAVE_PIE)
+ # If -fpie or -fPIE are used ensure the assembly code has PIC enabled to
+ # avoid DT_TEXTRELs: /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
+ set(CONFIG_PIC 1)
+ message(
+ "CONFIG_PIC enabled for position independent executable (PIE) build")
+ endif()
+ endif()
+ unset(cache_helpstring)
+endif()
+
+if(NOT MSVC)
+ if(CONFIG_PIC)
+
+ # TODO(tomfinegan): clang needs -pie in CMAKE_EXE_LINKER_FLAGS for this to
+ # work.
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ if(AOM_TARGET_SYSTEM STREQUAL "Linux"
+ AND AOM_TARGET_CPU MATCHES "^armv[78]")
+ set(AOM_AS_FLAGS ${AOM_AS_FLAGS} --defsym PIC=1)
+ else()
+ set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -DPIC)
+ endif()
+ endif()
+endif()
+
+if(AOM_TARGET_CPU STREQUAL "x86" OR AOM_TARGET_CPU STREQUAL "x86_64")
+ find_program(CMAKE_ASM_NASM_COMPILER yasm $ENV{YASM_PATH})
+ if(NOT CMAKE_ASM_NASM_COMPILER OR ENABLE_NASM)
+ unset(CMAKE_ASM_NASM_COMPILER CACHE)
+ find_program(CMAKE_ASM_NASM_COMPILER nasm $ENV{NASM_PATH})
+ endif()
+
+ include(CheckLanguage)
+ check_language(ASM_NASM)
+ if(CMAKE_ASM_NASM_COMPILER)
+ get_asm_obj_format("objformat")
+ unset(CMAKE_ASM_NASM_OBJECT_FORMAT)
+ set(CMAKE_ASM_NASM_OBJECT_FORMAT ${objformat})
+ enable_language(ASM_NASM)
+ if(CMAKE_ASM_NASM_COMPILER_ID STREQUAL "NASM")
+ test_nasm()
+ endif()
+ # Xcode requires building the objects manually, so pass the object format
+ # flag.
+ if(XCODE)
+ set(AOM_AS_FLAGS -f ${objformat} ${AOM_AS_FLAGS})
+ endif()
+ else()
+ message(
+ FATAL_ERROR
+ "Unable to find assembler. Install 'yasm' or 'nasm.' "
+ "To build without optimizations, add -DAOM_TARGET_CPU=generic to "
+ "your cmake command line.")
+ endif()
+ string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
+elseif(AOM_TARGET_CPU MATCHES "arm")
+ if(AOM_TARGET_SYSTEM STREQUAL "Darwin")
+ if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
+ endif()
+ set(AOM_AS_FLAGS -arch ${AOM_TARGET_CPU} -isysroot ${CMAKE_OSX_SYSROOT})
+ elseif(AOM_TARGET_SYSTEM STREQUAL "Windows")
+ if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER} -c -mimplicit-it=always)
+ endif()
+ else()
+ if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER as)
+ endif()
+ endif()
+ include(CheckLanguage)
+ check_language(ASM)
+ if(NOT CMAKE_ASM_COMPILER)
+ message(
+ FATAL_ERROR
+ "Unable to find assembler and optimizations are enabled."
+ "Searched for ${CMAKE_ASM_COMPILER}. Install it, add it to your path,"
+ "or set the assembler directly by adding "
+ "-DCMAKE_ASM_COMPILER=<assembler path> to your CMake command line."
+ "To build without optimizations, add -DAOM_TARGET_CPU=generic to your "
+ "cmake command line.")
+ endif()
+ enable_language(ASM)
+ string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
+endif()
+
+if(CONFIG_ANALYZER)
+ find_package(wxWidgets REQUIRED adv base core)
+ include(${wxWidgets_USE_FILE})
+endif()
+
+if(NOT MSVC AND CMAKE_C_COMPILER_ID MATCHES "GNU\|Clang")
+ set(CONFIG_GCC 1)
+endif()
+
+if(CONFIG_GCOV)
+ message("--- Testing for CONFIG_GCOV support.")
+ require_linker_flag("-fprofile-arcs -ftest-coverage")
+ require_compiler_flag("-fprofile-arcs -ftest-coverage" YES)
+endif()
+
+if(CONFIG_GPROF)
+ message("--- Testing for CONFIG_GPROF support.")
+ require_compiler_flag("-pg" YES)
+endif()
+
+if(AOM_TARGET_SYSTEM MATCHES "Darwin\|Linux\|Windows\|Android")
+ set(CONFIG_OS_SUPPORT 1)
+endif()
+
+if(AOM_TARGET_SYSTEM STREQUAL "Windows")
+ # The default _WIN32_WINNT value in MinGW is 0x0502 (Windows XP with SP2). Set
+ # it to 0x0601 (Windows 7).
+ add_compiler_flag_if_supported("-D_WIN32_WINNT=0x0601")
+ # Quiet warnings related to fopen, printf, etc.
+ add_compiler_flag_if_supported("-D_CRT_SECURE_NO_WARNINGS")
+endif()
+
+#
+# Fix CONFIG_* dependencies. This must be done before including cpu.cmake to
+# ensure RTCD_CONFIG_* are properly set.
+fix_experiment_configs()
+
+# Test compiler support.
+aom_get_inline("INLINE")
+
+# Don't just check for pthread.h, but use the result of the full pthreads
+# including a linking check in FindThreads above.
+set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
+aom_check_source_compiles("unistd_check" "#include <unistd.h>" HAVE_UNISTD_H)
+
+if(NOT WIN32)
+ aom_push_var(CMAKE_REQUIRED_LIBRARIES "m")
+ aom_check_c_compiles("fenv_check" "#define _GNU_SOURCE
+ #include <fenv.h>
+ void unused(void) {
+ (void)unused;
+ (void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
+ }" HAVE_FEXCEPT)
+ aom_pop_var(CMAKE_REQUIRED_LIBRARIES)
+endif()
+
+include("${AOM_ROOT}/build/cmake/cpu.cmake")
+
+if(ENABLE_CCACHE)
+ set_compiler_launcher(ENABLE_CCACHE ccache)
+endif()
+
+if(ENABLE_DISTCC)
+ set_compiler_launcher(ENABLE_DISTCC distcc)
+endif()
+
+if(ENABLE_GOMA)
+ set_compiler_launcher(ENABLE_GOMA gomacc)
+endif()
+
+if(NOT CONFIG_AV1_DECODER AND NOT CONFIG_AV1_ENCODER)
+ message(FATAL_ERROR "Decoder and encoder disabled, nothing to build.")
+endif()
+
+if(DECODE_HEIGHT_LIMIT OR DECODE_WIDTH_LIMIT)
+ change_config_and_warn(CONFIG_SIZE_LIMIT 1
+ "DECODE_HEIGHT_LIMIT and DECODE_WIDTH_LIMIT")
+endif()
+
+if(CONFIG_SIZE_LIMIT)
+ if(NOT DECODE_HEIGHT_LIMIT OR NOT DECODE_WIDTH_LIMIT)
+ message(FATAL_ERROR "When setting CONFIG_SIZE_LIMIT, DECODE_HEIGHT_LIMIT "
+ "and DECODE_WIDTH_LIMIT must be set.")
+ endif()
+endif()
+
+# Test compiler flags.
+if(MSVC)
+ # It isn't possible to specify C99 conformance for MSVC. MSVC doesn't support
+ # C++ standards modes earlier than C++14.
+ add_cxx_flag_if_supported("/std:c++14")
+ add_compiler_flag_if_supported("/W3")
+
+ # Disable MSVC warnings that suggest making code non-portable.
+ add_compiler_flag_if_supported("/wd4996")
+ if(ENABLE_WERROR)
+ add_compiler_flag_if_supported("/WX")
+ endif()
+else()
+ require_c_flag("-std=c99" YES)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
+ AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ # Microsoft's C++ Standard Library requires C++14 as it's MSVC's default and
+ # minimum supported C++ version. If Clang is using this Standard Library
+ # implementation, it cannot target C++11.
+ require_cxx_flag_nomsvc("-std=c++14" YES)
+ else()
+ require_cxx_flag_nomsvc("-std=c++11" YES)
+ endif()
+ add_compiler_flag_if_supported("-Wall")
+ add_compiler_flag_if_supported("-Wdisabled-optimization")
+ add_compiler_flag_if_supported("-Wextra")
+ # Prior to version 3.19.0 cmake would fail to parse the warning emitted by gcc
+ # with this flag. Note the order of this check and -Wextra-semi-stmt is
+ # important due to is_flag_present() matching substrings with string(FIND
+ # ...).
+ if(CMAKE_VERSION VERSION_LESS "3.19"
+ AND CMAKE_C_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
+ add_cxx_flag_if_supported("-Wextra-semi")
+ else()
+ add_compiler_flag_if_supported("-Wextra-semi")
+ endif()
+ add_compiler_flag_if_supported("-Wextra-semi-stmt")
+ add_compiler_flag_if_supported("-Wfloat-conversion")
+ add_compiler_flag_if_supported("-Wformat=2")
+ add_c_flag_if_supported("-Wimplicit-function-declaration")
+ add_compiler_flag_if_supported("-Wlogical-op")
+ add_compiler_flag_if_supported("-Wpointer-arith")
+ add_compiler_flag_if_supported("-Wshadow")
+ add_compiler_flag_if_supported("-Wshorten-64-to-32")
+ add_compiler_flag_if_supported("-Wsign-compare")
+ add_compiler_flag_if_supported("-Wstring-conversion")
+ add_compiler_flag_if_supported("-Wtype-limits")
+ add_compiler_flag_if_supported("-Wuninitialized")
+ add_compiler_flag_if_supported("-Wunreachable-code-aggressive")
+ add_compiler_flag_if_supported("-Wunused")
+ add_compiler_flag_if_supported("-Wvla")
+ add_cxx_flag_if_supported("-Wc++14-extensions")
+ add_cxx_flag_if_supported("-Wc++17-extensions")
+ add_cxx_flag_if_supported("-Wc++20-extensions")
+
+ if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address|undefined")
+
+ # This combination has more stack overhead, so we account for it by
+ # providing higher stack limit than usual.
+ add_c_flag_if_supported("-Wstack-usage=285000")
+ add_cxx_flag_if_supported("-Wstack-usage=270000")
+ elseif(CONFIG_RD_DEBUG) # Another case where higher stack usage is expected.
+ add_c_flag_if_supported("-Wstack-usage=135000")
+ add_cxx_flag_if_supported("-Wstack-usage=240000")
+ else()
+ add_c_flag_if_supported("-Wstack-usage=100000")
+ add_cxx_flag_if_supported("-Wstack-usage=240000")
+ endif()
+
+ if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address")
+ # Disable no optimization warning when compiling with sanitizers
+ add_compiler_flag_if_supported("-Wno-disabled-optimization")
+ endif()
+
+ # Add -Wundef only for C files to avoid massive gtest warning spam.
+ add_c_flag_if_supported("-Wundef")
+
+ # Quiet gcc 6 vs 7 abi warnings:
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
+ if(AOM_TARGET_CPU MATCHES "arm")
+ add_cxx_flag_if_supported("-Wno-psabi")
+ endif()
+
+ if(ENABLE_WERROR)
+ add_compiler_flag_if_supported("-Werror")
+ endif()
+
+ if(build_type_lowercase MATCHES "rel")
+ add_compiler_flag_if_supported("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
+ endif()
+ add_compiler_flag_if_supported("-D_LARGEFILE_SOURCE")
+ add_compiler_flag_if_supported("-D_FILE_OFFSET_BITS=64")
+endif()
+
+# Prior to r23, or with ANDROID_USE_LEGACY_TOOLCHAIN_FILE set,
+# android.toolchain.cmake would set normal (non-cache) versions of variables
+# like CMAKE_C_FLAGS_RELEASE which would mask the ones added to the cache
+# variable in add_compiler_flag_if_supported(), etc. As a workaround we add
+# everything accumulated in AOM_C/CXX_FLAGS to the normal versions. This could
+# also be addressed by reworking the flag tests and adding the results directly
+# to target_compile_options() as in e.g., libgav1, but that's a larger task.
+# https://github.com/android/ndk/wiki/Changelog-r23#changes
+if(ANDROID
+ AND ("${ANDROID_NDK_MAJOR}" LESS 23 OR ANDROID_USE_LEGACY_TOOLCHAIN_FILE))
+ foreach(lang C;CXX)
+ string(STRIP "${AOM_${lang}_FLAGS}" AOM_${lang}_FLAGS)
+ if(AOM_${lang}_FLAGS)
+ foreach(config ${AOM_${lang}_CONFIGS})
+ set(${config} "${${config}} ${AOM_${lang}_FLAGS}")
+ endforeach()
+ endif()
+ endforeach()
+endif()
+
+set(AOM_LIB_LINK_TYPE PUBLIC)
+if(EMSCRIPTEN)
+
+ # Avoid CMake generation time errors resulting from collisions with the form
+ # of target_link_libraries() used by Emscripten.cmake.
+ unset(AOM_LIB_LINK_TYPE)
+endif()
+
+# Generate aom_config templates.
+set(aom_config_asm_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
+set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
+execute_process(
+ COMMAND ${CMAKE_COMMAND}
+ -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR} -DAOM_ROOT=${AOM_ROOT} -P
+ "${AOM_ROOT}/build/cmake/generate_aom_config_templates.cmake")
+
+# Generate aom_config.{asm,h}.
+configure_file("${aom_config_asm_template}"
+ "${AOM_CONFIG_DIR}/config/aom_config.asm")
+configure_file("${aom_config_h_template}"
+ "${AOM_CONFIG_DIR}/config/aom_config.h")
+
+# Read the current git hash.
+find_package(Git)
+if(NOT GIT_FOUND)
+ message("--- Git missing, version will be read from CHANGELOG.")
+endif()
+
+string(TIMESTAMP year "%Y")
+configure_file("${AOM_ROOT}/build/cmake/aom_config.c.template"
+ "${AOM_CONFIG_DIR}/config/aom_config.c")
+
+# Find Perl and generate the RTCD sources.
+find_package(Perl)
+if(NOT PERL_FOUND)
+ message(FATAL_ERROR "Perl is required to build libaom.")
+endif()
+
+set(AOM_RTCD_CONFIG_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
+ "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
+ "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl")
+set(AOM_RTCD_HEADER_FILE_LIST "${AOM_CONFIG_DIR}/config/aom_dsp_rtcd.h"
+ "${AOM_CONFIG_DIR}/config/aom_scale_rtcd.h"
+ "${AOM_CONFIG_DIR}/config/av1_rtcd.h")
+set(AOM_RTCD_SOURCE_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
+ "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
+ "${AOM_ROOT}/av1/common/av1_rtcd.c")
+set(AOM_RTCD_SYMBOL_LIST aom_dsp_rtcd aom_scale_rtcd av1_rtcd)
+list(LENGTH AOM_RTCD_SYMBOL_LIST AOM_RTCD_CUSTOM_COMMAND_COUNT)
+math(EXPR AOM_RTCD_CUSTOM_COMMAND_COUNT "${AOM_RTCD_CUSTOM_COMMAND_COUNT} - 1")
+
+foreach(NUM RANGE ${AOM_RTCD_CUSTOM_COMMAND_COUNT})
+ list(GET AOM_RTCD_CONFIG_FILE_LIST ${NUM} AOM_RTCD_CONFIG_FILE)
+ list(GET AOM_RTCD_HEADER_FILE_LIST ${NUM} AOM_RTCD_HEADER_FILE)
+ list(GET AOM_RTCD_SOURCE_FILE_LIST ${NUM} AOM_RTCD_SOURCE_FILE)
+ list(GET AOM_RTCD_SYMBOL_LIST ${NUM} AOM_RTCD_SYMBOL)
+ execute_process(
+ COMMAND
+ ${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/rtcd.pl"
+ --arch=${AOM_TARGET_CPU}
+ --sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS}
+ --config=${AOM_CONFIG_DIR}/config/aom_config.h ${AOM_RTCD_CONFIG_FILE}
+ OUTPUT_FILE ${AOM_RTCD_HEADER_FILE})
+endforeach()
+
+# Generate aom_version.h.
+execute_process(COMMAND ${CMAKE_COMMAND}
+ -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
+ -DAOM_ROOT=${AOM_ROOT}
+ -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
+ -DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
+ "${AOM_ROOT}/build/cmake/version.cmake")
diff --git a/third_party/aom/build/cmake/aom_experiment_deps.cmake b/third_party/aom/build/cmake/aom_experiment_deps.cmake
new file mode 100644
index 0000000000..3bbeb0c874
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_experiment_deps.cmake
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_
+set(AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_ 1)
+
+# Adjusts CONFIG_* CMake variables to address conflicts between active AV1
+# experiments.
+macro(fix_experiment_configs)
+
+ if(CONFIG_ANALYZER)
+ change_config_and_warn(CONFIG_INSPECTION 1 CONFIG_ANALYZER)
+ endif()
+
+endmacro()
diff --git a/third_party/aom/build/cmake/aom_install.cmake b/third_party/aom/build/cmake/aom_install.cmake
new file mode 100644
index 0000000000..2c263e96b9
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_install.cmake
@@ -0,0 +1,98 @@
+#
+# Copyright (c) 2018, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom.h"
+ "${AOM_ROOT}/aom/aom_codec.h" "${AOM_ROOT}/aom/aom_frame_buffer.h"
+ "${AOM_ROOT}/aom/aom_image.h" "${AOM_ROOT}/aom/aom_integer.h")
+
+if(CONFIG_AV1_DECODER)
+ list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom_decoder.h"
+ "${AOM_ROOT}/aom/aomdx.h")
+endif()
+
+if(CONFIG_AV1_ENCODER)
+ list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aomcx.h"
+ "${AOM_ROOT}/aom/aom_encoder.h"
+ "${AOM_ROOT}/aom/aom_external_partition.h")
+endif()
+
+# Generate aom.pc and setup dependencies to ensure it is created when necessary.
+# Note: aom.pc generation uses GNUInstallDirs:
+# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
+macro(setup_aom_install_targets)
+ if(NOT XCODE)
+ include("GNUInstallDirs")
+ set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc")
+
+ # Create a library target for creating aom.pc.
+ create_no_op_source_file(aom_pc c AOM_PKG_CONFIG_SOURCES)
+ add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
+
+ # Setup a rule to generate aom.pc.
+ add_custom_command(
+ OUTPUT "${AOM_PKG_CONFIG_FILE}"
+ COMMAND ${CMAKE_COMMAND} ARGS
+ -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
+ -DAOM_ROOT=${AOM_ROOT}
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+ -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
+ -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
+ -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
+ -DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
+ -DCMAKE_THREAD_LIBS_INIT=${CMAKE_THREAD_LIBS_INIT}
+ -DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
+ -DCONFIG_TUNE_VMAF=${CONFIG_TUNE_VMAF}
+ -DCONFIG_TUNE_BUTTERAUGLI=${CONFIG_TUNE_BUTTERAUGLI}
+ -DCONFIG_SALIENCY_MAP=${CONFIG_SALIENCY_MAP}
+ -DCONFIG_TFLITE=${CONFIG_TFLITE}
+ -P
+ "${AOM_ROOT}/build/cmake/pkg_config.cmake"
+ COMMENT "Writing aom.pc"
+ VERBATIM)
+
+ # Explicitly add a dependency on the pkg-config file to ensure it's built.
+ get_property(aom_pc_sources TARGET aom_pc PROPERTY SOURCES)
+ set_source_files_properties(${aom_pc_sources} OBJECT_DEPENDS
+ "${AOM_PKG_CONFIG_FILE}")
+
+ # Our pkg-config file carries version information: add a dependency on the
+ # version rule.
+ add_dependencies(aom_pc aom_version)
+
+ if(CONFIG_AV1_DECODER)
+ if(ENABLE_EXAMPLES)
+ list(APPEND AOM_INSTALL_BINS aomdec)
+ endif()
+ endif()
+
+ if(CONFIG_AV1_ENCODER)
+ if(ENABLE_EXAMPLES)
+ list(APPEND AOM_INSTALL_BINS aomenc)
+ endif()
+ endif()
+
+ if(BUILD_SHARED_LIBS)
+ set(AOM_INSTALL_LIBS aom aom_static)
+ else()
+ set(AOM_INSTALL_LIBS aom)
+ endif()
+
+ # Setup the install rules. install() will automatically prepend
+ # CMAKE_INSTALL_PREFIX to relative paths
+ install(FILES ${AOM_INSTALL_INCS}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aom")
+ install(FILES "${AOM_PKG_CONFIG_FILE}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ install(TARGETS ${AOM_INSTALL_LIBS};${AOM_INSTALL_BINS}
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+ endif()
+endmacro()
diff --git a/third_party/aom/build/cmake/aom_optimization.cmake b/third_party/aom/build/cmake/aom_optimization.cmake
new file mode 100644
index 0000000000..0f93228eef
--- /dev/null
+++ b/third_party/aom/build/cmake/aom_optimization.cmake
@@ -0,0 +1,279 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_
+set(AOM_BUILD_CMAKE_AOM_OPTIMIZATION_CMAKE_ 1)
+
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
+# Translate $flag to one which MSVC understands, and write the new flag to the
+# variable named by $translated_flag (or unset it, when MSVC needs no flag).
+function(get_msvc_intrinsic_flag flag translated_flag)
+ if("${flag}" STREQUAL "-mavx")
+ set(${translated_flag} "/arch:AVX" PARENT_SCOPE)
+ elseif("${flag}" STREQUAL "-mavx2")
+ set(${translated_flag} "/arch:AVX2" PARENT_SCOPE)
+ else()
+
+ # MSVC does not need flags for intrinsics flavors other than AVX/AVX2.
+ unset(${translated_flag} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Adds an object library target. Terminates generation if $flag is not supported
+# by the current compiler. $flag is the intrinsics flag required by the current
+# compiler, and is added to the compile flags for all sources in $sources.
+# $opt_name is used to name the target. $target_to_update is made dependent upon
+# the created target.
+#
+# Note: this function always updates the aom, and aom_static targets because
+# OBJECT libraries have rules that disallow the direct addition of .o files to
+# them as dependencies. Static and shared libraries do not have this limitation.
+function(add_intrinsics_object_library flag opt_name target_to_update sources)
+ if("${${sources}}" STREQUAL "")
+ return()
+ endif()
+ set(target_name ${target_to_update}_${opt_name}_intrinsics)
+ add_library(${target_name} OBJECT ${${sources}})
+ set_property(TARGET ${target_name} PROPERTY FOLDER ${AOM_TARGET_CPU})
+
+ # MSVC does not need flags for intrinsics flavors other than AVX/AVX2.
+ # However, for clang-cl, the default is SSE2, and the MSVC frontend does not
+ # provide any flags to enable SSE3 up to SSE4.1. So we need to restrict the
+ # usage of MSVC-style flags to only the real MSVC.
+ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ get_msvc_intrinsic_flag("${flag}" "flag")
+ endif()
+
+ if("${flag}" STREQUAL "-mavx2")
+ unset(FLAG_SUPPORTED)
+ check_c_compiler_flag("-mno-avx256-split-unaligned-load" FLAG_SUPPORTED)
+ if(${FLAG_SUPPORTED})
+ set(flag "${flag} -mno-avx256-split-unaligned-load")
+ endif()
+
+ unset(FLAG_SUPPORTED)
+ check_c_compiler_flag("-mno-avx256-split-unaligned-store" FLAG_SUPPORTED)
+ if(${FLAG_SUPPORTED})
+ set(flag "${flag} -mno-avx256-split-unaligned-store")
+ endif()
+ endif()
+
+ if(flag)
+ separate_arguments(flag)
+ target_compile_options(${target_name} PUBLIC ${flag})
+ endif()
+
+ target_sources(aom PRIVATE $<TARGET_OBJECTS:${target_name}>)
+ if(BUILD_SHARED_LIBS)
+ target_sources(aom_static PRIVATE $<TARGET_OBJECTS:${target_name}>)
+ endif()
+
+ # Add the new lib target to the global list of aom library targets.
+ list(APPEND AOM_LIB_TARGETS ${target_name})
+ set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
+endfunction()
+
+# Adds sources in list named by $sources to $target and adds $flag to the
+# compile flags for each source file.
+function(add_intrinsics_source_to_target flag target sources)
+ target_sources(${target} PRIVATE ${${sources}})
+ if(MSVC)
+ get_msvc_intrinsic_flag("${flag}" "flag")
+ endif()
+ if(flag)
+ foreach(source ${${sources}})
+ set_property(SOURCE ${source} APPEND PROPERTY COMPILE_FLAGS ${flag})
+ endforeach()
+ endif()
+endfunction()
+
+# Writes object format for the current target to the var named by $out_format,
+# or terminates the build when the object format for the current target is
+# unknown.
+function(get_asm_obj_format out_format)
+ if("${AOM_TARGET_CPU}" STREQUAL "x86_64")
+ if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(objformat "macho64")
+ elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "CYGWIN"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ set(objformat "win64")
+ else()
+ set(objformat "elf64")
+ endif()
+ elseif("${AOM_TARGET_CPU}" STREQUAL "x86")
+ if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(objformat "macho32")
+ elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "CYGWIN"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ set(objformat "win32")
+ else()
+ set(objformat "elf32")
+ endif()
+ else()
+ message(
+ FATAL_ERROR "Unknown obj format: ${AOM_TARGET_CPU}-${AOM_TARGET_SYSTEM}")
+ endif()
+
+ set(${out_format} ${objformat} PARENT_SCOPE)
+endfunction()
+
+# Adds library target named $lib_name for ASM files in variable named by
+# $asm_sources. Builds an output directory path from $lib_name. Links $lib_name
+# into the aom library target(s). Generates a C file with an unused no-op
+# function to ensure that all cmake generators can determine the linker
+# language, and that build tools don't complain that an object exposes no
+# symbols.
+#
+# In Xcode-based builds every step described above happens twice, and
+# directory/target/object names are updated to include _shared and _static
+# suffixes.
+function(add_asm_library lib_name asm_sources)
+ if("${${asm_sources}}" STREQUAL "")
+ return()
+ endif()
+
+ if(XCODE)
+ # CMake's generator does not output a build rule for Nasm files. Moreover,
+ # it makes Xcode believe Nasm files are of type "sourcecode" instead of
+ # "sourcecode.nasm", which prevents even the default rule from applying.
+ # This default rule is broken, though, because it doesn't apply any of the
+ # flags specified for ASM_NASM. See https://discourse.cmake.org/t/building-
+ # nasm-files-with-xcode/7934
+ list(APPEND asm_configs "static")
+ if(BUILD_SHARED_LIBS)
+ list(APPEND asm_configs "shared")
+ endif()
+
+ set(as_executable "${CMAKE_ASM_NASM_COMPILER}")
+ if(NOT as_executable)
+ set(as_executable "${CMAKE_ASM_COMPILER}")
+ endif()
+
+ foreach(asm_config ${asm_configs})
+ set(asm_lib_name ${lib_name}_${asm_config})
+ set(asm_lib_obj_dir "${AOM_CONFIG_DIR}/asm_objects/${asm_lib_name}")
+ if(NOT EXISTS "${asm_lib_obj_dir}")
+ file(MAKE_DIRECTORY "${asm_lib_obj_dir}")
+ endif()
+
+ foreach(asm_source ${${asm_sources}})
+ get_filename_component(asm_source_name "${asm_source}" NAME)
+ set(asm_object "${asm_lib_obj_dir}/${asm_source_name}.o")
+ add_custom_command(OUTPUT "${asm_object}"
+ COMMAND ${as_executable} ARGS ${AOM_AS_FLAGS}
+ -I${AOM_ROOT}/ -I${AOM_CONFIG_DIR}/ -o
+ "${asm_object}" "${asm_source}"
+ DEPENDS "${asm_source}"
+ COMMENT "Building ASM object ${asm_object}"
+ WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
+ VERBATIM)
+ if(BUILD_SHARED_LIBS AND "${asm_config}" STREQUAL "static")
+ target_sources(aom_static PRIVATE "${asm_object}")
+ else()
+ target_sources(aom PRIVATE "${asm_object}")
+ endif()
+ endforeach()
+ endforeach()
+ else()
+ # For non-Xcode generators, CMake does not need extra help. The language
+ # support takes care of it.
+ set(asm_lib_name ${lib_name})
+
+ add_library(${asm_lib_name} OBJECT ${${asm_sources}})
+ target_include_directories(${asm_lib_name}
+ PRIVATE ${AOM_ROOT} ${AOM_CONFIG_DIR})
+ target_compile_options(${asm_lib_name} PRIVATE ${AOM_AS_FLAGS})
+ set_property(TARGET ${asm_lib_name} PROPERTY FOLDER ${AOM_TARGET_CPU})
+ if(BUILD_SHARED_LIBS)
+ target_sources(aom_static PRIVATE "$<TARGET_OBJECTS:${asm_lib_name}>")
+ endif()
+ target_sources(aom PRIVATE "$<TARGET_OBJECTS:${asm_lib_name}>")
+
+ # Add the new lib target to the global list of aom library targets.
+ list(APPEND AOM_LIB_TARGETS ${asm_lib_name})
+ endif()
+
+ set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)
+endfunction()
+
+# Terminates generation if nasm found in PATH does not meet requirements.
+# Currently checks only for presence of required object formats and support for
+# the -Ox argument (multipass optimization).
+function(test_nasm)
+ execute_process(COMMAND ${CMAKE_ASM_NASM_COMPILER} -hf
+ OUTPUT_VARIABLE nasm_helptext)
+
+ if(NOT "${nasm_helptext}" MATCHES "-Ox")
+ message(
+ FATAL_ERROR "Unsupported nasm: multipass optimization not supported.")
+ endif()
+
+ if("${AOM_TARGET_CPU}" STREQUAL "x86")
+ if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ if(NOT "${nasm_helptext}" MATCHES "macho32")
+ message(
+ FATAL_ERROR "Unsupported nasm: macho32 object format not supported.")
+ endif()
+ elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ if(NOT "${nasm_helptext}" MATCHES "win32")
+ message(
+ FATAL_ERROR "Unsupported nasm: win32 object format not supported.")
+ endif()
+ else()
+ if(NOT "${nasm_helptext}" MATCHES "elf32")
+ message(
+ FATAL_ERROR "Unsupported nasm: elf32 object format not supported.")
+ endif()
+ endif()
+ else()
+ if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ if(NOT "${nasm_helptext}" MATCHES "macho64")
+ message(
+ FATAL_ERROR "Unsupported nasm: macho64 object format not supported.")
+ endif()
+ elseif("${AOM_TARGET_SYSTEM}" STREQUAL "MSYS"
+ OR "${AOM_TARGET_SYSTEM}" STREQUAL "Windows")
+ if(NOT "${nasm_helptext}" MATCHES "win64")
+ message(
+ FATAL_ERROR "Unsupported nasm: win64 object format not supported.")
+ endif()
+ else()
+ if(NOT "${nasm_helptext}" MATCHES "elf64")
+ message(
+ FATAL_ERROR "Unsupported nasm: elf64 object format not supported.")
+ endif()
+ endif()
+ endif()
+endfunction()
+
+# Adds build command for generation of rtcd C source files using
+# build/cmake/rtcd.pl. $config is the input perl file, $output is the output C
+# include file, $source is the C source file, and $symbol is used for the symbol
+# argument passed to rtcd.pl.
+function(add_rtcd_build_step config output source symbol)
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND ${PERL_EXECUTABLE} ARGS "${AOM_ROOT}/build/cmake/rtcd.pl"
+ --arch=${AOM_TARGET_CPU}
+ --sym=${symbol} ${AOM_RTCD_FLAGS}
+ --config=${AOM_CONFIG_DIR}/config/aom_config.h ${config} > ${output}
+ DEPENDS "${AOM_ROOT}/build/cmake/rtcd.pl" ${config}
+ COMMENT "Generating ${output}"
+ WORKING_DIRECTORY ${AOM_CONFIG_DIR}
+ VERBATIM)
+ set_property(SOURCE ${source} PROPERTY OBJECT_DEPENDS ${output})
+ set_property(SOURCE ${output} PROPERTY GENERATED TRUE)
+endfunction()
diff --git a/third_party/aom/build/cmake/compiler_flags.cmake b/third_party/aom/build/cmake/compiler_flags.cmake
new file mode 100644
index 0000000000..f008b964f5
--- /dev/null
+++ b/third_party/aom/build/cmake/compiler_flags.cmake
@@ -0,0 +1,385 @@
+#
+# Copyright (c) 2016, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_
+set(AOM_BUILD_CMAKE_COMPILER_FLAGS_CMAKE_ 1)
+
+include(CheckCCompilerFlag)
+include(CheckCXXCompilerFlag)
+include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
+
+# Strings used to cache flags.
+set(AOM_C_FLAGS)
+set(AOM_CXX_FLAGS)
+set(AOM_EXE_LINKER_FLAGS)
+set(AOM_FAILED_C_FLAGS)
+set(AOM_FAILED_CXX_FLAGS)
+
+# Sets variable named by $out_is_present to YES in the caller's scope when $flag
+# is found in the string variable named by $flag_cache. Sets the var to NO
+# otherwise.
+function(is_flag_present flag_cache flag out_is_present)
+ string(FIND "${${flag_cache}}" "${flag}" flag_pos)
+ if(${flag_pos} EQUAL -1)
+ set(${out_is_present} NO PARENT_SCOPE)
+ else()
+ set(${out_is_present} YES PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Appends $flag to $flags. Ignores scope via use of FORCE with set() call.
+function(append_flag flags flag)
+ string(FIND "${${flags}}" "${flag}" found)
+ if(${found} EQUAL -1)
+ set(${flags} "${${flags}} ${flag}" CACHE STRING "" FORCE)
+ endif()
+endfunction()
+
+# Checks C compiler for support of $c_flag. Adds $c_flag to all
+# $CMAKE_C_FLAGS_<CONFIG>s stored in AOM_C_CONFIGS when the compile test passes.
+# Caches $c_flag in $AOM_C_FLAGS or $AOM_FAILED_C_FLAGS depending on test
+# outcome.
+function(add_c_flag_if_supported c_flag)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ is_flag_present(AOM_C_FLAGS "${c_flag}" flag_ok)
+ is_flag_present(AOM_FAILED_C_FLAGS "${c_flag}" flag_failed)
+ if(${flag_ok} OR ${flag_failed})
+ return()
+ endif()
+
+ # Between 3.17.0 and 3.18.2 check_c_compiler_flag() sets a normal variable at
+ # parent scope while check_cxx_source_compiles() continues to set an internal
+ # cache variable, so we unset both to avoid the failure / success state
+ # persisting between checks. See
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/21207.
+ unset(C_FLAG_SUPPORTED)
+ unset(C_FLAG_SUPPORTED CACHE)
+ message("Checking C compiler flag support for: " ${c_flag})
+ check_c_compiler_flag("${c_flag}" C_FLAG_SUPPORTED)
+
+ if(${C_FLAG_SUPPORTED})
+ append_flag(AOM_C_FLAGS "${c_flag}")
+ foreach(config ${AOM_C_CONFIGS})
+ unset(C_FLAG_FOUND)
+ append_flag("${config}" "${c_flag}")
+ endforeach()
+ else()
+ append_flag(AOM_FAILED_C_FLAGS "${c_flag}")
+ endif()
+endfunction()
+
+# Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to all
+# $CMAKE_CXX_FLAGS_<CONFIG>s stored in AOM_CXX_CONFIGS when the compile test
+# passes. Caches $cxx_flag in $AOM_CXX_FLAGS or $AOM_FAILED_CXX_FLAGS depending
+# on test outcome.
+function(add_cxx_flag_if_supported cxx_flag)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ is_flag_present(AOM_CXX_FLAGS "${cxx_flag}" flag_ok)
+ is_flag_present(AOM_FAILED_CXX_FLAGS "${cxx_flag}" flag_failed)
+ if(${flag_ok} OR ${flag_failed})
+ return()
+ endif()
+
+ # Between 3.17.0 and 3.18.2 check_cxx_compiler_flag() sets a normal variable
+ # at parent scope while check_cxx_source_compiles() continues to set an
+ # internal cache variable, so we unset both to avoid the failure / success
+ # state persisting between checks. See
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/21207.
+ unset(CXX_FLAG_SUPPORTED)
+ unset(CXX_FLAG_SUPPORTED CACHE)
+ message("Checking C++ compiler flag support for: " ${cxx_flag})
+ check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED)
+
+ if(${CXX_FLAG_SUPPORTED})
+ append_flag(AOM_CXX_FLAGS "${cxx_flag}")
+ foreach(config ${AOM_CXX_CONFIGS})
+ unset(CXX_FLAG_FOUND)
+ append_flag("${config}" "${cxx_flag}")
+ endforeach()
+ else()
+ append_flag(AOM_FAILED_CXX_FLAGS "${cxx_flag}")
+ endif()
+endfunction()
+
+# Convenience method for adding a flag to both the C and C++ compiler command
+# lines.
+function(add_compiler_flag_if_supported flag)
+ add_c_flag_if_supported(${flag})
+ add_cxx_flag_if_supported(${flag})
+endfunction()
+
+# Checks C compiler for support of $c_flag and terminates generation when
+# support is not present.
+function(require_c_flag c_flag update_c_flags)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ is_flag_present(AOM_C_FLAGS "${c_flag}" flag_ok)
+ if(${flag_ok})
+ return()
+ endif()
+
+ if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
+ aom_push_var(CMAKE_EXE_LINKER_FLAGS "${AOM_EXE_LINKER_FLAGS}")
+ endif()
+
+ unset(HAVE_C_FLAG CACHE)
+ message("Checking C compiler flag support for: " ${c_flag})
+ check_c_compiler_flag("${c_flag}" HAVE_C_FLAG)
+ if(NOT HAVE_C_FLAG)
+ message(
+ FATAL_ERROR "${PROJECT_NAME} requires support for C flag: ${c_flag}.")
+ endif()
+
+ if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
+ aom_pop_var(CMAKE_EXE_LINKER_FLAGS)
+ endif()
+
+ append_flag(AOM_C_FLAGS "${c_flag}")
+ if(update_c_flags)
+ foreach(config ${AOM_C_CONFIGS})
+ set(${config} "${${config}} ${c_flag}" CACHE STRING "" FORCE)
+ endforeach()
+ endif()
+endfunction()
+
+# Checks CXX compiler for support of $cxx_flag and terminates generation when
+# support is not present.
+function(require_cxx_flag cxx_flag update_cxx_flags)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ is_flag_present(AOM_CXX_FLAGS "${cxx_flag}" flag_ok)
+ if(${flag_ok})
+ return()
+ endif()
+
+ if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
+ aom_push_var(CMAKE_EXE_LINKER_FLAGS "${AOM_EXE_LINKER_FLAGS}")
+ endif()
+
+ unset(HAVE_CXX_FLAG CACHE)
+ message("Checking C compiler flag support for: " ${cxx_flag})
+ check_cxx_compiler_flag("${cxx_flag}" HAVE_CXX_FLAG)
+ if(NOT HAVE_CXX_FLAG)
+ message(
+ FATAL_ERROR "${PROJECT_NAME} requires support for C flag: ${cxx_flag}.")
+ endif()
+
+ if(NOT "${AOM_EXE_LINKER_FLAGS}" STREQUAL "")
+ aom_pop_var(CMAKE_EXE_LINKER_FLAGS)
+ endif()
+
+ append_flag(AOM_CXX_FLAGS "${cxx_flag}")
+ if(update_cxx_flags)
+ foreach(config ${AOM_CXX_CONFIGS})
+ set(${config} "${${config}} ${cxx_flag}" CACHE STRING "" FORCE)
+ endforeach()
+ endif()
+endfunction()
+
+# Checks for support of $flag by both the C and CXX compilers. Terminates
+# generation when support is not present in both compilers.
+function(require_compiler_flag flag update_cmake_flags)
+ require_c_flag(${flag} ${update_cmake_flags})
+ require_cxx_flag(${flag} ${update_cmake_flags})
+endfunction()
+
+# Checks only non-MSVC targets for support of $c_flag and terminates generation
+# when support is not present.
+function(require_c_flag_nomsvc c_flag update_c_flags)
+ if(NOT MSVC)
+ require_c_flag(${c_flag} ${update_c_flags})
+ endif()
+endfunction()
+
+# Checks only non-MSVC targets for support of $cxx_flag and terminates
+# generation when support is not present.
+function(require_cxx_flag_nomsvc cxx_flag update_cxx_flags)
+ if(NOT MSVC)
+ require_cxx_flag(${cxx_flag} ${update_cxx_flags})
+ endif()
+endfunction()
+
+# Checks only non-MSVC targets for support of $flag by both the C and CXX
+# compilers. Terminates generation when support is not present in both
+# compilers.
+function(require_compiler_flag_nomsvc flag update_cmake_flags)
+ require_c_flag_nomsvc(${flag} ${update_cmake_flags})
+ require_cxx_flag_nomsvc(${flag} ${update_cmake_flags})
+endfunction()
+
+# Adds $preproc_def to C compiler command line (as -D$preproc_def) if not
+# already present.
+function(add_c_preproc_definition preproc_def)
+ set(preproc_def "-D${preproc_def}")
+ is_flag_present(AOM_C_FLAGS "${preproc_def}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+
+ foreach(config ${AOM_C_CONFIGS})
+ set(${config} "${${config}} ${preproc_def}" CACHE STRING "" FORCE)
+ endforeach()
+endfunction()
+
+# Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
+# already present.
+function(add_cxx_preproc_definition preproc_def)
+ set(preproc_def "-D${preproc_def}")
+ is_flag_present(AOM_CXX_FLAGS "${preproc_def}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+
+ foreach(config ${AOM_CXX_CONFIGS})
+ set(${config} "${${config}} ${preproc_def}" CACHE STRING "" FORCE)
+ endforeach()
+endfunction()
+
+# Adds $preproc_def to C and CXX compiler command line (as -D$preproc_def) if
+# not already present.
+function(add_preproc_definition preproc_def)
+ add_c_preproc_definition(${preproc_def})
+ add_cxx_preproc_definition(${preproc_def})
+endfunction()
+
+# Adds $flag to assembler command line.
+function(append_as_flag flag)
+ is_flag_present(AOM_AS_FLAGS "${flag}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+ append_flag(AOM_AS_FLAGS "${flag}")
+endfunction()
+
+# Adds $flag to the C compiler command line.
+function(append_c_flag flag)
+ is_flag_present(AOM_C_FLAGS "${flag}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+
+ foreach(config ${AOM_C_CONFIGS})
+ append_flag(${config} "${flag}")
+ endforeach()
+endfunction()
+
+# Adds $flag to the CXX compiler command line.
+function(append_cxx_flag flag)
+ is_flag_present(AOM_CXX_FLAGS "${flag}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+
+ foreach(config ${AOM_CXX_CONFIGS})
+ append_flag(${config} "${flag}")
+ endforeach()
+endfunction()
+
+# Adds $flag to the C and CXX compiler command lines.
+function(append_compiler_flag flag)
+ append_c_flag(${flag})
+ append_cxx_flag(${flag})
+endfunction()
+
+# Adds $flag to the executable linker command line when not present.
+function(append_exe_linker_flag flag)
+ is_flag_present(AOM_EXE_LINKER_FLAGS "${flag}" flag_cached)
+ if(${flag_cached})
+ return()
+ endif()
+
+ append_flag(AOM_EXE_LINKER_FLAGS "${flag}")
+ foreach(config ${AOM_EXE_LINKER_CONFIGS})
+ append_flag(${config} "${flag}")
+ endforeach()
+endfunction()
+
+# Adds $flag to the link flags for $target.
+function(append_link_flag_to_target target flag)
+ unset(target_link_flags)
+ get_target_property(target_link_flags ${target} LINK_FLAGS)
+
+ if(target_link_flags)
+ is_flag_present(target_link_flags "${flag}" flag_found)
+ if(${flag_found})
+ return()
+ endif()
+ set(target_link_flags "${target_link_flags} ${flag}")
+ else()
+ set(target_link_flags "${flag}")
+ endif()
+
+ set_target_properties(${target} PROPERTIES LINK_FLAGS ${target_link_flags})
+endfunction()
+
+# Adds $flag to executable linker flags, and makes sure C/CXX builds still work.
+function(require_linker_flag flag)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ append_exe_linker_flag(${flag})
+
+ unset(c_passed)
+ aom_check_c_compiles("LINKER_FLAG_C_TEST(${flag})" "" c_passed)
+ unset(cxx_passed)
+ aom_check_cxx_compiles("LINKER_FLAG_CXX_TEST(${flag})" "" cxx_passed)
+
+ if(NOT c_passed OR NOT cxx_passed)
+ message(FATAL_ERROR "Linker flag test for ${flag} failed.")
+ endif()
+endfunction()
+
+# Appends flags in $AOM_EXTRA_<TYPE>_FLAGS variables to the flags used at build
+# time.
+function(set_user_flags)
+
+ # Linker flags are handled first because some C/CXX flags require that a
+ # linker flag is present at link time.
+ if(AOM_EXTRA_EXE_LINKER_FLAGS)
+ is_flag_present(AOM_EXE_LINKER_FLAGS "${AOM_EXTRA_EXE_LINKER_FLAGS}"
+ extra_present)
+ if(NOT ${extra_present})
+ require_linker_flag("${AOM_EXTRA_EXE_LINKER_FLAGS}")
+ endif()
+ endif()
+ if(AOM_EXTRA_AS_FLAGS)
+
+ # TODO(tomfinegan): assembler flag testing would be a good thing to have.
+ is_flag_present(AOM_AS_FLAGS "${AOM_EXTRA_AS_FLAGS}" extra_present)
+ if(NOT ${extra_present})
+ append_flag(AOM_AS_FLAGS "${AOM_EXTRA_AS_FLAGS}")
+ endif()
+ endif()
+ if(AOM_EXTRA_C_FLAGS)
+ is_flag_present(AOM_C_FLAGS "${AOM_EXTRA_C_FLAGS}" extra_present)
+ if(NOT ${extra_present})
+ require_c_flag("${AOM_EXTRA_C_FLAGS}" YES)
+ endif()
+ endif()
+ if(AOM_EXTRA_CXX_FLAGS)
+ is_flag_present(AOM_CXX_FLAGS "${AOM_EXTRA_CXX_FLAGS}" extra_present)
+ if(NOT ${extra_present})
+ require_cxx_flag("${AOM_EXTRA_CXX_FLAGS}" YES)
+ endif()
+ endif()
+endfunction()
diff --git a/third_party/aom/build/cmake/compiler_tests.cmake b/third_party/aom/build/cmake/compiler_tests.cmake
new file mode 100644
index 0000000000..0402832253
--- /dev/null
+++ b/third_party/aom/build/cmake/compiler_tests.cmake
@@ -0,0 +1,179 @@
+#
+# Copyright (c) 2016, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_
+set(AOM_BUILD_CMAKE_COMPILER_TESTS_CMAKE_ 1)
+
+include(CheckCSourceCompiles)
+include(CheckCXXSourceCompiles)
+
+# CMake passes command line flags like this:
+#
+# * $compiler $lang_flags $lang_flags_config ...
+#
+# To ensure the flags tested here and elsewhere are obeyed a list of active
+# build configuration types is built, and flags are applied to the flag strings
+# for each configuration currently active for C and CXX builds as determined by
+# reading $CMAKE_CONFIGURATION_TYPES and $CMAKE_BUILD_TYPE. When
+# $CMAKE_CONFIGURATION_TYPES is non-empty a multi- configuration generator is in
+# use: currently this includes MSVC and Xcode. For other generators
+# $CMAKE_BUILD_TYPE is used. For both cases AOM_<LANG>_CONFIGS is populated with
+# CMake string variable names that contain flags for the currently available
+# configuration(s).
+unset(AOM_C_CONFIGS)
+unset(AOM_CXX_CONFIGS)
+list(LENGTH CMAKE_CONFIGURATION_TYPES num_configs)
+if(${num_configs} GREATER 0)
+ foreach(config ${CMAKE_CONFIGURATION_TYPES})
+ string(TOUPPER ${config} config)
+ list(APPEND AOM_C_CONFIGS "CMAKE_C_FLAGS_${config}")
+ list(APPEND AOM_CXX_CONFIGS "CMAKE_CXX_FLAGS_${config}")
+ list(APPEND AOM_EXE_LINKER_CONFIGS "CMAKE_EXE_LINKER_FLAGS_${config}")
+ endforeach()
+else()
+ string(TOUPPER ${CMAKE_BUILD_TYPE} config)
+ set(AOM_C_CONFIGS "CMAKE_C_FLAGS_${config}")
+ set(AOM_CXX_CONFIGS "CMAKE_CXX_FLAGS_${config}")
+ set(AOM_EXE_LINKER_CONFIGS "CMAKE_EXE_LINKER_FLAGS_${config}")
+endif()
+
+# The basic main() function used in all compile tests.
+set(AOM_C_MAIN "\nint main(void) { return 0; }")
+set(AOM_CXX_MAIN "\nint main() { return 0; }")
+
+# Strings containing the names of passed and failed tests.
+set(AOM_C_PASSED_TESTS)
+set(AOM_C_FAILED_TESTS)
+set(AOM_CXX_PASSED_TESTS)
+set(AOM_CXX_FAILED_TESTS)
+
+function(aom_push_var var new_value)
+ set(SAVED_${var} ${${var}} PARENT_SCOPE)
+ set(${var} "${${var}} ${new_value}" PARENT_SCOPE)
+endfunction()
+
+function(aom_pop_var var)
+ set(var ${SAVED_${var}} PARENT_SCOPE)
+ unset(SAVED_${var} PARENT_SCOPE)
+endfunction()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_C_PASSED_TESTS or $AOM_C_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset. The
+# test is not run if the test name is found in either of the passed or failed
+# test variables.
+function(aom_check_c_compiles test_name test_source result_var)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ unset(C_TEST_PASSED CACHE)
+ unset(C_TEST_FAILED CACHE)
+ string(FIND "${AOM_C_PASSED_TESTS}" "${test_name}" C_TEST_PASSED)
+ string(FIND "${AOM_C_FAILED_TESTS}" "${test_name}" C_TEST_FAILED)
+ if(${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1)
+ unset(C_TEST_COMPILED CACHE)
+ message("Running C compiler test: ${test_name}")
+ check_c_source_compiles("${test_source} ${AOM_C_MAIN}" C_TEST_COMPILED)
+ set(${result_var} ${C_TEST_COMPILED} PARENT_SCOPE)
+
+ if(C_TEST_COMPILED)
+ set(AOM_C_PASSED_TESTS
+ "${AOM_C_PASSED_TESTS} ${test_name}"
+ CACHE STRING "" FORCE)
+ else()
+ set(AOM_C_FAILED_TESTS
+ "${AOM_C_FAILED_TESTS} ${test_name}"
+ CACHE STRING "" FORCE)
+ message("C Compiler test ${test_name} failed.")
+ endif()
+ elseif(NOT ${C_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else() # ${C_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Confirms $test_source compiles and stores $test_name in one of
+# $AOM_CXX_PASSED_TESTS or $AOM_CXX_FAILED_TESTS depending on out come. When the
+# test passes $result_var is set to 1. When it fails $result_var is unset. The
+# test is not run if the test name is found in either of the passed or failed
+# test variables.
+function(aom_check_cxx_compiles test_name test_source result_var)
+ if(DEBUG_CMAKE_DISABLE_COMPILER_TESTS)
+ return()
+ endif()
+
+ unset(CXX_TEST_PASSED CACHE)
+ unset(CXX_TEST_FAILED CACHE)
+ string(FIND "${AOM_CXX_PASSED_TESTS}" "${test_name}" CXX_TEST_PASSED)
+ string(FIND "${AOM_CXX_FAILED_TESTS}" "${test_name}" CXX_TEST_FAILED)
+ if(${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1)
+ unset(CXX_TEST_COMPILED CACHE)
+ message("Running CXX compiler test: ${test_name}")
+ check_cxx_source_compiles("${test_source} ${AOM_CXX_MAIN}"
+ CXX_TEST_COMPILED)
+ set(${result_var} ${CXX_TEST_COMPILED} PARENT_SCOPE)
+
+ if(CXX_TEST_COMPILED)
+ set(AOM_CXX_PASSED_TESTS
+ "${AOM_CXX_PASSED_TESTS} ${test_name}"
+ CACHE STRING "" FORCE)
+ else()
+ set(AOM_CXX_FAILED_TESTS
+ "${AOM_CXX_FAILED_TESTS} ${test_name}"
+ CACHE STRING "" FORCE)
+ message("CXX Compiler test ${test_name} failed.")
+ endif()
+ elseif(NOT ${CXX_TEST_PASSED} EQUAL -1)
+ set(${result_var} 1 PARENT_SCOPE)
+ else() # ${CXX_TEST_FAILED} NOT EQUAL -1
+ unset(${result_var} PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Convenience function that confirms $test_source compiles as C and C++.
+# $result_var is set to 1 when both tests are successful, and 0 when one or both
+# tests fail. Note: This function is intended to be used to write to result
+# variables that are expanded via configure_file(). $result_var is set to 1 or 0
+# to allow direct usage of the value in generated source files.
+function(aom_check_source_compiles test_name test_source result_var)
+ unset(C_PASSED)
+ unset(CXX_PASSED)
+ aom_check_c_compiles(${test_name} ${test_source} C_PASSED)
+ aom_check_cxx_compiles(${test_name} ${test_source} CXX_PASSED)
+ if(C_PASSED AND CXX_PASSED)
+ set(${result_var} 1 PARENT_SCOPE)
+ else()
+ set(${result_var} 0 PARENT_SCOPE)
+ endif()
+endfunction()
+
+# When inline support is detected for the current compiler the supported
+# inlining keyword is written to $result in caller scope.
+function(aom_get_inline result)
+ aom_check_source_compiles("inline_check_1"
+ "static inline void function(void) {}"
+ HAVE_INLINE_1)
+ if(HAVE_INLINE_1 EQUAL 1)
+ set(${result} "inline" PARENT_SCOPE)
+ return()
+ endif()
+
+ # Check __inline.
+ aom_check_source_compiles("inline_check_2"
+ "static __inline void function(void) {}"
+ HAVE_INLINE_2)
+ if(HAVE_INLINE_2 EQUAL 1)
+ set(${result} "__inline" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/third_party/aom/build/cmake/cpu.cmake b/third_party/aom/build/cmake/cpu.cmake
new file mode 100644
index 0000000000..a9b7a67070
--- /dev/null
+++ b/third_party/aom/build/cmake/cpu.cmake
@@ -0,0 +1,108 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+
+if("${AOM_TARGET_CPU}" STREQUAL "arm64")
+ set(AOM_ARCH_ARM 1)
+ set(AOM_ARCH_AARCH64 1)
+ set(RTCD_ARCH_ARM "yes")
+
+ set(ARM64_FLAVORS "NEON;ARM_CRC32;NEON_DOTPROD;NEON_I8MM;SVE")
+ set(AOM_ARM_CRC32_DEFAULT_FLAG "-march=armv8-a+crc")
+ set(AOM_NEON_DOTPROD_DEFAULT_FLAG "-march=armv8.2-a+dotprod")
+ set(AOM_NEON_I8MM_DEFAULT_FLAG "-march=armv8.2-a+dotprod+i8mm")
+ set(AOM_SVE_DEFAULT_FLAG "-march=armv8.2-a+dotprod+i8mm+sve")
+
+ # Check that the compiler flag to enable each flavor is supported by the
+ # compiler. This may not be the case for new architecture features on old
+ # compiler versions.
+ foreach(flavor ${ARM64_FLAVORS})
+ if(ENABLE_${flavor} AND NOT DEFINED AOM_${flavor}_FLAG)
+ set(AOM_${flavor}_FLAG "${AOM_${flavor}_DEFAULT_FLAG}")
+ unset(FLAG_SUPPORTED)
+ check_c_compiler_flag("${AOM_${flavor}_FLAG}" FLAG_SUPPORTED)
+ if(NOT ${FLAG_SUPPORTED})
+ set(ENABLE_${flavor} 0)
+ endif()
+ endif()
+ endforeach()
+
+ # SVE requires that the Neon-SVE bridge header is also available.
+ if(ENABLE_SVE)
+ set(OLD_CMAKE_REQURED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AOM_SVE_FLAG}")
+ aom_check_source_compiles("arm_neon_sve_bridge_available" "
+#ifndef __ARM_NEON_SVE_BRIDGE
+#error 1
+#endif
+#include <arm_sve.h>
+#include <arm_neon_sve_bridge.h>" HAVE_SVE_HEADERS)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS})
+ if(HAVE_SVE_HEADERS EQUAL 0)
+ set(ENABLE_SVE 0)
+ endif()
+ endif()
+
+ foreach(flavor ${ARM64_FLAVORS})
+ if(ENABLE_${flavor})
+ set(HAVE_${flavor} 1)
+ set(RTCD_HAVE_${flavor} "yes")
+ else()
+ set(HAVE_${flavor} 0)
+ string(TOLOWER ${flavor} flavor)
+ set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-${flavor})
+ endif()
+ endforeach()
+
+elseif("${AOM_TARGET_CPU}" MATCHES "^arm")
+ set(AOM_ARCH_ARM 1)
+ set(RTCD_ARCH_ARM "yes")
+
+ if(ENABLE_NEON)
+ set(HAVE_NEON 1)
+ set(RTCD_HAVE_NEON "yes")
+ else()
+ set(HAVE_NEON 0)
+ set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-neon)
+ endif()
+
+elseif("${AOM_TARGET_CPU}" MATCHES "ppc")
+ set(AOM_ARCH_PPC 1)
+ set(RTCD_ARCH_PPC "yes")
+
+ if(ENABLE_VSX)
+ set(HAVE_VSX 1)
+ set(RTCD_HAVE_VSX "yes")
+ else()
+ set(HAVE_VSX 0)
+ set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-vsx)
+ endif()
+elseif("${AOM_TARGET_CPU}" MATCHES "^x86")
+ if("${AOM_TARGET_CPU}" STREQUAL "x86")
+ set(AOM_ARCH_X86 1)
+ set(RTCD_ARCH_X86 "yes")
+ elseif("${AOM_TARGET_CPU}" STREQUAL "x86_64")
+ set(AOM_ARCH_X86_64 1)
+ set(RTCD_ARCH_X86_64 "yes")
+ endif()
+
+ set(X86_FLAVORS "MMX;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;AVX;AVX2")
+ foreach(flavor ${X86_FLAVORS})
+ if(ENABLE_${flavor} AND NOT disable_remaining_flavors)
+ set(HAVE_${flavor} 1)
+ set(RTCD_HAVE_${flavor} "yes")
+ else()
+ set(disable_remaining_flavors 1)
+ set(HAVE_${flavor} 0)
+ string(TOLOWER ${flavor} flavor)
+ set(AOM_RTCD_FLAGS ${AOM_RTCD_FLAGS} --disable-${flavor})
+ endif()
+ endforeach()
+endif()
diff --git a/third_party/aom/build/cmake/dist.cmake b/third_party/aom/build/cmake/dist.cmake
new file mode 100644
index 0000000000..5b9fc95d41
--- /dev/null
+++ b/third_party/aom/build/cmake/dist.cmake
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+cmake_minimum_required(VERSION 3.5)
+
+# Converts spaces in $in_string to semicolons and writes the output to
+# $out_string. In CMake's eyes this converts the input string to a list.
+function(listify_string in_string out_string)
+ string(REPLACE " " ";" ${out_string} ${in_string})
+ set(${out_string} "${${out_string}}" PARENT_SCOPE)
+endfunction()
+
+set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_DIST_DIR" "AOM_DIST_INCLUDES"
+ "AOM_DIST_LIBS" "ENABLE_DOCS")
+
+foreach(arg ${REQUIRED_ARGS})
+ if("${${arg}}" STREQUAL "")
+ message(FATAL_ERROR "${arg} must not be empty.")
+ endif()
+endforeach()
+
+if(ENABLE_DOCS)
+ file(INSTALL "${AOM_CONFIG_DIR}/docs" DESTINATION "${AOM_DIST_DIR}")
+endif()
+
+if(AOM_DIST_EXAMPLES)
+ listify_string("${AOM_DIST_EXAMPLES}" "AOM_DIST_EXAMPLES")
+ foreach(example ${AOM_DIST_EXAMPLES})
+ if(NOT "${example}" MATCHES "aomdec\|aomenc")
+ file(INSTALL "${example}" DESTINATION "${AOM_DIST_DIR}/bin/examples")
+ endif()
+ endforeach()
+endif()
+
+if(AOM_DIST_TOOLS)
+ listify_string("${AOM_DIST_TOOLS}" "AOM_DIST_TOOLS")
+ foreach(tool ${AOM_DIST_TOOLS})
+ file(INSTALL "${tool}" DESTINATION "${AOM_DIST_DIR}/bin/tools")
+ endforeach()
+endif()
+
+if(AOM_DIST_APPS)
+ listify_string("${AOM_DIST_APPS}" "AOM_DIST_APPS")
+ foreach(app ${AOM_DIST_APPS})
+ file(INSTALL "${app}" DESTINATION "${AOM_DIST_DIR}/bin")
+ endforeach()
+endif()
+
+listify_string("${AOM_DIST_INCLUDES}" "AOM_DIST_INCLUDES")
+foreach(inc ${AOM_DIST_INCLUDES})
+ file(INSTALL "${inc}" DESTINATION "${AOM_DIST_DIR}/include/aom")
+endforeach()
+
+listify_string("${AOM_DIST_LIBS}" "AOM_DIST_LIBS")
+foreach(lib ${AOM_DIST_LIBS})
+ file(INSTALL "${lib}" DESTINATION "${AOM_DIST_DIR}/lib")
+endforeach()
diff --git a/third_party/aom/build/cmake/exports.cmake b/third_party/aom/build/cmake/exports.cmake
new file mode 100644
index 0000000000..1cea2b52ab
--- /dev/null
+++ b/third_party/aom/build/cmake/exports.cmake
@@ -0,0 +1,76 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_EXPORTS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_EXPORTS_CMAKE_
+set(AOM_BUILD_CMAKE_EXPORTS_CMAKE_ 1)
+
+include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
+
+# Creates the custom target which handles generation of the symbol export lists.
+function(setup_exports_target)
+ if(APPLE)
+ set(symbol_file_ext "syms")
+ elseif(WIN32)
+ set(symbol_file_ext "def")
+ else()
+ set(symbol_file_ext "ver")
+ endif()
+
+ set(aom_sym_file "${AOM_CONFIG_DIR}/libaom.${symbol_file_ext}")
+
+ add_custom_target(
+ generate_exports
+ COMMAND ${CMAKE_COMMAND}
+ -DAOM_ROOT="${AOM_ROOT}"
+ -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}"
+ -DAOM_TARGET_SYSTEM=${AOM_TARGET_SYSTEM}
+ -DAOM_SYM_FILE="${aom_sym_file}"
+ -DAOM_MSVC=${MSVC}
+ -DAOM_XCODE=${XCODE}
+ -DCMAKE_SHARED_LIBRARY_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"
+ -DCONFIG_NAME=$<CONFIG>
+ -DCONFIG_AV1_DECODER=${CONFIG_AV1_DECODER}
+ -DCONFIG_AV1_ENCODER=${CONFIG_AV1_ENCODER}
+ -DCONFIG_INSPECTION=${CONFIG_INSPECTION}
+ -DENABLE_TESTS=${ENABLE_TESTS}
+ -P
+ "${AOM_ROOT}/build/cmake/generate_exports.cmake"
+ SOURCES ${AOM_EXPORTS_SOURCES}
+ DEPENDS ${AOM_EXPORTS_SOURCES} BYPRODUCTS ${aom_sym_file})
+
+ # Make libaom depend on the exports file, and set flags to pick it up when
+ # creating the dylib.
+ add_dependencies(aom generate_exports)
+
+ if(APPLE)
+ set_property(TARGET aom
+ APPEND_STRING
+ PROPERTY LINK_FLAGS "-exported_symbols_list ${aom_sym_file}")
+ elseif(WIN32)
+ if(MSVC)
+ set_property(TARGET aom
+ APPEND_STRING
+ PROPERTY LINK_FLAGS "/DEF:${aom_sym_file}")
+ else()
+ # For MinGW and MSYS compilers, you can use either version scripts or
+ # module definition files. If the latter, it must be supplied as an
+ # "object".
+ set_property(TARGET aom
+ APPEND_STRING
+ PROPERTY LINK_FLAGS "${aom_sym_file}")
+ endif()
+ else()
+ set_property(TARGET aom
+ APPEND_STRING
+ PROPERTY LINK_FLAGS "-Wl,--version-script,${aom_sym_file}")
+ endif()
+endfunction()
diff --git a/third_party/aom/build/cmake/exports_sources.cmake b/third_party/aom/build/cmake/exports_sources.cmake
new file mode 100644
index 0000000000..46bf001d86
--- /dev/null
+++ b/third_party/aom/build/cmake/exports_sources.cmake
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_
+set(AOM_BUILD_CMAKE_EXPORTS_SOURCES_CMAKE_ 1)
+
+list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_com"
+ "${AOM_ROOT}/av1/exports_com")
+
+if(CONFIG_AV1_DECODER)
+ list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_dec"
+ "${AOM_ROOT}/av1/exports_dec")
+ if(CONFIG_INSPECTION)
+ list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/av1/exports_ident")
+ endif()
+endif()
+
+if(CONFIG_AV1_ENCODER)
+ list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_enc"
+ "${AOM_ROOT}/av1/exports_enc")
+endif()
+
+if(ENABLE_TESTS)
+ list(APPEND AOM_EXPORTS_SOURCES "${AOM_ROOT}/aom/exports_test"
+ "${AOM_ROOT}/av1/exports_test")
+endif()
diff --git a/third_party/aom/build/cmake/generate_aom_config_templates.cmake b/third_party/aom/build/cmake/generate_aom_config_templates.cmake
new file mode 100644
index 0000000000..529daaf02a
--- /dev/null
+++ b/third_party/aom/build/cmake/generate_aom_config_templates.cmake
@@ -0,0 +1,92 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+cmake_minimum_required(VERSION 3.5)
+
+string(TIMESTAMP year "%Y")
+set(asm_file_header_block "\;
+\; Copyright (c) ${year}, Alliance for Open Media. All rights reserved
+\;
+\; This source code is subject to the terms of the BSD 2 Clause License and
+\; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+\; was not distributed with this source code in the LICENSE file, you can
+\; obtain it at www.aomedia.org/license/software. If the Alliance for Open
+\; Media Patent License 1.0 was not distributed with this source code in the
+\; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+\;
+")
+set(h_file_header_block "/*
+ * Copyright (c) ${year}, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+\#ifndef AOM_CONFIG_H_
+\#define AOM_CONFIG_H_
+")
+set(cmake_file_header_block "##
+## Copyright (c) ${year}, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+")
+
+# Terminates cmake execution when $var_name is an empty string, or the variable
+# name it contains does not expand to an existing directory.
+function(check_directory_var var_name)
+ if("${var_name}" STREQUAL "")
+ message(FATAL_ERROR "The CMake variable ${var_name} must be defined.")
+ endif()
+
+ if(NOT EXISTS "${${var_name}}")
+ message(FATAL_ERROR "${${var_name}} (${var_name}) missing.")
+ endif()
+endfunction()
+
+check_directory_var(AOM_CONFIG_DIR)
+check_directory_var(AOM_ROOT)
+
+set(AOM_DEFAULTS "${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+if(NOT EXISTS "${AOM_DEFAULTS}")
+ message(
+ FATAL_ERROR "Configuration default values file (${AOM_DEFAULTS}) missing.")
+endif()
+
+include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
+list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS})
+list(SORT aom_build_vars)
+
+set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
+file(WRITE "${aom_config_h_template}" ${h_file_header_block})
+foreach(aom_var ${aom_build_vars})
+ if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS")
+ file(APPEND "${aom_config_h_template}"
+ "\#define ${aom_var} \${${aom_var}}\n")
+ endif()
+endforeach()
+file(APPEND "${aom_config_h_template}" "\#endif // AOM_CONFIG_H_")
+
+set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
+file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
+foreach(aom_var ${aom_build_vars})
+ if(NOT "${aom_var}" STREQUAL "INLINE"
+ AND NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS")
+ file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n")
+ endif()
+endforeach()
diff --git a/third_party/aom/build/cmake/generate_exports.cmake b/third_party/aom/build/cmake/generate_exports.cmake
new file mode 100644
index 0000000000..3a5f67cea6
--- /dev/null
+++ b/third_party/aom/build/cmake/generate_exports.cmake
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+cmake_minimum_required(VERSION 3.5)
+
+# CMAKE_SHARED_LIBRARY_PREFIX can be empty
+set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "AOM_TARGET_SYSTEM" "AOM_SYM_FILE"
+ "CONFIG_AV1_DECODER" "CONFIG_AV1_ENCODER")
+
+foreach(arg ${REQUIRED_ARGS})
+ if("${${arg}}" STREQUAL "")
+ message(FATAL_ERROR "${arg} must not be empty.")
+ endif()
+endforeach()
+
+include("${AOM_ROOT}/build/cmake/exports_sources.cmake")
+
+if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ set(symbol_prefix "_")
+elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
+ file(WRITE "${AOM_SYM_FILE}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n"
+ "EXPORTS\n")
+else()
+ set(symbol_suffix ";")
+endif()
+
+set(aom_sym_file "${AOM_SYM_FILE}")
+
+if("${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
+ file(REMOVE "${aom_sym_file}")
+elseif("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
+ file(WRITE "${aom_sym_file}" "LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}aom\n"
+ "EXPORTS\n")
+else()
+ file(WRITE "${aom_sym_file}" "{\nglobal:\n")
+endif()
+
+foreach(export_file ${AOM_EXPORTS_SOURCES})
+ file(STRINGS "${export_file}" exported_file_data)
+ set(exported_symbols "${exported_symbols} ${exported_file_data};")
+ string(STRIP "${exported_symbols}" exported_symbols)
+endforeach()
+
+foreach(exported_symbol ${exported_symbols})
+ string(STRIP "${exported_symbol}" exported_symbol)
+ if("${AOM_TARGET_SYSTEM}" MATCHES "Windows\|MSYS")
+ string(SUBSTRING ${exported_symbol} 0 4 export_type)
+ string(COMPARE EQUAL "${export_type}" "data" is_data)
+ if(is_data)
+ set(symbol_suffix " DATA")
+ else()
+ set(symbol_suffix "")
+ endif()
+ endif()
+ string(REGEX REPLACE "text \|data " "" "exported_symbol" "${exported_symbol}")
+ set(exported_symbol " ${symbol_prefix}${exported_symbol}${symbol_suffix}")
+ file(APPEND "${aom_sym_file}" "${exported_symbol}\n")
+endforeach()
+
+if("${aom_sym_file}" MATCHES "ver$")
+ file(APPEND "${aom_sym_file}" " \nlocal:\n *;\n};")
+endif()
diff --git a/third_party/aom/build/cmake/pkg_config.cmake b/third_party/aom/build/cmake/pkg_config.cmake
new file mode 100644
index 0000000000..c4f94808a5
--- /dev/null
+++ b/third_party/aom/build/cmake/pkg_config.cmake
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+cmake_minimum_required(VERSION 3.5)
+
+set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "CMAKE_INSTALL_PREFIX"
+ "CMAKE_INSTALL_BINDIR" "CMAKE_INSTALL_INCLUDEDIR"
+ "CMAKE_INSTALL_LIBDIR" "CMAKE_PROJECT_NAME"
+ "CONFIG_MULTITHREAD")
+
+foreach(arg ${REQUIRED_ARGS})
+ if("${${arg}}" STREQUAL "")
+ message(FATAL_ERROR "${arg} must not be empty.")
+ endif()
+endforeach()
+
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
+extract_version_string("${AOM_CONFIG_DIR}/config/aom_version.h" aom_version)
+
+# Create a version string suitable for comparison using the RPM version compare
+# algorithm: strip out everything after the number.
+string(FIND "${aom_version}" "-" dash_pos)
+if(${dash_pos} EQUAL -1)
+ set(package_version "${aom_version}")
+else()
+ string(SUBSTRING "${aom_version}" 0 ${dash_pos} package_version)
+endif()
+
+# Write pkg-config info.
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+set(bindir "${CMAKE_INSTALL_BINDIR}")
+set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
+set(libdir "${CMAKE_INSTALL_LIBDIR}")
+set(pkgconfig_file "${AOM_CONFIG_DIR}/aom.pc")
+string(TOLOWER ${CMAKE_PROJECT_NAME} pkg_name)
+file(WRITE "${pkgconfig_file}" "# libaom pkg-config.\n")
+file(APPEND "${pkgconfig_file}" "prefix=${prefix}\n")
+file(APPEND "${pkgconfig_file}" "exec_prefix=\${prefix}\n")
+file(APPEND "${pkgconfig_file}" "includedir=\${prefix}/${includedir}\n")
+file(APPEND "${pkgconfig_file}" "libdir=\${exec_prefix}/${libdir}\n\n")
+file(APPEND "${pkgconfig_file}" "Name: ${pkg_name}\n")
+file(
+ APPEND "${pkgconfig_file}"
+ "Description: Alliance for Open Media AV1 codec library v${aom_version}.\n")
+file(APPEND "${pkgconfig_file}" "Version: ${package_version}\n")
+file(APPEND "${pkgconfig_file}" "Requires:")
+if(CONFIG_TUNE_VMAF)
+ file(APPEND "${pkgconfig_file}" " libvmaf")
+endif()
+if(CONFIG_TUNE_BUTTERAUGLI)
+ file(APPEND "${pkgconfig_file}" " libjxl")
+endif()
+file(APPEND "${pkgconfig_file}" "\nConflicts:\n")
+file(APPEND "${pkgconfig_file}" "Libs: -L\${libdir} -l${pkg_name}\n")
+if(CONFIG_MULTITHREAD AND CMAKE_THREAD_LIBS_INIT)
+ file(APPEND "${pkgconfig_file}"
+ "Libs.private: -lm ${CMAKE_THREAD_LIBS_INIT}\n")
+else()
+ file(APPEND "${pkgconfig_file}" "Libs.private: -lm\n")
+endif()
+file(APPEND "${pkgconfig_file}" "Cflags: -I\${includedir}\n")
diff --git a/third_party/aom/build/cmake/rtcd.pl b/third_party/aom/build/cmake/rtcd.pl
new file mode 100755
index 0000000000..1cf52f076c
--- /dev/null
+++ b/third_party/aom/build/cmake/rtcd.pl
@@ -0,0 +1,430 @@
+#!/usr/bin/env perl
+##
+## Copyright (c) 2017, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+no strict 'refs';
+use warnings;
+use Getopt::Long;
+Getopt::Long::Configure("auto_help") if $Getopt::Long::VERSION > 2.32;
+
+my %ALL_FUNCS = ();
+my @ALL_ARCHS;
+my @ALL_FORWARD_DECLS;
+my @REQUIRES;
+
+my %opts = ();
+my %disabled = ();
+my %required = ();
+
+my @argv;
+foreach (@ARGV) {
+ $disabled{$1} = 1, next if /--disable-(.*)/;
+ $required{$1} = 1, next if /--require-(.*)/;
+ push @argv, $_;
+}
+
+# NB: use GetOptions() instead of GetOptionsFromArray() for compatibility.
+@ARGV = @argv;
+GetOptions(
+ \%opts,
+ 'arch=s',
+ 'sym=s',
+ 'config=s',
+);
+
+foreach my $opt (qw/arch config/) {
+ if (!defined($opts{$opt})) {
+ warn "--$opt is required!\n";
+ Getopt::Long::HelpMessage('-exit' => 1);
+ }
+}
+
+foreach my $defs_file (@ARGV) {
+ if (!-f $defs_file) {
+ warn "$defs_file: $!\n";
+ Getopt::Long::HelpMessage('-exit' => 1);
+ }
+}
+
+open CONFIG_FILE, $opts{config} or
+ die "Error opening config file '$opts{config}': $!\n";
+
+my %config = ();
+while (<CONFIG_FILE>) {
+ next if !/^#define\s+(?:CONFIG_|HAVE_)/;
+ chomp;
+ my @line_components = split /\s/;
+ scalar @line_components > 2 or
+ die "Invalid input passed to rtcd.pl via $opts{config}.";
+ # $line_components[0] = #define
+ # $line_components[1] = flag name (CONFIG_SOMETHING or HAVE_SOMETHING)
+ # $line_components[2] = flag value (0 or 1)
+ $config{$line_components[1]} = "$line_components[2]" eq "1" ? "yes" : "";
+}
+close CONFIG_FILE;
+
+#
+# Routines for the RTCD DSL to call
+#
+sub aom_config($) {
+ return (defined $config{$_[0]}) ? $config{$_[0]} : "";
+}
+
+sub specialize {
+ if (@_ <= 1) {
+ die "'specialize' must be called with a function name and at least one ",
+ "architecture ('C' is implied): \n@_\n";
+ }
+ my $fn=$_[0];
+ shift;
+ foreach my $opt (@_) {
+ eval "\$${fn}_${opt}=${fn}_${opt}";
+ }
+}
+
+sub add_proto {
+ my $fn = splice(@_, -2, 1);
+ my @proto = @_;
+ foreach (@proto) { tr/\t/ / }
+ $ALL_FUNCS{$fn} = \@proto;
+ specialize $fn, "c";
+}
+
+sub require {
+ foreach my $fn (keys %ALL_FUNCS) {
+ foreach my $opt (@_) {
+ my $ofn = eval "\$${fn}_${opt}";
+ next if !$ofn;
+
+ # if we already have a default, then we can disable it, as we know
+ # we can do better.
+ my $best = eval "\$${fn}_default";
+ if ($best) {
+ my $best_ofn = eval "\$${best}";
+ if ($best_ofn && "$best_ofn" ne "$ofn") {
+ eval "\$${best}_link = 'false'";
+ }
+ }
+ eval "\$${fn}_default=${fn}_${opt}";
+ eval "\$${fn}_${opt}_link='true'";
+ }
+ }
+}
+
+sub forward_decls {
+ push @ALL_FORWARD_DECLS, @_;
+}
+
+#
+# Include the user's directives
+#
+foreach my $f (@ARGV) {
+ open FILE, "<", $f or die "cannot open $f: $!\n";
+ my $contents = join('', <FILE>);
+ close FILE;
+ eval $contents or warn "eval failed: $@\n";
+}
+
+#
+# Process the directives according to the command line
+#
+sub process_forward_decls() {
+ foreach (@ALL_FORWARD_DECLS) {
+ $_->();
+ }
+}
+
+sub determine_indirection {
+ aom_config("CONFIG_RUNTIME_CPU_DETECT") eq "yes" or &require(@ALL_ARCHS);
+ foreach my $fn (keys %ALL_FUNCS) {
+ my $n = "";
+ my @val = @{$ALL_FUNCS{$fn}};
+ my $args = pop @val;
+ my $rtyp = "@val";
+ my $dfn = eval "\$${fn}_default";
+ $dfn = eval "\$${dfn}";
+ foreach my $opt (@_) {
+ my $ofn = eval "\$${fn}_${opt}";
+ next if !$ofn;
+ my $link = eval "\$${fn}_${opt}_link";
+ next if $link && $link eq "false";
+ $n .= "x";
+ }
+ if ($n eq "x") {
+ eval "\$${fn}_indirect = 'false'";
+ } else {
+ eval "\$${fn}_indirect = 'true'";
+ }
+ }
+}
+
+sub declare_function_pointers {
+ foreach my $fn (sort keys %ALL_FUNCS) {
+ my @val = @{$ALL_FUNCS{$fn}};
+ my $args = pop @val;
+ my $rtyp = "@val";
+ my $dfn = eval "\$${fn}_default";
+ $dfn = eval "\$${dfn}";
+ foreach my $opt (@_) {
+ my $ofn = eval "\$${fn}_${opt}";
+ next if !$ofn;
+ print "$rtyp ${ofn}($args);\n";
+ }
+ if (eval "\$${fn}_indirect" eq "false") {
+ print "#define ${fn} ${dfn}\n";
+ } else {
+ print "RTCD_EXTERN $rtyp (*${fn})($args);\n";
+ }
+ print "\n";
+ }
+}
+
+sub set_function_pointers {
+ foreach my $fn (sort keys %ALL_FUNCS) {
+ my @val = @{$ALL_FUNCS{$fn}};
+ my $args = pop @val;
+ my $rtyp = "@val";
+ my $dfn = eval "\$${fn}_default";
+ $dfn = eval "\$${dfn}";
+ if (eval "\$${fn}_indirect" eq "true") {
+ print " $fn = $dfn;\n";
+ foreach my $opt (@_) {
+ my $ofn = eval "\$${fn}_${opt}";
+ next if !$ofn;
+ next if "$ofn" eq "$dfn";
+ my $link = eval "\$${fn}_${opt}_link";
+ next if $link && $link eq "false";
+ my $cond = eval "\$have_${opt}";
+ print " if (${cond}) $fn = $ofn;\n"
+ }
+ }
+ }
+}
+
+sub filter {
+ my @filtered;
+ foreach (@_) { push @filtered, $_ unless $disabled{$_}; }
+ return @filtered;
+}
+
+#
+# Helper functions for generating the arch specific RTCD files
+#
+sub common_top() {
+ my $include_guard = uc($opts{sym})."_H_";
+ print <<EOF;
+// This file is generated. Do not edit.
+#ifndef ${include_guard}
+#define ${include_guard}
+
+#ifdef RTCD_C
+#define RTCD_EXTERN
+#else
+#define RTCD_EXTERN extern
+#endif
+
+EOF
+
+process_forward_decls();
+print <<EOF;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+declare_function_pointers("c", @ALL_ARCHS);
+
+print <<EOF;
+void $opts{sym}(void);
+
+EOF
+}
+
+sub common_bottom() {
+ print <<EOF;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
+EOF
+}
+
+sub x86() {
+ determine_indirection("c", @ALL_ARCHS);
+
+ # Assign the helper variable for each enabled extension
+ foreach my $opt (@ALL_ARCHS) {
+ my $opt_uc = uc $opt;
+ eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
+ }
+
+ common_top;
+ print <<EOF;
+#ifdef RTCD_C
+#include "aom_ports/x86.h"
+static void setup_rtcd_internal(void)
+{
+ int flags = x86_simd_caps();
+
+ (void)flags;
+
+EOF
+
+ set_function_pointers("c", @ALL_ARCHS);
+
+ print <<EOF;
+}
+#endif
+EOF
+ common_bottom;
+}
+
+sub arm() {
+ determine_indirection("c", @ALL_ARCHS);
+
+ # Assign the helper variable for each enabled extension
+ foreach my $opt (@ALL_ARCHS) {
+ my $opt_uc = uc $opt;
+ eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
+ }
+
+ common_top;
+ print <<EOF;
+#include "config/aom_config.h"
+
+#ifdef RTCD_C
+#include "aom_ports/arm.h"
+static void setup_rtcd_internal(void)
+{
+ int flags = aom_arm_cpu_caps();
+
+ (void)flags;
+
+EOF
+
+ set_function_pointers("c", @ALL_ARCHS);
+
+ print <<EOF;
+}
+#endif
+EOF
+ common_bottom;
+}
+
+sub ppc() {
+ determine_indirection("c", @ALL_ARCHS);
+
+ # Assign the helper variable for each enabled extension
+ foreach my $opt (@ALL_ARCHS) {
+ my $opt_uc = uc $opt;
+ eval "\$have_${opt}=\"flags & HAS_${opt_uc}\"";
+ }
+
+ common_top;
+
+ print <<EOF;
+#include "config/aom_config.h"
+
+#ifdef RTCD_C
+#include "aom_ports/ppc.h"
+static void setup_rtcd_internal(void)
+{
+ int flags = ppc_simd_caps();
+
+ (void)flags;
+
+EOF
+
+ set_function_pointers("c", @ALL_ARCHS);
+
+ print <<EOF;
+}
+#endif
+EOF
+ common_bottom;
+}
+
+sub unoptimized() {
+ determine_indirection "c";
+ common_top;
+ print <<EOF;
+#include "config/aom_config.h"
+
+#ifdef RTCD_C
+static void setup_rtcd_internal(void)
+{
+EOF
+
+ set_function_pointers "c";
+
+ print <<EOF;
+}
+#endif
+EOF
+ common_bottom;
+}
+
+#
+# Main Driver
+#
+
+&require("c");
+&require(keys %required);
+if ($opts{arch} eq 'x86') {
+ @ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/);
+ x86;
+} elsif ($opts{arch} eq 'x86_64') {
+ @ALL_ARCHS = filter(qw/mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2/);
+ @REQUIRES = filter(qw/mmx sse sse2/);
+ &require(@REQUIRES);
+ x86;
+} elsif ($opts{arch} =~ /armv[78]\w?/) {
+ @ALL_ARCHS = filter(qw/neon/);
+ arm;
+} elsif ($opts{arch} eq 'arm64' ) {
+ @ALL_ARCHS = filter(qw/neon arm_crc32 neon_dotprod neon_i8mm sve/);
+ @REQUIRES = filter(qw/neon/);
+ &require(@REQUIRES);
+ arm;
+} elsif ($opts{arch} eq 'ppc') {
+ @ALL_ARCHS = filter(qw/vsx/);
+ ppc;
+} else {
+ unoptimized;
+}
+
+__END__
+
+=head1 NAME
+
+rtcd -
+
+=head1 SYNOPSIS
+
+Usage: rtcd.pl [options] FILE
+
+See 'perldoc rtcd.pl' for more details.
+
+=head1 DESCRIPTION
+
+Reads the Run Time CPU Detections definitions from FILE and generates a
+C header file on stdout.
+
+=head1 OPTIONS
+
+Options:
+ --arch=ARCH Architecture to generate defs for (required)
+ --disable-EXT Disable support for EXT extensions
+ --require-EXT Require support for EXT extensions
+ --sym=SYMBOL Unique symbol to use for RTCD initialization function
+ --config=FILE Path to file containing C preprocessor directives to parse
diff --git a/third_party/aom/build/cmake/sanitizers.cmake b/third_party/aom/build/cmake/sanitizers.cmake
new file mode 100644
index 0000000000..bcb600ce4c
--- /dev/null
+++ b/third_party/aom/build/cmake/sanitizers.cmake
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_SANITIZERS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_SANITIZERS_CMAKE_
+set(AOM_BUILD_CMAKE_SANITIZERS_CMAKE_ 1)
+
+if(MSVC OR NOT SANITIZE)
+ return()
+endif()
+
+include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
+
+string(TOLOWER ${SANITIZE} SANITIZE)
+
+# Require the sanitizer requested. cfi sanitizer requires all the flags in order
+# for the compiler to accept it.
+if("${SANITIZE}" MATCHES "cfi" AND CMAKE_C_COMPILER_ID MATCHES "Clang")
+ require_linker_flag("-fsanitize=${SANITIZE} -flto -fno-sanitize-trap=cfi \
+ -fuse-ld=gold" YES)
+ require_compiler_flag("-fsanitize=${SANITIZE} -flto -fvisibility=hidden \
+ -fno-sanitize-trap=cfi" YES)
+else()
+ require_linker_flag("-fsanitize=${SANITIZE}")
+ require_compiler_flag("-fsanitize=${SANITIZE}" YES)
+endif()
+
+# Make callstacks accurate.
+require_compiler_flag("-fno-omit-frame-pointer -fno-optimize-sibling-calls" YES)
+
+# Fix link errors due to missing rt compiler lib in 32-bit builds.
+# http://llvm.org/bugs/show_bug.cgi?id=17693
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ if(${CMAKE_SIZEOF_VOID_P} EQUAL 4
+ AND "${SANITIZE}" MATCHES "integer|undefined")
+ require_linker_flag("--rtlib=compiler-rt -lgcc_s")
+ endif()
+endif()
diff --git a/third_party/aom/build/cmake/toolchains/android.cmake b/third_party/aom/build/cmake/toolchains/android.cmake
new file mode 100644
index 0000000000..fb086856a7
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/android.cmake
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2019, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ANDROID_CMAKE_ 1)
+
+if(NOT ANDROID_PLATFORM)
+ set(ANDROID_PLATFORM android-24)
+endif()
+
+# Choose target architecture with:
+#
+# -DANDROID_ABI={armeabi-v7a,armeabi-v7a with NEON,arm64-v8a,x86,x86_64}
+if(NOT ANDROID_ABI)
+ set(ANDROID_ABI arm64-v8a)
+endif()
+
+# Toolchain files don't have access to cached variables:
+# https://gitlab.kitware.com/cmake/cmake/issues/16170. Set an intermediate
+# environment variable when loaded the first time.
+if(AOM_ANDROID_NDK_PATH)
+ set(ENV{_AOM_ANDROID_NDK_PATH} "${AOM_ANDROID_NDK_PATH}")
+else()
+ set(AOM_ANDROID_NDK_PATH "$ENV{_AOM_ANDROID_NDK_PATH}")
+endif()
+
+if("${AOM_ANDROID_NDK_PATH}" STREQUAL "")
+ message(FATAL_ERROR "AOM_ANDROID_NDK_PATH not set.")
+ return()
+endif()
+
+include("${AOM_ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake")
+
+if(ANDROID_ABI MATCHES "^armeabi")
+ set(AOM_NEON_INTRIN_FLAG "-mfpu=neon")
+endif()
+
+if(ANDROID_ABI MATCHES "^arm")
+ set(CMAKE_ASM_COMPILER as)
+elseif(ANDROID_ABI MATCHES "^x86")
+ set(CMAKE_ASM_NASM_COMPILER yasm)
+endif()
+
+set(CMAKE_SYSTEM_NAME "Android")
diff --git a/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake b/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
new file mode 100644
index 0000000000..2c433befd9
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm-ios-common.cmake
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_
+set(AOM_BUILD_CMAKE_ARM_IOS_COMMON_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_SYSROOT iphoneos)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_CXX_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+
+# TODO(tomfinegan): Handle bit code embedding.
diff --git a/third_party/aom/build/cmake/toolchains/arm64-ios.cmake b/third_party/aom/build/cmake/toolchains/arm64-ios.cmake
new file mode 100644
index 0000000000..6feb1090f2
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-ios.cmake
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_ 1)
+
+if(XCODE) # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif()
+
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+set(CMAKE_OSX_ARCHITECTURES "arm64")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
diff --git a/third_party/aom/build/cmake/toolchains/arm64-linux-clang.cmake b/third_party/aom/build/cmake/toolchains/arm64-linux-clang.cmake
new file mode 100644
index 0000000000..b4645cc09e
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-linux-clang.cmake
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2023, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_CLANG_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_CLANG_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_CLANG_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+set(TRIPLE aarch64-linux-gnu)
+
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_COMPILER_TARGET ${TRIPLE})
+
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_CXX_COMPILER_TARGET ${TRIPLE})
+
+set(CMAKE_ASM_COMPILER clang)
+set(CMAKE_ASM_COMPILER_TARGET ${TRIPLE})
+
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
diff --git a/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
new file mode 100644
index 0000000000..3d0dff0252
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-linux-gcc.cmake
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS aarch64-linux-gnu-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CROSS}as)
+endif()
+set(CMAKE_C_FLAGS_INIT "-march=armv8-a")
+set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a")
+set(AOM_AS_FLAGS "-march=armv8-a")
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+
+# No intrinsics flag required for arm64-linux-gcc.
+set(AOM_NEON_INTRIN_FLAG "")
diff --git a/third_party/aom/build/cmake/toolchains/arm64-macos.cmake b/third_party/aom/build/cmake/toolchains/arm64-macos.cmake
new file mode 100644
index 0000000000..99f8d16e16
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-macos.cmake
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2022, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_ARCHITECTURES "arm64")
+set(CMAKE_C_FLAGS_INIT "-arch arm64")
+set(CMAKE_CXX_FLAGS_INIT "-arch arm64")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-arch arm64")
diff --git a/third_party/aom/build/cmake/toolchains/arm64-mingw-gcc.cmake b/third_party/aom/build/cmake/toolchains/arm64-mingw-gcc.cmake
new file mode 100644
index 0000000000..95b26d3ceb
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/arm64-mingw-gcc.cmake
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2018, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARM64_MINGW_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_PROCESSOR "arm64")
+set(CMAKE_SYSTEM_NAME "Windows")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by MSYS2.
+ set(CROSS aarch64-w64-mingw32-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_AR)
+ set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
+endif()
+if(NOT CMAKE_RANLIB)
+ set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
+endif()
diff --git a/third_party/aom/build/cmake/toolchains/armv7-ios.cmake b/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
new file mode 100644
index 0000000000..11f7e160df
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7-ios.cmake
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_ 1)
+
+if(XCODE)
+
+ # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif()
+
+set(CMAKE_SYSTEM_PROCESSOR "armv7")
+set(CMAKE_OSX_ARCHITECTURES "armv7")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
+
+# No intrinsics flag required for armv7s-ios.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# No runtime cpu detect for armv7s-ios.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
new file mode 100644
index 0000000000..aa0550574d
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7-linux-gcc.cmake
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS arm-linux-gnueabihf-)
+endif()
+
+if(NOT ${CROSS} MATCHES hf-$)
+ set(AOM_EXTRA_TOOLCHAIN_FLAGS "-mfloat-abi=softfp")
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CROSS}as)
+endif()
+set(CMAKE_C_FLAGS_INIT "-march=armv7-a -mfpu=vfpv3 \
+ ${AOM_EXTRA_TOOLCHAIN_FLAGS}")
+set(CMAKE_CXX_FLAGS_INIT "-march=armv7-a -mfpu=vfpv3 \
+ ${AOM_EXTRA_TOOLCHAIN_FLAGS}")
+set(AOM_AS_FLAGS --defsym ARCHITECTURE=7 -march=armv7-a -mfpu=neon
+ ${AOM_EXTRA_TOOLCHAIN_FLAGS})
+set(CMAKE_SYSTEM_PROCESSOR "armv7")
+
+set(AOM_NEON_INTRIN_FLAG "-mfpu=neon ${AOM_EXTRA_TOOLCHAIN_FLAGS}")
diff --git a/third_party/aom/build/cmake/toolchains/armv7-mingw-gcc.cmake b/third_party/aom/build/cmake/toolchains/armv7-mingw-gcc.cmake
new file mode 100644
index 0000000000..93f8c065c9
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7-mingw-gcc.cmake
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2018, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7_MINGW_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_PROCESSOR "armv7")
+set(CMAKE_SYSTEM_NAME "Windows")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by MSYS2.
+ set(CROSS armv7-w64-mingw32-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_AR)
+ set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
+endif()
+if(NOT CMAKE_RANLIB)
+ set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
+endif()
+
+# No runtime cpu detect for armv7-mingw-gcc.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake b/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
new file mode 100644
index 0000000000..faa2933cf0
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/armv7s-ios.cmake
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_ 1)
+
+if(XCODE)
+
+ # TODO(tomfinegan): Handle arm builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif()
+
+set(CMAKE_SYSTEM_PROCESSOR "armv7s")
+set(CMAKE_OSX_ARCHITECTURES "armv7s")
+
+include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake")
+
+# No intrinsics flag required for armv7s-ios.
+set(AOM_NEON_INTRIN_FLAG "")
+
+# No runtime cpu detect for armv7s-ios.
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/i686-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/i686-linux-gcc.cmake
new file mode 100644
index 0000000000..c4f6ab9465
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/i686-linux-gcc.cmake
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2023, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_I686_LINUX_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_I686_LINUX_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_I686_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS i686-linux-gnu-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CROSS}as)
+endif()
diff --git a/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake b/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake
new file mode 100644
index 0000000000..173c423c3d
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/ios-simulator-common.cmake
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_IOS_SIMULATOR_COMMON_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_IOS_SIMULATOR_COMMON_CMAKE_
+set(AOM_BUILD_CMAKE_IOS_SIMULATOR_COMMON_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_SYSROOT iphonesimulator)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_CXX_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-arch ${CMAKE_SYSTEM_PROCESSOR}")
+
+# TODO(tomfinegan): Handle bit code embedding.
diff --git a/third_party/aom/build/cmake/toolchains/ppc-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/ppc-linux-gcc.cmake
new file mode 100644
index 0000000000..3aa265254e
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/ppc-linux-gcc.cmake
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2018, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_PPC_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS powerpc64le-linux-gnu-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CROSS}as)
+endif()
+set(CMAKE_SYSTEM_PROCESSOR "ppc")
+
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/riscv-linux-gcc.cmake b/third_party/aom/build/cmake/toolchains/riscv-linux-gcc.cmake
new file mode 100644
index 0000000000..4133be68b3
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/riscv-linux-gcc.cmake
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2022, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_RISCV_LINUX_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_RISCV_LINUX_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_RISCV_LINUX_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_NAME "Linux")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS riscv64-linux-gnu-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_ASM_COMPILER)
+ set(CMAKE_ASM_COMPILER ${CROSS}as)
+endif()
+set(CMAKE_SYSTEM_PROCESSOR "riscv")
+
+set(CONFIG_RUNTIME_CPU_DETECT 0 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake b/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
new file mode 100644
index 0000000000..caacb8c38b
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-ios-simulator.cmake
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_IOS_SIMULATOR_CMAKE_ 1)
+
+if(XCODE)
+
+ # TODO(tomfinegan): Handle ios sim builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif()
+
+set(CMAKE_SYSTEM_PROCESSOR "i386")
+set(CMAKE_OSX_ARCHITECTURES "i386")
+
+# Avoid noisy PIC/PIE warnings.
+set(CONFIG_PIC 1 CACHE STRING "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")
diff --git a/third_party/aom/build/cmake/toolchains/x86-linux.cmake b/third_party/aom/build/cmake/toolchains/x86-linux.cmake
new file mode 100644
index 0000000000..a9c4f8c6b4
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-linux.cmake
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_LINUX_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+set(CMAKE_SYSTEM_NAME "Linux")
+set(CMAKE_C_FLAGS_INIT "-m32")
+set(CMAKE_CXX_FLAGS_INIT "-m32")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-m32")
diff --git a/third_party/aom/build/cmake/toolchains/x86-macos.cmake b/third_party/aom/build/cmake/toolchains/x86-macos.cmake
new file mode 100644
index 0000000000..68e1bb07ff
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-macos.cmake
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_ARCHITECTURES "i386")
+set(CMAKE_C_FLAGS_INIT "-arch i386")
+set(CMAKE_CXX_FLAGS_INIT "-arch i386")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-arch i386")
+
+# Apple tools always complain in 32 bit mode without PIC.
+set(CONFIG_PIC 1 CACHE STRING "")
diff --git a/third_party/aom/build/cmake/toolchains/x86-mingw-gcc.cmake b/third_party/aom/build/cmake/toolchains/x86-mingw-gcc.cmake
new file mode 100644
index 0000000000..2208333f37
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86-mingw-gcc.cmake
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_MINGW_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_PROCESSOR "x86")
+set(CMAKE_SYSTEM_NAME "Windows")
+set(CMAKE_C_FLAGS_INIT "-m32")
+set(CMAKE_CXX_FLAGS_INIT "-m32")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-m32")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS i686-w64-mingw32-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_AR)
+ set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
+endif()
+if(NOT CMAKE_RANLIB)
+ set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
+endif()
diff --git a/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake b/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake
new file mode 100644
index 0000000000..d4b40ed098
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86_64-ios-simulator.cmake
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_IOS_SIMULATOR_CMAKE_ 1)
+
+if(XCODE)
+
+ # TODO(tomfinegan): Handle ios sim builds in Xcode.
+ message(FATAL_ERROR "This toolchain does not support Xcode.")
+endif()
+
+set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+set(CMAKE_OSX_ARCHITECTURES "x86_64")
+
+include("${CMAKE_CURRENT_LIST_DIR}/ios-simulator-common.cmake")
diff --git a/third_party/aom/build/cmake/toolchains/x86_64-macos.cmake b/third_party/aom/build/cmake/toolchains/x86_64-macos.cmake
new file mode 100644
index 0000000000..899df6f353
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86_64-macos.cmake
@@ -0,0 +1,16 @@
+#
+# Copyright (c) 2022, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+set(CMAKE_SYSTEM_NAME "Darwin")
+set(CMAKE_OSX_ARCHITECTURES "x86_64")
+set(CMAKE_C_FLAGS_INIT "-arch x86_64")
+set(CMAKE_CXX_FLAGS_INIT "-arch x86_64")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-arch x86_64")
diff --git a/third_party/aom/build/cmake/toolchains/x86_64-mingw-gcc.cmake b/third_party/aom/build/cmake/toolchains/x86_64-mingw-gcc.cmake
new file mode 100644
index 0000000000..978146a4f2
--- /dev/null
+++ b/third_party/aom/build/cmake/toolchains/x86_64-mingw-gcc.cmake
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_
+set(AOM_BUILD_CMAKE_TOOLCHAINS_X86_64_MINGW_GCC_CMAKE_ 1)
+
+set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+set(CMAKE_SYSTEM_NAME "Windows")
+
+if("${CROSS}" STREQUAL "")
+
+ # Default the cross compiler prefix to one used by Debian and other package
+ # management systems.
+ set(CROSS x86_64-w64-mingw32-)
+endif()
+
+if(NOT CMAKE_C_COMPILER)
+ set(CMAKE_C_COMPILER ${CROSS}gcc)
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ set(CMAKE_CXX_COMPILER ${CROSS}g++)
+endif()
+if(NOT CMAKE_AR)
+ set(CMAKE_AR ${CROSS}ar CACHE FILEPATH Archiver)
+endif()
+if(NOT CMAKE_RANLIB)
+ set(CMAKE_RANLIB ${CROSS}ranlib CACHE FILEPATH Indexer)
+endif()
diff --git a/third_party/aom/build/cmake/util.cmake b/third_party/aom/build/cmake/util.cmake
new file mode 100644
index 0000000000..31de2e1702
--- /dev/null
+++ b/third_party/aom/build/cmake/util.cmake
@@ -0,0 +1,173 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+if(AOM_BUILD_CMAKE_UTIL_CMAKE_)
+ return()
+endif() # AOM_BUILD_CMAKE_UTIL_CMAKE_
+set(AOM_BUILD_CMAKE_UTIL_CMAKE_ 1)
+
+# Directory where generated sources will be written.
+set(AOM_GEN_SRC_DIR "${AOM_CONFIG_DIR}/gen_src")
+
+# Creates a no-op source file in $AOM_GEN_SRC_DIR named $basename.$extension and
+# returns the full path to the source file via appending it to the list variable
+# referred to by $out_file_list_var parameter.
+macro(create_no_op_source_file basename extension out_file_list_var)
+ set(no_op_source_file "${AOM_GEN_SRC_DIR}/${basename}_no_op.${extension}")
+ file(WRITE "${no_op_source_file}"
+ "// Generated file. DO NOT EDIT!\n"
+ "// ${target_name} needs a ${extension} file to force link language, \n"
+ "// or to silence a harmless CMake warning: Ignore me.\n"
+ "void aom_${target_name}_no_op_function(void);\n"
+ "void aom_${target_name}_no_op_function(void) {}\n")
+ list(APPEND "${out_file_list_var}" "${no_op_source_file}")
+endmacro()
+
+# Convenience function for adding a no-op source file to $target_name using
+# $extension as the file extension. Wraps create_no_op_source_file().
+function(add_no_op_source_file_to_target target_name extension)
+ create_no_op_source_file("${target_name}" "${extension}"
+ "no_op_source_file_list")
+ target_sources(${target_name} PRIVATE ${no_op_source_file_list})
+endfunction()
+
+# Sets the value of the variable referenced by $feature to $value, and reports
+# the change to the user via call to message(WARNING ...). $cause is expected to
+# be a configuration variable that conflicts with $feature in some way. This
+# function is a no-op if $feature is already set to $value.
+function(change_config_and_warn feature value cause)
+ if(${feature} EQUAL ${value})
+ return()
+ endif()
+ set(${feature} ${value} PARENT_SCOPE)
+ if(${value} EQUAL 1)
+ set(verb "Enabled")
+ set(reason "required for")
+ else()
+ set(verb "Disabled")
+ set(reason "incompatible with")
+ endif()
+ set(warning_message "${verb} ${feature}, ${reason} ${cause}.")
+ message(WARNING "--- ${warning_message}")
+endfunction()
+
+# Extracts the version string from $version_file and returns it to the user via
+# $version_string_out_var. To achieve this VERSION_STRING_NOSP is located in
+# $version_file and then everything but the string literal assigned to the
+# variable is removed. Quotes and the leading 'v' are stripped from the returned
+# string.
+function(extract_version_string version_file version_string_out_var)
+ file(STRINGS "${version_file}" aom_version REGEX "VERSION_STRING_NOSP")
+ string(REPLACE "#define VERSION_STRING_NOSP " "" aom_version "${aom_version}")
+ string(REPLACE "\"" "" aom_version "${aom_version}")
+ string(REPLACE " " "" aom_version "${aom_version}")
+ string(FIND "${aom_version}" "v" v_pos)
+ if(${v_pos} EQUAL 0)
+ string(SUBSTRING "${aom_version}" 1 -1 aom_version)
+ endif()
+ set("${version_string_out_var}" "${aom_version}" PARENT_SCOPE)
+endfunction()
+
+# Sets CMake compiler launcher to $launcher_name when $launcher_name is found in
+# $PATH. Warns user about ignoring build flag $launcher_flag when $launcher_name
+# is not found in $PATH.
+function(set_compiler_launcher launcher_flag launcher_name)
+ find_program(launcher_path "${launcher_name}")
+ if(launcher_path)
+ set(CMAKE_C_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
+ set(CMAKE_CXX_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE)
+ message("--- Using ${launcher_name} as compiler launcher.")
+ else()
+ message(
+ WARNING "--- Cannot find ${launcher_name}, ${launcher_flag} ignored.")
+ endif()
+endfunction()
+
+# Sentinel value used to detect when a variable has been set via the -D argument
+# passed to CMake on the command line.
+set(cmake_cmdline_helpstring "No help, variable specified on the command line.")
+
+# Wrapper macro for set() that does some book keeping to help with storage of
+# build configuration information.
+#
+# Sets the default value for variable $name when the value of $name has not
+# already been set via the CMake command line.
+#
+# The names of variables defaulted through this macro are added to
+# $AOM_DETECT_VARS to facilitate build logging and diagnostics.
+macro(set_aom_detect_var name value helpstring)
+ unset(list_index)
+ list(FIND AOM_DETECT_VARS ${name} list_index)
+ if(${list_index} EQUAL -1)
+ list(APPEND AOM_DETECT_VARS ${name})
+ endif()
+
+ # Update the variable only when it does not carry the CMake assigned help
+ # string for variables specified via the command line.
+ unset(cache_helpstring)
+ get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
+ if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
+ set(${name} ${value} CACHE STRING "${helpstring}")
+ mark_as_advanced(${name})
+ else()
+ message(
+ WARNING
+ "${name} has been set by CMake, but it may be overridden by the build "
+ "system during environment detection")
+ endif()
+endmacro()
+
+# Wrapper macro for set() that does some book keeping to help with storage of
+# build configuration information.
+#
+# Sets the default value for variable $name when the value of $name has not
+# already been set via the CMake command line.
+#
+# The names of variables defaulted through this macro are added to
+# $AOM_CONFIG_VARS to facilitate build logging and diagnostics.
+macro(set_aom_config_var name value helpstring)
+ unset(list_index)
+ list(FIND AOM_CONFIG_VARS ${name} list_index)
+ if(${list_index} EQUAL -1)
+ list(APPEND AOM_CONFIG_VARS ${name})
+ endif()
+
+ # Update the variable only when it does not carry the CMake assigned help
+ # string for variables specified via the command line.
+ unset(cache_helpstring)
+ get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
+ if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
+ set(${name} ${value} CACHE STRING "${helpstring}")
+ endif()
+endmacro()
+
+# Wrapper macro for option() that does some book keeping to help with storage of
+# build configuration information.
+#
+# Sets the default value for variable $name when the value of $name has not
+# already been set via the CMake command line.
+#
+# The names of variables defaulted through this macro are added to
+# $AOM_OPTION_VARS to facilitate build logging and diagnostics.
+macro(set_aom_option_var name helpstring value)
+ unset(list_index)
+ list(FIND AOM_OPTION_VARS ${name} list_index)
+ if(${list_index} EQUAL -1)
+ list(APPEND AOM_OPTION_VARS ${name})
+ endif()
+
+ # Update the variable only when it does not carry the CMake assigned help
+ # string for variables specified via the command line.
+ unset(cache_helpstring)
+ get_property(cache_helpstring CACHE ${name} PROPERTY HELPSTRING)
+ if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
+ option(${name} "${helpstring}" ${value})
+ endif()
+endmacro()
diff --git a/third_party/aom/build/cmake/version.cmake b/third_party/aom/build/cmake/version.cmake
new file mode 100644
index 0000000000..f4377a13e1
--- /dev/null
+++ b/third_party/aom/build/cmake/version.cmake
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2017, Alliance for Open Media. All rights reserved
+#
+# This source code is subject to the terms of the BSD 2 Clause License and the
+# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
+# not distributed with this source code in the LICENSE file, you can obtain it
+# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
+# License 1.0 was not distributed with this source code in the PATENTS file, you
+# can obtain it at www.aomedia.org/license/patent.
+#
+cmake_minimum_required(VERSION 3.5)
+
+set(REQUIRED_ARGS "AOM_ROOT" "AOM_CONFIG_DIR" "GIT_EXECUTABLE"
+ "PERL_EXECUTABLE")
+
+foreach(arg ${REQUIRED_ARGS})
+ if("${${arg}}" STREQUAL "")
+ message(FATAL_ERROR "${arg} must not be empty.")
+ endif()
+endforeach()
+
+include("${AOM_ROOT}/build/cmake/util.cmake")
+
+# Generate the version string for this run.
+unset(aom_version)
+if(EXISTS "${GIT_EXECUTABLE}")
+ execute_process(COMMAND ${GIT_EXECUTABLE}
+ --git-dir=${AOM_ROOT}/.git describe
+ --match=v[0-9]*
+ OUTPUT_VARIABLE aom_version
+ ERROR_QUIET
+ RESULT_VARIABLE version_check_result)
+
+ if(${version_check_result} EQUAL 0)
+ string(STRIP "${aom_version}" aom_version)
+
+ # Remove the leading 'v' from the version string.
+ string(FIND "${aom_version}" "v" v_pos)
+ if(${v_pos} EQUAL 0)
+ string(SUBSTRING "${aom_version}" 1 -1 aom_version)
+ endif()
+ else()
+ set(aom_version "")
+ endif()
+endif()
+
+if("${aom_version}" STREQUAL "")
+ set(aom_version "${AOM_ROOT}/CHANGELOG")
+endif()
+
+unset(last_aom_version)
+set(version_file "${AOM_CONFIG_DIR}/config/aom_version.h")
+if(EXISTS "${version_file}")
+ extract_version_string("${version_file}" last_aom_version)
+ if("${aom_version}" MATCHES "CHANGELOG$")
+ set(aom_version "${last_aom_version}")
+ endif()
+endif()
+
+if(NOT "${aom_version}" STREQUAL "${last_aom_version}")
+ # TODO(tomfinegan): Perl dependency is unnecessary. CMake can do everything
+ # that is done by version.pl on its own (if a bit more verbosely...).
+ execute_process(COMMAND ${PERL_EXECUTABLE}
+ "${AOM_ROOT}/build/cmake/version.pl"
+ --version_data=${aom_version}
+ --version_filename=${version_file} VERBATIM)
+endif()
diff --git a/third_party/aom/build/cmake/version.pl b/third_party/aom/build/cmake/version.pl
new file mode 100755
index 0000000000..392815f81d
--- /dev/null
+++ b/third_party/aom/build/cmake/version.pl
@@ -0,0 +1,114 @@
+#!/usr/bin/env perl
+##
+## Copyright (c) 2016, Alliance for Open Media. All rights reserved
+##
+## This source code is subject to the terms of the BSD 2 Clause License and
+## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+## was not distributed with this source code in the LICENSE file, you can
+## obtain it at www.aomedia.org/license/software. If the Alliance for Open
+## Media Patent License 1.0 was not distributed with this source code in the
+## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+##
+use strict;
+use warnings;
+use 5.010;
+use Getopt::Long;
+
+my $git_desc = '';
+my $version_data;
+my $version_filename;
+GetOptions('version_data=s' => \$version_data,
+ 'version_filename=s' => \$version_filename) or
+ die("Invalid arg(s): $!");
+
+if (!defined $version_data || length($version_data) == 0 ||
+ !defined $version_filename || length($version_filename) == 0) {
+ die("--version_data and --version_filename are required.");
+}
+
+# Determine if $version_data is a filename or a git tag/description.
+my $version_string;
+chomp($version_data);
+if (-r $version_data) {
+ # $version_data is the path to the CHANGELOG. Parse the most recent version.
+ my $changelog_filename = $version_data;
+ open(my $changelog_file, '<', $changelog_filename) or
+ die("Unable to open CHANGELOG @ $changelog_filename: $!.");
+
+ while (my $line = <$changelog_file>) {
+ my @split_line = split(" ", $line, 3);
+ next if @split_line < 2;
+ $version_string = $split_line[1];
+ last if substr($version_string, 0, 1) eq "v";
+ }
+ close($changelog_file);
+} else {
+ # $version_data is either a tag name or a full git description, one of:
+ # tagName OR tagName-commitsSinceTag-shortCommitHash
+ # In either case we want the first element of the array returned by split.
+ $version_string = (split("-", $version_data))[0];
+ $git_desc = $version_data;
+}
+
+if (substr($version_string, 0, 1) eq "v") {
+ $version_string = substr($version_string, 1);
+}
+
+my @version_components = split('\.', $version_string, 4);
+my $version_major = $version_components[0];
+my $version_minor = $version_components[1];
+my $version_patch = $version_components[2];
+
+my $version_extra = "";
+if (length($git_desc) > 0) {
+ my @git_desc_components = split('-', $git_desc, 2);
+ if (@git_desc_components > 1) {
+ $version_extra = $git_desc_components[1];
+ }
+}
+
+open(my $version_file, '>', $version_filename) or
+ die("Cannot open $version_filename: $!");
+
+my $version_packed = "((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | (VERSION_PATCH))";
+my $year = (localtime)[5] + 1900;
+my $lic_block = << "EOF";
+/*
+ * Copyright (c) $year, Alliance for Open Media. All rights reserved
+ *
+ * This source code is subject to the terms of the BSD 2 Clause License and
+ * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
+ * was not distributed with this source code in the LICENSE file, you can
+ * obtain it at www.aomedia.org/license/software. If the Alliance for Open
+ * Media Patent License 1.0 was not distributed with this source code in the
+ * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
+ */
+EOF
+
+select $version_file;
+if (length($git_desc)) {
+ print << "EOF";
+$lic_block
+#define VERSION_MAJOR $version_major
+#define VERSION_MINOR $version_minor
+#define VERSION_PATCH $version_patch
+#define VERSION_EXTRA \"$version_extra\"
+#define VERSION_PACKED \\
+ $version_packed
+#define VERSION_STRING_NOSP \"$git_desc\"
+#define VERSION_STRING \" $git_desc\"
+EOF
+} else {
+ print << "EOF";
+$lic_block
+#define VERSION_MAJOR $version_major
+#define VERSION_MINOR $version_minor
+#define VERSION_PATCH $version_patch
+#define VERSION_EXTRA \"$version_extra\"
+#define VERSION_PACKED \\
+ $version_packed
+#define VERSION_STRING_NOSP \"v$version_string\"
+#define VERSION_STRING \" v$version_string\"
+EOF
+}
+close($version_file);