xref: /plan9/sys/src/games/mp3enc/machine.h (revision 8f5875f3e9b20916b4c52ad4336922bc8653eb7b)
1 /*
2  *	Machine dependent defines/includes for LAME.
3  *
4  *	Copyright (c) 1999 A.L. Faber
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef LAME_MACHINE_H
23 #define LAME_MACHINE_H
24 
25 #include <stdio.h>
26 #include <memory.h>
27 
28 #ifdef STDC_HEADERS
29 # include <stdlib.h>
30 # include <string.h>
31 #else
32 # ifndef HAVE_STRCHR
33 #  define strchr index
34 #  define strrchr rindex
35 # endif
36 char *strchr (), *strrchr ();
37 # ifndef HAVE_MEMCPY
38 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
39 #  define memmove(d, s, n) bcopy ((s), (d), (n))
40 # endif
41 #endif
42 
43 #if  defined(__riscos__)  &&  defined(FPA10)
44 # include "ymath.h"
45 #else
46 # include <math.h>
47 #endif
48 
49 #include <ctype.h>
50 
51 #ifdef HAVE_ERRNO_H
52 # include <errno.h>
53 #endif
54 #ifdef HAVE_FCNTL_H
55 # include <fcntl.h>
56 #endif
57 
58 #if defined(macintosh)
59 # include <types.h>
60 # include <stat.h>
61 #else
62 # include <sys/types.h>
63 # include <sys/stat.h>
64 #endif
65 
66 /*
67  * 3 different types of pow() functions:
68  *   - table lookup
69  *   - pow()
70  *   - exp()   on some machines this is claimed to be faster than pow()
71  */
72 
73 #define POW20(x)  pow20[x]
74 //#define POW20(x)  pow(2.0,((double)(x)-210)*.25)
75 //#define POW20(x)  exp( ((double)(x)-210)*(.25*LOG2) )
76 
77 #define IPOW20(x)  ipow20[x]
78 //#define IPOW20(x)  exp( -((double)(x)-210)*.1875*LOG2 )
79 //#define IPOW20(x)  pow(2.0,-((double)(x)-210)*.1875)
80 
81 
82 /* in case this is used without configure */
83 #ifndef inline
84 # define inline
85 #endif
86 /* compatibility */
87 #define INLINE inline
88 
89 #if defined(_MSC_VER)
90 # undef inline
91 # define inline _inline
92 #elif defined(__SASC) || defined(__GNUC__)
93 /* if __GNUC__ we always want to inline, not only if the user requests it */
94 # undef inline
95 # define inline __inline
96 #endif
97 
98 #if    defined(_MSC_VER)
99 # pragma warning( disable : 4244 )
100 //# pragma warning( disable : 4305 )
101 #endif
102 
103 /*
104  * FLOAT    for variables which require at least 32 bits
105  * FLOAT8   for variables which require at least 64 bits
106  *
107  * On some machines, 64 bit will be faster than 32 bit.  Also, some math
108  * routines require 64 bit float, so setting FLOAT=float will result in a
109  * lot of conversions.
110  */
111 
112 #if ( defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) )
113 # define WIN32_LEAN_AND_MEAN
114 # include <windows.h>
115 #else
116 # ifndef FLOAT
117 typedef float   FLOAT;
118 # endif
119 #endif
120 
121 #ifndef FLOAT8  /* NOTE: RH: 7/00:  if FLOAT8=float, it breaks resampling and VBR code */
122 typedef double  FLOAT8;
123 #endif
124 
125 /* Various integer types */
126 
127 #if   defined _WIN32 && !defined __CYGWIN__
128 typedef unsigned char	u_char;
129 #elif defined __DECALPHA__
130 // do nothing
131 #elif defined OS_AMIGAOS
132 // do nothing
133 #elif defined __DJGPP__
134 typedef unsigned char	u_char;
135 #elif !defined __GNUC__  ||  defined __STRICT_ANSI__
136 typedef unsigned char	u_char;
137 #else
138 // do nothing
139 #endif
140 
141 /* sample_t must be floating point, at least 32 bits */
142 typedef FLOAT     sample_t;
143 typedef sample_t  stereo_t [2];
144 
145 #endif
146 
147 /* end of machine.h */
148