annotate mp3lib/decod386.c @ 668:f448a43d049a

List of known bugs and workarounds
author arpi_esp
date Mon, 30 Apr 2001 02:16:07 +0000
parents 3b5f5d1c5041
children e14114170e01
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 * Mpeg Layer-1,2,3 audio decoder
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 * ------------------------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * See also 'README'
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * slighlty optimized for machines without autoincrement/decrement.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * The performance is highly compiler dependend. Maybe
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * the decode.c version for 'normal' processor may be faster
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * even for Intel processors.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 /* new WRITE_SAMPLE */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 /* sizeof(int) == 4 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #define WRITE_SAMPLE(samples,sum,clip) { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 double dtemp; long v; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 v = ((*(int *)&dtemp) - 0x80000000); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 else { *(samples) = v; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #define WRITE_SAMPLE(samples,sum,clip) { \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 double dtemp; int v; \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 v = ((*(int *)&dtemp) - 0x80000000); \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 else { *(samples) = v; } \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 static int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 short samples_tmp[64];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 short *tmp1 = samples_tmp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 int i,ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 int pnt1 = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 samples += *pnt;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 for(i=0;i<32;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 *( (short *) samples) = *tmp1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 samples += 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 tmp1 += 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 *pnt += 64;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 static int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 int i,ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 ret = synth_1to1(bandPtr,0,samples,pnt);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 samples = samples + *pnt - 128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 for(i=0;i<32;i++) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 ((short *)samples)[1] = ((short *)samples)[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 samples+=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 static int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 static real buffs[2][2][0x110];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 static const int step = 2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 static int bo = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 short *samples = (short *) (out + *pnt);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 real *b0,(*buf)[0x110];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 int clip = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 int bo1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 #ifdef HAVE_3DNOW
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 if ( _3dnow )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 int ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 ret=synth_1to1_3dnow( bandPtr,channel,out+*pnt );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 *pnt+=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 if ( _i586 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 int ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 ret=synth_1to1_pent( bandPtr,channel,out+*pnt );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 *pnt+=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 return ret;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 if(!channel) { /* channel=0 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 bo--;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 bo &= 0xf;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 buf = buffs[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 samples++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 buf = buffs[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 if(bo & 0x1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 b0 = buf[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 bo1 = bo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 b0 = buf[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 bo1 = bo+1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 register int j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 real *window = decwin + 16 - bo1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 real sum;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 sum = window[0x0] * b0[0x0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 sum -= window[0x1] * b0[0x1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 sum += window[0x2] * b0[0x2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 sum -= window[0x3] * b0[0x3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 sum += window[0x4] * b0[0x4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 sum -= window[0x5] * b0[0x5];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 sum += window[0x6] * b0[0x6];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 sum -= window[0x7] * b0[0x7];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 sum += window[0x8] * b0[0x8];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 sum -= window[0x9] * b0[0x9];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 sum += window[0xA] * b0[0xA];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 sum -= window[0xB] * b0[0xB];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 sum += window[0xC] * b0[0xC];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 sum -= window[0xD] * b0[0xD];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 sum += window[0xE] * b0[0xE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 sum -= window[0xF] * b0[0xF];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 WRITE_SAMPLE(samples,sum,clip);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 real sum;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 sum = window[0x0] * b0[0x0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 sum += window[0x2] * b0[0x2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 sum += window[0x4] * b0[0x4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 sum += window[0x6] * b0[0x6];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 sum += window[0x8] * b0[0x8];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 sum += window[0xA] * b0[0xA];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 sum += window[0xC] * b0[0xC];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 sum += window[0xE] * b0[0xE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 WRITE_SAMPLE(samples,sum,clip);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 b0-=0x10,window-=0x20,samples+=step;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 window += bo1<<1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 real sum;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 sum = -window[-0x1] * b0[0x0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 sum -= window[-0x2] * b0[0x1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 sum -= window[-0x3] * b0[0x2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 sum -= window[-0x4] * b0[0x3];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 sum -= window[-0x5] * b0[0x4];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 sum -= window[-0x6] * b0[0x5];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 sum -= window[-0x7] * b0[0x6];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 sum -= window[-0x8] * b0[0x7];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 sum -= window[-0x9] * b0[0x8];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 sum -= window[-0xA] * b0[0x9];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 sum -= window[-0xB] * b0[0xA];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 sum -= window[-0xC] * b0[0xB];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 sum -= window[-0xD] * b0[0xC];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 sum -= window[-0xE] * b0[0xD];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 sum -= window[-0xF] * b0[0xE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 sum -= window[-0x0] * b0[0xF];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 WRITE_SAMPLE(samples,sum,clip);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 *pnt += 128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 return clip;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194