machine.h

Go to the documentation of this file.
00001 /*
00002  *      Machine dependent defines/includes for LAME.
00003  *
00004  *      Copyright (c) 1999 A.L. Faber
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef LAME_MACHINE_H
00023 #define LAME_MACHINE_H
00024 
00025 #include "version.h"
00026 
00027 #if (LAME_RELEASE_VERSION == 0)
00028 #undef NDEBUG
00029 #endif
00030 
00031 #include <stdio.h>
00032 #include <assert.h>
00033 
00034 #ifdef STDC_HEADERS
00035 # include <stdlib.h>
00036 # include <string.h>
00037 #else
00038 # ifndef HAVE_STRCHR
00039 #  define strchr index
00040 #  define strrchr rindex
00041 # endif
00042 char   *strchr(), *strrchr();
00043 # ifndef HAVE_MEMCPY
00044 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
00045 #  define memmove(d, s, n) bcopy ((s), (d), (n))
00046 # endif
00047 #endif
00048 
00049 #if  defined(__riscos__)  &&  defined(FPA10)
00050 # include "ymath.h"
00051 #else
00052 # include <math.h>
00053 #endif
00054 #include <limits.h>
00055 
00056 #include <ctype.h>
00057 
00058 #ifdef HAVE_ERRNO_H
00059 # include <errno.h>
00060 #endif
00061 #ifdef HAVE_FCNTL_H
00062 # include <fcntl.h>
00063 #endif
00064 
00065 #if defined(macintosh)
00066 # include <types.h>
00067 # include <stat.h>
00068 #else
00069 # include <sys/types.h>
00070 # include <sys/stat.h>
00071 #endif
00072 
00073 #ifdef HAVE_INTTYPES_H
00074 # include <inttypes.h>
00075 #else
00076 # ifdef HAVE_STDINT_H
00077 #  include <stdint.h>
00078 # endif
00079 #endif
00080 
00081 #ifdef WITH_DMALLOC
00082 #include <dmalloc.h>
00083 #endif
00084 
00085 /*
00086  * 3 different types of pow() functions:
00087  *   - table lookup
00088  *   - pow()
00089  *   - exp()   on some machines this is claimed to be faster than pow()
00090  */
00091 
00092 #define POW20(x) (assert(0 <= (x+Q_MAX2) && x < Q_MAX), pow20[x+Q_MAX2])
00093 /*#define POW20(x)  pow(2.0,((double)(x)-210)*.25) */
00094 /*#define POW20(x)  exp( ((double)(x)-210)*(.25*LOG2) ) */
00095 
00096 #define IPOW20(x)  (assert(0 <= x && x < Q_MAX), ipow20[x])
00097 /*#define IPOW20(x)  exp( -((double)(x)-210)*.1875*LOG2 ) */
00098 /*#define IPOW20(x)  pow(2.0,-((double)(x)-210)*.1875) */
00099 
00100 /* in case this is used without configure */
00101 #ifndef inline
00102 # define inline
00103 #endif
00104 
00105 #if defined(_MSC_VER)
00106 # undef inline
00107 # define inline _inline
00108 #elif defined(__SASC) || defined(__GNUC__) || defined(__ICC) || defined(__ECC)
00109 /* if __GNUC__ we always want to inline, not only if the user requests it */
00110 # undef inline
00111 # define inline __inline
00112 #endif
00113 
00114 #if    defined(_MSC_VER)
00115 # pragma warning( disable : 4244 )
00116 /*# pragma warning( disable : 4305 ) */
00117 #endif
00118 
00119 /*
00120  * FLOAT    for variables which require at least 32 bits
00121  * FLOAT8   for variables which require at least 64 bits
00122  *
00123  * On some machines, 64 bit will be faster than 32 bit.  Also, some math
00124  * routines require 64 bit float, so setting FLOAT=float will result in a
00125  * lot of conversions.
00126  */
00127 
00128 #if ( defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) )
00129 # define WIN32_LEAN_AND_MEAN
00130 # include <windows.h>
00131 # include <float.h>
00132 # define FLOAT_MAX FLT_MAX
00133 #else
00134 # ifndef FLOAT
00135 typedef float FLOAT;
00136 #  ifdef FLT_MAX
00137 #   define FLOAT_MAX FLT_MAX
00138 #  else
00139 #   define FLOAT_MAX 1e37 /* approx */
00140 #  endif
00141 # endif
00142 #endif
00143 
00144 #ifndef FLOAT8          /* NOTE: RH: 7/00:  if FLOAT8=float, it breaks resampling and VBR code */
00145 typedef double FLOAT8;
00146 # ifdef DBL_MAX
00147 #  define FLOAT8_MAX DBL_MAX
00148 # else
00149 #  define FLOAT8_MAX 1e99 /* approx */
00150 # endif
00151 #else
00152 # ifdef FLT_MAX
00153 #  define FLOAT8_MAX FLT_MAX
00154 # else
00155 #  define FLOAT8_MAX 1e37 /* approx */
00156 # endif
00157 #endif
00158 
00159 /* sample_t must be floating point, at least 32 bits */
00160 typedef FLOAT sample_t;
00161 typedef sample_t stereo_t[2];
00162 
00163 
00164 
00165 #endif
00166 
00167 /* end of machine.h */

Generated on Sun Dec 2 11:34:19 2007 for LAME by  doxygen 1.5.2