| OLD | NEW |
| (Empty) | |
| 1 /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, |
| 2 Gregory Maxwell |
| 3 Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ |
| 4 /* |
| 5 Redistribution and use in source and binary forms, with or without |
| 6 modification, are permitted provided that the following conditions |
| 7 are met: |
| 8 |
| 9 - Redistributions of source code must retain the above copyright |
| 10 notice, this list of conditions and the following disclaimer. |
| 11 |
| 12 - Redistributions in binary form must reproduce the above copyright |
| 13 notice, this list of conditions and the following disclaimer in the |
| 14 documentation and/or other materials provided with the distribution. |
| 15 |
| 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 20 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 24 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 25 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
| 28 |
| 29 #ifdef HAVE_CONFIG_H |
| 30 #include "config.h" |
| 31 #endif |
| 32 |
| 33 #include <stdio.h> |
| 34 #include <string.h> |
| 35 |
| 36 #ifndef CUSTOM_MODES |
| 37 #define CUSTOM_MODES |
| 38 #else |
| 39 #define TEST_CUSTOM_MODES |
| 40 #endif |
| 41 |
| 42 #define CELT_C |
| 43 #include "stack_alloc.h" |
| 44 #include "entenc.c" |
| 45 #include "entdec.c" |
| 46 #include "entcode.c" |
| 47 #include "cwrs.c" |
| 48 #include "mathops.c" |
| 49 #include "rate.h" |
| 50 |
| 51 #define NMAX (240) |
| 52 #define KMAX (128) |
| 53 |
| 54 #ifdef TEST_CUSTOM_MODES |
| 55 |
| 56 #define NDIMS (44) |
| 57 static const int pn[NDIMS]={ |
| 58 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 59 11, 12, 13, 14, 15, 16, 18, 20, 22, |
| 60 24, 26, 28, 30, 32, 36, 40, 44, 48, |
| 61 52, 56, 60, 64, 72, 80, 88, 96, 104, |
| 62 112, 120, 128, 144, 160, 176, 192, 208 |
| 63 }; |
| 64 static const int pkmax[NDIMS]={ |
| 65 128, 128, 128, 128, 88, 52, 36, 26, 22, |
| 66 18, 16, 15, 13, 12, 12, 11, 10, 9, |
| 67 9, 8, 8, 7, 7, 7, 7, 6, 6, |
| 68 6, 6, 6, 5, 5, 5, 5, 5, 5, |
| 69 4, 4, 4, 4, 4, 4, 4, 4 |
| 70 }; |
| 71 |
| 72 #else /* TEST_CUSTOM_MODES */ |
| 73 |
| 74 #define NDIMS (22) |
| 75 static const int pn[NDIMS]={ |
| 76 2, 3, 4, 6, 8, 9, 11, 12, 16, |
| 77 18, 22, 24, 32, 36, 44, 48, 64, 72, |
| 78 88, 96, 144, 176 |
| 79 }; |
| 80 static const int pkmax[NDIMS]={ |
| 81 128, 128, 128, 88, 36, 26, 18, 16, 12, |
| 82 11, 9, 9, 7, 7, 6, 6, 5, 5, |
| 83 5, 5, 4, 4 |
| 84 }; |
| 85 |
| 86 #endif |
| 87 |
| 88 int main(void){ |
| 89 int t; |
| 90 int n; |
| 91 ALLOC_STACK; |
| 92 for(t=0;t<NDIMS;t++){ |
| 93 int pseudo; |
| 94 n=pn[t]; |
| 95 for(pseudo=1;pseudo<41;pseudo++) |
| 96 { |
| 97 int k; |
| 98 #if defined(SMALL_FOOTPRINT) |
| 99 opus_uint32 uu[KMAX+2U]; |
| 100 #endif |
| 101 opus_uint32 inc; |
| 102 opus_uint32 nc; |
| 103 opus_uint32 i; |
| 104 k=get_pulses(pseudo); |
| 105 if (k>pkmax[t])break; |
| 106 printf("Testing CWRS with N=%i, K=%i...\n",n,k); |
| 107 #if defined(SMALL_FOOTPRINT) |
| 108 nc=ncwrs_urow(n,k,uu); |
| 109 #else |
| 110 nc=CELT_PVQ_V(n,k); |
| 111 #endif |
| 112 inc=nc/20000; |
| 113 if(inc<1)inc=1; |
| 114 for(i=0;i<nc;i+=inc){ |
| 115 #if defined(SMALL_FOOTPRINT) |
| 116 opus_uint32 u[KMAX+2U]; |
| 117 #endif |
| 118 int y[NMAX]; |
| 119 int sy; |
| 120 opus_uint32 v; |
| 121 opus_uint32 ii; |
| 122 int j; |
| 123 #if defined(SMALL_FOOTPRINT) |
| 124 memcpy(u,uu,(k+2U)*sizeof(*u)); |
| 125 cwrsi(n,k,i,y,u); |
| 126 #else |
| 127 cwrsi(n,k,i,y); |
| 128 #endif |
| 129 sy=0; |
| 130 for(j=0;j<n;j++)sy+=abs(y[j]); |
| 131 if(sy!=k){ |
| 132 fprintf(stderr,"N=%d Pulse count mismatch in cwrsi (%d!=%d).\n", |
| 133 n,sy,k); |
| 134 return 99; |
| 135 } |
| 136 /*printf("%6u of %u:",i,nc); |
| 137 for(j=0;j<n;j++)printf(" %+3i",y[j]); |
| 138 printf(" ->");*/ |
| 139 #if defined(SMALL_FOOTPRINT) |
| 140 ii=icwrs(n,k,&v,y,u); |
| 141 #else |
| 142 ii=icwrs(n,y); |
| 143 v=CELT_PVQ_V(n,k); |
| 144 #endif |
| 145 if(ii!=i){ |
| 146 fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", |
| 147 (long)ii,(long)i); |
| 148 return 1; |
| 149 } |
| 150 if(v!=nc){ |
| 151 fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", |
| 152 (long)v,(long)nc); |
| 153 return 2; |
| 154 } |
| 155 /*printf(" %6u\n",i);*/ |
| 156 } |
| 157 /*printf("\n");*/ |
| 158 } |
| 159 } |
| 160 return 0; |
| 161 } |
| OLD | NEW |