Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/mpg123/src/libmpg123/decode.h
4394 views
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-2023 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 INT123_ntom_set_ntom(mpg123_handle *fr, int64_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 INT123_synth_1to1 (real*, int, mpg123_handle*, int);
43
int INT123_synth_1to1_dither (real*, int, mpg123_handle*, int);
44
int INT123_synth_1to1_i386 (real*, int, mpg123_handle*, int);
45
int INT123_synth_1to1_i586 (real*, int, mpg123_handle*, int);
46
int INT123_synth_1to1_i586_dither(real*, int, mpg123_handle*, int);
47
int INT123_synth_1to1_mmx (real*, int, mpg123_handle*, int);
48
int INT123_synth_1to1_3dnow (real*, int, mpg123_handle*, int);
49
int INT123_synth_1to1_sse (real*, int, mpg123_handle*, int);
50
int INT123_synth_1to1_stereo_sse (real*, real*, mpg123_handle*);
51
int INT123_synth_1to1_3dnowext (real*, int, mpg123_handle*, int);
52
int INT123_synth_1to1_altivec (real*, int, mpg123_handle*, int);
53
int INT123_synth_1to1_stereo_altivec(real*, real*, mpg123_handle*);
54
int INT123_synth_1to1_x86_64 (real*, int, mpg123_handle*, int);
55
int INT123_synth_1to1_stereo_x86_64(real*, real*, mpg123_handle*);
56
int INT123_synth_1to1_avx (real*, int, mpg123_handle*, int);
57
int INT123_synth_1to1_stereo_avx (real*, real*, mpg123_handle*);
58
int INT123_synth_1to1_arm (real*, int, mpg123_handle*, int);
59
int INT123_synth_1to1_neon (real*, int, mpg123_handle*, int);
60
int INT123_synth_1to1_stereo_neon(real*, real*, mpg123_handle*);
61
int INT123_synth_1to1_neon64 (real*, int, mpg123_handle*, int);
62
int INT123_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 INT123_absynth_1to1_i486(real*, int, mpg123_handle*, int);
67
/* These mono/stereo converters use one of the above for the grunt work. */
68
int INT123_synth_1to1_mono (real*, mpg123_handle*);
69
int INT123_synth_1to1_m2s(real*, mpg123_handle*);
70
71
/* Sample rate decimation comes in less flavours. */
72
#ifndef NO_DOWNSAMPLE
73
int INT123_synth_2to1 (real*, int, mpg123_handle*, int);
74
int INT123_synth_2to1_dither (real*, int, mpg123_handle*, int);
75
int INT123_synth_2to1_i386 (real*, int, mpg123_handle*, int);
76
int INT123_synth_2to1_mono (real*, mpg123_handle*);
77
int INT123_synth_2to1_m2s(real*, mpg123_handle*);
78
int INT123_synth_4to1 (real *,int, mpg123_handle*, int);
79
int INT123_synth_4to1_dither (real *,int, mpg123_handle*, int);
80
int INT123_synth_4to1_i386 (real*, int, mpg123_handle*, int);
81
int INT123_synth_4to1_mono (real*, mpg123_handle*);
82
int INT123_synth_4to1_m2s(real*, mpg123_handle*);
83
#endif
84
#ifndef NO_NTOM
85
/* NtoM is really just one implementation. */
86
int INT123_synth_ntom (real *,int, mpg123_handle*, int);
87
int INT123_synth_ntom_mono (real *, mpg123_handle *);
88
int INT123_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 INT123_synth_1to1_8bit (real*, int, mpg123_handle*, int);
96
int INT123_synth_1to1_8bit_i386 (real*, int, mpg123_handle*, int);
97
#ifndef NO_16BIT
98
int INT123_synth_1to1_8bit_wrap (real*, int, mpg123_handle*, int);
99
int INT123_synth_1to1_8bit_mono (real*, mpg123_handle*);
100
#endif
101
int INT123_synth_1to1_8bit_m2s(real*, mpg123_handle*);
102
#ifndef NO_16BIT
103
int INT123_synth_1to1_8bit_wrap_mono (real*, mpg123_handle*);
104
int INT123_synth_1to1_8bit_wrap_m2s(real*, mpg123_handle*);
105
#endif
106
#ifndef NO_DOWNSAMPLE
107
int INT123_synth_2to1_8bit (real*, int, mpg123_handle*, int);
108
int INT123_synth_2to1_8bit_i386 (real*, int, mpg123_handle*, int);
109
int INT123_synth_2to1_8bit_mono (real*, mpg123_handle*);
110
int INT123_synth_2to1_8bit_m2s(real*, mpg123_handle*);
111
int INT123_synth_4to1_8bit (real*, int, mpg123_handle*, int);
112
int INT123_synth_4to1_8bit_i386 (real*, int, mpg123_handle*, int);
113
int INT123_synth_4to1_8bit_mono (real*, mpg123_handle*);
114
int INT123_synth_4to1_8bit_m2s(real*, mpg123_handle*);
115
#endif
116
#ifndef NO_NTOM
117
int INT123_synth_ntom_8bit (real*, int, mpg123_handle*, int);
118
int INT123_synth_ntom_8bit_mono (real*, mpg123_handle*);
119
int INT123_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 INT123_synth_1to1_real (real*, int, mpg123_handle*, int);
128
int INT123_synth_1to1_real_i386 (real*, int, mpg123_handle*, int);
129
int INT123_synth_1to1_real_sse (real*, int, mpg123_handle*, int);
130
int INT123_synth_1to1_real_stereo_sse (real*, real*, mpg123_handle*);
131
int INT123_synth_1to1_real_x86_64 (real*, int, mpg123_handle*, int);
132
int INT123_synth_1to1_real_stereo_x86_64(real*, real*, mpg123_handle*);
133
int INT123_synth_1to1_real_avx (real*, int, mpg123_handle*, int);
134
int INT123_synth_1to1_fltst_avx (real*, real*, mpg123_handle*);
135
int INT123_synth_1to1_real_altivec (real*, int, mpg123_handle*, int);
136
int INT123_synth_1to1_fltst_altivec(real*, real*, mpg123_handle*);
137
int INT123_synth_1to1_real_neon (real*, int, mpg123_handle*, int);
138
int INT123_synth_1to1_real_stereo_neon(real*, real*, mpg123_handle*);
139
int INT123_synth_1to1_real_neon64 (real*, int, mpg123_handle*, int);
140
int INT123_synth_1to1_fltst_neon64(real*, real*, mpg123_handle*);
141
int INT123_synth_1to1_real_mono (real*, mpg123_handle*);
142
int INT123_synth_1to1_real_m2s(real*, mpg123_handle*);
143
#ifndef NO_DOWNSAMPLE
144
int INT123_synth_2to1_real (real*, int, mpg123_handle*, int);
145
int INT123_synth_2to1_real_i386 (real*, int, mpg123_handle*, int);
146
int INT123_synth_2to1_real_mono (real*, mpg123_handle*);
147
int INT123_synth_2to1_real_m2s(real*, mpg123_handle*);
148
int INT123_synth_4to1_real (real*, int, mpg123_handle*, int);
149
int INT123_synth_4to1_real_i386 (real*, int, mpg123_handle*, int);
150
int INT123_synth_4to1_real_mono (real*, mpg123_handle*);
151
int INT123_synth_4to1_real_m2s(real*, mpg123_handle*);
152
#endif
153
#ifndef NO_NTOM
154
int INT123_synth_ntom_real (real*, int, mpg123_handle*, int);
155
int INT123_synth_ntom_real_mono (real*, mpg123_handle*);
156
int INT123_synth_ntom_real_m2s(real*, mpg123_handle*);
157
#endif
158
#endif
159
160
#ifndef NO_32BIT
161
/* 32bit integer */
162
int INT123_synth_1to1_s32 (real*, int, mpg123_handle*, int);
163
int INT123_synth_1to1_s32_i386 (real*, int, mpg123_handle*, int);
164
int INT123_synth_1to1_s32_sse (real*, int, mpg123_handle*, int);
165
int INT123_synth_1to1_s32_stereo_sse (real*, real*, mpg123_handle*);
166
int INT123_synth_1to1_s32_x86_64 (real*, int, mpg123_handle*, int);
167
int INT123_synth_1to1_s32_stereo_x86_64(real*, real*, mpg123_handle*);
168
int INT123_synth_1to1_s32_avx (real*, int, mpg123_handle*, int);
169
int INT123_synth_1to1_s32_stereo_avx (real*, real*, mpg123_handle*);
170
int INT123_synth_1to1_s32_altivec (real*, int, mpg123_handle*, int);
171
int INT123_synth_1to1_s32_stereo_altivec(real*, real*, mpg123_handle*);
172
int INT123_synth_1to1_s32_neon (real*, int, mpg123_handle*, int);
173
int INT123_synth_1to1_s32_stereo_neon(real*, real*, mpg123_handle*);
174
int INT123_synth_1to1_s32_neon64 (real*, int, mpg123_handle*, int);
175
int INT123_synth_1to1_s32st_neon64(real*, real*, mpg123_handle*);
176
int INT123_synth_1to1_s32_mono (real*, mpg123_handle*);
177
int INT123_synth_1to1_s32_m2s(real*, mpg123_handle*);
178
#ifndef NO_DOWNSAMPLE
179
int INT123_synth_2to1_s32 (real*, int, mpg123_handle*, int);
180
int INT123_synth_2to1_s32_i386 (real*, int, mpg123_handle*, int);
181
int INT123_synth_2to1_s32_mono (real*, mpg123_handle*);
182
int INT123_synth_2to1_s32_m2s(real*, mpg123_handle*);
183
int INT123_synth_4to1_s32 (real*, int, mpg123_handle*, int);
184
int INT123_synth_4to1_s32_i386 (real*, int, mpg123_handle*, int);
185
int INT123_synth_4to1_s32_mono (real*, mpg123_handle*);
186
int INT123_synth_4to1_s32_m2s(real*, mpg123_handle*);
187
#endif
188
#ifndef NO_NTOM
189
int INT123_synth_ntom_s32 (real*, int, mpg123_handle*, int);
190
int INT123_synth_ntom_s32_mono (real*, mpg123_handle*);
191
int INT123_synth_ntom_s32_m2s(real*, mpg123_handle*);
192
#endif
193
#endif
194
195
#endif /* FIXED */
196
197
198
/* Inside these synth functions, some INT123_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 INT123_dct64 (real *,real *,real *);
202
void INT123_dct64_i386 (real *,real *,real *);
203
void INT123_dct64_altivec(real *,real *,real *);
204
void INT123_dct64_i486(int*, int* , real*); /* Yeah, of no use outside of synth_i486.c .*/
205
206
/* Tools for NtoM resampling synth, defined in ntom.c . */
207
int INT123_synth_ntom_set_step(mpg123_handle *fr); /* prepare ntom decoding */
208
unsigned long INT123_ntom_val(mpg123_handle *fr, int64_t frame); /* compute INT123_ntom_val for frame offset */
209
/* Frame and sample offsets. */
210
#ifndef NO_NTOM
211
/*
212
Outsamples of _this_ frame.
213
To be exact: The samples to be expected from the next frame decode (using the current INT123_ntom_val). When you already decoded _this_ frame, this is the number of samples to be expected from the next one.
214
*/
215
int64_t INT123_ntom_frame_outsamples(mpg123_handle *fr);
216
/* Total out/insample offset. */
217
int64_t INT123_ntom_frmouts(mpg123_handle *fr, int64_t frame);
218
int64_t INT123_ntom_ins2outs(mpg123_handle *fr, int64_t ins);
219
int64_t INT123_ntom_frameoff(mpg123_handle *fr, int64_t soff);
220
#endif
221
222
/* Initialization of any static data that majy be needed at runtime.
223
Make sure you call these once before it is too late. */
224
#ifndef NO_LAYER3
225
226
#ifdef OPT_THE_DCT36
227
// Set the current dct36 function choice. The pointers themselves are to static functions.
228
void INT123_dct36_choose(mpg123_handle *fr);
229
int INT123_dct36_match(mpg123_handle *fr, enum optdec t);
230
#endif
231
232
#ifdef RUNTIME_TABLES
233
void INT123_init_layer3(void);
234
#endif
235
real INT123_init_layer3_gainpow2(mpg123_handle *fr, int i);
236
void INT123_init_layer3_stuff(mpg123_handle *fr, real (*gainpow2)(mpg123_handle *fr, int i));
237
#endif
238
#ifndef NO_LAYER12
239
#ifdef RUNTIME_TABLES
240
void INT123_init_layer12(void);
241
#endif
242
real* INT123_init_layer12_table(mpg123_handle *fr, real *table, int m);
243
void INT123_init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m));
244
#endif
245
246
#ifdef RUNTIME_TABLES
247
void INT123_init_costabs(void);
248
#else
249
const
250
#endif
251
extern real *INT123_pnts[5]; /* costab.h provides, INT123_dct64 needs */
252
253
/* Runtime (re)init functions; needed more often. */
254
void INT123_make_decode_tables(mpg123_handle *fr); /* For every volume change. */
255
/* Stuff needed after updating synth setup (see INT123_set_synth_functions()). */
256
257
#ifdef OPT_MMXORSSE
258
/* Special treatment for mmx-like decoders, these functions go into the slots below. */
259
void INT123_make_decode_tables_mmx(mpg123_handle *fr);
260
#ifndef NO_LAYER3
261
real INT123_init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
262
#endif
263
#ifndef NO_LAYER12
264
real* INT123_init_layer12_table_mmx(mpg123_handle *fr, real *table, int m);
265
#endif
266
#endif
267
268
#ifndef NO_8BIT
269
/* Needed when switching to 8bit output. */
270
int INT123_make_conv16to8_table(mpg123_handle *fr);
271
#endif
272
273
/* These are the actual workers.
274
They operate on the parsed frame data and handle decompression to audio samples.
275
The synth functions defined above are called from inside the layer handlers. */
276
277
#ifndef NO_LAYER3
278
int INT123_do_layer3(mpg123_handle *fr);
279
#endif
280
#ifndef NO_LAYER2
281
int INT123_do_layer2(mpg123_handle *fr);
282
#endif
283
#ifndef NO_LAYER1
284
int INT123_do_layer1(mpg123_handle *fr);
285
#endif
286
/* There's an 3DNow counterpart in asm. */
287
void INT123_do_equalizer(real *bandPtr,int channel, real equalizer[2][32]);
288
289
#endif
290
291