| 1 |
// HC.h |
| 2 |
|
| 3 |
#include "../LZInWindow.h" |
| 4 |
#include "../IMatchFinder.h" |
| 5 |
|
| 6 |
namespace HC_NAMESPACE { |
| 7 |
|
| 8 |
typedef UInt32 CIndex; |
| 9 |
const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1; |
| 10 |
|
| 11 |
class CMatchFinderHC: |
| 12 |
public IMatchFinder, |
| 13 |
public IMatchFinderSetCallback, |
| 14 |
public CLZInWindow, |
| 15 |
public CMyUnknownImp |
| 16 |
{ |
| 17 |
UInt32 _cyclicBufferPos; |
| 18 |
UInt32 _cyclicBufferSize; // it must be historySize + 1 |
| 19 |
UInt32 _matchMaxLen; |
| 20 |
CIndex *_hash; |
| 21 |
UInt32 _cutValue; |
| 22 |
|
| 23 |
CMyComPtr<IMatchFinderCallback> m_Callback; |
| 24 |
|
| 25 |
void Normalize(); |
| 26 |
void FreeThisClassMemory(); |
| 27 |
void FreeMemory(); |
| 28 |
|
| 29 |
MY_UNKNOWN_IMP1(IMatchFinderSetCallback) |
| 30 |
|
| 31 |
STDMETHOD(Init)(ISequentialInStream *inStream); |
| 32 |
STDMETHOD_(void, ReleaseStream)(); |
| 33 |
STDMETHOD(MovePos)(); |
| 34 |
STDMETHOD_(Byte, GetIndexByte)(Int32 index); |
| 35 |
STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit); |
| 36 |
STDMETHOD_(UInt32, GetNumAvailableBytes)(); |
| 37 |
STDMETHOD_(const Byte *, GetPointerToCurrentPos)(); |
| 38 |
STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore, |
| 39 |
UInt32 matchMaxLen, UInt32 keepAddBufferAfter); |
| 40 |
STDMETHOD_(UInt32, GetLongestMatch)(UInt32 *distances); |
| 41 |
STDMETHOD_(void, DummyLongestMatch)(); |
| 42 |
|
| 43 |
// IMatchFinderSetCallback |
| 44 |
STDMETHOD(SetCallback)(IMatchFinderCallback *callback); |
| 45 |
|
| 46 |
virtual void BeforeMoveBlock(); |
| 47 |
virtual void AfterMoveBlock(); |
| 48 |
|
| 49 |
public: |
| 50 |
CMatchFinderHC(); |
| 51 |
virtual ~CMatchFinderHC(); |
| 52 |
void SetCutValue(UInt32 cutValue) { _cutValue = cutValue; } |
| 53 |
}; |
| 54 |
|
| 55 |
} |