annotate src/opus-1.3/celt/tests/test_unit_cwrs32.c @ 79:91c729825bca pa_catalina

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