annotate src/opus-1.3/tests/test_opus_common.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 /* Copyright (c) 2011 Xiph.Org Foundation
cannam@154 2 Written by Gregory Maxwell */
cannam@154 3 /*
cannam@154 4 Redistribution and use in source and binary forms, with or without
cannam@154 5 modification, are permitted provided that the following conditions
cannam@154 6 are met:
cannam@154 7
cannam@154 8 - Redistributions of source code must retain the above copyright
cannam@154 9 notice, this list of conditions and the following disclaimer.
cannam@154 10
cannam@154 11 - Redistributions in binary form must reproduce the above copyright
cannam@154 12 notice, this list of conditions and the following disclaimer in the
cannam@154 13 documentation and/or other materials provided with the distribution.
cannam@154 14
cannam@154 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@154 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@154 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@154 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
cannam@154 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@154 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@154 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@154 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@154 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@154 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@154 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@154 26 */
cannam@154 27
cannam@154 28 static OPUS_INLINE void deb2_impl(unsigned char *_t,unsigned char **_p,int _k,int _x,int _y)
cannam@154 29 {
cannam@154 30 int i;
cannam@154 31 if(_x>2){
cannam@154 32 if(_y<3)for(i=0;i<_y;i++)*(--*_p)=_t[i+1];
cannam@154 33 }else{
cannam@154 34 _t[_x]=_t[_x-_y];
cannam@154 35 deb2_impl(_t,_p,_k,_x+1,_y);
cannam@154 36 for(i=_t[_x-_y]+1;i<_k;i++){
cannam@154 37 _t[_x]=i;
cannam@154 38 deb2_impl(_t,_p,_k,_x+1,_x);
cannam@154 39 }
cannam@154 40 }
cannam@154 41 }
cannam@154 42
cannam@154 43 /*Generates a De Bruijn sequence (k,2) with length k^2*/
cannam@154 44 static OPUS_INLINE void debruijn2(int _k, unsigned char *_res)
cannam@154 45 {
cannam@154 46 unsigned char *p;
cannam@154 47 unsigned char *t;
cannam@154 48 t=malloc(sizeof(unsigned char)*_k*2);
cannam@154 49 memset(t,0,sizeof(unsigned char)*_k*2);
cannam@154 50 p=&_res[_k*_k];
cannam@154 51 deb2_impl(t,&p,_k,1,1);
cannam@154 52 free(t);
cannam@154 53 }
cannam@154 54
cannam@154 55 /*MWC RNG of George Marsaglia*/
cannam@154 56 static opus_uint32 Rz, Rw;
cannam@154 57 static OPUS_INLINE opus_uint32 fast_rand(void)
cannam@154 58 {
cannam@154 59 Rz=36969*(Rz&65535)+(Rz>>16);
cannam@154 60 Rw=18000*(Rw&65535)+(Rw>>16);
cannam@154 61 return (Rz<<16)+Rw;
cannam@154 62 }
cannam@154 63 static opus_uint32 iseed;
cannam@154 64
cannam@154 65 #ifdef __GNUC__
cannam@154 66 __attribute__((noreturn))
cannam@154 67 #elif defined(_MSC_VER)
cannam@154 68 __declspec(noreturn)
cannam@154 69 #endif
cannam@154 70 static OPUS_INLINE void _test_failed(const char *file, int line)
cannam@154 71 {
cannam@154 72 fprintf(stderr,"\n ***************************************************\n");
cannam@154 73 fprintf(stderr," *** A fatal error was detected. ***\n");
cannam@154 74 fprintf(stderr," ***************************************************\n");
cannam@154 75 fprintf(stderr,"Please report this failure and include\n");
cannam@154 76 fprintf(stderr,"'make check SEED=%u fails %s at line %d for %s'\n",iseed,file,line,opus_get_version_string());
cannam@154 77 fprintf(stderr,"and any relevant details about your system.\n\n");
cannam@154 78 abort();
cannam@154 79 }
cannam@154 80 #define test_failed() _test_failed(__FILE__, __LINE__);
cannam@154 81
cannam@154 82 void regression_test(void);