Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | 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,
40
	dreidnow, dreidnowext, altivec, sse, x86_64, arm,
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) \
70
 || (defined OPT_3DNOW) || (defined OPT_3DNOWEXT) || (defined OPT_X86_64) || (defined OPT_GENERIC_DITHER)
71
#error "Bad decoder choice together with fixed point math!"
72
#endif
73
#endif
74
 
75
#if (defined NO_LAYER1 && defined NO_LAYER2)
76
#define NO_LAYER12
77
#endif
78
 
79
#ifdef OPT_GENERIC
80
#ifndef OPT_MULTI
81
#	define defopt generic
82
#endif
83
#endif
84
 
85
#ifdef OPT_GENERIC_DITHER
86
#define OPT_DITHER
87
#ifndef OPT_MULTI
88
#	define defopt generic_dither
89
#endif
90
#endif
91
 
92
/* i486 is special... always alone! */
93
#ifdef OPT_I486
94
#define OPT_X86
95
#define defopt ivier
96
#ifdef OPT_MULTI
97
#error "i486 can only work alone!"
98
#endif
99
#define FIR_BUFFER_SIZE  128
100
#define FIR_SIZE 16
101
#endif
102
 
103
#ifdef OPT_I386
104
#define OPT_X86
105
#ifndef OPT_MULTI
106
#	define defopt idrei
107
#endif
108
#endif
109
 
110
#ifdef OPT_I586
111
#define OPT_X86
112
#ifndef OPT_MULTI
113
#	define defopt ifuenf
114
#endif
115
#endif
116
 
117
#ifdef OPT_I586_DITHER
118
#define OPT_X86
119
#define OPT_DITHER
120
#ifndef OPT_MULTI
121
#	define defopt ifuenf_dither
122
#endif
123
#endif
124
 
125
/* We still have some special code around MMX tables. */
126
 
127
#ifdef OPT_MMX
128
#define OPT_MMXORSSE
129
#define OPT_X86
130
#ifndef OPT_MULTI
131
#	define defopt mmx
132
#endif
133
#endif
134
 
135
#ifdef OPT_SSE
136
#define OPT_MMXORSSE
137
#define OPT_MPLAYER
138
#define OPT_X86
139
#ifndef OPT_MULTI
140
#	define defopt sse
141
#endif
142
#endif
143
 
144
#ifdef OPT_3DNOWEXT
145
#define OPT_MMXORSSE
146
#define OPT_MPLAYER
147
#define OPT_X86
148
#ifndef OPT_MULTI
149
#	define defopt dreidnowext
150
#	define opt_dct36(fr) dct36_3dnowext
151
#endif
152
#endif
153
 
154
#ifdef OPT_MPLAYER
155
extern const int costab_mmxsse[];
156
#endif
157
 
158
/* 3dnow used to use synth_1to1_i586 for mono / 8bit conversion - was that intentional? */
159
/* I'm trying to skip the pentium code here ... until I see that that is indeed a bad idea */
160
#ifdef OPT_3DNOW
161
#define OPT_X86
162
#ifndef OPT_MULTI
163
#	define defopt dreidnow
164
#	define opt_dct36(fr) dct36_3dnow
165
#endif
166
#endif
167
 
168
#ifdef OPT_ALTIVEC
169
#ifndef OPT_MULTI
170
#	define defopt altivec
171
#endif
172
#endif
173
 
174
#ifdef OPT_X86_64
175
#define OPT_MMXORSSE
176
#ifndef OPT_MULTI
177
#	define defopt x86_64
178
#endif
179
#endif
180
 
181
#ifdef OPT_ARM
182
#ifndef OPT_MULTI
183
#	define defopt arm
184
#endif
185
#endif
186
 
187
/* used for multi opt mode and the single 3dnow mode to have the old 3dnow test flag still working */
188
void check_decoders(void);
189
 
190
/*
191
	Now come two blocks of standard definitions for multi-decoder mode and single-decoder mode.
192
	Most stuff is so automatic that it's indeed generated by some inline shell script.
193
	Remember to use these scripts when possible, instead of direct repetitive hacking.
194
*/
195
 
196
#ifdef OPT_MULTI
197
 
198
#	define defopt nodec
199
 
200
#	if (defined OPT_3DNOW || defined OPT_3DNOWEXT)
201
#		define opt_dct36(fr) ((fr)->cpu_opts.dct36)
202
#	endif
203
 
204
#endif /* OPT_MULTI else */
205
 
206
#	ifndef opt_dct36
207
#		define opt_dct36(fr) dct36
208
#	endif
209
 
210
#endif /* MPG123_H_OPTIMIZE */
211