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

« back to all changes in this revision

Viewing changes to src/libmpg123/optimize.c

  • 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:
1
1
/*
2
2
        optimize: get a grip on the different optimizations
3
3
 
4
 
        copyright 2006 by the mpg123 project - free software under the terms of the LGPL 2.1
 
4
        copyright 2006-9 by the mpg123 project - free software under the terms of the LGPL 2.1
5
5
        see COPYING and AUTHORS files in distribution or http://mpg123.org
6
6
        initially written by Thomas Orgis, inspired by 3DNow stuff in mpg123.[hc]
7
7
 
9
9
*/
10
10
 
11
11
#include "mpg123lib_intern.h" /* includes optimize.h */
12
 
#ifdef OPT_MULTI
13
 
 
 
12
#include "debug.h"
 
13
 
 
14
/* Must match the enum dectype! */
 
15
 
 
16
/*
 
17
        It SUCKS having to define these names that way, but compile-time intialization of string arrays is a bitch.
 
18
        GCC doesn't see constant stuff when it's wiggling in front of it!
 
19
        Anyhow: Have a script for that:
 
20
names="generic generic_dither i386 i486 i586 i586_dither MMX 3DNow 3DNowExt AltiVec SSE"
 
21
for i in $names; do echo "##define dn_$i \"$i\""; done
 
22
echo -n "static const char* decname[] =
 
23
{
 
24
        \"auto\"
 
25
        "
 
26
for i in $names; do echo -n ", dn_$i"; done
 
27
echo "
 
28
        , \"nodec\"
 
29
};"
 
30
*/
 
31
#define dn_generic "generic"
 
32
#define dn_generic_dither "generic_dither"
 
33
#define dn_i386 "i386"
 
34
#define dn_i486 "i486"
 
35
#define dn_i586 "i586"
 
36
#define dn_i586_dither "i586_dither"
 
37
#define dn_MMX "MMX"
 
38
#define dn_3DNow "3DNow"
 
39
#define dn_3DNowExt "3DNowExt"
 
40
#define dn_AltiVec "AltiVec"
 
41
#define dn_SSE "SSE"
 
42
static const char* decname[] =
 
43
{
 
44
        "auto"
 
45
        , dn_generic, dn_generic_dither, dn_i386, dn_i486, dn_i586, dn_i586_dither, dn_MMX, dn_3DNow, dn_3DNowExt, dn_AltiVec, dn_SSE
 
46
        , "nodec"
 
47
};
 
48
 
 
49
#if (defined OPT_X86) && (defined OPT_MULTI)
14
50
#include "getcpuflags.h"
15
51
struct cpuflags cpu_flags;
 
52
#endif
 
53
 
 
54
enum optdec defdec(void){ return defopt; }
 
55
 
 
56
enum optcla decclass(const enum optdec type)
 
57
{
 
58
        return (type == mmx || type == sse || type == dreidnowext) ? mmxsse : normal;
 
59
}
 
60
 
 
61
/* Determine what kind of decoder is actually active
 
62
   This depends on runtime choices which may cause fallback to i386 or generic code. */
 
63
static int find_dectype(mpg123_handle *fr)
 
64
{
 
65
        enum optdec type = nodec;
 
66
        /* Direct and indirect usage, 1to1 stereo decoding.
 
67
           Concentrating on the plain stereo synth should be fine, mono stuff is derived. */
 
68
        func_synth basic_synth = fr->synth;
 
69
#ifndef NO_8BIT
 
70
#ifndef NO_16BIT
 
71
        if(basic_synth == synth_1to1_8bit_wrap)
 
72
        basic_synth = opt_synth_1to1(fr); /* That is what's really below the surface. */
 
73
#endif
 
74
#endif
 
75
 
 
76
        if(FALSE) ; /* Just to initialize the else if ladder. */
 
77
#ifndef NO_16BIT
 
78
#ifdef OPT_3DNOWEXT
 
79
        else if(basic_synth == synth_1to1_3dnowext) type = dreidnowext;
 
80
#endif
 
81
#ifdef OPT_SSE
 
82
        else if(basic_synth == synth_1to1_sse) type = sse;
 
83
#endif
 
84
#ifdef OPT_3DNOW
 
85
        else if(basic_synth == synth_1to1_3dnow) type = dreidnow;
 
86
#endif
 
87
#ifdef OPT_MMX
 
88
        else if(basic_synth == synth_1to1_mmx) type = mmx;
 
89
#endif
 
90
#ifdef OPT_I586_DITHER
 
91
        else if(basic_synth == synth_1to1_i586_dither) type = ifuenf_dither;
 
92
#endif
 
93
#ifdef OPT_I586
 
94
        else if(basic_synth == synth_1to1_i586) type = ifuenf;
 
95
#endif
 
96
#endif /* 16bit */
 
97
#ifdef OPT_I386
 
98
        else if
 
99
        ( FALSE /* just as a first value for the || chain */
 
100
#ifndef NO_16BIT
 
101
                || basic_synth == synth_1to1_i386
 
102
#endif
 
103
#ifndef NO_8BIT
 
104
                || basic_synth == synth_1to1_8bit_i386
 
105
#endif
 
106
#ifndef NO_DOWNSAMPLE
 
107
#ifndef NO_16BIT
 
108
                || basic_synth == synth_2to1_i386
 
109
                || basic_synth == synth_4to1_i386
 
110
#endif
 
111
#ifndef NO_8BIT
 
112
                || basic_synth == synth_2to1_8bit_i386
 
113
                || basic_synth == synth_4to1_8bit_i386
 
114
#endif
 
115
#endif
 
116
#ifndef REAL_IS_FIXED
 
117
#ifndef NO_REAL
 
118
                || basic_synth == synth_1to1_real_i386
 
119
#endif
 
120
#ifndef NO_32BIT
 
121
                || basic_synth == synth_1to1_s32_i386
 
122
#endif
 
123
#ifndef NO_DOWNSAMPLE
 
124
#ifndef NO_REAL
 
125
                || basic_synth == synth_2to1_real_i386
 
126
                || basic_synth == synth_4to1_real_i386
 
127
#endif
 
128
#ifndef NO_32BIT
 
129
                || basic_synth == synth_2to1_s32_i386
 
130
                || basic_synth == synth_4to1_s32_i386
 
131
#endif
 
132
#endif
 
133
#endif
 
134
        ) type = idrei;
 
135
#endif
 
136
        else if
 
137
        ( FALSE
 
138
#ifndef NO_16BIT
 
139
                || basic_synth == synth_1to1
 
140
#ifndef NO_DOWNSAMPLE
 
141
                || basic_synth == synth_2to1
 
142
                || basic_synth == synth_4to1
 
143
#endif
 
144
#ifndef NO_NTOM
 
145
                || basic_synth == synth_ntom
 
146
#endif
 
147
#endif
 
148
#ifndef NO_8BIT
 
149
                || basic_synth == synth_1to1_8bit
 
150
#ifndef NO_DOWNSAMPLE
 
151
                || basic_synth == synth_2to1_8bit
 
152
                || basic_synth == synth_4to1_8bit
 
153
#endif
 
154
#ifndef NO_NTOM
 
155
                || basic_synth == synth_ntom_8bit
 
156
#endif
 
157
#endif
 
158
#ifndef NO_REAL
 
159
                || basic_synth == synth_1to1_real
 
160
#ifndef NO_DOWNSAMPLE
 
161
                || basic_synth == synth_2to1_real
 
162
                || basic_synth == synth_4to1_real
 
163
#endif
 
164
#ifndef NO_NTOM
 
165
                || basic_synth == synth_ntom_real
 
166
#endif
 
167
#endif
 
168
#ifndef NO_32BIT
 
169
                || basic_synth == synth_1to1_s32
 
170
#ifndef NO_DOWNSAMPLE
 
171
                || basic_synth == synth_2to1_s32
 
172
                || basic_synth == synth_4to1_s32
 
173
#endif
 
174
#ifndef NO_NTOM
 
175
                || basic_synth == synth_ntom_s32
 
176
#endif
 
177
#endif
 
178
        ) type = generic;
 
179
#ifndef NO_16BIT
 
180
#ifdef OPT_GENERIC_DITHER
 
181
        else if(basic_synth == synth_1to1_dither) type = generic_dither;
 
182
#endif
 
183
#ifdef OPT_DITHER /* either i586 or generic! */
 
184
#ifndef NO_DOWNSAMPLE
 
185
        else if
 
186
        (
 
187
                   basic_synth == synth_2to1_dither
 
188
                || basic_synth == synth_4to1_dither
 
189
        ) type = generic_dither;
 
190
#endif
 
191
#endif
 
192
#ifdef OPT_ALTIVEC
 
193
        else if(basic_synth == synth_1to1_altivec) type = altivec;
 
194
#endif
 
195
#endif /* 16bit */
 
196
#ifdef OPT_I486
 
197
        /* i486 is special ... the specific code is in use for 16bit 1to1 stereo
 
198
           otherwise we have i386 active... but still, the distinction doesn't matter*/
 
199
        type = ivier;
 
200
#endif
 
201
 
 
202
        if(type != nodec)
 
203
        {
 
204
                fr->cpu_opts.type = type;
 
205
                fr->cpu_opts.class = decclass(type);
 
206
 
 
207
                debug3("determined active decoder type %i (%s) of class %i", type, decname[type], fr->cpu_opts.class);
 
208
                return MPG123_OK;
 
209
        }
 
210
        else
 
211
        {
 
212
                if(NOQUIET) error("Unable to determine active decoder type -- this is SERIOUS b0rkage!");
 
213
 
 
214
                fr->err = MPG123_BAD_DECODER_SETUP;
 
215
                return MPG123_ERR;
 
216
        }
 
217
}
 
218
 
 
219
/* set synth functions for current frame, optimizations handled by opt_* macros */
 
220
int set_synth_functions(mpg123_handle *fr)
 
221
{
 
222
        int ds = fr->down_sample;
 
223
        int basic_format = OUT_16; /* Default is always 16bit. */
 
224
        /* The tables to select the synth functions from...
 
225
           First we have stereo synths for different outputs and resampling modes,
 
226
           then functions for mono2stereo and mono, again for different outputs and resampling modes. */
 
227
        func_synth      funcs[OUT_FORMATS][4];
 
228
        func_synth_mono funcs_mono[OUT_FORMATS][4];
 
229
        func_synth_mono funcs_mono2stereo[OUT_FORMATS][4];
 
230
 
 
231
        /* What a pyramid... but that's the host of synth function interfaces we cater.
 
232
           TODO: In future, the synth slots in the frame struct should have the same array structure.
 
233
           Actually... they shall _be_ _this_ struct. Will reduce quite some code. */
 
234
#ifndef NO_16BIT
 
235
        funcs[OUT_16][0] = (func_synth) opt_synth_1to1(fr);
 
236
#ifndef NO_DOWNSAMPLE
 
237
        funcs[OUT_16][1] = (func_synth) opt_synth_2to1(fr);
 
238
        funcs[OUT_16][2] = (func_synth) opt_synth_4to1(fr);
 
239
#endif
 
240
#ifndef NO_NTOM
 
241
        funcs[OUT_16][3] = (func_synth) opt_synth_ntom(fr);
 
242
#endif
 
243
#endif
 
244
#ifndef NO_8BIT
 
245
        funcs[OUT_8][0] = (func_synth) opt_synth_1to1_8bit(fr);
 
246
#ifndef NO_DOWNSAMPLE
 
247
        funcs[OUT_8][1] = (func_synth) opt_synth_2to1_8bit(fr);
 
248
        funcs[OUT_8][2] = (func_synth) opt_synth_4to1_8bit(fr);
 
249
#endif
 
250
#ifndef NO_NTOM
 
251
        funcs[OUT_8][3] = (func_synth) opt_synth_ntom_8bit(fr);
 
252
#endif
 
253
#endif
 
254
#ifndef NO_REAL
 
255
        funcs[OUT_REAL][0] = (func_synth) opt_synth_1to1_real(fr);
 
256
#ifndef NO_DOWNSAMPLE
 
257
        funcs[OUT_REAL][1] = (func_synth) opt_synth_2to1_real(fr);
 
258
        funcs[OUT_REAL][2] = (func_synth) opt_synth_4to1_real(fr);
 
259
#endif
 
260
#ifndef NO_NTOM
 
261
        funcs[OUT_REAL][3] = (func_synth) opt_synth_ntom_real(fr);
 
262
#endif
 
263
#endif
 
264
#ifndef NO_32BIT
 
265
        funcs[OUT_S32][0] = (func_synth) opt_synth_1to1_s32(fr);
 
266
#ifndef NO_DOWNSAMPLE
 
267
        funcs[OUT_S32][1] = (func_synth) opt_synth_2to1_s32(fr);
 
268
        funcs[OUT_S32][2] = (func_synth) opt_synth_4to1_s32(fr);
 
269
#endif
 
270
#ifndef NO_NTOM
 
271
        funcs[OUT_S32][3] = (func_synth) opt_synth_ntom_s32(fr);
 
272
#endif
 
273
#endif
 
274
 
 
275
#ifndef NO_16BIT
 
276
        funcs_mono[OUT_16][0] = (func_synth_mono) opt_synth_1to1_mono(fr);
 
277
#ifndef NO_DOWNSAMPLE
 
278
        funcs_mono[OUT_16][1] = (func_synth_mono) opt_synth_2to1_mono(fr);
 
279
        funcs_mono[OUT_16][2] = (func_synth_mono) opt_synth_4to1_mono(fr);
 
280
#endif
 
281
#ifndef NO_NTOM
 
282
        funcs_mono[OUT_16][3] = (func_synth_mono) opt_synth_ntom_mono(fr);
 
283
#endif
 
284
#endif
 
285
#ifndef NO_8BIT
 
286
        funcs_mono[OUT_8][0] = (func_synth_mono) opt_synth_1to1_8bit_mono(fr);
 
287
#ifndef NO_DOWNSAMPLE
 
288
        funcs_mono[OUT_8][1] = (func_synth_mono) opt_synth_2to1_8bit_mono(fr);
 
289
        funcs_mono[OUT_8][2] = (func_synth_mono) opt_synth_4to1_8bit_mono(fr);
 
290
#endif
 
291
#ifndef NO_NTOM
 
292
        funcs_mono[OUT_8][3] = (func_synth_mono) opt_synth_ntom_8bit_mono(fr);
 
293
#endif
 
294
#endif
 
295
#ifndef NO_REAL
 
296
        funcs_mono[OUT_REAL][0] = (func_synth_mono) opt_synth_1to1_real_mono(fr);
 
297
#ifndef NO_DOWNSAMPLE
 
298
        funcs_mono[OUT_REAL][1] = (func_synth_mono) opt_synth_2to1_real_mono(fr);
 
299
        funcs_mono[OUT_REAL][2] = (func_synth_mono) opt_synth_4to1_real_mono(fr);
 
300
#endif
 
301
#ifndef NO_NTOM
 
302
        funcs_mono[OUT_REAL][3] = (func_synth_mono) opt_synth_ntom_real_mono(fr);
 
303
#endif
 
304
#endif
 
305
#ifndef NO_32BIT
 
306
        funcs_mono[OUT_S32][0] = (func_synth_mono) opt_synth_1to1_s32_mono(fr);
 
307
#ifndef NO_DOWNSAMPLE
 
308
        funcs_mono[OUT_S32][1] = (func_synth_mono) opt_synth_2to1_s32_mono(fr);
 
309
        funcs_mono[OUT_S32][2] = (func_synth_mono) opt_synth_4to1_s32_mono(fr);
 
310
#endif
 
311
#ifndef NO_NTOM
 
312
        funcs_mono[OUT_S32][3] = (func_synth_mono) opt_synth_ntom_s32_mono(fr);
 
313
#endif
 
314
#endif
 
315
 
 
316
#ifndef NO_16BIT
 
317
        funcs_mono2stereo[OUT_16][0] = (func_synth_mono) opt_synth_1to1_mono2stereo(fr);
 
318
#ifndef NO_DOWNSAMPLE
 
319
        funcs_mono2stereo[OUT_16][1] = (func_synth_mono) opt_synth_2to1_mono2stereo(fr);
 
320
        funcs_mono2stereo[OUT_16][2] = (func_synth_mono) opt_synth_4to1_mono2stereo(fr);
 
321
#endif
 
322
#ifndef NO_NTOM
 
323
        funcs_mono2stereo[OUT_16][3] = (func_synth_mono) opt_synth_ntom_mono2stereo(fr);
 
324
#endif
 
325
#endif
 
326
#ifndef NO_8BIT
 
327
        funcs_mono2stereo[OUT_8][0] = (func_synth_mono) opt_synth_1to1_8bit_mono2stereo(fr);
 
328
#ifndef NO_DOWNSAMPLE
 
329
        funcs_mono2stereo[OUT_8][1] = (func_synth_mono) opt_synth_2to1_8bit_mono2stereo(fr);
 
330
        funcs_mono2stereo[OUT_8][2] = (func_synth_mono) opt_synth_4to1_8bit_mono2stereo(fr);
 
331
#endif
 
332
#ifndef NO_NTOM
 
333
        funcs_mono2stereo[OUT_8][3] = (func_synth_mono) opt_synth_ntom_8bit_mono2stereo(fr);
 
334
#endif
 
335
#endif
 
336
#ifndef NO_REAL
 
337
        funcs_mono2stereo[OUT_REAL][0] = (func_synth_mono) opt_synth_1to1_real_mono2stereo(fr);
 
338
#ifndef NO_DOWNSAMPLE
 
339
        funcs_mono2stereo[OUT_REAL][1] = (func_synth_mono) opt_synth_2to1_real_mono2stereo(fr);
 
340
        funcs_mono2stereo[OUT_REAL][2] = (func_synth_mono) opt_synth_4to1_real_mono2stereo(fr);
 
341
#endif
 
342
#ifndef NO_NTOM
 
343
        funcs_mono2stereo[OUT_REAL][3] = (func_synth_mono) opt_synth_ntom_real_mono2stereo(fr);
 
344
#endif
 
345
#endif
 
346
#ifndef NO_32BIT
 
347
        funcs_mono2stereo[OUT_S32][0] = (func_synth_mono) opt_synth_1to1_s32_mono2stereo(fr);
 
348
#ifndef NO_DOWNSAMPLE
 
349
        funcs_mono2stereo[OUT_S32][1] = (func_synth_mono) opt_synth_2to1_s32_mono2stereo(fr);
 
350
        funcs_mono2stereo[OUT_S32][2] = (func_synth_mono) opt_synth_4to1_s32_mono2stereo(fr);
 
351
#endif
 
352
#ifndef NO_NTOM
 
353
        funcs_mono2stereo[OUT_S32][3] = (func_synth_mono) opt_synth_ntom_s32_mono2stereo(fr);
 
354
#endif
 
355
#endif
 
356
 
 
357
        /* Select the basic output format, different from 16bit: 8bit, real. */
 
358
        if(fr->af.encoding & MPG123_ENC_8)
 
359
        basic_format = OUT_8;
 
360
        else if(fr->af.encoding & MPG123_ENC_FLOAT)
 
361
        basic_format = OUT_REAL;
 
362
        else if(fr->af.encoding & MPG123_ENC_32)
 
363
        basic_format = OUT_S32;
 
364
 
 
365
        if /* Make sure the chosen format is compiled into this lib. */
 
366
        ( FALSE
 
367
#ifdef NO_8BIT
 
368
                || basic_format == OUT_8
 
369
#endif
 
370
#ifdef NO_16BIT
 
371
                || basic_format == OUT_16
 
372
#endif
 
373
#ifdef NO_32BIT
 
374
                || basic_format == OUT_S32
 
375
#endif
 
376
#ifdef NO_REAL
 
377
                || basic_format == OUT_REAL
 
378
#endif
 
379
        )
 
380
        {
 
381
                if(NOQUIET) error("set_synth_functions: This output format is disabled in this build!");
 
382
 
 
383
                return -1;
 
384
        }
 
385
 
 
386
        /* Finally selecting the synth functions for stereo / mono. */
 
387
        fr->synth = funcs[basic_format][ds];
 
388
        fr->synth_mono = fr->af.channels==2
 
389
                ? funcs_mono2stereo[basic_format][ds] /* Mono MPEG file decoded to stereo. */
 
390
                : funcs_mono[basic_format][ds];       /* Mono MPEG file decoded to mono. */
 
391
 
 
392
        if(find_dectype(fr) != MPG123_OK) /* Actually determine the currently active decoder breed. */
 
393
        {
 
394
                fr->err = MPG123_BAD_DECODER_SETUP;
 
395
                return MPG123_ERR;
 
396
        }
 
397
 
 
398
        if(frame_buffers(fr) != 0)
 
399
        {
 
400
                fr->err = MPG123_NO_BUFFERS;
 
401
                if(NOQUIET) error("Failed to set up decoder buffers!");
 
402
 
 
403
                return MPG123_ERR;
 
404
        }
 
405
 
 
406
#ifndef NO_8BIT
 
407
        if(basic_format == OUT_8)
 
408
        {
 
409
                if(make_conv16to8_table(fr) != 0)
 
410
                {
 
411
                        if(NOQUIET) error("Failed to set up conv16to8 table!");
 
412
                        /* it's a bit more work to get proper error propagation up */
 
413
                        return -1;
 
414
                }
 
415
        }
 
416
#endif
 
417
 
 
418
#ifdef OPT_MMXORSSE
 
419
        /* Special treatment for MMX, SSE and 3DNowExt stuff. */
 
420
        if(fr->cpu_opts.class == mmxsse)
 
421
        {
 
422
#ifndef NO_LAYER3
 
423
                init_layer3_stuff(fr, init_layer3_gainpow2_mmx);
 
424
#endif
 
425
#ifndef NO_LAYER12
 
426
                init_layer12_stuff(fr, init_layer12_table_mmx);
 
427
#endif
 
428
                fr->make_decode_tables = make_decode_tables_mmx;
 
429
        }
 
430
        else
 
431
#endif
 
432
        {
 
433
#ifndef NO_LAYER3
 
434
                init_layer3_stuff(fr, init_layer3_gainpow2);
 
435
#endif
 
436
#ifndef NO_LAYER12
 
437
                init_layer12_stuff(fr, init_layer12_table);
 
438
#endif
 
439
                fr->make_decode_tables = make_decode_tables;
 
440
        }
 
441
 
 
442
        /* We allocated the table buffers just now, so (re)create the tables. */
 
443
        fr->make_decode_tables(fr);
 
444
 
 
445
        return 0;
 
446
}
 
447
 
 
448
int frame_cpu_opt(mpg123_handle *fr, const char* cpu)
 
449
{
 
450
        const char* chosen = ""; /* the chosen decoder opt as string */
 
451
        enum optdec want_dec = nodec;
 
452
        int done = 0;
 
453
        int auto_choose = 0;
 
454
        want_dec = dectype(cpu);
 
455
        auto_choose = want_dec == autodec ? 1 : 0;
 
456
#ifndef OPT_MULTI
 
457
        {
 
458
                if(!auto_choose && want_dec != defopt)
 
459
                {
 
460
                        if(NOQUIET) error2("you wanted decoder type %i, I only have %i", want_dec, defopt);
 
461
 
 
462
                        done = 0;
 
463
                }
 
464
                else
 
465
                {
 
466
                        const char **sd = mpg123_decoders(); /* this contains _one_ decoder */
 
467
                        chosen = sd[0];
 
468
                        done = 1;
 
469
                }
 
470
        }
 
471
#else
 
472
/*
 
473
        First the set of synth functions is nulled, so that we know what to fill in at the end.
 
474
 
 
475
        ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
476
        ## The ## is a quote for just #
 
477
        for t in "" _8bit _s32 _real
 
478
        do
 
479
                test "$t" = _real   && echo "##ifndef NO_REAL"
 
480
                test "$t" = ""      && echo "##ifndef NO_16BIT"
 
481
                test "$t" = "_8bit" && echo "##ifndef NO_8BIT"
 
482
                test "$t" = "_s32"  && echo "##ifndef NO_32BIT"
 
483
 
 
484
                for i in 1to1 2to1 4to1 ntom;
 
485
                do
 
486
                if test "$i" = ntom; then
 
487
                        echo "##ifndef NO_NTOM"
 
488
                fi
 
489
                if test "$i" = 2to1; then
 
490
                        echo "##ifndef NO_DOWNSAMPLE"
 
491
                fi
 
492
                for f in "" _mono _mono2stereo;
 
493
                do
 
494
                        echo "  fr->cpu_opts.synth_${i}${t}${f} = NULL;"
 
495
                done
 
496
                if test "$i" = ntom; then
 
497
                        echo "##endif"
 
498
                fi
 
499
                if test "$i" = 4to1; then
 
500
                        echo "##endif"
 
501
                fi
 
502
                done
 
503
 
 
504
                echo "##endif"
 
505
        done
 
506
*/
 
507
#ifndef NO_16BIT
 
508
        fr->cpu_opts.synth_1to1 = NULL;
 
509
        fr->cpu_opts.synth_1to1_mono = NULL;
 
510
        fr->cpu_opts.synth_1to1_mono2stereo = NULL;
 
511
#ifndef NO_DOWNSAMPLE
 
512
        fr->cpu_opts.synth_2to1 = NULL;
 
513
        fr->cpu_opts.synth_2to1_mono = NULL;
 
514
        fr->cpu_opts.synth_2to1_mono2stereo = NULL;
 
515
        fr->cpu_opts.synth_4to1 = NULL;
 
516
        fr->cpu_opts.synth_4to1_mono = NULL;
 
517
        fr->cpu_opts.synth_4to1_mono2stereo = NULL;
 
518
#endif
 
519
#ifndef NO_NTOM
 
520
        fr->cpu_opts.synth_ntom = NULL;
 
521
        fr->cpu_opts.synth_ntom_mono = NULL;
 
522
        fr->cpu_opts.synth_ntom_mono2stereo = NULL;
 
523
#endif
 
524
#endif
 
525
#ifndef NO_8BIT
 
526
        fr->cpu_opts.synth_1to1_8bit = NULL;
 
527
        fr->cpu_opts.synth_1to1_8bit_mono = NULL;
 
528
        fr->cpu_opts.synth_1to1_8bit_mono2stereo = NULL;
 
529
#ifndef NO_DOWNSAMPLE
 
530
        fr->cpu_opts.synth_2to1_8bit = NULL;
 
531
        fr->cpu_opts.synth_2to1_8bit_mono = NULL;
 
532
        fr->cpu_opts.synth_2to1_8bit_mono2stereo = NULL;
 
533
        fr->cpu_opts.synth_4to1_8bit = NULL;
 
534
        fr->cpu_opts.synth_4to1_8bit_mono = NULL;
 
535
        fr->cpu_opts.synth_4to1_8bit_mono2stereo = NULL;
 
536
#endif
 
537
#ifndef NO_NTOM
 
538
        fr->cpu_opts.synth_ntom_8bit = NULL;
 
539
        fr->cpu_opts.synth_ntom_8bit_mono = NULL;
 
540
        fr->cpu_opts.synth_ntom_8bit_mono2stereo = NULL;
 
541
#endif
 
542
#endif
 
543
#ifndef NO_32BIT
 
544
        fr->cpu_opts.synth_1to1_s32 = NULL;
 
545
        fr->cpu_opts.synth_1to1_s32_mono = NULL;
 
546
        fr->cpu_opts.synth_1to1_s32_mono2stereo = NULL;
 
547
#ifndef NO_DOWNSAMPLE
 
548
        fr->cpu_opts.synth_2to1_s32 = NULL;
 
549
        fr->cpu_opts.synth_2to1_s32_mono = NULL;
 
550
        fr->cpu_opts.synth_2to1_s32_mono2stereo = NULL;
 
551
        fr->cpu_opts.synth_4to1_s32 = NULL;
 
552
        fr->cpu_opts.synth_4to1_s32_mono = NULL;
 
553
        fr->cpu_opts.synth_4to1_s32_mono2stereo = NULL;
 
554
#endif
 
555
#ifndef NO_NTOM
 
556
        fr->cpu_opts.synth_ntom_s32 = NULL;
 
557
        fr->cpu_opts.synth_ntom_s32_mono = NULL;
 
558
        fr->cpu_opts.synth_ntom_s32_mono2stereo = NULL;
 
559
#endif
 
560
#endif
 
561
#ifndef NO_REAL
 
562
        fr->cpu_opts.synth_1to1_real = NULL;
 
563
        fr->cpu_opts.synth_1to1_real_mono = NULL;
 
564
        fr->cpu_opts.synth_1to1_real_mono2stereo = NULL;
 
565
#ifndef NO_DOWNSAMPLE
 
566
        fr->cpu_opts.synth_2to1_real = NULL;
 
567
        fr->cpu_opts.synth_2to1_real_mono = NULL;
 
568
        fr->cpu_opts.synth_2to1_real_mono2stereo = NULL;
 
569
        fr->cpu_opts.synth_4to1_real = NULL;
 
570
        fr->cpu_opts.synth_4to1_real_mono = NULL;
 
571
        fr->cpu_opts.synth_4to1_real_mono2stereo = NULL;
 
572
#endif
 
573
#ifndef NO_NTOM
 
574
        fr->cpu_opts.synth_ntom_real = NULL;
 
575
        fr->cpu_opts.synth_ntom_real_mono = NULL;
 
576
        fr->cpu_opts.synth_ntom_real_mono2stereo = NULL;
 
577
#endif
 
578
#endif
 
579
 
 
580
        fr->cpu_opts.type = nodec;
 
581
        /* covers any i386+ cpu; they actually differ only in the synth_1to1 function... */
 
582
#ifdef OPT_X86
 
583
 
 
584
#ifndef NO_LAYER3
 
585
#if (defined OPT_3DNOW || defined OPT_3DNOWEXT)
 
586
        fr->cpu_opts.dct36 = dct36;
 
587
#endif
 
588
#endif
 
589
 
 
590
        if(cpu_i586(cpu_flags))
 
591
        {
 
592
                debug2("standard flags: 0x%08x\textended flags: 0x%08x", cpu_flags.std, cpu_flags.ext);
 
593
                #ifdef OPT_3DNOWEXT
 
594
                if(   !done && (auto_choose || want_dec == dreidnowext )
 
595
                   && cpu_3dnow(cpu_flags)
 
596
                   && cpu_3dnowext(cpu_flags)
 
597
                   && cpu_mmx(cpu_flags) )
 
598
                {
 
599
                        chosen = "3DNowExt";
 
600
                        fr->cpu_opts.type = dreidnowext;
 
601
#                       ifndef NO_LAYER3
 
602
                        fr->cpu_opts.dct36 = dct36_3dnowext;
 
603
#                       endif
 
604
#                       ifndef NO_16BIT
 
605
                        fr->cpu_opts.synth_1to1 = synth_1to1_3dnowext;
 
606
#                       endif
 
607
                        done = 1;
 
608
                }
 
609
                #endif
 
610
                #ifdef OPT_SSE
 
611
                if(   !done && (auto_choose || want_dec == sse)
 
612
                   && cpu_sse(cpu_flags) && cpu_mmx(cpu_flags) )
 
613
                {
 
614
                        chosen = "SSE";
 
615
                        fr->cpu_opts.type = sse;
 
616
#                       ifndef NO_16BIT
 
617
                        fr->cpu_opts.synth_1to1 = synth_1to1_sse;
 
618
#                       endif
 
619
                        done = 1;
 
620
                }
 
621
                #endif
 
622
                #ifdef OPT_3DNOW
 
623
#               ifndef NO_LAYER3
 
624
                fr->cpu_opts.dct36 = dct36;
 
625
#               endif
 
626
                if(    !done && (auto_choose || want_dec == dreidnow)
 
627
                    && cpu_3dnow(cpu_flags) && cpu_mmx(cpu_flags) )
 
628
                {
 
629
                        chosen = "3DNow";
 
630
                        fr->cpu_opts.type = dreidnow;
 
631
#                       ifndef NO_LAYER3
 
632
                        fr->cpu_opts.dct36 = dct36_3dnow;
 
633
#                       endif
 
634
#                       ifndef NO_16BIT
 
635
                        fr->cpu_opts.synth_1to1 = synth_1to1_3dnow;
 
636
#                       endif
 
637
                        done = 1;
 
638
                }
 
639
                #endif
 
640
                #ifdef OPT_MMX
 
641
                if(   !done && (auto_choose || want_dec == mmx)
 
642
                   && cpu_mmx(cpu_flags) )
 
643
                {
 
644
                        chosen = "MMX";
 
645
                        fr->cpu_opts.type = mmx;
 
646
#                       ifndef NO_16BIT
 
647
                        fr->cpu_opts.synth_1to1 = synth_1to1_mmx;
 
648
#                       endif
 
649
                        done = 1;
 
650
                }
 
651
                #endif
 
652
                #ifdef OPT_I586
 
653
                if(!done && (auto_choose || want_dec == ifuenf))
 
654
                {
 
655
                        chosen = "i586/pentium";
 
656
                        fr->cpu_opts.type = ifuenf;
 
657
#                       ifndef NO_16BIT
 
658
                        fr->cpu_opts.synth_1to1 = synth_1to1_i586;
 
659
#                       endif
 
660
                        done = 1;
 
661
                }
 
662
                #endif
 
663
                #ifdef OPT_I586_DITHER
 
664
                if(!done && (auto_choose || want_dec == ifuenf_dither))
 
665
                {
 
666
                        chosen = "dithered i586/pentium";
 
667
                        fr->cpu_opts.type = ifuenf_dither;
 
668
#                       ifndef NO_16BIT
 
669
                        fr->cpu_opts.synth_1to1 = synth_1to1_i586_dither;
 
670
#                       ifndef NO_DOWNSAMPLE
 
671
                        fr->cpu_opts.synth_2to1 = synth_2to1_dither;
 
672
                        fr->cpu_opts.synth_4to1 = synth_4to1_dither;
 
673
#                       endif
 
674
#                       endif
 
675
                        done = 1;
 
676
                }
 
677
                #endif
 
678
        }
 
679
        #ifdef OPT_I486
 
680
        /* That won't cooperate in multi opt mode - forcing i486 in layer3.c
 
681
           But still... here it is... maybe for real use in future. */
 
682
        if(!done && (auto_choose || want_dec == ivier))
 
683
        {
 
684
                chosen = "i486";
 
685
                fr->cpu_opts.type = ivier;
 
686
                done = 1;
 
687
        }
 
688
        #endif
 
689
        #ifdef OPT_I386
 
690
        if(!done && (auto_choose || want_dec == idrei))
 
691
        {
 
692
                chosen = "i386";
 
693
                fr->cpu_opts.type = idrei;
 
694
                done = 1;
 
695
        }
 
696
        #endif
 
697
 
 
698
        if(done)
 
699
        { /* We have chosen some x86 decoder... */
 
700
                /* First, we see if there is indeed some special (non-i386) synth_1to1 and use the 8bit wrappers over it.
 
701
                   If not, we use the direct i386 8bit synth and the normal mono functions. */
 
702
#ifndef NO_8BIT
 
703
#ifndef NO_16BIT /* possibility to use a 16->8 wrapper... */
 
704
                if(fr->cpu_opts.synth_1to1 != NULL)
 
705
                {
 
706
                        fr->cpu_opts.synth_1to1_8bit = synth_1to1_8bit_wrap;
 
707
                        fr->cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_wrap_mono;
 
708
                        fr->cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_wrap_mono2stereo;
 
709
                }
 
710
                else
 
711
                {
 
712
                        fr->cpu_opts.synth_1to1 = synth_1to1_i386;
 
713
#endif /* straight 8bit */
 
714
                        fr->cpu_opts.synth_1to1_8bit = synth_1to1_8bit_i386;
 
715
#ifndef NO_16BIT
 
716
                }
 
717
#endif
 
718
#endif
 
719
#ifndef NO_16BIT
 
720
                if(fr->cpu_opts.synth_1to1 == NULL)
 
721
                fr->cpu_opts.synth_1to1 = synth_1to1_i386;
 
722
#endif
 
723
                /*
 
724
                        Now fill in the non-mono synths that are still missing from the i386 variants.
 
725
                        
 
726
 
 
727
                        ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
728
                        ## The ## is a quote for just #
 
729
                        for t in "" _8bit _s32 _real
 
730
                        do
 
731
                                test "$t" = _real   && echo "##         ifndef NO_REAL"
 
732
                                test "$t" = ""      && echo "##         ifndef NO_16BIT"
 
733
                                test "$t" = "_8bit" && echo "##         ifndef NO_8BIT"
 
734
                                test "$t" = "_s32"  && echo "##         ifndef NO_32BIT"
 
735
 
 
736
                                for i in 1to1 2to1 4to1
 
737
                                do
 
738
                                        if test "$i" = 2to1; then
 
739
                                                echo "##                ifndef NO_DOWNSAMPLE"
 
740
                                        fi
 
741
                                        echo "          if(fr->cpu_opts.synth_${i}${t} == NULL) fr->cpu_opts.synth_${i}${t} = synth_${i}${t}_i386;"
 
742
                                        if test "$i" = 4to1; then
 
743
                                                echo "##                endif"
 
744
                                        fi
 
745
                                done
 
746
 
 
747
                                echo "##                endif"
 
748
                        done
 
749
                */
 
750
#               ifndef NO_16BIT
 
751
                if(fr->cpu_opts.synth_1to1 == NULL) fr->cpu_opts.synth_1to1 = synth_1to1_i386;
 
752
#               ifndef NO_DOWNSAMPLE
 
753
                if(fr->cpu_opts.synth_2to1 == NULL) fr->cpu_opts.synth_2to1 = synth_2to1_i386;
 
754
                if(fr->cpu_opts.synth_4to1 == NULL) fr->cpu_opts.synth_4to1 = synth_4to1_i386;
 
755
#               endif
 
756
#               endif
 
757
#               ifndef NO_8BIT
 
758
                if(fr->cpu_opts.synth_1to1_8bit == NULL) fr->cpu_opts.synth_1to1_8bit = synth_1to1_8bit_i386;
 
759
#               ifndef NO_DOWNSAMPLE
 
760
                if(fr->cpu_opts.synth_2to1_8bit == NULL) fr->cpu_opts.synth_2to1_8bit = synth_2to1_8bit_i386;
 
761
                if(fr->cpu_opts.synth_4to1_8bit == NULL) fr->cpu_opts.synth_4to1_8bit = synth_4to1_8bit_i386;
 
762
#               endif
 
763
#               endif
 
764
#               ifndef NO_32BIT
 
765
                if(fr->cpu_opts.synth_1to1_s32 == NULL) fr->cpu_opts.synth_1to1_s32 = synth_1to1_s32_i386;
 
766
#               ifndef NO_DOWNSAMPLE
 
767
                if(fr->cpu_opts.synth_2to1_s32 == NULL) fr->cpu_opts.synth_2to1_s32 = synth_2to1_s32_i386;
 
768
                if(fr->cpu_opts.synth_4to1_s32 == NULL) fr->cpu_opts.synth_4to1_s32 = synth_4to1_s32_i386;
 
769
#               endif
 
770
#               endif
 
771
#               ifndef NO_REAL
 
772
                if(fr->cpu_opts.synth_1to1_real == NULL) fr->cpu_opts.synth_1to1_real = synth_1to1_real_i386;
 
773
#               ifndef NO_DOWNSAMPLE
 
774
                if(fr->cpu_opts.synth_2to1_real == NULL) fr->cpu_opts.synth_2to1_real = synth_2to1_real_i386;
 
775
                if(fr->cpu_opts.synth_4to1_real == NULL) fr->cpu_opts.synth_4to1_real = synth_4to1_real_i386;
 
776
#               endif
 
777
#               endif
 
778
        }
 
779
 
 
780
#endif /* OPT_X86 */
 
781
 
 
782
#ifdef OPT_GENERIC_DITHER
 
783
        if(!done && (auto_choose || want_dec == generic_dither))
 
784
        {
 
785
                chosen = "dithered generic";
 
786
                fr->cpu_opts.type = generic_dither;
 
787
#               ifndef NO_16BIT
 
788
                fr->cpu_opts.synth_1to1 = synth_1to1_dither;
 
789
#               ifndef NO_DOWNSAMPLE
 
790
                fr->cpu_opts.synth_2to1 = synth_2to1_dither;
 
791
                fr->cpu_opts.synth_4to1 = synth_4to1_dither;
 
792
#               endif
 
793
#               endif
 
794
                /* Wrapping 8bit functions don't make sense for dithering. */
 
795
                done = 1;
 
796
        }
 
797
#endif
 
798
 
 
799
        #ifdef OPT_ALTIVEC
 
800
        if(!done && (auto_choose || want_dec == altivec))
 
801
        {
 
802
                chosen = "AltiVec";
 
803
                fr->cpu_opts.type = altivec;
 
804
#               ifndef NO_16BIT
 
805
                fr->cpu_opts.synth_1to1 = synth_1to1_altivec;
 
806
                fr->cpu_opts.synth_1to1_8bit = synth_1to1_8bit_wrap;
 
807
                fr->cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_wrap_mono;
 
808
                fr->cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_wrap_mono2stereo;
 
809
#               endif
 
810
                done = 1;
 
811
        }
 
812
        #endif
 
813
 
 
814
        #ifdef OPT_GENERIC
 
815
        if(!done && (auto_choose || want_dec == generic))
 
816
        {
 
817
                chosen = "generic";
 
818
                fr->cpu_opts.type = generic;
 
819
                done = 1;
 
820
        }
 
821
        #endif
 
822
 
 
823
        fr->cpu_opts.class = decclass(fr->cpu_opts.type);
 
824
 
 
825
        /*
 
826
                Filling in the last bits.
 
827
                No need to care about 8bit wrappers here, that's all set.
 
828
                Just set everything still missing to a generic function.
 
829
 
 
830
                ## This is an inline bourne shell script for execution in nedit to generate the lines below.
 
831
                ## The ## is a quote for just #
 
832
                for t in "" _8bit _s32 _real
 
833
                do
 
834
                        test "$t" = _real   && echo "## ifndef NO_REAL"
 
835
                        test "$t" = ""      && echo "## ifndef NO_16BIT"
 
836
                        test "$t" = "_8bit" && echo "## ifndef NO_8BIT"
 
837
                        test "$t" = "_s32"  && echo "## ifndef NO_32BIT"
 
838
 
 
839
                        for i in 1to1 2to1 4to1 ntom
 
840
                        do
 
841
                        if test "$i" = ntom; then
 
842
                                echo "##        ifndef NO_NTOM"
 
843
                        fi
 
844
                        if test "$i" = 2to1; then
 
845
                                echo "##        ifndef NO_DOWNSAMPLE"
 
846
                        fi
 
847
                        for m in "" _mono _mono2stereo
 
848
                        do
 
849
                                echo "  if(fr->cpu_opts.synth_${i}${t}${m} == NULL) fr->cpu_opts.synth_${i}${t}${m} = synth_${i}${t}${m};"
 
850
                        done
 
851
                        if test "$i" = ntom; then
 
852
                                echo "##        endif"
 
853
                        fi
 
854
                        if test "$i" = 4to1; then
 
855
                                echo "##        endif"
 
856
                        fi
 
857
                        done
 
858
 
 
859
                        echo "##        endif"
 
860
                done
 
861
        */
 
862
#       ifndef NO_16BIT
 
863
        if(fr->cpu_opts.synth_1to1 == NULL) fr->cpu_opts.synth_1to1 = synth_1to1;
 
864
        if(fr->cpu_opts.synth_1to1_mono == NULL) fr->cpu_opts.synth_1to1_mono = synth_1to1_mono;
 
865
        if(fr->cpu_opts.synth_1to1_mono2stereo == NULL) fr->cpu_opts.synth_1to1_mono2stereo = synth_1to1_mono2stereo;
 
866
#       ifndef NO_DOWNSAMPLE
 
867
        if(fr->cpu_opts.synth_2to1 == NULL) fr->cpu_opts.synth_2to1 = synth_2to1;
 
868
        if(fr->cpu_opts.synth_2to1_mono == NULL) fr->cpu_opts.synth_2to1_mono = synth_2to1_mono;
 
869
        if(fr->cpu_opts.synth_2to1_mono2stereo == NULL) fr->cpu_opts.synth_2to1_mono2stereo = synth_2to1_mono2stereo;
 
870
        if(fr->cpu_opts.synth_4to1 == NULL) fr->cpu_opts.synth_4to1 = synth_4to1;
 
871
        if(fr->cpu_opts.synth_4to1_mono == NULL) fr->cpu_opts.synth_4to1_mono = synth_4to1_mono;
 
872
        if(fr->cpu_opts.synth_4to1_mono2stereo == NULL) fr->cpu_opts.synth_4to1_mono2stereo = synth_4to1_mono2stereo;
 
873
#       endif
 
874
#       ifndef NO_NTOM
 
875
        if(fr->cpu_opts.synth_ntom == NULL) fr->cpu_opts.synth_ntom = synth_ntom;
 
876
        if(fr->cpu_opts.synth_ntom_mono == NULL) fr->cpu_opts.synth_ntom_mono = synth_ntom_mono;
 
877
        if(fr->cpu_opts.synth_ntom_mono2stereo == NULL) fr->cpu_opts.synth_ntom_mono2stereo = synth_ntom_mono2stereo;
 
878
#       endif
 
879
#       endif
 
880
#       ifndef NO_8BIT
 
881
        if(fr->cpu_opts.synth_1to1_8bit == NULL) fr->cpu_opts.synth_1to1_8bit = synth_1to1_8bit;
 
882
        if(fr->cpu_opts.synth_1to1_8bit_mono == NULL) fr->cpu_opts.synth_1to1_8bit_mono = synth_1to1_8bit_mono;
 
883
        if(fr->cpu_opts.synth_1to1_8bit_mono2stereo == NULL) fr->cpu_opts.synth_1to1_8bit_mono2stereo = synth_1to1_8bit_mono2stereo;
 
884
#       ifndef NO_DOWNSAMPLE
 
885
        if(fr->cpu_opts.synth_2to1_8bit == NULL) fr->cpu_opts.synth_2to1_8bit = synth_2to1_8bit;
 
886
        if(fr->cpu_opts.synth_2to1_8bit_mono == NULL) fr->cpu_opts.synth_2to1_8bit_mono = synth_2to1_8bit_mono;
 
887
        if(fr->cpu_opts.synth_2to1_8bit_mono2stereo == NULL) fr->cpu_opts.synth_2to1_8bit_mono2stereo = synth_2to1_8bit_mono2stereo;
 
888
        if(fr->cpu_opts.synth_4to1_8bit == NULL) fr->cpu_opts.synth_4to1_8bit = synth_4to1_8bit;
 
889
        if(fr->cpu_opts.synth_4to1_8bit_mono == NULL) fr->cpu_opts.synth_4to1_8bit_mono = synth_4to1_8bit_mono;
 
890
        if(fr->cpu_opts.synth_4to1_8bit_mono2stereo == NULL) fr->cpu_opts.synth_4to1_8bit_mono2stereo = synth_4to1_8bit_mono2stereo;
 
891
#       endif
 
892
#       ifndef NO_NTOM
 
893
        if(fr->cpu_opts.synth_ntom_8bit == NULL) fr->cpu_opts.synth_ntom_8bit = synth_ntom_8bit;
 
894
        if(fr->cpu_opts.synth_ntom_8bit_mono == NULL) fr->cpu_opts.synth_ntom_8bit_mono = synth_ntom_8bit_mono;
 
895
        if(fr->cpu_opts.synth_ntom_8bit_mono2stereo == NULL) fr->cpu_opts.synth_ntom_8bit_mono2stereo = synth_ntom_8bit_mono2stereo;
 
896
#       endif
 
897
#       endif
 
898
#       ifndef NO_32BIT
 
899
        if(fr->cpu_opts.synth_1to1_s32 == NULL) fr->cpu_opts.synth_1to1_s32 = synth_1to1_s32;
 
900
        if(fr->cpu_opts.synth_1to1_s32_mono == NULL) fr->cpu_opts.synth_1to1_s32_mono = synth_1to1_s32_mono;
 
901
        if(fr->cpu_opts.synth_1to1_s32_mono2stereo == NULL) fr->cpu_opts.synth_1to1_s32_mono2stereo = synth_1to1_s32_mono2stereo;
 
902
#       ifndef NO_DOWNSAMPLE
 
903
        if(fr->cpu_opts.synth_2to1_s32 == NULL) fr->cpu_opts.synth_2to1_s32 = synth_2to1_s32;
 
904
        if(fr->cpu_opts.synth_2to1_s32_mono == NULL) fr->cpu_opts.synth_2to1_s32_mono = synth_2to1_s32_mono;
 
905
        if(fr->cpu_opts.synth_2to1_s32_mono2stereo == NULL) fr->cpu_opts.synth_2to1_s32_mono2stereo = synth_2to1_s32_mono2stereo;
 
906
        if(fr->cpu_opts.synth_4to1_s32 == NULL) fr->cpu_opts.synth_4to1_s32 = synth_4to1_s32;
 
907
        if(fr->cpu_opts.synth_4to1_s32_mono == NULL) fr->cpu_opts.synth_4to1_s32_mono = synth_4to1_s32_mono;
 
908
        if(fr->cpu_opts.synth_4to1_s32_mono2stereo == NULL) fr->cpu_opts.synth_4to1_s32_mono2stereo = synth_4to1_s32_mono2stereo;
 
909
#       endif
 
910
#       ifndef NO_NTOM
 
911
        if(fr->cpu_opts.synth_ntom_s32 == NULL) fr->cpu_opts.synth_ntom_s32 = synth_ntom_s32;
 
912
        if(fr->cpu_opts.synth_ntom_s32_mono == NULL) fr->cpu_opts.synth_ntom_s32_mono = synth_ntom_s32_mono;
 
913
        if(fr->cpu_opts.synth_ntom_s32_mono2stereo == NULL) fr->cpu_opts.synth_ntom_s32_mono2stereo = synth_ntom_s32_mono2stereo;
 
914
#       endif
 
915
#       endif
 
916
#       ifndef NO_REAL
 
917
        if(fr->cpu_opts.synth_1to1_real == NULL) fr->cpu_opts.synth_1to1_real = synth_1to1_real;
 
918
        if(fr->cpu_opts.synth_1to1_real_mono == NULL) fr->cpu_opts.synth_1to1_real_mono = synth_1to1_real_mono;
 
919
        if(fr->cpu_opts.synth_1to1_real_mono2stereo == NULL) fr->cpu_opts.synth_1to1_real_mono2stereo = synth_1to1_real_mono2stereo;
 
920
#       ifndef NO_DOWNSAMPLE
 
921
        if(fr->cpu_opts.synth_2to1_real == NULL) fr->cpu_opts.synth_2to1_real = synth_2to1_real;
 
922
        if(fr->cpu_opts.synth_2to1_real_mono == NULL) fr->cpu_opts.synth_2to1_real_mono = synth_2to1_real_mono;
 
923
        if(fr->cpu_opts.synth_2to1_real_mono2stereo == NULL) fr->cpu_opts.synth_2to1_real_mono2stereo = synth_2to1_real_mono2stereo;
 
924
        if(fr->cpu_opts.synth_4to1_real == NULL) fr->cpu_opts.synth_4to1_real = synth_4to1_real;
 
925
        if(fr->cpu_opts.synth_4to1_real_mono == NULL) fr->cpu_opts.synth_4to1_real_mono = synth_4to1_real_mono;
 
926
        if(fr->cpu_opts.synth_4to1_real_mono2stereo == NULL) fr->cpu_opts.synth_4to1_real_mono2stereo = synth_4to1_real_mono2stereo;
 
927
#       endif
 
928
#       ifndef NO_NTOM
 
929
        if(fr->cpu_opts.synth_ntom_real == NULL) fr->cpu_opts.synth_ntom_real = synth_ntom_real;
 
930
        if(fr->cpu_opts.synth_ntom_real_mono == NULL) fr->cpu_opts.synth_ntom_real_mono = synth_ntom_real_mono;
 
931
        if(fr->cpu_opts.synth_ntom_real_mono2stereo == NULL) fr->cpu_opts.synth_ntom_real_mono2stereo = synth_ntom_real_mono2stereo;
 
932
#       endif
 
933
#       endif
 
934
 
 
935
#endif /* OPT_MULTI */
 
936
        if(done)
 
937
        {
 
938
                if(VERBOSE) fprintf(stderr, "Decoder: %s\n", chosen);
 
939
                return 1;
 
940
        }
 
941
        else
 
942
        {
 
943
                if(NOQUIET) error("Could not set optimization!");
 
944
                return 0;
 
945
        }
 
946
}
 
947
 
 
948
enum optdec dectype(const char* decoder)
 
949
{
 
950
        enum optdec dt;
 
951
        if(   (decoder == NULL)
 
952
           || (decoder[0] == 0) )
 
953
        return autodec;
 
954
 
 
955
        for(dt=autodec; dt<nodec; ++dt)
 
956
        if(!strcasecmp(decoder, decname[dt])) return dt;
 
957
 
 
958
        return nodec; /* If we found nothing... */
 
959
}
 
960
 
 
961
#ifdef OPT_MULTI
16
962
 
17
963
/* same number of entries as full list, but empty at beginning */
18
 
static char *mpg123_supported_decoder_list[] =
 
964
static const char *mpg123_supported_decoder_list[] =
19
965
{
20
966
        #ifdef OPT_3DNOWEXT
21
967
        NULL,
44
990
        #ifdef OPT_ALTIVEC
45
991
        NULL,
46
992
        #endif
47
 
        NULL, /* generic */
 
993
        #ifdef OPT_GENERIC_FLOAT
 
994
        NULL,
 
995
        #endif
 
996
#       ifdef OPT_GENERIC
 
997
        NULL,
 
998
#       endif
 
999
#       ifdef OPT_GENERIC_DITHER
 
1000
        NULL,
 
1001
#       endif
48
1002
        NULL
49
1003
};
50
1004
#endif
51
1005
 
52
 
static char *mpg123_decoder_list[] =
 
1006
static const char *mpg123_decoder_list[] =
53
1007
{
54
1008
        #ifdef OPT_3DNOWEXT
55
 
        "3DNowExt",
 
1009
        dn_3DNowExt
56
1010
        #endif
57
1011
        #ifdef OPT_SSE
58
 
        "SSE",
 
1012
        dn_SSE,
59
1013
        #endif
60
1014
        #ifdef OPT_3DNOW
61
 
        "3DNow",
 
1015
        dn_3DNow,
62
1016
        #endif
63
1017
        #ifdef OPT_MMX
64
 
        "MMX",
 
1018
        dn_MMX,
65
1019
        #endif
66
1020
        #ifdef OPT_I586
67
 
        "i586",
 
1021
        dn_i586,
68
1022
        #endif
69
1023
        #ifdef OPT_I586_DITHER
70
 
        "i586_dither",
 
1024
        dn_i586_dither,
71
1025
        #endif
72
1026
        #ifdef OPT_I486
73
 
        "i486",
 
1027
        dn_i486,
74
1028
        #endif
75
1029
        #ifdef OPT_I386
76
 
        "i386",
 
1030
        dn_i386,
77
1031
        #endif
78
1032
        #ifdef OPT_ALTIVEC
79
 
        "AltiVec",
 
1033
        dn_AltiVec,
80
1034
        #endif
81
1035
        #ifdef OPT_GENERIC
82
 
        "generic",
 
1036
        dn_generic,
 
1037
        #endif
 
1038
        #ifdef OPT_GENERIC_DITHER
 
1039
        dn_generic_dither,
83
1040
        #endif
84
1041
        NULL
85
1042
};
87
1044
void check_decoders(void )
88
1045
{
89
1046
#ifndef OPT_MULTI
 
1047
        /* In non-multi mode, only the full list (one entry) is used. */
90
1048
        return;
91
1049
#else
92
 
        char **d = mpg123_supported_decoder_list;
 
1050
        const char **d = mpg123_supported_decoder_list;
93
1051
#ifdef OPT_X86
94
1052
        getcpuflags(&cpu_flags);
95
1053
        if(cpu_i586(cpu_flags))
97
1055
                /* not yet: if(cpu_sse2(cpu_flags)) printf(" SSE2");
98
1056
                if(cpu_sse3(cpu_flags)) printf(" SSE3"); */
99
1057
#ifdef OPT_3DNOWEXT
100
 
                if(cpu_3dnowext(cpu_flags)) *(d++) = "3DNowExt";
 
1058
                if(cpu_3dnowext(cpu_flags)) *(d++) = decname[dreidnowext];
101
1059
#endif
102
1060
#ifdef OPT_SSE
103
 
                if(cpu_sse(cpu_flags)) *(d++) = "SSE";
 
1061
                if(cpu_sse(cpu_flags)) *(d++) = decname[sse];
104
1062
#endif
105
1063
#ifdef OPT_3DNOW
106
 
                if(cpu_3dnow(cpu_flags)) *(d++) = "3DNow";
 
1064
                if(cpu_3dnow(cpu_flags)) *(d++) = decname[dreidnow];
107
1065
#endif
108
1066
#ifdef OPT_MMX
109
 
                if(cpu_mmx(cpu_flags)) *(d++) = "MMX";
 
1067
                if(cpu_mmx(cpu_flags)) *(d++) = decname[mmx];
110
1068
#endif
111
1069
#ifdef OPT_I586
112
 
                *(d++) = "i586";
 
1070
                *(d++) = decname[ifuenf];
113
1071
#endif
114
1072
#ifdef OPT_I586_DITHER
115
 
                *(d++) = "i586_dither";
 
1073
                *(d++) = decname[ifuenf_dither];
116
1074
#endif
117
1075
        }
118
1076
#endif
119
1077
/* just assume that the i486 built is run on a i486 cpu... */
120
1078
#ifdef OPT_I486
121
 
        *(d++) = "i486";
 
1079
        *(d++) = decname[ivier];
122
1080
#endif
123
1081
#ifdef OPT_ALTIVEC
124
 
        *(d++) = "AltiVec";
 
1082
        *(d++) = decname[altivec];
125
1083
#endif
126
1084
/* every supported x86 can do i386, any cpu can do generic */
127
1085
#ifdef OPT_I386
128
 
        *(d++) = "i386";
 
1086
        *(d++) = decname[idrei];
129
1087
#endif
130
1088
#ifdef OPT_GENERIC
131
 
        *(d++) = "generic";
 
1089
        *(d++) = decname[generic];
 
1090
#endif
 
1091
#ifdef OPT_GENERIC_DITHER
 
1092
        *(d++) = decname[generic_dither];
132
1093
#endif
133
1094
#endif /* ndef OPT_MULTI */
134
1095
}
135
1096
 
136
 
char attribute_align_arg **mpg123_decoders(){ return mpg123_decoder_list; }
137
 
char attribute_align_arg **mpg123_supported_decoders()
 
1097
const char* attribute_align_arg mpg123_current_decoder(mpg123_handle *mh)
 
1098
{
 
1099
        if(mh == NULL) return NULL;
 
1100
 
 
1101
        return decname[mh->cpu_opts.type];
 
1102
}
 
1103
 
 
1104
const char attribute_align_arg **mpg123_decoders(){ return mpg123_decoder_list; }
 
1105
const char attribute_align_arg **mpg123_supported_decoders()
138
1106
{
139
1107
#ifdef OPT_MULTI
140
1108
        return mpg123_supported_decoder_list;