ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

mpg123lib_intern.h
Go to the documentation of this file.
00001 /*
00002     mpg123lib_intern: Common non-public stuff for libmpg123
00003 
00004     copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
00005     see COPYING and AUTHORS files in distribution or http://mpg123.org
00006 
00007     derived from the old mpg123.h
00008 */
00009 
00010 #ifndef MPG123_H_INTERN
00011 #define MPG123_H_INTERN
00012 
00013 #define MPG123_RATES 9
00014 #define MPG123_ENCODINGS 10
00015 
00016 #include "config.h" /* Load this before _anything_ */
00017 
00018 /* ABI conformance for other compilers.
00019    mpg123 needs 16byte-aligned stack for SSE and friends.
00020    gcc provides that, but others don't necessarily. */
00021 #ifdef ABI_ALIGN_FUN
00022 #ifndef attribute_align_arg
00023 #if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1)
00024 #    define attribute_align_arg __attribute__((force_align_arg_pointer))
00025 /* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */
00026 #else
00027 
00028 #    define attribute_align_arg
00029 /* Other compilers get code to catch misaligned stack.
00030    Well, except Sun Studio, which accepts the aligned attribute but does not honor it. */
00031 #if !defined(__SUNPRO_C)
00032 #    define NEED_ALIGNCHECK
00033 #endif
00034 
00035 #endif
00036 #endif
00037 #else
00038 #define attribute_align_arg
00039 /* We won't try the align check... */
00040 #endif
00041 
00042 /* export DLL symbols */
00043 #if defined(WIN32) && defined(DYNAMIC_BUILD)
00044 #define BUILD_MPG123_DLL
00045 #endif
00046 #include "compat.h"
00047 #include "mpg123.h"
00048 
00049 #define SKIP_JUNK 1
00050 
00051 #ifndef M_PI
00052 # define M_PI       3.14159265358979323846
00053 #endif
00054 #ifndef M_SQRT2
00055 # define M_SQRT2    1.41421356237309504880
00056 #endif
00057 
00058 #ifdef SUNOS
00059 #define memmove(dst,src,size) bcopy(src,dst,size)
00060 #endif
00061 
00062 /* some stuff has to go back to mpg123.h */
00063 #ifdef REAL_IS_FLOAT
00064 #  define real float
00065 #  define REAL_SCANF "%f"
00066 #  define REAL_PRINTF "%f"
00067 #elif defined(REAL_IS_LONG_DOUBLE)
00068 #  define real long double
00069 #  define REAL_SCANF "%Lf"
00070 #  define REAL_PRINTF "%Lf"
00071 #elif defined(REAL_IS_FIXED)
00072 /* Disable some output formats for fixed point decoder... */
00073 
00074 # define real long
00075 
00076 /*
00077   for fixed-point decoders, use pre-calculated tables to avoid expensive floating-point maths
00078   undef this macro for run-time calculation
00079 */
00080 #define PRECALC_TABLES
00081 
00082 # define REAL_RADIX             24
00083 # define REAL_FACTOR            16777216.0
00084 
00085 static inline long double_to_long_rounded(double x, double scalefac)
00086 {
00087     x *= scalefac;
00088     x += (x > 0) ? 0.5 : -0.5;
00089     return (long)x;
00090 }
00091 
00092 static inline long scale_rounded(long x, int shift)
00093 {
00094     x += (x >> 31);
00095     x >>= (shift - 1);
00096     x += (x & 1);
00097     return (x >> 1);
00098 }
00099 
00100 # ifdef __GNUC__
00101 #  if defined(OPT_I386)
00102 /* for i386_nofpu decoder */
00103 #   define REAL_MUL_ASM(x, y, radix) \
00104 ({ \
00105     long _x=(x), _y=(y); \
00106     __asm__ ( \
00107         "imull %1 \n\t" \
00108         "shrdl %2, %%edx, %0 \n\t" \
00109         : "+&a" (_x) \
00110         : "mr" (_y), "I" (radix) \
00111         : "%edx", "cc" \
00112     ); \
00113     _x; \
00114 })
00115 
00116 #   define REAL_MUL_SCALE_LAYER3_ASM(x, y, radix) \
00117 ({ \
00118     long _x=(x), _y=(y), _radix=(radix); \
00119     __asm__ ( \
00120         "imull %1 \n\t" \
00121         "shrdl %%cl, %%edx, %0 \n\t" \
00122         : "+&a" (_x) \
00123         : "mr" (_y), "c" (_radix) \
00124         : "%edx", "cc" \
00125     ); \
00126     _x; \
00127 })
00128 #  elif defined(OPT_PPC)
00129 /* for powerpc */
00130 #   define REAL_MUL_ASM(x, y, radix) \
00131 ({ \
00132     long _x=(x), _y=(y), _mull, _mulh; \
00133     __asm__ ( \
00134         "mullw %0, %2, %3 \n\t" \
00135         "mulhw %1, %2, %3 \n\t" \
00136         "srwi %0, %0, %4 \n\t" \
00137         "rlwimi %0, %1, %5, 0, %6 \n\t" \
00138         : "=&r" (_mull), "=&r" (_mulh) \
00139         : "%r" (_x), "r" (_y), "i" (radix), "i" (32-(radix)), "i" ((radix)-1) \
00140     ); \
00141     _mull; \
00142 })
00143 
00144 #   define REAL_MUL_SCALE_LAYER3_ASM(x, y, radix) \
00145 ({ \
00146     long _x=(x), _y=(y), _radix=(radix), _mull, _mulh, _radix2; \
00147     __asm__ ( \
00148         "mullw %0, %3, %4 \n\t" \
00149         "mulhw %1, %3, %4 \n\t" \
00150         "subfic %2, %5, 32 \n\t" \
00151         "srw %0, %0, %5 \n\t" \
00152         "slw %1, %1, %2 \n\t" \
00153         "or %0, %0, %1 \n\t" \
00154         : "=&r" (_mull), "=&r" (_mulh), "=&r" (_radix2) \
00155         : "%r" (_x), "r" (_y), "r" (_radix) \
00156         : "cc" \
00157     ); \
00158     _mull; \
00159 })
00160 #  elif defined(OPT_ARM)
00161 /* for arm */
00162 #   define REAL_MUL_ASM(x, y, radix) \
00163 ({ \
00164     long _x=(x), _y=(y), _mull, _mulh; \
00165     __asm__ ( \
00166         "smull %0, %1, %2, %3 \n\t" \
00167         "mov %0, %0, lsr %4 \n\t" \
00168         "orr %0, %0, %1, lsl %5 \n\t" \
00169         : "=&r" (_mull), "=&r" (_mulh) \
00170         : "%r" (_x), "r" (_y), "M" (radix), "M" (32-(radix)) \
00171     ); \
00172     _mull; \
00173 })
00174 
00175 #   define REAL_MUL_SCALE_LAYER3_ASM(x, y, radix) \
00176 ({ \
00177     long _x=(x), _y=(y), _radix=(radix), _mull, _mulh, _radix2; \
00178     __asm__ ( \
00179         "smull %0, %1, %3, %4 \n\t" \
00180         "mov %0, %0, lsr %5 \n\t" \
00181         "rsb %2, %5, #32 \n\t" \
00182         "orr %0, %0, %1, lsl %2 \n\t" \
00183         : "=&r" (_mull), "=&r" (_mulh), "=&r" (_radix2) \
00184         : "%r" (_x), "r" (_y), "r" (_radix) \
00185     ); \
00186     _mull; \
00187 })
00188 #  endif
00189 # endif
00190 
00191 /* I just changed the (int) to (long) there... seemed right. */
00192 # define DOUBLE_TO_REAL(x)                  (double_to_long_rounded(x, REAL_FACTOR))
00193 # define DOUBLE_TO_REAL_15(x)               (double_to_long_rounded(x, 32768.0))
00194 # define DOUBLE_TO_REAL_POW43(x)            (double_to_long_rounded(x, 8192.0))
00195 # define DOUBLE_TO_REAL_SCALE_LAYER12(x)    (double_to_long_rounded(x, 1073741824.0))
00196 # define DOUBLE_TO_REAL_SCALE_LAYER3(x, y)  (double_to_long_rounded(x, pow(2.0,gainpow2_scale[y])))
00197 # define REAL_TO_DOUBLE(x)                  ((double)(x) / REAL_FACTOR)
00198 # ifdef REAL_MUL_ASM
00199 #  define REAL_MUL(x, y)                    REAL_MUL_ASM(x, y, REAL_RADIX)
00200 #  define REAL_MUL_15(x, y)                 REAL_MUL_ASM(x, y, 15)
00201 #  define REAL_MUL_SCALE_LAYER12(x, y)      REAL_MUL_ASM(x, y, 15 + 30 - REAL_RADIX)
00202 # else
00203 #  define REAL_MUL(x, y)                    (((long long)(x) * (long long)(y)) >> REAL_RADIX)
00204 #  define REAL_MUL_15(x, y)                 (((long long)(x) * (long long)(y)) >> 15)
00205 #  define REAL_MUL_SCALE_LAYER12(x, y)      (((long long)(x) * (long long)(y)) >> (15 + 30 - REAL_RADIX))
00206 # endif
00207 # ifdef REAL_MUL_SCALE_LAYER3_ASM
00208 #  define REAL_MUL_SCALE_LAYER3(x, y, z)    REAL_MUL_SCALE_LAYER3_ASM(x, y, 13 + gainpow2_scale[z] - REAL_RADIX)
00209 # else
00210 #  define REAL_MUL_SCALE_LAYER3(x, y, z)    (((long long)(x) * (long long)(y)) >> (13 + gainpow2_scale[z] - REAL_RADIX))
00211 # endif
00212 # define REAL_SCALE_LAYER12(x)              ((long)((x) >> (30 - REAL_RADIX)))
00213 # define REAL_SCALE_LAYER3(x, y)            ((long)((x) >> (gainpow2_scale[y] - REAL_RADIX)))
00214 # ifdef ACCURATE_ROUNDING
00215 #  define REAL_MUL_SYNTH(x, y)              REAL_MUL(x, y)
00216 #  define REAL_SCALE_DCT64(x)               (x)
00217 #  define REAL_SCALE_WINDOW(x)              (x)
00218 # else
00219 #  define REAL_MUL_SYNTH(x, y)              ((x) * (y))
00220 #  define REAL_SCALE_DCT64(x)               ((x) >> 8)
00221 #  define REAL_SCALE_WINDOW(x)              scale_rounded(x, 16)
00222 # endif
00223 #  define REAL_SCANF "%ld"
00224 #  define REAL_PRINTF "%ld"
00225 
00226 #else
00227 #  define real double
00228 #  define REAL_SCANF "%lf"
00229 #  define REAL_PRINTF "%f"
00230 #endif
00231 
00232 #ifndef REAL_IS_FIXED
00233 # if (defined SIZEOF_INT32_T) && (SIZEOF_INT32_T != 4)
00234 #  error "Bad 32bit types!!!"
00235 # endif
00236 #endif
00237 
00238 #ifndef DOUBLE_TO_REAL
00239 # define DOUBLE_TO_REAL(x)                  (real)(x)
00240 #endif
00241 #ifndef DOUBLE_TO_REAL_15
00242 # define DOUBLE_TO_REAL_15(x)               (real)(x)
00243 #endif
00244 #ifndef DOUBLE_TO_REAL_POW43
00245 # define DOUBLE_TO_REAL_POW43(x)            (real)(x)
00246 #endif
00247 #ifndef DOUBLE_TO_REAL_SCALE_LAYER12
00248 # define DOUBLE_TO_REAL_SCALE_LAYER12(x)    (real)(x)
00249 #endif
00250 #ifndef DOUBLE_TO_REAL_SCALE_LAYER3
00251 # define DOUBLE_TO_REAL_SCALE_LAYER3(x, y)  (real)(x)
00252 #endif
00253 #ifndef REAL_TO_DOUBLE
00254 # define REAL_TO_DOUBLE(x)                  (x)
00255 #endif
00256 
00257 #ifndef REAL_MUL
00258 # define REAL_MUL(x, y)                     ((x) * (y))
00259 #endif
00260 #ifndef REAL_MUL_SYNTH
00261 # define REAL_MUL_SYNTH(x, y)               ((x) * (y))
00262 #endif
00263 #ifndef REAL_MUL_15
00264 # define REAL_MUL_15(x, y)                  ((x) * (y))
00265 #endif
00266 #ifndef REAL_MUL_SCALE_LAYER12
00267 # define REAL_MUL_SCALE_LAYER12(x, y)       ((x) * (y))
00268 #endif
00269 #ifndef REAL_MUL_SCALE_LAYER3
00270 # define REAL_MUL_SCALE_LAYER3(x, y, z)     ((x) * (y))
00271 #endif
00272 #ifndef REAL_SCALE_LAYER12
00273 # define REAL_SCALE_LAYER12(x)              (x)
00274 #endif
00275 #ifndef REAL_SCALE_LAYER3
00276 # define REAL_SCALE_LAYER3(x, y)            (x)
00277 #endif
00278 #ifndef REAL_SCALE_DCT64
00279 # define REAL_SCALE_DCT64(x)                (x)
00280 #endif
00281 
00282 /* used to be: AUDIOBUFSIZE = n*64 with n=1,2,3 ...
00283    now: factor on minimum frame buffer size (which takes upsampling into account) */
00284 #define     AUDIOBUFSIZE        2
00285 
00286 #include "true.h"
00287 
00288 #define         MAX_NAME_SIZE           81
00289 #define         SBLIMIT                 32
00290 #define         SCALE_BLOCK             12
00291 #define         SSLIMIT                 18
00292 
00293 /* Same as MPG_M_* */
00294 #define         MPG_MD_STEREO           0
00295 #define         MPG_MD_JOINT_STEREO     1
00296 #define         MPG_MD_DUAL_CHANNEL     2
00297 #define         MPG_MD_MONO             3
00298 
00299 /* We support short or float output samples...
00300    Short integer amplitude is scaled by this. */
00301 #define SHORT_SCALE 32768
00302 /* That scales a short-scaled value to a 32bit integer scaled one
00303    value = 2**31/2**15 */
00304 #define S32_RESCALE 65536
00305 
00306 /* Pre Shift fo 16 to 8 bit converter table */
00307 #define AUSHIFT (3)
00308 
00309 #include "optimize.h"
00310 #include "decode.h"
00311 #include "parse.h"
00312 #include "frame.h"
00313 
00314 /* fr is a mpg123_handle* by convention here... */
00315 #define NOQUIET  (!(fr->p.flags & MPG123_QUIET))
00316 #define VERBOSE  (NOQUIET && fr->p.verbose)
00317 #define VERBOSE2 (NOQUIET && fr->p.verbose > 1)
00318 #define VERBOSE3 (NOQUIET && fr->p.verbose > 2)
00319 #define VERBOSE4 (NOQUIET && fr->p.verbose > 3)
00320 #define PVERB(mp, level) (!((mp)->flags & MPG123_QUIET) && (mp)->verbose >= (level))
00321 
00322 int decode_update(mpg123_handle *mh);
00323 /* residing in format.c  */
00324 off_t samples_to_bytes(mpg123_handle *fr , off_t s);
00325 off_t bytes_to_samples(mpg123_handle *fr , off_t b);
00326 
00327 /* If networking is enabled and we really mean internal networking, the timeout_read function is available. */
00328 #if defined (NETWORK) && !defined (WANT_WIN32_SOCKETS)
00329 /* Does not work with win32 */
00330 #define TIMEOUT_READ
00331 #endif
00332 
00333 #endif

Generated on Sat May 26 2012 04:31:59 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.