goat3d

annotate libs/openctm/liblzma/LzFind.h @ 55:af1310ed212b

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