home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- BitStreamStruct.h
-
- 03/02/08 Xiaohong
- *************************************************************************/
- #ifndef _INCLUDE_BIT_STREAM_STRUCT_H_____________________________
- #define _INCLUDE_BIT_STREAM_STRUCT_H_____________________________
-
- #include <windows.h>
-
- typedef enum
- {
- BSSR_OK = 0,
- BSSR_OPEN_FILE_ERR,
- BSSR_ALLOC_BUFFER_ERR,
- }BSSRET;
-
- #define BUFFER_SIZE 4096
-
- class BitStreamStruct
- {
- public:
- BitStreamStruct();
- ~BitStreamStruct();
-
- void Clear(void);
- void PutBitStream(const unsigned int val,int N);
- void PutBit(const unsigned int bit);
- unsigned long GetBitStream(int N);
- unsigned int GetBit(void);
- void EmptyBuffer(const int minimum);
- BSSRET OpenBitStreamW(const char* szFile,const int nSize);
- BSSRET OpenBitStreamR(const char* szFile,const int nSize);
- void CloseBitStreamW(void);
- void CloseBitStreamR(void);
- void RefillBuffer(void);
- bool SeekSync(const long sync,const int N);
-
- inline long sstell(void)
- {
- return m_nBitCount;
- }
-
- inline bool end_bs(void)
- {
- return m_bEndOfBitStream;
- }
- private:
- inline bool AllocBuffer(const int nSize);
- private:
- HANDLE m_hFile; /* pointer to bit stream device */
- unsigned char *m_pBuffer; /* bit stream buffer */
- int m_nBufSize; /* size of buffer (in number of bytes) */
- long m_nBitCount; /* bit counter of bit stream */
- int m_nBufferByteIndex; /* pointer to top byte in buffer */
- int m_nBufferBitIndex; /* pointer to top bit of top byte in buffer */
- int m_nMode; /* bit stream open in read or write mode */
- int m_nEndOfBuffer; /* end of buffer index */
- bool m_bEndOfBitStream; /* end of bit stream flag */
- char m_nFormat;
- };
-
- #endif