| OLD | NEW |
| 1 /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, | 1 /* Copyright (c) 2008-2011 Xiph.Org Foundation, Mozilla Corporation, |
| 2 Gregory Maxwell | 2 Gregory Maxwell |
| 3 Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ | 3 Written by Jean-Marc Valin, Gregory Maxwell, and Timothy B. Terriberry */ |
| 4 /* | 4 /* |
| 5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
| 6 modification, are permitted provided that the following conditions | 6 modification, are permitted provided that the following conditions |
| 7 are met: | 7 are met: |
| 8 | 8 |
| 9 - Redistributions of source code must retain the above copyright | 9 - Redistributions of source code must retain the above copyright |
| 10 notice, this list of conditions and the following disclaimer. | 10 notice, this list of conditions and the following disclaimer. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "entcode.c" | 46 #include "entcode.c" |
| 47 #include "cwrs.c" | 47 #include "cwrs.c" |
| 48 #include "mathops.c" | 48 #include "mathops.c" |
| 49 #include "rate.h" | 49 #include "rate.h" |
| 50 | 50 |
| 51 #define NMAX (240) | 51 #define NMAX (240) |
| 52 #define KMAX (128) | 52 #define KMAX (128) |
| 53 | 53 |
| 54 #ifdef TEST_CUSTOM_MODES | 54 #ifdef TEST_CUSTOM_MODES |
| 55 | 55 |
| 56 #define NDIMS (46) | 56 #define NDIMS (44) |
| 57 static const int pn[NDIMS]={ | 57 static const int pn[NDIMS]={ |
| 58 2, 3, 4, 5, 6, 7, 8, 9, 10, | 58 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 59 11, 12, 13, 14, 15, 16, 18, 20, 22, | 59 11, 12, 13, 14, 15, 16, 18, 20, 22, |
| 60 24, 26, 28, 30, 32, 36, 40, 44, 48, | 60 24, 26, 28, 30, 32, 36, 40, 44, 48, |
| 61 52, 56, 60, 64, 72, 80, 88, 96, 104, | 61 52, 56, 60, 64, 72, 80, 88, 96, 104, |
| 62 112, 120, 128, 144, 160, 176, 192, 208, 224, | 62 112, 120, 128, 144, 160, 176, 192, 208 |
| 63 240 | |
| 64 }; | 63 }; |
| 65 static const int pkmax[NDIMS]={ | 64 static const int pkmax[NDIMS]={ |
| 66 128, 128, 128, 128, 88, 52, 36, 26, 22, | 65 128, 128, 128, 128, 88, 52, 36, 26, 22, |
| 67 18, 16, 15, 13, 12, 12, 11, 10, 9, | 66 18, 16, 15, 13, 12, 12, 11, 10, 9, |
| 68 9, 8, 8, 7, 7, 7, 7, 6, 6, | 67 9, 8, 8, 7, 7, 7, 7, 6, 6, |
| 69 6, 6, 6, 5, 5, 5, 5, 5, 5, | 68 6, 6, 6, 5, 5, 5, 5, 5, 5, |
| 70 4, 4, 4, 4, 4, 4, 4, 4, 4, | 69 4, 4, 4, 4, 4, 4, 4, 4 |
| 71 4 | |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 #else /* TEST_CUSTOM_MODES */ | 72 #else /* TEST_CUSTOM_MODES */ |
| 75 | 73 |
| 76 #define NDIMS (22) | 74 #define NDIMS (22) |
| 77 static const int pn[NDIMS]={ | 75 static const int pn[NDIMS]={ |
| 78 2, 3, 4, 6, 8, 9, 11, 12, 16, | 76 2, 3, 4, 6, 8, 9, 11, 12, 16, |
| 79 18, 22, 24, 32, 36, 44, 48, 64, 72, | 77 18, 22, 24, 32, 36, 44, 48, 64, 72, |
| 80 88, 96, 144, 176 | 78 88, 96, 144, 176 |
| 81 }; | 79 }; |
| 82 static const int pkmax[NDIMS]={ | 80 static const int pkmax[NDIMS]={ |
| 83 128, 128, 128, 88, 36, 26, 18, 16, 12, | 81 128, 128, 128, 88, 36, 26, 18, 16, 12, |
| 84 11, 9, 9, 7, 7, 6, 6, 5, 5, | 82 11, 9, 9, 7, 7, 6, 6, 5, 5, |
| 85 5, 5, 4, 4 | 83 5, 5, 4, 4 |
| 86 }; | 84 }; |
| 87 | 85 |
| 88 #endif | 86 #endif |
| 89 | 87 |
| 90 int main(void){ | 88 int main(void){ |
| 91 int t; | 89 int t; |
| 92 int n; | 90 int n; |
| 93 ALLOC_STACK; | 91 ALLOC_STACK; |
| 94 for(t=0;t<NDIMS;t++){ | 92 for(t=0;t<NDIMS;t++){ |
| 95 int pseudo; | 93 int pseudo; |
| 96 n=pn[t]; | 94 n=pn[t]; |
| 97 for(pseudo=1;pseudo<41;pseudo++) | 95 for(pseudo=1;pseudo<41;pseudo++) |
| 98 { | 96 { |
| 99 int k; | 97 int k; |
| 98 #if defined(SMALL_FOOTPRINT) |
| 100 opus_uint32 uu[KMAX+2U]; | 99 opus_uint32 uu[KMAX+2U]; |
| 100 #endif |
| 101 opus_uint32 inc; | 101 opus_uint32 inc; |
| 102 opus_uint32 nc; | 102 opus_uint32 nc; |
| 103 opus_uint32 i; | 103 opus_uint32 i; |
| 104 k=get_pulses(pseudo); | 104 k=get_pulses(pseudo); |
| 105 if (k>pkmax[t])break; | 105 if (k>pkmax[t])break; |
| 106 printf("Testing CWRS with N=%i, K=%i...\n",n,k); | 106 printf("Testing CWRS with N=%i, K=%i...\n",n,k); |
| 107 #if defined(SMALL_FOOTPRINT) |
| 107 nc=ncwrs_urow(n,k,uu); | 108 nc=ncwrs_urow(n,k,uu); |
| 109 #else |
| 110 nc=CELT_PVQ_V(n,k); |
| 111 #endif |
| 108 inc=nc/20000; | 112 inc=nc/20000; |
| 109 if(inc<1)inc=1; | 113 if(inc<1)inc=1; |
| 110 for(i=0;i<nc;i+=inc){ | 114 for(i=0;i<nc;i+=inc){ |
| 115 #if defined(SMALL_FOOTPRINT) |
| 111 opus_uint32 u[KMAX+2U]; | 116 opus_uint32 u[KMAX+2U]; |
| 112 int y[NMAX]; | 117 #endif |
| 113 int sy; | 118 int y[NMAX]; |
| 114 int yy[5]; | 119 int sy; |
| 115 opus_uint32 v; | 120 opus_uint32 v; |
| 116 opus_uint32 ii; | 121 opus_uint32 ii; |
| 117 int kk; | 122 int j; |
| 118 int j; | 123 #if defined(SMALL_FOOTPRINT) |
| 119 memcpy(u,uu,(k+2U)*sizeof(*u)); | 124 memcpy(u,uu,(k+2U)*sizeof(*u)); |
| 120 cwrsi(n,k,i,y,u); | 125 cwrsi(n,k,i,y,u); |
| 126 #else |
| 127 cwrsi(n,k,i,y); |
| 128 #endif |
| 121 sy=0; | 129 sy=0; |
| 122 for(j=0;j<n;j++)sy+=ABS(y[j]); | 130 for(j=0;j<n;j++)sy+=ABS(y[j]); |
| 123 if(sy!=k){ | 131 if(sy!=k){ |
| 124 fprintf(stderr,"N=%d Pulse count mismatch in cwrsi (%d!=%d).\n", | 132 fprintf(stderr,"N=%d Pulse count mismatch in cwrsi (%d!=%d).\n", |
| 125 n,sy,k); | 133 n,sy,k); |
| 126 return 99; | 134 return 99; |
| 127 } | 135 } |
| 128 /*printf("%6u of %u:",i,nc); | 136 /*printf("%6u of %u:",i,nc); |
| 129 for(j=0;j<n;j++)printf(" %+3i",y[j]); | 137 for(j=0;j<n;j++)printf(" %+3i",y[j]); |
| 130 printf(" ->");*/ | 138 printf(" ->");*/ |
| 139 #if defined(SMALL_FOOTPRINT) |
| 131 ii=icwrs(n,k,&v,y,u); | 140 ii=icwrs(n,k,&v,y,u); |
| 141 #else |
| 142 ii=icwrs(n,y); |
| 143 v=CELT_PVQ_V(n,k); |
| 144 #endif |
| 132 if(ii!=i){ | 145 if(ii!=i){ |
| 133 fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", | 146 fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", |
| 134 (long)ii,(long)i); | 147 (long)ii,(long)i); |
| 135 return 1; | 148 return 1; |
| 136 } | 149 } |
| 137 if(v!=nc){ | 150 if(v!=nc){ |
| 138 fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", | 151 fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", |
| 139 (long)v,(long)nc); | 152 (long)v,(long)nc); |
| 140 return 2; | 153 return 2; |
| 141 } | 154 } |
| 142 #ifndef SMALL_FOOTPRINT | |
| 143 if(n==2){ | |
| 144 cwrsi2(k,i,yy); | |
| 145 for(j=0;j<2;j++)if(yy[j]!=y[j]){ | |
| 146 fprintf(stderr,"N=2 pulse vector mismatch ({%i,%i}!={%i,%i}).\n", | |
| 147 yy[0],yy[1],y[0],y[1]); | |
| 148 return 3; | |
| 149 } | |
| 150 ii=icwrs2(yy,&kk); | |
| 151 if(ii!=i){ | |
| 152 fprintf(stderr,"N=2 combination-index mismatch (%lu!=%lu).\n", | |
| 153 (long)ii,(long)i); | |
| 154 return 4; | |
| 155 } | |
| 156 if(kk!=k){ | |
| 157 fprintf(stderr,"N=2 pulse count mismatch (%i,%i).\n",kk,k); | |
| 158 return 5; | |
| 159 } | |
| 160 v=ncwrs2(k); | |
| 161 if(v!=nc){ | |
| 162 fprintf(stderr,"N=2 combination count mismatch (%lu,%lu).\n", | |
| 163 (long)v,(long)nc); | |
| 164 return 6; | |
| 165 } | |
| 166 } | |
| 167 else if(n==3){ | |
| 168 cwrsi3(k,i,yy); | |
| 169 for(j=0;j<3;j++)if(yy[j]!=y[j]){ | |
| 170 fprintf(stderr,"N=3 pulse vector mismatch " | |
| 171 "({%i,%i,%i}!={%i,%i,%i}).\n",yy[0],yy[1],yy[2],y[0],y[1],y[2]); | |
| 172 return 7; | |
| 173 } | |
| 174 ii=icwrs3(yy,&kk); | |
| 175 if(ii!=i){ | |
| 176 fprintf(stderr,"N=3 combination-index mismatch (%lu!=%lu).\n", | |
| 177 (long)ii,(long)i); | |
| 178 return 8; | |
| 179 } | |
| 180 if(kk!=k){ | |
| 181 fprintf(stderr,"N=3 pulse count mismatch (%i!=%i).\n",kk,k); | |
| 182 return 9; | |
| 183 } | |
| 184 v=ncwrs3(k); | |
| 185 if(v!=nc){ | |
| 186 fprintf(stderr,"N=3 combination count mismatch (%lu!=%lu).\n", | |
| 187 (long)v,(long)nc); | |
| 188 return 10; | |
| 189 } | |
| 190 } | |
| 191 else if(n==4){ | |
| 192 cwrsi4(k,i,yy); | |
| 193 for(j=0;j<4;j++)if(yy[j]!=y[j]){ | |
| 194 fprintf(stderr,"N=4 pulse vector mismatch " | |
| 195 "({%i,%i,%i,%i}!={%i,%i,%i,%i}.\n", | |
| 196 yy[0],yy[1],yy[2],yy[3],y[0],y[1],y[2],y[3]); | |
| 197 return 11; | |
| 198 } | |
| 199 ii=icwrs4(yy,&kk); | |
| 200 if(ii!=i){ | |
| 201 fprintf(stderr,"N=4 combination-index mismatch (%lu!=%lu).\n", | |
| 202 (long)ii,(long)i); | |
| 203 return 12; | |
| 204 } | |
| 205 if(kk!=k){ | |
| 206 fprintf(stderr,"N=4 pulse count mismatch (%i!=%i).\n",kk,k); | |
| 207 return 13; | |
| 208 } | |
| 209 v=ncwrs4(k); | |
| 210 if(v!=nc){ | |
| 211 fprintf(stderr,"N=4 combination count mismatch (%lu!=%lu).\n", | |
| 212 (long)v,(long)nc); | |
| 213 return 14; | |
| 214 } | |
| 215 } | |
| 216 #endif /* SMALL_FOOTPRINT */ | |
| 217 /*printf(" %6u\n",i);*/ | 155 /*printf(" %6u\n",i);*/ |
| 218 } | 156 } |
| 219 /*printf("\n");*/ | 157 /*printf("\n");*/ |
| 220 } | 158 } |
| 221 } | 159 } |
| 222 return 0; | 160 return 0; |
| 223 } | 161 } |
| OLD | NEW |