1 | #!/usr/bin/perl
|
---|
2 | print <<'EOD';
|
---|
3 | /********************************************************************
|
---|
4 | * *
|
---|
5 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
---|
6 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
---|
7 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
---|
8 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
---|
9 | * *
|
---|
10 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
---|
11 | * by the Xiph.Org Foundation https://xiph.org/ *
|
---|
12 | * *
|
---|
13 | ********************************************************************
|
---|
14 |
|
---|
15 | function: lookup data; generated by lookups.pl; edit there
|
---|
16 |
|
---|
17 | ********************************************************************/
|
---|
18 |
|
---|
19 | #ifndef _V_LOOKUP_DATA_H_
|
---|
20 |
|
---|
21 | #ifdef FLOAT_LOOKUP
|
---|
22 | EOD
|
---|
23 |
|
---|
24 | $cos_sz=128;
|
---|
25 | $invsq_sz=32;
|
---|
26 | $invsq2exp_min=-32;
|
---|
27 | $invsq2exp_max=32;
|
---|
28 |
|
---|
29 | $fromdB_sz=35;
|
---|
30 | $fromdB_shift=5;
|
---|
31 | $fromdB2_shift=3;
|
---|
32 |
|
---|
33 | $invsq_i_shift=10;
|
---|
34 | $cos_i_shift=9;
|
---|
35 | $delta_shift=6;
|
---|
36 |
|
---|
37 | print "#define COS_LOOKUP_SZ $cos_sz\n";
|
---|
38 | print "static float COS_LOOKUP[COS_LOOKUP_SZ+1]={\n";
|
---|
39 |
|
---|
40 | for($i=0;$i<=$cos_sz;){
|
---|
41 | print "\t";
|
---|
42 | for($j=0;$j<4 && $i<=$cos_sz;$j++){
|
---|
43 | printf "%+.13f,", cos(3.14159265358979323846*($i++)/$cos_sz) ;
|
---|
44 | }
|
---|
45 | print "\n";
|
---|
46 | }
|
---|
47 | print "};\n\n";
|
---|
48 |
|
---|
49 | print "#define INVSQ_LOOKUP_SZ $invsq_sz\n";
|
---|
50 | print "static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={\n";
|
---|
51 |
|
---|
52 | for($i=0;$i<=$invsq_sz;){
|
---|
53 | print "\t";
|
---|
54 | for($j=0;$j<4 && $i<=$invsq_sz;$j++){
|
---|
55 | my$indexmap=$i++/$invsq_sz*.5+.5;
|
---|
56 | printf "%.12f,", 1./sqrt($indexmap);
|
---|
57 | }
|
---|
58 | print "\n";
|
---|
59 | }
|
---|
60 | print "};\n\n";
|
---|
61 |
|
---|
62 | print "#define INVSQ2EXP_LOOKUP_MIN $invsq2exp_min\n";
|
---|
63 | print "#define INVSQ2EXP_LOOKUP_MAX $invsq2exp_max\n";
|
---|
64 | print "static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\\\n".
|
---|
65 | " INVSQ2EXP_LOOKUP_MIN+1]={\n";
|
---|
66 |
|
---|
67 | for($i=$invsq2exp_min;$i<=$invsq2exp_max;){
|
---|
68 | print "\t";
|
---|
69 | for($j=0;$j<4 && $i<=$invsq2exp_max;$j++){
|
---|
70 | printf "%15.10g,", 2**($i++*-.5);
|
---|
71 | }
|
---|
72 | print "\n";
|
---|
73 | }
|
---|
74 | print "};\n\n#endif\n\n";
|
---|
75 |
|
---|
76 |
|
---|
77 | # 0 to -140 dB
|
---|
78 | $fromdB2_sz=1<<$fromdB_shift;
|
---|
79 | $fromdB_gran=1<<($fromdB_shift-$fromdB2_shift);
|
---|
80 | print "#define FROMdB_LOOKUP_SZ $fromdB_sz\n";
|
---|
81 | print "#define FROMdB2_LOOKUP_SZ $fromdB2_sz\n";
|
---|
82 | print "#define FROMdB_SHIFT $fromdB_shift\n";
|
---|
83 | print "#define FROMdB2_SHIFT $fromdB2_shift\n";
|
---|
84 | print "#define FROMdB2_MASK ".((1<<$fromdB_shift)-1)."\n";
|
---|
85 |
|
---|
86 | print "static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={\n";
|
---|
87 |
|
---|
88 | for($i=0;$i<$fromdB_sz;){
|
---|
89 | print "\t";
|
---|
90 | for($j=0;$j<4 && $i<$fromdB_sz;$j++){
|
---|
91 | printf "%15.10g,", 10**(.05*(-$fromdB_gran*$i++));
|
---|
92 | }
|
---|
93 | print "\n";
|
---|
94 | }
|
---|
95 | print "};\n\n";
|
---|
96 |
|
---|
97 | print "static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={\n";
|
---|
98 |
|
---|
99 | for($i=0;$i<$fromdB2_sz;){
|
---|
100 | print "\t";
|
---|
101 | for($j=0;$j<4 && $i<$fromdB_sz;$j++){
|
---|
102 | printf "%15.10g,", 10**(.05*(-$fromdB_gran/$fromdB2_sz*(.5+$i++)));
|
---|
103 | }
|
---|
104 | print "\n";
|
---|
105 | }
|
---|
106 | print "};\n\n#ifdef INT_LOOKUP\n\n";
|
---|
107 |
|
---|
108 |
|
---|
109 | $iisz=0x10000>>$invsq_i_shift;
|
---|
110 | print "#define INVSQ_LOOKUP_I_SHIFT $invsq_i_shift\n";
|
---|
111 | print "#define INVSQ_LOOKUP_I_MASK ".(0x0ffff>>(16-$invsq_i_shift))."\n";
|
---|
112 | print "static long INVSQ_LOOKUP_I[$iisz+1]={\n";
|
---|
113 | for($i=0;$i<=$iisz;){
|
---|
114 | print "\t";
|
---|
115 | for($j=0;$j<4 && $i<=$iisz;$j++){
|
---|
116 | my$indexmap=$i++/$iisz*.5+.5;
|
---|
117 | printf "%8d,", int(1./sqrt($indexmap)*65536.+.5);
|
---|
118 | }
|
---|
119 | print "\n";
|
---|
120 | }
|
---|
121 | print "};\n\n";
|
---|
122 |
|
---|
123 | $cisz=0x10000>>$cos_i_shift;
|
---|
124 | print "#define COS_LOOKUP_I_SHIFT $cos_i_shift\n";
|
---|
125 | print "#define COS_LOOKUP_I_MASK ".(0x0ffff>>(16-$cos_i_shift))."\n";
|
---|
126 | print "#define COS_LOOKUP_I_SZ $cisz\n";
|
---|
127 | print "static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={\n";
|
---|
128 |
|
---|
129 | for($i=0;$i<=$cisz;){
|
---|
130 | print "\t";
|
---|
131 | for($j=0;$j<4 && $i<=$cisz;$j++){
|
---|
132 | printf "%8d,", int(cos(3.14159265358979323846*($i++)/$cos_sz)*16384.+.5) ;
|
---|
133 | }
|
---|
134 | print "\n";
|
---|
135 | }
|
---|
136 | print "};\n\n";
|
---|
137 |
|
---|
138 |
|
---|
139 | print "#endif\n\n#endif\n";
|
---|
140 |
|
---|
141 |
|
---|