PageRenderTime 22ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/project/jni/sdl_sound/decoders/mpglib/tabinit.c

https://github.com/aichunyu/FFPlayer
C | 80 lines | 68 code | 12 blank | 0 comment | 14 complexity | 15c576fd78af2cbb8c7efb2f5be14383 MD5 | raw file
 1
 2#include <stdlib.h>
 3
 4#include "mpg123_sdlsound.h"
 5
 6real decwin[512+32];
 7static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1];
 8real *pnts[] = { cos64,cos32,cos16,cos8,cos4 };
 9
10#if 0
11static unsigned char *conv16to8_buf = NULL;
12unsigned char *conv16to8;
13#endif
14
15static long intwinbase[] = {
16     0,    -1,    -1,    -1,    -1,    -1,    -1,    -2,    -2,    -2,
17    -2,    -3,    -3,    -4,    -4,    -5,    -5,    -6,    -7,    -7,
18    -8,    -9,   -10,   -11,   -13,   -14,   -16,   -17,   -19,   -21,
19   -24,   -26,   -29,   -31,   -35,   -38,   -41,   -45,   -49,   -53,
20   -58,   -63,   -68,   -73,   -79,   -85,   -91,   -97,  -104,  -111,
21  -117,  -125,  -132,  -139,  -147,  -154,  -161,  -169,  -176,  -183,
22  -190,  -196,  -202,  -208,  -213,  -218,  -222,  -225,  -227,  -228,
23  -228,  -227,  -224,  -221,  -215,  -208,  -200,  -189,  -177,  -163,
24  -146,  -127,  -106,   -83,   -57,   -29,     2,    36,    72,   111,
25   153,   197,   244,   294,   347,   401,   459,   519,   581,   645,
26   711,   779,   848,   919,   991,  1064,  1137,  1210,  1283,  1356,
27  1428,  1498,  1567,  1634,  1698,  1759,  1817,  1870,  1919,  1962,
28  2001,  2032,  2057,  2075,  2085,  2087,  2080,  2063,  2037,  2000,
29  1952,  1893,  1822,  1739,  1644,  1535,  1414,  1280,  1131,   970,
30   794,   605,   402,   185,   -45,  -288,  -545,  -814, -1095, -1388,
31 -1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
32 -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
33 -8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
34 -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
35 -7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
36   -70,   998,  2122,  3300,  4533,  5818,  7154,  8540,  9975, 11455,
37 12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
38 30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
39 48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
40 64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
41 73415, 73908, 74313, 74630, 74856, 74992, 75038 };
42
43void make_decode_tables(long scaleval)
44{
45  int i,j,k,kr,divv;
46  real *table,*costab;
47
48  
49  for(i=0;i<5;i++)
50  {
51    kr=0x10>>i; divv=0x40>>i;
52    costab = pnts[i];
53    for(k=0;k<kr;k++)
54      costab[k] = 1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv));
55  }
56
57  table = decwin;
58  scaleval = -scaleval;
59  for(i=0,j=0;i<256;i++,j++,table+=32)
60  {
61    if(table < decwin+512+16)
62      table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
63    if(i % 32 == 31)
64      table -= 1023;
65    if(i % 64 == 63)
66      scaleval = - scaleval;
67  }
68
69  for( /* i=256 */ ;i<512;i++,j--,table+=32)
70  {
71    if(table < decwin+512+16)
72      table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
73    if(i % 32 == 31)
74      table -= 1023;
75    if(i % 64 == 63)
76      scaleval = - scaleval;
77  }
78}
79
80