Debian Codegraph @

src/libmpg123/init_layer12.h

raw
1 /*
2 The function to compute the layer I and II tables at runtime or for pregeneration.
3
4 copyright ?-2021 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Michael Hipp (in layer2.c).
7
8 The type clreal is either double or float. POW() is pow() or powf().
9 */
10
11 void INT123_init_layer12(void)
12 {
13 const clreal mulmul[27] =
14 {
15 0.0 , -2.0/3.0 , 2.0/3.0 ,
16 2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 ,
17 2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 ,
18 2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 ,
19 -4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 ,
20 -8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0
21 };
22 // void INT123_init_layer12_stuff()
23 // real* INT123_init_layer12_table()
24 for(int k=0;k<27;k++)
25 {
26 int i,j;
27 clreal *table = layer12_table[k];
28 for(j=3,i=0;i<63;i++,j--)
29 *table++ = mulmul[k] * POW(2.0,(clreal) j / 3.0);
30 *table++ = 0.0;
31 }
32
33 // void INT123_init_layer12()
34 const unsigned char base[3][9] =
35 {
36 { 1 , 0, 2 , } ,
37 { 17, 18, 0 , 19, 20 , } ,
38 { 21, 1, 22, 23, 0, 24, 25, 2, 26 }
39 };
40 int i,j,k,l,len;
41 const int tablen[3] = { 3 , 5 , 9 };
42 unsigned char *itable;
43 unsigned char *tables[3] = { grp_3tab , grp_5tab , grp_9tab };
44
45 for(i=0;i<3;i++)
46 {
47 itable = tables[i];
48 len = tablen[i];
49 for(j=0;j<len;j++)
50 for(k=0;k<len;k++)
51 for(l=0;l<len;l++)
52 {
53 *itable++ = base[i][l];
54 *itable++ = base[i][k];
55 *itable++ = base[i][j];
56 }
57 }
58 }