ref: 8420fd34546e541abcb5b755cee816dc4e6e4374
parent: a1c491499f8816f89a80b9af0a42eced0d3c0e27
parent: 89f2c8bf7cd5c7396b4b2f1dab315c36243c4941
author: volvet <[email protected]>
date: Fri Jan 24 20:05:27 EST 2014
Merge pull request #210 from mstorsjo/cleanup-macros Cleanup the common/macros.h header
--- a/codec/common/macros.h
+++ b/codec/common/macros.h
@@ -65,7 +65,6 @@
_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
-///////////// from encoder
#if defined(_MSC_VER)
#if(_MSC_VER < 1700)
@@ -72,72 +71,30 @@
#define inline __inline
#endif
-#define __FASTCALL __fastcall
#define ALIGNED_DECLARE( type, var, n ) __declspec(align(n)) type var
-#define __align8(t,v) __declspec(align(8)) t v
#define __align16(t,v) __declspec(align(16)) t v
-#elif defined(__GNUC__)
-#if !defined(MAC_POWERPC)
-#define __FASTCALL __attribute__ ((fastcall))
-#else
-#define __FASTCALL // mean NULL for mac ppc
-#endif//MAC_POWERPC
-#define ALIGNED_DECLARE( type, var, n ) type var __attribute__((aligned(n)))
-#define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
-#endif//_MSC_VER
-
-#if defined(_MACH_PLATFORM) || defined(__GNUC__)
+#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
+ __declspec(align(alignment)) type name[(size)]
#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
- type name[(sizex)*(sizey)] __attribute__((aligned(alignment)))
-#else //_MSC_VER <= 1200
-#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
__declspec(align(alignment)) type name[(sizex)*(sizey)]
-#endif//#if _MACH_PLATFORM
-#if defined(_MACH_PLATFORM) || defined(__GNUC__)
-#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
- type name[size] __attribute__((aligned(alignment)))
-#else //_MSC_VER <= 1200
-#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
- __declspec(align(alignment)) type name[(size)]
-#endif//#if _MACH_PLATFORM
-
-#if defined(_MSC_VER)
-#if _MSC_VER < 1700
-#define inline __inline
-#endif
-#define __FASTCALL __fastcall
-// #define __align8(t,v) __declspec(align(8)) t v
-#define __align16(t,v) __declspec(align(16)) t v
#elif defined(__GNUC__)
-#if !defined(MAC_POWERPC) && !defined(UNIX) && !defined(ANDROID_NDK) && !defined(APPLE_IOS)
-#define __FASTCALL __attribute__ ((fastcall))// linux, centos, mac_x86 can be used
-#else
-#define __FASTCALL // mean NULL for mac_ppc, solaris(sparc/x86)
-#endif//MAC_POWERPC
-// #define __align8(t,v) t v __attribute__ ((aligned (8)))
-#define __align16(t,v) t v __attribute__ ((aligned (16)))
-#if defined(APPLE_IOS)
-#define inline //For iOS platform
-#endif
-
+#define ALIGNED_DECLARE( type, var, n ) type var __attribute__((aligned(n)))
+#define __align16(t,v) t v __attribute__ ((aligned (16)))
+#define ALIGNED_DECLARE_MATRIX_1D(name,size,type,alignment) \
+ type name[size] __attribute__((aligned(alignment)))
+#define ALIGNED_DECLARE_MATRIX_2D(name,sizex,sizey,type,alignment) \
+ type name[(sizex)*(sizey)] __attribute__((aligned(alignment)))
#endif//_MSC_VER
-#if !defined(SIZEOFRGB24)
-#define SIZEOFRGB24(cx, cy) (3 * (cx) * (cy))
-#endif//SIZEOFRGB24
-
-#if !defined(SIZEOFRGB32)
-#define SIZEOFRGB32(cx, cy) (4 * (cx) * (cy))
-#endif//SIZEOFRGB32
-#if 1
#ifndef WELS_ALIGN
#define WELS_ALIGN(x, n) (((x)+(n)-1)&~((n)-1))
#endif//WELS_ALIGN
+
+#if 1 // Alternative implementation of WELS_MAX and WELS_MIN
#ifndef WELS_MAX
#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y))
#endif//WELS_MAX
@@ -145,12 +102,7 @@
#ifndef WELS_MIN
#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y))
#endif//WELS_MIN
-#else
-
-#ifndef WELS_ALIGN
-#define WELS_ALIGN(x, n) (((x)+(n)-1)&~((n)-1))
-#endif//WELS_ALIGN
-
+#else // Alternative implementation of WELS_MAX and WELS_MIN
#ifndef WELS_MAX
#define WELS_MAX(x, y) ((x) - (((x)-(y))&(((x)-(y))>>31)))
#endif//WELS_MAX
@@ -158,8 +110,8 @@
#ifndef WELS_MIN
#define WELS_MIN(x, y) ((y) + (((x)-(y))&(((x)-(y))>>31)))
#endif//WELS_MIN
+#endif // Alternative implementation of WELS_MAX and WELS_MIN
-#endif
#ifndef WELS_CEIL
#define WELS_CEIL(x) ceil(x) // FIXME: low complexity instead of math library used
@@ -269,70 +221,6 @@
}
#endif//#if WELS_VERIFY_RETURN_PROC_IF
-/*
- * Description: to check variable validation and return
- * case_if: negtive condition to be verified
- * return: NONE
- */
-#ifndef WELS_VERIFY_IF
-#define WELS_VERIFY_IF(bCaseIf) \
- if ( bCaseIf ){ \
- return; \
- }
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description: to check variable validation and return with correspoinding process advance.
- * case_if: negtive condition to be verified
- * proc: process need preform
- * return: NONE
- */
-#ifndef WELS_VERIFY_PROC_IF
-#define WELS_VERIFY_PROC_IF(bCaseIf, fProc) \
- if ( bCaseIf ){ \
- fProc; \
- return; \
- }
-#endif//#if WELS_VERIFY_IF
-
-/*
- * Description: to safe free a ptr with free function pointer
- * p: pointer to be destroyed
- * free_fn: free function pointer used
- */
-#ifndef WELS_SAFE_FREE_P
-#define WELS_SAFE_FREE_P(pPtr, fFreeFunc) \
- do{ \
- if ( NULL != (pPtr) ){ \
- fFreeFunc( (pPtr) ); \
- (pPtr) = NULL; \
- } \
- }while( 0 );
-#endif//#if WELS_SAFE_FREE_P
-
-/*
- * Description: to safe free an array ptr with free function pointer
- * arr: pointer to an array, something like "**p";
- * num: number of elements in array
- * free_fn: free function pointer
- */
-#ifndef WELS_SAFE_FREE_ARR
-#define WELS_SAFE_FREE_ARR(pArray, iNum, fFreeFunc) \
- do{ \
- if ( NULL != (pArray) ){ \
- int32_t iIdx = 0; \
- while( iIdx < iNum ){ \
- if ( NULL != (pArray)[iIdx] ){ \
- fFreeFunc( (pArray)[iIdx] ); \
- (pArray)[iIdx] = NULL; \
- } \
- ++ iIdx; \
- } \
- fFreeFunc((pArray)); \
- (pArray) = NULL; \
- } \
- }while( 0 );
-#endif//#if WELS_SAFE_FREE_ARR
static inline int32_t WELS_LOG2 (uint32_t v) {
int32_t r = 0;
while (v >>= 1) {
@@ -344,15 +232,14 @@
#define CLIP3_QP_0_51(q) WELS_CLIP3(q, 0, 51) // ((q) < (0) ? (0) : ((q) > (51) ? (51) : (q)))
#define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3)
-#ifdef WORDS_BIGENDIAN
+
+#ifdef WORDS_BIGENDIAN
static inline uint32_t ENDIAN_FIX (uint32_t x) {
return x;
}
+#else //!WORDS_BIGENDIAN
-#else
-
-
#if defined(_MSC_VER) && defined(_M_IX86)
static inline uint32_t ENDIAN_FIX (uint32_t x) {
__asm {
@@ -372,11 +259,11 @@
#endif
return x;
}
+#endif//GCC
+#endif//!WORDS_BIGENDIAN
-#endif
-#endif
#ifndef BUTTERFLY1x2
#define BUTTERFLY1x2(b) (((b)<<8) | (b))
#endif//BUTTERFLY1x2
@@ -389,14 +276,6 @@
#define BUTTERFLY4x8(dw) (((uint64_t)(dw)<<32) | (dw))
#endif//BUTTERFLY4x8
-static inline int32_t WELS_MEDIAN (int32_t x, int32_t y, int32_t z) {
-int32_t t = (x - y) & ((x - y) >> 31);
-x -= t;
-y += t;
-y -= (y - z) & ((y - z) >> 31);
-y += (x - y) & ((x - y) >> 31);
-return y;
-}
static inline BOOL_T WELS_POWER2_IF (uint32_t v) {
return (v && ! (v & (v - 1)));
}
--- a/codec/decoder/core/src/deblocking.cpp
+++ b/codec/decoder/core/src/deblocking.cpp
@@ -473,7 +473,7 @@
}
}
-void_t /*__FASTCALL*/ FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
+void_t FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
int32_t iMbX = pCurDqLayer->iMbX;
int32_t iMbY = pCurDqLayer->iMbY;
@@ -521,7 +521,7 @@
pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
}
}
-void_t /*__FASTCALL*/ FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
+void_t FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
int32_t iMbX = pCurDqLayer->iMbX;
int32_t iMbY = pCurDqLayer->iMbY;
--- a/codec/encoder/core/src/md.cpp
+++ b/codec/encoder/core/src/md.cpp
@@ -873,7 +873,7 @@
*pSadPred = iSadC;
break;
default:
- *pSadPred = WELS_MEDIAN (kiSadA, kiSadB, iSadC);
+ *pSadPred = WelsMedian (kiSadA, kiSadB, iSadC);
break;
}
}
@@ -920,7 +920,7 @@
*iSadPredSkip = iSadC;
break;
default:
- *iSadPredSkip = WELS_MEDIAN (kiSadA, kiSadB, iSadC);
+ *iSadPredSkip = WelsMedian (kiSadA, kiSadB, iSadC);
break;
}
}
--- a/codec/encoder/core/src/mv_pred.cpp
+++ b/codec/encoder/core/src/mv_pred.cpp
@@ -83,8 +83,8 @@
*sMvp = sMvC;
break;
default:
- sMvp->iMvX = WELS_MEDIAN (sMvA.iMvX, sMvB.iMvX, sMvC.iMvX);
- sMvp->iMvY = WELS_MEDIAN (sMvA.iMvY, sMvB.iMvY, sMvC.iMvY);
+ sMvp->iMvX = WelsMedian (sMvA.iMvX, sMvB.iMvX, sMvC.iMvX);
+ sMvp->iMvY = WelsMedian (sMvA.iMvY, sMvB.iMvY, sMvC.iMvY);
break;
}
}