shithub: openh264

Download patch

ref: d9cbe19110cad66f2654a4aed2f387e89b2f6afd
parent: 5616ddb3a57a6cd04da6ecf6d3288eef3254666f
parent: 60e0255677ec25ecf5557ebf3f3b110c0fd89ec0
author: Ethan Hugg <ethanhugg@gmail.com>
date: Mon Jan 27 08:07:38 EST 2014

Merge pull request #240 from mstorsjo/simplify-inline-asm

Unify the fallback codepath for getting prefix bits into a macro

--- a/codec/decoder/core/inc/vlc_decoder.h
+++ b/codec/decoder/core/inc/vlc_decoder.h
@@ -102,15 +102,18 @@
 extern const uint8_t g_kuiZeroLeftTable6[8][2];
 extern const uint8_t g_kuiZeroLeftBitNumMap[16];
 
-#ifdef WIN32
+#if defined(_MSC_VER) && defined(_M_IX86)
 //TODO need linux version
 #define WELS_GET_PREFIX_BITS(inval,outval){\
+	uint32_t local = inval;\
 	__asm xor		eax,	eax\
-	__asm bsr		eax,	inval\
+	__asm bsr		eax,	local\
 	__asm sub		eax,	32\
 	__asm neg		eax\
 	__asm mov		outval,	eax\
 }
+#else
+#define WELS_GET_PREFIX_BITS(inval, outval) outval = GetPrefixBits(inval)
 #endif
 
 static inline void_t InitVlcTable (SVlcTable* pVlcTable) {
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -537,7 +537,6 @@
                                  uint8_t uiTrailingOnes) {
   int32_t i, iUsedBits = 0;
   int32_t iSuffixLength, iSuffixLengthSize, iLevelPrefix, iPrefixBits, iLevelCode, iThreshold;
-  uint32_t uiCache32Bit;
   for (i = 0; i < uiTrailingOnes; i++) {
     iLevel[i] = 1 - ((pBitsCache->uiCache32Bit >> (30 - i)) & 0x02);
   }
@@ -548,12 +547,7 @@
 
   for (; i < uiTotalCoeff; i++) {
     if (pBitsCache->uiRemainBits <= 16)		SHIFT_BUFFER (pBitsCache);
-#if defined(_MSC_VER) && defined(_M_IX86)
-    uiCache32Bit = pBitsCache->uiCache32Bit;
-    WELS_GET_PREFIX_BITS (uiCache32Bit, iPrefixBits);
-#else
-    iPrefixBits = GetPrefixBits (pBitsCache->uiCache32Bit);
-#endif
+    WELS_GET_PREFIX_BITS (pBitsCache->uiCache32Bit, iPrefixBits);
     POP_BUFFER (pBitsCache, iPrefixBits);
     iUsedBits   += iPrefixBits;
     iLevelPrefix = iPrefixBits - 1;