1#ifndef APE_APEDECOMPRESS_H
2#define APE_APEDECOMPRESS_H
3
4class CUnBitArray;
5class CPrepare;
6class CAPEInfo;
7class IPredictorDecompress;
8#include "UnBitArrayBase.h"
9#include "MACLib.h"
10#include "Prepare.h"
11#include "CircleBuffer.h"
12
13class CAPEDecompress : public IAPEDecompress
14{
15public:
16
17    CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock = -1, int nFinishBlock = -1);
18    ~CAPEDecompress();
19
20    int GetData(char * pBuffer, int nBlocks, int * pBlocksRetrieved);
21    int Seek(int nBlockOffset);
22
23    int GetInfo(APE_DECOMPRESS_FIELDS Field, int nParam1 = 0, int nParam2 = 0);
24
25protected:
26
27    // file info
28    int m_nBlockAlign;
29    int m_nCurrentFrame;
30
31    // start / finish information
32    int m_nStartBlock;
33    int m_nFinishBlock;
34    int m_nCurrentBlock;
35    BOOL m_bIsRanged;
36    BOOL m_bDecompressorInitialized;
37
38    // decoding tools
39    CPrepare m_Prepare;
40    WAVEFORMATEX m_wfeInput;
41    unsigned int m_nCRC;
42    unsigned int m_nStoredCRC;
43    int m_nSpecialCodes;
44
45    int SeekToFrame(int nFrameIndex);
46    void DecodeBlocksToFrameBuffer(int nBlocks);
47    int FillFrameBuffer();
48    void StartFrame();
49    void EndFrame();
50    int InitializeDecompressor();
51
52    // more decoding components
53    CSmartPtr<CAPEInfo> m_spAPEInfo;
54    CSmartPtr<CUnBitArrayBase> m_spUnBitArray;
55    UNBIT_ARRAY_STATE m_BitArrayStateX;
56    UNBIT_ARRAY_STATE m_BitArrayStateY;
57
58    CSmartPtr<IPredictorDecompress> m_spNewPredictorX;
59    CSmartPtr<IPredictorDecompress> m_spNewPredictorY;
60
61    int m_nLastX;
62
63    // decoding buffer
64    BOOL m_bErrorDecodingCurrentFrame;
65    int m_nCurrentFrameBufferBlock;
66    int m_nFrameBufferFinishedBlocks;
67    CCircleBuffer m_cbFrameBuffer;
68};
69
70#endif // #ifndef APE_APEDECOMPRESS_H
71