diff --git a/opus-4507637cc.patch b/opus-4507637cc.patch new file mode 100644 index 0000000..8f223a3 --- /dev/null +++ b/opus-4507637cc.patch @@ -0,0 +1,456 @@ +From 4507637ccca66d1520e806bbbb69396e4511679c Mon Sep 17 00:00:00 2001 +From: Jean-Marc Valin +Date: Thu, 25 May 2017 16:28:53 -0400 +Subject: [PATCH] Fixes unit tests that need arch-specific code + +We now include the object files for those rather than attempt to +problems. +--- + Makefile.am | 26 ++++++++++-------- + celt/bands.c | 4 +-- + celt/bands.h | 3 +++ + celt/tests/test_unit_dft.c | 46 ++++++++++++-------------------- + celt/tests/test_unit_mathops.c | 43 ++---------------------------- + celt/tests/test_unit_mdct.c | 58 ++++++++++++++++++----------------------- + celt/tests/test_unit_rotation.c | 37 ++------------------------ + celt/vq.c | 2 +- + celt/vq.h | 2 ++ + 9 files changed, 69 insertions(+), 152 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 67453e4..5b57b33 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -141,16 +141,20 @@ tests_test_opus_decode_LDADD = libopus.la $(NE10_LIBS) $(LIBM) + tests_test_opus_padding_SOURCES = tests/test_opus_padding.c tests/test_opus_common.h + tests_test_opus_padding_LDADD = libopus.la $(NE10_LIBS) $(LIBM) + ++CELT_OBJ = $(CELT_SOURCES:.c=.lo) ++SILK_OBJ = $(SILK_SOURCES:.c=.lo) ++ + silk_tests_test_unit_LPC_inv_pred_gain_SOURCES = silk/tests/test_unit_LPC_inv_pred_gain.c +-silk_tests_test_unit_LPC_inv_pred_gain_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +-# this target requires hidden symbols +-silk_tests_test_unit_LPC_inv_pred_gain_LDFLAGS = -static ++silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) ++if OPUS_ARM_EXTERNAL_ASM ++silk_tests_test_unit_LPC_inv_pred_gain_LDADD += libarmasm.la ++endif + + celt_tests_test_unit_cwrs32_SOURCES = celt/tests/test_unit_cwrs32.c + celt_tests_test_unit_cwrs32_LDADD = $(LIBM) + + celt_tests_test_unit_dft_SOURCES = celt/tests/test_unit_dft.c +-celt_tests_test_unit_dft_LDADD = $(NE10_LIBS) $(LIBM) ++celt_tests_test_unit_dft_LDADD = $(CELT_OBJ) $(NE10_LIBS) $(LIBM) + if OPUS_ARM_EXTERNAL_ASM + celt_tests_test_unit_dft_LDADD += libarmasm.la + endif +@@ -162,19 +166,19 @@ celt_tests_test_unit_laplace_SOURCES = celt/tests/test_unit_laplace.c + celt_tests_test_unit_laplace_LDADD = $(LIBM) + + celt_tests_test_unit_mathops_SOURCES = celt/tests/test_unit_mathops.c +-celt_tests_test_unit_mathops_LDADD = $(NE10_LIBS) $(LIBM) ++celt_tests_test_unit_mathops_LDADD = $(CELT_OBJ) $(NE10_LIBS) $(LIBM) + if OPUS_ARM_EXTERNAL_ASM + celt_tests_test_unit_mathops_LDADD += libarmasm.la + endif + + celt_tests_test_unit_mdct_SOURCES = celt/tests/test_unit_mdct.c +-celt_tests_test_unit_mdct_LDADD = $(NE10_LIBS) $(LIBM) ++celt_tests_test_unit_mdct_LDADD = $(CELT_OBJ) $(NE10_LIBS) $(LIBM) + if OPUS_ARM_EXTERNAL_ASM + celt_tests_test_unit_mdct_LDADD += libarmasm.la + endif + + celt_tests_test_unit_rotation_SOURCES = celt/tests/test_unit_rotation.c +-celt_tests_test_unit_rotation_LDADD = $(NE10_LIBS) $(LIBM) ++celt_tests_test_unit_rotation_LDADD = $(CELT_OBJ) $(NE10_LIBS) $(LIBM) + if OPUS_ARM_EXTERNAL_ASM + celt_tests_test_unit_rotation_LDADD += libarmasm.la + endif +@@ -308,25 +312,25 @@ OPT_UNIT_TEST_OBJ = $(celt_tests_test_unit_mathops_SOURCES:.c=.o) \ + + if HAVE_SSE + SSE_OBJ = $(CELT_SOURCES_SSE:.c=.lo) +-$(SSE_OBJ) $(OPT_UNIT_TEST_OBJ): CFLAGS += $(OPUS_X86_SSE_CFLAGS) ++$(SSE_OBJ): CFLAGS += $(OPUS_X86_SSE_CFLAGS) + endif + + if HAVE_SSE2 + SSE2_OBJ = $(CELT_SOURCES_SSE2:.c=.lo) +-$(SSE2_OBJ) $(OPT_UNIT_TEST_OBJ): CFLAGS += $(OPUS_X86_SSE2_CFLAGS) ++$(SSE2_OBJ): CFLAGS += $(OPUS_X86_SSE2_CFLAGS) + endif + + if HAVE_SSE4_1 + SSE4_1_OBJ = $(CELT_SOURCES_SSE4_1:.c=.lo) \ + $(SILK_SOURCES_SSE4_1:.c=.lo) \ + $(SILK_SOURCES_FIXED_SSE4_1:.c=.lo) +-$(SSE4_1_OBJ) $(OPT_UNIT_TEST_OBJ): CFLAGS += $(OPUS_X86_SSE4_1_CFLAGS) ++$(SSE4_1_OBJ): CFLAGS += $(OPUS_X86_SSE4_1_CFLAGS) + endif + + if HAVE_ARM_NEON_INTR + ARM_NEON_INTR_OBJ = $(CELT_SOURCES_ARM_NEON_INTR:.c=.lo) \ + $(SILK_SOURCES_ARM_NEON_INTR:.c=.lo) \ + $(SILK_SOURCES_FIXED_ARM_NEON_INTR:.c=.lo) +-$(ARM_NEON_INTR_OBJ) $(OPT_UNIT_TEST_OBJ): CFLAGS += \ ++$(ARM_NEON_INTR_OBJ): CFLAGS += \ + $(OPUS_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) + endif +diff --git a/celt/bands.c b/celt/bands.c +index 20d1fd5..d434818 100644 +--- a/celt/bands.c ++++ b/celt/bands.c +@@ -65,7 +65,7 @@ opus_uint32 celt_lcg_rand(opus_uint32 seed) + + /* This is a cos() approximation designed to be bit-exact on any platform. Bit exactness + with this approximation is important because it has an impact on the bit allocation */ +-static opus_int16 bitexact_cos(opus_int16 x) ++opus_int16 bitexact_cos(opus_int16 x) + { + opus_int32 tmp; + opus_int16 x2; +@@ -77,7 +77,7 @@ static opus_int16 bitexact_cos(opus_int16 x) + return 1+x2; + } + +-static int bitexact_log2tan(int isin,int icos) ++int bitexact_log2tan(int isin,int icos) + { + int lc; + int ls; +diff --git a/celt/bands.h b/celt/bands.h +index c040c7f..8cb9b6e 100644 +--- a/celt/bands.h ++++ b/celt/bands.h +@@ -36,6 +36,9 @@ + #include "entdec.h" + #include "rate.h" + ++opus_int16 bitexact_cos(opus_int16 x); ++int bitexact_log2tan(int isin,int icos); ++ + /** Compute the amplitude (sqrt energy) in each of the bands + * @param m Mode data + * @param X Spectrum +diff --git a/celt/tests/test_unit_dft.c b/celt/tests/test_unit_dft.c +index 6166eb0..29fa851 100644 +--- a/celt/tests/test_unit_dft.c ++++ b/celt/tests/test_unit_dft.c +@@ -29,38 +29,12 @@ + #include "config.h" + #endif + +-#define SKIP_CONFIG_H +- +-#ifndef CUSTOM_MODES +-#define CUSTOM_MODES +-#endif +- + #include + +-#define CELT_C +-#define TEST_UNIT_DFT_C + #include "stack_alloc.h" + #include "kiss_fft.h" +-#include "kiss_fft.c" +-#include "mathops.c" +-#include "entcode.c" +- +-#if defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# include "x86/x86cpu.c" +-#elif defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/armcpu.c" +-# include "celt_lpc.c" +-# include "pitch.c" +-# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/celt_neon_intr.c" +-# if defined(HAVE_ARM_NE10) +-# include "mdct.c" +-# include "arm/celt_ne10_fft.c" +-# include "arm/celt_ne10_mdct.c" +-# endif +-# endif +-# include "arm/arm_celt_map.c" +-#endif ++#include "mathops.h" ++#include "modes.h" + + #ifndef M_PI + #define M_PI 3.141592653 +@@ -115,8 +89,20 @@ void test1d(int nfft,int isinverse,int arch) + + kiss_fft_cpx * in = (kiss_fft_cpx*)malloc(buflen); + kiss_fft_cpx * out= (kiss_fft_cpx*)malloc(buflen); +- kiss_fft_state *cfg = opus_fft_alloc(nfft,0,0,arch); + int k; ++#ifdef CUSTOM_MODES ++ kiss_fft_state *cfg = opus_fft_alloc(nfft,0,0,arch); ++#else ++ int id; ++ const kiss_fft_state *cfg; ++ CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); ++ if (nfft == 480) id = 0; ++ else if (nfft == 240) id = 1; ++ else if (nfft == 120) id = 2; ++ else if (nfft == 60) id = 3; ++ else return; ++ cfg = mode->mdct.kfft[id]; ++#endif + + for (k=0;k + #include +-#include "mathops.c" +-#include "entenc.c" +-#include "entdec.c" +-#include "entcode.c" +-#include "bands.c" +-#include "quant_bands.c" +-#include "laplace.c" +-#include "vq.c" +-#include "cwrs.c" +-#include "pitch.c" +-#include "celt_lpc.c" +-#include "celt.c" +- +-#if defined(OPUS_X86_MAY_HAVE_SSE) || defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# if defined(OPUS_X86_MAY_HAVE_SSE) +-# include "x86/pitch_sse.c" +-# endif +-# if defined(OPUS_X86_MAY_HAVE_SSE2) +-# include "x86/pitch_sse2.c" +-# include "x86/vq_sse2.c" +-# endif +-# if defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# include "x86/pitch_sse4_1.c" +-# include "x86/celt_lpc_sse.c" +-# endif +-# include "x86/x86_celt_map.c" +-#elif defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/armcpu.c" +-# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/celt_neon_intr.c" +-# if defined(HAVE_ARM_NE10) +-# include "kiss_fft.c" +-# include "mdct.c" +-# include "arm/celt_ne10_fft.c" +-# include "arm/celt_ne10_mdct.c" +-# endif +-# endif +-# include "arm/arm_celt_map.c" +-#endif ++#include "mathops.h" ++#include "bands.h" + + #ifdef FIXED_POINT + #define WORD "%d" +diff --git a/celt/tests/test_unit_mdct.c b/celt/tests/test_unit_mdct.c +index 8dbb9ca..e3e487f 100644 +--- a/celt/tests/test_unit_mdct.c ++++ b/celt/tests/test_unit_mdct.c +@@ -29,38 +29,13 @@ + #include "config.h" + #endif + +-#define SKIP_CONFIG_H +- +-#ifndef CUSTOM_MODES +-#define CUSTOM_MODES +-#endif +- + #include + +-#define CELT_C + #include "mdct.h" + #include "stack_alloc.h" +- +-#include "kiss_fft.c" +-#include "mdct.c" +-#include "mathops.c" +-#include "entcode.c" +- +-#if defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# include "x86/x86cpu.c" +-#elif defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/armcpu.c" +-# include "pitch.c" +-# include "celt_lpc.c" +-# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/celt_neon_intr.c" +-# if defined(HAVE_ARM_NE10) +-# include "arm/celt_ne10_fft.c" +-# include "arm/celt_ne10_mdct.c" +-# endif +-# endif +-# include "arm/arm_celt_map.c" +-#endif ++#include "kiss_fft.h" ++#include "mdct.h" ++#include "modes.h" + + #ifndef M_PI + #define M_PI 3.141592653 +@@ -130,7 +105,6 @@ void check_inv(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinver + + void test1d(int nfft,int isinverse,int arch) + { +- mdct_lookup cfg; + size_t buflen = sizeof(kiss_fft_scalar)*nfft; + + kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen); +@@ -139,7 +113,23 @@ void test1d(int nfft,int isinverse,int arch) + opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); + int k; + +- clt_mdct_init(&cfg, nfft, 0, arch); ++#ifdef CUSTOM_MODES ++ int shift = 0; ++ const mdct_lookup *cfg; ++ mdct_lookup _cfg; ++ clt_mdct_init(&_cfg, nfft, 0, arch); ++ cfg = &_cfg; ++#else ++ int shift; ++ const mdct_lookup *cfg; ++ CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); ++ if (nfft == 1920) shift = 0; ++ else if (nfft == 960) shift = 1; ++ else if (nfft == 480) shift = 2; ++ else if (nfft == 240) shift = 3; ++ else return; ++ cfg = &mode->mdct; ++#endif + for (k=0;k + #include +-#include "vq.c" +-#include "cwrs.c" +-#include "entcode.c" +-#include "entenc.c" +-#include "entdec.c" +-#include "mathops.c" ++#include "vq.h" + #include "bands.h" +-#include "pitch.c" +-#include "celt_lpc.c" +-#include "celt.c" ++#include "stack_alloc.h" + #include + +-#if defined(OPUS_X86_MAY_HAVE_SSE) || defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# if defined(OPUS_X86_MAY_HAVE_SSE) +-# include "x86/pitch_sse.c" +-# endif +-# if defined(OPUS_X86_MAY_HAVE_SSE2) +-# include "x86/pitch_sse2.c" +-# include "x86/vq_sse2.c" +-# endif +-# if defined(OPUS_X86_MAY_HAVE_SSE4_1) +-# include "x86/pitch_sse4_1.c" +-# include "x86/celt_lpc_sse.c" +-# endif +-# include "x86/x86_celt_map.c" +-#elif defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/armcpu.c" +-# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +-# include "arm/celt_neon_intr.c" +-# if defined(HAVE_ARM_NE10) +-# include "kiss_fft.c" +-# include "mdct.c" +-# include "arm/celt_ne10_fft.c" +-# include "arm/celt_ne10_mdct.c" +-# endif +-# endif +-# include "arm/arm_celt_map.c" +-#endif + + #define MAX_SIZE 100 + +diff --git a/celt/vq.c b/celt/vq.c +index 9462e7f..8ef80e5 100644 +--- a/celt/vq.c ++++ b/celt/vq.c +@@ -67,7 +67,7 @@ static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_ + } + #endif /* OVERRIDE_vq_exp_rotation1 */ + +-static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) ++void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) + { + static const int SPREAD_FACTOR[3]={15,10,5}; + int i; +diff --git a/celt/vq.h b/celt/vq.h +index 5dbf9ce..0dfe6af 100644 +--- a/celt/vq.h ++++ b/celt/vq.h +@@ -45,6 +45,8 @@ + #include "mips/vq_mipsr1.h" + #endif + ++void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread); ++ + opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch); + + #if !defined(OVERRIDE_OP_PVQ_SEARCH) +-- +2.1.4 +