1 #ifndef MPG123_H_OPTIMIZE
2 #define MPG123_H_OPTIMIZE
4 optimize: get a grip on the different optimizations
6 copyright 2007-2013 by the mpg123 project - free software under the terms of the LGPL 2.1
7 see COPYING and AUTHORS files in distribution or http://mpg123.org
8 initially written by Thomas Orgis, taking from mpg123.[hc]
10 for building mpg123 with one optimization only, you have to choose exclusively between
11 OPT_GENERIC (generic C code for everyone)
12 OPT_GENERIC_DITHER (same with dithering for 1to1)
14 OPT_I486 (Somewhat special code for i486; does not work together with others.)
15 OPT_I586 (Intel Pentium)
16 OPT_I586_DITHER (Intel Pentium with dithering/noise shaping for enhanced quality)
17 OPT_MMX (Intel Pentium and compatibles with MMX, fast, but not the best accuracy)
18 OPT_3DNOW (AMD 3DNow!, K6-2/3, Athlon, compatibles...)
20 OPT_3DNOWEXT (AMD 3DNow! extended, generally Athlon, compatibles...)
24 OPT_ALTIVEC (Motorola/IBM PPC with AltiVec under MacOSX)
25 OPT_X86_64 (x86-64 / AMD64 / Intel 64)
28 or you define OPT_MULTI and give a combination which makes sense (do not include i486, do not mix altivec and x86).
30 I still have to examine the dynamics of this here together with REAL_IS_FIXED.
31 Basic point is: Don't use REAL_IS_FIXED with something else than generic or i386.
33 Also, one should minimize code size by really ensuring that only functions that are really needed are included.
34 Currently, all generic functions will be always there (to be safe for fallbacks for advanced decoders).
35 Strictly, at least the synth_1to1 should not be necessary for single-decoder mode.
39 /* Runtime optimization interface now here: */
41 /* Nedit inline Perl script to generate decoder list and name mapping in one place
42 optimize.c defining I_AM_OPTIMIZE to get the names
45 ## order is important (autodec first, nodec last)
49 ,['generic', 'generic']
50 ,['generic_dither', 'generic_dither']
54 ,['ifuenf_dither', 'i586_dither']
56 ,['dreidnow', '3DNow']
57 ,['dreidnowext', '3DNowExt']
58 ,['altivec', 'AltiVec']
64 ,['dreidnow_vintage', '3DNow_vintage']
65 ,['dreidnowext_vintage', '3DNowExt_vintage']
66 ,['sse_vintage', 'SSE_vintage']
70 print "enum optdec\n{\n";
74 $enum = $name eq 'autodec' ? $name = " $name=0" : ",$name";
78 print "##ifdef I_AM_OPTIMIZE\n";
83 print "static const char dn_$key\[\] = \"$val\";\n";
85 print "static const char* decname[] =\n{\n";
89 print "\t".($key eq 'autodec' ? ' ' : ',')."dn_$key\n";
119 static const char dn_autodec[] = "auto";
120 static const char dn_generic[] = "generic";
121 static const char dn_generic_dither[] = "generic_dither";
122 static const char dn_idrei[] = "i386";
123 static const char dn_ivier[] = "i486";
124 static const char dn_ifuenf[] = "i586";
125 static const char dn_ifuenf_dither[] = "i586_dither";
126 static const char dn_mmx[] = "MMX";
127 static const char dn_dreidnow[] = "3DNow";
128 static const char dn_dreidnowext[] = "3DNowExt";
129 static const char dn_altivec[] = "AltiVec";
130 static const char dn_sse[] = "SSE";
131 static const char dn_x86_64[] = "x86-64";
132 static const char dn_arm[] = "ARM";
133 static const char dn_neon[] = "NEON";
134 static const char dn_neon64[] = "NEON64";
135 static const char dn_avx[] = "AVX";
136 static const char dn_dreidnow_vintage[] = "3DNow_vintage";
137 static const char dn_dreidnowext_vintage[] = "3DNowExt_vintage";
138 static const char dn_sse_vintage[] = "SSE_vintage";
139 static const char dn_nodec[] = "nodec";
140 static const char* decname[] =
160 ,dn_dreidnowext_vintage
166 enum optcla { nocla=0, normal, mmxsse };
168 /* - Set up the table of synth functions for current decoder choice. */
169 int frame_cpu_opt(mpg123_handle *fr, const char* cpu);
170 /* - Choose, from the synth table, the synth functions to use for current output format/rate. */
171 int set_synth_functions(mpg123_handle *fr);
172 /* - Parse decoder name and return numerical code. */
173 enum optdec dectype(const char* decoder);
174 /* - Return the default decoder type. */
175 enum optdec defdec(void);
176 /* - Return the class of a decoder type (mmxsse or normal). */
177 enum optcla decclass(const enum optdec);
179 /* Now comes a whole lot of definitions, for multi decoder mode and single decoder mode.
180 Because of the latter, it may look redundant at times. */
182 /* this is included in mpg123.h, which includes config.h */
184 #define ALIGNED(a) __attribute__((aligned(a)))
189 /* Safety catch for invalid decoder choice. */
191 #if (defined OPT_I486) || (defined OPT_I586) || (defined OPT_I586_DITHER) \
192 || (defined OPT_MMX) || (defined OPT_SSE) || (defined_OPT_ALTIVEC) \
193 || (defined OPT_3DNOW) || (defined OPT_3DNOWEXT) || (defined OPT_X86_64) \
194 || (defined OPT_3DNOW_VINTAGE) || (defined OPT_3DNOWEXT_VINTAGE) \
195 || (defined OPT_SSE_VINTAGE) \
196 || (defined OPT_NEON) || (defined OPT_NEON64) || (defined OPT_AVX) \
197 || (defined OPT_GENERIC_DITHER)
198 #error "Bad decoder choice together with fixed point math!"
202 #if (defined NO_LAYER1 && defined NO_LAYER2)
208 # define defopt generic
212 #ifdef OPT_GENERIC_DITHER
215 # define defopt generic_dither
219 /* i486 is special... always alone! */
224 #error "i486 can only work alone!"
226 #define FIR_BUFFER_SIZE 128
233 # define defopt idrei
240 # define defopt ifuenf
244 #ifdef OPT_I586_DITHER
248 # define defopt ifuenf_dither
252 /* We still have some special code around MMX tables. */
268 # define opt_dct36(fr) dct36_sse
272 #ifdef OPT_SSE_VINTAGE
286 # define defopt dreidnowext
290 /* same as above but also using 3DNowExt dct36 */
291 #ifdef OPT_3DNOWEXT_VINTAGE
296 # define defopt dreidnowext_vintage
297 # define opt_dct36(fr) dct36_3dnowext
302 extern const int costab_mmxsse[];
305 /* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
306 /* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */
310 # define defopt dreidnow
314 /* same as above but also using 3DNow dct36 */
315 #ifdef OPT_3DNOW_VINTAGE
318 # define defopt dreidnow_vintage
319 # define opt_dct36(fr) dct36_3dnow
325 # define defopt altivec
332 # define defopt x86_64
333 # define opt_dct36(fr) dct36_x86_64
341 # define opt_dct36(fr) dct36_avx
355 # define opt_dct36(fr) dct36_neon
362 # define defopt neon64
363 # define opt_dct36(fr) dct36_neon64
367 /* used for multi opt mode and the single 3dnow mode to have the old 3dnow test flag still working */
368 void check_decoders(void);
371 Now come two blocks of standard definitions for multi-decoder mode and single-decoder mode.
372 Most stuff is so automatic that it's indeed generated by some inline shell script.
373 Remember to use these scripts when possible, instead of direct repetitive hacking.
378 # define defopt nodec
380 # if (defined OPT_3DNOW_VINTAGE || defined OPT_3DNOWEXT_VINTAGE || defined OPT_SSE || defined OPT_X86_64 || defined OPT_AVX || defined OPT_NEON || defined OPT_NEON64)
381 # define opt_dct36(fr) ((fr)->cpu_opts.the_dct36)
384 #endif /* OPT_MULTI else */
387 # define opt_dct36(fr) dct36
390 #endif /* MPG123_H_OPTIMIZE */