ref: 4507637ccca66d1520e806bbbb69396e4511679c
parent: 6cdd84a3c877e5d0f68ee0d047fadfa737c0efd9
author: Jean-Marc Valin <[email protected]>
date: Thu May 25 12:28:53 EDT 2017
Fixes unit tests that need arch-specific code We now include the object files for those rather than attempt to problems.
--- a/Makefile.am
+++ b/Makefile.am
@@ -141,16 +141,20 @@
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_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,12 +312,12 @@
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
@@ -320,7 +324,7 @@
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
@@ -327,6 +331,6 @@
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
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -65,7 +65,7 @@
/* 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 @@
return 1+x2;
}
-static int bitexact_log2tan(int isin,int icos)
+int bitexact_log2tan(int isin,int icos)
{
int lc;
int ls;
--- 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
--- a/celt/tests/test_unit_dft.c
+++ b/celt/tests/test_unit_dft.c
@@ -29,39 +29,13 @@
#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"
+#include "mathops.h"
+#include "modes.h"
-#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
-
#ifndef M_PI
#define M_PI 3.141592653
#endif
@@ -115,8 +89,20 @@
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 @@
free(in);
free(out);
+#ifdef CUSTOM_MODES
opus_fft_free(cfg, arch);
+#endif
}
int main(int argc,char ** argv)
--- 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"
--- a/celt/tests/test_unit_mdct.c
+++ b/celt/tests/test_unit_mdct.c
@@ -29,39 +29,14 @@
#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.h"
+#include "mdct.h"
+#include "modes.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
-
#ifndef M_PI
#define M_PI 3.141592653
#endif
@@ -130,7 +105,6 @@
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 @@
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 @@
{
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 @@
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)
--- 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
--- a/celt/vq.c
+++ b/celt/vq.c
@@ -67,7 +67,7 @@
}
#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;
--- 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)