Mercurial > mplayer.hg
annotate drivers/generic_math.h @ 35494:9cc5a5de6aa1
Cosmetic: Choose better variable name.
author | ib |
---|---|
date | Tue, 04 Dec 2012 18:39:09 +0000 |
parents | 0ad2da052b2e |
children |
rev | line source |
---|---|
22691 | 1 /* |
26003
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
2 * generic implementation of sin(x) and cos(x) functions specially for Linux |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
3 * Copyright (C) 2002 Nick Kurshev |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
4 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
5 * This file is part of MPlayer. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
6 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
7 * MPlayer is free software; you can redistribute it and/or modify |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
10 * (at your option) any later version. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
11 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
12 * MPlayer is distributed in the hope that it will be useful, |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
15 * GNU General Public License for more details. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
16 * |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
17 * You should have received a copy of the GNU General Public License along |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
a506a6ab14e1
Add standard license header and make copyright notices consistent.
diego
parents:
25607
diff
changeset
|
20 */ |
22691 | 21 |
26029 | 22 #ifndef MPLAYER_GENERIC_MATH_H |
23 #define MPLAYER_GENERIC_MATH_H | |
22691 | 24 |
25607
9d0b189ce1b2
Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents:
25535
diff
changeset
|
25 typedef struct gen_sincos |
22691 | 26 { |
27 double x; | |
28 double sinx; | |
29 double cosx; | |
30 }gen_sincos_t; | |
31 | |
32 static gen_sincos_t g_sincos[201] = { | |
33 { -3.141600e+00, 7.346410e-06, -1.000000e-00 }, | |
34 { -3.110184e+00, -3.140349e-02, -9.995068e-01 }, | |
35 { -3.078768e+00, -6.278333e-02, -9.980272e-01 }, | |
36 { -3.047352e+00, -9.410122e-02, -9.955626e-01 }, | |
37 { -3.015936e+00, -1.253262e-01, -9.921156e-01 }, | |
38 { -2.984520e+00, -1.564276e-01, -9.876894e-01 }, | |
39 { -2.953104e+00, -1.873745e-01, -9.822885e-01 }, | |
40 { -2.921688e+00, -2.181366e-01, -9.759183e-01 }, | |
41 { -2.890272e+00, -2.486833e-01, -9.685848e-01 }, | |
42 { -2.858856e+00, -2.789847e-01, -9.602956e-01 }, | |
43 { -2.827440e+00, -3.090107e-01, -9.510586e-01 }, | |
44 { -2.796024e+00, -3.387318e-01, -9.408830e-01 }, | |
45 { -2.764608e+00, -3.681185e-01, -9.297789e-01 }, | |
46 { -2.733192e+00, -3.971420e-01, -9.177572e-01 }, | |
47 { -2.701776e+00, -4.257736e-01, -9.048297e-01 }, | |
48 { -2.670360e+00, -4.539849e-01, -8.910094e-01 }, | |
49 { -2.638944e+00, -4.817483e-01, -8.763097e-01 }, | |
50 { -2.607528e+00, -5.090362e-01, -8.607451e-01 }, | |
51 { -2.576112e+00, -5.358217e-01, -8.443312e-01 }, | |
52 { -2.544696e+00, -5.620785e-01, -8.270839e-01 }, | |
53 { -2.513280e+00, -5.877805e-01, -8.090204e-01 }, | |
54 { -2.481864e+00, -6.129025e-01, -7.901586e-01 }, | |
55 { -2.450448e+00, -6.374196e-01, -7.705169e-01 }, | |
56 { -2.419032e+00, -6.613076e-01, -7.501148e-01 }, | |
57 { -2.387616e+00, -6.845430e-01, -7.289724e-01 }, | |
58 { -2.356200e+00, -7.071029e-01, -7.071107e-01 }, | |
59 { -2.324784e+00, -7.289649e-01, -6.845511e-01 }, | |
60 { -2.293368e+00, -7.501075e-01, -6.613159e-01 }, | |
61 { -2.261952e+00, -7.705099e-01, -6.374281e-01 }, | |
62 { -2.230536e+00, -7.901518e-01, -6.129112e-01 }, | |
63 { -2.199120e+00, -8.090140e-01, -5.877894e-01 }, | |
64 { -2.167704e+00, -8.270777e-01, -5.620876e-01 }, | |
65 { -2.136288e+00, -8.443252e-01, -5.358310e-01 }, | |
66 { -2.104872e+00, -8.607395e-01, -5.090457e-01 }, | |
67 { -2.073456e+00, -8.763043e-01, -4.817579e-01 }, | |
68 { -2.042040e+00, -8.910044e-01, -4.539948e-01 }, | |
69 { -2.010624e+00, -9.048251e-01, -4.257835e-01 }, | |
70 { -1.979208e+00, -9.177528e-01, -3.971521e-01 }, | |
71 { -1.947792e+00, -9.297748e-01, -3.681288e-01 }, | |
72 { -1.916376e+00, -9.408793e-01, -3.387421e-01 }, | |
73 { -1.884960e+00, -9.510552e-01, -3.090212e-01 }, | |
74 { -1.853544e+00, -9.602925e-01, -2.789953e-01 }, | |
75 { -1.822128e+00, -9.685821e-01, -2.486940e-01 }, | |
76 { -1.790712e+00, -9.759158e-01, -2.181473e-01 }, | |
77 { -1.759296e+00, -9.822865e-01, -1.873854e-01 }, | |
78 { -1.727880e+00, -9.876877e-01, -1.564385e-01 }, | |
79 { -1.696464e+00, -9.921142e-01, -1.253372e-01 }, | |
80 { -1.665048e+00, -9.955616e-01, -9.411219e-02 }, | |
81 { -1.633632e+00, -9.980265e-01, -6.279433e-02 }, | |
82 { -1.602216e+00, -9.995064e-01, -3.141450e-02 }, | |
83 { -1.570800e+00, -1.000000e-00, -3.673205e-06 }, | |
84 { -1.539384e+00, -9.995067e-01, 3.140716e-02 }, | |
85 { -1.507968e+00, -9.980269e-01, 6.278700e-02 }, | |
86 { -1.476552e+00, -9.955623e-01, 9.410488e-02 }, | |
87 { -1.445136e+00, -9.921151e-01, 1.253299e-01 }, | |
88 { -1.413720e+00, -9.876889e-01, 1.564312e-01 }, | |
89 { -1.382304e+00, -9.822879e-01, 1.873781e-01 }, | |
90 { -1.350888e+00, -9.759175e-01, 2.181402e-01 }, | |
91 { -1.319472e+00, -9.685839e-01, 2.486869e-01 }, | |
92 { -1.288056e+00, -9.602945e-01, 2.789882e-01 }, | |
93 { -1.256640e+00, -9.510574e-01, 3.090142e-01 }, | |
94 { -1.225224e+00, -9.408817e-01, 3.387352e-01 }, | |
95 { -1.193808e+00, -9.297775e-01, 3.681220e-01 }, | |
96 { -1.162392e+00, -9.177557e-01, 3.971454e-01 }, | |
97 { -1.130976e+00, -9.048282e-01, 4.257769e-01 }, | |
98 { -1.099560e+00, -8.910077e-01, 4.539882e-01 }, | |
99 { -1.068144e+00, -8.763079e-01, 4.817515e-01 }, | |
100 { -1.036728e+00, -8.607433e-01, 5.090393e-01 }, | |
101 { -1.005312e+00, -8.443292e-01, 5.358248e-01 }, | |
102 { -9.738960e-01, -8.270819e-01, 5.620815e-01 }, | |
103 { -9.424800e-01, -8.090183e-01, 5.877835e-01 }, | |
104 { -9.110640e-01, -7.901563e-01, 6.129054e-01 }, | |
105 { -8.796480e-01, -7.705146e-01, 6.374224e-01 }, | |
106 { -8.482320e-01, -7.501124e-01, 6.613104e-01 }, | |
107 { -8.168160e-01, -7.289699e-01, 6.845457e-01 }, | |
108 { -7.854000e-01, -7.071081e-01, 7.071055e-01 }, | |
109 { -7.539840e-01, -6.845484e-01, 7.289674e-01 }, | |
110 { -7.225680e-01, -6.613131e-01, 7.501100e-01 }, | |
111 { -6.911520e-01, -6.374252e-01, 7.705122e-01 }, | |
112 { -6.597360e-01, -6.129083e-01, 7.901541e-01 }, | |
113 { -6.283200e-01, -5.877864e-01, 8.090161e-01 }, | |
114 { -5.969040e-01, -5.620845e-01, 8.270798e-01 }, | |
115 { -5.654880e-01, -5.358279e-01, 8.443272e-01 }, | |
116 { -5.340720e-01, -5.090425e-01, 8.607414e-01 }, | |
117 { -5.026560e-01, -4.817547e-01, 8.763061e-01 }, | |
118 { -4.712400e-01, -4.539915e-01, 8.910060e-01 }, | |
119 { -4.398240e-01, -4.257802e-01, 9.048266e-01 }, | |
120 { -4.084080e-01, -3.971488e-01, 9.177542e-01 }, | |
121 { -3.769920e-01, -3.681254e-01, 9.297762e-01 }, | |
122 { -3.455760e-01, -3.387387e-01, 9.408805e-01 }, | |
123 { -3.141600e-01, -3.090177e-01, 9.510563e-01 }, | |
124 { -2.827440e-01, -2.789917e-01, 9.602935e-01 }, | |
125 { -2.513280e-01, -2.486905e-01, 9.685830e-01 }, | |
126 { -2.199120e-01, -2.181437e-01, 9.759166e-01 }, | |
127 { -1.884960e-01, -1.873817e-01, 9.822872e-01 }, | |
128 { -1.570800e-01, -1.564348e-01, 9.876883e-01 }, | |
129 { -1.256640e-01, -1.253335e-01, 9.921147e-01 }, | |
130 { -9.424800e-02, -9.410853e-02, 9.955619e-01 }, | |
131 { -6.283200e-02, -6.279067e-02, 9.980267e-01 }, | |
132 { -3.141600e-02, -3.141083e-02, 9.995066e-01 }, | |
133 { 0.000000e+00, 0.000000e+00, 1.000000e+00 }, | |
134 { 3.141600e-02, 3.141083e-02, 9.995066e-01 }, | |
135 { 6.283200e-02, 6.279067e-02, 9.980267e-01 }, | |
136 { 9.424800e-02, 9.410853e-02, 9.955619e-01 }, | |
137 { 1.256640e-01, 1.253335e-01, 9.921147e-01 }, | |
138 { 1.570800e-01, 1.564348e-01, 9.876883e-01 }, | |
139 { 1.884960e-01, 1.873817e-01, 9.822872e-01 }, | |
140 { 2.199120e-01, 2.181437e-01, 9.759166e-01 }, | |
141 { 2.513280e-01, 2.486905e-01, 9.685830e-01 }, | |
142 { 2.827440e-01, 2.789917e-01, 9.602935e-01 }, | |
143 { 3.141600e-01, 3.090177e-01, 9.510563e-01 }, | |
144 { 3.455760e-01, 3.387387e-01, 9.408805e-01 }, | |
145 { 3.769920e-01, 3.681254e-01, 9.297762e-01 }, | |
146 { 4.084080e-01, 3.971488e-01, 9.177542e-01 }, | |
147 { 4.398240e-01, 4.257802e-01, 9.048266e-01 }, | |
148 { 4.712400e-01, 4.539915e-01, 8.910060e-01 }, | |
149 { 5.026560e-01, 4.817547e-01, 8.763061e-01 }, | |
150 { 5.340720e-01, 5.090425e-01, 8.607414e-01 }, | |
151 { 5.654880e-01, 5.358279e-01, 8.443272e-01 }, | |
152 { 5.969040e-01, 5.620845e-01, 8.270798e-01 }, | |
153 { 6.283200e-01, 5.877864e-01, 8.090161e-01 }, | |
154 { 6.597360e-01, 6.129083e-01, 7.901541e-01 }, | |
155 { 6.911520e-01, 6.374252e-01, 7.705122e-01 }, | |
156 { 7.225680e-01, 6.613131e-01, 7.501100e-01 }, | |
157 { 7.539840e-01, 6.845484e-01, 7.289674e-01 }, | |
158 { 7.854000e-01, 7.071081e-01, 7.071055e-01 }, | |
159 { 8.168160e-01, 7.289699e-01, 6.845457e-01 }, | |
160 { 8.482320e-01, 7.501124e-01, 6.613104e-01 }, | |
161 { 8.796480e-01, 7.705146e-01, 6.374224e-01 }, | |
162 { 9.110640e-01, 7.901563e-01, 6.129054e-01 }, | |
163 { 9.424800e-01, 8.090183e-01, 5.877835e-01 }, | |
164 { 9.738960e-01, 8.270819e-01, 5.620815e-01 }, | |
165 { 1.005312e+00, 8.443292e-01, 5.358248e-01 }, | |
166 { 1.036728e+00, 8.607433e-01, 5.090393e-01 }, | |
167 { 1.068144e+00, 8.763079e-01, 4.817515e-01 }, | |
168 { 1.099560e+00, 8.910077e-01, 4.539882e-01 }, | |
169 { 1.130976e+00, 9.048282e-01, 4.257769e-01 }, | |
170 { 1.162392e+00, 9.177557e-01, 3.971454e-01 }, | |
171 { 1.193808e+00, 9.297775e-01, 3.681220e-01 }, | |
172 { 1.225224e+00, 9.408817e-01, 3.387352e-01 }, | |
173 { 1.256640e+00, 9.510574e-01, 3.090142e-01 }, | |
174 { 1.288056e+00, 9.602945e-01, 2.789882e-01 }, | |
175 { 1.319472e+00, 9.685839e-01, 2.486869e-01 }, | |
176 { 1.350888e+00, 9.759175e-01, 2.181402e-01 }, | |
177 { 1.382304e+00, 9.822879e-01, 1.873781e-01 }, | |
178 { 1.413720e+00, 9.876889e-01, 1.564312e-01 }, | |
179 { 1.445136e+00, 9.921151e-01, 1.253299e-01 }, | |
180 { 1.476552e+00, 9.955623e-01, 9.410488e-02 }, | |
181 { 1.507968e+00, 9.980269e-01, 6.278700e-02 }, | |
182 { 1.539384e+00, 9.995067e-01, 3.140716e-02 }, | |
183 { 1.570800e+00, 1.000000e-00, -3.673205e-06 }, | |
184 { 1.602216e+00, 9.995064e-01, -3.141450e-02 }, | |
185 { 1.633632e+00, 9.980265e-01, -6.279433e-02 }, | |
186 { 1.665048e+00, 9.955616e-01, -9.411219e-02 }, | |
187 { 1.696464e+00, 9.921142e-01, -1.253372e-01 }, | |
188 { 1.727880e+00, 9.876877e-01, -1.564385e-01 }, | |
189 { 1.759296e+00, 9.822865e-01, -1.873854e-01 }, | |
190 { 1.790712e+00, 9.759158e-01, -2.181473e-01 }, | |
191 { 1.822128e+00, 9.685821e-01, -2.486940e-01 }, | |
192 { 1.853544e+00, 9.602925e-01, -2.789953e-01 }, | |
193 { 1.884960e+00, 9.510552e-01, -3.090212e-01 }, | |
194 { 1.916376e+00, 9.408793e-01, -3.387421e-01 }, | |
195 { 1.947792e+00, 9.297748e-01, -3.681288e-01 }, | |
196 { 1.979208e+00, 9.177528e-01, -3.971521e-01 }, | |
197 { 2.010624e+00, 9.048251e-01, -4.257835e-01 }, | |
198 { 2.042040e+00, 8.910044e-01, -4.539948e-01 }, | |
199 { 2.073456e+00, 8.763043e-01, -4.817579e-01 }, | |
200 { 2.104872e+00, 8.607395e-01, -5.090457e-01 }, | |
201 { 2.136288e+00, 8.443252e-01, -5.358310e-01 }, | |
202 { 2.167704e+00, 8.270777e-01, -5.620876e-01 }, | |
203 { 2.199120e+00, 8.090140e-01, -5.877894e-01 }, | |
204 { 2.230536e+00, 7.901518e-01, -6.129112e-01 }, | |
205 { 2.261952e+00, 7.705099e-01, -6.374281e-01 }, | |
206 { 2.293368e+00, 7.501075e-01, -6.613159e-01 }, | |
207 { 2.324784e+00, 7.289649e-01, -6.845511e-01 }, | |
208 { 2.356200e+00, 7.071029e-01, -7.071107e-01 }, | |
209 { 2.387616e+00, 6.845430e-01, -7.289724e-01 }, | |
210 { 2.419032e+00, 6.613076e-01, -7.501148e-01 }, | |
211 { 2.450448e+00, 6.374196e-01, -7.705169e-01 }, | |
212 { 2.481864e+00, 6.129025e-01, -7.901586e-01 }, | |
213 { 2.513280e+00, 5.877805e-01, -8.090204e-01 }, | |
214 { 2.544696e+00, 5.620785e-01, -8.270839e-01 }, | |
215 { 2.576112e+00, 5.358217e-01, -8.443312e-01 }, | |
216 { 2.607528e+00, 5.090362e-01, -8.607451e-01 }, | |
217 { 2.638944e+00, 4.817483e-01, -8.763097e-01 }, | |
218 { 2.670360e+00, 4.539849e-01, -8.910094e-01 }, | |
219 { 2.701776e+00, 4.257736e-01, -9.048297e-01 }, | |
220 { 2.733192e+00, 3.971420e-01, -9.177572e-01 }, | |
221 { 2.764608e+00, 3.681185e-01, -9.297789e-01 }, | |
222 { 2.796024e+00, 3.387318e-01, -9.408830e-01 }, | |
223 { 2.827440e+00, 3.090107e-01, -9.510586e-01 }, | |
224 { 2.858856e+00, 2.789847e-01, -9.602956e-01 }, | |
225 { 2.890272e+00, 2.486833e-01, -9.685848e-01 }, | |
226 { 2.921688e+00, 2.181366e-01, -9.759183e-01 }, | |
227 { 2.953104e+00, 1.873745e-01, -9.822885e-01 }, | |
228 { 2.984520e+00, 1.564276e-01, -9.876894e-01 }, | |
229 { 3.015936e+00, 1.253262e-01, -9.921156e-01 }, | |
230 { 3.047352e+00, 9.410122e-02, -9.955626e-01 }, | |
231 { 3.078768e+00, 6.278333e-02, -9.980272e-01 }, | |
232 { 3.110184e+00, 3.140349e-02, -9.995068e-01 }, | |
233 { 3.141600e+00, -7.346410e-06, -1.000000e-00 } | |
234 }; | |
235 | |
30990 | 236 #define M_PI 3.14159265358979323846 /* pi */ |
22691 | 237 |
238 static double inline gen_sin(double x) | |
239 { | |
240 int i; | |
241 if(x < 0) while(x < -M_PI) x+= M_PI; | |
242 else while(x > M_PI) x-= M_PI; | |
243 for(i=0;i<sizeof(g_sincos)/sizeof(gen_sincos_t)-1;i++) | |
244 { | |
245 if(x>=g_sincos[i].x && x <= g_sincos[i+1].x) | |
246 { | |
247 return (g_sincos[i+1].sinx-g_sincos[i].sinx)*(x-g_sincos[i].x)/(g_sincos[i+1].x-g_sincos[i].x)+g_sincos[i].sinx; | |
248 } | |
249 } | |
250 return x<0?1:-1; | |
251 } | |
252 #undef sin | |
253 #define sin(x) gen_sin(x) | |
254 | |
255 static double inline gen_cos(double x) | |
256 { | |
257 int i; | |
258 if(x < 0) while(x < -M_PI) x+= M_PI; | |
259 else while(x > M_PI) x-= M_PI; | |
260 for(i=0;i<sizeof(g_sincos)/sizeof(gen_sincos_t)-1;i++) | |
261 { | |
262 if(x>=g_sincos[i].x && x <= g_sincos[i+1].x) | |
263 { | |
264 return (g_sincos[i+1].cosx-g_sincos[i].cosx)*(x-g_sincos[i].x)/(g_sincos[i+1].x-g_sincos[i].x)+g_sincos[i].cosx; | |
265 } | |
266 } | |
267 return x<0?1:-1; | |
268 } | |
269 #undef cos | |
270 #define cos(x) gen_cos(x) | |
271 | |
26029 | 272 #endif /* MPLAYER_GENERIC_MATH_H */ |