Rev 1905 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1905 | Rev 3960 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | synth.c: The functions for synthesizing samples, at the end of decoding. |
2 | synth.c: The functions for synthesizing samples, at the end of decoding. |
3 | 3 | ||
4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 |
4 | copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 |
5 | see COPYING and AUTHORS files in distribution or http://mpg123.org |
5 | see COPYING and AUTHORS files in distribution or http://mpg123.org |
6 | initially written by Michael Hipp, heavily dissected and rearranged by Thomas Orgis |
6 | initially written by Michael Hipp, heavily dissected and rearranged by Thomas Orgis |
7 | */ |
7 | */ |
8 | 8 | ||
9 | #include "mpg123lib_intern.h" |
9 | #include "mpg123lib_intern.h" |
10 | #include "sample.h" |
10 | #include "sample.h" |
11 | #include "debug.h" |
11 | #include "debug.h" |
12 | - | ||
13 | /* Stereo-related synth, wrapping over _some_ plain synth. */ |
- | |
14 | int synth_stereo_wrap(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
- | |
15 | { |
- | |
16 | int clip; |
- | |
17 | clip = (fr->synth)(bandPtr_l, 0, fr, 0); |
- | |
18 | clip += (fr->synth)(bandPtr_r, 1, fr, 1); |
- | |
19 | return clip; |
- | |
20 | } |
- | |
21 | 12 | ||
22 | /* |
13 | /* |
23 | Part 1: All synth functions that produce signed short. |
14 | Part 1: All synth functions that produce signed short. |
24 | That is: |
15 | That is: |
25 | - synth_1to1 with cpu-specific variants (synth_1to1_i386, synth_1to1_i586 ...) |
16 | - synth_1to1 with cpu-specific variants (synth_1to1_i386, synth_1to1_i586 ...) |
26 | - synth_1to1_mono and synth_1to1_mono2stereo; which use fr->synths.plain[r_1to1][f_16]. |
17 | - synth_1to1_mono and synth_1to1_m2s; which use fr->synths.plain[r_1to1][f_16]. |
27 | Nearly every decoder variant has it's own synth_1to1, while the mono conversion is shared. |
18 | Nearly every decoder variant has it's own synth_1to1, while the mono conversion is shared. |
28 | */ |
19 | */ |
29 | 20 | ||
30 | #define SAMPLE_T short |
21 | #define SAMPLE_T short |
31 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE(samples,sum,clip) |
22 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE(samples,sum,clip) |
32 | 23 | ||
33 | /* Part 1a: All straight 1to1 decoding functions */ |
24 | /* Part 1a: All straight 1to1 decoding functions */ |
34 | #define BLOCK 0x40 /* One decoding block is 64 samples. */ |
25 | #define BLOCK 0x40 /* One decoding block is 64 samples. */ |
35 | 26 | ||
36 | #define SYNTH_NAME synth_1to1 |
27 | #define SYNTH_NAME synth_1to1 |
37 | #include "synth.h" |
28 | #include "synth.h" |
38 | #undef SYNTH_NAME |
29 | #undef SYNTH_NAME |
39 | 30 | ||
40 | /* Mono-related synths; they wrap over _some_ synth_1to1. */ |
31 | /* Mono-related synths; they wrap over _some_ synth_1to1. */ |
41 | #define SYNTH_NAME fr->synths.plain[r_1to1][f_16] |
32 | #define SYNTH_NAME fr->synths.plain[r_1to1][f_16] |
42 | #define MONO_NAME synth_1to1_mono |
33 | #define MONO_NAME synth_1to1_mono |
43 | #define MONO2STEREO_NAME synth_1to1_mono2stereo |
34 | #define MONO2STEREO_NAME synth_1to1_m2s |
44 | #include "synth_mono.h" |
35 | #include "synth_mono.h" |
45 | #undef SYNTH_NAME |
36 | #undef SYNTH_NAME |
46 | #undef MONO_NAME |
37 | #undef MONO_NAME |
47 | #undef MONO2STEREO_NAME |
38 | #undef MONO2STEREO_NAME |
48 | 39 | ||
49 | /* Now we have possibly some special synth_1to1 ... |
40 | /* Now we have possibly some special synth_1to1 ... |
50 | ... they produce signed short; the mono functions defined above work on the special synths, too. */ |
41 | ... they produce signed short; the mono functions defined above work on the special synths, too. */ |
51 | 42 | ||
52 | #ifdef OPT_GENERIC_DITHER |
43 | #ifdef OPT_GENERIC_DITHER |
53 | #define SYNTH_NAME synth_1to1_dither |
44 | #define SYNTH_NAME synth_1to1_dither |
54 | /* We need the accurate sample writing... */ |
45 | /* We need the accurate sample writing... */ |
55 | #undef WRITE_SAMPLE |
46 | #undef WRITE_SAMPLE |
56 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE_ACCURATE(samples,sum,clip) |
47 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE_ACCURATE(samples,sum,clip) |
57 | 48 | ||
58 | #define USE_DITHER |
49 | #define USE_DITHER |
59 | #include "synth.h" |
50 | #include "synth.h" |
60 | #undef USE_DITHER |
51 | #undef USE_DITHER |
61 | #undef SYNTH_NAME |
52 | #undef SYNTH_NAME |
62 | 53 | ||
63 | #undef WRITE_SAMPLE |
54 | #undef WRITE_SAMPLE |
64 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE(samples,sum,clip) |
55 | #define WRITE_SAMPLE(samples,sum,clip) WRITE_SHORT_SAMPLE(samples,sum,clip) |
65 | 56 | ||
66 | #endif |
57 | #endif |
67 | 58 | ||
68 | #ifdef OPT_X86 |
59 | #ifdef OPT_X86 |
69 | /* The i386-specific C code, here as short variant, later 8bit and float. */ |
60 | /* The i386-specific C code, here as short variant, later 8bit and float. */ |
70 | #define NO_AUTOINCREMENT |
61 | #define NO_AUTOINCREMENT |
71 | #define SYNTH_NAME synth_1to1_i386 |
62 | #define SYNTH_NAME synth_1to1_i386 |
72 | #include "synth.h" |
63 | #include "synth.h" |
73 | #undef SYNTH_NAME |
64 | #undef SYNTH_NAME |
74 | /* i386 uses the normal mono functions. */ |
65 | /* i386 uses the normal mono functions. */ |
75 | #undef NO_AUTOINCREMENT |
66 | #undef NO_AUTOINCREMENT |
76 | #endif |
67 | #endif |
77 | 68 | ||
78 | #undef BLOCK /* Following functions are so special that they don't need this. */ |
69 | #undef BLOCK /* Following functions are so special that they don't need this. */ |
79 | 70 | ||
80 | #ifdef OPT_I586 |
71 | #ifdef OPT_I586 |
81 | /* This is defined in assembler. */ |
72 | /* This is defined in assembler. */ |
82 | int synth_1to1_i586_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); |
73 | int synth_1to1_i586_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); |
83 | /* This is just a hull to use the mpg123 handle. */ |
74 | /* This is just a hull to use the mpg123 handle. */ |
84 | int synth_1to1_i586(real *bandPtr, int channel, mpg123_handle *fr, int final) |
75 | int synth_1to1_i586(real *bandPtr, int channel, mpg123_handle *fr, int final) |
85 | { |
76 | { |
86 | int ret; |
77 | int ret; |
87 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
78 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
88 | 79 | ||
89 | ret = synth_1to1_i586_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin); |
80 | ret = synth_1to1_i586_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin); |
90 | if(final) fr->buffer.fill += 128; |
81 | if(final) fr->buffer.fill += 128; |
91 | return ret; |
82 | return ret; |
92 | } |
83 | } |
93 | #endif |
84 | #endif |
94 | 85 | ||
95 | #ifdef OPT_I586_DITHER |
86 | #ifdef OPT_I586_DITHER |
96 | /* This is defined in assembler. */ |
87 | /* This is defined in assembler. */ |
97 | int synth_1to1_i586_asm_dither(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin, float *dithernoise); |
88 | int synth_1to1_i586_asm_dither(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin, float *dithernoise); |
98 | /* This is just a hull to use the mpg123 handle. */ |
89 | /* This is just a hull to use the mpg123 handle. */ |
99 | int synth_1to1_i586_dither(real *bandPtr, int channel, mpg123_handle *fr, int final) |
90 | int synth_1to1_i586_dither(real *bandPtr, int channel, mpg123_handle *fr, int final) |
100 | { |
91 | { |
101 | int ret; |
92 | int ret; |
102 | int bo_dither[2]; /* Temporary workaround? Could expand the asm code. */ |
93 | int bo_dither[2]; /* Temporary workaround? Could expand the asm code. */ |
103 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
94 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
104 | 95 | ||
105 | /* Applying this hack, to change the asm only bit by bit (adding dithernoise pointer). */ |
96 | /* Applying this hack, to change the asm only bit by bit (adding dithernoise pointer). */ |
106 | bo_dither[0] = fr->bo; |
97 | bo_dither[0] = fr->bo; |
107 | bo_dither[1] = fr->ditherindex; |
98 | bo_dither[1] = fr->ditherindex; |
108 | ret = synth_1to1_i586_asm_dither(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, bo_dither, fr->decwin, fr->dithernoise); |
99 | ret = synth_1to1_i586_asm_dither(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, bo_dither, fr->decwin, fr->dithernoise); |
109 | fr->bo = bo_dither[0]; |
100 | fr->bo = bo_dither[0]; |
110 | fr->ditherindex = bo_dither[1]; |
101 | fr->ditherindex = bo_dither[1]; |
111 | 102 | ||
112 | if(final) fr->buffer.fill += 128; |
103 | if(final) fr->buffer.fill += 128; |
113 | return ret; |
104 | return ret; |
114 | } |
105 | } |
115 | #endif |
106 | #endif |
116 | 107 | ||
117 | #ifdef OPT_3DNOW |
108 | #ifdef OPT_3DNOW |
118 | /* Those are defined in assembler. */ |
109 | /* Those are defined in assembler. */ |
119 | void do_equalizer_3dnow(real *bandPtr,int channel, real equalizer[2][32]); |
110 | void do_equalizer_3dnow(real *bandPtr,int channel, real equalizer[2][32]); |
120 | int synth_1to1_3dnow_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); |
111 | int synth_1to1_3dnow_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin); |
121 | /* This is just a hull to use the mpg123 handle. */ |
112 | /* This is just a hull to use the mpg123 handle. */ |
122 | int synth_1to1_3dnow(real *bandPtr, int channel, mpg123_handle *fr, int final) |
113 | int synth_1to1_3dnow(real *bandPtr, int channel, mpg123_handle *fr, int final) |
123 | { |
114 | { |
124 | int ret; |
115 | int ret; |
125 | 116 | ||
126 | if(fr->have_eq_settings) do_equalizer_3dnow(bandPtr,channel,fr->equalizer); |
117 | if(fr->have_eq_settings) do_equalizer_3dnow(bandPtr,channel,fr->equalizer); |
127 | 118 | ||
128 | /* this is in asm, can be dither or not */ |
119 | /* this is in asm, can be dither or not */ |
129 | /* uh, is this return from pointer correct? */ |
120 | /* uh, is this return from pointer correct? */ |
130 | ret = (int) synth_1to1_3dnow_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin); |
121 | ret = (int) synth_1to1_3dnow_asm(bandPtr, channel, fr->buffer.data+fr->buffer.fill, fr->rawbuffs, &fr->bo, fr->decwin); |
131 | if(final) fr->buffer.fill += 128; |
122 | if(final) fr->buffer.fill += 128; |
132 | return ret; |
123 | return ret; |
133 | } |
124 | } |
134 | #endif |
125 | #endif |
135 | 126 | ||
136 | #ifdef OPT_MMX |
127 | #ifdef OPT_MMX |
137 | /* This is defined in assembler. */ |
128 | /* This is defined in assembler. */ |
138 | int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins); |
129 | int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins); |
139 | /* This is just a hull to use the mpg123 handle. */ |
130 | /* This is just a hull to use the mpg123 handle. */ |
140 | int synth_1to1_mmx(real *bandPtr, int channel, mpg123_handle *fr, int final) |
131 | int synth_1to1_mmx(real *bandPtr, int channel, mpg123_handle *fr, int final) |
141 | { |
132 | { |
142 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
133 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
143 | 134 | ||
144 | /* in asm */ |
135 | /* in asm */ |
145 | synth_1to1_MMX(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
136 | synth_1to1_MMX(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
146 | if(final) fr->buffer.fill += 128; |
137 | if(final) fr->buffer.fill += 128; |
147 | return 0; |
138 | return 0; |
148 | } |
139 | } |
149 | #endif |
140 | #endif |
150 | 141 | ||
151 | #ifdef OPT_SSE |
142 | #ifdef OPT_SSE |
152 | #ifdef ACCURATE_ROUNDING |
143 | #ifdef ACCURATE_ROUNDING |
153 | /* This is defined in assembler. */ |
144 | /* This is defined in assembler. */ |
154 | int synth_1to1_sse_accurate_asm(real *window, real *b0, short *samples, int bo1); |
145 | int synth_1to1_sse_accurate_asm(real *window, real *b0, short *samples, int bo1); |
155 | int synth_1to1_stereo_sse_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
146 | int synth_1to1_s_sse_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
156 | void dct64_real_sse(real *out0, real *out1, real *samples); |
147 | void dct64_real_sse(real *out0, real *out1, real *samples); |
157 | /* This is just a hull to use the mpg123 handle. */ |
148 | /* This is just a hull to use the mpg123 handle. */ |
158 | int synth_1to1_sse(real *bandPtr,int channel, mpg123_handle *fr, int final) |
149 | int synth_1to1_sse(real *bandPtr,int channel, mpg123_handle *fr, int final) |
159 | { |
150 | { |
160 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
151 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
161 | real *b0, **buf; |
152 | real *b0, **buf; |
162 | int clip; |
153 | int clip; |
163 | int bo1; |
154 | int bo1; |
164 | 155 | ||
165 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
156 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
166 | 157 | ||
167 | if(!channel) |
158 | if(!channel) |
168 | { |
159 | { |
169 | fr->bo--; |
160 | fr->bo--; |
170 | fr->bo &= 0xf; |
161 | fr->bo &= 0xf; |
171 | buf = fr->real_buffs[0]; |
162 | buf = fr->real_buffs[0]; |
172 | } |
163 | } |
173 | else |
164 | else |
174 | { |
165 | { |
175 | samples++; |
166 | samples++; |
176 | buf = fr->real_buffs[1]; |
167 | buf = fr->real_buffs[1]; |
177 | } |
168 | } |
178 | 169 | ||
179 | if(fr->bo & 0x1) |
170 | if(fr->bo & 0x1) |
180 | { |
171 | { |
181 | b0 = buf[0]; |
172 | b0 = buf[0]; |
182 | bo1 = fr->bo; |
173 | bo1 = fr->bo; |
183 | dct64_real_sse(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
174 | dct64_real_sse(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
184 | } |
175 | } |
185 | else |
176 | else |
186 | { |
177 | { |
187 | b0 = buf[1]; |
178 | b0 = buf[1]; |
188 | bo1 = fr->bo+1; |
179 | bo1 = fr->bo+1; |
189 | dct64_real_sse(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
180 | dct64_real_sse(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
190 | } |
181 | } |
191 | 182 | ||
192 | clip = synth_1to1_sse_accurate_asm(fr->decwin, b0, samples, bo1); |
183 | clip = synth_1to1_sse_accurate_asm(fr->decwin, b0, samples, bo1); |
193 | 184 | ||
194 | if(final) fr->buffer.fill += 128; |
185 | if(final) fr->buffer.fill += 128; |
195 | 186 | ||
196 | return clip; |
187 | return clip; |
197 | } |
188 | } |
198 | 189 | ||
199 | int synth_1to1_stereo_sse(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
190 | int synth_1to1_stereo_sse(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
200 | { |
191 | { |
201 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
192 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
202 | 193 | ||
203 | real *b0l, *b0r, **bufl, **bufr; |
194 | real *b0l, *b0r, **bufl, **bufr; |
204 | int bo1; |
195 | int bo1; |
205 | int clip; |
196 | int clip; |
206 | 197 | ||
207 | if(fr->have_eq_settings) |
198 | if(fr->have_eq_settings) |
208 | { |
199 | { |
209 | do_equalizer(bandPtr_l,0,fr->equalizer); |
200 | do_equalizer(bandPtr_l,0,fr->equalizer); |
210 | do_equalizer(bandPtr_r,1,fr->equalizer); |
201 | do_equalizer(bandPtr_r,1,fr->equalizer); |
211 | } |
202 | } |
212 | 203 | ||
213 | fr->bo--; |
204 | fr->bo--; |
214 | fr->bo &= 0xf; |
205 | fr->bo &= 0xf; |
215 | bufl = fr->real_buffs[0]; |
206 | bufl = fr->real_buffs[0]; |
216 | bufr = fr->real_buffs[1]; |
207 | bufr = fr->real_buffs[1]; |
217 | 208 | ||
218 | if(fr->bo & 0x1) |
209 | if(fr->bo & 0x1) |
219 | { |
210 | { |
220 | b0l = bufl[0]; |
211 | b0l = bufl[0]; |
221 | b0r = bufr[0]; |
212 | b0r = bufr[0]; |
222 | bo1 = fr->bo; |
213 | bo1 = fr->bo; |
223 | dct64_real_sse(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
214 | dct64_real_sse(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
224 | dct64_real_sse(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
215 | dct64_real_sse(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
225 | } |
216 | } |
226 | else |
217 | else |
227 | { |
218 | { |
228 | b0l = bufl[1]; |
219 | b0l = bufl[1]; |
229 | b0r = bufr[1]; |
220 | b0r = bufr[1]; |
230 | bo1 = fr->bo+1; |
221 | bo1 = fr->bo+1; |
231 | dct64_real_sse(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
222 | dct64_real_sse(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
232 | dct64_real_sse(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
223 | dct64_real_sse(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
233 | } |
224 | } |
234 | 225 | ||
235 | clip = synth_1to1_stereo_sse_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
226 | clip = synth_1to1_s_sse_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
236 | 227 | ||
237 | fr->buffer.fill += 128; |
228 | fr->buffer.fill += 128; |
238 | 229 | ||
239 | return clip; |
230 | return clip; |
240 | } |
231 | } |
241 | #else |
232 | #else |
242 | /* This is defined in assembler. */ |
233 | /* This is defined in assembler. */ |
243 | void synth_1to1_sse_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin); |
234 | void synth_1to1_sse_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin); |
244 | /* This is just a hull to use the mpg123 handle. */ |
235 | /* This is just a hull to use the mpg123 handle. */ |
245 | int synth_1to1_sse(real *bandPtr, int channel, mpg123_handle *fr, int final) |
236 | int synth_1to1_sse(real *bandPtr, int channel, mpg123_handle *fr, int final) |
246 | { |
237 | { |
247 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
238 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
248 | 239 | ||
249 | synth_1to1_sse_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
240 | synth_1to1_sse_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
250 | if(final) fr->buffer.fill += 128; |
241 | if(final) fr->buffer.fill += 128; |
251 | return 0; |
242 | return 0; |
252 | } |
243 | } |
253 | #endif |
244 | #endif |
254 | #endif |
245 | #endif |
255 | 246 | ||
256 | #ifdef OPT_3DNOWEXT |
247 | #ifdef OPT_3DNOWEXT |
257 | /* This is defined in assembler. */ |
248 | /* This is defined in assembler. */ |
258 | void synth_1to1_3dnowext_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin); |
249 | void synth_1to1_3dnowext_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin); |
259 | /* This is just a hull to use the mpg123 handle. */ |
250 | /* This is just a hull to use the mpg123 handle. */ |
260 | int synth_1to1_3dnowext(real *bandPtr, int channel, mpg123_handle *fr, int final) |
251 | int synth_1to1_3dnowext(real *bandPtr, int channel, mpg123_handle *fr, int final) |
261 | { |
252 | { |
262 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
253 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
263 | 254 | ||
264 | synth_1to1_3dnowext_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
255 | synth_1to1_3dnowext_asm(bandPtr, channel, (short*) (fr->buffer.data+fr->buffer.fill), (short *) fr->rawbuffs, &fr->bo, fr->decwins); |
265 | if(final) fr->buffer.fill += 128; |
256 | if(final) fr->buffer.fill += 128; |
266 | return 0; |
257 | return 0; |
267 | } |
258 | } |
268 | #endif |
259 | #endif |
269 | 260 | ||
270 | #ifdef OPT_X86_64 |
261 | #ifdef OPT_X86_64 |
271 | #ifdef ACCURATE_ROUNDING |
262 | #ifdef ACCURATE_ROUNDING |
272 | /* Assembler routines. */ |
263 | /* Assembler routines. */ |
273 | int synth_1to1_x86_64_accurate_asm(real *window, real *b0, short *samples, int bo1); |
264 | int synth_1to1_x86_64_accurate_asm(real *window, real *b0, short *samples, int bo1); |
274 | int synth_1to1_stereo_x86_64_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
265 | int synth_1to1_s_x86_64_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
275 | void dct64_real_x86_64(real *out0, real *out1, real *samples); |
266 | void dct64_real_x86_64(real *out0, real *out1, real *samples); |
276 | /* Hull for C mpg123 API */ |
267 | /* Hull for C mpg123 API */ |
277 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
268 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
278 | { |
269 | { |
279 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
270 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
280 | 271 | ||
281 | real *b0, **buf; |
272 | real *b0, **buf; |
282 | int bo1; |
273 | int bo1; |
283 | int clip; |
274 | int clip; |
284 | 275 | ||
285 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
276 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
286 | 277 | ||
287 | if(!channel) |
278 | if(!channel) |
288 | { |
279 | { |
289 | fr->bo--; |
280 | fr->bo--; |
290 | fr->bo &= 0xf; |
281 | fr->bo &= 0xf; |
291 | buf = fr->real_buffs[0]; |
282 | buf = fr->real_buffs[0]; |
292 | } |
283 | } |
293 | else |
284 | else |
294 | { |
285 | { |
295 | samples++; |
286 | samples++; |
296 | buf = fr->real_buffs[1]; |
287 | buf = fr->real_buffs[1]; |
297 | } |
288 | } |
298 | 289 | ||
299 | if(fr->bo & 0x1) |
290 | if(fr->bo & 0x1) |
300 | { |
291 | { |
301 | b0 = buf[0]; |
292 | b0 = buf[0]; |
302 | bo1 = fr->bo; |
293 | bo1 = fr->bo; |
303 | dct64_real_x86_64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
294 | dct64_real_x86_64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
304 | } |
295 | } |
305 | else |
296 | else |
306 | { |
297 | { |
307 | b0 = buf[1]; |
298 | b0 = buf[1]; |
308 | bo1 = fr->bo+1; |
299 | bo1 = fr->bo+1; |
309 | dct64_real_x86_64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
300 | dct64_real_x86_64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
310 | } |
301 | } |
311 | 302 | ||
312 | clip = synth_1to1_x86_64_accurate_asm(fr->decwin, b0, samples, bo1); |
303 | clip = synth_1to1_x86_64_accurate_asm(fr->decwin, b0, samples, bo1); |
313 | 304 | ||
314 | if(final) fr->buffer.fill += 128; |
305 | if(final) fr->buffer.fill += 128; |
315 | 306 | ||
316 | return clip; |
307 | return clip; |
317 | } |
308 | } |
318 | 309 | ||
319 | int synth_1to1_stereo_x86_64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
310 | int synth_1to1_stereo_x86_64(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
320 | { |
311 | { |
321 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
312 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
322 | 313 | ||
323 | real *b0l, *b0r, **bufl, **bufr; |
314 | real *b0l, *b0r, **bufl, **bufr; |
324 | int bo1; |
315 | int bo1; |
325 | int clip; |
316 | int clip; |
326 | 317 | ||
327 | if(fr->have_eq_settings) |
318 | if(fr->have_eq_settings) |
328 | { |
319 | { |
329 | do_equalizer(bandPtr_l,0,fr->equalizer); |
320 | do_equalizer(bandPtr_l,0,fr->equalizer); |
330 | do_equalizer(bandPtr_r,1,fr->equalizer); |
321 | do_equalizer(bandPtr_r,1,fr->equalizer); |
331 | } |
322 | } |
332 | 323 | ||
333 | fr->bo--; |
324 | fr->bo--; |
334 | fr->bo &= 0xf; |
325 | fr->bo &= 0xf; |
335 | bufl = fr->real_buffs[0]; |
326 | bufl = fr->real_buffs[0]; |
336 | bufr = fr->real_buffs[1]; |
327 | bufr = fr->real_buffs[1]; |
337 | 328 | ||
338 | if(fr->bo & 0x1) |
329 | if(fr->bo & 0x1) |
339 | { |
330 | { |
340 | b0l = bufl[0]; |
331 | b0l = bufl[0]; |
341 | b0r = bufr[0]; |
332 | b0r = bufr[0]; |
342 | bo1 = fr->bo; |
333 | bo1 = fr->bo; |
343 | dct64_real_x86_64(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
334 | dct64_real_x86_64(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
344 | dct64_real_x86_64(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
335 | dct64_real_x86_64(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
345 | } |
336 | } |
346 | else |
337 | else |
347 | { |
338 | { |
348 | b0l = bufl[1]; |
339 | b0l = bufl[1]; |
349 | b0r = bufr[1]; |
340 | b0r = bufr[1]; |
350 | bo1 = fr->bo+1; |
341 | bo1 = fr->bo+1; |
351 | dct64_real_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
342 | dct64_real_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
352 | dct64_real_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
343 | dct64_real_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
353 | } |
344 | } |
354 | 345 | ||
355 | clip = synth_1to1_stereo_x86_64_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
346 | clip = synth_1to1_s_x86_64_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
356 | 347 | ||
357 | fr->buffer.fill += 128; |
348 | fr->buffer.fill += 128; |
358 | 349 | ||
359 | return clip; |
350 | return clip; |
360 | } |
351 | } |
361 | #else |
352 | #else |
362 | /* This is defined in assembler. */ |
353 | /* This is defined in assembler. */ |
363 | int synth_1to1_x86_64_asm(short *window, short *b0, short *samples, int bo1); |
354 | int synth_1to1_x86_64_asm(short *window, short *b0, short *samples, int bo1); |
364 | int synth_1to1_stereo_x86_64_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
355 | int synth_1to1_s_x86_64_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
365 | void dct64_x86_64(short *out0, short *out1, real *samples); |
356 | void dct64_x86_64(short *out0, short *out1, real *samples); |
366 | /* This is just a hull to use the mpg123 handle. */ |
357 | /* This is just a hull to use the mpg123 handle. */ |
367 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
358 | int synth_1to1_x86_64(real *bandPtr,int channel, mpg123_handle *fr, int final) |
368 | { |
359 | { |
369 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
360 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
370 | short *b0, **buf; |
361 | short *b0, **buf; |
371 | int clip; |
362 | int clip; |
372 | int bo1; |
363 | int bo1; |
373 | 364 | ||
374 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
365 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
375 | 366 | ||
376 | if(!channel) |
367 | if(!channel) |
377 | { |
368 | { |
378 | fr->bo--; |
369 | fr->bo--; |
379 | fr->bo &= 0xf; |
370 | fr->bo &= 0xf; |
380 | buf = fr->short_buffs[0]; |
371 | buf = fr->short_buffs[0]; |
381 | } |
372 | } |
382 | else |
373 | else |
383 | { |
374 | { |
384 | samples++; |
375 | samples++; |
385 | buf = fr->short_buffs[1]; |
376 | buf = fr->short_buffs[1]; |
386 | } |
377 | } |
387 | 378 | ||
388 | if(fr->bo & 0x1) |
379 | if(fr->bo & 0x1) |
389 | { |
380 | { |
390 | b0 = buf[0]; |
381 | b0 = buf[0]; |
391 | bo1 = fr->bo; |
382 | bo1 = fr->bo; |
392 | dct64_x86_64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
383 | dct64_x86_64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
393 | } |
384 | } |
394 | else |
385 | else |
395 | { |
386 | { |
396 | b0 = buf[1]; |
387 | b0 = buf[1]; |
397 | bo1 = fr->bo+1; |
388 | bo1 = fr->bo+1; |
398 | dct64_x86_64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
389 | dct64_x86_64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
399 | } |
390 | } |
400 | 391 | ||
401 | clip = synth_1to1_x86_64_asm((short *)fr->decwins, b0, samples, bo1); |
392 | clip = synth_1to1_x86_64_asm((short *)fr->decwins, b0, samples, bo1); |
402 | 393 | ||
403 | if(final) fr->buffer.fill += 128; |
394 | if(final) fr->buffer.fill += 128; |
404 | 395 | ||
405 | return clip; |
396 | return clip; |
406 | } |
397 | } |
407 | 398 | ||
408 | int synth_1to1_stereo_x86_64(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr) |
399 | int synth_1to1_stereo_x86_64(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr) |
409 | { |
400 | { |
410 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
401 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
411 | short *b0l, *b0r, **bufl, **bufr; |
402 | short *b0l, *b0r, **bufl, **bufr; |
412 | int clip; |
403 | int clip; |
413 | int bo1; |
404 | int bo1; |
414 | 405 | ||
415 | if(fr->have_eq_settings) |
406 | if(fr->have_eq_settings) |
416 | { |
407 | { |
417 | do_equalizer(bandPtr_l,0,fr->equalizer); |
408 | do_equalizer(bandPtr_l,0,fr->equalizer); |
418 | do_equalizer(bandPtr_r,1,fr->equalizer); |
409 | do_equalizer(bandPtr_r,1,fr->equalizer); |
419 | } |
410 | } |
420 | 411 | ||
421 | fr->bo--; |
412 | fr->bo--; |
422 | fr->bo &= 0xf; |
413 | fr->bo &= 0xf; |
423 | bufl = fr->short_buffs[0]; |
414 | bufl = fr->short_buffs[0]; |
424 | bufr = fr->short_buffs[1]; |
415 | bufr = fr->short_buffs[1]; |
425 | 416 | ||
426 | if(fr->bo & 0x1) |
417 | if(fr->bo & 0x1) |
427 | { |
418 | { |
428 | b0l = bufl[0]; |
419 | b0l = bufl[0]; |
429 | b0r = bufr[0]; |
420 | b0r = bufr[0]; |
430 | bo1 = fr->bo; |
421 | bo1 = fr->bo; |
431 | dct64_x86_64(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
422 | dct64_x86_64(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
432 | dct64_x86_64(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
423 | dct64_x86_64(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
433 | } |
424 | } |
434 | else |
425 | else |
435 | { |
426 | { |
436 | b0l = bufl[1]; |
427 | b0l = bufl[1]; |
437 | b0r = bufr[1]; |
428 | b0r = bufr[1]; |
438 | bo1 = fr->bo+1; |
429 | bo1 = fr->bo+1; |
439 | dct64_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
430 | dct64_x86_64(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
440 | dct64_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
431 | dct64_x86_64(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
441 | } |
432 | } |
442 | 433 | ||
443 | clip = synth_1to1_stereo_x86_64_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
434 | clip = synth_1to1_s_x86_64_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
444 | 435 | ||
445 | fr->buffer.fill += 128; |
436 | fr->buffer.fill += 128; |
446 | 437 | ||
447 | return clip; |
438 | return clip; |
448 | } |
439 | } |
449 | #endif |
440 | #endif |
450 | #endif |
441 | #endif |
451 | 442 | ||
452 | #ifdef OPT_ARM |
443 | #ifdef OPT_ARM |
453 | #ifdef ACCURATE_ROUNDING |
444 | #ifdef ACCURATE_ROUNDING |
454 | /* Assembler routines. */ |
445 | /* Assembler routines. */ |
455 | int synth_1to1_arm_accurate_asm(real *window, real *b0, short *samples, int bo1); |
446 | int synth_1to1_arm_accurate_asm(real *window, real *b0, short *samples, int bo1); |
456 | /* Hull for C mpg123 API */ |
447 | /* Hull for C mpg123 API */ |
457 | int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final) |
448 | int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final) |
458 | { |
449 | { |
459 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
450 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
460 | 451 | ||
461 | real *b0, **buf; |
452 | real *b0, **buf; |
462 | int bo1; |
453 | int bo1; |
463 | int clip; |
454 | int clip; |
464 | 455 | ||
465 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
456 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
466 | 457 | ||
467 | if(!channel) |
458 | if(!channel) |
468 | { |
459 | { |
469 | fr->bo--; |
460 | fr->bo--; |
470 | fr->bo &= 0xf; |
461 | fr->bo &= 0xf; |
471 | buf = fr->real_buffs[0]; |
462 | buf = fr->real_buffs[0]; |
472 | } |
463 | } |
473 | else |
464 | else |
474 | { |
465 | { |
475 | samples++; |
466 | samples++; |
476 | buf = fr->real_buffs[1]; |
467 | buf = fr->real_buffs[1]; |
477 | } |
468 | } |
478 | 469 | ||
479 | if(fr->bo & 0x1) |
470 | if(fr->bo & 0x1) |
480 | { |
471 | { |
481 | b0 = buf[0]; |
472 | b0 = buf[0]; |
482 | bo1 = fr->bo; |
473 | bo1 = fr->bo; |
483 | dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
474 | dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
484 | } |
475 | } |
485 | else |
476 | else |
486 | { |
477 | { |
487 | b0 = buf[1]; |
478 | b0 = buf[1]; |
488 | bo1 = fr->bo+1; |
479 | bo1 = fr->bo+1; |
489 | dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
480 | dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
490 | } |
481 | } |
491 | 482 | ||
492 | clip = synth_1to1_arm_accurate_asm(fr->decwin, b0, samples, bo1); |
483 | clip = synth_1to1_arm_accurate_asm(fr->decwin, b0, samples, bo1); |
493 | 484 | ||
494 | if(final) fr->buffer.fill += 128; |
485 | if(final) fr->buffer.fill += 128; |
495 | 486 | ||
496 | return clip; |
487 | return clip; |
497 | } |
488 | } |
498 | #else |
489 | #else |
499 | /* Assembler routines. */ |
490 | /* Assembler routines. */ |
500 | int synth_1to1_arm_asm(real *window, real *b0, short *samples, int bo1); |
491 | int synth_1to1_arm_asm(real *window, real *b0, short *samples, int bo1); |
501 | /* Hull for C mpg123 API */ |
492 | /* Hull for C mpg123 API */ |
502 | int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final) |
493 | int synth_1to1_arm(real *bandPtr,int channel, mpg123_handle *fr, int final) |
503 | { |
494 | { |
504 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
495 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
505 | 496 | ||
506 | real *b0, **buf; |
497 | real *b0, **buf; |
507 | int bo1; |
498 | int bo1; |
508 | int clip; |
499 | int clip; |
509 | 500 | ||
510 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
501 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
511 | 502 | ||
512 | if(!channel) |
503 | if(!channel) |
513 | { |
504 | { |
514 | fr->bo--; |
505 | fr->bo--; |
515 | fr->bo &= 0xf; |
506 | fr->bo &= 0xf; |
516 | buf = fr->real_buffs[0]; |
507 | buf = fr->real_buffs[0]; |
517 | } |
508 | } |
518 | else |
509 | else |
519 | { |
510 | { |
520 | samples++; |
511 | samples++; |
521 | buf = fr->real_buffs[1]; |
512 | buf = fr->real_buffs[1]; |
522 | } |
513 | } |
523 | 514 | ||
524 | if(fr->bo & 0x1) |
515 | if(fr->bo & 0x1) |
525 | { |
516 | { |
526 | b0 = buf[0]; |
517 | b0 = buf[0]; |
527 | bo1 = fr->bo; |
518 | bo1 = fr->bo; |
528 | dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
519 | dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
529 | } |
520 | } |
530 | else |
521 | else |
531 | { |
522 | { |
532 | b0 = buf[1]; |
523 | b0 = buf[1]; |
533 | bo1 = fr->bo+1; |
524 | bo1 = fr->bo+1; |
534 | dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
525 | dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
535 | } |
526 | } |
536 | 527 | ||
537 | clip = synth_1to1_arm_asm(fr->decwin, b0, samples, bo1); |
528 | clip = synth_1to1_arm_asm(fr->decwin, b0, samples, bo1); |
538 | 529 | ||
539 | if(final) fr->buffer.fill += 128; |
530 | if(final) fr->buffer.fill += 128; |
540 | 531 | ||
541 | return clip; |
532 | return clip; |
542 | } |
533 | } |
543 | #endif |
534 | #endif |
544 | #endif |
535 | #endif |
- | 536 | ||
- | 537 | #ifdef OPT_NEON |
|
- | 538 | #ifdef ACCURATE_ROUNDING |
|
- | 539 | /* This is defined in assembler. */ |
|
- | 540 | int synth_1to1_neon_accurate_asm(real *window, real *b0, short *samples, int bo1); |
|
- | 541 | int synth_1to1_s_neon_accurate_asm(real *window, real *b0l, real *b0r, short *samples, int bo1); |
|
- | 542 | void dct64_real_neon(real *out0, real *out1, real *samples); |
|
- | 543 | /* Hull for C mpg123 API */ |
|
- | 544 | int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final) |
|
- | 545 | { |
|
- | 546 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 547 | ||
- | 548 | real *b0, **buf; |
|
- | 549 | int bo1; |
|
- | 550 | int clip; |
|
- | 551 | ||
- | 552 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
|
- | 553 | ||
- | 554 | if(!channel) |
|
- | 555 | { |
|
- | 556 | fr->bo--; |
|
- | 557 | fr->bo &= 0xf; |
|
- | 558 | buf = fr->real_buffs[0]; |
|
- | 559 | } |
|
- | 560 | else |
|
- | 561 | { |
|
- | 562 | samples++; |
|
- | 563 | buf = fr->real_buffs[1]; |
|
- | 564 | } |
|
- | 565 | ||
- | 566 | if(fr->bo & 0x1) |
|
- | 567 | { |
|
- | 568 | b0 = buf[0]; |
|
- | 569 | bo1 = fr->bo; |
|
- | 570 | dct64_real_neon(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
|
- | 571 | } |
|
- | 572 | else |
|
- | 573 | { |
|
- | 574 | b0 = buf[1]; |
|
- | 575 | bo1 = fr->bo+1; |
|
- | 576 | dct64_real_neon(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
|
- | 577 | } |
|
- | 578 | ||
- | 579 | clip = synth_1to1_neon_accurate_asm(fr->decwin, b0, samples, bo1); |
|
- | 580 | ||
- | 581 | if(final) fr->buffer.fill += 128; |
|
- | 582 | ||
- | 583 | return clip; |
|
- | 584 | } |
|
- | 585 | ||
- | 586 | int synth_1to1_stereo_neon(real *bandPtr_l, real *bandPtr_r, mpg123_handle *fr) |
|
- | 587 | { |
|
- | 588 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 589 | ||
- | 590 | real *b0l, *b0r, **bufl, **bufr; |
|
- | 591 | int bo1; |
|
- | 592 | int clip; |
|
- | 593 | ||
- | 594 | if(fr->have_eq_settings) |
|
- | 595 | { |
|
- | 596 | do_equalizer(bandPtr_l,0,fr->equalizer); |
|
- | 597 | do_equalizer(bandPtr_r,1,fr->equalizer); |
|
- | 598 | } |
|
- | 599 | ||
- | 600 | fr->bo--; |
|
- | 601 | fr->bo &= 0xf; |
|
- | 602 | bufl = fr->real_buffs[0]; |
|
- | 603 | bufr = fr->real_buffs[1]; |
|
- | 604 | ||
- | 605 | if(fr->bo & 0x1) |
|
- | 606 | { |
|
- | 607 | b0l = bufl[0]; |
|
- | 608 | b0r = bufr[0]; |
|
- | 609 | bo1 = fr->bo; |
|
- | 610 | dct64_real_neon(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
|
- | 611 | dct64_real_neon(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
|
- | 612 | } |
|
- | 613 | else |
|
- | 614 | { |
|
- | 615 | b0l = bufl[1]; |
|
- | 616 | b0r = bufr[1]; |
|
- | 617 | bo1 = fr->bo+1; |
|
- | 618 | dct64_real_neon(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
|
- | 619 | dct64_real_neon(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
|
- | 620 | } |
|
- | 621 | ||
- | 622 | clip = synth_1to1_s_neon_accurate_asm(fr->decwin, b0l, b0r, samples, bo1); |
|
- | 623 | ||
- | 624 | fr->buffer.fill += 128; |
|
- | 625 | ||
- | 626 | return clip; |
|
- | 627 | } |
|
- | 628 | #else |
|
- | 629 | /* This is defined in assembler. */ |
|
- | 630 | int synth_1to1_neon_asm(short *window, short *b0, short *samples, int bo1); |
|
- | 631 | int synth_1to1_s_neon_asm(short *window, short *b0l, short *b0r, short *samples, int bo1); |
|
- | 632 | void dct64_neon(short *out0, short *out1, real *samples); |
|
- | 633 | /* Hull for C mpg123 API */ |
|
- | 634 | int synth_1to1_neon(real *bandPtr,int channel, mpg123_handle *fr, int final) |
|
- | 635 | { |
|
- | 636 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 637 | short *b0, **buf; |
|
- | 638 | int clip; |
|
- | 639 | int bo1; |
|
- | 640 | ||
- | 641 | if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); |
|
- | 642 | ||
- | 643 | if(!channel) |
|
- | 644 | { |
|
- | 645 | fr->bo--; |
|
- | 646 | fr->bo &= 0xf; |
|
- | 647 | buf = fr->short_buffs[0]; |
|
- | 648 | } |
|
- | 649 | else |
|
- | 650 | { |
|
- | 651 | samples++; |
|
- | 652 | buf = fr->short_buffs[1]; |
|
- | 653 | } |
|
- | 654 | ||
- | 655 | if(fr->bo & 0x1) |
|
- | 656 | { |
|
- | 657 | b0 = buf[0]; |
|
- | 658 | bo1 = fr->bo; |
|
- | 659 | dct64_neon(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); |
|
- | 660 | } |
|
- | 661 | else |
|
- | 662 | { |
|
- | 663 | b0 = buf[1]; |
|
- | 664 | bo1 = fr->bo+1; |
|
- | 665 | dct64_neon(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); |
|
- | 666 | } |
|
- | 667 | ||
- | 668 | clip = synth_1to1_neon_asm((short *)fr->decwins, b0, samples, bo1); |
|
- | 669 | ||
- | 670 | if(final) fr->buffer.fill += 128; |
|
- | 671 | ||
- | 672 | return clip; |
|
- | 673 | } |
|
- | 674 | ||
- | 675 | int synth_1to1_stereo_neon(real *bandPtr_l,real *bandPtr_r, mpg123_handle *fr) |
|
- | 676 | { |
|
- | 677 | short *samples = (short *) (fr->buffer.data+fr->buffer.fill); |
|
- | 678 | short *b0l, *b0r, **bufl, **bufr; |
|
- | 679 | int clip; |
|
- | 680 | int bo1; |
|
- | 681 | ||
- | 682 | if(fr->have_eq_settings) |
|
- | 683 | { |
|
- | 684 | do_equalizer(bandPtr_l,0,fr->equalizer); |
|
- | 685 | do_equalizer(bandPtr_r,1,fr->equalizer); |
|
- | 686 | } |
|
- | 687 | ||
- | 688 | fr->bo--; |
|
- | 689 | fr->bo &= 0xf; |
|
- | 690 | bufl = fr->short_buffs[0]; |
|
- | 691 | bufr = fr->short_buffs[1]; |
|
- | 692 | ||
- | 693 | if(fr->bo & 0x1) |
|
- | 694 | { |
|
- | 695 | b0l = bufl[0]; |
|
- | 696 | b0r = bufr[0]; |
|
- | 697 | bo1 = fr->bo; |
|
- | 698 | dct64_neon(bufl[1]+((fr->bo+1)&0xf),bufl[0]+fr->bo,bandPtr_l); |
|
- | 699 | dct64_neon(bufr[1]+((fr->bo+1)&0xf),bufr[0]+fr->bo,bandPtr_r); |
|
- | 700 | } |
|
- | 701 | else |
|
- | 702 | { |
|
- | 703 | b0l = bufl[1]; |
|
- | 704 | b0r = bufr[1]; |
|
- | 705 | bo1 = fr->bo+1; |
|
- | 706 | dct64_neon(bufl[0]+fr->bo,bufl[1]+fr->bo+1,bandPtr_l); |
|
- | 707 | dct64_neon(bufr[0]+fr->bo,bufr[1]+fr->bo+1,bandPtr_r); |
|
- | 708 | } |
|
- | 709 | ||
- | 710 | clip = synth_1to1_s_neon_asm((short *)fr->decwins, b0l, b0r, samples, bo1); |
|
- | 711 | ||
- | 712 | fr->buffer.fill += 128; |
|
- | 713 | ||
- | 714 | return clip; |
|
- | 715 | } |
|
- | 716 | #endif |
|
- | 717 | #endif |
|
545 | 718 | ||
546 | #ifndef NO_DOWNSAMPLE |
719 | #ifndef NO_DOWNSAMPLE |
547 | 720 | ||
548 | /* |
721 | /* |
549 | Part 1b: 2to1 synth. |
722 | Part 1b: 2to1 synth. |
550 | Only generic and i386 functions this time. |
723 | Only generic and i386 functions this time. |
551 | */ |
724 | */ |
552 | #define BLOCK 0x20 /* One decoding block is 32 samples. */ |
725 | #define BLOCK 0x20 /* One decoding block is 32 samples. */ |
553 | 726 | ||
554 | #define SYNTH_NAME synth_2to1 |
727 | #define SYNTH_NAME synth_2to1 |
555 | #include "synth.h" |
728 | #include "synth.h" |
556 | #undef SYNTH_NAME |
729 | #undef SYNTH_NAME |
557 | 730 | ||
558 | #ifdef OPT_DITHER /* Used for generic_dither and as fallback for i586_dither. */ |
731 | #ifdef OPT_DITHER /* Used for generic_dither and as fallback for i586_dither. */ |
559 | #define SYNTH_NAME synth_2to1_dither |
732 | #define SYNTH_NAME synth_2to1_dither |
560 | #define USE_DITHER |
733 | #define USE_DITHER |
561 | #include "synth.h" |
734 | #include "synth.h" |
562 | #undef USE_DITHER |
735 | #undef USE_DITHER |
563 | #undef SYNTH_NAME |
736 | #undef SYNTH_NAME |
564 | #endif |
737 | #endif |
565 | 738 | ||
566 | #define SYNTH_NAME fr->synths.plain[r_2to1][f_16] |
739 | #define SYNTH_NAME fr->synths.plain[r_2to1][f_16] |
567 | #define MONO_NAME synth_2to1_mono |
740 | #define MONO_NAME synth_2to1_mono |
568 | #define MONO2STEREO_NAME synth_2to1_mono2stereo |
741 | #define MONO2STEREO_NAME synth_2to1_m2s |
569 | #include "synth_mono.h" |
742 | #include "synth_mono.h" |
570 | #undef SYNTH_NAME |
743 | #undef SYNTH_NAME |
571 | #undef MONO_NAME |
744 | #undef MONO_NAME |
572 | #undef MONO2STEREO_NAME |
745 | #undef MONO2STEREO_NAME |
573 | 746 | ||
574 | #ifdef OPT_X86 |
747 | #ifdef OPT_X86 |
575 | #define NO_AUTOINCREMENT |
748 | #define NO_AUTOINCREMENT |
576 | #define SYNTH_NAME synth_2to1_i386 |
749 | #define SYNTH_NAME synth_2to1_i386 |
577 | #include "synth.h" |
750 | #include "synth.h" |
578 | #undef SYNTH_NAME |
751 | #undef SYNTH_NAME |
579 | /* i386 uses the normal mono functions. */ |
752 | /* i386 uses the normal mono functions. */ |
580 | #undef NO_AUTOINCREMENT |
753 | #undef NO_AUTOINCREMENT |
581 | #endif |
754 | #endif |
582 | 755 | ||
583 | #undef BLOCK |
756 | #undef BLOCK |
584 | 757 | ||
585 | /* |
758 | /* |
586 | Part 1c: 4to1 synth. |
759 | Part 1c: 4to1 synth. |
587 | Same procedure as above... |
760 | Same procedure as above... |
588 | */ |
761 | */ |
589 | #define BLOCK 0x10 /* One decoding block is 16 samples. */ |
762 | #define BLOCK 0x10 /* One decoding block is 16 samples. */ |
590 | 763 | ||
591 | #define SYNTH_NAME synth_4to1 |
764 | #define SYNTH_NAME synth_4to1 |
592 | #include "synth.h" |
765 | #include "synth.h" |
593 | #undef SYNTH_NAME |
766 | #undef SYNTH_NAME |
594 | 767 | ||
595 | #ifdef OPT_DITHER |
768 | #ifdef OPT_DITHER |
596 | #define SYNTH_NAME synth_4to1_dither |
769 | #define SYNTH_NAME synth_4to1_dither |
597 | #define USE_DITHER |
770 | #define USE_DITHER |
598 | #include "synth.h" |
771 | #include "synth.h" |
599 | #undef USE_DITHER |
772 | #undef USE_DITHER |
600 | #undef SYNTH_NAME |
773 | #undef SYNTH_NAME |
601 | #endif |
774 | #endif |
602 | 775 | ||
603 | #define SYNTH_NAME fr->synths.plain[r_4to1][f_16] /* This is just for the _i386 one... gotta check if it is really useful... */ |
776 | #define SYNTH_NAME fr->synths.plain[r_4to1][f_16] /* This is just for the _i386 one... gotta check if it is really useful... */ |
604 | #define MONO_NAME synth_4to1_mono |
777 | #define MONO_NAME synth_4to1_mono |
605 | #define MONO2STEREO_NAME synth_4to1_mono2stereo |
778 | #define MONO2STEREO_NAME synth_4to1_m2s |
606 | #include "synth_mono.h" |
779 | #include "synth_mono.h" |
607 | #undef SYNTH_NAME |
780 | #undef SYNTH_NAME |
608 | #undef MONO_NAME |
781 | #undef MONO_NAME |
609 | #undef MONO2STEREO_NAME |
782 | #undef MONO2STEREO_NAME |
610 | 783 | ||
611 | #ifdef OPT_X86 |
784 | #ifdef OPT_X86 |
612 | #define NO_AUTOINCREMENT |
785 | #define NO_AUTOINCREMENT |
613 | #define SYNTH_NAME synth_4to1_i386 |
786 | #define SYNTH_NAME synth_4to1_i386 |
614 | #include "synth.h" |
787 | #include "synth.h" |
615 | #undef SYNTH_NAME |
788 | #undef SYNTH_NAME |
616 | /* i386 uses the normal mono functions. */ |
789 | /* i386 uses the normal mono functions. */ |
617 | #undef NO_AUTOINCREMENT |
790 | #undef NO_AUTOINCREMENT |
618 | #endif |
791 | #endif |
619 | 792 | ||
620 | #undef BLOCK |
793 | #undef BLOCK |
621 | 794 | ||
622 | #endif /* NO_DOWNSAMPLE */ |
795 | #endif /* NO_DOWNSAMPLE */ |
623 | 796 | ||
624 | #ifndef NO_NTOM |
797 | #ifndef NO_NTOM |
625 | /* |
798 | /* |
626 | Part 1d: ntom synth. |
799 | Part 1d: ntom synth. |
627 | Same procedure as above... Just no extra play anymore, straight synth that uses the plain dct64. |
800 | Same procedure as above... Just no extra play anymore, straight synth that uses the plain dct64. |
628 | */ |
801 | */ |
629 | 802 | ||
630 | /* These are all in one header, there's no flexibility to gain. */ |
803 | /* These are all in one header, there's no flexibility to gain. */ |
631 | #define SYNTH_NAME synth_ntom |
804 | #define SYNTH_NAME synth_ntom |
632 | #define MONO_NAME synth_ntom_mono |
805 | #define MONO_NAME synth_ntom_mono |
633 | #define MONO2STEREO_NAME synth_ntom_mono2stereo |
806 | #define MONO2STEREO_NAME synth_ntom_m2s |
634 | #include "synth_ntom.h" |
807 | #include "synth_ntom.h" |
635 | #undef SYNTH_NAME |
808 | #undef SYNTH_NAME |
636 | #undef MONO_NAME |
809 | #undef MONO_NAME |
637 | #undef MONO2STEREO_NAME |
810 | #undef MONO2STEREO_NAME |
638 | 811 | ||
639 | #endif |
812 | #endif |
640 | 813 | ||
641 | /* Done with short output. */ |
814 | /* Done with short output. */ |
642 | #undef SAMPLE_T |
815 | #undef SAMPLE_T |
643 | #undef WRITE_SAMPLE |
816 | #undef WRITE_SAMPLE |