summaryrefslogtreecommitdiff
path: root/drivers/opus/celt/tests
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2016-05-01 12:48:46 -0300
committerGeorge Marques <george@gmarqu.es>2016-05-02 13:18:34 -0300
commit7c59d819a7ebb936d51ca032e66a2489e4080d08 (patch)
treedf6747620113a36812194db3456729aac2fa1b08 /drivers/opus/celt/tests
parenta3d81cab8a97eeece54ebadb82c40532188b4d57 (diff)
Update Opus driver to 1.1.2
And opusfile to 0.7.
Diffstat (limited to 'drivers/opus/celt/tests')
-rw-r--r--drivers/opus/celt/tests/test_unit_cwrs32.c161
-rw-r--r--drivers/opus/celt/tests/test_unit_dft.c164
-rw-r--r--drivers/opus/celt/tests/test_unit_entropy.c382
-rw-r--r--drivers/opus/celt/tests/test_unit_laplace.c92
-rw-r--r--drivers/opus/celt/tests/test_unit_mathops.c275
-rw-r--r--drivers/opus/celt/tests/test_unit_mdct.c210
-rw-r--r--drivers/opus/celt/tests/test_unit_rotation.c90
-rw-r--r--drivers/opus/celt/tests/test_unit_types.c50
8 files changed, 0 insertions, 1424 deletions
diff --git a/drivers/opus/celt/tests/test_unit_cwrs32.c b/drivers/opus/celt/tests/test_unit_cwrs32.c
deleted file mode 100644
index db43e3392b..0000000000
--- a/drivers/opus/celt/tests/test_unit_cwrs32.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation,
- Gregory Maxwell
- Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifndef CUSTOM_MODES
-#define CUSTOM_MODES
-#else
-#define TEST_CUSTOM_MODES
-#endif
-
-#define CELT_C
-#include "opus/celt/stack_alloc.h"
-#include "opus/celt/entenc.c"
-#include "opus/celt/entdec.c"
-#include "opus/celt/entcode.c"
-#include "opus/celt/cwrs.c"
-#include "opus/celt/mathops.c"
-#include "opus/celt/rate.h"
-
-#define NMAX (240)
-#define KMAX (128)
-
-#ifdef TEST_CUSTOM_MODES
-
-#define NDIMS (44)
-static const int pn[NDIMS]={
- 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 18, 20, 22,
- 24, 26, 28, 30, 32, 36, 40, 44, 48,
- 52, 56, 60, 64, 72, 80, 88, 96, 104,
- 112, 120, 128, 144, 160, 176, 192, 208
-};
-static const int pkmax[NDIMS]={
- 128, 128, 128, 128, 88, 52, 36, 26, 22,
- 18, 16, 15, 13, 12, 12, 11, 10, 9,
- 9, 8, 8, 7, 7, 7, 7, 6, 6,
- 6, 6, 6, 5, 5, 5, 5, 5, 5,
- 4, 4, 4, 4, 4, 4, 4, 4
-};
-
-#else /* TEST_CUSTOM_MODES */
-
-#define NDIMS (22)
-static const int pn[NDIMS]={
- 2, 3, 4, 6, 8, 9, 11, 12, 16,
- 18, 22, 24, 32, 36, 44, 48, 64, 72,
- 88, 96, 144, 176
-};
-static const int pkmax[NDIMS]={
- 128, 128, 128, 88, 36, 26, 18, 16, 12,
- 11, 9, 9, 7, 7, 6, 6, 5, 5,
- 5, 5, 4, 4
-};
-
-#endif
-
-int main(void){
- int t;
- int n;
- ALLOC_STACK;
- for(t=0;t<NDIMS;t++){
- int pseudo;
- n=pn[t];
- for(pseudo=1;pseudo<41;pseudo++)
- {
- int k;
-#if defined(SMALL_FOOTPRINT)
- opus_uint32 uu[KMAX+2U];
-#endif
- opus_uint32 inc;
- opus_uint32 nc;
- opus_uint32 i;
- k=get_pulses(pseudo);
- if (k>pkmax[t])break;
- printf("Testing CWRS with N=%i, K=%i...\n",n,k);
-#if defined(SMALL_FOOTPRINT)
- nc=ncwrs_urow(n,k,uu);
-#else
- nc=CELT_PVQ_V(n,k);
-#endif
- inc=nc/20000;
- if(inc<1)inc=1;
- for(i=0;i<nc;i+=inc){
-#if defined(SMALL_FOOTPRINT)
- opus_uint32 u[KMAX+2U];
-#endif
- int y[NMAX];
- int sy;
- opus_uint32 v;
- opus_uint32 ii;
- int j;
-#if defined(SMALL_FOOTPRINT)
- memcpy(u,uu,(k+2U)*sizeof(*u));
- cwrsi(n,k,i,y,u);
-#else
- cwrsi(n,k,i,y);
-#endif
- sy=0;
- for(j=0;j<n;j++)sy+=ABS(y[j]);
- if(sy!=k){
- fprintf(stderr,"N=%d Pulse count mismatch in cwrsi (%d!=%d).\n",
- n,sy,k);
- return 99;
- }
- /*printf("%6u of %u:",i,nc);
- for(j=0;j<n;j++)printf(" %+3i",y[j]);
- printf(" ->");*/
-#if defined(SMALL_FOOTPRINT)
- ii=icwrs(n,k,&v,y,u);
-#else
- ii=icwrs(n,y);
- v=CELT_PVQ_V(n,k);
-#endif
- if(ii!=i){
- fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n",
- (long)ii,(long)i);
- return 1;
- }
- if(v!=nc){
- fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n",
- (long)v,(long)nc);
- return 2;
- }
- /*printf(" %6u\n",i);*/
- }
- /*printf("\n");*/
- }
- }
- return 0;
-}
diff --git a/drivers/opus/celt/tests/test_unit_dft.c b/drivers/opus/celt/tests/test_unit_dft.c
deleted file mode 100644
index 9c0db3e9ac..0000000000
--- a/drivers/opus/celt/tests/test_unit_dft.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Copyright (c) 2008 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#define SKIP_CONFIG_H
-
-#ifndef CUSTOM_MODES
-#define CUSTOM_MODES
-#endif
-
-#include <stdio.h>
-
-#define CELT_C
-#include "opus/celt/stack_alloc.h"
-#include "opus/celt/kiss_fft.h"
-#include "opus/celt/kiss_fft.c"
-#include "opus/celt/mathops.c"
-#include "opus/celt/entcode.c"
-
-
-#ifndef M_PI
-#define M_PI 3.141592653
-#endif
-
-int ret = 0;
-
-void check(kiss_fft_cpx * in,kiss_fft_cpx * out,int nfft,int isinverse)
-{
- int bin,k;
- double errpow=0,sigpow=0, snr;
-
- for (bin=0;bin<nfft;++bin) {
- double ansr = 0;
- double ansi = 0;
- double difr;
- double difi;
-
- for (k=0;k<nfft;++k) {
- double phase = -2*M_PI*bin*k/nfft;
- double re = cos(phase);
- double im = sin(phase);
- if (isinverse)
- im = -im;
-
- if (!isinverse)
- {
- re /= nfft;
- im /= nfft;
- }
-
- ansr += in[k].r * re - in[k].i * im;
- ansi += in[k].r * im + in[k].i * re;
- }
- /*printf ("%d %d ", (int)ansr, (int)ansi);*/
- difr = ansr - out[bin].r;
- difi = ansi - out[bin].i;
- errpow += difr*difr + difi*difi;
- sigpow += ansr*ansr+ansi*ansi;
- }
- snr = 10*log10(sigpow/errpow);
- printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr );
- if (snr<60) {
- printf( "** poor snr: %f ** \n", snr);
- ret = 1;
- }
-}
-
-void test1d(int nfft,int isinverse)
-{
- size_t buflen = sizeof(kiss_fft_cpx)*nfft;
-
- 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);
- int k;
-
- for (k=0;k<nfft;++k) {
- in[k].r = (rand() % 32767) - 16384;
- in[k].i = (rand() % 32767) - 16384;
- }
-
- for (k=0;k<nfft;++k) {
- in[k].r *= 32768;
- in[k].i *= 32768;
- }
-
- if (isinverse)
- {
- for (k=0;k<nfft;++k) {
- in[k].r /= nfft;
- in[k].i /= nfft;
- }
- }
-
- /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/
-
- if (isinverse)
- opus_ifft(cfg,in,out);
- else
- opus_fft(cfg,in,out);
-
- /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
-
- check(in,out,nfft,isinverse);
-
- free(in);
- free(out);
- free(cfg);
-}
-
-int main(int argc,char ** argv)
-{
- ALLOC_STACK;
- if (argc>1) {
- int k;
- for (k=1;k<argc;++k) {
- test1d(atoi(argv[k]),0);
- test1d(atoi(argv[k]),1);
- }
- }else{
- test1d(32,0);
- test1d(32,1);
- test1d(128,0);
- test1d(128,1);
- test1d(256,0);
- test1d(256,1);
-#ifndef RADIX_TWO_ONLY
- test1d(36,0);
- test1d(36,1);
- test1d(50,0);
- test1d(50,1);
- test1d(120,0);
- test1d(120,1);
-#endif
- }
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_entropy.c b/drivers/opus/celt/tests/test_unit_entropy.c
deleted file mode 100644
index 8c2defa8b3..0000000000
--- a/drivers/opus/celt/tests/test_unit_entropy.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/* Copyright (c) 2007-2011 Xiph.Org Foundation, Mozilla Corporation,
- Gregory Maxwell
- Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <time.h>
-#include "opus/celt/entcode.h"
-#include "opus/celt/entenc.h"
-#include "opus/celt/entdec.h"
-#include <string.h>
-
-#include "opus/celt/entenc.c"
-#include "opus/celt/entdec.c"
-#include "opus/celt/entcode.c"
-
-#ifndef M_LOG2E
-# define M_LOG2E 1.4426950408889634074
-#endif
-#define DATA_SIZE 10000000
-#define DATA_SIZE2 10000
-
-int main(int _argc,char **_argv){
- ec_enc enc;
- ec_dec dec;
- long nbits;
- long nbits2;
- double entropy;
- int ft;
- int ftb;
- int sz;
- int i;
- int ret;
- unsigned int sym;
- unsigned int seed;
- unsigned char *ptr;
- const char *env_seed;
- ret=0;
- entropy=0;
- if (_argc > 2) {
- fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]);
- return 1;
- }
- env_seed = getenv("SEED");
- if (_argc > 1)
- seed = atoi(_argv[1]);
- else if (env_seed)
- seed = atoi(env_seed);
- else
- seed = time(NULL);
- /*Testing encoding of raw bit values.*/
- ptr = (unsigned char *)malloc(DATA_SIZE);
- ec_enc_init(&enc,ptr, DATA_SIZE);
- for(ft=2;ft<1024;ft++){
- for(i=0;i<ft;i++){
- entropy+=log(ft)*M_LOG2E;
- ec_enc_uint(&enc,i,ft);
- }
- }
- /*Testing encoding of raw bit values.*/
- for(ftb=1;ftb<16;ftb++){
- for(i=0;i<(1<<ftb);i++){
- entropy+=ftb;
- nbits=ec_tell(&enc);
- ec_enc_bits(&enc,i,ftb);
- nbits2=ec_tell(&enc);
- if(nbits2-nbits!=ftb){
- fprintf(stderr,"Used %li bits to encode %i bits directly.\n",
- nbits2-nbits,ftb);
- ret=-1;
- }
- }
- }
- nbits=ec_tell_frac(&enc);
- ec_enc_done(&enc);
- fprintf(stderr,
- "Encoded %0.2lf bits of entropy to %0.2lf bits (%0.3lf%% wasted).\n",
- entropy,ldexp(nbits,-3),100*(nbits-ldexp(entropy,3))/nbits);
- fprintf(stderr,"Packed to %li bytes.\n",(long)ec_range_bytes(&enc));
- ec_dec_init(&dec,ptr,DATA_SIZE);
- for(ft=2;ft<1024;ft++){
- for(i=0;i<ft;i++){
- sym=ec_dec_uint(&dec,ft);
- if(sym!=(unsigned)i){
- fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
- ret=-1;
- }
- }
- }
- for(ftb=1;ftb<16;ftb++){
- for(i=0;i<(1<<ftb);i++){
- sym=ec_dec_bits(&dec,ftb);
- if(sym!=(unsigned)i){
- fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
- ret=-1;
- }
- }
- }
- nbits2=ec_tell_frac(&dec);
- if(nbits!=nbits2){
- fprintf(stderr,
- "Reported number of bits used was %0.2lf, should be %0.2lf.\n",
- ldexp(nbits2,-3),ldexp(nbits,-3));
- ret=-1;
- }
- /*Testing an encoder bust prefers range coder data over raw bits.
- This isn't a general guarantee, will only work for data that is buffered in
- the encoder state and not yet stored in the user buffer, and should never
- get used in practice.
- It's mostly here for code coverage completeness.*/
- /*Start with a 16-bit buffer.*/
- ec_enc_init(&enc,ptr,2);
- /*Write 7 raw bits.*/
- ec_enc_bits(&enc,0x55,7);
- /*Write 12.3 bits of range coder data.*/
- ec_enc_uint(&enc,1,2);
- ec_enc_uint(&enc,1,3);
- ec_enc_uint(&enc,1,4);
- ec_enc_uint(&enc,1,5);
- ec_enc_uint(&enc,2,6);
- ec_enc_uint(&enc,6,7);
- ec_enc_done(&enc);
- ec_dec_init(&dec,ptr,2);
- if(!enc.error
- /*The raw bits should have been overwritten by the range coder data.*/
- ||ec_dec_bits(&dec,7)!=0x05
- /*And all the range coder data should have been encoded correctly.*/
- ||ec_dec_uint(&dec,2)!=1
- ||ec_dec_uint(&dec,3)!=1
- ||ec_dec_uint(&dec,4)!=1
- ||ec_dec_uint(&dec,5)!=1
- ||ec_dec_uint(&dec,6)!=2
- ||ec_dec_uint(&dec,7)!=6){
- fprintf(stderr,"Encoder bust overwrote range coder data with raw bits.\n");
- ret=-1;
- }
- srand(seed);
- fprintf(stderr,"Testing random streams... Random seed: %u (%.4X)\n", seed, rand() % 65536);
- for(i=0;i<409600;i++){
- unsigned *data;
- unsigned *tell;
- unsigned tell_bits;
- int j;
- int zeros;
- ft=rand()/((RAND_MAX>>(rand()%11U))+1U)+10;
- sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
- data=(unsigned *)malloc(sz*sizeof(*data));
- tell=(unsigned *)malloc((sz+1)*sizeof(*tell));
- ec_enc_init(&enc,ptr,DATA_SIZE2);
- zeros = rand()%13==0;
- tell[0]=ec_tell_frac(&enc);
- for(j=0;j<sz;j++){
- if (zeros)
- data[j]=0;
- else
- data[j]=rand()%ft;
- ec_enc_uint(&enc,data[j],ft);
- tell[j+1]=ec_tell_frac(&enc);
- }
- if (rand()%2==0)
- while(ec_tell(&enc)%8 != 0)
- ec_enc_uint(&enc, rand()%2, 2);
- tell_bits = ec_tell(&enc);
- ec_enc_done(&enc);
- if(tell_bits!=(unsigned)ec_tell(&enc)){
- fprintf(stderr,"ec_tell() changed after ec_enc_done(): %i instead of %i (Random seed: %u)\n",
- ec_tell(&enc),tell_bits,seed);
- ret=-1;
- }
- if ((tell_bits+7)/8 < ec_range_bytes(&enc))
- {
- fprintf (stderr, "ec_tell() lied, there's %i bytes instead of %d (Random seed: %u)\n",
- ec_range_bytes(&enc), (tell_bits+7)/8,seed);
- ret=-1;
- }
- ec_dec_init(&dec,ptr,DATA_SIZE2);
- if(ec_tell_frac(&dec)!=tell[0]){
- fprintf(stderr,
- "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n",
- 0,ec_tell_frac(&dec),tell[0],seed);
- }
- for(j=0;j<sz;j++){
- sym=ec_dec_uint(&dec,ft);
- if(sym!=data[j]){
- fprintf(stderr,
- "Decoded %i instead of %i with ft of %i at position %i of %i (Random seed: %u).\n",
- sym,data[j],ft,j,sz,seed);
- ret=-1;
- }
- if(ec_tell_frac(&dec)!=tell[j+1]){
- fprintf(stderr,
- "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n",
- j+1,ec_tell_frac(&dec),tell[j+1],seed);
- }
- }
- free(tell);
- free(data);
- }
- /*Test compatibility between multiple different encode/decode routines.*/
- for(i=0;i<409600;i++){
- unsigned *logp1;
- unsigned *data;
- unsigned *tell;
- unsigned *enc_method;
- int j;
- sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
- logp1=(unsigned *)malloc(sz*sizeof(*logp1));
- data=(unsigned *)malloc(sz*sizeof(*data));
- tell=(unsigned *)malloc((sz+1)*sizeof(*tell));
- enc_method=(unsigned *)malloc(sz*sizeof(*enc_method));
- ec_enc_init(&enc,ptr,DATA_SIZE2);
- tell[0]=ec_tell_frac(&enc);
- for(j=0;j<sz;j++){
- data[j]=rand()/((RAND_MAX>>1)+1);
- logp1[j]=(rand()%15)+1;
- enc_method[j]=rand()/((RAND_MAX>>2)+1);
- switch(enc_method[j]){
- case 0:{
- ec_encode(&enc,data[j]?(1<<logp1[j])-1:0,
- (1<<logp1[j])-(data[j]?0:1),1<<logp1[j]);
- }break;
- case 1:{
- ec_encode_bin(&enc,data[j]?(1<<logp1[j])-1:0,
- (1<<logp1[j])-(data[j]?0:1),logp1[j]);
- }break;
- case 2:{
- ec_enc_bit_logp(&enc,data[j],logp1[j]);
- }break;
- case 3:{
- unsigned char icdf[2];
- icdf[0]=1;
- icdf[1]=0;
- ec_enc_icdf(&enc,data[j],icdf,logp1[j]);
- }break;
- }
- tell[j+1]=ec_tell_frac(&enc);
- }
- ec_enc_done(&enc);
- if((ec_tell(&enc)+7U)/8U<ec_range_bytes(&enc)){
- fprintf(stderr,"tell() lied, there's %i bytes instead of %d (Random seed: %u)\n",
- ec_range_bytes(&enc),(ec_tell(&enc)+7)/8,seed);
- ret=-1;
- }
- ec_dec_init(&dec,ptr,DATA_SIZE2);
- if(ec_tell_frac(&dec)!=tell[0]){
- fprintf(stderr,
- "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n",
- 0,ec_tell_frac(&dec),tell[0],seed);
- }
- for(j=0;j<sz;j++){
- int fs;
- int dec_method;
- dec_method=rand()/((RAND_MAX>>2)+1);
- switch(dec_method){
- case 0:{
- fs=ec_decode(&dec,1<<logp1[j]);
- sym=fs>=(1<<logp1[j])-1;
- ec_dec_update(&dec,sym?(1<<logp1[j])-1:0,
- (1<<logp1[j])-(sym?0:1),1<<logp1[j]);
- }break;
- case 1:{
- fs=ec_decode_bin(&dec,logp1[j]);
- sym=fs>=(1<<logp1[j])-1;
- ec_dec_update(&dec,sym?(1<<logp1[j])-1:0,
- (1<<logp1[j])-(sym?0:1),1<<logp1[j]);
- }break;
- case 2:{
- sym=ec_dec_bit_logp(&dec,logp1[j]);
- }break;
- case 3:{
- unsigned char icdf[2];
- icdf[0]=1;
- icdf[1]=0;
- sym=ec_dec_icdf(&dec,icdf,logp1[j]);
- }break;
- }
- if(sym!=data[j]){
- fprintf(stderr,
- "Decoded %i instead of %i with logp1 of %i at position %i of %i (Random seed: %u).\n",
- sym,data[j],logp1[j],j,sz,seed);
- fprintf(stderr,"Encoding method: %i, decoding method: %i\n",
- enc_method[j],dec_method);
- ret=-1;
- }
- if(ec_tell_frac(&dec)!=tell[j+1]){
- fprintf(stderr,
- "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n",
- j+1,ec_tell_frac(&dec),tell[j+1],seed);
- }
- }
- free(enc_method);
- free(tell);
- free(data);
- free(logp1);
- }
- ec_enc_init(&enc,ptr,DATA_SIZE2);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,0,2);
- ec_enc_patch_initial_bits(&enc,3,2);
- if(enc.error){
- fprintf(stderr,"patch_initial_bits failed");
- ret=-1;
- }
- ec_enc_patch_initial_bits(&enc,0,5);
- if(!enc.error){
- fprintf(stderr,"patch_initial_bits didn't fail when it should have");
- ret=-1;
- }
- ec_enc_done(&enc);
- if(ec_range_bytes(&enc)!=1||ptr[0]!=192){
- fprintf(stderr,"Got %d when expecting 192 for patch_initial_bits",ptr[0]);
- ret=-1;
- }
- ec_enc_init(&enc,ptr,DATA_SIZE2);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,0,1);
- ec_enc_bit_logp(&enc,1,6);
- ec_enc_bit_logp(&enc,0,2);
- ec_enc_patch_initial_bits(&enc,0,2);
- if(enc.error){
- fprintf(stderr,"patch_initial_bits failed");
- ret=-1;
- }
- ec_enc_done(&enc);
- if(ec_range_bytes(&enc)!=2||ptr[0]!=63){
- fprintf(stderr,"Got %d when expecting 63 for patch_initial_bits",ptr[0]);
- ret=-1;
- }
- ec_enc_init(&enc,ptr,2);
- ec_enc_bit_logp(&enc,0,2);
- for(i=0;i<48;i++){
- ec_enc_bits(&enc,0,1);
- }
- ec_enc_done(&enc);
- if(!enc.error){
- fprintf(stderr,"Raw bits overfill didn't fail when it should have");
- ret=-1;
- }
- ec_enc_init(&enc,ptr,2);
- for(i=0;i<17;i++){
- ec_enc_bits(&enc,0,1);
- }
- ec_enc_done(&enc);
- if(!enc.error){
- fprintf(stderr,"17 raw bits encoded in two bytes");
- ret=-1;
- }
- free(ptr);
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_laplace.c b/drivers/opus/celt/tests/test_unit_laplace.c
deleted file mode 100644
index e4fe83c4d6..0000000000
--- a/drivers/opus/celt/tests/test_unit_laplace.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation
- Written by Jean-Marc Valin and Timothy B. Terriberry */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "opus/celt/laplace.h"
-#define CELT_C
-#include "opus/celt/stack_alloc.h"
-
-#include "opus/celt/entenc.c"
-#include "opus/celt/entdec.c"
-#include "opus/celt/entcode.c"
-#include "opus/celt/laplace.c"
-
-#define DATA_SIZE 40000
-
-int ec_laplace_get_start_freq(int decay)
-{
- opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1);
- int fs = (ft*(16384-decay))/(16384+decay);
- return fs+LAPLACE_MINP;
-}
-
-int main(void)
-{
- int i;
- int ret = 0;
- ec_enc enc;
- ec_dec dec;
- unsigned char *ptr;
- int val[10000], decay[10000];
- ALLOC_STACK;
- ptr = (unsigned char *)malloc(DATA_SIZE);
- ec_enc_init(&enc,ptr,DATA_SIZE);
-
- val[0] = 3; decay[0] = 6000;
- val[1] = 0; decay[1] = 5800;
- val[2] = -1; decay[2] = 5600;
- for (i=3;i<10000;i++)
- {
- val[i] = rand()%15-7;
- decay[i] = rand()%11000+5000;
- }
- for (i=0;i<10000;i++)
- ec_laplace_encode(&enc, &val[i],
- ec_laplace_get_start_freq(decay[i]), decay[i]);
-
- ec_enc_done(&enc);
-
- ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc));
-
- for (i=0;i<10000;i++)
- {
- int d = ec_laplace_decode(&dec,
- ec_laplace_get_start_freq(decay[i]), decay[i]);
- if (d != val[i])
- {
- fprintf (stderr, "Got %d instead of %d\n", d, val[i]);
- ret = 1;
- }
- }
-
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_mathops.c b/drivers/opus/celt/tests/test_unit_mathops.c
deleted file mode 100644
index 0e3f300d40..0000000000
--- a/drivers/opus/celt/tests/test_unit_mathops.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation,
- Gregory Maxwell
- Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#ifndef CUSTOM_MODES
-#define CUSTOM_MODES
-#endif
-
-#define CELT_C
-
-#include "opus/celt/mathops.c"
-#include "opus/celt/entenc.c"
-#include "opus/celt/entdec.c"
-#include "opus/celt/entcode.c"
-#include "opus/celt/bands.c"
-#include "opus/celt/quant_bands.c"
-#include "opus/celt/laplace.c"
-#include "opus/celt/vq.c"
-#include "opus/celt/cwrs.c"
-#include <stdio.h>
-#include <math.h>
-
-#ifdef OPUS_FIXED_POINT
-#define WORD "%d"
-#else
-#define WORD "%f"
-#endif
-
-int ret = 0;
-
-void testdiv(void)
-{
- opus_int32 i;
- for (i=1;i<=327670;i++)
- {
- double prod;
- opus_val32 val;
- val = celt_rcp(i);
-#ifdef OPUS_FIXED_POINT
- prod = (1./32768./65526.)*val*i;
-#else
- prod = val*i;
-#endif
- if (fabs(prod-1) > .00025)
- {
- fprintf (stderr, "div failed: 1/%d="WORD" (product = %f)\n", i, val, prod);
- ret = 1;
- }
- }
-}
-
-void testsqrt(void)
-{
- opus_int32 i;
- for (i=1;i<=1000000000;i++)
- {
- double ratio;
- opus_val16 val;
- val = celt_sqrt(i);
- ratio = val/sqrt(i);
- if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2)
- {
- fprintf (stderr, "sqrt failed: sqrt(%d)="WORD" (ratio = %f)\n", i, val, ratio);
- ret = 1;
- }
- i+= i>>10;
- }
-}
-
-void testbitexactcos(void)
-{
- int i;
- opus_int32 min_d,max_d,last,chk;
- chk=max_d=0;
- last=min_d=32767;
- for(i=64;i<=16320;i++)
- {
- opus_int32 d;
- opus_int32 q=bitexact_cos(i);
- chk ^= q*i;
- d = last - q;
- if (d>max_d)max_d=d;
- if (d<min_d)min_d=d;
- last = q;
- }
- if ((chk!=89408644)||(max_d!=5)||(min_d!=0)||(bitexact_cos(64)!=32767)||
- (bitexact_cos(16320)!=200)||(bitexact_cos(8192)!=23171))
- {
- fprintf (stderr, "bitexact_cos failed\n");
- ret = 1;
- }
-}
-
-void testbitexactlog2tan(void)
-{
- int i,fail;
- opus_int32 min_d,max_d,last,chk;
- fail=chk=max_d=0;
- last=min_d=15059;
- for(i=64;i<8193;i++)
- {
- opus_int32 d;
- opus_int32 mid=bitexact_cos(i);
- opus_int32 side=bitexact_cos(16384-i);
- opus_int32 q=bitexact_log2tan(mid,side);
- chk ^= q*i;
- d = last - q;
- if (q!=-1*bitexact_log2tan(side,mid))
- fail = 1;
- if (d>max_d)max_d=d;
- if (d<min_d)min_d=d;
- last = q;
- }
- if ((chk!=15821257)||(max_d!=61)||(min_d!=-2)||fail||
- (bitexact_log2tan(32767,200)!=15059)||(bitexact_log2tan(30274,12540)!=2611)||
- (bitexact_log2tan(23171,23171)!=0))
- {
- fprintf (stderr, "bitexact_log2tan failed\n");
- ret = 1;
- }
-}
-
-#ifndef OPUS_FIXED_POINT
-void testlog2(void)
-{
- float x;
- for (x=0.001;x<1677700.0;x+=(x/8.0))
- {
- float error = fabs((1.442695040888963387*log(x))-celt_log2(x));
- if (error>0.0009)
- {
- fprintf (stderr, "celt_log2 failed: fabs((1.442695040888963387*log(x))-celt_log2(x))>0.001 (x = %f, error = %f)\n", x,error);
- ret = 1;
- }
- }
-}
-
-void testexp2(void)
-{
- float x;
- for (x=-11.0;x<24.0;x+=0.0007)
- {
- float error = fabs(x-(1.442695040888963387*log(celt_exp2(x))));
- if (error>0.0002)
- {
- fprintf (stderr, "celt_exp2 failed: fabs(x-(1.442695040888963387*log(celt_exp2(x))))>0.0005 (x = %f, error = %f)\n", x,error);
- ret = 1;
- }
- }
-}
-
-void testexp2log2(void)
-{
- float x;
- for (x=-11.0;x<24.0;x+=0.0007)
- {
- float error = fabs(x-(celt_log2(celt_exp2(x))));
- if (error>0.001)
- {
- fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_log2(celt_exp2(x))))>0.001 (x = %f, error = %f)\n", x,error);
- ret = 1;
- }
- }
-}
-#else
-void testlog2(void)
-{
- opus_val32 x;
- for (x=8;x<1073741824;x+=(x>>3))
- {
- float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0);
- if (error>0.003)
- {
- fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error);
- ret = 1;
- }
- }
-}
-
-void testexp2(void)
-{
- opus_val16 x;
- for (x=-32768;x<15360;x++)
- {
- float error1 = fabs(x/1024.0-(1.442695040888963387*log(celt_exp2(x)/65536.0)));
- float error2 = fabs(exp(0.6931471805599453094*x/1024.0)-celt_exp2(x)/65536.0);
- if (error1>0.0002&&error2>0.00004)
- {
- fprintf (stderr, "celt_exp2 failed: x = "WORD", error1 = %f, error2 = %f\n", x,error1,error2);
- ret = 1;
- }
- }
-}
-
-void testexp2log2(void)
-{
- opus_val32 x;
- for (x=8;x<65536;x+=(x>>3))
- {
- float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384;
- if (error>0.004)
- {
- fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error);
- ret = 1;
- }
- }
-}
-
-void testilog2(void)
-{
- opus_val32 x;
- for (x=1;x<=268435455;x+=127)
- {
- opus_val32 lg;
- opus_val32 y;
-
- lg = celt_ilog2(x);
- if (lg<0 || lg>=31)
- {
- printf("celt_ilog2 failed: 0<=celt_ilog2(x)<31 (x = %d, celt_ilog2(x) = %d)\n",x,lg);
- ret = 1;
- }
- y = 1<<lg;
-
- if (x<y || (x>>1)>=y)
- {
- printf("celt_ilog2 failed: 2**celt_ilog2(x)<=x<2**(celt_ilog2(x)+1) (x = %d, 2**celt_ilog2(x) = %d)\n",x,y);
- ret = 1;
- }
- }
-}
-#endif
-
-int main(void)
-{
- testbitexactcos();
- testbitexactlog2tan();
- testdiv();
- testsqrt();
- testlog2();
- testexp2();
- testexp2log2();
-#ifdef OPUS_FIXED_POINT
- testilog2();
-#endif
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_mdct.c b/drivers/opus/celt/tests/test_unit_mdct.c
deleted file mode 100644
index 0be03db2e8..0000000000
--- a/drivers/opus/celt/tests/test_unit_mdct.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#define SKIP_CONFIG_H
-
-#ifndef CUSTOM_MODES
-#define CUSTOM_MODES
-#endif
-
-#include <stdio.h>
-
-#define CELT_C
-#include "opus/celt/mdct.h"
-#include "opus/celt/stack_alloc.h"
-
-#include "opus/celt/kiss_fft.c"
-#include "opus/celt/mdct.c"
-#include "opus/celt/mathops.c"
-#include "opus/celt/entcode.c"
-
-#ifndef M_PI
-#define M_PI 3.141592653
-#endif
-
-int ret = 0;
-void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse)
-{
- int bin,k;
- double errpow=0,sigpow=0;
- double snr;
- for (bin=0;bin<nfft/2;++bin) {
- double ansr = 0;
- double difr;
-
- for (k=0;k<nfft;++k) {
- double phase = 2*M_PI*(k+.5+.25*nfft)*(bin+.5)/nfft;
- double re = cos(phase);
-
- re /= nfft/4;
-
- ansr += in[k] * re;
- }
- /*printf ("%f %f\n", ansr, out[bin]);*/
- difr = ansr - out[bin];
- errpow += difr*difr;
- sigpow += ansr*ansr;
- }
- snr = 10*log10(sigpow/errpow);
- printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr );
- if (snr<60) {
- printf( "** poor snr: %f **\n", snr);
- ret = 1;
- }
-}
-
-void check_inv(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse)
-{
- int bin,k;
- double errpow=0,sigpow=0;
- double snr;
- for (bin=0;bin<nfft;++bin) {
- double ansr = 0;
- double difr;
-
- for (k=0;k<nfft/2;++k) {
- double phase = 2*M_PI*(bin+.5+.25*nfft)*(k+.5)/nfft;
- double re = cos(phase);
-
- /*re *= 2;*/
-
- ansr += in[k] * re;
- }
- /*printf ("%f %f\n", ansr, out[bin]);*/
- difr = ansr - out[bin];
- errpow += difr*difr;
- sigpow += ansr*ansr;
- }
- snr = 10*log10(sigpow/errpow);
- printf("nfft=%d inverse=%d,snr = %f\n",nfft,isinverse,snr );
- if (snr<60) {
- printf( "** poor snr: %f **\n", snr);
- ret = 1;
- }
-}
-
-
-void test1d(int nfft,int isinverse)
-{
- celt_mdct_lookup cfg;
- size_t buflen = sizeof(kiss_fft_scalar)*nfft;
-
- kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen);
- kiss_fft_scalar * in_copy = (kiss_fft_scalar*)malloc(buflen);
- kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen);
- opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2);
- int k;
-
- clt_mdct_init(&cfg, nfft, 0);
- for (k=0;k<nfft;++k) {
- in[k] = (rand() % 32768) - 16384;
- }
-
- for (k=0;k<nfft/2;++k) {
- window[k] = Q15ONE;
- }
- for (k=0;k<nfft;++k) {
- in[k] *= 32768;
- }
-
- if (isinverse)
- {
- for (k=0;k<nfft;++k) {
- in[k] /= nfft;
- }
- }
-
- for (k=0;k<nfft;++k)
- in_copy[k] = in[k];
- /*for (k=0;k<nfft;++k) printf("%d %d ", in[k].r, in[k].i);printf("\n");*/
-
- if (isinverse)
- {
- for (k=0;k<nfft;++k)
- out[k] = 0;
- clt_mdct_backward(&cfg,in,out, window, nfft/2, 0, 1);
- /* 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);
- check(in_copy,out,nfft,isinverse);
- }
- /*for (k=0;k<nfft;++k) printf("%d %d ", out[k].r, out[k].i);printf("\n");*/
-
-
- free(in);
- free(out);
- clt_mdct_clear(&cfg);
-}
-
-int main(int argc,char ** argv)
-{
- ALLOC_STACK;
- if (argc>1) {
- int k;
- for (k=1;k<argc;++k) {
- test1d(atoi(argv[k]),0);
- test1d(atoi(argv[k]),1);
- }
- }else{
- test1d(32,0);
- test1d(32,1);
- test1d(256,0);
- test1d(256,1);
- test1d(512,0);
- test1d(512,1);
- test1d(1024,0);
- test1d(1024,1);
- test1d(2048,0);
- test1d(2048,1);
-#ifndef RADIX_TWO_ONLY
- test1d(36,0);
- test1d(36,1);
- test1d(40,0);
- test1d(40,1);
- test1d(60,0);
- test1d(60,1);
- test1d(120,0);
- test1d(120,1);
- test1d(240,0);
- test1d(240,1);
- test1d(480,0);
- test1d(480,1);
- test1d(960,0);
- test1d(960,1);
- test1d(1920,0);
- test1d(1920,1);
-#endif
- }
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_rotation.c b/drivers/opus/celt/tests/test_unit_rotation.c
deleted file mode 100644
index a57bf11e79..0000000000
--- a/drivers/opus/celt/tests/test_unit_rotation.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#ifndef CUSTOM_MODES
-#define CUSTOM_MODES
-#endif
-
-#define CELT_C
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "opus/celt/vq.c"
-#include "opus/celt/cwrs.c"
-#include "opus/celt/entcode.c"
-#include "opus/celt/entenc.c"
-#include "opus/celt/entdec.c"
-#include "opus/celt/mathops.c"
-#include "opus/celt/bands.h"
-#include <math.h>
-#define MAX_SIZE 100
-
-int ret=0;
-void test_rotation(int N, int K)
-{
- int i;
- double err = 0, ener = 0, snr, snr0;
- opus_val16 x0[MAX_SIZE];
- opus_val16 x1[MAX_SIZE];
- for (i=0;i<N;i++)
- x1[i] = x0[i] = rand()%32767-16384;
- exp_rotation(x1, N, 1, 1, K, SPREAD_NORMAL);
- for (i=0;i<N;i++)
- {
- err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]);
- ener += x0[i]*(double)x0[i];
- }
- snr0 = 20*log10(ener/err);
- err = ener = 0;
- exp_rotation(x1, N, -1, 1, K, SPREAD_NORMAL);
- for (i=0;i<N;i++)
- {
- err += (x0[i]-(double)x1[i])*(x0[i]-(double)x1[i]);
- ener += x0[i]*(double)x0[i];
- }
- snr = 20*log10(ener/err);
- printf ("SNR for size %d (%d pulses) is %f (was %f without inverse)\n", N, K, snr, snr0);
- if (snr < 60 || snr0 > 20)
- {
- fprintf(stderr, "FAIL!\n");
- ret = 1;
- }
-}
-
-int main(void)
-{
- ALLOC_STACK;
- test_rotation(15, 3);
- test_rotation(23, 5);
- test_rotation(50, 3);
- test_rotation(80, 1);
- return ret;
-}
diff --git a/drivers/opus/celt/tests/test_unit_types.c b/drivers/opus/celt/tests/test_unit_types.c
deleted file mode 100644
index 12d5ca72f8..0000000000
--- a/drivers/opus/celt/tests/test_unit_types.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (c) 2008-2011 Xiph.Org Foundation
- Written by Jean-Marc Valin */
-/*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifdef OPUS_ENABLED
-#include "opus/opus_config.h"
-#endif
-
-#include "opus/opus_types.h"
-#include <stdio.h>
-
-int main(void)
-{
- opus_int16 i = 1;
- i <<= 14;
- if (i>>14 != 1)
- {
- fprintf(stderr, "opus_int16 isn't 16 bits\n");
- return 1;
- }
- if (sizeof(opus_int16)*2 != sizeof(opus_int32))
- {
- fprintf(stderr, "16*2 != 32\n");
- return 1;
- }
- return 0;
-}