Mercurial > audlegacy
comparison Plugins/Input/mpg123/decode_2to1.c @ 970:0f294f2b0a9b trunk
[svn] - integer-mode decoding accuracy improvements
author | nenolod |
---|---|
date | Wed, 26 Apr 2006 10:54:58 -0700 |
parents | 05d824e30afd |
children | b5ae09a6c2f1 |
comparison
equal
deleted
inserted
replaced
969:971bd2b03ff5 | 970:0f294f2b0a9b |
---|---|
16 #define WRITE_SAMPLE(samples,sum,clip) \ | 16 #define WRITE_SAMPLE(samples,sum,clip) \ |
17 if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ | 17 if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \ |
18 else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ | 18 else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \ |
19 else { *(samples) = sum; } | 19 else { *(samples) = sum; } |
20 | 20 |
21 int mpg123_synth_2to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt) | 21 int mpg123_synth_2to1_8bit(mpgdec_real *bandPtr,int channel,unsigned char *samples,int *pnt) |
22 { | 22 { |
23 short samples_tmp[32]; | 23 short samples_tmp[32]; |
24 short *tmp1 = samples_tmp + channel; | 24 short *tmp1 = samples_tmp + channel; |
25 int i,ret; | 25 int i,ret; |
26 int pnt1 = 0; | 26 int pnt1 = 0; |
36 *pnt += 32; | 36 *pnt += 32; |
37 | 37 |
38 return ret; | 38 return ret; |
39 } | 39 } |
40 | 40 |
41 int mpg123_synth_2to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt) | 41 int mpg123_synth_2to1_8bit_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) |
42 { | 42 { |
43 short samples_tmp[32]; | 43 short samples_tmp[32]; |
44 short *tmp1 = samples_tmp; | 44 short *tmp1 = samples_tmp; |
45 int i,ret; | 45 int i,ret; |
46 int pnt1 = 0; | 46 int pnt1 = 0; |
56 | 56 |
57 return ret; | 57 return ret; |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 int mpg123_synth_2to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt) | 61 int mpg123_synth_2to1_8bit_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) |
62 { | 62 { |
63 short samples_tmp[32]; | 63 short samples_tmp[32]; |
64 short *tmp1 = samples_tmp; | 64 short *tmp1 = samples_tmp; |
65 int i,ret; | 65 int i,ret; |
66 int pnt1 = 0; | 66 int pnt1 = 0; |
76 *pnt += 32; | 76 *pnt += 32; |
77 | 77 |
78 return ret; | 78 return ret; |
79 } | 79 } |
80 | 80 |
81 int mpg123_synth_2to1_mono(real *bandPtr,unsigned char *samples,int *pnt) | 81 int mpg123_synth_2to1_mono(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) |
82 { | 82 { |
83 short samples_tmp[32]; | 83 short samples_tmp[32]; |
84 short *tmp1 = samples_tmp; | 84 short *tmp1 = samples_tmp; |
85 int i,ret; | 85 int i,ret; |
86 int pnt1=0; | 86 int pnt1=0; |
96 *pnt += 32; | 96 *pnt += 32; |
97 | 97 |
98 return ret; | 98 return ret; |
99 } | 99 } |
100 | 100 |
101 int mpg123_synth_2to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt) | 101 int mpg123_synth_2to1_mono2stereo(mpgdec_real *bandPtr,unsigned char *samples,int *pnt) |
102 { | 102 { |
103 int i,ret; | 103 int i,ret; |
104 | 104 |
105 ret = mpg123_synth_2to1(bandPtr,0,samples,pnt); | 105 ret = mpg123_synth_2to1(bandPtr,0,samples,pnt); |
106 samples = samples + *pnt - 64; | 106 samples = samples + *pnt - 64; |
111 } | 111 } |
112 | 112 |
113 return ret; | 113 return ret; |
114 } | 114 } |
115 | 115 |
116 int mpg123_synth_2to1(real *bandPtr,int channel,unsigned char *out,int *pnt) | 116 int mpg123_synth_2to1(mpgdec_real *bandPtr,int channel,unsigned char *out,int *pnt) |
117 { | 117 { |
118 static real buffs[2][2][0x110]; | 118 static mpgdec_real buffs[2][2][0x110]; |
119 static const int step = 2; | 119 static const int step = 2; |
120 static int bo = 1; | 120 static int bo = 1; |
121 short *samples = (short *) (out + *pnt); | 121 short *samples = (short *) (out + *pnt); |
122 | 122 |
123 real *b0,(*buf)[0x110]; | 123 mpgdec_real *b0,(*buf)[0x110]; |
124 int clip = 0; | 124 int clip = 0; |
125 int bo1; | 125 int bo1; |
126 | 126 |
127 if(!channel) { | 127 if(!channel) { |
128 bo--; | 128 bo--; |
145 mpg123_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); | 145 mpg123_dct64(buf[0]+bo,buf[1]+bo+1,bandPtr); |
146 } | 146 } |
147 | 147 |
148 { | 148 { |
149 register int j; | 149 register int j; |
150 real *window = mpg123_decwin + 16 - bo1; | 150 mpgdec_real *window = mpg123_decwin + 16 - bo1; |
151 | 151 |
152 for (j=8;j;j--,b0+=0x10,window+=0x30) | 152 for (j=8;j;j--,b0+=0x10,window+=0x30) |
153 { | 153 { |
154 real sum; | 154 mpgdec_real sum; |
155 sum = *window++ * *b0++; | 155 sum = *window++ * *b0++; |
156 sum -= *window++ * *b0++; | 156 sum -= *window++ * *b0++; |
157 sum += *window++ * *b0++; | 157 sum += *window++ * *b0++; |
158 sum -= *window++ * *b0++; | 158 sum -= *window++ * *b0++; |
159 sum += *window++ * *b0++; | 159 sum += *window++ * *b0++; |
174 WRITE_SAMPLE(samples,sum,clip); samples += step; | 174 WRITE_SAMPLE(samples,sum,clip); samples += step; |
175 #endif | 175 #endif |
176 } | 176 } |
177 | 177 |
178 { | 178 { |
179 real sum; | 179 mpgdec_real sum; |
180 sum = window[0x0] * b0[0x0]; | 180 sum = window[0x0] * b0[0x0]; |
181 sum += window[0x2] * b0[0x2]; | 181 sum += window[0x2] * b0[0x2]; |
182 sum += window[0x4] * b0[0x4]; | 182 sum += window[0x4] * b0[0x4]; |
183 sum += window[0x6] * b0[0x6]; | 183 sum += window[0x6] * b0[0x6]; |
184 sum += window[0x8] * b0[0x8]; | 184 sum += window[0x8] * b0[0x8]; |
193 } | 193 } |
194 window += bo1<<1; | 194 window += bo1<<1; |
195 | 195 |
196 for (j=7;j;j--,b0-=0x30,window-=0x30) | 196 for (j=7;j;j--,b0-=0x30,window-=0x30) |
197 { | 197 { |
198 real sum; | 198 mpgdec_real sum; |
199 sum = -*(--window) * *b0++; | 199 sum = -*(--window) * *b0++; |
200 sum -= *(--window) * *b0++; | 200 sum -= *(--window) * *b0++; |
201 sum -= *(--window) * *b0++; | 201 sum -= *(--window) * *b0++; |
202 sum -= *(--window) * *b0++; | 202 sum -= *(--window) * *b0++; |
203 sum -= *(--window) * *b0++; | 203 sum -= *(--window) * *b0++; |