home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / dctm.lzh / DCTM / source.lzh / source / BitStreamStruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-08  |  1.8 KB  |  63 lines

  1. /*************************************************************************
  2.     BitStreamStruct.h
  3.  
  4.     03/02/08    Xiaohong
  5. *************************************************************************/
  6. #ifndef _INCLUDE_BIT_STREAM_STRUCT_H_____________________________
  7. #define _INCLUDE_BIT_STREAM_STRUCT_H_____________________________
  8.  
  9. #include <windows.h>
  10.  
  11. typedef enum
  12. {
  13.     BSSR_OK = 0,
  14.     BSSR_OPEN_FILE_ERR,
  15.     BSSR_ALLOC_BUFFER_ERR,
  16. }BSSRET;
  17.  
  18. #define BUFFER_SIZE     4096
  19.  
  20. class BitStreamStruct
  21. {
  22. public:
  23.     BitStreamStruct();
  24.     ~BitStreamStruct();
  25.  
  26.     void Clear(void);
  27.     void PutBitStream(const unsigned int val,int N);
  28.     void PutBit(const unsigned int bit);
  29.     unsigned long GetBitStream(int N);
  30.     unsigned int GetBit(void);
  31.     void EmptyBuffer(const int minimum);
  32.     BSSRET OpenBitStreamW(const char* szFile,const int nSize);
  33.     BSSRET OpenBitStreamR(const char* szFile,const int nSize);
  34.     void CloseBitStreamW(void);
  35.     void CloseBitStreamR(void);
  36.     void RefillBuffer(void);
  37.     bool SeekSync(const long sync,const int N);
  38.  
  39.     inline long sstell(void)
  40.     {
  41.         return m_nBitCount;
  42.     }
  43.  
  44.     inline bool end_bs(void)
  45.     {
  46.         return m_bEndOfBitStream;
  47.     }
  48. private:
  49.     inline bool AllocBuffer(const int nSize);
  50. private:
  51.     HANDLE            m_hFile;            /* pointer to bit stream device */
  52.     unsigned char    *m_pBuffer;            /* bit stream buffer */
  53.     int                m_nBufSize;       /* size of buffer (in number of bytes) */
  54.     long            m_nBitCount;         /* bit counter of bit stream */
  55.     int                m_nBufferByteIndex;   /* pointer to top byte in buffer */
  56.     int                m_nBufferBitIndex;    /* pointer to top bit of top byte in buffer */
  57.     int                m_nMode;           /* bit stream open in read or write mode */
  58.     int                m_nEndOfBuffer;            /* end of buffer index */
  59.     bool            m_bEndOfBitStream;           /* end of bit stream flag */
  60.     char            m_nFormat;
  61. };
  62.  
  63. #endif