Mercurial > mplayer.hg
annotate mp3lib/decod386.c @ 855:044cfdebe60c
opendivx NEW_DECORE fixed
author | arpi_esp |
---|---|
date | Thu, 24 May 2001 01:19:29 +0000 |
parents | 9bc104531aec |
children | 03b7e2955a20 |
rev | line source |
---|---|
1 | 1 /* |
2 * Mpeg Layer-1,2,3 audio decoder | |
3 * ------------------------------ | |
4 * copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved. | |
5 * See also 'README' | |
6 * | |
7 * slighlty optimized for machines without autoincrement/decrement. | |
8 * The performance is highly compiler dependend. Maybe | |
9 * the decode.c version for 'normal' processor may be faster | |
10 * even for Intel processors. | |
11 */ | |
12 | |
13 | |
14 | |
15 /* new WRITE_SAMPLE */ | |
16 /* sizeof(int) == 4 */ | |
17 #define WRITE_SAMPLE(samples,sum,clip) { \ | |
18 double dtemp; long v; \ | |
19 dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\ | |
20 v = ((*(int *)&dtemp) - 0x80000000); \ | |
21 if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \ | |
22 else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \ | |
23 else { *(samples) = v; } \ | |
24 } | |
25 | |
26 | |
27 /* | |
28 #define WRITE_SAMPLE(samples,sum,clip) { \ | |
29 double dtemp; int v; \ | |
30 dtemp = ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0)) + (sum);\ | |
31 v = ((*(int *)&dtemp) - 0x80000000); \ | |
32 if( v > 32767) { *(samples) = 0x7fff; (clip)++; } \ | |
33 else if( v < -32768) { *(samples) = -0x8000; (clip)++; } \ | |
34 else { *(samples) = v; } \ | |
35 } | |
36 */ | |
37 | |
38 static int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt) | |
39 { | |
40 short samples_tmp[64]; | |
41 short *tmp1 = samples_tmp; | |
42 int i,ret; | |
43 int pnt1 = 0; | |
44 | |
45 ret = synth_1to1(bandPtr,0,(unsigned char *) samples_tmp,&pnt1); | |
46 samples += *pnt; | |
47 | |
48 for(i=0;i<32;i++) { | |
49 *( (short *) samples) = *tmp1; | |
50 samples += 2; | |
51 tmp1 += 2; | |
52 } | |
53 *pnt += 64; | |
54 | |
55 return ret; | |
56 } | |
57 | |
58 | |
59 static int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt) | |
60 { | |
61 int i,ret; | |
62 | |
63 ret = synth_1to1(bandPtr,0,samples,pnt); | |
64 samples = samples + *pnt - 128; | |
65 | |
66 for(i=0;i<32;i++) { | |
67 ((short *)samples)[1] = ((short *)samples)[0]; | |
68 samples+=4; | |
69 } | |
70 | |
71 return ret; | |
72 } | |
73 | |
74 | |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
75 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
76 static int synth_1to1_l(real *bandPtr,int channel,unsigned char *out,int *pnt) |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
77 { |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
78 int i,ret; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
79 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
80 ret = synth_1to1(bandPtr,channel,out,pnt); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
81 out = out + *pnt - 128; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
82 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
83 for(i=0;i<32;i++) { |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
84 ((short *)out)[1] = ((short *)out)[0]; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
85 out+=4; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
86 } |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
87 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
88 return ret; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
89 } |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
90 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
91 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
92 static int synth_1to1_r(real *bandPtr,int channel,unsigned char *out,int *pnt) |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
93 { |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
94 int i,ret; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
95 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
96 ret = synth_1to1(bandPtr,channel,out,pnt); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
97 out = out + *pnt - 128; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
98 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
99 for(i=0;i<32;i++) { |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
100 ((short *)out)[0] = ((short *)out)[1]; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
101 out+=4; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
102 } |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
103 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
104 return ret; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
105 } |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
106 #endif |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
107 |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
1
diff
changeset
|
108 |
1 | 109 static int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt) |
110 { | |
111 static real buffs[2][2][0x110]; | |
112 static const int step = 2; | |
113 static int bo = 1; | |
114 short *samples = (short *) (out + *pnt); | |
115 | |
116 real *b0,(*buf)[0x110]; | |
117 int clip = 0; | |
118 int bo1; | |
119 | |
787 | 120 #ifdef HAVE_SSE_MP3 |
121 //if ( _3dnow ) | |
122 { | |
123 int ret; | |
124 ret=synth_1to1_sse( bandPtr,channel,out+*pnt ); | |
125 *pnt+=128; | |
126 return ret; | |
127 } | |
128 #endif | |
736 | 129 #ifdef HAVE_3DNOWEX |
130 if ( _3dnow > 1 ) | |
131 { | |
132 int ret; | |
133 ret=synth_1to1_3dnowex( bandPtr,channel,out+*pnt ); | |
134 *pnt+=128; | |
135 return ret; | |
136 } | |
137 #endif | |
1 | 138 #ifdef HAVE_3DNOW |
139 if ( _3dnow ) | |
140 { | |
141 int ret; | |
142 ret=synth_1to1_3dnow( bandPtr,channel,out+*pnt ); | |
143 *pnt+=128; | |
144 return ret; | |
145 } | |
146 #endif | |
147 if ( _i586 ) | |
148 { | |
149 int ret; | |
150 ret=synth_1to1_pent( bandPtr,channel,out+*pnt ); | |
151 *pnt+=128; | |
152 return ret; | |
153 } | |
154 | |
155 if(!channel) { /* channel=0 */ | |
156 bo--; | |
157 bo &= 0xf; | |
158 buf = buffs[0]; | |
159 } | |
160 else { | |
161 samples++; | |
162 buf = buffs[1]; | |
163 } | |
164 | |
165 if(bo & 0x1) { | |
166 b0 = buf[0]; | |
167 bo1 = bo; | |
168 dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr); | |
169 } | |
170 else { | |
171 b0 = buf[1]; | |
172 bo1 = bo+1; | |
173 dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); | |
174 } | |
175 | |
176 { | |
177 register int j; | |
178 real *window = decwin + 16 - bo1; | |
179 | |
180 for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step) | |
181 { | |
182 real sum; | |
183 sum = window[0x0] * b0[0x0]; | |
184 sum -= window[0x1] * b0[0x1]; | |
185 sum += window[0x2] * b0[0x2]; | |
186 sum -= window[0x3] * b0[0x3]; | |
187 sum += window[0x4] * b0[0x4]; | |
188 sum -= window[0x5] * b0[0x5]; | |
189 sum += window[0x6] * b0[0x6]; | |
190 sum -= window[0x7] * b0[0x7]; | |
191 sum += window[0x8] * b0[0x8]; | |
192 sum -= window[0x9] * b0[0x9]; | |
193 sum += window[0xA] * b0[0xA]; | |
194 sum -= window[0xB] * b0[0xB]; | |
195 sum += window[0xC] * b0[0xC]; | |
196 sum -= window[0xD] * b0[0xD]; | |
197 sum += window[0xE] * b0[0xE]; | |
198 sum -= window[0xF] * b0[0xF]; | |
199 | |
200 WRITE_SAMPLE(samples,sum,clip); | |
201 } | |
202 | |
203 { | |
204 real sum; | |
205 sum = window[0x0] * b0[0x0]; | |
206 sum += window[0x2] * b0[0x2]; | |
207 sum += window[0x4] * b0[0x4]; | |
208 sum += window[0x6] * b0[0x6]; | |
209 sum += window[0x8] * b0[0x8]; | |
210 sum += window[0xA] * b0[0xA]; | |
211 sum += window[0xC] * b0[0xC]; | |
212 sum += window[0xE] * b0[0xE]; | |
213 WRITE_SAMPLE(samples,sum,clip); | |
214 b0-=0x10,window-=0x20,samples+=step; | |
215 } | |
216 window += bo1<<1; | |
217 | |
218 for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step) | |
219 { | |
220 real sum; | |
221 sum = -window[-0x1] * b0[0x0]; | |
222 sum -= window[-0x2] * b0[0x1]; | |
223 sum -= window[-0x3] * b0[0x2]; | |
224 sum -= window[-0x4] * b0[0x3]; | |
225 sum -= window[-0x5] * b0[0x4]; | |
226 sum -= window[-0x6] * b0[0x5]; | |
227 sum -= window[-0x7] * b0[0x6]; | |
228 sum -= window[-0x8] * b0[0x7]; | |
229 sum -= window[-0x9] * b0[0x8]; | |
230 sum -= window[-0xA] * b0[0x9]; | |
231 sum -= window[-0xB] * b0[0xA]; | |
232 sum -= window[-0xC] * b0[0xB]; | |
233 sum -= window[-0xD] * b0[0xC]; | |
234 sum -= window[-0xE] * b0[0xD]; | |
235 sum -= window[-0xF] * b0[0xE]; | |
236 sum -= window[-0x0] * b0[0xF]; | |
237 | |
238 WRITE_SAMPLE(samples,sum,clip); | |
239 } | |
240 } | |
241 *pnt += 128; | |
242 | |
243 return clip; | |
244 | |
245 } | |
246 |