macros.h
来自「ESS3890+SL原代码(1*16内存)」· C头文件 代码 · 共 201 行
H
201 行
/* Copyright 1997, ESS Technology, Inc. *//* SCCSID @(#)macros.h 1.2 02/20/02 *//* Based on DVD code version 1.19 10/04/01 */#ifndef __COMMON_MACROS_H#define __COMMON_MACROS_H#include "w_const.h"/* ************************************************************************** *//* Default Fundamental Typedefs *//* ************************************************************************** */typedef unsigned int U32;typedef int I32;typedef unsigned short U16;typedef short I16;typedef unsigned char U8;typedef signed char I8;#define Mul32x32(a,b) \(((((a)>>16)*((b)>>16))<<1)+(((a)&0x8000)? (((b)>>16)<<1):0) + (((b)&0x8000)? (((a)>>16)<<1):0) + ((((a)>>16)*((short)((b)&0xffff)) +((b)>>16)*((short)((a)&0xffff)))>>15))#define PAUSE() { \ current_task = 0; \ DBG_console(); \}#define MULT_HI(a,b) (mul32x32(a,b)<<1)#define MULT_HI_HALF(a,b) (Mul32x32(a,b))typedef struct tagRandState { I32 iPrior; /* prior value */ U32 uiRand; /* current value */} tRandState;#define ENABLE_ALL_ENCOPT/* ************************************************************************** *//* Common Typedefs (not expected to change by platform) *//* ************************************************************************** */#ifndef _WMARESULT_DEFINED#define _WMARESULT_DEFINEDtypedef I32 WMARESULT;/* SUCCESS codes */static const WMARESULT WMA_OK = 0x00000000;static const WMARESULT WMA_S_FALSE = 0x00000001;static const WMARESULT WMA_S_BUFUNDERFLOW = 0x00000002;static const WMARESULT WMA_S_NEWPACKET = 0x00000003;static const WMARESULT WMA_S_NO_MORE_FRAME = 0x00000004;static const WMARESULT WMA_S_DEFAULT = 0x00000005;static const WMARESULT WMA_S_NO_MORE_SRCDATA= 0x00000005;static const WMARESULT WMA_S_SWITCHCHMODE = 0x00000006; /* Internal error, corrected internally *//* ERROR codes */static const WMARESULT WMA_E_FAIL = 0x80004005;static const WMARESULT WMA_E_OUTOFMEMORY = 0x8007000E;static const WMARESULT WMA_E_INVALIDARG = 0x80070057;static const WMARESULT WMA_E_NOTSUPPORTED = 0x80040000;static const WMARESULT WMA_E_LOSTPACKET = 0x80040001;static const WMARESULT WMA_E_BROKEN_FRAME = 0x80040002;static const WMARESULT WMA_E_BUFFEROVERFLOW = 0x80040003;static const WMARESULT WMA_E_ONHOLD = 0x80040004; /*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*. */static const WMARESULT WMA_E_BUFFERUNDERFLOW =0x80040005;static const WMARESULT WMA_E_INVALIDRECHDR = 0x80040006;static const WMARESULT WMA_E_SYNCERROR = 0x80040007;static const WMARESULT WMA_E_NOTIMPL = 0x80040008;static const WMARESULT WMA_E_FLUSHOVERFLOW = 0x80040009; /* Too much input data provided to flush */#define WMARAW_SUCCEEDED(Status) ((WMARESULT)(Status) >= 0)#define WMARAW_FAILED(Status) ((WMARESULT)(Status)<0)#endif /* _WMARESULT_DEFINED */#define WMAB_TRUE 1#define WMAB_FALSE 0#if 0#define NULL -1 #endif#define own /* used as "reserved word" to indicate ownership or transfer to distinguish from const */typedef double Double;typedef float Float;typedef void Void;typedef U32 UInt;typedef I32 Int;typedef I32 Bool; /* In Win32, BOOL is an "int" == 4 bytes. Keep it this way to reduce problems. */ /* Weights, computed from LPC (and Bark?). */typedef struct { Int iFracBits; Int iFraction; } FastFloat;typedef UInt WeightType;typedef FastFloat QuantStepType;typedef Int CoefType;typedef FastFloat QuantFloat;/* ************************************************************************** *//* Overridable Compiler Directives *//* ************************************************************************** *//* 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#define TraceResult(x) (x)#if 1#define CHECKWMA_EXIT(wmaResult) { \ if (WMA_FAILED(wmaResult)) \ { \ goto exit; \ } \}#else#define CHECKWMA_EXIT(wmaResult) assert(wmaResult == WMA_OK)#endif#define DOUBLE(fUpsample,x) (x)#if 1#define TRACEWMA_EXIT(wmaResult,action) { \ (wmaResult) = (action); \ if (WMA_FAILED(wmaResult)) { \ goto exit; \ } else {} \ }#else#define TRACEWMA_EXIT(wmaResult,action) ((wmaResult) = (action))#endif#if 1#define ASSERTWMA_EXIT(wmaResult, action) \ (wmaResult) = (action); \ if (WMA_FAILED(wmaResult)) \ { \ DEBUG_ONLY(DEBUG_BREAK()); /* assert(WMAB_FALSE); */ \ TraceResult(wmaResult); \ goto exit; \ } else {}#else#define ASSERTWMA_EXIT(wmaResult, action) ((wmaResult) = (action))#endif#define TraceError(code)#define MONITOR_RANGE(a,x)#define DEBUG_TRACE_QUANT(a,b,c)/* ************************************************************************** *//* 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. */#if 0#define MULT_HI(a,b) (MULT_HI_DWORD(a,b)<<1)#endif#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 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#define DEBUG_ONLY(x) x#else /* _DEBUG */#define DEBUG_ONLY(x)#endif /* _DEBUG *//* WMARESULT macros (stolen from winerror.h) */#define WMA_SUCCEEDED(Status) ((WMARESULT)(Status) >= 0)#define WMA_FAILED(Status) ((WMARESULT)(Status)<0)#define COEF_ABS(a) (((a)<0) ? -(a) : (a))#define BPX_ABS(a) (((a)<0) ? -(a) : (a))#define INTEGER_ONLY(a) a#endif /* __COMMON_MACROS_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?