summaryrefslogtreecommitdiff
path: root/Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h')
-rwxr-xr-xSource/7zip/7zip/Compress/LZ/BinTree/BinTree.h119
1 files changed, 48 insertions, 71 deletions
diff --git a/Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h b/Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h
index 50a7058..186adab 100755
--- a/Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h
+++ b/Source/7zip/7zip/Compress/LZ/BinTree/BinTree.h
@@ -1,92 +1,69 @@
-// BinTree.h
-
-// #ifndef __BINTREE_H
-// #define __BINTREE_H
+/*
+ * BinTree.h
+ *
+ * This file is a part of LZMA compression module for NSIS.
+ *
+ * Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
+ * Modifications Copyright (C) 2003-2006 Amir Szekely <kichik@netvision.net.il>
+ *
+ * Licensed under the Common Public License version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
#include "../LZInWindow.h"
+#include "../IMatchFinder.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
+class CMatchFinder:
+ public IMatchFinder,
+ public CLZInWindow,
+ public CMyUnknownImp,
+ public IMatchFinderSetNumPasses
{
UInt32 _cyclicBufferPos;
- UInt32 _cyclicBufferSize;
- UInt32 _historySize;
+ UInt32 _cyclicBufferSize; // it must be historySize + 1
UInt32 _matchMaxLen;
-
CIndex *_hash;
-
- #ifdef HASH_ARRAY_2
- CIndex *_hash2;
- #ifdef HASH_ARRAY_3
- CIndex *_hash3;
- #endif
- #endif
-
- // CBundle *_son;
- CPair *_son;
-
+ CIndex *_son;
+ UInt32 _hashMask;
UInt32 _cutValue;
+ UInt32 _hashSizeSum;
- void NormalizeLinks(CIndex *items, UInt32 numItems, UInt32 subValue);
void Normalize();
+ void FreeThisClassMemory();
void FreeMemory();
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(SetStream)(ISequentialInStream *inStream);
+ STDMETHOD_(void, ReleaseStream)();
+ STDMETHOD(Init)();
+ HRESULT MovePos();
+ STDMETHOD_(Byte, GetIndexByte)(Int32 index);
+ STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit);
+ STDMETHOD_(UInt32, GetNumAvailableBytes)();
+ STDMETHOD_(const Byte *, GetPointerToCurrentPos)();
+ STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);
+ STDMETHOD_(void, ChangeBufferPos)();
+
+ STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
+ STDMETHOD(GetMatches)(UInt32 *distances);
+ STDMETHOD(Skip)(UInt32 num);
+
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;
- }
+ CMatchFinder();
+ virtual ~CMatchFinder();
+ virtual void SetNumPasses(UInt32 numPasses) { _cutValue = numPasses; }
};
}
-
-// #endif