[LIBMPG123]
[reactos.git] / reactos / sdk / include / reactos / libs / libmpg123 / decode.h
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 void ntom_set_ntom(mpg123_handle *fr, off_t num);
34 #endif
35
36 /* Let's collect all possible synth functions here, for an overview.
37 If they are actually defined and used depends on preprocessor machinery.
38 See synth.c and optimize.h for that, also some special C and assembler files. */
39
40 #ifndef NO_16BIT
41 /* The signed-16bit-producing variants. */
42 int synth_1to1 (real*, int, mpg123_handle*, int);
43 int synth_1to1_dither (real*, int, mpg123_handle*, int);
44 int synth_1to1_i386 (real*, int, mpg123_handle*, int);
45 int synth_1to1_i586 (real*, int, mpg123_handle*, int);
46 int synth_1to1_i586_dither(real*, int, mpg123_handle*, int);
47 int synth_1to1_mmx (real*, int, mpg123_handle*, int);
48 int synth_1to1_3dnow (real*, int, mpg123_handle*, int);
49 int synth_1to1_sse (real*, int, mpg123_handle*, int);
50 int synth_1to1_stereo_sse (real*, real*, mpg123_handle*);
51 int synth_1to1_3dnowext (real*, int, mpg123_handle*, int);
52 int synth_1to1_altivec (real*, int, mpg123_handle*, int);
53 int synth_1to1_stereo_altivec(real*, real*, mpg123_handle*);
54 int synth_1to1_x86_64 (real*, int, mpg123_handle*, int);
55 int synth_1to1_stereo_x86_64(real*, real*, mpg123_handle*);
56 int synth_1to1_avx (real*, int, mpg123_handle*, int);
57 int synth_1to1_stereo_avx (real*, real*, mpg123_handle*);
58 int synth_1to1_arm (real*, int, mpg123_handle*, int);
59 int synth_1to1_neon (real*, int, mpg123_handle*, int);
60 int synth_1to1_stereo_neon(real*, real*, mpg123_handle*);
61 int synth_1to1_neon64 (real*, int, mpg123_handle*, int);
62 int synth_1to1_stereo_neon64(real*, real*, mpg123_handle*);
63 /* This is different, special usage in layer3.c only.
64 Hence, the name... and now forget about it.
65 Never use it outside that special portion of code inside layer3.c! */
66 int absynth_1to1_i486(real*, int, mpg123_handle*, int);
67 /* These mono/stereo converters use one of the above for the grunt work. */
68 int synth_1to1_mono (real*, mpg123_handle*);
69 int synth_1to1_m2s(real*, mpg123_handle*);
70
71 /* Sample rate decimation comes in less flavours. */
72 #ifndef NO_DOWNSAMPLE
73 int synth_2to1 (real*, int, mpg123_handle*, int);
74 int synth_2to1_dither (real*, int, mpg123_handle*, int);
75 int synth_2to1_i386 (real*, int, mpg123_handle*, int);
76 int synth_2to1_mono (real*, mpg123_handle*);
77 int synth_2to1_m2s(real*, mpg123_handle*);
78 int synth_4to1 (real *,int, mpg123_handle*, int);
79 int synth_4to1_dither (real *,int, mpg123_handle*, int);
80 int synth_4to1_i386 (real*, int, mpg123_handle*, int);
81 int synth_4to1_mono (real*, mpg123_handle*);
82 int synth_4to1_m2s(real*, mpg123_handle*);
83 #endif
84 #ifndef NO_NTOM
85 /* NtoM is really just one implementation. */
86 int synth_ntom (real *,int, mpg123_handle*, int);
87 int synth_ntom_mono (real *, mpg123_handle *);
88 int synth_ntom_m2s (real *, mpg123_handle *);
89 #endif
90 #endif
91
92 #ifndef NO_8BIT
93 /* The 8bit-producing variants. */
94 /* There are direct 8-bit synths and wrappers over a possibly optimized 16bit one. */
95 int synth_1to1_8bit (real*, int, mpg123_handle*, int);
96 int synth_1to1_8bit_i386 (real*, int, mpg123_handle*, int);
97 #ifndef NO_16BIT
98 int synth_1to1_8bit_wrap (real*, int, mpg123_handle*, int);
99 int synth_1to1_8bit_mono (real*, mpg123_handle*);
100 #endif
101 int synth_1to1_8bit_m2s(real*, mpg123_handle*);
102 #ifndef NO_16BIT
103 int synth_1to1_8bit_wrap_mono (real*, mpg123_handle*);
104 int synth_1to1_8bit_wrap_m2s(real*, mpg123_handle*);
105 #endif
106 #ifndef NO_DOWNSAMPLE
107 int synth_2to1_8bit (real*, int, mpg123_handle*, int);
108 int synth_2to1_8bit_i386 (real*, int, mpg123_handle*, int);
109 int synth_2to1_8bit_mono (real*, mpg123_handle*);
110 int synth_2to1_8bit_m2s(real*, mpg123_handle*);
111 int synth_4to1_8bit (real*, int, mpg123_handle*, int);
112 int synth_4to1_8bit_i386 (real*, int, mpg123_handle*, int);
113 int synth_4to1_8bit_mono (real*, mpg123_handle*);
114 int synth_4to1_8bit_m2s(real*, mpg123_handle*);
115 #endif
116 #ifndef NO_NTOM
117 int synth_ntom_8bit (real*, int, mpg123_handle*, int);
118 int synth_ntom_8bit_mono (real*, mpg123_handle*);
119 int synth_ntom_8bit_m2s(real*, mpg123_handle*);
120 #endif
121 #endif
122
123 #ifndef REAL_IS_FIXED
124
125 #ifndef NO_REAL
126 /* The real-producing variants. */
127 int synth_1to1_real (real*, int, mpg123_handle*, int);
128 int synth_1to1_real_i386 (real*, int, mpg123_handle*, int);
129 int synth_1to1_real_sse (real*, int, mpg123_handle*, int);
130 int synth_1to1_real_stereo_sse (real*, real*, mpg123_handle*);
131 int synth_1to1_real_x86_64 (real*, int, mpg123_handle*, int);
132 int synth_1to1_real_stereo_x86_64(real*, real*, mpg123_handle*);
133 int synth_1to1_real_avx (real*, int, mpg123_handle*, int);
134 int synth_1to1_fltst_avx (real*, real*, mpg123_handle*);
135 int synth_1to1_real_altivec (real*, int, mpg123_handle*, int);
136 int synth_1to1_fltst_altivec(real*, real*, mpg123_handle*);
137 int synth_1to1_real_neon (real*, int, mpg123_handle*, int);
138 int synth_1to1_real_stereo_neon(real*, real*, mpg123_handle*);
139 int synth_1to1_real_neon64 (real*, int, mpg123_handle*, int);
140 int synth_1to1_fltst_neon64(real*, real*, mpg123_handle*);
141 int synth_1to1_real_mono (real*, mpg123_handle*);
142 int synth_1to1_real_m2s(real*, mpg123_handle*);
143 #ifndef NO_DOWNSAMPLE
144 int synth_2to1_real (real*, int, mpg123_handle*, int);
145 int synth_2to1_real_i386 (real*, int, mpg123_handle*, int);
146 int synth_2to1_real_mono (real*, mpg123_handle*);
147 int synth_2to1_real_m2s(real*, mpg123_handle*);
148 int synth_4to1_real (real*, int, mpg123_handle*, int);
149 int synth_4to1_real_i386 (real*, int, mpg123_handle*, int);
150 int synth_4to1_real_mono (real*, mpg123_handle*);
151 int synth_4to1_real_m2s(real*, mpg123_handle*);
152 #endif
153 #ifndef NO_NTOM
154 int synth_ntom_real (real*, int, mpg123_handle*, int);
155 int synth_ntom_real_mono (real*, mpg123_handle*);
156 int synth_ntom_real_m2s(real*, mpg123_handle*);
157 #endif
158 #endif
159
160 #ifndef NO_32BIT
161 /* 32bit integer */
162 int synth_1to1_s32 (real*, int, mpg123_handle*, int);
163 int synth_1to1_s32_i386 (real*, int, mpg123_handle*, int);
164 int synth_1to1_s32_sse (real*, int, mpg123_handle*, int);
165 int synth_1to1_s32_stereo_sse (real*, real*, mpg123_handle*);
166 int synth_1to1_s32_x86_64 (real*, int, mpg123_handle*, int);
167 int synth_1to1_s32_stereo_x86_64(real*, real*, mpg123_handle*);
168 int synth_1to1_s32_avx (real*, int, mpg123_handle*, int);
169 int synth_1to1_s32_stereo_avx (real*, real*, mpg123_handle*);
170 int synth_1to1_s32_altivec (real*, int, mpg123_handle*, int);
171 int synth_1to1_s32_stereo_altivec(real*, real*, mpg123_handle*);
172 int synth_1to1_s32_neon (real*, int, mpg123_handle*, int);
173 int synth_1to1_s32_stereo_neon(real*, real*, mpg123_handle*);
174 int synth_1to1_s32_neon64 (real*, int, mpg123_handle*, int);
175 int synth_1to1_s32st_neon64(real*, real*, mpg123_handle*);
176 int synth_1to1_s32_mono (real*, mpg123_handle*);
177 int synth_1to1_s32_m2s(real*, mpg123_handle*);
178 #ifndef NO_DOWNSAMPLE
179 int synth_2to1_s32 (real*, int, mpg123_handle*, int);
180 int synth_2to1_s32_i386 (real*, int, mpg123_handle*, int);
181 int synth_2to1_s32_mono (real*, mpg123_handle*);
182 int synth_2to1_s32_m2s(real*, mpg123_handle*);
183 int synth_4to1_s32 (real*, int, mpg123_handle*, int);
184 int synth_4to1_s32_i386 (real*, int, mpg123_handle*, int);
185 int synth_4to1_s32_mono (real*, mpg123_handle*);
186 int synth_4to1_s32_m2s(real*, mpg123_handle*);
187 #endif
188 #ifndef NO_NTOM
189 int synth_ntom_s32 (real*, int, mpg123_handle*, int);
190 int synth_ntom_s32_mono (real*, mpg123_handle*);
191 int synth_ntom_s32_m2s(real*, mpg123_handle*);
192 #endif
193 #endif
194
195 #endif /* FIXED */
196
197
198 /* Inside these synth functions, some dct64 variants may be used.
199 The special optimized ones that only appear in assembler code are not mentioned here.
200 And, generally, these functions are only employed in a matching synth function. */
201 void dct64 (real *,real *,real *);
202 void dct64_i386 (real *,real *,real *);
203 void dct64_altivec(real *,real *,real *);
204 void dct64_i486(int*, int* , real*); /* Yeah, of no use outside of synth_i486.c .*/
205
206 /* This is used by the layer 3 decoder, one generic function and 3DNow variants. */
207 void dct36 (real *,real *,real *,real *,real *);
208 void dct36_3dnow (real *,real *,real *,real *,real *);
209 void dct36_3dnowext(real *,real *,real *,real *,real *);
210 void dct36_x86_64 (real *,real *,real *,real *,real *);
211 void dct36_sse (real *,real *,real *,real *,real *);
212 void dct36_avx (real *,real *,real *,real *,real *);
213 void dct36_neon (real *,real *,real *,real *,real *);
214 void dct36_neon64 (real *,real *,real *,real *,real *);
215
216 /* Tools for NtoM resampling synth, defined in ntom.c . */
217 int synth_ntom_set_step(mpg123_handle *fr); /* prepare ntom decoding */
218 unsigned long ntom_val(mpg123_handle *fr, off_t frame); /* compute ntom_val for frame offset */
219 /* Frame and sample offsets. */
220 #ifndef NO_NTOM
221 /*
222 Outsamples of _this_ frame.
223 To be exact: The samples to be expected from the next frame decode (using the current ntom_val). When you already decoded _this_ frame, this is the number of samples to be expected from the next one.
224 */
225 off_t ntom_frame_outsamples(mpg123_handle *fr);
226 /* Total out/insample offset. */
227 off_t ntom_frmouts(mpg123_handle *fr, off_t frame);
228 off_t ntom_ins2outs(mpg123_handle *fr, off_t ins);
229 off_t ntom_frameoff(mpg123_handle *fr, off_t soff);
230 #endif
231
232 /* Initialization of any static data that majy be needed at runtime.
233 Make sure you call these once before it is too late. */
234 #ifndef NO_LAYER3
235 void init_layer3(void);
236 real init_layer3_gainpow2(mpg123_handle *fr, int i);
237 void init_layer3_stuff(mpg123_handle *fr, real (*gainpow2)(mpg123_handle *fr, int i));
238 #endif
239 #ifndef NO_LAYER12
240 void init_layer12(void);
241 real* init_layer12_table(mpg123_handle *fr, real *table, int m);
242 void init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m));
243 #endif
244
245 void prepare_decode_tables(void);
246
247 extern real *pnts[5]; /* tabinit provides, dct64 needs */
248
249 /* Runtime (re)init functions; needed more often. */
250 void make_decode_tables(mpg123_handle *fr); /* For every volume change. */
251 /* Stuff needed after updating synth setup (see set_synth_functions()). */
252
253 #ifdef OPT_MMXORSSE
254 /* Special treatment for mmx-like decoders, these functions go into the slots below. */
255 void make_decode_tables_mmx(mpg123_handle *fr);
256 #ifndef NO_LAYER3
257 real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
258 #endif
259 #ifndef NO_LAYER12
260 real* init_layer12_table_mmx(mpg123_handle *fr, real *table, int m);
261 #endif
262 #endif
263
264 #ifndef NO_8BIT
265 /* Needed when switching to 8bit output. */
266 int make_conv16to8_table(mpg123_handle *fr);
267 #endif
268
269 /* These are the actual workers.
270 They operate on the parsed frame data and handle decompression to audio samples.
271 The synth functions defined above are called from inside the layer handlers. */
272
273 #ifndef NO_LAYER3
274 int do_layer3(mpg123_handle *fr);
275 #endif
276 #ifndef NO_LAYER2
277 int do_layer2(mpg123_handle *fr);
278 #endif
279 #ifndef NO_LAYER1
280 int do_layer1(mpg123_handle *fr);
281 #endif
282 /* There's an 3DNow counterpart in asm. */
283 void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]);
284
285 #endif