acpi: Add IORT helper functions
[coreboot2.git] / util / cbfstool / lzma / C / LzFind.h
blob66e1ecdf326593804f4fe11f37dbf75d3ae7fc65
1 /* LzFind.h -- Match finder for LZ algorithms
2 2009-04-22 : Igor Pavlov : Public domain */
4 #ifndef __LZ_FIND_H
5 #define __LZ_FIND_H
7 #include "Types.h"
9 typedef uint32_t CLzRef;
11 struct CMatchFinder
13 uint8_t *buffer;
14 uint32_t pos;
15 uint32_t posLimit;
16 uint32_t streamPos;
17 uint32_t lenLimit;
19 uint32_t cyclicBufferPos;
20 uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */
22 uint32_t matchMaxLen;
23 CLzRef *hash;
24 CLzRef *son;
25 uint32_t hashMask;
26 uint32_t cutValue;
28 uint8_t *bufferBase;
29 struct ISeqInStream *stream;
30 int streamEndWasReached;
32 uint32_t blockSize;
33 uint32_t keepSizeBefore;
34 uint32_t keepSizeAfter;
36 uint32_t numHashBytes;
37 int directInput;
38 size_t directInputRem;
39 int btMode;
40 int bigHash;
41 uint32_t historySize;
42 uint32_t fixedHashSize;
43 uint32_t hashSizeSum;
44 uint32_t numSons;
45 SRes result;
46 uint32_t crc[256];
49 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
50 #define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(int32_t)(index)])
52 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
54 int MatchFinder_NeedMove(struct CMatchFinder *p);
55 uint8_t *MatchFinder_GetPointerToCurrentPos(struct CMatchFinder *p);
56 void MatchFinder_MoveBlock(struct CMatchFinder *p);
57 void MatchFinder_ReadIfRequired(struct CMatchFinder *p);
59 void MatchFinder_Construct(struct CMatchFinder *p);
61 /* Conditions:
62 historySize <= 3 GB
63 keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
65 int MatchFinder_Create(struct CMatchFinder *p, uint32_t historySize,
66 uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
67 struct ISzAlloc *alloc);
68 void MatchFinder_Free(struct CMatchFinder *p, struct ISzAlloc *alloc);
69 void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, uint32_t numItems);
70 void MatchFinder_ReduceOffsets(struct CMatchFinder *p, uint32_t subValue);
72 uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *buffer, CLzRef *son,
73 uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue,
74 uint32_t *distances, uint32_t maxLen);
77 Conditions:
78 Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
79 Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
82 typedef void (*Mf_Init_Func)(void *object);
83 typedef uint8_t (*Mf_GetIndexByte_Func)(void *object, int32_t index);
84 typedef uint32_t (*Mf_GetNumAvailableBytes_Func)(void *object);
85 typedef const uint8_t * (*Mf_GetPointerToCurrentPos_Func)(void *object);
86 typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
87 typedef void (*Mf_Skip_Func)(void *object, uint32_t);
89 struct IMatchFinder
91 Mf_Init_Func Init;
92 Mf_GetIndexByte_Func GetIndexByte;
93 Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
94 Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
95 Mf_GetMatches_Func GetMatches;
96 Mf_Skip_Func Skip;
99 void MatchFinder_CreateVTable(struct CMatchFinder *p, struct IMatchFinder *vTable);
101 void MatchFinder_Init(struct CMatchFinder *p);
102 uint32_t Bt3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances);
103 uint32_t Hc3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances);
104 void Bt3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num);
105 void Hc3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num);
107 #endif