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