| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef __LZ_FIND_H |
| 5 |
#define __LZ_FIND_H |
| 6 |
|
| 7 |
#include "Types.h" |
| 8 |
|
| 9 |
typedef uint32_t CLzRef; |
| 10 |
|
| 11 |
struct CMatchFinder |
| 12 |
{ |
| 13 |
uint8_t *buffer; |
| 14 |
uint32_t pos; |
| 15 |
uint32_t posLimit; |
| 16 |
uint32_t streamPos; |
| 17 |
uint32_t lenLimit; |
| 18 |
|
| 19 |
uint32_t cyclicBufferPos; |
| 20 |
uint32_t cyclicBufferSize; |
| 21 |
|
| 22 |
uint32_t matchMaxLen; |
| 23 |
CLzRef *hash; |
| 24 |
CLzRef *son; |
| 25 |
uint32_t hashMask; |
| 26 |
uint32_t cutValue; |
| 27 |
|
| 28 |
uint8_t *bufferBase; |
| 29 |
struct ISeqInStream *stream; |
| 30 |
int streamEndWasReached; |
| 31 |
|
| 32 |
uint32_t blockSize; |
| 33 |
uint32_t keepSizeBefore; |
| 34 |
uint32_t keepSizeAfter; |
| 35 |
|
| 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]; |
| 47 |
}; |
| 48 |
|
| 49 |
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) |
| 50 |
#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(int32_t)(index)]) |
| 51 |
|
| 52 |
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) |
| 53 |
|
| 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); |
| 58 |
|
| 59 |
void MatchFinder_Construct(struct CMatchFinder *p); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 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); |
| 71 |
|
| 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); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 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); |
| 88 |
|
| 89 |
struct IMatchFinder |
| 90 |
{ |
| 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; |
| 97 |
}; |
| 98 |
|
| 99 |
void MatchFinder_CreateVTable(struct CMatchFinder *p, struct IMatchFinder *vTable); |
| 100 |
|
| 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); |
| 106 |
|
| 107 |
#endif |