Rev 1905 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1905 | serge | 1 | #ifndef MPG123_H_OPTIMIZE |
2 | #define MPG123_H_OPTIMIZE |
||
3 | /* |
||
4 | optimize: get a grip on the different optimizations |
||
5 | |||
6 | copyright 2007 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] |
||
9 | |||
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) |
||
13 | OPT_I386 (Intel i386) |
||
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...) |
||
19 | OPT_3DNOWEXT (AMD 3DNow! extended, generally Athlon, compatibles...) |
||
20 | OPT_ALTIVEC (Motorola/IBM PPC with AltiVec under MacOSX) |
||
21 | OPT_X86_64 (x86-64 / AMD64 / Intel 64) |
||
22 | |||
23 | or you define OPT_MULTI and give a combination which makes sense (do not include i486, do not mix altivec and x86). |
||
24 | |||
25 | I still have to examine the dynamics of this here together with REAL_IS_FIXED. |
||
26 | Basic point is: Don't use REAL_IS_FIXED with something else than generic or i386. |
||
27 | |||
28 | Also, one should minimize code size by really ensuring that only functions that are really needed are included. |
||
29 | Currently, all generic functions will be always there (to be safe for fallbacks for advanced decoders). |
||
30 | Strictly, at least the synth_1to1 should not be necessary for single-decoder mode. |
||
31 | */ |
||
32 | |||
33 | |||
34 | /* Runtime optimization interface now here: */ |
||
35 | |||
36 | enum optdec |
||
37 | { /* autodec needs to be =0 and the first, nodec needs to be the last -- for loops! */ |
||
38 | autodec=0, generic, generic_dither, idrei, |
||
39 | ivier, ifuenf, ifuenf_dither, mmx, |
||
3960 | Serge | 40 | dreidnow, dreidnowext, altivec, sse, x86_64, arm, neon, |
1905 | serge | 41 | nodec |
42 | }; |
||
43 | enum optcla { nocla=0, normal, mmxsse }; |
||
44 | |||
45 | /* - Set up the table of synth functions for current decoder choice. */ |
||
46 | int frame_cpu_opt(mpg123_handle *fr, const char* cpu); |
||
47 | /* - Choose, from the synth table, the synth functions to use for current output format/rate. */ |
||
48 | int set_synth_functions(mpg123_handle *fr); |
||
49 | /* - Parse decoder name and return numerical code. */ |
||
50 | enum optdec dectype(const char* decoder); |
||
51 | /* - Return the default decoder type. */ |
||
52 | enum optdec defdec(void); |
||
53 | /* - Return the class of a decoder type (mmxsse or normal). */ |
||
54 | enum optcla decclass(const enum optdec); |
||
55 | |||
56 | /* Now comes a whole lot of definitions, for multi decoder mode and single decoder mode. |
||
57 | Because of the latter, it may look redundant at times. */ |
||
58 | |||
59 | /* this is included in mpg123.h, which includes config.h */ |
||
60 | #ifdef CCALIGN |
||
61 | #define ALIGNED(a) __attribute__((aligned(a))) |
||
62 | #else |
||
63 | #define ALIGNED(a) |
||
64 | #endif |
||
65 | |||
66 | /* Safety catch for invalid decoder choice. */ |
||
67 | #ifdef REAL_IS_FIXED |
||
68 | #if (defined OPT_I486) || (defined OPT_I586) || (defined OPT_I586_DITHER) \ |
||
69 | || (defined OPT_MMX) || (defined OPT_SSE) || (defined_OPT_ALTIVEC) \ |
||
3960 | Serge | 70 | || (defined OPT_3DNOW) || (defined OPT_3DNOWEXT) || (defined OPT_X86_64) \ |
71 | || (defined OPT_NEON) || (defined OPT_GENERIC_DITHER) |
||
1905 | serge | 72 | #error "Bad decoder choice together with fixed point math!" |
73 | #endif |
||
74 | #endif |
||
75 | |||
76 | #if (defined NO_LAYER1 && defined NO_LAYER2) |
||
77 | #define NO_LAYER12 |
||
78 | #endif |
||
79 | |||
80 | #ifdef OPT_GENERIC |
||
81 | #ifndef OPT_MULTI |
||
82 | # define defopt generic |
||
83 | #endif |
||
84 | #endif |
||
85 | |||
86 | #ifdef OPT_GENERIC_DITHER |
||
87 | #define OPT_DITHER |
||
88 | #ifndef OPT_MULTI |
||
89 | # define defopt generic_dither |
||
90 | #endif |
||
91 | #endif |
||
92 | |||
93 | /* i486 is special... always alone! */ |
||
94 | #ifdef OPT_I486 |
||
95 | #define OPT_X86 |
||
96 | #define defopt ivier |
||
97 | #ifdef OPT_MULTI |
||
98 | #error "i486 can only work alone!" |
||
99 | #endif |
||
100 | #define FIR_BUFFER_SIZE 128 |
||
101 | #define FIR_SIZE 16 |
||
102 | #endif |
||
103 | |||
104 | #ifdef OPT_I386 |
||
105 | #define OPT_X86 |
||
106 | #ifndef OPT_MULTI |
||
107 | # define defopt idrei |
||
108 | #endif |
||
109 | #endif |
||
110 | |||
111 | #ifdef OPT_I586 |
||
112 | #define OPT_X86 |
||
113 | #ifndef OPT_MULTI |
||
114 | # define defopt ifuenf |
||
115 | #endif |
||
116 | #endif |
||
117 | |||
118 | #ifdef OPT_I586_DITHER |
||
119 | #define OPT_X86 |
||
120 | #define OPT_DITHER |
||
121 | #ifndef OPT_MULTI |
||
122 | # define defopt ifuenf_dither |
||
123 | #endif |
||
124 | #endif |
||
125 | |||
126 | /* We still have some special code around MMX tables. */ |
||
127 | |||
128 | #ifdef OPT_MMX |
||
129 | #define OPT_MMXORSSE |
||
130 | #define OPT_X86 |
||
131 | #ifndef OPT_MULTI |
||
132 | # define defopt mmx |
||
133 | #endif |
||
134 | #endif |
||
135 | |||
136 | #ifdef OPT_SSE |
||
137 | #define OPT_MMXORSSE |
||
138 | #define OPT_MPLAYER |
||
139 | #define OPT_X86 |
||
140 | #ifndef OPT_MULTI |
||
141 | # define defopt sse |
||
142 | #endif |
||
143 | #endif |
||
144 | |||
145 | #ifdef OPT_3DNOWEXT |
||
146 | #define OPT_MMXORSSE |
||
147 | #define OPT_MPLAYER |
||
148 | #define OPT_X86 |
||
149 | #ifndef OPT_MULTI |
||
150 | # define defopt dreidnowext |
||
151 | # define opt_dct36(fr) dct36_3dnowext |
||
152 | #endif |
||
153 | #endif |
||
154 | |||
155 | #ifdef OPT_MPLAYER |
||
156 | extern const int costab_mmxsse[]; |
||
157 | #endif |
||
158 | |||
159 | /* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */ |
||
160 | /* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */ |
||
161 | #ifdef OPT_3DNOW |
||
162 | #define OPT_X86 |
||
163 | #ifndef OPT_MULTI |
||
164 | # define defopt dreidnow |
||
165 | # define opt_dct36(fr) dct36_3dnow |
||
166 | #endif |
||
167 | #endif |
||
168 | |||
169 | #ifdef OPT_ALTIVEC |
||
170 | #ifndef OPT_MULTI |
||
171 | # define defopt altivec |
||
172 | #endif |
||
173 | #endif |
||
174 | |||
175 | #ifdef OPT_X86_64 |
||
176 | #define OPT_MMXORSSE |
||
177 | #ifndef OPT_MULTI |
||
178 | # define defopt x86_64 |
||
179 | #endif |
||
180 | #endif |
||
181 | |||
182 | #ifdef OPT_ARM |
||
183 | #ifndef OPT_MULTI |
||
184 | # define defopt arm |
||
185 | #endif |
||
186 | #endif |
||
187 | |||
3960 | Serge | 188 | #ifdef OPT_NEON |
189 | #define OPT_MMXORSSE |
||
190 | #ifndef OPT_MULTI |
||
191 | # define defopt neon |
||
192 | #endif |
||
193 | #endif |
||
194 | |||
1905 | serge | 195 | /* used for multi opt mode and the single 3dnow mode to have the old 3dnow test flag still working */ |
196 | void check_decoders(void); |
||
197 | |||
198 | /* |
||
199 | Now come two blocks of standard definitions for multi-decoder mode and single-decoder mode. |
||
200 | Most stuff is so automatic that it's indeed generated by some inline shell script. |
||
201 | Remember to use these scripts when possible, instead of direct repetitive hacking. |
||
202 | */ |
||
203 | |||
204 | #ifdef OPT_MULTI |
||
205 | |||
206 | # define defopt nodec |
||
207 | |||
208 | # if (defined OPT_3DNOW || defined OPT_3DNOWEXT) |
||
3960 | Serge | 209 | # define opt_dct36(fr) ((fr)->cpu_opts.the_dct36) |
1905 | serge | 210 | # endif |
211 | |||
212 | #endif /* OPT_MULTI else */ |
||
213 | |||
214 | # ifndef opt_dct36 |
||
215 | # define opt_dct36(fr) dct36 |
||
216 | # endif |
||
217 | |||
218 | #endif /* MPG123_H_OPTIMIZE */ |
||
219 |