Showing the changes to codec/decoder/core/src/bit_stream.cpp (1 of 225 files). Show all
Unified · Split
| @@ -43,53 +43,47 @@ · 42 unmodified lines | ||
| 43 | 43 | namespace WelsDec { |
| 44 | 44 | |
| 45 | 45 | #ifdef WORDS_BIGENDIAN |
| 46 | −inline uint32_t EndianFix(uint32_t uiX) | |
| 47 | −{ | |
| 48 | − return uiX; | |
| 46 | +inline uint32_t EndianFix (uint32_t uiX) { | |
| 47 | + return uiX; | |
| 49 | 48 | } |
| 50 | 49 | #else //WORDS_BIGENDIAN |
| 51 | 50 | |
| 52 | 51 | #ifdef _MSC_VER |
| 53 | −inline uint32_t EndianFix(uint32_t uiX) | |
| 54 | −{ | |
| 55 | − __asm | |
| 56 | − { | |
| 57 | − mov eax, uiX | |
| 58 | − bswap eax | |
| 59 | − mov uiX, eax | |
| 60 | − } | |
| 61 | − return uiX; | |
| 52 | +inline uint32_t EndianFix (uint32_t uiX) { | |
| 53 | + __asm { | |
| 54 | + mov eax, uiX | |
| 55 | + bswap eax | |
| 56 | + mov uiX, eax | |
| 57 | + } | |
| 58 | + return uiX; | |
| 62 | 59 | } |
| 63 | 60 | #else //_MSC_VER |
| 64 | 61 | |
| 65 | −inline uint32_t EndianFix(uint32_t uiX) | |
| 66 | −{ | |
| 62 | +inline uint32_t EndianFix (uint32_t uiX) { | |
| 67 | 63 | #ifdef ARM_ARCHv7 |
| 68 | − __asm__ __volatile__("rev %0, %0":"+r"(uiX)); //Just for the ARMv7 | |
| 64 | + __asm__ __volatile__ ("rev %0, %0":"+r" (uiX)); //Just for the ARMv7 | |
| 69 | 65 | #elif defined (X86_ARCH) |
| 70 | − __asm__ __volatile__("bswap %0":"+r"(uiX)); | |
| 66 | + __asm__ __volatile__ ("bswap %0":"+r" (uiX)); | |
| 71 | 67 | #else |
| 72 | − uiX = ((uiX & 0xff000000)>> 24) | ((uiX & 0xff0000) >> 8) | | |
| 73 | − ((uiX & 0xff00) << 8) | ((uiX&0xff) << 24); | |
| 74 | −#endif | |
| 75 | − return uiX; | |
| 68 | + uiX = ((uiX & 0xff000000) >> 24) | ((uiX & 0xff0000) >> 8) | | |
| 69 | + ((uiX & 0xff00) << 8) | ((uiX & 0xff) << 24); | |
| 70 | +#endif | |
| 71 | + return uiX; | |
| 76 | 72 | } |
| 77 | 73 | #endif //_MSC_VER |
| 78 | 74 | |
| 79 | 75 | #endif //WORDS_BIGENDIAN |
| 80 | 76 | |
| 81 | −inline uint32_t GetValue4Bytes( uint8_t* pDstNal ) | |
| 82 | −{ | |
| 83 | − uint32_t uiValue = 0; | |
| 84 | − uiValue = (pDstNal[0]<<24) | (pDstNal[1]<<16) | (pDstNal[2]<<8) | (pDstNal[3]); | |
| 85 | − return uiValue; | |
| 77 | +inline uint32_t GetValue4Bytes (uint8_t* pDstNal) { | |
| 78 | + uint32_t uiValue = 0; | |
| 79 | + uiValue = (pDstNal[0] << 24) | (pDstNal[1] << 16) | (pDstNal[2] << 8) | (pDstNal[3]); | |
| 80 | + return uiValue; | |
| 86 | 81 | } |
| 87 | 82 | |
| 88 | −void_t InitReadBits( PBitStringAux pBitString ) | |
| 89 | −{ | |
| 90 | − pBitString->uiCurBits = GetValue4Bytes( pBitString->pCurBuf ); | |
| 91 | − pBitString->pCurBuf += 4; | |
| 92 | − pBitString->iLeftBits = -16; | |
| 83 | +void_t InitReadBits (PBitStringAux pBitString) { | |
| 84 | + pBitString->uiCurBits = GetValue4Bytes (pBitString->pCurBuf); | |
| 85 | + pBitString->pCurBuf += 4; | |
| 86 | + pBitString->iLeftBits = -16; | |
| 93 | 87 | } |
| 94 | 88 | |
| 95 | 89 | /*! |
| @@ -101,22 +95,21 @@ void_t InitReadBits( PBitStringAux pBitString ) · 5 unmodified lines | ||
| 101 | 95 | * |
| 102 | 96 | * \return size of buffer data in byte; failed in -1 return |
| 103 | 97 | */ |
| 104 | −int32_t InitBits( PBitStringAux pBitString, const uint8_t *kpBuf, const int32_t kiSize ) | |
| 105 | −{ | |
| 106 | − const int32_t kiSizeBuf = (kiSize + 7) >> 3; | |
| 107 | − uint8_t *pTmp = (uint8_t *)kpBuf; | |
| 98 | +int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize) { | |
| 99 | + const int32_t kiSizeBuf = (kiSize + 7) >> 3; | |
| 100 | + uint8_t* pTmp = (uint8_t*)kpBuf; | |
| 108 | 101 | |
| 109 | − if ( NULL == pTmp ) | |
| 110 | − return -1; | |
| 102 | + if (NULL == pTmp) | |
| 103 | + return -1; | |
| 111 | 104 | |
| 112 | − pBitString->pStartBuf = pTmp; // buffer to start position | |
| 113 | − pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length | |
| 114 | − pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex; | |
| 105 | + pBitString->pStartBuf = pTmp; // buffer to start position | |
| 106 | + pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length | |
| 107 | + pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex; | |
| 115 | 108 | |
| 116 | − pBitString->pCurBuf = pBitString->pStartBuf; | |
| 117 | − InitReadBits( pBitString ); | |
| 109 | + pBitString->pCurBuf = pBitString->pStartBuf; | |
| 110 | + InitReadBits (pBitString); | |
| 118 | 111 | |
| 119 | − return kiSizeBuf; | |
| 112 | + return kiSizeBuf; | |
| 120 | 113 | } |
| 121 | 114 | |
| 122 | 115 | } // namespace WelsDec |