123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #ifndef __BITSTREAM_H__
- #define __BITSTREAM_H__
- class CGioBase;
- class CBitStream
- {
- public:
- CBitStream(int cbSize);
- CBitStream(unsigned char *pBuf, int cbSize, bool fDataValid = false);
- virtual ~CBitStream();
- virtual void Reset();
- bool ByteAligned() const { return !(m_BitNdx & 7); }
- bool ResetOccurred() { return m_ResetOccurred; }
- void SetResetState(bool state) { m_ResetOccurred = state; }
- void Connect(CGioBase *pGB);
- void ResetBitCnt() { m_BitCnt = 0; }
- int GetBitCnt() const { return m_BitCnt; }
- unsigned int GetBits(unsigned int nBits);
- unsigned int GetBits8(unsigned int nBits);
- unsigned int Get1Bit();
- unsigned long Get32Bits();
- bool Ff(int nBits) { return ( (nBits > 0) ? Seek(nBits) : false); }
- bool Rewind(int nBits) { return ( (nBits > 0) ? Seek(-nBits) : false); }
- bool Seek(int nBits)
- {
- m_BitCnt += nBits;
- m_ValidBits -= nBits;
- m_BitNdx = (m_BitNdx+nBits) & m_bitMask;
- return true;
- }
- int GetValidBits() const { return m_ValidBits; }
- int GetFree() const;
- void SetEof();
- int Fill(const unsigned char *pBuf, int cbSize);
- int Fill(CBitStream &Bs, int cbSize);
- protected:
- int Refill();
- bool IsEof() const;
- bool IsConnected() const;
- private:
- CGioBase *m_pGB;
- int m_nBytes;
- int m_mask;
- int m_nBits;
- int m_bitMask;
- int m_ValidBits;
- int m_ReadOffset;
- int m_BitCnt;
- int m_BitNdx;
- bool m_fEof;
- unsigned char *m_Buf;
- bool m_fBufferIntern;
- bool m_ResetOccurred;
- };
- #endif
|