annotate mp3lib/layer3.c @ 6766:f7cd3a7aaa13

Applied patch by Fabian Franz <FabianFranz@gmx.de>, adding a note to the TV section and correcting a keyboard control. Reviewed the TV section, realigned the table and reworded the entries.
author diego
date Mon, 22 Jul 2002 11:25:01 +0000
parents 03b7e2955a20
children 140fcbd20c18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 * Mpeg Layer-3 audio decoder
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * --------------------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * copyright (c) 1995,1996,1997 by Michael Hipp.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * All rights reserved. See also 'README'
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * - I'm currently working on that .. needs a few more optimizations,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * though the code is now fast enough to run in realtime on a 100Mhz 486
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * - a few personal notes are in german ..
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * used source:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * mpeg1_iis package
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 static real ispow[8207];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 static real aa_ca[8],aa_cs[8];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 static real COS1[12][6];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 static real win[4][36];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 static real win1[4][36];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #define GP2MAX (256+118+4)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 static real gainpow2[GP2MAX];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
25 real COS9[9];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 static real COS6_1,COS6_2;
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
27 real tfcos36[9];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 static real tfcos12[3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #ifdef NEW_DCT9
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 static real cos9[3],cos18[3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 struct bandInfoStruct {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 int longIdx[23];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 int longDiff[22];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 int shortIdx[14];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 int shortDiff[13];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 int longLimit[9][23];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 int shortLimit[9][14];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 struct bandInfoStruct bandInfo[9] = {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 /* MPEG 1.0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 { {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 {4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 {0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 {4,4,4,4,6,8,10,12,14,18,22,30,56} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 { {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 {4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 {0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 {4,4,4,4,6,6,10,12,14,16,20,26,66} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 { {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 {4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 {0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 {4,4,4,4,6,8,12,16,20,26,34,42,12} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 /* MPEG 2.0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 {0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 {4,4,4,6,6,8,10,14,18,26,32,42,18 } } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 { {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 {6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,52,64,70,76,36 } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 {4,4,4,6,8,10,12,14,18,24,32,44,12 } } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 },
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 {4,4,4,6,8,10,12,14,18,24,30,40,18 } } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 /* MPEG 2.5 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 {4,4,4,6,8,10,12,14,18,24,30,40,18} },
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 {4,4,4,6,8,10,12,14,18,24,30,40,18} },
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 { {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 {12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 {0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 {8,8,8,12,16,20,24,28,36,2,2,2,26} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 static int mapbuf0[9][152];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 static int mapbuf1[9][156];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 static int mapbuf2[9][44];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 static int *map[9][3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 static int *mapend[9][3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 static real tan1_1[16],tan2_1[16],tan1_2[16],tan2_2[16];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 static real pow1_1[2][16],pow2_1[2][16],pow1_2[2][16],pow2_2[2][16];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 * init tables for layer-3
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 void init_layer3(int down_sample_sblimit)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 int i,j,k,l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 for(i=-256;i<118+4;i++)
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
114 {
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
115 if(_has_mmx)
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
116 gainpow2[i+256] = 16384.0 * pow((double)2.0,-0.25 * (double) (i+210) );
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
117 else
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
118 gainpow2[i+256] = pow((double)2.0,-0.25 * (double) (i+210) );
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
119 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 for(i=0;i<8207;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 ispow[i] = pow((double)i,(double)4.0/3.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 for (i=0;i<8;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 static double Ci[8]={-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 double sq=sqrt(1.0+Ci[i]*Ci[i]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 aa_cs[i] = 1.0/sq;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 aa_ca[i] = Ci[i]/sq;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 for(i=0;i<18;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 win[0][i] = win[1][i] = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+0) +1) ) / cos ( M_PI * (double) (2*(i+0) +19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 win[0][i+18] = win[3][i+18] = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+18)+1) ) / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 for(i=0;i<6;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 win[1][i+18] = 0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 win[3][i+12] = 0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 win[1][i+24] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 win[1][i+30] = win[3][i] = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 win[3][i+6 ] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 for(i=0;i<9;i++)
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
146 COS9[i] = cos( M_PI / 18.0 * (double) i);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 for(i=0;i<9;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 tfcos36[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 for(i=0;i<3;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 tfcos12[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 COS6_1 = cos( M_PI / 6.0 * (double) 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 COS6_2 = cos( M_PI / 6.0 * (double) 2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 #ifdef NEW_DCT9
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 cos9[0] = cos(1.0*M_PI/9.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 cos9[1] = cos(5.0*M_PI/9.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 cos9[2] = cos(7.0*M_PI/9.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 cos18[0] = cos(1.0*M_PI/18.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 cos18[1] = cos(11.0*M_PI/18.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 cos18[2] = cos(13.0*M_PI/18.0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 for(i=0;i<12;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 win[2][i] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 for(j=0;j<6;j++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 COS1[i][j] = cos( M_PI / 24.0 * (double) ((2*i+7)*(2*j+1)) );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 for(j=0;j<4;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 static int len[4] = { 36,36,12,36 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 for(i=0;i<len[j];i+=2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 win1[j][i] = + win[j][i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 for(i=1;i<len[j];i+=2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 win1[j][i] = - win[j][i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 for(i=0;i<16;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 double t = tan( (double) i * M_PI / 12.0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 tan1_1[i] = t / (1.0+t);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 tan2_1[i] = 1.0 / (1.0 + t);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 tan1_2[i] = M_SQRT2 * t / (1.0+t);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 tan2_2[i] = M_SQRT2 / (1.0 + t);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 for(j=0;j<2;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 double base = pow(2.0,-0.25*(j+1.0));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 double p1=1.0,p2=1.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 if(i > 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 if( i & 1 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 p1 = pow(base,(i+1.0)*0.5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 p2 = pow(base,i*0.5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 pow1_1[j][i] = p1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 pow2_1[j][i] = p2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 pow1_2[j][i] = M_SQRT2 * p1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 pow2_2[j][i] = M_SQRT2 * p2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 for(j=0;j<9;j++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 struct bandInfoStruct *bi = &bandInfo[j];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 int *mp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 int cb,lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 int *bdf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 mp = map[j][0] = mapbuf0[j];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 bdf = bi->longDiff;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 *mp++ = (*bdf) >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 *mp++ = i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 *mp++ = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 *mp++ = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 bdf = bi->shortDiff+3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 for(cb=3;cb<13;cb++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 int l = (*bdf++) >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 for(lwin=0;lwin<3;lwin++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 *mp++ = l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 *mp++ = i + lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 *mp++ = lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 *mp++ = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 i += 6*l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 mapend[j][0] = mp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 mp = map[j][1] = mapbuf1[j];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 bdf = bi->shortDiff+0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 for(i=0,cb=0;cb<13;cb++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 int l = (*bdf++) >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 for(lwin=0;lwin<3;lwin++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 *mp++ = l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 *mp++ = i + lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 *mp++ = lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 *mp++ = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 i += 6*l;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 mapend[j][1] = mp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 mp = map[j][2] = mapbuf2[j];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 bdf = bi->longDiff;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 for(cb = 0; cb < 22 ; cb++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 *mp++ = (*bdf++) >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 *mp++ = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 mapend[j][2] = mp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 for(j=0;j<9;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 for(i=0;i<23;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 if(longLimit[j][i] > (down_sample_sblimit) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 longLimit[j][i] = down_sample_sblimit;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 for(i=0;i<14;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 if(shortLimit[j][i] > (down_sample_sblimit) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 shortLimit[j][i] = down_sample_sblimit;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 for(i=0;i<5;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 for(j=0;j<6;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 for(k=0;k<6;k++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 int n = k + j * 6 + i * 36;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 i_slen2[n] = i|(j<<3)|(k<<6)|((long)3<<12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 for(j=0;j<4;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 for(k=0;k<4;k++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 int n = k + j * 4 + i * 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 i_slen2[n+180] = i|(j<<3)|(k<<6)|((long)4<<12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 for(j=0;j<3;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 int n = j + i * 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 i_slen2[n+244] = i|(j<<3) | ((long)5<<12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 n_slen2[n+500] = i|(j<<3) | ((long)2<<12) | ((long)1<<15);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 for(i=0;i<5;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 for(j=0;j<5;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 for(k=0;k<4;k++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 for(l=0;l<4;l++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 int n = l + k * 4 + j * 16 + i * 80;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|((long)0<<12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 for(i=0;i<5;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 for(j=0;j<5;j++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 for(k=0;k<4;k++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 int n = k + j * 4 + i * 20;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 n_slen2[n+400] = i|(j<<3)|(k<<6)|((long)1<<12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 } /* init_layer3() */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 /* ========================== READ FRAME DATA ========================= */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 LOCAL real Gainpow2(int i){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 // if(i<0) i=0; else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 // if(i>=GP2MAX) i=GP2MAX-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 // return gainpow2[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 return gainpow2[((i)<0)?0:( ((i)<GP2MAX)?(i):(GP2MAX-1) )];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 #define Gainpow2(i) gainpow2[((i)<0)?0:( ((i)<GP2MAX)?(i):(GP2MAX-1) )]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 * read additional side information
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 static void III_get_side_info_1(struct III_sideinfo *si,int stereo,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 int ms_stereo,long sfreq,int single)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 int ch, gr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 int powdiff = (single == 3) ? 4 : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 si->main_data_begin = getbits(9);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 if (stereo == 1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 si->private_bits = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 si->private_bits = getbits_fast(3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 for (ch=0; ch<stereo; ch++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 si->ch[ch].gr[0].scfsi = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 si->ch[ch].gr[1].scfsi = getbits_fast(4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 for (gr=0; gr<2; gr++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 for (ch=0; ch<stereo; ch++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 gr_info->part2_3_length = getbits(12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 gr_info->big_values = getbits(9);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 if(gr_info->big_values > 288) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 printf("\rbig_values too large! \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 gr_info->big_values = 288;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 gr_info->pow2gain = 256 - getbits_fast(8) + powdiff;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 if(ms_stereo) gr_info->pow2gain += 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 gr_info->scalefac_compress = getbits_fast(4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 /* window-switching flag==1 (block_Type!=0) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 gr_info->block_type = getbits_fast(2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 gr_info->mixed_block_flag = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 gr_info->table_select[0] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 gr_info->table_select[1] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369 * table_select[2] not needed, because there is no region2,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 * but to satisfy some verifications tools we set it either.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 gr_info->table_select[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 for(i=0;i<3;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 if(gr_info->block_type == 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 printf("\rBlocktype == 0 and window-switching == 1 not allowed. \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 /* region_count/start parameters are implicit in this case. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 gr_info->region1start = 36>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 gr_info->region2start = 576>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 /* window-switching flag==0 (block_Type==0) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 int i,r0c,r1c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 for (i=0; i<3; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 gr_info->table_select[i] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 r0c = getbits_fast(4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 r1c = getbits_fast(3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 gr_info->block_type = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 gr_info->mixed_block_flag = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 gr_info->preflag = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 gr_info->scalefac_scale = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 gr_info->count1table_select = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 * Side Info for MPEG 2.0 / LSF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 static void III_get_side_info_2(struct III_sideinfo *si,int stereo,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 int ms_stereo,long sfreq,int single)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 int ch;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 int powdiff = (single == 3) ? 4 : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 si->main_data_begin = getbits(8);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 if (stereo == 1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 si->private_bits = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 si->private_bits = getbits_fast(2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 for (ch=0; ch<stereo; ch++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 register struct gr_info_s *gr_info = &(si->ch[ch].gr[0]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 gr_info->part2_3_length = getbits(12);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 gr_info->big_values = getbits(9);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 if(gr_info->big_values > 288) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 printf("\rbig_values too large! \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 gr_info->big_values = 288;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 gr_info->pow2gain = 256 - getbits_fast(8) + powdiff;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 if(ms_stereo)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 gr_info->pow2gain += 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 gr_info->scalefac_compress = getbits(9);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 /* window-switching flag==1 (block_Type!=0) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 gr_info->block_type = getbits_fast(2);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 gr_info->mixed_block_flag = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 gr_info->table_select[0] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 gr_info->table_select[1] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 * table_select[2] not needed, because there is no region2,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 * but to satisfy some verifications tools we set it either.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 gr_info->table_select[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 for(i=0;i<3;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 if(gr_info->block_type == 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 printf("\rBlocktype == 0 and window-switching == 1 not allowed. \n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 /* region_count/start parameters are implicit in this case. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 /* check this again! */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 if(gr_info->block_type == 2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 gr_info->region1start = 36>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 else if(sfreq == 8)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 /* check this for 2.5 and sfreq=8 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 gr_info->region1start = 108>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 gr_info->region1start = 54>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 gr_info->region2start = 576>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 /* window-switching flag==0 (block_Type==0) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 int i,r0c,r1c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 for (i=0; i<3; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 gr_info->table_select[i] = getbits_fast(5);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 r0c = getbits_fast(4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 r1c = getbits_fast(3);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 gr_info->block_type = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 gr_info->mixed_block_flag = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 gr_info->scalefac_scale = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 gr_info->count1table_select = get1bit();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
478 * read scalefactors
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 static int III_get_scale_factors_1(int *scf,struct gr_info_s *gr_info)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 static unsigned char slen[2][16] = {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484 {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486 int numbits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 int num0 = slen[0][gr_info->scalefac_compress];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488 int num1 = slen[1][gr_info->scalefac_compress];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
489
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
490 if (gr_info->block_type == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
491 int i=18;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
492 numbits = (num0 + num1) * 18;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 if (gr_info->mixed_block_flag) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494 for (i=8;i;i--) *scf++ = getbits(num0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
495 i = 9;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
496 numbits -= num0; /* num0 * 17 + num1 * 18 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
497 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
498 for (;i;i--) *scf++ = getbits(num0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
499 for (i = 18; i; i--) *scf++ = getbits(num1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
500 *scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
501 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
502 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
503 int scfsi = gr_info->scfsi;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
504
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505 if(scfsi < 0) { /* scfsi < 0 => granule == 0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 for(i=11;i;i--) *scf++ = getbits(num0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
507 for(i=10;i;i--) *scf++ = getbits(num1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 numbits = (num0 + num1) * 10 + num0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
509 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
510 numbits = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 if(!(scfsi & 0x8)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
512 for (i=6;i;i--) *scf++ = getbits(num0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
513 numbits += num0 * 6;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
515 scf += 6;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
516 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
517 if(!(scfsi & 0x4)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
518 for (i=5;i;i--) *scf++ = getbits(num0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
519 numbits += num0 * 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
520 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
521 scf += 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
522 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
523 if(!(scfsi & 0x2)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
524 for(i=5;i;i--) *scf++ = getbits(num1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
525 numbits += num1 * 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
526 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
527 scf += 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
528 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
529 if(!(scfsi & 0x1)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
530 for (i=5;i;i--) *scf++ = getbits(num1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
531 numbits += num1 * 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
532 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
533 scf += 5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
534 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
535 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
536
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
537 *scf++ = 0; /* no l[21] in original sources */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
538 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
539 return numbits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
540 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
541
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
542 static int III_get_scale_factors_2(int *scf,struct gr_info_s *gr_info,int i_stereo)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
543 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
544 unsigned char *pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
545 int i,j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
546 unsigned int slen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
547 int n = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
548 int numbits = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
549
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
550 static unsigned char stab[3][6][4] = {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
551 { { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
552 { 7, 7, 7,0 } , { 6, 6, 6,3 } , { 8, 8,5,0} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
553 { { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
554 {12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0} } ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
555 { { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0} ,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
556 { 6,15,12,0 } , { 6,12, 9,6 } , { 6,18,9,0} } };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
557
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
558 if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
559 slen = i_slen2[gr_info->scalefac_compress>>1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
560 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
561 slen = n_slen2[gr_info->scalefac_compress];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
562
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
563 gr_info->preflag = (slen>>15) & 0x1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
564
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
565 n = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
566 if( gr_info->block_type == 2 ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
567 n++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
568 if(gr_info->mixed_block_flag) n++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
569 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
570
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
571 pnt = stab[n][(slen>>12)&0x7];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
572
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
573 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
574 int num = slen & 0x7;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
575 slen >>= 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
576 if(num) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
577 for(j=0;j<(int)(pnt[i]);j++) *scf++ = getbits_fast(num);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
578 numbits += pnt[i] * num;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
579 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
580 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
581 for(j=0;j<(int)(pnt[i]);j++) *scf++ = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
582 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
583 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
584
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
585 n = (n << 1) + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
586 for(i=0;i<n;i++) *scf++ = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
587
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
588 return numbits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
589 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591 static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
592 static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
593
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
594 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 * don't forget to apply the same changes to III_dequantize_sample_ms() !!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
596 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
597 static int III_dequantize_sample(real xr[SBLIMIT][SSLIMIT],int *scf,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
598 struct gr_info_s *gr_info,int sfreq,int part2bits)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
599 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
600 int shift = 1 + gr_info->scalefac_scale;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
601 real *xrpnt = (real *) xr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
602 int l[3],l3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
603 int part2remain = gr_info->part2_3_length - part2bits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
604 int *me;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
605
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
606 { int bv = gr_info->big_values;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
607 int region1 = gr_info->region1start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
608 int region2 = gr_info->region2start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
609
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
610 l3 = ((576>>1)-bv)>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
611 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
612 * we may lose the 'odd' bit here !!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
613 * check this later again
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
614 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
615 if(bv <= region1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
616 l[0] = bv; l[1] = 0; l[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
617 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
618 l[0] = region1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
619 if(bv <= region2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
620 l[1] = bv - l[0]; l[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
621 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
622 l[1] = region2 - l[0]; l[2] = bv - region2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
623 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
624 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
625 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
626
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
627 if(gr_info->block_type == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
628 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
629 * decoding with short or mixed mode BandIndex table
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
630 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
631 int i,max[4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
632 int step=0,lwin=0,cb=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
633 register real v = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
634 register int *m,mc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
635
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
636 if(gr_info->mixed_block_flag) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
637 max[3] = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
638 max[0] = max[1] = max[2] = 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
639 m = map[sfreq][0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
640 me = mapend[sfreq][0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
641 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
642 max[0] = max[1] = max[2] = max[3] = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
643 /* max[3] not really needed in this case */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
644 m = map[sfreq][1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
645 me = mapend[sfreq][1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
646 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
647
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
648 mc = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
649 for(i=0;i<2;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
650 int lp = l[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
651 struct newhuff *h = ht+gr_info->table_select[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
652 for(;lp;lp--,mc--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
653 register int x,y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
654 if( (!mc) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
655 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
656 xrpnt = ((real *) xr) + (*m++);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
657 lwin = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
658 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
659 if(lwin == 3) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
660 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
661 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
662 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
663 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
664 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
665 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
666 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
667 { register short *val = h->table;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
668 while((y=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
669 part2remain--;
716
946170f9ed39 segfault fixed - maybe
arpi_esp
parents: 1
diff changeset
670 if(part2remain < 0) return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
671 if (get1bit()) val-=y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
672 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
673 x = y >> 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
674 y &= 0xf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
675 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
676 if(x == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
677 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
678 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
679 x += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
680 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
681 *xrpnt = -ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
682 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
683 *xrpnt = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
684 } else if(x) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
685 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
686 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
687 *xrpnt = -ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
688 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
689 *xrpnt = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
690 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
691 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
692 *xrpnt = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
693 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
694 if(y == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
695 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
696 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
697 y += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
698 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
699 *xrpnt = -ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
700 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
701 *xrpnt = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
702 } else if(y) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
703 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
704 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
705 *xrpnt = -ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
706 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
707 *xrpnt = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
708 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
709 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
710 *xrpnt = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
711 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
712 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
713 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
714
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
715 for(;l3 && (part2remain > 0);l3--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
716 struct newhuff *h = htc+gr_info->count1table_select;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
717 register short *val = h->table,a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
718
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
719 while((a=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
720 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
721 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
722 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
723 a = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
724 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
725 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
726 if (get1bit()) val-=a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
727 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
728
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
729 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
730 if(!(i & 1)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
731 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
732 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
733 xrpnt = ((real *) xr) + (*m++);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
734 lwin = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
735 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
736 if(lwin == 3) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
737 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
738 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
739 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
740 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
741 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
742 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
743 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
744 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
745 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
746 if( (a & (0x8>>i)) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
747 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
748 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
749 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
750 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
751 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
752 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
753 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
754 *xrpnt = -v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
755 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
756 *xrpnt = v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
757 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
758 *xrpnt = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
759 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
760 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
761 } // for(;l3 && (part2remain > 0);l3--)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
762
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
763 while( m < me ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
764 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
765 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
766 xrpnt = ((real *) xr) + *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
767 if( (*m++) == 3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
768 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
769 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
770 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
771 m++; /* cb */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
772 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
773 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
774 *xrpnt = 0.0; xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
775 *xrpnt = 0.0; xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
776 /* we could add a little opt. here:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
777 * if we finished a band for window 3 or a long band
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
778 * further bands could copied in a simple loop without a
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
779 * special 'map' decoding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
780 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
781 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
782
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
783 gr_info->maxband[0] = max[0]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
784 gr_info->maxband[1] = max[1]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
785 gr_info->maxband[2] = max[2]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
786 gr_info->maxbandl = max[3]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
787
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
788 { int rmax = max[0] > max[1] ? max[0] : max[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
789 rmax = (rmax > max[2] ? rmax : max[2]) + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
790 gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
791 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
792
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
793 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
794 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
795 * decoding with 'long' BandIndex table (block_type != 2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
796 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
797 int *pretab = gr_info->preflag ? pretab1 : pretab2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
798 int i,max = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
799 int cb = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
800 register int *m = map[sfreq][2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
801 register real v = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
802 register int mc = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
803 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
804 me = mapend[sfreq][2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
805 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
806
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
807 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
808 * long hash table values
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
809 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
810 for(i=0;i<3;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
811 int lp = l[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
812 struct newhuff *h = ht+gr_info->table_select[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
813
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
814 for(;lp;lp--,mc--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
815 int x,y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
816
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
817 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
818 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
819 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
820 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
821 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
822 { register short *val = h->table;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
823 while((y=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
824 part2remain--;
716
946170f9ed39 segfault fixed - maybe
arpi_esp
parents: 1
diff changeset
825 if(part2remain < 0) return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
826 if (get1bit()) val -= y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
827 // if(part2remain<=0) return 0; // Arpi
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
828 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
829 x = y >> 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
830 y &= 0xf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
831 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
832 if (x == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
833 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
834 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
835 x += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
836 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
837 *xrpnt++ = -ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
838 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
839 *xrpnt++ = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
840 } else if(x) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
841 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
842 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
843 *xrpnt++ = -ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
844 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
845 *xrpnt++ = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
846 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
847 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
848 *xrpnt++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
849
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
850 if (y == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
851 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
852 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
853 y += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
854 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
855 *xrpnt++ = -ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
856 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
857 *xrpnt++ = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
858 } else if(y) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
859 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
860 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
861 *xrpnt++ = -ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
862 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
863 *xrpnt++ = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
864 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
865 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
866 *xrpnt++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
867 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
868 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
869
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
870 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
871 * short (count1table) values
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
872 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
873 for(;l3 && (part2remain > 0);l3--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
874 struct newhuff *h = htc+gr_info->count1table_select;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
875 register short *val = h->table,a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
876
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
877 while((a=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
878 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
879 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
880 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
881 a = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
882 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
883 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
884 if (get1bit()) val -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
885 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
886
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
887 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
888 if(!(i & 1)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
889 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
890 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
891 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
892 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
893 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
894 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
895 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
896 if ( (a & (0x8>>i)) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
897 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
898 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
899 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
900 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
901 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
902 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
903 if(get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
904 *xrpnt++ = -v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
905 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
906 *xrpnt++ = v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
907 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
908 *xrpnt++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
909 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
910 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
911
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
912 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
913 * zero part
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
914 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
915 for(i=(&xr[SBLIMIT][0]-xrpnt)>>1;i;i--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
916 *xrpnt++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
917 *xrpnt++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
918 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
919
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
920 gr_info->maxbandl = max+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
921 gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
922 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
923
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
924 while( part2remain > 16 ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
925 getbits(16); /* Dismiss stuffing Bits */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
926 part2remain -= 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
927 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
928 if(part2remain > 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
929 getbits(part2remain);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
930 else if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
931 printf("\rCan't rewind stream by %d bits! \n",(-part2remain));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
932 return 1; /* -> error */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
933 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
934 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
935 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
936
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
937 static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT],int *scf,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
938 struct gr_info_s *gr_info,int sfreq,int part2bits)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
939 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
940 int shift = 1 + gr_info->scalefac_scale;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
941 real *xrpnt = (real *) xr[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
942 real *xr0pnt = (real *) xr[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
943 int l[3],l3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
944 int part2remain = gr_info->part2_3_length - part2bits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
945 int *me;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
946
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
947 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
948 int bv = gr_info->big_values;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
949 int region1 = gr_info->region1start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
950 int region2 = gr_info->region2start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
951
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
952 l3 = ((576>>1)-bv)>>1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
953 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
954 * we may lose the 'odd' bit here !!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
955 * check this later gain
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
956 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
957 if(bv <= region1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
958 l[0] = bv; l[1] = 0; l[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
959 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
960 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
961 l[0] = region1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
962 if(bv <= region2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
963 l[1] = bv - l[0]; l[2] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
964 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
965 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
966 l[1] = region2 - l[0]; l[2] = bv - region2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
967 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
968 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
969 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
970
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
971 if(gr_info->block_type == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
972 int i,max[4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
973 int step=0,lwin=0,cb=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
974 register real v = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
975 register int *m,mc = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
976
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
977 if(gr_info->mixed_block_flag) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
978 max[3] = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
979 max[0] = max[1] = max[2] = 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
980 m = map[sfreq][0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
981 me = mapend[sfreq][0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
982 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
983 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
984 max[0] = max[1] = max[2] = max[3] = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
985 /* max[3] not really needed in this case */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
986 m = map[sfreq][1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
987 me = mapend[sfreq][1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
988 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
989
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
990 for(i=0;i<2;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
991 int lp = l[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
992 struct newhuff *h = ht+gr_info->table_select[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
993 for(;lp;lp--,mc--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
994 int x,y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
995
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
996 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
997 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
998 xrpnt = ((real *) xr[1]) + *m;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
999 xr0pnt = ((real *) xr[0]) + *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1000 lwin = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1001 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1002 if(lwin == 3) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1003 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1004 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1005 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1006 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1007 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1008 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1009 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1010 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1011 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1012 register short *val = h->table;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1013 while((y=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1014 part2remain--;
716
946170f9ed39 segfault fixed - maybe
arpi_esp
parents: 1
diff changeset
1015 if(part2remain < 0) return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1016 if (get1bit()) val -= y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1017 // if(part2remain<=0) return 0; // Arpi
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1018 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1019 x = y >> 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1020 y &= 0xf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1021 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1022 if(x == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1023 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1024 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1025 x += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1026 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1027 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1028 *xrpnt = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1029 *xr0pnt -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1030 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1031 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1032 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1033 *xrpnt = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1034 *xr0pnt += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1035 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1036 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1037 else if(x) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1038 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1039 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1040 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1041 *xrpnt = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1042 *xr0pnt -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1043 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1044 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1045 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1046 *xrpnt = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1047 *xr0pnt += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1048 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1049 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1050 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1051 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1052 *xrpnt = *xr0pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1053 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1054 xr0pnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1055
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1056 if(y == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1057 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1058 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1059 y += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1060 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1061 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1062 *xrpnt = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1063 *xr0pnt -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1064 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1065 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1066 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1067 *xrpnt = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1068 *xr0pnt += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1069 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1070 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1071 else if(y) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1072 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1073 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1074 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1075 *xrpnt = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1076 *xr0pnt -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1077 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1078 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1079 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1080 *xrpnt = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1081 *xr0pnt += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1082 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1083 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1084 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1085 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1086 *xrpnt = *xr0pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1087 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1088 xr0pnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1089 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1090 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1091
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1092 for(;l3 && (part2remain > 0);l3--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1093 struct newhuff *h = htc+gr_info->count1table_select;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1094 register short *val = h->table,a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1095
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1096 while((a=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1097 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1098 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1099 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1100 a = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1101 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1102 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1103 if (get1bit())
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1104 val -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1105 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1106
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1107 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1108 if(!(i & 1)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1109 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1110 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1111 xrpnt = ((real *) xr[1]) + *m;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1112 xr0pnt = ((real *) xr[0]) + *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1113 lwin = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1114 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1115 if(lwin == 3) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1116 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1117 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1118 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1119 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1120 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1121 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1122 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1123 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1124 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1125 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1126 if( (a & (0x8>>i)) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1127 max[lwin] = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1128 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1129 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1130 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1131 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1132 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1133 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1134 *xrpnt = *xr0pnt + v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1135 *xr0pnt -= v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1136 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1137 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1138 *xrpnt = *xr0pnt - v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1139 *xr0pnt += v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1140 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1141 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1142 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1143 *xrpnt = *xr0pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1144 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1145 xr0pnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1146 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1147 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1149 while( m < me ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1150 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1151 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1152 xrpnt = ((real *) xr[1]) + *m;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1153 xr0pnt = ((real *) xr[0]) + *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1154 if(*m++ == 3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1155 step = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1156 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1157 step = 3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1158 m++; /* cb */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1159 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1160 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1161 *xrpnt = *xr0pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1162 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1163 xr0pnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1164 *xrpnt = *xr0pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1165 xrpnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1166 xr0pnt += step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1167 /* we could add a little opt. here:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1168 * if we finished a band for window 3 or a long band
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1169 * further bands could copied in a simple loop without a
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1170 * special 'map' decoding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1171 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1172 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1173
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1174 gr_info->maxband[0] = max[0]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1175 gr_info->maxband[1] = max[1]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1176 gr_info->maxband[2] = max[2]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1177 gr_info->maxbandl = max[3]+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1178
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1179 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1180 int rmax = max[0] > max[1] ? max[0] : max[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1181 rmax = (rmax > max[2] ? rmax : max[2]) + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1182 gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1183 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1184 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1185 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1186 int *pretab = gr_info->preflag ? pretab1 : pretab2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1187 int i,max = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1188 int cb = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1189 register int mc=0,*m = map[sfreq][2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1190 register real v = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1191 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1192 me = mapend[sfreq][2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1193 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1195 for(i=0;i<3;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1196 int lp = l[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1197 struct newhuff *h = ht+gr_info->table_select[i];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1199 for(;lp;lp--,mc--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1200 int x,y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1201 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1202 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1203 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1204 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1205 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1206 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1207 register short *val = h->table;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1208 while((y=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1209 part2remain--;
716
946170f9ed39 segfault fixed - maybe
arpi_esp
parents: 1
diff changeset
1210 if(part2remain < 0) return 1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1211 if (get1bit()) val -= y;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1212 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1213 x = y >> 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1214 y &= 0xf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1215 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1216 if (x == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1217 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1218 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1219 x += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1220 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1221 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1222 *xrpnt++ = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1223 *xr0pnt++ -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1224 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1225 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1226 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1227 *xrpnt++ = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1228 *xr0pnt++ += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1229 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1230 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1231 else if(x) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1232 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1233 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1234 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1235 *xrpnt++ = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1236 *xr0pnt++ -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1237 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1238 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1239 real a = ispow[x] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1240 *xrpnt++ = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1241 *xr0pnt++ += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1242 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1243 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1244 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1245 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1246 *xrpnt++ = *xr0pnt++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1247
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1248 if (y == 15) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1249 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1250 part2remain -= h->linbits+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1251 y += getbits(h->linbits);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1252 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1253 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1254 *xrpnt++ = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1255 *xr0pnt++ -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1256 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1257 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1258 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1259 *xrpnt++ = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1260 *xr0pnt++ += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1261 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1262 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1263 else if(y) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1264 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1265 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1266 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1267 *xrpnt++ = *xr0pnt + a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1268 *xr0pnt++ -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1269 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1270 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1271 real a = ispow[y] * v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1272 *xrpnt++ = *xr0pnt - a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1273 *xr0pnt++ += a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1274 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1275 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1276 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1277 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1278 *xrpnt++ = *xr0pnt++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1279 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1280 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1281
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1282 for(;l3 && (part2remain > 0);l3--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1283 struct newhuff *h = htc+gr_info->count1table_select;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1284 register short *val = h->table,a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1285
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1286 while((a=*val++)<0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1287 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1288 if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1289 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1290 a = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1291 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1292 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1293 if (get1bit()) val -= a;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1294 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1295
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1296 for(i=0;i<4;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1297 if(!(i & 1)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1298 if(!mc) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1299 mc = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1300 cb = *m++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1301 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1302 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1303 mc--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1304 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1305 if ( (a & (0x8>>i)) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1306 max = cb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1307 part2remain--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1308 if(part2remain <= 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1309 part2remain++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1310 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1311 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1312 if(get1bit()) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1313 *xrpnt++ = *xr0pnt + v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1314 *xr0pnt++ -= v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1315 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1316 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1317 *xrpnt++ = *xr0pnt - v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1318 *xr0pnt++ += v;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1319 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1320 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1321 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1322 *xrpnt++ = *xr0pnt++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1323 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1324 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1325 for(i=(&xr[1][SBLIMIT][0]-xrpnt)>>1;i;i--) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1326 *xrpnt++ = *xr0pnt++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1327 *xrpnt++ = *xr0pnt++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1328 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1329
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1330 gr_info->maxbandl = max+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1331 gr_info->maxb = longLimit[sfreq][gr_info->maxbandl];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1332 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1333
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1334 while ( part2remain > 16 ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1335 getbits(16); /* Dismiss stuffing Bits */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1336 part2remain -= 16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1337 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1338 if(part2remain > 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1339 getbits(part2remain);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1340 else if(part2remain < 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1341 printf("\rCan't rewind stream by %d bits! \n",(-part2remain));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1342 // fprintf(stderr,"mpg123: Can't rewind stream by %d bits (left=%d)!\n",(-part2remain),bitsleft);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1343 // fprintf(stderr,"mpg123_ms: Can't rewind stream by %d bits!\n",(-part2remain));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1344 return 1; /* -> error */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1345 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1346 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1347 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1348
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1349 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1350 * III_stereo: calculate real channel values for Joint-I-Stereo-mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1351 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1352 static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1353 struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1354 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1355 real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1356 struct bandInfoStruct *bi = &bandInfo[sfreq];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1357 real *tab1,*tab2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1358
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1359 if(lsf) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1360 int p = gr_info->scalefac_compress & 0x1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1361 if(ms_stereo) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1362 tab1 = pow1_2[p]; tab2 = pow2_2[p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1363 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1364 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1365 tab1 = pow1_1[p]; tab2 = pow2_1[p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1366 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1367 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1368 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1369 if(ms_stereo) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1370 tab1 = tan1_2; tab2 = tan2_2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1371 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1372 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1373 tab1 = tan1_1; tab2 = tan2_1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1374 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1375 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1376
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1377 if (gr_info->block_type == 2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1378 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1379 int lwin,do_l = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1380 if( gr_info->mixed_block_flag )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1381 do_l = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1382
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1383 for (lwin=0;lwin<3;lwin++) /* process each window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1384 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1385 /* get first band with zero values */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1386 int is_p,sb,idx,sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1387 if(sfb > 3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1388 do_l = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1389
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1390 for(;sfb<12;sfb++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1391 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1392 is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1393 if(is_p != 7) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1394 real t1,t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1395 sb = bi->shortDiff[sfb];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1396 idx = bi->shortIdx[sfb] + lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1397 t1 = tab1[is_p]; t2 = tab2[is_p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1398 for (; sb > 0; sb--,idx+=3)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1399 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1400 real v = xr[0][idx];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1401 xr[0][idx] = v * t1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1402 xr[1][idx] = v * t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1403 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1404 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1405 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1406
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1407 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1408 /* in the original: copy 10 to 11 , here: copy 11 to 12
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1409 maybe still wrong??? (copy 12 to 13?) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1410 is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1411 sb = bi->shortDiff[12];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1412 idx = bi->shortIdx[12] + lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1413 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1414 is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1415 sb = bi->shortDiff[11];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1416 idx = bi->shortIdx[11] + lwin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1417 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1418 if(is_p != 7)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1419 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1420 real t1,t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1421 t1 = tab1[is_p]; t2 = tab2[is_p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1422 for ( ; sb > 0; sb--,idx+=3 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1423 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1424 real v = xr[0][idx];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1425 xr[0][idx] = v * t1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1426 xr[1][idx] = v * t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1427 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1428 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1429 } /* end for(lwin; .. ; . ) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1430
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1431 if (do_l)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1432 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1433 /* also check l-part, if ALL bands in the three windows are 'empty'
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1434 * and mode = mixed_mode
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1435 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1436 int sfb = gr_info->maxbandl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1437 int idx = bi->longIdx[sfb];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1438
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1439 for ( ; sfb<8; sfb++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1440 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1441 int sb = bi->longDiff[sfb];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1442 int is_p = scalefac[sfb]; /* scale: 0-15 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1443 if(is_p != 7) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1444 real t1,t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1445 t1 = tab1[is_p]; t2 = tab2[is_p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1446 for ( ; sb > 0; sb--,idx++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1447 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1448 real v = xr[0][idx];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1449 xr[0][idx] = v * t1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1450 xr[1][idx] = v * t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1451 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1452 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1453 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1454 idx += sb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1455 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1456 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1457 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1458 else /* ((gr_info->block_type != 2)) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1459 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1460 int sfb = gr_info->maxbandl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1461 int is_p,idx = bi->longIdx[sfb];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1462 for ( ; sfb<21; sfb++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1463 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1464 int sb = bi->longDiff[sfb];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1465 is_p = scalefac[sfb]; /* scale: 0-15 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1466 if(is_p != 7) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1467 real t1,t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1468 t1 = tab1[is_p]; t2 = tab2[is_p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1469 for ( ; sb > 0; sb--,idx++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1470 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1471 real v = xr[0][idx];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1472 xr[0][idx] = v * t1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1473 xr[1][idx] = v * t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1474 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1475 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1476 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1477 idx += sb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1478 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1479
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1480 is_p = scalefac[20]; /* copy l-band 20 to l-band 21 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1481 if(is_p != 7)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1482 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1483 int sb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1484 real t1 = tab1[is_p],t2 = tab2[is_p];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1485
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1486 for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1487 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1488 real v = xr[0][idx];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1489 xr[0][idx] = v * t1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1490 xr[1][idx] = v * t2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1491 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1492 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1493 } /* ... */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1494 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1495
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1496 static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1497 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1498 int sblim;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1499
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1500 if(gr_info->block_type == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1501 if(!gr_info->mixed_block_flag) return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1502 sblim = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1503 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1504 sblim = gr_info->maxb-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1505 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1506
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1507 //printf("sblim=%d\n",sblim);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1508 //if(sblim<=0 || sblim>SBLIMIT) return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1509
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1510 /* 31 alias-reduction operations between each pair of sub-bands */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1511 /* with 8 butterflies between each pair */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1512
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1513 { int sb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1514 real *xr1=(real *) xr[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1515
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1516 for(sb=sblim;sb;sb--,xr1+=10) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1517 int ss;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1518 real *cs=aa_cs,*ca=aa_ca;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1519 real *xr2 = xr1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1520
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1521 for(ss=7;ss>=0;ss--) { /* upper and lower butterfly inputs */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1522 register real bu = *--xr2,bd = *xr1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1523 *xr2 = (bu * (*cs) ) - (bd * (*ca) );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1524 *xr1++ = (bd * (*cs++) ) + (bu * (*ca++) );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1525 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1526 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1527
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1528 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1529 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1530
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1531 #include "dct64.c"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1532 #include "dct36.c"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1533 #include "dct12.c"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1534
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1535 #include "decod386.c"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1536
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1537 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1538 * III_hybrid
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1539 */
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1540
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1541 dct36_func_t dct36_func;
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1542
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1543 static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1544 int ch,struct gr_info_s *gr_info)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1545 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1546 real *tspnt = (real *) tsOut;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1547 static real block[2][2][SBLIMIT*SSLIMIT] = { { { 0, } } };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1548 static int blc[2]={0,0};
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1549 real *rawout1,*rawout2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1550 int bt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1551 int sb = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1552
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1553 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1554 int b = blc[ch];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1555 rawout1=block[b][ch];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1556 b=-b+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1557 rawout2=block[b][ch];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1558 blc[ch] = b;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1559 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1560
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1561 if(gr_info->mixed_block_flag) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1562 sb = 2;
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1563 (*dct36_func)(fsIn[0],rawout1,rawout2,win[0],tspnt);
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1564 (*dct36_func)(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1565 rawout1 += 36; rawout2 += 36; tspnt += 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1566 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1567
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1568 bt = gr_info->block_type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1569 if(bt == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1570 for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1571 dct12(fsIn[sb],rawout1,rawout2,win[2],tspnt);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1572 dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1573 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1574 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1575 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1576 for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) {
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1577 (*dct36_func)(fsIn[sb],rawout1,rawout2,win[bt],tspnt);
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 716
diff changeset
1578 (*dct36_func)(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1579 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1580 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1581
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1582 for(;sb<SBLIMIT;sb++,tspnt++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1583 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1584 for(i=0;i<SSLIMIT;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1585 tspnt[i*SBLIMIT] = *rawout1++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1586 *rawout2++ = 0.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1587 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1588 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1589 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1590
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1591 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1592 * main layer3 handler
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1593 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1594 /* int do_layer3(struct frame *fr,int outmode,struct audio_info_struct *ai) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1595 static int do_layer3(struct frame *fr,int single){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1596 int gr, ch, ss,clip=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1597 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1598 struct III_sideinfo sideinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1599 int stereo = fr->stereo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1600 int ms_stereo,i_stereo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1601 int sfreq = fr->sampling_frequency;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1602 int stereo1,granules;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1603
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1604 // if (fr->error_protection) getbits(16); /* skip crc */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1605
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1606 if(stereo == 1) { /* stream is mono */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1607 stereo1 = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1608 single = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1609 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1610 if(single >= 0) /* stream is stereo, but force to mono */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1611 stereo1 = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1612 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1613 stereo1 = 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1614
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1615 if(fr->mode == MPG_MD_JOINT_STEREO) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1616 ms_stereo = fr->mode_ext & 0x2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1617 i_stereo = fr->mode_ext & 0x1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1618 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1619 ms_stereo = i_stereo = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1620
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1621 if(fr->lsf) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1622 granules = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1623 III_get_side_info_2(&sideinfo,stereo,ms_stereo,sfreq,single);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1624 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1625 granules = 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1626 III_get_side_info_1(&sideinfo,stereo,ms_stereo,sfreq,single);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1627 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1628
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1629 set_pointer(sideinfo.main_data_begin);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1630
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1631 for (gr=0;gr<granules;gr++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1632 static real hybridIn[2][SBLIMIT][SSLIMIT];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1633 static real hybridOut[2][SSLIMIT][SBLIMIT];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1634
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1635 { struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1636 long part2bits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1637 if(fr->lsf)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1638 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1639 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1640 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1641 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1642 return clip;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1643 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1644
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1645 if(stereo == 2) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1646 struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1647
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1648 long part2bits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1649 if(fr->lsf)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1650 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1651 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1652 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1653
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1654 if(ms_stereo) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1655 if(III_dequantize_sample_ms(hybridIn,scalefacs[1],gr_info,sfreq,part2bits))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1656 return clip;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1657 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1658 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1659 return clip;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1660 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1661
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1662 if(i_stereo)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1663 III_i_stereo(hybridIn,scalefacs[1],gr_info,sfreq,ms_stereo,fr->lsf);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1664
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1665 if(ms_stereo || i_stereo || (single == 3) ) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1666 if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1667 sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1668 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1669 gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1670 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1671
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1672 switch(single) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1673 case 3: {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1674 register int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1675 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1676 for(i=0;i<SSLIMIT*gr_info->maxb;i++,in0++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1677 *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1678 break; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1679 case 1: {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1680 register int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1681 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1682 for(i=0;i<SSLIMIT*gr_info->maxb;i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1683 *in0++ = *in1++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1684 break; }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1685 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1686
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1687 } // if(stereo == 2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1688
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1689 for(ch=0;ch<stereo1;ch++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1690 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1691 III_antialias(hybridIn[ch],gr_info);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1692 III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1693 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1694
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1695 for(ss=0;ss<SSLIMIT;ss++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1696 if(single >= 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1697 clip += (fr->synth_mono)(hybridOut[0][ss],pcm_sample,&pcm_point);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1698 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1699 int p1 = pcm_point;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1700 clip += (fr->synth)(hybridOut[0][ss],0,pcm_sample,&p1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1701 clip += (fr->synth)(hybridOut[1][ss],1,pcm_sample,&pcm_point);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1702 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1703 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1704
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1705 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1706
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1707 return clip;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1708 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1709
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1710