File: BitArray.h

package info (click to toggle)
libjmac-java 1.74-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,780 kB
  • sloc: java: 9,279; cpp: 4,375; xml: 369; makefile: 31; sh: 12
file content (62 lines) | stat: -rw-r--r-- 1,530 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef APE_BITARRAY_H
#define APE_BITARRAY_H

#include "IO.h"
#include "MD5.h"

//#define BUILD_RANGE_TABLE

struct RANGE_CODER_STRUCT_COMPRESS
{
    unsigned int low;        // low end of interval
    unsigned int range;        // length of interval
    unsigned int help;        // bytes_to_follow resp. intermediate value
    unsigned char buffer;    // buffer for input / output
};

struct BIT_ARRAY_STATE
{
    uint32    k;
    uint32    nKSum;
};

class CBitArray
{
public:
    
    // construction / destruction
    CBitArray(CIO *pIO);
    ~CBitArray();

    // encoding
    int EncodeUnsignedLong(unsigned int n);
    int EncodeValue(int nEncode, BIT_ARRAY_STATE & BitArrayState);
    int EncodeBits(unsigned int nValue, int nBits);

    // output (saving)
    int OutputBitArray(BOOL bFinalize = FALSE);
    
    // other functions
    void Finalize();
    void AdvanceToByteBoundary();
    inline uint32 GetCurrentBitIndex() { return m_nCurrentBitIndex; }
    void FlushState(BIT_ARRAY_STATE & BitArrayState);
    void FlushBitArray();
    inline CMD5Helper & GetMD5Helper() { return m_MD5; }
        
private:
    
    // data members
    uint32 *            m_pBitArray;
    CIO    *                        m_pIO;
    uint32            m_nCurrentBitIndex;
    RANGE_CODER_STRUCT_COMPRESS    m_RangeCoderInfo;
    CMD5Helper                    m_MD5;

#ifdef BUILD_RANGE_TABLE
    void OutputRangeTable();
#endif
    
};

#endif // #ifndef APE_BITARRAY_H