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