1*b51fbe43SDavid McPaul #ifndef APE_BITARRAY_H 2*b51fbe43SDavid McPaul #define APE_BITARRAY_H 3*b51fbe43SDavid McPaul 4*b51fbe43SDavid McPaul #include "IO.h" 5*b51fbe43SDavid McPaul #include "MD5.h" 6*b51fbe43SDavid McPaul 7*b51fbe43SDavid McPaul //#define BUILD_RANGE_TABLE 8*b51fbe43SDavid McPaul 9*b51fbe43SDavid McPaul struct RANGE_CODER_STRUCT_COMPRESS 10*b51fbe43SDavid McPaul { 11*b51fbe43SDavid McPaul unsigned int low; // low end of interval 12*b51fbe43SDavid McPaul unsigned int range; // length of interval 13*b51fbe43SDavid McPaul unsigned int help; // bytes_to_follow resp. intermediate value 14*b51fbe43SDavid McPaul unsigned char buffer; // buffer for input / output 15*b51fbe43SDavid McPaul }; 16*b51fbe43SDavid McPaul 17*b51fbe43SDavid McPaul struct BIT_ARRAY_STATE 18*b51fbe43SDavid McPaul { 19*b51fbe43SDavid McPaul uint32 k; 20*b51fbe43SDavid McPaul uint32 nKSum; 21*b51fbe43SDavid McPaul }; 22*b51fbe43SDavid McPaul 23*b51fbe43SDavid McPaul class CBitArray 24*b51fbe43SDavid McPaul { 25*b51fbe43SDavid McPaul public: 26*b51fbe43SDavid McPaul 27*b51fbe43SDavid McPaul // construction / destruction 28*b51fbe43SDavid McPaul CBitArray(CIO *pIO); 29*b51fbe43SDavid McPaul ~CBitArray(); 30*b51fbe43SDavid McPaul 31*b51fbe43SDavid McPaul // encoding 32*b51fbe43SDavid McPaul int EncodeUnsignedLong(unsigned int n); 33*b51fbe43SDavid McPaul int EncodeValue(int nEncode, BIT_ARRAY_STATE & BitArrayState); 34*b51fbe43SDavid McPaul int EncodeBits(unsigned int nValue, int nBits); 35*b51fbe43SDavid McPaul 36*b51fbe43SDavid McPaul // output (saving) 37*b51fbe43SDavid McPaul int OutputBitArray(BOOL bFinalize = FALSE); 38*b51fbe43SDavid McPaul 39*b51fbe43SDavid McPaul // other functions 40*b51fbe43SDavid McPaul void Finalize(); 41*b51fbe43SDavid McPaul void AdvanceToByteBoundary(); GetCurrentBitIndex()42*b51fbe43SDavid McPaul inline uint32 GetCurrentBitIndex() { return m_nCurrentBitIndex; } 43*b51fbe43SDavid McPaul void FlushState(BIT_ARRAY_STATE & BitArrayState); 44*b51fbe43SDavid McPaul void FlushBitArray(); GetMD5Helper()45*b51fbe43SDavid McPaul inline CMD5Helper & GetMD5Helper() { return m_MD5; } 46*b51fbe43SDavid McPaul 47*b51fbe43SDavid McPaul private: 48*b51fbe43SDavid McPaul 49*b51fbe43SDavid McPaul // data members 50*b51fbe43SDavid McPaul uint32 * m_pBitArray; 51*b51fbe43SDavid McPaul CIO * m_pIO; 52*b51fbe43SDavid McPaul uint32 m_nCurrentBitIndex; 53*b51fbe43SDavid McPaul RANGE_CODER_STRUCT_COMPRESS m_RangeCoderInfo; 54*b51fbe43SDavid McPaul CMD5Helper m_MD5; 55*b51fbe43SDavid McPaul 56*b51fbe43SDavid McPaul #ifdef BUILD_RANGE_TABLE 57*b51fbe43SDavid McPaul void OutputRangeTable(); 58*b51fbe43SDavid McPaul #endif 59*b51fbe43SDavid McPaul 60*b51fbe43SDavid McPaul }; 61*b51fbe43SDavid McPaul 62*b51fbe43SDavid McPaul #endif // #ifndef APE_BITARRAY_H 63