portability/cross-compiling improvements/clean-up; env. var. runtime overrides
parent
5703403cea
commit
60ce8de4ff
|
@ -34,7 +34,11 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
endif ()
|
||||
|
||||
option (BUILD_TESTS "Build sanity-tests." ON)
|
||||
if (NOT CMAKE_CROSSCOMPILING)
|
||||
option (BUILD_TESTS "Build sanity-tests." ON)
|
||||
else ()
|
||||
set (BUILD_TESTS OFF)
|
||||
endif ()
|
||||
option (BUILD_SHARED_LIBS "Build shared libraries." ON)
|
||||
option (BUILD_EXAMPLES "Build examples." OFF)
|
||||
option (WITH_OPENMP "Include OpenMP threading." ON)
|
||||
|
@ -49,12 +53,13 @@ cmake_dependent_option (WITH_AVFFT "Use libavcodec (LGPL) for SIMD DFT." OFF
|
|||
"WITH_SIMD;NOT WITH_PFFFT" OFF)
|
||||
cmake_dependent_option (WITH_PFFFT "Use PFFFT (BSD-like licence) for SIMD DFT." ON
|
||||
"WITH_SIMD;NOT WITH_AVFFT" OFF)
|
||||
if (UNIX)
|
||||
if (EXISTS ${PROJECT_SOURCE_DIR}/lsr-tests)
|
||||
cmake_dependent_option (BUILD_LSR_TESTS "Build LSR tests." OFF
|
||||
"WITH_LSR_BINDINGS" OFF)
|
||||
endif ()
|
||||
if (UNIX AND NOT CMAKE_CROSSCOMPILING AND EXISTS ${PROJECT_SOURCE_DIR}/lsr-tests)
|
||||
cmake_dependent_option (BUILD_LSR_TESTS "Build LSR tests." OFF
|
||||
"WITH_LSR_BINDINGS" OFF)
|
||||
else ()
|
||||
set (BUILD_LSR_TESTS OFF)
|
||||
endif ()
|
||||
option (WITH_DEV_TRACE "Enable developer trace output." OFF)
|
||||
|
||||
|
||||
|
||||
|
@ -65,8 +70,11 @@ list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
|||
include (CheckFunctionExists)
|
||||
include (CheckIncludeFiles)
|
||||
include (CheckLibraryExists)
|
||||
include (SetSystemProcessor)
|
||||
include (TestBigEndian)
|
||||
|
||||
set_system_processor ()
|
||||
|
||||
check_library_exists (m pow "" NEED_LIBM)
|
||||
if (NEED_LIBM)
|
||||
set (CMAKE_REQUIRED_LIBRARIES "m;${CMAKE_REQUIRED_LIBRARIES}")
|
||||
|
@ -84,44 +92,35 @@ endif ()
|
|||
|
||||
if (WITH_SIMD)
|
||||
find_package (SIMD)
|
||||
if (SIMD_FOUND)
|
||||
set (HAVE_SIMD 1)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WITH_SINGLE_PRECISION)
|
||||
set (HAVE_SINGLE_PRECISION 1)
|
||||
endif ()
|
||||
|
||||
if (WITH_DOUBLE_PRECISION)
|
||||
set (HAVE_DOUBLE_PRECISION 1)
|
||||
endif ()
|
||||
|
||||
if (WITH_AVFFT)
|
||||
find_package (LibAVCodec)
|
||||
find_package (LibAVCodec REQUIRED)
|
||||
if (AVCODEC_FOUND)
|
||||
include_directories (${AVCODEC_INCLUDE_DIRS})
|
||||
set (HAVE_AVFFT 1)
|
||||
set (LIBS ${LIBS} ${AVCODEC_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND HAVE_SIMD)
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND SIMD_FOUND)
|
||||
find_package (LibAVUtil)
|
||||
if (AVUTIL_FOUND)
|
||||
include_directories (${AVUTIL_INCLUDE_DIRS})
|
||||
set (HAVE_AVUTIL 1)
|
||||
set (LIBS ${LIBS} ${AVUTIL_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
check_function_exists (lrint HAVE_LRINT)
|
||||
check_include_files (fenv.h HAVE_FENV_H)
|
||||
test_big_endian (WORDS_BIGENDIAN)
|
||||
check_include_files (stdbool.h HAVE_STDBOOL_H)
|
||||
check_include_files (stdint.h HAVE_STDINT_H)
|
||||
test_big_endian (HAVE_BIGENDIAN)
|
||||
|
||||
|
||||
|
||||
# Compiler configuration:
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set (PROJECT_CXX_FLAGS "-Wconversion -Wall -W -pedantic -Wundef -Wcast-align -Wpointer-arith -Wno-long-long")
|
||||
set (PROJECT_C_FLAGS "${PROJECT_CXX_FLAGS} -std=gnu89 -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes")
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
|
@ -255,10 +254,8 @@ if (UNIX)
|
|||
soxr-config.h
|
||||
src/CMakeFiles
|
||||
src/cmake_install.cmake
|
||||
src/libsoxr-dev.src
|
||||
src/libsoxr-lsr.pc
|
||||
src/libsoxr.pc
|
||||
src/libsoxr.src
|
||||
src/Makefile)
|
||||
endif ()
|
||||
|
||||
|
|
26
INSTALL
26
INSTALL
|
@ -4,7 +4,7 @@ INSTALLATION GUIDE CONTENTS
|
|||
|
||||
* Standard build
|
||||
* Build customisation
|
||||
* Cross-compiling with mingw (linux host)
|
||||
* Cross-compilation
|
||||
* Integration with other build systems
|
||||
* SIMD
|
||||
|
||||
|
@ -82,17 +82,29 @@ Options, if given, should be preceded with '-D', e.g.
|
|||
|
||||
|
||||
|
||||
CROSS-COMPILING WITH MINGW (LINUX HOST)
|
||||
CROSS-COMPILATION
|
||||
|
||||
For example:
|
||||
E.g. targeting a Linux ARM system:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc-5 \
|
||||
..
|
||||
or, also building the examples (one of which uses C++):
|
||||
|
||||
cmake -DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc-5 \
|
||||
-DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++-5 \
|
||||
-DBUILD_EXAMPLES=1 \
|
||||
..
|
||||
|
||||
E.g. with Mingw (Linux host), using a tool-chain file:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-x86_64-mingw-w64-mingw32.cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
-DHAVE_WORDS_BIGENDIAN_EXITCODE=1 \
|
||||
-DBUILD_TESTS=0 \
|
||||
-DBUILD_EXAMPLES=1 \
|
||||
..
|
||||
make
|
||||
|
||||
|
@ -128,7 +140,7 @@ For MS visual studio, see msvc/README
|
|||
SIMD
|
||||
|
||||
A single build of the library can support both SIMD and non-SIMD variants of a
|
||||
particular CPU, via a run-time selection of which instruction-set to use. The
|
||||
particular CPU via run-time selection of which instruction-set to use. The
|
||||
SOXR_USE_SIMD boolean environment provides manual selection; otherwise,
|
||||
selection is automatic for x86 CPUs, and can be automatic for ARM CPUs if the
|
||||
3rd-party library `libavutil' is available when libsoxr is built.
|
||||
|
|
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
|||
Version 0.1.3 (2016-mm-dd)
|
||||
* Better support for ARM+SIMD and cross-compilation.
|
||||
* Other minor fixes/improvements to build/tests/documentation.
|
||||
|
||||
Version 0.1.2 (2015-09-05)
|
||||
* Fix conversion failure when I/O types differ but I/O rates don't.
|
||||
* Fix #defines for interpolation order selection.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
if (AVCODEC_INCLUDES)
|
||||
set (AVCODEC_FIND_QUIETLY TRUE)
|
||||
endif (AVCODEC_INCLUDES)
|
||||
endif ()
|
||||
|
||||
find_path (AVCODEC_INCLUDES libavcodec/avcodec.h)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
if (AVUTIL_INCLUDES)
|
||||
set (AVUTIL_FIND_QUIETLY TRUE)
|
||||
endif (AVUTIL_INCLUDES)
|
||||
endif ()
|
||||
|
||||
find_path (AVUTIL_INCLUDES libavutil/cpu.h)
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ else ()
|
|||
# Microsoft Visual Studio x86
|
||||
"/arch:SSE /fp:fast -D__SSE__"
|
||||
# Gcc x86
|
||||
"-msse -mfpmath=sse ${GCC_WIN32_SIMD_OPTS}"
|
||||
"-Wno-cast-align -msse -mfpmath=sse ${GCC_WIN32_SIMD_OPTS}"
|
||||
# Gcc x86 (old versions)
|
||||
"-msse -mfpmath=sse"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# 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_SYSTEM_PROCESSOR}" STREQUAL "")
|
||||
include (CheckCSourceCompiles)
|
||||
set (CPU_CANDIDATES
|
||||
"#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_CANDIDATES})
|
||||
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 set to ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
break ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
endmacro ()
|
|
@ -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 ()
|
|
@ -42,4 +42,5 @@
|
|||
#define min(x,y) ((x)<(y)?(x):(y))
|
||||
#define max(x,y) ((x)>(y)?(x):(y))
|
||||
|
||||
#undef AL
|
||||
#define AL(a) (sizeof(a)/sizeof((a)[0])) /* Array Length */
|
||||
|
|
8
go
8
go
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
|
||||
# Licence for this file: LGPL v2.1 See LICENCE for details.
|
||||
|
||||
|
@ -12,6 +14,6 @@ rm -f CMakeCache.txt # Prevent interference from any in-tree build
|
|||
mkdir -p $build
|
||||
cd $build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=$build -Wno-dev .. &&
|
||||
make $j &&
|
||||
(ctest $j || echo "FAILURE details in $build/Testing/Temporary/LastTest.log")
|
||||
cmake -DCMAKE_BUILD_TYPE=$build -Wno-dev ..
|
||||
make $j
|
||||
ctest $j || echo "FAILURE details in $build/Testing/Temporary/LastTest.log"
|
||||
|
|
|
@ -7,44 +7,18 @@
|
|||
#if !defined soxr_config_included
|
||||
#define soxr_config_included
|
||||
|
||||
#define HAVE_SINGLE_PRECISION 1
|
||||
#define HAVE_DOUBLE_PRECISION 1
|
||||
#define HAVE_AVFFT 0
|
||||
#define HAVE_AVUTIL 0
|
||||
#define HAVE_SIMD 1
|
||||
#define WITH_SINGLE_PRECISION 1
|
||||
#define WITH_DOUBLE_PRECISION 1
|
||||
|
||||
#define AVCODEC_FOUND 0
|
||||
#define AVUTIL_FOUND 0
|
||||
#define SIMD_FOUND 1
|
||||
|
||||
#define HAVE_FENV_H 0
|
||||
#define HAVE_STDBOOL_H 0
|
||||
#define HAVE_STDINT_H 0
|
||||
#define HAVE_LRINT 0
|
||||
#define WORDS_BIGENDIAN 0
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#undef bool
|
||||
#undef false
|
||||
#undef true
|
||||
#define bool int
|
||||
#define false 0
|
||||
#define true 1
|
||||
|
||||
#undef int16_t
|
||||
#undef int32_t
|
||||
#undef int64_t
|
||||
#undef uint32_t
|
||||
#undef uint64_t
|
||||
#define int16_t short
|
||||
#if LONG_MAX > 2147483647L
|
||||
#define int32_t int
|
||||
#define int64_t long
|
||||
#elif LONG_MAX < 2147483647L
|
||||
#error this library requires that 'long int' has at least 32-bits
|
||||
#else
|
||||
#define int32_t long
|
||||
#if defined _MSC_VER
|
||||
#define int64_t __int64
|
||||
#else
|
||||
#define int64_t long long
|
||||
#endif
|
||||
#endif
|
||||
#define uint32_t unsigned int32_t
|
||||
#define uint64_t unsigned int64_t
|
||||
#define HAVE_BIGENDIAN 0
|
||||
#define WITH_DEV_TRACE 0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,47 +1,21 @@
|
|||
/* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
|
||||
/* SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
|
||||
* Licence for this file: LGPL v2.1 See LICENCE for details. */
|
||||
|
||||
#if !defined soxr_config_included
|
||||
#define soxr_config_included
|
||||
|
||||
#cmakedefine01 HAVE_SINGLE_PRECISION
|
||||
#cmakedefine01 HAVE_DOUBLE_PRECISION
|
||||
#cmakedefine01 HAVE_AVFFT
|
||||
#cmakedefine01 HAVE_AVUTIL
|
||||
#cmakedefine01 HAVE_SIMD
|
||||
#cmakedefine01 WITH_SINGLE_PRECISION
|
||||
#cmakedefine01 WITH_DOUBLE_PRECISION
|
||||
|
||||
#cmakedefine01 AVCODEC_FOUND
|
||||
#cmakedefine01 AVUTIL_FOUND
|
||||
#cmakedefine01 SIMD_FOUND
|
||||
|
||||
#cmakedefine01 HAVE_FENV_H
|
||||
#cmakedefine01 HAVE_STDBOOL_H
|
||||
#cmakedefine01 HAVE_STDINT_H
|
||||
#cmakedefine01 HAVE_LRINT
|
||||
#cmakedefine01 WORDS_BIGENDIAN
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#undef bool
|
||||
#undef false
|
||||
#undef true
|
||||
#define bool int
|
||||
#define false 0
|
||||
#define true 1
|
||||
|
||||
#undef int16_t
|
||||
#undef int32_t
|
||||
#undef int64_t
|
||||
#undef uint32_t
|
||||
#undef uint64_t
|
||||
#define int16_t short
|
||||
#if LONG_MAX > 2147483647L
|
||||
#define int32_t int
|
||||
#define int64_t long
|
||||
#elif LONG_MAX < 2147483647L
|
||||
#error this library requires that 'long int' has at least 32-bits
|
||||
#else
|
||||
#define int32_t long
|
||||
#if defined _MSC_VER
|
||||
#define int64_t __int64
|
||||
#else
|
||||
#define int64_t long long
|
||||
#endif
|
||||
#endif
|
||||
#define uint32_t unsigned int32_t
|
||||
#define uint64_t unsigned int64_t
|
||||
#cmakedefine01 HAVE_BIGENDIAN
|
||||
#cmakedefine01 WITH_DEV_TRACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,13 +23,13 @@ add_definitions (${PROJECT_C_FLAGS} -DSOXR_LIB)
|
|||
# Libsoxr configuration:
|
||||
|
||||
set (RDFT32 fft4g32)
|
||||
if (WITH_AVFFT AND AVCODEC_FOUND)
|
||||
if (AVCODEC_FOUND)
|
||||
set (RDFT32 avfft32)
|
||||
set (RDFT32S avfft32s)
|
||||
elseif (WITH_PFFFT)
|
||||
#set (RDFT32 pffft32)
|
||||
set (RDFT32S pffft32s)
|
||||
elseif (WITH_SIMD)
|
||||
elseif (SIMD_FOUND)
|
||||
set (RDFT32S fft4g32s)
|
||||
endif ()
|
||||
|
||||
|
@ -41,7 +41,7 @@ if (WITH_SINGLE_PRECISION)
|
|||
set (SP_SOURCES rate32 ${RDFT32})
|
||||
endif ()
|
||||
|
||||
if (HAVE_SIMD)
|
||||
if (SIMD_FOUND)
|
||||
set (SIMD_SOURCES rate32s ${RDFT32S} simd)
|
||||
foreach (source ${SIMD_SOURCES})
|
||||
set_property (SOURCE ${source} PROPERTY COMPILE_FLAGS ${SIMD_C_FLAGS})
|
||||
|
@ -54,7 +54,7 @@ endif ()
|
|||
|
||||
add_library (${PROJECT_NAME} ${LIB_TYPE} ${PROJECT_NAME}.c data-io dbesi0 filter fft4g64
|
||||
${SP_SOURCES} vr32 ${DP_SOURCES} ${SIMD_SOURCES})
|
||||
target_link_libraries (${PROJECT_NAME} PRIVATE ${AVCODEC_LIBRARIES} ${AVUTIL_LIBRARIES} ${LIBM_LIBRARIES})
|
||||
target_link_libraries (${PROJECT_NAME} PRIVATE ${LIBS} ${LIBM_LIBRARIES})
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES
|
||||
VERSION "${SO_VERSION}"
|
||||
SOVERSION ${SO_VERSION_MAJOR}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
void _soxr_deinterleave(double * * dest, /* Round/clipping not needed here */
|
||||
soxr_datatype_t data_type, void const * * src0, size_t n, unsigned ch)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ void _soxr_deinterleave(double * * dest, /* Round/clipping not needed here */
|
|||
|
||||
|
||||
|
||||
#if HAVE_SINGLE_PRECISION
|
||||
#if WITH_SINGLE_PRECISION
|
||||
void _soxr_deinterleave_f(float * * dest, /* Round/clipping not needed here */
|
||||
soxr_datatype_t data_type, void const * * src0, size_t n, unsigned ch)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ void _soxr_deinterleave_f(float * * dest, /* Round/clipping not needed here */
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
#define FLOATX double
|
||||
|
||||
#define LSX_RINT_CLIP_2 lsx_rint32_clip_2
|
||||
|
@ -139,7 +139,7 @@ void _soxr_deinterleave_f(float * * dest, /* Round/clipping not needed here */
|
|||
|
||||
|
||||
|
||||
#if HAVE_SINGLE_PRECISION
|
||||
#if WITH_SINGLE_PRECISION
|
||||
#define FLOATX float
|
||||
|
||||
#define LSX_RINT_CLIP_2 lsx_rint32_clip_2_f
|
||||
|
@ -199,7 +199,7 @@ void _soxr_deinterleave_f(float * * dest, /* Round/clipping not needed here */
|
|||
return 0; \
|
||||
} while (0)
|
||||
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
size_t /* clips */ _soxr_interleave(soxr_datatype_t data_type, void * * dest0,
|
||||
double const * const * src, size_t n, unsigned ch, unsigned long * seed)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ size_t /* clips */ _soxr_interleave(soxr_datatype_t data_type, void * * dest0,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_SINGLE_PRECISION
|
||||
#if WITH_SINGLE_PRECISION
|
||||
size_t /* clips */ _soxr_interleave_f(soxr_datatype_t data_type, void * * dest0,
|
||||
float const * const * src, size_t n, unsigned ch, unsigned long * seed)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "fft4g.c"
|
||||
#include "soxr-config.h"
|
||||
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
static void * null(void) {return 0;}
|
||||
static void nothing(void) {}
|
||||
static void forward (int length, void * setup, double * H) {lsx_safe_rdft(length, 1, H); (void)setup;}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "fft4g.h"
|
||||
#include "ccrw2.h"
|
||||
|
||||
#if 1 || HAVE_DOUBLE_PRECISION /* Always need this, for lsx_fir_to_phase. */
|
||||
#if 1 || WITH_DOUBLE_PRECISION /* Always need this, for lsx_fir_to_phase. */
|
||||
#define DFT_FLOAT double
|
||||
#define DONE_WITH_FFT_CACHE done_with_fft_cache
|
||||
#define FFT_CACHE_CCRW fft_cache_ccrw
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include "fft4g_cache.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_SINGLE_PRECISION && !HAVE_AVFFT
|
||||
#if WITH_SINGLE_PRECISION && !AVCODEC_FOUND
|
||||
#define DFT_FLOAT float
|
||||
#define DONE_WITH_FFT_CACHE done_with_fft_cache_f
|
||||
#define FFT_CACHE_CCRW fft_cache_ccrw_f
|
||||
|
@ -48,14 +48,14 @@
|
|||
#include "fft4g_cache.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_DOUBLE_PRECISION || !SOXR_LIB
|
||||
#if WITH_DOUBLE_PRECISION || !SOXR_LIB
|
||||
#define DFT_FLOAT double
|
||||
#define ORDERED_CONVOLVE lsx_ordered_convolve
|
||||
#define ORDERED_PARTIAL_CONVOLVE lsx_ordered_partial_convolve
|
||||
#include "rdft.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_SINGLE_PRECISION
|
||||
#if WITH_SINGLE_PRECISION
|
||||
#define DFT_FLOAT float
|
||||
#define ORDERED_CONVOLVE lsx_ordered_convolve_f
|
||||
#define ORDERED_PARTIAL_CONVOLVE lsx_ordered_partial_convolve_f
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
|
||||
/* SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
|
||||
* Licence for this file: LGPL v2.1 See LICENCE for details. */
|
||||
|
||||
#if !defined soxr_internal_included
|
||||
#define soxr_internal_included
|
||||
|
||||
#include "soxr-config.h"
|
||||
#include "std-types.h"
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
@ -14,33 +14,31 @@
|
|||
#define range_limit(x, lower, upper) (min(max(x, lower), upper))
|
||||
#define linear_to_dB(x) (log10(x) * 20)
|
||||
#define array_length(a) (sizeof(a)/sizeof(a[0]))
|
||||
#if !defined AL
|
||||
#define AL(a) array_length(a)
|
||||
#endif
|
||||
#define iAL(a) (int)AL(a)
|
||||
#define sqr(a) ((a) * (a))
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined __GNUC__
|
||||
#define UNUSED __attribute__ ((unused))
|
||||
#else
|
||||
#define UNUSED
|
||||
#endif
|
||||
|
||||
#if defined NDEBUG
|
||||
#if !WITH_DEV_TRACE
|
||||
#ifdef __GNUC__
|
||||
void lsx_dummy(char const *, ...);
|
||||
#else
|
||||
static __inline void lsx_dummy(char const * x, ...) {}
|
||||
#endif
|
||||
#define lsx_debug if(0) lsx_dummy
|
||||
#define lsx_debug_more lsx_debug
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
UNUSED static void lsx_debug(char const * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fputc('\n', stderr);
|
||||
va_end(args);
|
||||
}
|
||||
int _soxr_trace_level(void);
|
||||
void _soxr_trace(char const * fmt, ...);
|
||||
#define lsx_debug if (_soxr_trace_level() >= 4) _soxr_trace
|
||||
#define lsx_debug_more if (_soxr_trace_level() >= 5) _soxr_trace
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
#define pffft_aligned_malloc _soxr_simd_aligned_malloc
|
||||
#define pffft_aligned_calloc _soxr_simd_aligned_calloc
|
||||
|
||||
#undef inline
|
||||
#define inline __inline
|
||||
|
||||
#if defined _MSC_VER
|
||||
#define sin (float)sin
|
||||
#define cos (float)cos
|
||||
|
|
|
@ -69,7 +69,7 @@ extern fn_t RDFT_CB[11];
|
|||
#include "fifo.h"
|
||||
|
||||
typedef union { /* Int64 in parts */
|
||||
#if WORDS_BIGENDIAN
|
||||
#if HAVE_BIGENDIAN
|
||||
struct {int32_t ms; uint32_t ls;} parts;
|
||||
#else
|
||||
struct {uint32_t ls; int32_t ms;} parts;
|
||||
|
@ -78,7 +78,7 @@ typedef union { /* Int64 in parts */
|
|||
} int64p_t;
|
||||
|
||||
typedef union { /* Uint64 in parts */
|
||||
#if WORDS_BIGENDIAN
|
||||
#if HAVE_BIGENDIAN
|
||||
struct {uint32_t ms, ls;} parts;
|
||||
#else
|
||||
struct {uint32_t ls, ms;} parts;
|
||||
|
@ -695,7 +695,7 @@ static char const * rate_create(
|
|||
q_spec->phase_response,
|
||||
q_spec->passband_end,
|
||||
q_spec->stopband_begin,
|
||||
"\1\2\0"[q_spec->flags & 3],
|
||||
(rolloff_t)"\1\2\0"[q_spec->flags & 3],
|
||||
!!(q_spec->flags & SOXR_MAINTAIN_3DB_PT),
|
||||
scale,
|
||||
!!(q_spec->flags & SOXR_HI_PREC_CLOCK),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if !defined soxr_rint_included
|
||||
#define soxr_rint_included
|
||||
|
||||
#include "soxr-config.h"
|
||||
#include "std-types.h"
|
||||
|
||||
|
||||
|
||||
|
|
75
src/soxr.c
75
src/soxr.c
|
@ -2,7 +2,9 @@
|
|||
* Licence for this file: LGPL v2.1 See LICENCE for details. */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
@ -10,12 +12,35 @@
|
|||
#include "data-io.h"
|
||||
#include "internal.h"
|
||||
|
||||
#if HAVE_AVUTIL
|
||||
#if AVUTIL_FOUND
|
||||
#include <libavutil/cpu.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if WITH_DEV_TRACE
|
||||
|
||||
int _soxr_trace_level(void)
|
||||
{
|
||||
char const * e = getenv("SOXR_TRACE");
|
||||
return e? atoi(e) : 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _soxr_trace(char const * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fputc('\n', stderr);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
char const * soxr_version(void)
|
||||
{
|
||||
return "libsoxr-" SOXR_THIS_VERSION_STR;
|
||||
|
@ -169,7 +194,7 @@ soxr_io_spec_t soxr_io_spec(
|
|||
|
||||
|
||||
|
||||
#if HAVE_SIMD
|
||||
#if SIMD_FOUND
|
||||
static bool cpu_has_simd(void)
|
||||
{
|
||||
#if defined __x86_64__ || defined _M_X64
|
||||
|
@ -217,6 +242,31 @@ extern control_block_t _soxr_rate32s_cb, _soxr_rate32_cb, _soxr_rate64_cb, _soxr
|
|||
|
||||
|
||||
|
||||
static void runtime_num(char const * env_name, int min, int max, unsigned * field)
|
||||
{
|
||||
char const * e = getenv(env_name);
|
||||
if (e) {
|
||||
int i = atoi(e);
|
||||
if (i >= min && i <= max)
|
||||
*field = (unsigned)i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void runtime_flag(char const * env_name, unsigned n_bits, unsigned n_shift, unsigned long * flags)
|
||||
{
|
||||
char const * e = getenv(env_name);
|
||||
if (e) {
|
||||
int i = atoi(e);
|
||||
unsigned long mask = (1UL << n_bits) - 1;
|
||||
if (i >= 0 && i <= (int)mask)
|
||||
*flags &= ~(mask << n_shift), *flags |= ((unsigned long)i << n_shift);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
soxr_t soxr_create(
|
||||
double input_rate, double output_rate,
|
||||
unsigned num_channels,
|
||||
|
@ -254,27 +304,38 @@ soxr_t soxr_create(
|
|||
p->io_spec.scale = 1;
|
||||
|
||||
p->runtime_spec = runtime_spec? *runtime_spec : soxr_runtime_spec(1);
|
||||
|
||||
runtime_num("SOXR_MIN_DFT_SIZE", 8, 15, &p->runtime_spec.log2_min_dft_size);
|
||||
runtime_num("SOXR_LARGE_DFT_SIZE", 8, 20, &p->runtime_spec.log2_large_dft_size);
|
||||
runtime_num("SOXR_COEFS_SIZE", 100, 800, &p->runtime_spec.coef_size_kbytes);
|
||||
runtime_num("SOXR_NUM_THREADS", 0, 64, &p->runtime_spec.num_threads);
|
||||
runtime_flag("SOXR_COEF_INTERP", 2, 0, &p->runtime_spec.flags);
|
||||
|
||||
runtime_flag("SOXR_STRICT_BUF", 1, 2, &p->runtime_spec.flags);
|
||||
runtime_flag("SOXR_NOSMALLINTOPT", 1, 3, &p->runtime_spec.flags);
|
||||
|
||||
p->io_spec.scale *= datatype_full_scale[p->io_spec.otype & 3] /
|
||||
datatype_full_scale[p->io_spec.itype & 3];
|
||||
|
||||
p->seed = (unsigned long)time(0) ^ (unsigned long)(size_t)p;
|
||||
|
||||
#if HAVE_SINGLE_PRECISION
|
||||
if (!HAVE_DOUBLE_PRECISION || (p->q_spec.precision <= 20 && !(p->q_spec.flags & SOXR_DOUBLE_PRECISION))
|
||||
#if WITH_SINGLE_PRECISION
|
||||
if (!WITH_DOUBLE_PRECISION || (p->q_spec.precision <= 20 && !(p->q_spec.flags & SOXR_DOUBLE_PRECISION))
|
||||
|| (p->q_spec.flags & SOXR_VR)) {
|
||||
p->deinterleave = (deinterleave_t)_soxr_deinterleave_f;
|
||||
p->interleave = (interleave_t)_soxr_interleave_f;
|
||||
memcpy(&p->control_block,
|
||||
(p->q_spec.flags & SOXR_VR)? &_soxr_vr32_cb :
|
||||
#if HAVE_SIMD
|
||||
#if SIMD_FOUND
|
||||
should_use_simd()? &_soxr_rate32s_cb :
|
||||
#endif
|
||||
&_soxr_rate32_cb, sizeof(p->control_block));
|
||||
}
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
#if HAVE_DOUBLE_PRECISION
|
||||
#if WITH_DOUBLE_PRECISION
|
||||
{
|
||||
p->deinterleave = (deinterleave_t)_soxr_deinterleave;
|
||||
p->interleave = (interleave_t)_soxr_interleave;
|
||||
|
|
|
@ -258,7 +258,7 @@ struct soxr_quality_spec { /* Typically */
|
|||
|
||||
struct soxr_runtime_spec { /* Typically */
|
||||
unsigned log2_min_dft_size;/* For DFT efficiency. [8,15] 10 */
|
||||
unsigned log2_large_dft_size;/* For DFT efficiency. [16,20] 17 */
|
||||
unsigned log2_large_dft_size;/* For DFT efficiency. [8,20] 17 */
|
||||
unsigned coef_size_kbytes; /* For SOXR_COEF_INTERP_AUTO (below). 400 */
|
||||
unsigned num_threads; /* If built so. 0 means `automatic'. 1 */
|
||||
void * e; /* Reserved for internal use. 0 */
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/* SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
|
||||
* Licence for this file: LGPL v2.1 See LICENCE for details. */
|
||||
|
||||
#if !defined soxr_std_types_included
|
||||
#define soxr_std_types_included
|
||||
|
||||
#include "soxr-config.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#if HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#undef bool
|
||||
#undef false
|
||||
#undef true
|
||||
#define bool int
|
||||
#define false 0
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#undef int16_t
|
||||
#undef int32_t
|
||||
#undef int64_t
|
||||
#undef uint32_t
|
||||
#undef uint64_t
|
||||
#define int16_t short
|
||||
#if LONG_MAX > 2147483647L
|
||||
#define int32_t int
|
||||
#define int64_t long
|
||||
#elif LONG_MAX < 2147483647L
|
||||
#error this library requires that 'long int' has at least 32-bits
|
||||
#else
|
||||
#define int32_t long
|
||||
#if defined _MSC_VER
|
||||
#define int64_t __int64
|
||||
#else
|
||||
#define int64_t long long
|
||||
#endif
|
||||
#endif
|
||||
#define uint32_t unsigned int32_t
|
||||
#define uint64_t unsigned int64_t
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -197,7 +197,7 @@ static float poly_fir1_u(float const * input, uint32_t frac)
|
|||
typedef struct {
|
||||
union {
|
||||
int64_t all;
|
||||
#if WORDS_BIGENDIAN
|
||||
#if HAVE_BIGENDIAN
|
||||
struct {int32_t integer; uint32_t frac;} part;
|
||||
#else
|
||||
struct {uint32_t frac; int32_t integer;} part;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# SoX Resampler Library Copyright (c) 2007-15 robs@users.sourceforge.net
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
#include <quadmath.h>
|
||||
#endif
|
||||
|
||||
#include "../examples/examples-common.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#if !defined M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#if QUAD
|
||||
#define modf modfq
|
||||
|
|
Loading…
Reference in New Issue