OLD | NEW |
(Empty) | |
| 1 /* LzFind.h -- Match finder for LZ algorithms |
| 2 2009-04-22 : Igor Pavlov : Public domain */ |
| 3 |
| 4 #ifndef __LZ_FIND_H |
| 5 #define __LZ_FIND_H |
| 6 |
| 7 #include "Types.h" |
| 8 |
| 9 namespace ots { |
| 10 namespace lzma { |
| 11 |
| 12 typedef UInt32 CLzRef; |
| 13 |
| 14 typedef struct _CMatchFinder |
| 15 { |
| 16 Byte *buffer; |
| 17 UInt32 pos; |
| 18 UInt32 posLimit; |
| 19 UInt32 streamPos; |
| 20 UInt32 lenLimit; |
| 21 |
| 22 UInt32 cyclicBufferPos; |
| 23 UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ |
| 24 |
| 25 UInt32 matchMaxLen; |
| 26 CLzRef *hash; |
| 27 CLzRef *son; |
| 28 UInt32 hashMask; |
| 29 UInt32 cutValue; |
| 30 |
| 31 Byte *bufferBase; |
| 32 ISeqInStream *stream; |
| 33 int streamEndWasReached; |
| 34 |
| 35 UInt32 blockSize; |
| 36 UInt32 keepSizeBefore; |
| 37 UInt32 keepSizeAfter; |
| 38 |
| 39 UInt32 numHashBytes; |
| 40 int directInput; |
| 41 size_t directInputRem; |
| 42 int btMode; |
| 43 int bigHash; |
| 44 UInt32 historySize; |
| 45 UInt32 fixedHashSize; |
| 46 UInt32 hashSizeSum; |
| 47 UInt32 numSons; |
| 48 SRes result; |
| 49 UInt32 crc[256]; |
| 50 } CMatchFinder; |
| 51 |
| 52 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) |
| 53 #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) |
| 54 |
| 55 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) |
| 56 |
| 57 int MatchFinder_NeedMove(CMatchFinder *p); |
| 58 Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); |
| 59 void MatchFinder_MoveBlock(CMatchFinder *p); |
| 60 void MatchFinder_ReadIfRequired(CMatchFinder *p); |
| 61 |
| 62 void MatchFinder_Construct(CMatchFinder *p); |
| 63 |
| 64 /* Conditions: |
| 65 historySize <= 3 GB |
| 66 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB |
| 67 */ |
| 68 int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, |
| 69 UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, |
| 70 ISzAlloc *alloc); |
| 71 void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); |
| 72 void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); |
| 73 void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); |
| 74 |
| 75 UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
e *buffer, CLzRef *son, |
| 76 UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, |
| 77 UInt32 *distances, UInt32 maxLen); |
| 78 |
| 79 /* |
| 80 Conditions: |
| 81 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. |
| 82 Mf_GetPointerToCurrentPos_Func's result must be used only before any other fun
ction |
| 83 */ |
| 84 |
| 85 typedef void (*Mf_Init_Func)(void *object); |
| 86 typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); |
| 87 typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); |
| 88 typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); |
| 89 typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); |
| 90 typedef void (*Mf_Skip_Func)(void *object, UInt32); |
| 91 |
| 92 typedef struct _IMatchFinder |
| 93 { |
| 94 Mf_Init_Func Init; |
| 95 Mf_GetIndexByte_Func GetIndexByte; |
| 96 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; |
| 97 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; |
| 98 Mf_GetMatches_Func GetMatches; |
| 99 Mf_Skip_Func Skip; |
| 100 } IMatchFinder; |
| 101 |
| 102 void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); |
| 103 |
| 104 void MatchFinder_Init(CMatchFinder *p); |
| 105 UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); |
| 106 UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); |
| 107 void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); |
| 108 void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); |
| 109 |
| 110 } // namespace lzma |
| 111 } // namespace ots |
| 112 |
| 113 #endif |
OLD | NEW |