⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macros.h

📁 本程序为ST公司开发的源代码
💻 H
📖 第 1 页 / 共 5 页
字号:
typedef long long I64;#elsetypedef unsigned __int64 U64;typedef __int64 I64;#endif#endif#endif //NOINT64// Default all other typedefs to standard definitions (see below)#endif // Platform-specific #ifdefs// **************************************************************************// Default Fundamental Typedefs// **************************************************************************/* O.K. - defined in wmatypes.h#ifndef PLATFORM_SPECIFIC_I32#ifdef HITACHItypedef unsigned long U32;typedef long I32;#elsetypedef unsigned long int U32;typedef long int I32;#endif#endif#ifndef PLATFORM_SPECIFIC_I16typedef unsigned short U16;typedef short I16;#endif#ifndef PLATFORM_SPECIFIC_I8typedef unsigned char U8;typedef signed char I8;#endif*/#include "wmatypes.h"#include "wmatyps.h"#include "wmaerror.h"// internal SUCCESS codesstatic const WMARESULT WMA_S_SWITCHCHMODE   = 0x00010001; // Internal error, corrected internally// the matrix input to matrixinvert is or close to singular. can not invert or the inversion is not precise.static const WMARESULT WMA_S_SINGULARMATRIX = 0x00010002;static const WMARESULT WMA_S_MODELLING      = 0x00010003; // Modelling, skip full encode stepsstatic const WMARESULT WMA_S_CANTMAKEBITS   = 0x00010004; // Can't make the cMin/cMax bit constraintstatic const WMARESULT WMA_S_DEFAULT        = 0x00010005;static const WMARESULT WMA_S_NOMOREOUTPUT   = 0x00010006;static const WMARESULT WMA_S_PLLM_NOLPC     = 0x00010007; // Did not get reliable LPC filter.static const WMARESULT WMA_S_PLLM_UNSTABLELPC= 0x00010008; // unstable LPC can not be converted to LSP domain.//ON_HOLD: the decoder can't continue operating because of sth, most//       likely no more data for flushing, getbits or peekbits. all functions//       stop *immediately*.// internal error codesstatic const WMARESULT WMA_E_BUFFERUNDERFLOW =  0x80010001;static const WMARESULT WMA_E_INVALIDRECHDR  =   0x80010002;static const WMARESULT WMA_E_SYNCERROR      =   0x80010003;static const WMARESULT WMA_E_NOTIMPL        =   0x80010004;static const WMARESULT WMA_E_FLUSHOVERFLOW  =   0x80010005; // Too much input data provided to flushstatic const WMARESULT WMA_E_CANNOTPREDICT  =   0x80010007; // Cannot make bit-constrained VBR prediction due to insufficient datastatic const WMARESULT WMA_E_COEFSTRMFILE   =   0x80010008; // Failure reading or writing from coefficient stream file.static const WMARESULT WMA_E_FILESTRMFILEIO =   0x80010009; // Error in filestrm.c with File I/O (opening, reading or writing).static const WMARESULT WMA_E_MODELINVALID   =   0x8001000A; // Two-pass VBR model cannot predict using given dependent varstatic const WMARESULT WMA_E_INPUTBUFUNDERFLOW= 0x8001000B; // Two-pass VBR, 2nd pass, not enough input PCM supplied to correlate to outputstatic const WMARESULT WMA_E_FRAMECAPOVERFLOW = 0x8001000C; // v2 onlystatic const WMARESULT WMA_E_NMRPREDICTFAILURE= 0x8001000D; // Two-pass VBR: predictor is unable to generate a meaningful estimate for global NMRstatic const WMARESULT WMA_E_MODELDEVIATION =   0x8001000E; // Two-pass VBR: current results directly conflict with previous model datapoints (eg, same QStep, diff NMR).static const WMARESULT WMA_E_MODELNOROOM =      0x8001000F; // Two-pass VBR: no more room for additional datapoints!/* to wmatypes O.K.#define WMAB_TRUE 1#define WMAB_FALSE 0*/#define own // used as "reserved word" to indicate ownership or transfer to distinguish from const/* O.K. -defined in wmatypes.htypedef double Double;typedef float Float;typedef void Void;typedef U32 UIntW;typedef I32 IntW;typedef I32 Bool; // In Win32, BOOL is an "int" == 4 bytes. Keep it this way to reduce problems.*///***************************************************************************// 24-bit Encoding//***************************************************************************#define PCMSAMPLE_MAX(iValidBits)   ((1 << ((iValidBits) - 1)) - 1)#define PCMSAMPLE_MIN(iValidBits)   (~((1 << ((iValidBits) - 1)) - 1))typedef I32 PCMSAMPLE;#define PCMSAMPLE_BITS  32#define I24_MIN     ((I32)0xFF800000)#define I24_MAX     ((I32)0x007FFFFF)#define I2024_MIN   ((I32)0xFFF80000)#define I2024_MAX   ((I32)0x0007FFFF)#define I25_MIN     ((I32)0xFF000000)#define I25_MAX     ((I32)0x00FFFFFF)#define I2025_MIN   ((I32)0xFFF00000)#define I2025_MAX   ((I32)0x000FFFFF)#define I32_MIN ((I32)0x80000000)// **************************************************************************// Overridable Compiler Directives// **************************************************************************#ifndef PLATFORM_SPECIFIC_INLINE// This should hopefully work for most compilers. It works for VC#ifdef WMA_TARGET_ARM#ifndef INLINE	#ifdef __GNUCOMP_VERSION		#define INLINE inline __attribute__((always_inline)) //O.K. removed from macros.h	#else			//#define INLINE __forceinline  //RVDS armcc		#define INLINE __inline			//ADS armcc	#endif	#endif#else#define INLINE __inline#endif#endif  // PLATFORM_SPECIFIC_INLINE#ifndef PLATFORM_SPECIFIC_COMPILER_MESSAGE#define COMPILER_MESSAGE(x)         message(x)#endif#ifndef PLATFORM_SPECIFIC_COMPILER_PACKALIGN#define COMPILER_PACKALIGN(x)       pack(x)#endif#ifndef PLATFORM_SPECIFIC_COMPILER_PACKALIGN_DEFAULT#define COMPILER_PACKALIGN_DEFAULT  pack()#endif#ifdef _MSC_VER#define MSVC_DISABLE_WARNING(x)     warning(disable:x)#define MSVC_RESTORE_WARNING(x)     warning(default:x)#define MSVC_CDECL                  __cdecl#else   // _MSC_VER// I'm hoping that compilers can take an empty #pragma (VC can)#define MSVC_DISABLE_WARNING(x)#define MSVC_RESTORE_WARNING(x)#define MSVC_CDECL#endif  // _MSC_VER// **************************************************************************// Macros Common to All Platforms// **************************************************************************// If you need to override the following for just one platform, #define a// switch to override as in the case for ROUNDF/ROUNDD above in the// platform-specific #ifdefs so that it is plain to see.#define MULT_HI(a,b) (MULT_HI_DWORD(a,b)<<1)#ifndef BUILD_INTEGER    // these macros are not used by integer decoder.     // Where/when needed, provide cpu depended optimized versions as well as these generic ones.#   define UMASR(a,b,c) (U32)((((U64)a)*((U64)b))>>c)#   define MASR(a,b,c) (I32)((((I64)a)*((I64)b))>>(c))#   define DASR(a,b,c) (I32)((((I64)a)*((I64)b))>>(c))#   define DASL(a,b,c) (I32)((((I64)a)*((I64)b))<<(c))    // The following macro has no perf-enhanced equivalents, although one can    // easily be written a la x86 MULT_HI_DWORD:    // I32HI,LOW = a*b; if (I32LOW & 0x80000000) I32HI += 1; return I32HI;    // NOTE that it only rounds UP, and does not consider negative numbers.#   define MULT_HI_DWORD_ROUND(a,b)    (I32)((((I64)(a))*((I64)(b)) + ((I64)1 << 31))>>32)#endif#define max(a,b) (((a) > (b)) ? (a) : (b))#define min(a, b)  (((a) < (b)) ? (a) : (b))#define checkRange(x, a, b) (((x) < (a)) ? (a) : (((x) > (b)) ? (b) : (x)))#define DELETE_ARRAY(ptr) if (ptr!=NULL) { auFree (ptr); ptr = NULL;}#define DELETE_PTR(ptr) if (ptr!=NULL) {auFree (ptr); ptr = NULL;}#define ARRAY_SIZE(ar) (sizeof(ar)/sizeof((ar)[0]))#  ifdef DEBUG_ONLY// WCE already has this macro defined in the same way, avoid warning messages#  undef DEBUG_ONLY#  endif#ifdef _DEBUG#define DEBUG_ONLY(x)   x#else   // _DEBUG#define DEBUG_ONLY(x)#endif  // _DEBUG#if defined(LITTLE_ENDIAN)#define DEFAULTENDIAN_TO_BIGENDIAN(i)   ByteSwap(i)#define BIGENDIAN_TO_DEFAULTENDIAN(i)   ByteSwap(i)#elif defined(BIG_ENDIAN)#define DEFAULTENDIAN_TO_BIGENDIAN(i)   (i)#define BIGENDIAN_TO_DEFAULTENDIAN(i)   (i)#else#error Must define the endian of the target platform#endif // ENDIAN#define SWAP_WORD( w )      (w) = ((w) << 8) | ((w) >> 8)#define SWAP_DWORD( dw )    (dw) = ((dw) << 24) | ( ((dw) & 0xFF00) << 8 ) | ( ((dw) & 0xFF0000) >> 8 ) | ( ((dw) & 0xFF000000) >> 24);// WMARESULT macros (stolen from winerror.h)#define WMA_SUCCEEDED(Status) ((WMARESULT)(Status) >= 0)#define WMA_FAILED(Status) ((WMARESULT)(Status)<0)// Use 64-bit buffers in integer build to get better match in int vs. intfloat#if defined(BUILD_INTEGER) && defined(BUILD_WMAPRO)#define COEF64BIT#define RECALC_SINCOS#else#undef COEF64BIT#endif// Use integer calculations when calculating inverse channel transform matrix#define FLOAT_INT_CHXFORM#ifdef COEF64BIT//#define HIGHBIT_CH//#define HIGHBIT_IQ#define HIGHBIT_FFT#else#undef HIGHBIT_CH#undef HIGHBIT_IQ#undef HIGHBIT_FFT#endif#if defined(BUILD_INTEGER) // already integer calcs#undef FLOAT_INT_CHXFORM#elif defined(BUILD_INT_FLOAT) // float cannont support 64 bit buffers#undef COEF64BIT#else // assume it is floating build, unless otherwise specified.#undef COEF64BIT//#error "At least one of BUILD_INTEGER or BUILD_INT_FLOAT must be defined."#endif#ifdef COEF64BITtypedef I64 CBT;#elsetypedef IntW CBT;#endif#ifdef COEF64BIT// a is guaranteed to be less than 40 bits.INLINE I64 multHi64(I64 a, I32 b, IntW bits);/*{  if (bits <= 32) {    if (a > 0)      return ((((a & 0xffffffff)*b)>>bits) + (((a>>32)*b)<<(32-bits)));    else {      a = -a;      return -((((a & 0xffffffff)*b)>>bits) + (((a>>32)*b)<<(32-bits)));    }  } else {    if (a > 0)      return ((((a & 0xffffffff)*b)>>bits) + (((a>>32)*b)>>(bits-32)));    else {      a = -a;      return -((((a & 0xffffffff)*b)>>bits) + (((a>>32)*b)>>(bits-32)));    }  }}*/INLINE I64 multHi64B31(I64 a, I32 b);/*{#if 0 // non-branching versions of the above for 30, 31 bits  U64 r;  U64 s = a >> 63;  a = (a^s)-s;  r = ((((a & 0xffffffff)*b)>>31) + (((a>>32)*b)<<1));  return (r^s)-s;#else  if (a > 0)    return ((((a & 0xffffffff)*b)>>31) + (((a>>32)*b)<<1));  else {    a = -a;    return -((((a & 0xffffffff)*b)>>31) + (((a>>32)*b)<<1));  }#endif}*/INLINE I64 multHi64B30(I64 a, I32 b);/*{#if 0  U64 r;  U64 s = a >> 63;  a = (a^s)-s;  r = ((((a & 0xffffffff)*b)>>30) + (((a>>32)*b)<<2));  return (r^s)-s;#else  if (a > 0)    return ((((a & 0xffffffff)*b)>>30) + (((a>>32)*b)<<2));  else {    a = -a;    return -((((a & 0xffffffff)*b)>>30) + (((a>>32)*b)<<2));  }#endif}*/#endifINLINE I32 wmaiiround2toN(const I32 x, const I32 N);/*{  return x >= 0 ? (x+(1<<N>>1)) & ~((1<<N)-1) : (x-1+(1<<N>>1)) & ~((1<<N)-1);}*/// Create types which are change implementation between BUILD_INTEGER and BUILD_INT_FLOAT// Some platforms, like the X86 and the SH4, can implement either build efficently.// Other platforms, with only emulated floating point support, are typically only build with BUILD_INTEGER//  // Each type defined below is either a float (BUILD_INT_FLOAT) and an I32 with some number of fractional bits (BUILD_INTEGER)// Use float or and I32 with five fractional bits// And create a type for trig functions (Float or I32 with 30 fractional bits)#define FLOAT_FROM_FRAC(a, bits) ((a)/((Float)(((I64)1<<(bits)))))#define FRAC_FROM_FLOAT(a, bits) ((I32)((a)*(Float)(((I64)1<<(bits)))))#if 0 // the following loses one bit of precision.#define MULT_HI32_SHIFT(a, scale, bits) \  (MULT_HI_DWORD(a, (scale)<<(31-(bits))) << 1)#else // this maintains full precision#define MULT_HI32_SHIFT(a, b, bits) \  ((I32)(((I64)(a)*(I64)(b))>>bits))#endif#if defined(BUILD_INTEGER)// Coefficents type (output of inverse quantization, transformed by DCT and overlapped/added)// Range is +/- 2^26 with five fractional bits#ifdef COEF64BIT    typedef I64 CoefType;#else    typedef I32 CoefType;#endif#   define COEF_FRAC_BITS TRANSFORM_FRACT_BITS // == 5#   define COEF_FRAC_SCALE (1<<COEF_FRAC_BITS)#   define COEF_FROM_FLOAT(flt) ((CoefType)(flt*COEF_FRAC_SCALE))#   define FLOAT_FROM_COEF(coef) (coef/((Float)COEF_FRAC_SCALE))//#   define COEF_FROM_INT(i) ((i)<<COEF_FRAC_BITS)//#   define INT_FROM_COEF(cf) ((cf)>>COEF_FRAC_BITS)#   define COEF_FROM_INT(i) ((i)<<pau->m_cLeftShiftBitsFixedPre)#   define INT_FROM_COEF(cf) ((cf)>>pau->m_cLeftShiftBitsFixedPost)#   define FRAC_FROM_RATIO(a, b, bits) (DIVI64BYU32((I64)(a)<<(bits), (b)))// Fractional Type with range -2.0 <= x < 2.0 used by FFT Trig Recurrsion     typedef I32 BP2Type;#   define BP2_FRAC_BITS 30#   define BP2_FRAC_SCALE NF2BP2#   define BP2_FROM_FLOAT(flt) ((BP2Type)(flt*BP2_FRAC_SCALE))#   define FLOAT_FROM_BP2(bp2) (bp2/((Float)BP2_FRAC_SCALE))#   define BP2_FROM_BP1(bp1) ((bp1)>>1)#   define MULT_BP2(a,b) MULT_HI_DWORD_DOWN((a),(b))// Fractional type with range -1.0 <= x < 1.0 used by DCT Trig Recurrsion    typedef I32 BP1Type;#   define BP1_FRAC_BITS 31#   define BP1_FRAC_SCALE NF2BP1#   define BP1_FROM_FLOAT(flt) ((BP2Type)(flt*BP1_FRAC_SCALE))#   define FLOAT_FROM_BP1(bp1) (bp1/((Float)BP1_FRAC_SCALE))#   define MULT_BP1(a,b) MULT_HI((a),(b))#   define MAX40BITVAL ((I64)0xfffffffff0)#   define LOG2MAX40BITVAL (39)#   define MAX32BITVAL ((I32)0x7ffffff0)#   define LOG2MAX32BITVAL (30)#ifdef HIGHBIT_FFT#   define MAXINTVAL_FFT MAX40BITVAL#   define MAXINTVAL_FFT_LOG2 (LOG2MAX40BITVAL)  //LOG2_64(MAXINTVAL_FFT)#   define MULT_CBP2(a,b) (multHi64B30((b), (a)))#   define MULT_CBP1(a,b) (multHi64B31((b), (a)))#else#   define MAXINTVAL_FFT MAX32BITVAL#   define MAXINTVAL_FFT_LOG2 (LOG2MAX32BITVAL)  //LOG2(MAXINTVAL_FFT)#   define MULT_CBP2(a,b) MULT_BP2(a,b)#   define MULT_CBP1(a,b) MULT_BP1(a,b)#endif// Channel transform    typedef I32 ChXFormType;#   define CH_FRAC_BITS (30)#ifdef HIGHBIT_CH#   define MAXINTVAL_CH MAX40BITVAL#   define MAXINTVAL_CH_LOG2 (LOG2MAX40BITVAL)   //LOG2_64(MAXINTVAL_CH)#   define MULT_CH(a,b) (multHi64(b, a, CH_FRAC_BITS))#   define MULT_CH_SQRT2(a) (multHi64((a), INT_SQRT2, INT_SQRT2_BITS))#else#   define MAXINTVAL_CH MAX32BITVAL#   define MAXINTVAL_CH_LOG2 (LOG2MAX32BITVAL)   //LOG2(MAXINTVAL_CH)#   define MULT_CH(a,b) MULT_HI32_SHIFT(b, a, CH_FRAC_BITS)#   define MULT_CH_SQRT2(a) MULT_HI32_SHIFT(a, INT_SQRT2, INT_SQRT2_BITS)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -