Chris@69: /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, Chris@69: Gregory Maxwell Chris@69: Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ Chris@69: /* Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: Chris@69: - Redistributions of source code must retain the above copyright Chris@69: notice, this list of conditions and the following disclaimer. Chris@69: Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: #ifdef HAVE_CONFIG_H Chris@69: #include "config.h" Chris@69: #endif Chris@69: Chris@69: #include Chris@69: #include Chris@69: Chris@69: #ifndef CUSTOM_MODES Chris@69: #define CUSTOM_MODES Chris@69: #else Chris@69: #define TEST_CUSTOM_MODES Chris@69: #endif Chris@69: Chris@69: #define CELT_C Chris@69: #include "stack_alloc.h" Chris@69: #include "entenc.c" Chris@69: #include "entdec.c" Chris@69: #include "entcode.c" Chris@69: #include "cwrs.c" Chris@69: #include "mathops.c" Chris@69: #include "rate.h" Chris@69: Chris@69: #define NMAX (240) Chris@69: #define KMAX (128) Chris@69: Chris@69: #ifdef TEST_CUSTOM_MODES Chris@69: Chris@69: #define NDIMS (44) Chris@69: static const int pn[NDIMS]={ Chris@69: 2, 3, 4, 5, 6, 7, 8, 9, 10, Chris@69: 11, 12, 13, 14, 15, 16, 18, 20, 22, Chris@69: 24, 26, 28, 30, 32, 36, 40, 44, 48, Chris@69: 52, 56, 60, 64, 72, 80, 88, 96, 104, Chris@69: 112, 120, 128, 144, 160, 176, 192, 208 Chris@69: }; Chris@69: static const int pkmax[NDIMS]={ Chris@69: 128, 128, 128, 128, 88, 52, 36, 26, 22, Chris@69: 18, 16, 15, 13, 12, 12, 11, 10, 9, Chris@69: 9, 8, 8, 7, 7, 7, 7, 6, 6, Chris@69: 6, 6, 6, 5, 5, 5, 5, 5, 5, Chris@69: 4, 4, 4, 4, 4, 4, 4, 4 Chris@69: }; Chris@69: Chris@69: #else /* TEST_CUSTOM_MODES */ Chris@69: Chris@69: #define NDIMS (22) Chris@69: static const int pn[NDIMS]={ Chris@69: 2, 3, 4, 6, 8, 9, 11, 12, 16, Chris@69: 18, 22, 24, 32, 36, 44, 48, 64, 72, Chris@69: 88, 96, 144, 176 Chris@69: }; Chris@69: static const int pkmax[NDIMS]={ Chris@69: 128, 128, 128, 88, 36, 26, 18, 16, 12, Chris@69: 11, 9, 9, 7, 7, 6, 6, 5, 5, Chris@69: 5, 5, 4, 4 Chris@69: }; Chris@69: Chris@69: #endif Chris@69: Chris@69: int main(void){ Chris@69: int t; Chris@69: int n; Chris@69: ALLOC_STACK; Chris@69: for(t=0;tpkmax[t])break; Chris@69: printf("Testing CWRS with N=%i, K=%i...\n",n,k); Chris@69: #if defined(SMALL_FOOTPRINT) Chris@69: nc=ncwrs_urow(n,k,uu); Chris@69: #else Chris@69: nc=CELT_PVQ_V(n,k); Chris@69: #endif Chris@69: inc=nc/20000; Chris@69: if(inc<1)inc=1; Chris@69: for(i=0;i");*/ Chris@69: #if defined(SMALL_FOOTPRINT) Chris@69: ii=icwrs(n,k,&v,y,u); Chris@69: #else Chris@69: ii=icwrs(n,y); Chris@69: v=CELT_PVQ_V(n,k); Chris@69: #endif Chris@69: if(ii!=i){ Chris@69: fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", Chris@69: (long)ii,(long)i); Chris@69: return 1; Chris@69: } Chris@69: if(v!=nc){ Chris@69: fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", Chris@69: (long)v,(long)nc); Chris@69: return 2; Chris@69: } Chris@69: /*printf(" %6u\n",i);*/ Chris@69: } Chris@69: /*printf("\n");*/ Chris@69: } Chris@69: } Chris@69: return 0; Chris@69: }