Update soxr to 0.1.3; make wasm compatible

This commit is contained in:
2022-08-03 18:10:19 -04:00
parent 6e4030212c
commit 39eb95a824
141 changed files with 9179 additions and 9529 deletions

View File

@@ -0,0 +1,35 @@
# SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Function to find C compiler feature flags
include (CheckCSourceCompiles)
include (FindPackageHandleStandardArgs)
function (FindCFlags PKG_NAME PKG_DESC TRIAL_C_FLAGS TEST_C_SOURCE)
foreach (TRIAL_C_FLAG ${TRIAL_C_FLAGS})
message (STATUS "Trying ${PKG_NAME} C flags: ${TRIAL_C_FLAG}")
unset (DETECT_${PKG_NAME}_C_FLAGS CACHE) #displayed by check_c_source_compiles
set (TMP "${CMAKE_REQUIRED_FLAGS}")
set (CMAKE_REQUIRED_FLAGS "${TRIAL_C_FLAG}")
check_c_source_compiles ("${TEST_C_SOURCE}" DETECT_${PKG_NAME}_C_FLAGS)
set (CMAKE_REQUIRED_FLAGS "${TMP}")
if (DETECT_${PKG_NAME}_C_FLAGS)
set (DETECTED_C_FLAGS "${TRIAL_C_FLAG}")
break ()
endif ()
endforeach ()
# N.B. Will not overwrite existing cache variable:
set (${PKG_NAME}_C_FLAGS "${DETECTED_C_FLAGS}"
CACHE STRING "C compiler flags for ${PKG_DESC}")
find_package_handle_standard_args (
${PKG_NAME} DEFAULT_MSG ${PKG_NAME}_C_FLAGS ${PKG_NAME}_C_FLAGS)
mark_as_advanced (${PKG_NAME}_C_FLAGS)
set (${PKG_NAME}_FOUND ${${PKG_NAME}_FOUND} PARENT_SCOPE)
endfunction ()

View File

@@ -1,23 +1,23 @@
# SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
# SoX Resampler Library Copyright (c) 2007-18 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Find AVCODEC
# Find the native installation of this package: includes and libraries.
# Find the installation of this package: include-dirs and libraries.
#
# AVCODEC_INCLUDES - where to find headers for this package.
# AVCODEC_LIBRARIES - List of libraries when using this package.
# AVCODEC_FOUND - True if this package can be found.
# AVCODEC_INCLUDE_DIRS - where to find headers for this package.
# AVCODEC_LIBRARIES - libraries to link to when using this package.
# AVCODEC_FOUND - true iff this package can be found.
if (AVCODEC_INCLUDES)
if (AVCODEC_INCLUDE_DIRS)
set (AVCODEC_FIND_QUIETLY TRUE)
endif (AVCODEC_INCLUDES)
endif ()
find_path (AVCODEC_INCLUDES libavcodec/avcodec.h)
find_path (AVCODEC_INCLUDE_DIRS libavcodec/avcodec.h)
find_library (AVCODEC_LIBRARIES NAMES avcodec)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (
AVCODEC DEFAULT_MSG AVCODEC_LIBRARIES AVCODEC_INCLUDES)
AVCODEC DEFAULT_MSG AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIRS)
mark_as_advanced (AVCODEC_LIBRARIES AVCODEC_INCLUDES)
mark_as_advanced (AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIRS)

View File

@@ -0,0 +1,23 @@
# SoX Resampler Library Copyright (c) 2007-18 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Find AVUTIL
# Find the installation of this package: includes and libraries.
#
# AVUTIL_INCLUDE_DIRS - where to find headers for this package.
# AVUTIL_LIBRARIES - libraries to link to when using this package.
# AVUTIL_FOUND - true iff this package can be found.
if (AVUTIL_INCLUDE_DIRS)
set (AVUTIL_FIND_QUIETLY TRUE)
endif ()
find_path (AVUTIL_INCLUDE_DIRS libavutil/cpu.h)
find_library (AVUTIL_LIBRARIES NAMES avutil)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (
AVUTIL DEFAULT_MSG AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS)
mark_as_advanced (AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS)

View File

@@ -1,115 +0,0 @@
# - Finds OpenMP support
# This module can be used to detect OpenMP support in a compiler.
# If the compiler supports OpenMP, the flags required to compile with
# openmp support are set.
#
# The following variables are set:
# OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
# OPENMP_FOUND - true if openmp is detected
#
# Supported compilers can be found at http://openmp.org/wp/openmp-compilers/
#
# Modifications for soxr:
# * don't rely on presence of C++ compiler
# * support MINGW
#
#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2008-2009 André Rigland Brodtkorb <Andre.Brodtkorb@ifi.uio.no>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include (CheckCSourceCompiles)
include (FindPackageHandleStandardArgs)
set (OpenMP_C_FLAG_CANDIDATES
#Gnu
"-fopenmp"
#Microsoft Visual Studio
"/openmp"
#Intel windows
"-Qopenmp"
#Intel
"-openmp"
#Empty, if compiler automatically accepts openmp
" "
#Sun
"-xopenmp"
#HP
"+Oopenmp"
#IBM XL C/c++
"-qsmp"
#Portland Group
"-mp"
)
# sample openmp source code to test
set (OpenMP_C_TEST_SOURCE
"
#include <omp.h>
int main() {
#ifdef _OPENMP
return 0;
#else
breaks_on_purpose
#endif
}
")
# if these are set then do not try to find them again,
# by avoiding any try_compiles for the flags
if (DEFINED OpenMP_C_FLAGS)
set (OpenMP_C_FLAG_CANDIDATES)
endif (DEFINED OpenMP_C_FLAGS)
# check c compiler
foreach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
set (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set (CMAKE_REQUIRED_FLAGS "${FLAG}")
unset (OpenMP_FLAG_DETECTED CACHE)
message (STATUS "Try OpenMP C flag = [${FLAG}]")
check_c_source_compiles ("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if (OpenMP_FLAG_DETECTED)
set (OpenMP_C_FLAGS_INTERNAL "${FLAG}")
break ()
endif (OpenMP_FLAG_DETECTED)
endforeach (FLAG ${OpenMP_C_FLAG_CANDIDATES})
set (OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
CACHE STRING "C compiler flags for OpenMP parallization")
# handle the standard arguments for find_package
find_package_handle_standard_args (OpenMP DEFAULT_MSG
OpenMP_C_FLAGS)
if (MINGW)
set (OpenMP_SHARED_LINKER_FLAGS "${OpenMP_SHARED_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
set (OpenMP_EXE_LINKER_FLAGS "${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
endif ()
mark_as_advanced (OpenMP_C_FLAGS OpenMP_SHARED_LINKER_FLAGS OpenMP_EXE_LINKER_FLAGS)

View File

@@ -1,94 +0,0 @@
# - Finds SIMD support
#
# The following variables are set:
# SIMD_C_FLAGS - flags to add to the C compiler for this package.
# SIMD_FOUND - true if support for this package is found.
#
#=============================================================================
# Based on FindOpenMP.cmake, which is:
#
# Copyright 2009 Kitware, Inc.
# Copyright 2008-2009 André Rigland Brodtkorb <Andre.Brodtkorb@ifi.uio.no>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * The names of Kitware, Inc., the Insight Consortium, or the names of
# any consortium members, or of any contributors, may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include (CheckCSourceCompiles)
include (FindPackageHandleStandardArgs)
if (WIN32) # Safety for when mixed lib/app compilers (but performance hit)
set (GCC_WIN32_SIMD_OPTS "-mincoming-stack-boundary=2")
endif ()
set (SIMD_C_FLAG_CANDIDATES
# x64
" "
# Microsoft Visual Studio x86
"/arch:SSE /fp:fast -D__SSE__"
# Gcc x86
"-msse -mfpmath=sse ${GCC_WIN32_SIMD_OPTS}"
# Gcc x86 (old versions)
"-msse -mfpmath=sse"
)
set (SIMD_C_TEST_SOURCE
"
#include <xmmintrin.h>
int main()
{
__m128 a, b;
float vals[4] = {0};
a = _mm_loadu_ps (vals);
b = a;
b = _mm_add_ps (a,b);
_mm_storeu_ps (vals,b);
return 0;
}
")
if (DEFINED SIMD_C_FLAGS)
set (SIMD_C_FLAG_CANDIDATES)
endif ()
foreach (FLAG ${SIMD_C_FLAG_CANDIDATES})
set (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set (CMAKE_REQUIRED_FLAGS "${FLAG}")
unset (SIMD_FLAG_DETECTED CACHE)
message (STATUS "Try SIMD C flag = [${FLAG}]")
check_c_source_compiles ("${SIMD_C_TEST_SOURCE}" SIMD_FLAG_DETECTED)
set (CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if (SIMD_FLAG_DETECTED)
set (SIMD_C_FLAGS_INTERNAL "${FLAG}")
break ()
endif ()
endforeach ()
set (SIMD_C_FLAGS "${SIMD_C_FLAGS_INTERNAL}"
CACHE STRING "C compiler flags for SIMD vectorization")
find_package_handle_standard_args (SIMD DEFAULT_MSG SIMD_C_FLAGS SIMD_C_FLAGS)
mark_as_advanced (SIMD_C_FLAGS)

View File

@@ -0,0 +1,54 @@
# SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Finds SIMD32 support
#
# The following variables are set:
# SIMD32_C_FLAGS - flags to add to the C compiler for this package.
# SIMD32_FOUND - true if support for this package is found.
if (DEFINED SIMD32_C_FLAGS)
set (TRIAL_C_FLAGS)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set (TRIAL_C_FLAGS
# Gcc
"-mfpu=neon-vfpv4 -mcpu=cortex-a7"
"-mfpu=neon -mfloat-abi=hard"
"-mfpu=neon -mfloat-abi=softfp"
"-mfpu=neon -mfloat-abi=soft"
)
set (TEST_C_SOURCE "
#include <arm_neon.h>
int main(int c, char * * v) {
float32x4_t a = vdupq_n_f32((float)c), b = vdupq_n_f32((float)!!v);
return !vgetq_lane_u32(vceqq_f32(a,b),0);
}
")
else ()
if (WIN32) # Safety for when mixed lib/app compilers (but performance hit)
set (GCC_WIN32_SIMD32_OPTS "-mincoming-stack-boundary=2")
endif ()
set (TRIAL_C_FLAGS
# x64
" "
# MSVC x86
"/arch:SSE /fp:fast -D__SSE__"
# Gcc x86
"-msse -mfpmath=sse ${GCC_WIN32_SIMD32_OPTS}"
# Gcc x86 (old versions)
"-msse -mfpmath=sse"
)
set (TEST_C_SOURCE "
#include <xmmintrin.h>
int main(int c, char * * v) {
__m128 a = _mm_set_ss((float)c), b = _mm_set_ss((float)!!v);
return _mm_comineq_ss(a,b);
}
")
endif ()
include (FindCFlags)
FindCFlags ("SIMD32" "FLOAT-32 (single-precision) SIMD vectorization"
"${TRIAL_C_FLAGS}" "${TEST_C_SOURCE}")

View File

@@ -0,0 +1,29 @@
# SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Finds SIMD64 support
#
# The following variables are set:
# SIMD64_C_FLAGS - flags to add to the C compiler for this package.
# SIMD64_FOUND - true if support for this package is found.
if (DEFINED SIMD64_C_FLAGS OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set (TRIAL_C_FLAGS)
else ()
set (TRIAL_C_FLAGS
"-mavx" # Gcc
"/arch:AVX" # MSVC
)
set (TEST_C_SOURCE "
#ifndef __AVX__
#error
#endif
#include <immintrin.h>
int main() {return 0;}
")
endif ()
include (FindCFlags)
FindCFlags ("SIMD64" "FLOAT-64 (double-precision) SIMD vectorization"
"${TRIAL_C_FLAGS}" "${TEST_C_SOURCE}")

View File

@@ -0,0 +1,37 @@
# SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Sets CMAKE_SYSTEM_PROCESSOR for cross-compiling.
macro (set_system_processor)
if (CMAKE_CROSSCOMPILING)
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "unknown")
unset(CMAKE_SYSTEM_PROCESSOR)
endif ()
if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
include (CheckCSourceCompiles)
set (CPU_LINES
"#if defined __x86_64__ || defined _M_X64 /*\;x86_64\;*/"
"#if defined __i386__ || defined _M_IX86 /*\;x86_32\;*/"
"#if defined __arm__ || defined _M_ARM /*\;arm\;*/"
)
foreach (CPU_LINE ${CPU_LINES})
string (CONCAT CPU_SOURCE "${CPU_LINE}" "
int main() {return 0;}
#endif
")
unset (SYSTEM_PROCESSOR_DETECTED CACHE)
check_c_source_compiles ("${CPU_SOURCE}" SYSTEM_PROCESSOR_DETECTED)
if (SYSTEM_PROCESSOR_DETECTED)
list (GET CPU_LINE 1 CMAKE_SYSTEM_PROCESSOR)
message (STATUS "CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}")
break ()
endif ()
endforeach ()
endif ()
# N.B. Will not overwrite existing cache variable:
set (CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}"
CACHE STRING "Target system processor")
endif ()
endmacro ()

View File

@@ -1,15 +0,0 @@
# SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# - Macro to determine endian type
# test_big_endian (VARIABLE)
# VARIABLE - variable to store the result to
macro (test_big_endian VARIABLE)
if ("${HAVE_${VARIABLE}}" MATCHES "^${HAVE_${VARIABLE}}$")
include (CheckCSourceRuns)
check_c_source_runs ("int main() {union {long i; char c[sizeof(long)];}
const u = {1}; return !!u.c[0];}" HAVE_${VARIABLE})
set (${VARIABLE} "${HAVE_${VARIABLE}}" CACHE INTERNAL "1 if system is big endian" FORCE)
endif ()
endmacro ()