History

add decoder cabac support and add UT

dong zhang committed 12 years ago

Commit cf857451 parent c7b505132 files · +2615 −470Browse files

Showing the changes to codec/decoder/core/src/bit_stream.cpp (1 of 32 files). Show all

Unified · Split

codec/decoder/core/src/bit_stream.cpp+13−7
@@ -38,6 +38,7 @@ · 37 unmodified lines
38 *************************************************************************************38 *************************************************************************************
39 */39 */
40#include "bit_stream.h"40#include "bit_stream.h"
41#include "error_code.h"
41 42
42namespace WelsDec {43namespace WelsDec {
43 44
@@ -47,10 +48,14 @@ inline uint32_t GetValue4Bytes (uint8_t* pDstNal) { · 3 unmodified lines
47 return uiValue;48 return uiValue;
48}49}
49 50
50void InitReadBits (PBitStringAux pBitString) {51int32_t InitReadBits (PBitStringAux pBitString, intX_t iEndOffset) {
52 if(pBitString->pCurBuf>=(pBitString->pEndBuf - iEndOffset)) {
53 return ERR_INFO_INVALID_ACCESS;
54 }
51 pBitString->uiCurBits = GetValue4Bytes (pBitString->pCurBuf);55 pBitString->uiCurBits = GetValue4Bytes (pBitString->pCurBuf);
52 pBitString->pCurBuf += 4;56 pBitString->pCurBuf += 4;
53 pBitString->iLeftBits = -16;57 pBitString->iLeftBits = -16;
58 return ERR_NONE;
54}59}
55 60
56/*!61/*!
@@ -60,23 +65,24 @@ void InitReadBits (PBitStringAux pBitString) { · 3 unmodified lines
60 * \param kpBuf bit-stream buffer65 * \param kpBuf bit-stream buffer
61 * \param kiSize size in bits for decoder; size in bytes for encoder66 * \param kiSize size in bits for decoder; size in bytes for encoder
62 *67 *
63 * \return size of buffer data in byte; failed in -1 return68 * \return 0: success, other: fail
64 */69 */
65int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize) {70int32_t InitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32_t kiSize) {
66 const int32_t kiSizeBuf = (kiSize + 7) >> 3;71 const int32_t kiSizeBuf = (kiSize + 7) >> 3;
67 uint8_t* pTmp = (uint8_t*)kpBuf;72 uint8_t* pTmp = (uint8_t*)kpBuf;
68 73
69 if (NULL == pTmp)74 if (NULL == pTmp)
70 return -1;75 return ERR_INFO_INVALID_ACCESS;
71 76
72 pBitString->pStartBuf = pTmp; // buffer to start position77 pBitString->pStartBuf = pTmp; // buffer to start position
73 pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length78 pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length
74 pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex;79 pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex;
75
76 pBitString->pCurBuf = pBitString->pStartBuf;80 pBitString->pCurBuf = pBitString->pStartBuf;
77 InitReadBits (pBitString);81 int32_t iErr = InitReadBits (pBitString, 0);
78 82 if(iErr) {
79 return kiSizeBuf;83 return iErr;
84 }
85 return ERR_NONE;
80}86}
81 87
82} // namespace WelsDec88} // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t