vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / plugins / ape_reader / MAClib / UnBitArrayBase.h
blob1ea286af07dea4509aa1c9068b60cf75bd77017d
1 #ifndef APE_UNBITARRAYBASE_H
2 #define APE_UNBITARRAYBASE_H
5 class IAPEDecompress;
6 class CIO;
9 struct UNBIT_ARRAY_STATE
11 uint32 k;
12 uint32 nKSum;
15 enum DECODE_VALUE_METHOD
17 DECODE_VALUE_METHOD_UNSIGNED_INT,
18 DECODE_VALUE_METHOD_UNSIGNED_RICE,
19 DECODE_VALUE_METHOD_X_BITS
23 class CUnBitArrayBase
25 public:
26 virtual ~CUnBitArrayBase() {}
28 virtual int FillBitArray();
29 virtual int FillAndResetBitArray(int nFileLocation = -1,
30 int nNewBitIndex = 0);
32 virtual void GenerateArray(int * pOutputArray, int nElements,
33 int nBytesRequired = -1) {}
34 virtual uint DecodeValue(DECODE_VALUE_METHOD DecodeMethod,
35 int nParam1 = 0, int nParam2 = 0) { return 0; }
37 virtual void AdvanceToByteBoundary();
39 virtual int DecodeValueRange(UNBIT_ARRAY_STATE& BitArrayState)
40 { return 0; }
41 virtual void FlushState(UNBIT_ARRAY_STATE& BitArrayState) {}
42 virtual void FlushBitArray() {}
43 virtual void Finalize() {}
45 protected:
46 virtual int CreateHelper(CIO* pIO, int nBytes, int nVersion);
47 virtual uint32 DecodeValueXBits(uint32 nBits);
49 uint32 m_nElements;
50 uint32 m_nBytes;
51 uint32 m_nBits;
53 int m_nVersion;
54 CIO * m_pIO;
56 uint32 m_nCurrentBitIndex;
57 uint32 * m_pBitArray;
60 CUnBitArrayBase* CreateUnBitArray(IAPEDecompress* pAPEDecompress, int nVersion);
63 #endif // #ifndef APE_UNBITARRAYBASE_H