audio_core: Replace AAC decoders with single FAAD2-based decoder. (#7098)

This commit is contained in:
Steveice10 2023-11-04 14:56:13 -07:00 committed by GitHub
parent 1570aeffcb
commit 27bad3a699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 304 additions and 2403 deletions

View file

@ -156,24 +156,12 @@ endif()
# Open Source Archives
add_subdirectory(open_source_archives)
# faad2
add_subdirectory(faad2 EXCLUDE_FROM_ALL)
# Dynamic library headers
add_library(library-headers INTERFACE)
if (USE_SYSTEM_FDK_AAC_HEADERS)
find_path(SYSTEM_FDK_AAC_INCLUDES NAMES fdk-aac/aacdecoder_lib.h)
if (SYSTEM_FDK_AAC_INCLUDES STREQUAL "SYSTEM_FDK_AAC_INCLUDES-NOTFOUND")
message(WARNING "System fdk-aac headers not found. Falling back on bundled headers.")
else()
message(STATUS "Using system fdk_aac headers.")
target_include_directories(library-headers SYSTEM INTERFACE ${SYSTEM_FDK_AAC_INCLUDES})
set(FOUND_FDK_AAC_HEADERS ON)
endif()
endif()
if (NOT FOUND_FDK_AAC_HEADERS)
message(STATUS "Using bundled fdk_aac headers.")
target_include_directories(library-headers SYSTEM INTERFACE ./library-headers/fdk-aac/include)
endif()
if (USE_SYSTEM_FFMPEG_HEADERS)
find_path(SYSTEM_FFMPEG_INCLUDES NAMES libavutil/avutil.h)
if (SYSTEM_FFMPEG_INCLUDES STREQUAL "SYSTEM_FFMPEG_INCLUDES-NOTFOUND")

View file

@ -15,7 +15,6 @@ option(USE_SYSTEM_DYNARMIC "Use the system dynarmic (instead of the bundled one)
option(USE_SYSTEM_FMT "Use the system fmt (instead of the bundled one)" OFF)
option(USE_SYSTEM_XBYAK "Use the system xbyak (instead of the bundled one)" OFF)
option(USE_SYSTEM_INIH "Use the system inih (instead of the bundled one)" OFF)
option(USE_SYSTEM_FDK_AAC_HEADERS "Use the system fdk-aac headers (instead of the bundled one)" OFF)
option(USE_SYSTEM_FFMPEG_HEADERS "Use the system FFmpeg headers (instead of the bundled one)" OFF)
option(USE_SYSTEM_GLSLANG "Use the system glslang and SPIR-V libraries (instead of the bundled ones)" OFF)
option(USE_SYSTEM_ZSTD "Use the system Zstandard library (instead of the bundled one)" OFF)
@ -36,7 +35,6 @@ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_DYNARMIC "Disable system Dynarmic" OFF "US
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FMT "Disable system fmt" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_XBYAK "Disable system xbyak" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_INIH "Disable system inih" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FDK_AAC_HEADERS "Disable system fdk_aac" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_FFMPEG_HEADERS "Disable system ffmpeg" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_GLSLANG "Disable system glslang" OFF "USE_SYSTEM_LIBS" OFF)
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ZSTD "Disable system Zstandard" OFF "USE_SYSTEM_LIBS" OFF)
@ -57,7 +55,6 @@ set(LIB_VAR_LIST
FMT
XBYAK
INIH
FDK_AAC_HEADERS
FFMPEG_HEADERS
GLSLANG
ZSTD

102
externals/faad2/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,102 @@
# Copy source to build directory for some modifications.
set(FAAD2_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/faad2/libfaad")
if (NOT EXISTS "${FAAD2_SOURCE_DIR}")
file(COPY faad2/libfaad/ DESTINATION "${FAAD2_SOURCE_DIR}/")
# These are fixed defines for some reason and not controllable with compile flags.
file(READ "${FAAD2_SOURCE_DIR}/common.h" FAAD2_COMMON_H)
# Disable SBR decoding since we don't want it for AAC-LC.
string(REGEX REPLACE "#define SBR_DEC" "" FAAD2_COMMON_H "${FAAD2_COMMON_H}")
# Disable PS decoding. This can cause mono to be upmixed to stereo, which we don't want.
string(REGEX REPLACE "#define PS_DEC" "" FAAD2_COMMON_H "${FAAD2_COMMON_H}")
file(WRITE "${FAAD2_SOURCE_DIR}/common.h" "${FAAD2_COMMON_H}")
endif()
# Source list from faad2/libfaad/Makefile.am, cut down to just what we need for AAC-LC.
add_library(faad2 STATIC EXCLUDE_FROM_ALL
"${FAAD2_SOURCE_DIR}/bits.c"
"${FAAD2_SOURCE_DIR}/cfft.c"
"${FAAD2_SOURCE_DIR}/common.c"
"${FAAD2_SOURCE_DIR}/decoder.c"
"${FAAD2_SOURCE_DIR}/drc.c"
"${FAAD2_SOURCE_DIR}/error.c"
"${FAAD2_SOURCE_DIR}/filtbank.c"
"${FAAD2_SOURCE_DIR}/huffman.c"
"${FAAD2_SOURCE_DIR}/is.c"
"${FAAD2_SOURCE_DIR}/mdct.c"
"${FAAD2_SOURCE_DIR}/mp4.c"
"${FAAD2_SOURCE_DIR}/ms.c"
"${FAAD2_SOURCE_DIR}/output.c"
"${FAAD2_SOURCE_DIR}/pns.c"
"${FAAD2_SOURCE_DIR}/pulse.c"
"${FAAD2_SOURCE_DIR}/specrec.c"
"${FAAD2_SOURCE_DIR}/syntax.c"
"${FAAD2_SOURCE_DIR}/tns.c"
)
target_include_directories(faad2 PUBLIC faad2/include PRIVATE "${FAAD2_SOURCE_DIR}")
# Configure compile definitions.
# Read version from autoconf script for configuring constant.
file(READ faad2/configure.ac CONFIGURE_SCRIPT)
string(REGEX MATCH "AC_INIT\\(faad2, ([0-9.]+)\\)" _ ${CONFIGURE_SCRIPT})
set(FAAD_VERSION ${CMAKE_MATCH_1})
message(STATUS "Building faad2 version ${FAAD_VERSION}")
# Check for functions and headers.
include(CheckFunctionExists)
include(CheckIncludeFiles)
check_function_exists(getpwuid HAVE_GETPWUID)
check_function_exists(lrintf HAVE_LRINTF)
check_function_exists(memcpy HAVE_MEMCPY)
check_function_exists(strchr HAVE_STRCHR)
check_function_exists(strsep HAVE_STRSEP)
check_include_files(dlfcn.h HAVE_DLFCN_H)
check_include_files(errno.h HAVE_ERRNO_H)
check_include_files(float.h HAVE_FLOAT_H)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(IOKit/IOKitLib.h HAVE_IOKIT_IOKITLIB_H)
check_include_files(limits.h HAVE_LIMITS_H)
check_include_files(mathf.h HAVE_MATHF_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdio.h HAVE_STDIO_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(string.h HAVE_STRING_H)
check_include_files(sysfs/libsysfs.h HAVE_SYSFS_LIBSYSFS_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(unistd.h HAVE_UNISTD_H)
# faad2 uses a relative include for its config.h which breaks under CMake.
# We can use target_compile_definitions to pass on the configuration instead.
target_compile_definitions(faad2 PRIVATE
-DFAAD_VERSION=${FAAD_VERSION}
-DPACKAGE_VERSION=\"${FAAD_VERSION}\"
-DSTDC_HEADERS
-DHAVE_GETPWUID=${HAVE_GETPWUID}
-DHAVE_LRINTF=${HAVE_LRINTF}
-DHAVE_MEMCPY=${HAVE_MEMCPY}
-DHAVE_STRCHR=${HAVE_STRCHR}
-DHAVE_STRSEP=${HAVE_STRSEP}
-DHAVE_DLFCN_H=${HAVE_DLFCN_H}
-DHAVE_ERRNO_H=${HAVE_ERRNO_H}
-DHAVE_FLOAT_H=${HAVE_FLOAT_H}
-DHAVE_INTTYPES_H=${HAVE_INTTYPES_H}
-DHAVE_IOKIT_IOKITLIB_H=${HAVE_IOKIT_IOKITLIB_H}
-DHAVE_LIMITS_H=${HAVE_LIMITS_H}
-DHAVE_MATHF_H=${HAVE_MATHF_H}
-DHAVE_STDINT_H=${HAVE_STDINT_H}
-DHAVE_STDIO_H=${HAVE_STDIO_H}
-DHAVE_STDLIB_H=${HAVE_STDLIB_H}
-DHAVE_STRINGS_H=${HAVE_STRINGS_H}
-DHAVE_STRING_H=${HAVE_STRING_H}
-DHAVE_SYSFS_LIBSYSFS_H=${HAVE_SYSFS_LIBSYSFS_H}
-DHAVE_SYS_STAT_H=${HAVE_SYS_STAT_H}
-DHAVE_SYS_TIME_H=${HAVE_SYS_TIME_H}
-DHAVE_SYS_TYPES_H=${HAVE_SYS_TYPES_H}
-DHAVE_UNISTD_H=${HAVE_UNISTD_H}
# Only compile for AAC-LC decoding.
-DLC_ONLY_DECODER
)

1
externals/faad2/faad2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 3918dee56063500d0aa23d6c3c94b211ac471a8c