blob: 50a705829e34d536b19a589192df67fcd52d1e78 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// BinTree.h
// #ifndef __BINTREE_H
// #define __BINTREE_H
#include "../LZInWindow.h"
namespace BT_NAMESPACE {
typedef UInt32 CIndex;
const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1;
// #define HASH_ARRAY_2
// #ifdef HASH_ARRAY_2
// #define HASH_ARRAY_3
// #else
// #define HASH_ZIP
// #endif
struct CPair
{
CIndex Left;
CIndex Right;
};
/*
const int kNumBundleBits = 2;
const UInt32 kNumPairsInBundle = 1 << kNumBundleBits;
const UInt32 kBundleMask = kNumPairsInBundle - 1;
const UInt32 kNumBundleBytes = kNumPairsInBundle * sizeof(CPair);
struct CBundle
{
CPair Pairs[kNumPairsInBundle];
Byte Bytes[kNumBundleBytes];
};
*/
class CInTree: public CLZInWindow
{
UInt32 _cyclicBufferPos;
UInt32 _cyclicBufferSize;
UInt32 _historySize;
UInt32 _matchMaxLen;
CIndex *_hash;
#ifdef HASH_ARRAY_2
CIndex *_hash2;
#ifdef HASH_ARRAY_3
CIndex *_hash3;
#endif
#endif
// CBundle *_son;
CPair *_son;
UInt32 _cutValue;
void NormalizeLinks(CIndex *items, UInt32 numItems, UInt32 subValue);
void Normalize();
void FreeMemory();
public:
CInTree();
~CInTree();
HRESULT Create(UInt32 sizeHistory, UInt32 keepAddBufferBefore, UInt32 matchMaxLen,
UInt32 keepAddBufferAfter, UInt32 sizeReserv = (1<<17));
HRESULT Init(ISequentialInStream *stream);
void SetCutValue(UInt32 cutValue) { _cutValue = cutValue; }
UInt32 GetLongestMatch(UInt32 *distances);
void DummyLongestMatch();
HRESULT MovePos()
{
_cyclicBufferPos++;
if (_cyclicBufferPos >= _cyclicBufferSize)
_cyclicBufferPos = 0;
RINOK(CLZInWindow::MovePos());
if (_pos == kMaxValForNormalize)
Normalize();
return S_OK;
}
};
}
// #endif
|