xref: /haiku/src/add-ons/media/plugins/ape_reader/MAClib/UnBitArrayBase.h (revision 23c0ae0362174e8dbdc88d14e03618815dde145e)
1b51fbe43SDavid McPaul #ifndef APE_UNBITARRAYBASE_H
2b51fbe43SDavid McPaul #define APE_UNBITARRAYBASE_H
3b51fbe43SDavid McPaul 
4*23c0ae03SWim van der Meer 
5b51fbe43SDavid McPaul class IAPEDecompress;
6b51fbe43SDavid McPaul class CIO;
7b51fbe43SDavid McPaul 
8*23c0ae03SWim van der Meer 
9b51fbe43SDavid McPaul struct UNBIT_ARRAY_STATE
10b51fbe43SDavid McPaul {
11b51fbe43SDavid McPaul 	uint32 k;
12b51fbe43SDavid McPaul 	uint32 nKSum;
13b51fbe43SDavid McPaul };
14b51fbe43SDavid McPaul 
15b51fbe43SDavid McPaul enum DECODE_VALUE_METHOD
16b51fbe43SDavid McPaul {
17b51fbe43SDavid McPaul 	DECODE_VALUE_METHOD_UNSIGNED_INT,
18b51fbe43SDavid McPaul 	DECODE_VALUE_METHOD_UNSIGNED_RICE,
19b51fbe43SDavid McPaul 	DECODE_VALUE_METHOD_X_BITS
20b51fbe43SDavid McPaul };
21b51fbe43SDavid McPaul 
22*23c0ae03SWim van der Meer 
23b51fbe43SDavid McPaul class CUnBitArrayBase
24b51fbe43SDavid McPaul {
25b51fbe43SDavid McPaul public:
~CUnBitArrayBase()26b51fbe43SDavid McPaul 	virtual 		~CUnBitArrayBase() {}
27b51fbe43SDavid McPaul 
28b51fbe43SDavid McPaul 	virtual	int		FillBitArray();
29*23c0ae03SWim van der Meer 	virtual	int		FillAndResetBitArray(int nFileLocation = -1,
30*23c0ae03SWim van der Meer 						int nNewBitIndex = 0);
31b51fbe43SDavid McPaul 
32*23c0ae03SWim van der Meer 	virtual	void	GenerateArray(int * pOutputArray, int nElements,
33*23c0ae03SWim van der Meer 						int nBytesRequired = -1) {}
34*23c0ae03SWim van der Meer 	virtual	uint	DecodeValue(DECODE_VALUE_METHOD DecodeMethod,
35*23c0ae03SWim van der Meer 						int nParam1 = 0, int nParam2 = 0) { return 0; }
36b51fbe43SDavid McPaul 
37b51fbe43SDavid McPaul 	virtual	void	AdvanceToByteBoundary();
38b51fbe43SDavid McPaul 
DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState)39*23c0ae03SWim van der Meer 	virtual	int		DecodeValueRange(UNBIT_ARRAY_STATE& BitArrayState)
40*23c0ae03SWim van der Meer 						{ return 0; }
FlushState(UNBIT_ARRAY_STATE & BitArrayState)41b51fbe43SDavid McPaul 	virtual	void	FlushState(UNBIT_ARRAY_STATE& BitArrayState) {}
FlushBitArray()42b51fbe43SDavid McPaul 	virtual	void	FlushBitArray() {}
Finalize()43b51fbe43SDavid McPaul 	virtual	void	Finalize() {}
44b51fbe43SDavid McPaul 
45b51fbe43SDavid McPaul protected:
46b51fbe43SDavid McPaul 	virtual	int		CreateHelper(CIO* pIO, int nBytes, int nVersion);
47b51fbe43SDavid McPaul 	virtual	uint32	DecodeValueXBits(uint32 nBits);
48b51fbe43SDavid McPaul 
49b51fbe43SDavid McPaul 			uint32 m_nElements;
50b51fbe43SDavid McPaul 			uint32 m_nBytes;
51b51fbe43SDavid McPaul 			uint32 m_nBits;
52b51fbe43SDavid McPaul 
53b51fbe43SDavid McPaul 			int m_nVersion;
54b51fbe43SDavid McPaul 			CIO * m_pIO;
55b51fbe43SDavid McPaul 
56b51fbe43SDavid McPaul 			uint32 m_nCurrentBitIndex;
57b51fbe43SDavid McPaul 			uint32 * m_pBitArray;
58b51fbe43SDavid McPaul };
59b51fbe43SDavid McPaul 
60b51fbe43SDavid McPaul CUnBitArrayBase* CreateUnBitArray(IAPEDecompress* pAPEDecompress, int nVersion);
61b51fbe43SDavid McPaul 
62*23c0ae03SWim van der Meer 
63b51fbe43SDavid McPaul #endif // #ifndef APE_UNBITARRAYBASE_H
64