Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1905 | serge | 1 | /* |
2 | decode.h: common definitions for decode functions |
||
3 | |||
4 | This file is strongly tied with optimize.h concerning the synth functions. |
||
5 | Perhaps one should restructure that a bit. |
||
6 | |||
7 | copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1 |
||
8 | see COPYING and AUTHORS files in distribution or http://mpg123.org |
||
9 | initially written by Thomas Orgis, taking WRITE_SAMPLE from decode.c |
||
10 | */ |
||
11 | #ifndef MPG123_DECODE_H |
||
12 | #define MPG123_DECODE_H |
||
13 | |||
14 | /* Selection of class of output routines for basic format. */ |
||
15 | #ifndef REAL_IS_FIXED |
||
16 | #define OUT_FORMATS 4 /* Basic output formats: 16bit, 8bit, real and s32 */ |
||
17 | #else |
||
18 | #define OUT_FORMATS 2 /* Only up to 16bit */ |
||
19 | #endif |
||
20 | |||
21 | #define OUT_16 0 |
||
22 | #define OUT_8 1 |
||
23 | /* Those are defined but not supported for fixed point decoding! */ |
||
24 | #define OUT_REAL 2 /* Write a floating point sample (that is, one matching the internal real type). */ |
||
25 | #define OUT_S32 3 |
||
26 | |||
27 | #ifdef NO_NTOM |
||
28 | #define NTOM_MAX 1 |
||
29 | #else |
||
30 | #define NTOM_MAX 8 /* maximum allowed factor for upsampling */ |
||
31 | #define NTOM_MAX_FREQ 96000 /* maximum frequency to upsample to / downsample from */ |
||
32 | #define NTOM_MUL (32768) |
||
33 | #endif |
||
34 | |||
35 | /* Let's collect all possible synth functions here, for an overview. |
||
36 | If they are actually defined and used depends on preprocessor machinery. |
||
37 | See synth.c and optimize.h for that, also some special C and assembler files. */ |
||
38 | |||
39 | /* The call of left and right plain synth, wrapped. |
||
40 | This may be replaced by a direct stereo optimized synth. */ |
||
41 | int synth_stereo_wrap(real*, real*, mpg123_handle*); |
||
42 | |||
43 | #ifndef NO_16BIT |
||
44 | /* The signed-16bit-producing variants. */ |
||
45 | int synth_1to1 (real*, int, mpg123_handle*, int); |
||
46 | int synth_1to1_dither (real*, int, mpg123_handle*, int); |
||
47 | int synth_1to1_i386 (real*, int, mpg123_handle*, int); |
||
48 | int synth_1to1_i586 (real*, int, mpg123_handle*, int); |
||
49 | int synth_1to1_i586_dither(real*, int, mpg123_handle*, int); |
||
50 | int synth_1to1_mmx (real*, int, mpg123_handle*, int); |
||
51 | int synth_1to1_3dnow (real*, int, mpg123_handle*, int); |
||
52 | int synth_1to1_sse (real*, int, mpg123_handle*, int); |
||
53 | int synth_1to1_stereo_sse (real*, real*, mpg123_handle*); |
||
54 | int synth_1to1_3dnowext (real*, int, mpg123_handle*, int); |
||
55 | int synth_1to1_altivec (real*, int, mpg123_handle*, int); |
||
56 | int synth_1to1_stereo_altivec(real*, real*, mpg123_handle*); |
||
57 | int synth_1to1_x86_64 (real*, int, mpg123_handle*, int); |
||
58 | int synth_1to1_stereo_x86_64(real*, real*, mpg123_handle*); |
||
59 | int synth_1to1_arm (real*, int, mpg123_handle*, int); |
||
60 | /* This is different, special usage in layer3.c only. |
||
61 | Hence, the name... and now forget about it. |
||
62 | Never use it outside that special portion of code inside layer3.c! */ |
||
63 | int absynth_1to1_i486(real*, int, mpg123_handle*, int); |
||
64 | /* These mono/stereo converters use one of the above for the grunt work. */ |
||
65 | int synth_1to1_mono (real*, mpg123_handle*); |
||
66 | int synth_1to1_mono2stereo(real*, mpg123_handle*); |
||
67 | |||
68 | /* Sample rate decimation comes in less flavours. */ |
||
69 | #ifndef NO_DOWNSAMPLE |
||
70 | int synth_2to1 (real*, int, mpg123_handle*, int); |
||
71 | int synth_2to1_dither (real*, int, mpg123_handle*, int); |
||
72 | int synth_2to1_i386 (real*, int, mpg123_handle*, int); |
||
73 | int synth_2to1_mono (real*, mpg123_handle*); |
||
74 | int synth_2to1_mono2stereo(real*, mpg123_handle*); |
||
75 | int synth_4to1 (real *,int, mpg123_handle*, int); |
||
76 | int synth_4to1_dither (real *,int, mpg123_handle*, int); |
||
77 | int synth_4to1_i386 (real*, int, mpg123_handle*, int); |
||
78 | int synth_4to1_mono (real*, mpg123_handle*); |
||
79 | int synth_4to1_mono2stereo(real*, mpg123_handle*); |
||
80 | #endif |
||
81 | #ifndef NO_NTOM |
||
82 | /* NtoM is really just one implementation. */ |
||
83 | int synth_ntom (real *,int, mpg123_handle*, int); |
||
84 | int synth_ntom_mono (real *, mpg123_handle *); |
||
85 | int synth_ntom_mono2stereo (real *, mpg123_handle *); |
||
86 | #endif |
||
87 | #endif |
||
88 | |||
89 | #ifndef NO_8BIT |
||
90 | /* The 8bit-producing variants. */ |
||
91 | /* There are direct 8-bit synths and wrappers over a possibly optimized 16bit one. */ |
||
92 | int synth_1to1_8bit (real*, int, mpg123_handle*, int); |
||
93 | int synth_1to1_8bit_i386 (real*, int, mpg123_handle*, int); |
||
94 | #ifndef NO_16BIT |
||
95 | int synth_1to1_8bit_wrap (real*, int, mpg123_handle*, int); |
||
96 | int synth_1to1_8bit_mono (real*, mpg123_handle*); |
||
97 | #endif |
||
98 | int synth_1to1_8bit_mono2stereo(real*, mpg123_handle*); |
||
99 | #ifndef NO_16BIT |
||
100 | int synth_1to1_8bit_wrap_mono (real*, mpg123_handle*); |
||
101 | int synth_1to1_8bit_wrap_mono2stereo(real*, mpg123_handle*); |
||
102 | #endif |
||
103 | #ifndef NO_DOWNSAMPLE |
||
104 | int synth_2to1_8bit (real*, int, mpg123_handle*, int); |
||
105 | int synth_2to1_8bit_i386 (real*, int, mpg123_handle*, int); |
||
106 | int synth_2to1_8bit_mono (real*, mpg123_handle*); |
||
107 | int synth_2to1_8bit_mono2stereo(real*, mpg123_handle*); |
||
108 | int synth_4to1_8bit (real*, int, mpg123_handle*, int); |
||
109 | int synth_4to1_8bit_i386 (real*, int, mpg123_handle*, int); |
||
110 | int synth_4to1_8bit_mono (real*, mpg123_handle*); |
||
111 | int synth_4to1_8bit_mono2stereo(real*, mpg123_handle*); |
||
112 | #endif |
||
113 | #ifndef NO_NTOM |
||
114 | int synth_ntom_8bit (real*, int, mpg123_handle*, int); |
||
115 | int synth_ntom_8bit_mono (real*, mpg123_handle*); |
||
116 | int synth_ntom_8bit_mono2stereo(real*, mpg123_handle*); |
||
117 | void ntom_set_ntom(mpg123_handle *fr, off_t num); |
||
118 | #endif |
||
119 | #endif |
||
120 | |||
121 | #ifndef REAL_IS_FIXED |
||
122 | |||
123 | #ifndef NO_REAL |
||
124 | /* The real-producing variants. */ |
||
125 | int synth_1to1_real (real*, int, mpg123_handle*, int); |
||
126 | int synth_1to1_real_i386 (real*, int, mpg123_handle*, int); |
||
127 | int synth_1to1_real_sse (real*, int, mpg123_handle*, int); |
||
128 | int synth_1to1_real_stereo_sse (real*, real*, mpg123_handle*); |
||
129 | int synth_1to1_real_x86_64 (real*, int, mpg123_handle*, int); |
||
130 | int synth_1to1_real_stereo_x86_64(real*, real*, mpg123_handle*); |
||
131 | int synth_1to1_real_altivec (real*, int, mpg123_handle*, int); |
||
132 | int synth_1to1_real_stereo_altivec(real*, real*, mpg123_handle*); |
||
133 | int synth_1to1_real_mono (real*, mpg123_handle*); |
||
134 | int synth_1to1_real_mono2stereo(real*, mpg123_handle*); |
||
135 | #ifndef NO_DOWNSAMPLE |
||
136 | int synth_2to1_real (real*, int, mpg123_handle*, int); |
||
137 | int synth_2to1_real_i386 (real*, int, mpg123_handle*, int); |
||
138 | int synth_2to1_real_mono (real*, mpg123_handle*); |
||
139 | int synth_2to1_real_mono2stereo(real*, mpg123_handle*); |
||
140 | int synth_4to1_real (real*, int, mpg123_handle*, int); |
||
141 | int synth_4to1_real_i386 (real*, int, mpg123_handle*, int); |
||
142 | int synth_4to1_real_mono (real*, mpg123_handle*); |
||
143 | int synth_4to1_real_mono2stereo(real*, mpg123_handle*); |
||
144 | #endif |
||
145 | #ifndef NO_NTOM |
||
146 | int synth_ntom_real (real*, int, mpg123_handle*, int); |
||
147 | int synth_ntom_real_mono (real*, mpg123_handle*); |
||
148 | int synth_ntom_real_mono2stereo(real*, mpg123_handle*); |
||
149 | #endif |
||
150 | #endif |
||
151 | |||
152 | #ifndef NO_32BIT |
||
153 | /* 32bit integer */ |
||
154 | int synth_1to1_s32 (real*, int, mpg123_handle*, int); |
||
155 | int synth_1to1_s32_i386 (real*, int, mpg123_handle*, int); |
||
156 | int synth_1to1_s32_sse (real*, int, mpg123_handle*, int); |
||
157 | int synth_1to1_s32_stereo_sse (real*, real*, mpg123_handle*); |
||
158 | int synth_1to1_s32_x86_64 (real*, int, mpg123_handle*, int); |
||
159 | int synth_1to1_s32_stereo_x86_64(real*, real*, mpg123_handle*); |
||
160 | int synth_1to1_s32_altivec (real*, int, mpg123_handle*, int); |
||
161 | int synth_1to1_s32_stereo_altivec(real*, real*, mpg123_handle*); |
||
162 | int synth_1to1_s32_mono (real*, mpg123_handle*); |
||
163 | int synth_1to1_s32_mono2stereo(real*, mpg123_handle*); |
||
164 | #ifndef NO_DOWNSAMPLE |
||
165 | int synth_2to1_s32 (real*, int, mpg123_handle*, int); |
||
166 | int synth_2to1_s32_i386 (real*, int, mpg123_handle*, int); |
||
167 | int synth_2to1_s32_mono (real*, mpg123_handle*); |
||
168 | int synth_2to1_s32_mono2stereo(real*, mpg123_handle*); |
||
169 | int synth_4to1_s32 (real*, int, mpg123_handle*, int); |
||
170 | int synth_4to1_s32_i386 (real*, int, mpg123_handle*, int); |
||
171 | int synth_4to1_s32_mono (real*, mpg123_handle*); |
||
172 | int synth_4to1_s32_mono2stereo(real*, mpg123_handle*); |
||
173 | #endif |
||
174 | #ifndef NO_NTOM |
||
175 | int synth_ntom_s32 (real*, int, mpg123_handle*, int); |
||
176 | int synth_ntom_s32_mono (real*, mpg123_handle*); |
||
177 | int synth_ntom_s32_mono2stereo(real*, mpg123_handle*); |
||
178 | #endif |
||
179 | #endif |
||
180 | |||
181 | #endif /* FIXED */ |
||
182 | |||
183 | |||
184 | /* Inside these synth functions, some dct64 variants may be used. |
||
185 | The special optimized ones that only appear in assembler code are not mentioned here. |
||
186 | And, generally, these functions are only employed in a matching synth function. */ |
||
187 | void dct64 (real *,real *,real *); |
||
188 | void dct64_i386 (real *,real *,real *); |
||
189 | void dct64_altivec(real *,real *,real *); |
||
190 | void dct64_i486(int*, int* , real*); /* Yeah, of no use outside of synth_i486.c .*/ |
||
191 | |||
192 | /* This is used by the layer 3 decoder, one generic function and 3DNow variants. */ |
||
193 | void dct36 (real *,real *,real *,real *,real *); |
||
194 | void dct36_3dnow (real *,real *,real *,real *,real *); |
||
195 | void dct36_3dnowext(real *,real *,real *,real *,real *); |
||
196 | |||
197 | /* Tools for NtoM resampling synth, defined in ntom.c . */ |
||
198 | int synth_ntom_set_step(mpg123_handle *fr); /* prepare ntom decoding */ |
||
199 | unsigned long ntom_val(mpg123_handle *fr, off_t frame); /* compute ntom_val for frame offset */ |
||
200 | /* Frame and sample offsets. */ |
||
201 | #ifndef NO_NTOM |
||
202 | off_t ntom_frmouts(mpg123_handle *fr, off_t frame); |
||
203 | off_t ntom_ins2outs(mpg123_handle *fr, off_t ins); |
||
204 | off_t ntom_frameoff(mpg123_handle *fr, off_t soff); |
||
205 | #endif |
||
206 | |||
207 | /* Initialization of any static data that majy be needed at runtime. |
||
208 | Make sure you call these once before it is too late. */ |
||
209 | #ifndef NO_LAYER3 |
||
210 | void init_layer3(void); |
||
211 | real init_layer3_gainpow2(mpg123_handle *fr, int i); |
||
212 | void init_layer3_stuff(mpg123_handle *fr, real (*gainpow2)(mpg123_handle *fr, int i)); |
||
213 | #endif |
||
214 | #ifndef NO_LAYER12 |
||
215 | void init_layer12(void); |
||
216 | real* init_layer12_table(mpg123_handle *fr, real *table, int m); |
||
217 | void init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m)); |
||
218 | #endif |
||
219 | |||
220 | void prepare_decode_tables(void); |
||
221 | |||
222 | extern real *pnts[5]; /* tabinit provides, dct64 needs */ |
||
223 | |||
224 | /* Runtime (re)init functions; needed more often. */ |
||
225 | void make_decode_tables(mpg123_handle *fr); /* For every volume change. */ |
||
226 | /* Stuff needed after updating synth setup (see set_synth_functions()). */ |
||
227 | |||
228 | #ifdef OPT_MMXORSSE |
||
229 | /* Special treatment for mmx-like decoders, these functions go into the slots below. */ |
||
230 | void make_decode_tables_mmx(mpg123_handle *fr); |
||
231 | #ifndef NO_LAYER3 |
||
232 | real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i); |
||
233 | #endif |
||
234 | #ifndef NO_LAYER12 |
||
235 | real* init_layer12_table_mmx(mpg123_handle *fr, real *table, int m); |
||
236 | #endif |
||
237 | #endif |
||
238 | |||
239 | #ifndef NO_8BIT |
||
240 | /* Needed when switching to 8bit output. */ |
||
241 | int make_conv16to8_table(mpg123_handle *fr); |
||
242 | #endif |
||
243 | |||
244 | /* These are the actual workers. |
||
245 | They operate on the parsed frame data and handle decompression to audio samples. |
||
246 | The synth functions defined above are called from inside the layer handlers. */ |
||
247 | |||
248 | #ifndef NO_LAYER3 |
||
249 | int do_layer3(mpg123_handle *fr); |
||
250 | #endif |
||
251 | #ifndef NO_LAYER2 |
||
252 | int do_layer2(mpg123_handle *fr); |
||
253 | #endif |
||
254 | #ifndef NO_LAYER1 |
||
255 | int do_layer1(mpg123_handle *fr); |
||
256 | #endif |
||
257 | /* There's an 3DNow counterpart in asm. */ |
||
258 | void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]); |
||
259 | |||
260 | #endif |