diff --git a/codec/common/macros.h b/codec/common/macros.h index 6666f679..b234d41b 100644 --- a/codec/common/macros.h +++ b/codec/common/macros.h @@ -234,34 +234,6 @@ return r; #define CALC_BI_STRIDE(width,bitcount) ((((width * bitcount) + 31) & ~31) >> 3) -#ifdef WORDS_BIGENDIAN -static inline uint32_t ENDIAN_FIX (uint32_t x) { -return x; -} -#else //!WORDS_BIGENDIAN - -#if defined(_MSC_VER) && defined(_M_IX86) -static inline uint32_t ENDIAN_FIX (uint32_t x) { -__asm { - mov eax, x - bswap eax - mov x, eax -} -return x; -} -#else // GCC -static inline uint32_t ENDIAN_FIX (uint32_t x) { -#ifdef X86_ARCH -__asm__ __volatile__ ("bswap %0":"+r" (x)); -#else -x = ((x & 0xff000000) >> 24) | ((x & 0xff0000) >> 8) | - ((x & 0xff00) << 8) | ((x & 0xff) << 24); -#endif -return x; -} -#endif//GCC - -#endif//!WORDS_BIGENDIAN #ifndef BUTTERFLY1x2 diff --git a/codec/encoder/core/inc/svc_enc_golomb.h b/codec/encoder/core/inc/svc_enc_golomb.h index 1d1fed36..6aaf87b7 100644 --- a/codec/encoder/core/inc/svc_enc_golomb.h +++ b/codec/encoder/core/inc/svc_enc_golomb.h @@ -46,6 +46,12 @@ namespace WelsSVCEnc { +#define WRITE_BE_32(ptr, val) do { \ + (ptr)[0] = (val) >> 24; \ + (ptr)[1] = (val) >> 16; \ + (ptr)[2] = (val) >> 8; \ + (ptr)[3] = (val) >> 0; \ + } while (0) /************************************************************************/ /* GOLOMB CODIMG FOR WELS ENCODER */ /************************************************************************/ @@ -73,7 +79,7 @@ namespace WelsSVCEnc { else {\ (n) -= iLeftBits;\ uiCurBits = (uiCurBits<>(n));\ - *((uint32_t*)pBufPtr) = ENDIAN_FIX(uiCurBits);\ + WRITE_BE_32(pBufPtr, uiCurBits);\ pBufPtr += 4;\ uiCurBits = (v) & ((1<<(n))-1);\ iLeftBits = 32 - (n);\ @@ -141,7 +147,7 @@ if (n < pBs->iLeftBits) { } else { n -= pBs->iLeftBits; pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n); - * ((uint32_t*)pBs->pBufPtr) = ENDIAN_FIX (pBs->uiCurBits); + WRITE_BE_32(pBs->pBufPtr, pBs->uiCurBits); pBs->pBufPtr += 4; pBs->uiCurBits = kuiValue & ((1 << n) - 1); pBs->iLeftBits = 32 - n; @@ -160,7 +166,7 @@ return 0; static inline void BsFlush (SBitStringAux* pBs) { -* (uint32_t*)pBs->pBufPtr = ENDIAN_FIX (pBs->uiCurBits << pBs->iLeftBits); +WRITE_BE_32(pBs->pBufPtr, pBs->uiCurBits << pBs->iLeftBits); pBs->pBufPtr += 4 - pBs->iLeftBits / 8; pBs->iLeftBits = 32; pBs->uiCurBits = 0; // for future writing safe, 5/19/2010