blob: 29c273dbb0ca68bbedd94f642181d4bfa5788763 (
plain)
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
63
64
|
#include "Portable.h"
#include "WindowIn.h"
namespace BT_NAMESPACE {
typedef UINT32 CIndex;
const UINT32 kMaxValForNormalize = (UINT32(1) << 31) - 1;
struct CPair
{
CIndex Left;
CIndex Right;
};
class CInTree: public NStream::NWindow::CIn
{
UINT32 m_HistorySize;
UINT32 m_MatchMaxLen;
CIndex *m_Hash;
#ifdef HASH_ARRAY_2
CIndex *m_Hash2;
#ifdef HASH_ARRAY_3
CIndex *m_Hash3;
#endif
#endif
CPair *m_Son;
CPair *m_Base;
UINT32 m_CutValue;
void NormalizeLinks(CIndex *anArray, UINT32 aNumItems, UINT32 aSubValue);
void Normalize();
void FreeMemory();
protected:
virtual void AfterMoveBlock();
public:
CInTree();
~CInTree();
HRESULT Create(UINT32 aSizeHistory, UINT32 aKeepAddBufferBefore, UINT32 aMatchMaxLen,
UINT32 aKeepAddBufferAfter, UINT32 _dwSizeReserv = (1<<17));
HRESULT Init(ISequentialInStream *aStream);
void SetCutValue(UINT32 aCutValue) { m_CutValue = aCutValue; }
UINT32 GetLongestMatch(UINT32 *aDistances);
void DummyLongestMatch();
HRESULT MovePos()
{
RETURN_IF_NOT_S_OK(CIn::MovePos());
if (m_Pos == kMaxValForNormalize)
Normalize();
return S_OK;
}
void ReduceOffsets(UINT32 aSubValue)
{
CIn::ReduceOffsets(aSubValue);
m_Son += aSubValue;
}
};
}
|