~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/mpcdec/fastmath.c

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2014-11-08 11:36:07 UTC
  • mfrom: (1.2.18) (10.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20141108113607-3lbwsamqqhrso4hp
Tags: 0.9.36.5-1
* New upstream release, uploaded to expermiental for the Jessie freeze.
* Standards-Version 3.9.6, no change required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Musepack audio compression
3
 
 * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
4
 
 *
5
 
 * This library is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU Lesser General Public
7
 
 * License as published by the Free Software Foundation; either
8
 
 * version 2.1 of the License, or (at your option) any later version.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
 * Lesser General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 */
19
 
 
20
 
#include "mpc/mpcmath.h"
21
 
 
22
 
#ifdef FAST_MATH
23
 
 
24
 
const float  tabatan2   [ 2*TABSTEP+1] [2];
25
 
const float  tabcos     [26*TABSTEP+1] [2];
26
 
const float  tabsqrt_ex [256];
27
 
const float  tabsqrt_m  [   TABSTEP+1] [2];
28
 
 
29
 
 
30
 
void   Init_FastMath ( void )
31
 
{
32
 
    int i; mpc_floatint X, Y; double xm, x0, xp, x, y; float* p;
33
 
 
34
 
    p = (float*) tabatan2;
35
 
    for ( i = -TABSTEP; i <= TABSTEP; i++ ) {
36
 
        xm = atan ((i-0.5)/TABSTEP);
37
 
        x0 = atan ((i+0.0)/TABSTEP);
38
 
        xp = atan ((i+0.5)/TABSTEP);
39
 
        x  = x0/2 + (xm + xp)/4;
40
 
        y  = xp - xm;
41
 
        *p++ = x;
42
 
        *p++ = y;
43
 
    }
44
 
 
45
 
    p = (float*) tabcos;
46
 
    for ( i = -13*TABSTEP; i <= 13*TABSTEP; i++ ) {
47
 
        xm = cos ((i-0.5)/TABSTEP);
48
 
        x0 = cos ((i+0.0)/TABSTEP);
49
 
        xp = cos ((i+0.5)/TABSTEP);
50
 
        x  = x0/2 + (xm + xp)/4;
51
 
        y  = xp - xm;
52
 
        *p++ = x;
53
 
        *p++ = y;
54
 
    }
55
 
 
56
 
    p = (float*) tabsqrt_ex;
57
 
    for ( i = 0; i < 255; i++ ) {
58
 
        X.n = (i << 23);
59
 
        Y.n = (i << 23) + (1<<23) - 1;
60
 
        *p++ = sqrt(X.f);
61
 
    }
62
 
    X.n  = (255 << 23) - 1;
63
 
    *p++ = sqrt(X.f);
64
 
 
65
 
    p = (float*) tabsqrt_m;
66
 
    for ( i = 1*TABSTEP; i <= 2*TABSTEP; i++ ) {
67
 
        xm = sqrt ((i-0.5)/TABSTEP);
68
 
        x0 = sqrt ((i+0.0)/TABSTEP);
69
 
        xp = sqrt ((i+0.5)/TABSTEP);
70
 
        x  = x0/2 + (xm + xp)/4;
71
 
        y  = xp - xm;
72
 
        *p++ = x;
73
 
        *p++ = y;
74
 
    }
75
 
}
76
 
 
77
 
#endif