summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-25 16:28:53 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-25 16:45:56 -0400
commit3308f61f3f508f180da587a350a88ee6729cdee7 (patch)
tree8123d934a0419d9cf7967099ae6d0c70b9b02654
parentf17991727e94230af16ec8f11c9a3fb247794fba (diff)
downloadopus-exp_staging.tar.gz
fixing unit testsexp_staging
-rw-r--r--Makefile.am23
-rw-r--r--celt/bands.c4
-rw-r--r--celt/bands.h3
-rw-r--r--celt/tests/test_unit_dft.c46
-rw-r--r--celt/tests/test_unit_mathops.c43
-rw-r--r--celt/tests/test_unit_mdct.c58
-rw-r--r--celt/tests/test_unit_rotation.c37
-rw-r--r--celt/vq.c2
-rw-r--r--celt/vq.h2
9 files changed, 66 insertions, 152 deletions
diff --git a/Makefile.am b/Makefile.am
index 67453e4a..49422bae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -141,16 +141,17 @@ 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)
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 +163,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 +309,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 20d1fd5e..d4348182 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 c040c7f7..8cb9b6ea 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 6166eb0e..29fa851c 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 <stdio.h>
-#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<nfft;++k) {
in[k].r = (rand() % 32767) - 16384;
@@ -149,7 +135,9 @@ void test1d(int nfft,int isinverse,int arch)
free(in);
free(out);
+#ifdef CUSTOM_MODES
opus_fft_free(cfg, arch);
+#endif
}
int main(int argc,char ** argv)
diff --git a/celt/tests/test_unit_mathops.c b/celt/tests/test_unit_mathops.c
index d49a2bd2..874e9adf 100644
--- a/celt/tests/test_unit_mathops.c
+++ b/celt/tests/test_unit_mathops.c
@@ -34,49 +34,10 @@
#define CUSTOM_MODES
#endif
-#define CELT_C
-
#include <stdio.h>
#include <math.h>
-#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 8dbb9caa..e3e487ff 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 <stdio.h>
-#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<nfft;++k) {
in[k] = (rand() % 32768) - 16384;
}
@@ -166,13 +156,13 @@ void test1d(int nfft,int isinverse,int arch)
{
for (k=0;k<nfft;++k)
out[k] = 0;
- clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1, arch);
+ clt_mdct_backward(cfg,in,out, window, nfft/2, shift, 1, arch);
/* apply TDAC because clt_mdct_backward() no longer does that */
for (k=0;k<nfft/4;++k)
out[nfft-k-1] = out[nfft/2+k];
check_inv(in,out,nfft,isinverse);
} else {
- clt_mdct_forward(&cfg,in,out,window, nfft/2, 0, 1, arch);
+ clt_mdct_forward(cfg,in,out,window, nfft/2, shift, 1, arch);
check(in_copy,out,nfft,isinverse);
}
/*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
@@ -182,7 +172,9 @@ void test1d(int nfft,int isinverse,int arch)
free(in_copy);
free(out);
free(window);
- clt_mdct_clear(&cfg, arch);
+#ifdef CUSTOM_MODES
+ clt_mdct_clear(&_cfg, arch);
+#endif
}
int main(int argc,char ** argv)
diff --git a/celt/tests/test_unit_rotation.c b/celt/tests/test_unit_rotation.c
index 571ed12d..267b9830 100644
--- a/celt/tests/test_unit_rotation.c
+++ b/celt/tests/test_unit_rotation.c
@@ -37,44 +37,11 @@
#include <stdio.h>
#include <stdlib.h>
-#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 <math.h>
-#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 9462e7fa..8ef80e50 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 5dbf9ce0..0dfe6af0 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)