~ubuntu-branches/ubuntu/karmic/mpg123/karmic

« back to all changes in this revision

Viewing changes to src/libmpg123/optimize.h

  • Committer: Bazaar Package Importer
  • Author(s): César Muñoz Albitres
  • Date: 2009-05-03 17:55:27 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090503175527-z94edsnxmiccxpy8
Tags: 1.7.2-3ubuntu1
* Merge from debian unstable, remaining changes:
  - Remove arts from dependencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
        for building mpg123 with one optimization only, you have to choose exclusively between
11
11
        OPT_GENERIC (generic C code for everyone)
 
12
        OPT_GENERIC_DITHER (same with dithering for 1to1)
12
13
        OPT_I386 (Intel i386)
13
 
        OPT_I486 (...)
 
14
        OPT_I486 (Somewhat special code for i486; does not work together with others.)
14
15
        OPT_I586 (Intel Pentium)
15
16
        OPT_I586_DITHER (Intel Pentium with dithering/noise shaping for enhanced quality)
16
17
        OPT_MMX (Intel Pentium and compatibles with MMX, fast, but not the best accuracy)
17
18
        OPT_3DNOW (AMD 3DNow!, K6-2/3, Athlon, compatibles...)
 
19
        OPT_3DNOWEXT (AMD 3DNow! extended, generally Athlon, compatibles...)
18
20
        OPT_ALTIVEC (Motorola/IBM PPC with AltiVec under MacOSX)
19
21
 
20
22
        or you define OPT_MULTI and give a combination which makes sense (do not include i486, do not mix altivec and x86).
21
23
 
22
24
        I still have to examine the dynamics of this here together with REAL_IS_FIXED.
 
25
        Basic point is: Don't use REAL_IS_FIXED with something else than generic or i386.
 
26
 
 
27
        Also, one should minimize code size by really ensuring that only functions that are really needed are included.
 
28
        Currently, all generic functions will be always there (to be safe for fallbacks for advanced decoders).
 
29
        Strictly, at least the synth_1to1 should not be necessary for single-decoder mode.
23
30
*/
24
31
 
 
32
 
 
33
/* Runtime optimization interface now here: */
 
34
 
 
35
enum optdec
 
36
{ /* autodec needs to be =0 and the first, nodec needs to be the last -- for loops! */
 
37
        autodec=0, generic, generic_dither, idrei,
 
38
        ivier, ifuenf, ifuenf_dither, mmx,
 
39
        dreidnow, dreidnowext, altivec, sse,
 
40
        nodec
 
41
};
 
42
enum optcla { nocla=0, normal, mmxsse };
 
43
 
 
44
/*  - Set up the table of synth functions for current decoder choice. */
 
45
int frame_cpu_opt(mpg123_handle *fr, const char* cpu);
 
46
/*  - Choose, from the synth table, the synth functions to use for current output format/rate. */
 
47
int set_synth_functions(mpg123_handle *fr);
 
48
/*  - Parse decoder name and return numerical code. */
 
49
enum optdec dectype(const char* decoder);
 
50
/*  - Return the default decoder type. */
 
51
enum optdec defdec(void);
 
52
/*  - Return the class of a decoder type (mmxsse or normal). */
 
53
enum optcla decclass(const enum optdec);
 
54
 
 
55
/* Now comes a whole lot of definitions, for multi decoder mode and single decoder mode.
 
56
   Because of the latter, it may look redundant at times. */
 
57
 
25
58
/* this is included in mpg123.h, which includes config.h */
26
59
#ifdef CCALIGN
27
60
#define ALIGNED(a) __attribute__((aligned(a)))
29
62
#define ALIGNED(a)
30
63
#endif
31
64
 
32
 
/* the optimizations only cover the synth1to1 mode and the dct36 function */
33
 
/* the first two types are needed in set_synth_functions regardless of optimizations */
34
 
typedef int (*func_synth)(real *,int, mpg123_handle *,int );
35
 
typedef int (*func_synth_mono)(real *, mpg123_handle *);
36
 
typedef void (*func_dct36)(real *,real *,real *,real *,real *);
37
 
typedef void (*func_dct64)(real *,real *,real *);
38
 
typedef void (*func_make_decode_tables)(mpg123_handle*);
39
 
typedef real (*func_init_layer3_gainpow2)(mpg123_handle*, int);
40
 
typedef real* (*func_init_layer2_table)(mpg123_handle*, real*, double);
41
 
typedef int (*func_synth_pent)(real *,int,unsigned char *);
42
 
 
43
 
/* last headaches about getting mmx hardcode out */
44
 
real init_layer3_gainpow2(mpg123_handle *fr, int i);
45
 
real* init_layer2_table(mpg123_handle *fr, real *table, double m);
46
 
void make_decode_tables(mpg123_handle *fr);
47
 
void prepare_decode_tables(void); /* perhaps not best place here */
48
 
 
49
 
/* only 3dnow replaces that one, it's internal to layer3.c otherwise */
50
 
void dct36(real *,real *,real *,real *,real *);
51
 
#define opt_dct36(fr) dct36
52
 
/* only mmx replaces those */
53
 
#define opt_make_decode_tables(fr) make_decode_tables(fr)
54
 
#define opt_decwin(fr) (fr)->decwin
55
 
#define opt_init_layer3_gainpow2(fr) init_layer3_gainpow2
56
 
#define opt_init_layer2_table(fr) init_layer2_table
 
65
/* Safety catch for invalid decoder choice. */
 
66
#ifdef REAL_IS_FIXED
 
67
#if (defined OPT_I486)  || (defined OPT_I586) || (defined OPT_I586_DITHER) \
 
68
 || (defined OPT_MMX)   || (defined OPT_SSE)  || (defined_OPT_ALTIVEC) \
 
69
 || (defined OPT_3DNOW) || (defined OPT_3DNOWEXT) || (defined OPT_GENERIC_DITHER)
 
70
#error "Bad decoder choice together with fixed point math!"
 
71
#endif
 
72
#endif
 
73
 
 
74
/* Make sure we disable real and 32bit integer output for integer decoder. */
 
75
#ifdef REAL_IS_FIXED
 
76
/* Undef first in case it's defined to something specific already. */
 
77
#undef NO_REAL
 
78
#undef NO_32BIT
 
79
#define NO_REAL
 
80
#define NO_32BIT
 
81
#endif
 
82
 
 
83
#if (defined NO_LAYER1 && defined NO_LAYER2)
 
84
#define NO_LAYER12
 
85
#endif
57
86
 
58
87
#ifdef OPT_GENERIC
59
 
        #define PENTIUM_FALLBACK
60
 
        void dct64(real *,real *,real *);
61
 
        int synth_1to1(real *bandPtr,int channel, mpg123_handle *fr, int final);
62
 
        int synth_1to1_8bit(real *bandPtr,int channel, mpg123_handle *fr, int final);
63
 
        int synth_1to1_mono(real *, mpg123_handle *fr);
64
 
        int synth_1to1_mono2stereo (real *, mpg123_handle *fr);
65
 
        int synth_1to1_8bit_mono (real *, mpg123_handle *fr);
66
 
        int synth_1to1_8bit_mono2stereo (real *, mpg123_handle *fr);
67
 
        #ifndef OPT_MULTI
68
 
        #define defopt generic
69
 
        #define opt_dct64(fr) dct64
70
 
        #define opt_synth_1to1(fr) synth_1to1
71
 
        #define opt_synth_1to1_mono(fr) synth_1to1_mono
72
 
        #define opt_synth_1to1_mono2stereo(fr) synth_1to1_mono2stereo
73
 
        #define opt_synth_1to1_8bit(fr) synth_1to1_8bit
74
 
        #define opt_synth_1to1_8bit_mono(fr) synth_1to1_8bit_mono
75
 
        #define opt_synth_1to1_8bit_mono2stereo(fr) synth_1to1_8bit_mono2stereo
76
 
        #endif
 
88
#ifndef OPT_MULTI
 
89
#       define defopt generic
 
90
#endif
 
91
#endif
 
92
 
 
93
#ifdef OPT_GENERIC_DITHER
 
94
#define OPT_DITHER
 
95
#ifndef OPT_MULTI
 
96
#       define defopt generic_dither
 
97
#       define opt_synth_1to1(fr) synth_1to1_dither
 
98
#       define opt_synth_2to1(fr) synth_2to1_dither
 
99
#       define opt_synth_4to1(fr) synth_4to1_dither
 
100
#endif
77
101
#endif
78
102
 
79
103
/* i486 is special... always alone! */
80
104
#ifdef OPT_I486
81
105
#define OPT_X86
82
 
#define OPT_I386_SYNTH
83
106
#define defopt ivier
84
 
        int synth_1to1_486(real *bandPtr, int channel, mpg123_handle *fr, int nb_blocks);
85
107
#ifdef OPT_MULTI
86
108
#error "i486 can only work alone!"
87
109
#endif
88
 
#define opt_synth_1to1(fr) synth_1to1_i386
89
110
#define FIR_BUFFER_SIZE  128
90
111
#define FIR_SIZE 16
91
 
        void dct64_i486(int *a,int *b,real *c); /* not used generally */
92
112
#endif
93
113
 
94
114
#ifdef OPT_I386
95
 
        #define PENTIUM_FALLBACK
96
 
        #define OPT_X86
97
 
        #define OPT_I386_SYNTH
98
 
        #ifndef OPT_MULTI
99
 
#ifndef defopt
100
 
        #define defopt idrei
101
 
#endif
102
 
        #define opt_synth_1to1(fr) synth_1to1_i386
103
 
        #endif
104
 
#endif
105
 
 
106
 
#ifdef OPT_I386_SYNTH
107
 
        int synth_1to1_i386(real *bandPtr, int channel, mpg123_handle *fr, int final);
 
115
#define OPT_X86
 
116
#ifndef OPT_MULTI
 
117
#       define defopt idrei
 
118
#endif
108
119
#endif
109
120
 
110
121
#ifdef OPT_I586
111
 
        #define PENTIUM_FALLBACK
112
 
        #define OPT_PENTIUM
113
 
        #define OPT_X86
114
 
        int synth_1to1_i586(real *bandPtr, int channel, mpg123_handle *fr, int final);
115
 
        int synth_1to1_i586_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin);
116
 
        #ifndef OPT_MULTI
117
 
        #define defopt ifuenf
118
 
        #define opt_synth_1to1(fr) synth_1to1_i586
119
 
        #define opt_synth_1to1_i586_asm(fr) synth_1to1_i586_asm
120
 
        #endif
 
122
#define OPT_X86
 
123
#ifndef OPT_MULTI
 
124
#       define defopt ifuenf
 
125
#       define opt_synth_1to1(fr) synth_1to1_i586
 
126
#endif
121
127
#endif
122
128
 
123
129
#ifdef OPT_I586_DITHER
124
 
        #define PENTIUM_FALLBACK
125
 
        #define OPT_PENTIUM
126
 
        #define OPT_X86
127
 
        int synth_1to1_i586(real *bandPtr, int channel, mpg123_handle *fr, int final);
128
 
        int synth_1to1_i586_asm_dither(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin);
129
 
        #ifndef OPT_MULTI
130
 
        #define defopt ifuenf_dither
131
 
        #define opt_synth_1to1(fr) synth_1to1_i586
132
 
        #define opt_synth_1to1_i586_asm(fr) synth_1to1_i586_asm_dither
133
 
        #endif
134
 
#endif
135
 
 
136
 
/* That one has by far the most ugly hacks to make it cooperative. */
 
130
#define OPT_X86
 
131
#define OPT_DITHER
 
132
#ifndef OPT_MULTI
 
133
#       define defopt ifuenf_dither
 
134
#       define opt_synth_1to1(fr) synth_1to1_i586_dither
 
135
#       define opt_synth_2to1(fr) synth_2to1_dither
 
136
#       define opt_synth_4to1(fr) synth_4to1_dither
 
137
#endif
 
138
#endif
 
139
 
 
140
/* We still have some special code around MMX tables. */
 
141
 
137
142
#ifdef OPT_MMX
138
 
        #define OPT_MMXORSSE
139
 
        #define OPT_X86
140
 
        real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
141
 
        real* init_layer2_table_mmx(mpg123_handle *fr, real *table, double m);
142
 
        /* I think one can optimize storage here with the normal decwin */
143
 
        extern real decwin_mmx[512+32];
144
 
        void dct64_mmx(real *,real *,real *);
145
 
        int synth_1to1_mmx(real *bandPtr, int channel, mpg123_handle *fr, int final);
146
 
        void make_decode_tables_mmx(mpg123_handle *fr); /* tabinit_mmx.s */
147
 
        void make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins); /* tabinit_mmx.s */
148
 
        /* these are in asm, dct64 called directly there */
149
 
        void dct64_MMX(short *a,short *b,real *c);
150
 
        int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins);
151
 
        #ifndef OPT_MULTI
152
 
        #define defopt mmx
153
 
/*      #undef opt_decwin
154
 
        #define opt_decwin(fr) decwin_mmx */
155
 
        #define opt_dct64(fr) dct64_mmx
156
 
        #define opt_synth_1to1(fr) synth_1to1_mmx
157
 
        #define opt_
158
 
        #undef opt_make_decode_tables
159
 
        #define opt_make_decode_tables(fr) make_decode_tables_mmx(fr)
160
 
        #undef opt_init_layer3_gainpow2
161
 
        #define opt_init_layer3_gainpow2(fr) init_layer3_gainpow2_mmx
162
 
        #undef opt_init_layer2_table
163
 
        #define opt_init_layer2_table(fr) init_layer2_table_mmx
164
 
        #define OPT_MMX_ONLY
165
 
        #endif
 
143
#define OPT_MMXORSSE
 
144
#define OPT_X86
 
145
#ifndef OPT_MULTI
 
146
#       define defopt mmx
 
147
#       define opt_synth_1to1(fr) synth_1to1_mmx
 
148
#endif
166
149
#endif
167
150
 
168
 
/* first crude hack into our source */
169
151
#ifdef OPT_SSE
170
 
        #define OPT_MMXORSSE
171
 
        #define OPT_MPLAYER
172
 
        #define OPT_X86
173
 
        real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
174
 
        real* init_layer2_table_mmx(mpg123_handle *fr, real *table, double m);
175
 
        /* I think one can optimize storage here with the normal decwin */
176
 
        extern real decwin_mmx[512+32];
177
 
        void dct64_mmx(real *,real *,real *);
178
 
        void dct64_sse(real *,real *,real *);
179
 
        int synth_1to1_sse(real *bandPtr, int channel, mpg123_handle *fr, int final);
180
 
        void synth_1to1_sse_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin);
181
 
        void make_decode_tables_mmx(mpg123_handle *fr); /* tabinit_mmx.s */
182
 
        void make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins); /* tabinit_mmx.s */
183
 
        /* ugly! */
184
 
        extern func_dct64 mpl_dct64;
185
 
        #ifndef OPT_MULTI
186
 
        #define defopt sse
187
 
        #define opt_mpl_dct64(fr) dct64_sse
188
 
/*      #undef opt_decwin
189
 
        #define opt_decwin(fr) decwin_mmx */
190
 
        #define opt_dct64(fr) dct64_mmx /* dct64_sse is silent in downsampling modes */
191
 
        #define opt_synth_1to1(fr) synth_1to1_sse /* that will use dct64_sse */
192
 
        #undef opt_make_decode_tables
193
 
        #define opt_make_decode_tables(fr) make_decode_tables_mmx(fr)
194
 
        #undef opt_init_layer3_gainpow2
195
 
        #define opt_init_layer3_gainpow2(fr) init_layer3_gainpow2_mmx
196
 
        #undef opt_init_layer2_table
197
 
        #define opt_init_layer2_table(fr) init_layer2_table_mmx
198
 
        #define OPT_MMX_ONLY /* watch out! */
199
 
        #endif
 
152
#define OPT_MMXORSSE
 
153
#define OPT_MPLAYER
 
154
#define OPT_X86
 
155
#ifndef OPT_MULTI
 
156
#       define defopt sse
 
157
#       define opt_synth_1to1(fr) synth_1to1_sse
 
158
#endif
200
159
#endif
201
160
 
202
 
/* first crude hack into our source */
203
161
#ifdef OPT_3DNOWEXT
204
 
        #define OPT_MMXORSSE
205
 
        #define OPT_MPLAYER
206
 
        #define OPT_X86
207
 
        real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
208
 
        real* init_layer2_table_mmx(mpg123_handle *fr, real *table, double m);
209
 
        /* I think one can optimize storage here with the normal decwin */
210
 
        extern real decwin_mmx[512+32];
211
 
        void dct64_mmx(real *,real *,real *);
212
 
        void dct64_3dnowext(real *,real *,real *);
213
 
        void dct36_3dnowext(real *,real *,real *,real *,real *);
214
 
        int synth_1to1_3dnowext(real *bandPtr, int channel, mpg123_handle *fr, int final);
215
 
        void synth_1to1_3dnowext_asm(real *bandPtr, int channel, short *samples, short *buffs, int *bo, real *decwin);
216
 
        void make_decode_tables_mmx(mpg123_handle *fr); /* tabinit_mmx.s */
217
 
        void make_decode_tables_mmx_asm(long scaleval, float* decwin_mmx, float *decwins); /* tabinit_mmx.s */
218
 
        /* ugly! */
219
 
        extern func_dct64 mpl_dct64;
220
 
        #ifndef OPT_MULTI
221
 
        #define defopt dreidnowext
222
 
        #define opt_mpl_dct64(fr) dct64_3dnowext
223
 
        #undef opt_dct36
224
 
        #define opt_dct36(fr) dct36_3dnowext
225
 
/*      #undef opt_decwin
226
 
        #define opt_decwin(fr) decwin_mmx */
227
 
        #define opt_dct64(fr) dct64_mmx /* dct64_sse is silent in downsampling modes */
228
 
        #define opt_synth_1to1(fr) synth_1to1_3dnowext /* that will use dct64_3dnowext */
229
 
        #undef opt_make_decode_tables
230
 
        #define opt_make_decode_tables(fr) make_decode_tables_mmx(fr)
231
 
        #undef opt_init_layer3_gainpow2
232
 
        #define opt_init_layer3_gainpow2(fr) init_layer3_gainpow2_mmx
233
 
        #undef opt_init_layer2_table
234
 
        #define opt_init_layer2_table(fr) init_layer2_table_mmx
235
 
        #define OPT_MMX_ONLY /* watch out! */
236
 
        #endif
237
 
#endif
238
 
 
239
 
 
240
 
#ifndef OPT_MMX_ONLY
241
 
extern real *pnts[5];
242
 
extern real decwin[512+32];
243
 
#endif
 
162
#define OPT_MMXORSSE
 
163
#define OPT_MPLAYER
 
164
#define OPT_X86
 
165
#ifndef OPT_MULTI
 
166
#       define defopt dreidnowext
 
167
#       define opt_dct36(fr) dct36_3dnowext
 
168
#       define opt_synth_1to1(fr) synth_1to1_3dnowext
 
169
#endif
 
170
#endif
 
171
 
244
172
#ifdef OPT_MPLAYER
245
173
extern const int costab_mmxsse[];
246
174
#endif
248
176
/* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
249
177
/* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */
250
178
#ifdef OPT_3DNOW
251
 
        #define K6_FALLBACK /* a fallback for 3DNowExt */
252
 
        #define OPT_X86
253
 
        void dct36_3dnow(real *,real *,real *,real *,real *);
254
 
        void do_equalizer_3dnow(real *bandPtr,int channel, real equalizer[2][32]);
255
 
        int synth_1to1_3dnow(real *bandPtr, int channel, mpg123_handle *fr, int final);
256
 
        int synth_1to1_3dnow_asm(real *bandPtr, int channel, unsigned char *out, unsigned char *buffs, int *bo, real *decwin);
257
 
        #ifndef OPT_MULTI
258
 
        #define defopt dreidnow
259
 
        #undef opt_dct36
260
 
        #define opt_dct36(fr) dct36_3dnow
261
 
        #define opt_synth_1to1(fr) synth_1to1_3dnow
262
 
        #endif
 
179
#define OPT_X86
 
180
#ifndef OPT_MULTI
 
181
#       define defopt dreidnow
 
182
#       define opt_dct36(fr) dct36_3dnow
 
183
#       define opt_synth_1to1(fr) synth_1to1_3dnow
263
184
#endif
264
 
 
265
 
#ifdef OPT_X86
266
 
        /* these have to be merged back into one! */
267
 
        unsigned int getcpuid();
268
 
        unsigned int getextcpuflags();
269
 
        unsigned int getstdcpuflags();
270
 
        unsigned int getstd2cpuflags();
271
 
 
272
 
        void dct64_i386(real *,real *,real *);
273
 
        int synth_1to1_mono_i386(real *, mpg123_handle *fr);
274
 
        int synth_1to1_mono2stereo_i386(real *, mpg123_handle *fr);
275
 
        int synth_1to1_8bit_i386(real *,int, mpg123_handle *fr, int final);
276
 
        int synth_1to1_8bit_mono_i386(real *, mpg123_handle *fr);
277
 
        int synth_1to1_8bit_mono2stereo_i386(real *, mpg123_handle *fr);
278
 
        #ifndef OPT_MULTI
279
 
        #ifndef opt_dct64
280
 
        #define opt_dct64(fr) dct64_i386 /* default one even for 3dnow and i486 in decode_2to1, decode_ntom */
281
 
        #endif
282
 
        #define opt_synth_1to1_mono(fr) synth_1to1_mono_i386
283
 
        #define opt_synth_1to1_mono2stereo(fr) synth_1to1_mono2stereo_i386
284
 
        #define opt_synth_1to1_8bit(fr) synth_1to1_8bit_i386
285
 
        #define opt_synth_1to1_8bit_mono(fr) synth_1to1_8bit_mono_i386
286
 
        #define opt_synth_1to1_8bit_mono2stereo(fr) synth_1to1_8bit_mono2stereo_i386
287
 
        #endif
288
185
#endif
289
186
 
290
187
#ifdef OPT_ALTIVEC
291
 
        void dct64_altivec(real *out0,real *out1,real *samples);
292
 
        int synth_1to1_altivec(real *,int,mpg123_handle *, int);
293
 
        int synth_1to1_mono_altivec(real *,mpg123_handle *);
294
 
        int synth_1to1_mono2stereo_altivec(real *, mpg123_handle *);
295
 
        int synth_1to1_8bit_altivec(real *,int,mpg123_handle *,int);
296
 
        int synth_1to1_8bit_mono_altivec(real *,mpg123_handle *);
297
 
        int synth_1to1_8bit_mono2stereo_altivec(real *,mpg123_handle *);
298
 
        #ifndef OPT_MULTI
299
 
        #define defopt altivec
300
 
        #define opt_dct64(fr) dct64_altivec
301
 
        #define opt_synth_1to1(fr) synth_1to1_altivec
302
 
        #define opt_synth_1to1_mono(fr) synth_1to1_mono_altivec
303
 
        #define opt_synth_1to1_mono2stereo(fr) synth_1to1_mono2stereo_altivec
304
 
        #define opt_synth_1to1_8bit(fr) synth_1to1_8bit_altivec
305
 
        #define opt_synth_1to1_8bit_mono(fr) synth_1to1_8bit_mono_altivec
306
 
        #define opt_synth_1to1_8bit_mono2stereo(fr) synth_1to1_8bit_mono2stereo_altivec
307
 
        #endif
308
 
#endif
309
 
                
 
188
#ifndef OPT_MULTI
 
189
#       define defopt altivec
 
190
#       define opt_synth_1to1(fr) synth_1to1_altivec
 
191
#endif
 
192
#endif
 
193
 
310
194
/* used for multi opt mode and the single 3dnow mode to have the old 3dnow test flag still working */
311
195
void check_decoders(void);
312
196
 
 
197
/* Announce the data in dnoise.c ... */
 
198
#ifdef OPT_DITHER
 
199
#define DITHERSIZE 65536
 
200
extern float dithernoise[DITHERSIZE];
 
201
#endif
 
202
 
 
203
/*
 
204
        Now come two blocks of standard definitions for multi-decoder mode and single-decoder mode.
 
205
        Most stuff is so automatic that it's indeed generated by some inline shell script.
 
206
        Remember to use these scripts when possible, instead of direct repetitive hacking.
 
207
*/
 
208
 
313
209
#ifdef OPT_MULTI
314
 
        #ifdef OPT_X86
315
 
        extern struct cpuflags cf;
316
 
        #endif
317
 
        #define defopt nodec
318
 
        /* a simple global struct to hold the decoding function pointers, could be localized later if really wanted */
319
 
 
320
 
        #define opt_synth_1to1(fr) ((fr)->cpu_opts.synth_1to1)
321
 
        #define opt_synth_1to1_mono(fr) ((fr)->cpu_opts.synth_1to1_mono)
322
 
        #define opt_synth_1to1_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_mono2stereo)
323
 
        #define opt_synth_1to1_8bit(fr) ((fr)->cpu_opts.synth_1to1_8bit)
324
 
        #define opt_synth_1to1_8bit_mono(fr) ((fr)->cpu_opts.synth_1to1_8bit_mono)
325
 
        #define opt_synth_1to1_8bit_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_8bit_mono2stereo)
326
 
        #ifdef OPT_PENTIUM
327
 
        #define opt_synth_1to1_i586_asm(fr) ((fr)->cpu_opts.synth_1to1_i586_asm)
328
 
        #endif
329
 
        #ifdef OPT_MMXORSSE
330
 
        #undef opt_make_decode_tables
331
 
        #define opt_make_decode_tables(fr) ((fr)->cpu_opts.make_decode_tables)(fr)
332
 
/*      #undef opt_decwin
333
 
        #define opt_decwin(fr) (fr)->cpu_opts.decwin */
334
 
        #undef opt_init_layer3_gainpow2
335
 
        #define opt_init_layer3_gainpow2(fr) ((fr)->cpu_opts.init_layer3_gainpow2)
336
 
        #undef opt_init_layer2_table
337
 
        #define opt_init_layer2_table(fr) ((fr)->cpu_opts.init_layer2_table)
338
 
        #endif
339
 
        #ifdef OPT_3DNOW
340
 
        #undef opt_dct36
341
 
        #define opt_dct36(fr) ((fr)->cpu_opts.dct36)
342
 
        #endif
343
 
        #define opt_dct64(fr) ((fr)->cpu_opts.dct64)
344
 
        #ifdef OPT_MPLAYER
345
 
        #define opt_mpl_dct64(fr) ((fr)->cpu_opts.mpl_dct64)
346
 
        #endif
347
 
#endif
 
210
 
 
211
#       define defopt nodec
 
212
 
 
213
/*
 
214
        ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
215
        ## The ## is a quote for just #
 
216
        star="*"; slash="/"; 
 
217
        for i in 1to1 2to1 4to1 ntom;
 
218
        do
 
219
                echo
 
220
                echo "$slash$star $i $star$slash"
 
221
                for t in "" _8bit _real _s32; do for f in "" _mono _mono2stereo;
 
222
                do
 
223
                        echo "##        define opt_synth_${i}${t}${f}(fr) ((fr)->cpu_opts.synth_${i}${t}${f})"
 
224
                done; done
 
225
        done
 
226
*/
 
227
 
 
228
/* 1to1 */
 
229
#       define opt_synth_1to1(fr) ((fr)->cpu_opts.synth_1to1)
 
230
#       define opt_synth_1to1_mono(fr) ((fr)->cpu_opts.synth_1to1_mono)
 
231
#       define opt_synth_1to1_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_mono2stereo)
 
232
#       define opt_synth_1to1_8bit(fr) ((fr)->cpu_opts.synth_1to1_8bit)
 
233
#       define opt_synth_1to1_8bit_mono(fr) ((fr)->cpu_opts.synth_1to1_8bit_mono)
 
234
#       define opt_synth_1to1_8bit_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_8bit_mono2stereo)
 
235
#       define opt_synth_1to1_real(fr) ((fr)->cpu_opts.synth_1to1_real)
 
236
#       define opt_synth_1to1_real_mono(fr) ((fr)->cpu_opts.synth_1to1_real_mono)
 
237
#       define opt_synth_1to1_real_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_real_mono2stereo)
 
238
#       define opt_synth_1to1_s32(fr) ((fr)->cpu_opts.synth_1to1_s32)
 
239
#       define opt_synth_1to1_s32_mono(fr) ((fr)->cpu_opts.synth_1to1_s32_mono)
 
240
#       define opt_synth_1to1_s32_mono2stereo(fr) ((fr)->cpu_opts.synth_1to1_s32_mono2stereo)
 
241
 
 
242
/* 2to1 */
 
243
#       define opt_synth_2to1(fr) ((fr)->cpu_opts.synth_2to1)
 
244
#       define opt_synth_2to1_mono(fr) ((fr)->cpu_opts.synth_2to1_mono)
 
245
#       define opt_synth_2to1_mono2stereo(fr) ((fr)->cpu_opts.synth_2to1_mono2stereo)
 
246
#       define opt_synth_2to1_8bit(fr) ((fr)->cpu_opts.synth_2to1_8bit)
 
247
#       define opt_synth_2to1_8bit_mono(fr) ((fr)->cpu_opts.synth_2to1_8bit_mono)
 
248
#       define opt_synth_2to1_8bit_mono2stereo(fr) ((fr)->cpu_opts.synth_2to1_8bit_mono2stereo)
 
249
#       define opt_synth_2to1_real(fr) ((fr)->cpu_opts.synth_2to1_real)
 
250
#       define opt_synth_2to1_real_mono(fr) ((fr)->cpu_opts.synth_2to1_real_mono)
 
251
#       define opt_synth_2to1_real_mono2stereo(fr) ((fr)->cpu_opts.synth_2to1_real_mono2stereo)
 
252
#       define opt_synth_2to1_s32(fr) ((fr)->cpu_opts.synth_2to1_s32)
 
253
#       define opt_synth_2to1_s32_mono(fr) ((fr)->cpu_opts.synth_2to1_s32_mono)
 
254
#       define opt_synth_2to1_s32_mono2stereo(fr) ((fr)->cpu_opts.synth_2to1_s32_mono2stereo)
 
255
 
 
256
/* 4to1 */
 
257
#       define opt_synth_4to1(fr) ((fr)->cpu_opts.synth_4to1)
 
258
#       define opt_synth_4to1_mono(fr) ((fr)->cpu_opts.synth_4to1_mono)
 
259
#       define opt_synth_4to1_mono2stereo(fr) ((fr)->cpu_opts.synth_4to1_mono2stereo)
 
260
#       define opt_synth_4to1_8bit(fr) ((fr)->cpu_opts.synth_4to1_8bit)
 
261
#       define opt_synth_4to1_8bit_mono(fr) ((fr)->cpu_opts.synth_4to1_8bit_mono)
 
262
#       define opt_synth_4to1_8bit_mono2stereo(fr) ((fr)->cpu_opts.synth_4to1_8bit_mono2stereo)
 
263
#       define opt_synth_4to1_real(fr) ((fr)->cpu_opts.synth_4to1_real)
 
264
#       define opt_synth_4to1_real_mono(fr) ((fr)->cpu_opts.synth_4to1_real_mono)
 
265
#       define opt_synth_4to1_real_mono2stereo(fr) ((fr)->cpu_opts.synth_4to1_real_mono2stereo)
 
266
#       define opt_synth_4to1_s32(fr) ((fr)->cpu_opts.synth_4to1_s32)
 
267
#       define opt_synth_4to1_s32_mono(fr) ((fr)->cpu_opts.synth_4to1_s32_mono)
 
268
#       define opt_synth_4to1_s32_mono2stereo(fr) ((fr)->cpu_opts.synth_4to1_s32_mono2stereo)
 
269
 
 
270
/* ntom */
 
271
#       define opt_synth_ntom(fr) ((fr)->cpu_opts.synth_ntom)
 
272
#       define opt_synth_ntom_mono(fr) ((fr)->cpu_opts.synth_ntom_mono)
 
273
#       define opt_synth_ntom_mono2stereo(fr) ((fr)->cpu_opts.synth_ntom_mono2stereo)
 
274
#       define opt_synth_ntom_8bit(fr) ((fr)->cpu_opts.synth_ntom_8bit)
 
275
#       define opt_synth_ntom_8bit_mono(fr) ((fr)->cpu_opts.synth_ntom_8bit_mono)
 
276
#       define opt_synth_ntom_8bit_mono2stereo(fr) ((fr)->cpu_opts.synth_ntom_8bit_mono2stereo)
 
277
#       define opt_synth_ntom_real(fr) ((fr)->cpu_opts.synth_ntom_real)
 
278
#       define opt_synth_ntom_real_mono(fr) ((fr)->cpu_opts.synth_ntom_real_mono)
 
279
#       define opt_synth_ntom_real_mono2stereo(fr) ((fr)->cpu_opts.synth_ntom_real_mono2stereo)
 
280
#       define opt_synth_ntom_s32(fr) ((fr)->cpu_opts.synth_ntom_s32)
 
281
#       define opt_synth_ntom_s32_mono(fr) ((fr)->cpu_opts.synth_ntom_s32_mono)
 
282
#       define opt_synth_ntom_s32_mono2stereo(fr) ((fr)->cpu_opts.synth_ntom_s32_mono2stereo)
 
283
 
 
284
/* End of generated output. */
 
285
 
 
286
#       ifdef OPT_3DNOW
 
287
#               define opt_dct36(fr) ((fr)->cpu_opts.dct36)
 
288
#       endif
 
289
 
 
290
#else /* OPT_MULTI */
 
291
 
 
292
/* Define missing opt functions, for generic or x86. */
 
293
#       ifdef opt_synth_1to1
 
294
/* If there is an optimized 1to1, we'll reuse it for 8bit stuff. */
 
295
#               ifndef opt_synth_1to1_8bit
 
296
#                       define opt_synth_1to1_8bit(fr)               synth_1to1_8bit_wrap
 
297
#               endif
 
298
#               ifndef opt_synth_1to1_8bit_mono
 
299
#                               define opt_synth_1to1_8bit_mono(fr)        synth_1to1_8bit_wrap_mono
 
300
#               endif
 
301
#               ifndef opt_synth_1to1_8bit_mono2stereo
 
302
#                               define opt_synth_1to1_8bit_mono2stereo(fr) synth_1to1_8bit_wrap_mono2stereo
 
303
#               endif
 
304
#       endif
 
305
 
 
306
/*
 
307
        ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
308
        ## The ## is a quote for just #
 
309
        star="*"; slash="/"; 
 
310
        for c in "ifdef OPT_X86" "else $slash$star generic code $star$slash"
 
311
        do
 
312
                if test "$c" = "ifdef OPT_X86"; then cpu=_i386; else cpu=; fi
 
313
                echo "##        $c"
 
314
                for i in 1to1 2to1 4to1 ntom;
 
315
                do
 
316
                        if test $i = ntom; then cpu=; fi
 
317
                        echo "$slash$star $i $star$slash"
 
318
                        for t in "" _8bit _real _s32; do
 
319
                                echo "##                ifndef opt_synth_${i}${t}"
 
320
                                echo "##                        define opt_synth_${i}${t}(fr) synth_${i}${t}$cpu"
 
321
                                echo "##                endif"
 
322
                        done
 
323
                done
 
324
        done
 
325
        echo "##        endif $slash$star x86 / generic $star$slash"
 
326
*/
 
327
#       ifdef OPT_X86
 
328
/* 1to1 */
 
329
#               ifndef opt_synth_1to1
 
330
#                       define opt_synth_1to1(fr) synth_1to1_i386
 
331
#               endif
 
332
#               ifndef opt_synth_1to1_8bit
 
333
#                       define opt_synth_1to1_8bit(fr) synth_1to1_8bit_i386
 
334
#               endif
 
335
#               ifndef opt_synth_1to1_real
 
336
#                       define opt_synth_1to1_real(fr) synth_1to1_real_i386
 
337
#               endif
 
338
#               ifndef opt_synth_1to1_s32
 
339
#                       define opt_synth_1to1_s32(fr) synth_1to1_s32_i386
 
340
#               endif
 
341
/* 2to1 */
 
342
#               ifndef opt_synth_2to1
 
343
#                       define opt_synth_2to1(fr) synth_2to1_i386
 
344
#               endif
 
345
#               ifndef opt_synth_2to1_8bit
 
346
#                       define opt_synth_2to1_8bit(fr) synth_2to1_8bit_i386
 
347
#               endif
 
348
#               ifndef opt_synth_2to1_real
 
349
#                       define opt_synth_2to1_real(fr) synth_2to1_real_i386
 
350
#               endif
 
351
#               ifndef opt_synth_2to1_s32
 
352
#                       define opt_synth_2to1_s32(fr) synth_2to1_s32_i386
 
353
#               endif
 
354
/* 4to1 */
 
355
#               ifndef opt_synth_4to1
 
356
#                       define opt_synth_4to1(fr) synth_4to1_i386
 
357
#               endif
 
358
#               ifndef opt_synth_4to1_8bit
 
359
#                       define opt_synth_4to1_8bit(fr) synth_4to1_8bit_i386
 
360
#               endif
 
361
#               ifndef opt_synth_4to1_real
 
362
#                       define opt_synth_4to1_real(fr) synth_4to1_real_i386
 
363
#               endif
 
364
#               ifndef opt_synth_4to1_s32
 
365
#                       define opt_synth_4to1_s32(fr) synth_4to1_s32_i386
 
366
#               endif
 
367
/* ntom */
 
368
#               ifndef opt_synth_ntom
 
369
#                       define opt_synth_ntom(fr) synth_ntom
 
370
#               endif
 
371
#               ifndef opt_synth_ntom_8bit
 
372
#                       define opt_synth_ntom_8bit(fr) synth_ntom_8bit
 
373
#               endif
 
374
#               ifndef opt_synth_ntom_real
 
375
#                       define opt_synth_ntom_real(fr) synth_ntom_real
 
376
#               endif
 
377
#               ifndef opt_synth_ntom_s32
 
378
#                       define opt_synth_ntom_s32(fr) synth_ntom_s32
 
379
#               endif
 
380
#       else /* generic code */
 
381
/* 1to1 */
 
382
#               ifndef opt_synth_1to1
 
383
#                       define opt_synth_1to1(fr) synth_1to1
 
384
#               endif
 
385
#               ifndef opt_synth_1to1_8bit
 
386
#                       define opt_synth_1to1_8bit(fr) synth_1to1_8bit
 
387
#               endif
 
388
#               ifndef opt_synth_1to1_real
 
389
#                       define opt_synth_1to1_real(fr) synth_1to1_real
 
390
#               endif
 
391
#               ifndef opt_synth_1to1_s32
 
392
#                       define opt_synth_1to1_s32(fr) synth_1to1_s32
 
393
#               endif
 
394
/* 2to1 */
 
395
#               ifndef opt_synth_2to1
 
396
#                       define opt_synth_2to1(fr) synth_2to1
 
397
#               endif
 
398
#               ifndef opt_synth_2to1_8bit
 
399
#                       define opt_synth_2to1_8bit(fr) synth_2to1_8bit
 
400
#               endif
 
401
#               ifndef opt_synth_2to1_real
 
402
#                       define opt_synth_2to1_real(fr) synth_2to1_real
 
403
#               endif
 
404
#               ifndef opt_synth_2to1_s32
 
405
#                       define opt_synth_2to1_s32(fr) synth_2to1_s32
 
406
#               endif
 
407
/* 4to1 */
 
408
#               ifndef opt_synth_4to1
 
409
#                       define opt_synth_4to1(fr) synth_4to1
 
410
#               endif
 
411
#               ifndef opt_synth_4to1_8bit
 
412
#                       define opt_synth_4to1_8bit(fr) synth_4to1_8bit
 
413
#               endif
 
414
#               ifndef opt_synth_4to1_real
 
415
#                       define opt_synth_4to1_real(fr) synth_4to1_real
 
416
#               endif
 
417
#               ifndef opt_synth_4to1_s32
 
418
#                       define opt_synth_4to1_s32(fr) synth_4to1_s32
 
419
#               endif
 
420
/* ntom */
 
421
#               ifndef opt_synth_ntom
 
422
#                       define opt_synth_ntom(fr) synth_ntom
 
423
#               endif
 
424
#               ifndef opt_synth_ntom_8bit
 
425
#                       define opt_synth_ntom_8bit(fr) synth_ntom_8bit
 
426
#               endif
 
427
#               ifndef opt_synth_ntom_real
 
428
#                       define opt_synth_ntom_real(fr) synth_ntom_real
 
429
#               endif
 
430
#               ifndef opt_synth_ntom_s32
 
431
#                       define opt_synth_ntom_s32(fr) synth_ntom_s32
 
432
#               endif
 
433
#       endif /* x86 / generic */
 
434
 
 
435
/* Common mono stuff, wrapping over possibly optimized basic synth. */
 
436
/*
 
437
        ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
438
        ## The ## is a quote for just #
 
439
        for i in 1to1 2to1 4to1 ntom; do
 
440
        star="*"; slash="/"; echo "$slash$star $i mono $star$slash"
 
441
        for t in "" _8bit _real _s32; do for m in mono mono2stereo; do
 
442
        echo "##        ifndef opt_synth_${i}${t}_${m}"
 
443
        echo "##                define opt_synth_${i}${t}_${m}(fr) synth_${i}${t}_${m}"
 
444
        echo "##        endif"
 
445
        done; done; done
 
446
*/
 
447
/* 1to1 mono */
 
448
#       ifndef opt_synth_1to1_mono
 
449
#               define opt_synth_1to1_mono(fr) synth_1to1_mono
 
450
#       endif
 
451
#       ifndef opt_synth_1to1_mono2stereo
 
452
#               define opt_synth_1to1_mono2stereo(fr) synth_1to1_mono2stereo
 
453
#       endif
 
454
#       ifndef opt_synth_1to1_8bit_mono
 
455
#               define opt_synth_1to1_8bit_mono(fr) synth_1to1_8bit_mono
 
456
#       endif
 
457
#       ifndef opt_synth_1to1_8bit_mono2stereo
 
458
#               define opt_synth_1to1_8bit_mono2stereo(fr) synth_1to1_8bit_mono2stereo
 
459
#       endif
 
460
#       ifndef opt_synth_1to1_real_mono
 
461
#               define opt_synth_1to1_real_mono(fr) synth_1to1_real_mono
 
462
#       endif
 
463
#       ifndef opt_synth_1to1_real_mono2stereo
 
464
#               define opt_synth_1to1_real_mono2stereo(fr) synth_1to1_real_mono2stereo
 
465
#       endif
 
466
#       ifndef opt_synth_1to1_s32_mono
 
467
#               define opt_synth_1to1_s32_mono(fr) synth_1to1_s32_mono
 
468
#       endif
 
469
#       ifndef opt_synth_1to1_s32_mono2stereo
 
470
#               define opt_synth_1to1_s32_mono2stereo(fr) synth_1to1_s32_mono2stereo
 
471
#       endif
 
472
/* 2to1 mono */
 
473
#       ifndef opt_synth_2to1_mono
 
474
#               define opt_synth_2to1_mono(fr) synth_2to1_mono
 
475
#       endif
 
476
#       ifndef opt_synth_2to1_mono2stereo
 
477
#               define opt_synth_2to1_mono2stereo(fr) synth_2to1_mono2stereo
 
478
#       endif
 
479
#       ifndef opt_synth_2to1_8bit_mono
 
480
#               define opt_synth_2to1_8bit_mono(fr) synth_2to1_8bit_mono
 
481
#       endif
 
482
#       ifndef opt_synth_2to1_8bit_mono2stereo
 
483
#               define opt_synth_2to1_8bit_mono2stereo(fr) synth_2to1_8bit_mono2stereo
 
484
#       endif
 
485
#       ifndef opt_synth_2to1_real_mono
 
486
#               define opt_synth_2to1_real_mono(fr) synth_2to1_real_mono
 
487
#       endif
 
488
#       ifndef opt_synth_2to1_real_mono2stereo
 
489
#               define opt_synth_2to1_real_mono2stereo(fr) synth_2to1_real_mono2stereo
 
490
#       endif
 
491
#       ifndef opt_synth_2to1_s32_mono
 
492
#               define opt_synth_2to1_s32_mono(fr) synth_2to1_s32_mono
 
493
#       endif
 
494
#       ifndef opt_synth_2to1_s32_mono2stereo
 
495
#               define opt_synth_2to1_s32_mono2stereo(fr) synth_2to1_s32_mono2stereo
 
496
#       endif
 
497
/* 4to1 mono */
 
498
#       ifndef opt_synth_4to1_mono
 
499
#               define opt_synth_4to1_mono(fr) synth_4to1_mono
 
500
#       endif
 
501
#       ifndef opt_synth_4to1_mono2stereo
 
502
#               define opt_synth_4to1_mono2stereo(fr) synth_4to1_mono2stereo
 
503
#       endif
 
504
#       ifndef opt_synth_4to1_8bit_mono
 
505
#               define opt_synth_4to1_8bit_mono(fr) synth_4to1_8bit_mono
 
506
#       endif
 
507
#       ifndef opt_synth_4to1_8bit_mono2stereo
 
508
#               define opt_synth_4to1_8bit_mono2stereo(fr) synth_4to1_8bit_mono2stereo
 
509
#       endif
 
510
#       ifndef opt_synth_4to1_real_mono
 
511
#               define opt_synth_4to1_real_mono(fr) synth_4to1_real_mono
 
512
#       endif
 
513
#       ifndef opt_synth_4to1_real_mono2stereo
 
514
#               define opt_synth_4to1_real_mono2stereo(fr) synth_4to1_real_mono2stereo
 
515
#       endif
 
516
#       ifndef opt_synth_4to1_s32_mono
 
517
#               define opt_synth_4to1_s32_mono(fr) synth_4to1_s32_mono
 
518
#       endif
 
519
#       ifndef opt_synth_4to1_s32_mono2stereo
 
520
#               define opt_synth_4to1_s32_mono2stereo(fr) synth_4to1_s32_mono2stereo
 
521
#       endif
 
522
/* ntom mono */
 
523
#       ifndef opt_synth_ntom_mono
 
524
#               define opt_synth_ntom_mono(fr) synth_ntom_mono
 
525
#       endif
 
526
#       ifndef opt_synth_ntom_mono2stereo
 
527
#               define opt_synth_ntom_mono2stereo(fr) synth_ntom_mono2stereo
 
528
#       endif
 
529
#       ifndef opt_synth_ntom_8bit_mono
 
530
#               define opt_synth_ntom_8bit_mono(fr) synth_ntom_8bit_mono
 
531
#       endif
 
532
#       ifndef opt_synth_ntom_8bit_mono2stereo
 
533
#               define opt_synth_ntom_8bit_mono2stereo(fr) synth_ntom_8bit_mono2stereo
 
534
#       endif
 
535
#       ifndef opt_synth_ntom_real_mono
 
536
#               define opt_synth_ntom_real_mono(fr) synth_ntom_real_mono
 
537
#       endif
 
538
#       ifndef opt_synth_ntom_real_mono2stereo
 
539
#               define opt_synth_ntom_real_mono2stereo(fr) synth_ntom_real_mono2stereo
 
540
#       endif
 
541
#       ifndef opt_synth_ntom_s32_mono
 
542
#               define opt_synth_ntom_s32_mono(fr) synth_ntom_s32_mono
 
543
#       endif
 
544
#       ifndef opt_synth_ntom_s32_mono2stereo
 
545
#               define opt_synth_ntom_s32_mono2stereo(fr) synth_ntom_s32_mono2stereo
 
546
#       endif
 
547
 
 
548
/* End of generated output. */
 
549
 
 
550
#       ifndef opt_dct36
 
551
#               define opt_dct36(fr) dct36
 
552
#       endif
 
553
 
 
554
#endif /* OPT_MULTI else */
348
555
 
349
556
#endif /* MPG123_H_OPTIMIZE */
350
557