annotate src/win32/7zip/7z/C/LzFind.h @ 1:f9f4f1b99eed

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