annotate decoders/mpglib/tabinit.c @ 420:5b8a07b5162e

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