| OLD | NEW |
| 1 /* Copyright (c) 2008-2011 Xiph.Org Foundation | 1 /* Copyright (c) 2008-2011 Xiph.Org Foundation |
| 2 Written by Jean-Marc Valin */ | 2 Written by Jean-Marc Valin */ |
| 3 /* | 3 /* |
| 4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
| 5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
| 6 are met: | 6 are met: |
| 7 | 7 |
| 8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
| 9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #define SKIP_CONFIG_H | |
| 33 | |
| 34 #ifndef CUSTOM_MODES | |
| 35 #define CUSTOM_MODES | |
| 36 #endif | |
| 37 | |
| 38 #include <stdio.h> | 32 #include <stdio.h> |
| 39 | 33 |
| 40 #define CELT_C | |
| 41 #include "mdct.h" | 34 #include "mdct.h" |
| 42 #include "stack_alloc.h" | 35 #include "stack_alloc.h" |
| 43 | 36 #include "kiss_fft.h" |
| 44 #include "kiss_fft.c" | 37 #include "mdct.h" |
| 45 #include "mdct.c" | 38 #include "modes.h" |
| 46 #include "mathops.c" | |
| 47 #include "entcode.c" | |
| 48 | |
| 49 #if defined(OPUS_X86_MAY_HAVE_SSE2) || defined(OPUS_X86_MAY_HAVE_SSE4_1) | |
| 50 # include "x86/x86cpu.c" | |
| 51 #elif defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) | |
| 52 # include "arm/armcpu.c" | |
| 53 # include "pitch.c" | |
| 54 # include "celt_lpc.c" | |
| 55 # if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) | |
| 56 # include "arm/celt_neon_intr.c" | |
| 57 # if defined(HAVE_ARM_NE10) | |
| 58 # include "arm/celt_ne10_fft.c" | |
| 59 # include "arm/celt_ne10_mdct.c" | |
| 60 # endif | |
| 61 # endif | |
| 62 # include "arm/arm_celt_map.c" | |
| 63 #endif | |
| 64 | 39 |
| 65 #ifndef M_PI | 40 #ifndef M_PI |
| 66 #define M_PI 3.141592653 | 41 #define M_PI 3.141592653 |
| 67 #endif | 42 #endif |
| 68 | 43 |
| 69 int ret = 0; | 44 int ret = 0; |
| 70 void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse) | 45 void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse) |
| 71 { | 46 { |
| 72 int bin,k; | 47 int bin,k; |
| 73 double errpow=0,sigpow=0; | 48 double errpow=0,sigpow=0; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr ); | 98 printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr ); |
| 124 if (snr<60) { | 99 if (snr<60) { |
| 125 printf( "** poor snr: %f **\n", snr); | 100 printf( "** poor snr: %f **\n", snr); |
| 126 ret = 1; | 101 ret = 1; |
| 127 } | 102 } |
| 128 } | 103 } |
| 129 | 104 |
| 130 | 105 |
| 131 void test1d(int nfft,int isinverse,int arch) | 106 void test1d(int nfft,int isinverse,int arch) |
| 132 { | 107 { |
| 133 mdct_lookup cfg; | |
| 134 size_t buflen = sizeof(kiss_fft_scalar)*nfft; | 108 size_t buflen = sizeof(kiss_fft_scalar)*nfft; |
| 135 | 109 kiss_fft_scalar *in; |
| 136 kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen); | 110 kiss_fft_scalar *in_copy; |
| 137 kiss_fft_scalar * in_copy = (kiss_fft_scalar*)malloc(buflen); | 111 kiss_fft_scalar *out; |
| 138 kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen); | 112 opus_val16 *window; |
| 139 opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); | |
| 140 int k; | 113 int k; |
| 141 | 114 |
| 142 clt_mdct_init(&cfg, nfft, 0, arch); | 115 #ifdef CUSTOM_MODES |
| 116 int shift = 0; |
| 117 const mdct_lookup *cfg; |
| 118 mdct_lookup _cfg; |
| 119 clt_mdct_init(&_cfg, nfft, 0, arch); |
| 120 cfg = &_cfg; |
| 121 #else |
| 122 int shift; |
| 123 const mdct_lookup *cfg; |
| 124 CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); |
| 125 if (nfft == 1920) shift = 0; |
| 126 else if (nfft == 960) shift = 1; |
| 127 else if (nfft == 480) shift = 2; |
| 128 else if (nfft == 240) shift = 3; |
| 129 else return; |
| 130 cfg = &mode->mdct; |
| 131 #endif |
| 132 |
| 133 in = (kiss_fft_scalar*)malloc(buflen); |
| 134 in_copy = (kiss_fft_scalar*)malloc(buflen); |
| 135 out = (kiss_fft_scalar*)malloc(buflen); |
| 136 window = (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); |
| 137 |
| 143 for (k=0;k<nfft;++k) { | 138 for (k=0;k<nfft;++k) { |
| 144 in[k] = (rand() % 32768) - 16384; | 139 in[k] = (rand() % 32768) - 16384; |
| 145 } | 140 } |
| 146 | 141 |
| 147 for (k=0;k<nfft/2;++k) { | 142 for (k=0;k<nfft/2;++k) { |
| 148 window[k] = Q15ONE; | 143 window[k] = Q15ONE; |
| 149 } | 144 } |
| 150 for (k=0;k<nfft;++k) { | 145 for (k=0;k<nfft;++k) { |
| 151 in[k] *= 32768; | 146 in[k] *= 32768; |
| 152 } | 147 } |
| 153 | 148 |
| 154 if (isinverse) | 149 if (isinverse) |
| 155 { | 150 { |
| 156 for (k=0;k<nfft;++k) { | 151 for (k=0;k<nfft;++k) { |
| 157 in[k] /= nfft; | 152 in[k] /= nfft; |
| 158 } | 153 } |
| 159 } | 154 } |
| 160 | 155 |
| 161 for (k=0;k<nfft;++k) | 156 for (k=0;k<nfft;++k) |
| 162 in_copy[k] = in[k]; | 157 in_copy[k] = in[k]; |
| 163 /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/ | 158 /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/ |
| 164 | 159 |
| 165 if (isinverse) | 160 if (isinverse) |
| 166 { | 161 { |
| 167 for (k=0;k<nfft;++k) | 162 for (k=0;k<nfft;++k) |
| 168 out[k] = 0; | 163 out[k] = 0; |
| 169 clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1, arch); | 164 clt_mdct_backward(cfg,in,out, window, nfft/2, shift, 1, arch); |
| 170 /* apply TDAC because clt_mdct_backward() no longer does that */ | 165 /* apply TDAC because clt_mdct_backward() no longer does that */ |
| 171 for (k=0;k<nfft/4;++k) | 166 for (k=0;k<nfft/4;++k) |
| 172 out[nfft-k-1] = out[nfft/2+k]; | 167 out[nfft-k-1] = out[nfft/2+k]; |
| 173 check_inv(in,out,nfft,isinverse); | 168 check_inv(in,out,nfft,isinverse); |
| 174 } else { | 169 } else { |
| 175 clt_mdct_forward(&cfg,in,out,window, nfft/2, 0, 1, arch); | 170 clt_mdct_forward(cfg,in,out,window, nfft/2, shift, 1, arch); |
| 176 check(in_copy,out,nfft,isinverse); | 171 check(in_copy,out,nfft,isinverse); |
| 177 } | 172 } |
| 178 /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/ | 173 /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/ |
| 179 | 174 |
| 180 | 175 |
| 181 free(in); | 176 free(in); |
| 182 free(in_copy); | 177 free(in_copy); |
| 183 free(out); | 178 free(out); |
| 184 free(window); | 179 free(window); |
| 185 clt_mdct_clear(&cfg, arch); | 180 #ifdef CUSTOM_MODES |
| 181 clt_mdct_clear(&_cfg, arch); |
| 182 #endif |
| 186 } | 183 } |
| 187 | 184 |
| 188 int main(int argc,char ** argv) | 185 int main(int argc,char ** argv) |
| 189 { | 186 { |
| 190 ALLOC_STACK; | 187 ALLOC_STACK; |
| 191 int arch = opus_select_arch(); | 188 int arch = opus_select_arch(); |
| 192 | 189 |
| 193 if (argc>1) { | 190 if (argc>1) { |
| 194 int k; | 191 int k; |
| 195 for (k=1;k<argc;++k) { | 192 for (k=1;k<argc;++k) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 221 test1d(480,0,arch); | 218 test1d(480,0,arch); |
| 222 test1d(480,1,arch); | 219 test1d(480,1,arch); |
| 223 test1d(960,0,arch); | 220 test1d(960,0,arch); |
| 224 test1d(960,1,arch); | 221 test1d(960,1,arch); |
| 225 test1d(1920,0,arch); | 222 test1d(1920,0,arch); |
| 226 test1d(1920,1,arch); | 223 test1d(1920,1,arch); |
| 227 #endif | 224 #endif |
| 228 } | 225 } |
| 229 return ret; | 226 return ret; |
| 230 } | 227 } |
| OLD | NEW |