Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: tests/test_opus_common.h

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/test_opus_api.c ('k') | tests/test_opus_decode.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 Xiph.Org Foundation 1 /* Copyright (c) 2011 Xiph.Org Foundation
2 Written by Gregory Maxwell */ 2 Written by Gregory Maxwell */
3 /* 3 /*
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 - Redistributions of source code must retain the above copyright 8 - Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 10
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the 12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution. 13 documentation and/or other materials provided with the distribution.
14 14
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 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. 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 static inline void deb2_impl(unsigned char *_t,unsigned char **_p,int _k,int _x, int _y) 28 static OPUS_INLINE void deb2_impl(unsigned char *_t,unsigned char **_p,int _k,in t _x,int _y)
29 { 29 {
30 int i; 30 int i;
31 if(_x>2){ 31 if(_x>2){
32 if(_y<3)for(i=0;i<_y;i++)*(--*_p)=_t[i+1]; 32 if(_y<3)for(i=0;i<_y;i++)*(--*_p)=_t[i+1];
33 }else{ 33 }else{
34 _t[_x]=_t[_x-_y]; 34 _t[_x]=_t[_x-_y];
35 deb2_impl(_t,_p,_k,_x+1,_y); 35 deb2_impl(_t,_p,_k,_x+1,_y);
36 for(i=_t[_x-_y]+1;i<_k;i++){ 36 for(i=_t[_x-_y]+1;i<_k;i++){
37 _t[_x]=i; 37 _t[_x]=i;
38 deb2_impl(_t,_p,_k,_x+1,_x); 38 deb2_impl(_t,_p,_k,_x+1,_x);
39 } 39 }
40 } 40 }
41 } 41 }
42 42
43 /*Generates a De Bruijn sequence (k,2) with length k^2*/ 43 /*Generates a De Bruijn sequence (k,2) with length k^2*/
44 static inline void debruijn2(int _k, unsigned char *_res) 44 static OPUS_INLINE void debruijn2(int _k, unsigned char *_res)
45 { 45 {
46 unsigned char *p; 46 unsigned char *p;
47 unsigned char *t; 47 unsigned char *t;
48 t=malloc(sizeof(unsigned char)*_k*2); 48 t=malloc(sizeof(unsigned char)*_k*2);
49 memset(t,0,sizeof(unsigned char)*_k*2); 49 memset(t,0,sizeof(unsigned char)*_k*2);
50 p=&_res[_k*_k]; 50 p=&_res[_k*_k];
51 deb2_impl(t,&p,_k,1,1); 51 deb2_impl(t,&p,_k,1,1);
52 free(t); 52 free(t);
53 } 53 }
54 54
55 /*MWC RNG of George Marsaglia*/ 55 /*MWC RNG of George Marsaglia*/
56 static opus_uint32 Rz, Rw; 56 static opus_uint32 Rz, Rw;
57 static inline opus_uint32 fast_rand(void) 57 static OPUS_INLINE opus_uint32 fast_rand(void)
58 { 58 {
59 Rz=36969*(Rz&65535)+(Rz>>16); 59 Rz=36969*(Rz&65535)+(Rz>>16);
60 Rw=18000*(Rw&65535)+(Rw>>16); 60 Rw=18000*(Rw&65535)+(Rw>>16);
61 return (Rz<<16)+Rw; 61 return (Rz<<16)+Rw;
62 } 62 }
63 static opus_uint32 iseed; 63 static opus_uint32 iseed;
64 64
65 #ifdef __GNUC__ 65 #ifdef __GNUC__
66 __attribute__((noreturn)) 66 __attribute__((noreturn))
67 #endif 67 #endif
68 static inline void _test_failed(const char *file, int line) 68 static OPUS_INLINE void _test_failed(const char *file, int line)
69 { 69 {
70 fprintf(stderr,"\n ***************************************************\n"); 70 fprintf(stderr,"\n ***************************************************\n");
71 fprintf(stderr," *** A fatal error was detected. ***\n"); 71 fprintf(stderr," *** A fatal error was detected. ***\n");
72 fprintf(stderr," ***************************************************\n"); 72 fprintf(stderr," ***************************************************\n");
73 fprintf(stderr,"Please report this failure and include\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()); 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"); 75 fprintf(stderr,"and any relevant details about your system.\n\n");
76 abort(); 76 abort();
77 } 77 }
78 #define test_failed() _test_failed(__FILE__, __LINE__); 78 #define test_failed() _test_failed(__FILE__, __LINE__);
OLDNEW
« no previous file with comments | « tests/test_opus_api.c ('k') | tests/test_opus_decode.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698