RetroArch
LzFind.h
Go to the documentation of this file.
1 /* LzFind.h -- Match finder for LZ algorithms
2 2015-10-15 : Igor Pavlov : Public domain */
3 
4 #ifndef __LZ_FIND_H
5 #define __LZ_FIND_H
6 
7 #include "7zTypes.h"
8 
10 
11 typedef uint32_t CLzRef;
12 
13 typedef struct _CMatchFinder
14 {
15  unsigned char *buffer;
20 
22  uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */
23 
24  unsigned char streamEndWasReached;
25  unsigned char btMode;
26  unsigned char bigHash;
27  unsigned char directInput;
28 
34 
35  unsigned char *bufferBase;
37 
41 
48  uint32_t crc[256];
49  size_t numRefs;
50 } CMatchFinder;
51 
52 #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
53 
54 #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
55 
56 #define Inline_MatchFinder_IsFinishedOK(p) \
57  ((p)->streamEndWasReached \
58  && (p)->streamPos == (p)->pos \
59  && (!(p)->directInput || (p)->directInputRem == 0))
60 
65 
67 
68 /* Conditions:
69  historySize <= 3 GB
70  keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
71 */
72 int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
73  uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
74  ISzAlloc *alloc);
76 void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems);
78 
79 uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const unsigned char *buffer, CLzRef *son,
80  uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue,
81  uint32_t *distances, uint32_t maxLen);
82 
83 /*
84 Conditions:
85  Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
86  Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
87 */
88 
89 typedef void (*Mf_Init_Func)(void *object);
91 typedef const unsigned char * (*Mf_GetPointerToCurrentPos_Func)(void *object);
92 typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
93 typedef void (*Mf_Skip_Func)(void *object, uint32_t);
94 
95 typedef struct _IMatchFinder
96 {
102 } IMatchFinder;
103 
105 
106 void MatchFinder_Init_2(CMatchFinder *p, int readData);
108 
111 
114 
116 
117 #endif
uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const unsigned char *buffer, CLzRef *son, uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue, uint32_t *distances, uint32_t maxLen)
Definition: LzFind.c:388
uint32_t cyclicBufferSize
Definition: LzFind.h:22
size_t directInputRem
Definition: LzFind.h:43
unsigned char streamEndWasReached
Definition: LzFind.h:24
Mf_GetMatches_Func GetMatches
Definition: LzFind.h:100
Definition: 7zTypes.h:162
size_t numRefs
Definition: LzFind.h:49
void MatchFinder_ReadIfRequired(CMatchFinder *p)
Definition: LzFind.c:114
EXTERN_C_BEGIN typedef uint32_t CLzRef
Definition: LzFind.h:11
uint32_t cyclicBufferPos
Definition: LzFind.h:21
Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos
Definition: LzFind.h:99
struct _CMatchFinder CMatchFinder
unsigned char * bufferBase
Definition: LzFind.h:35
uint32_t(* Mf_GetNumAvailableBytes_Func)(void *object)
Definition: LzFind.h:90
SRes result
Definition: LzFind.h:47
uint32_t blockSize
Definition: LzFind.h:38
void(* Mf_Skip_Func)(void *object, uint32_t)
Definition: LzFind.h:93
uint32_t posLimit
Definition: LzFind.h:17
void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems)
Definition: LzFind.c:325
uint32_t keepSizeBefore
Definition: LzFind.h:39
void(* Mf_Init_Func)(void *object)
Definition: LzFind.h:89
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
uint32_t pos
Definition: LzFind.h:16
uint32_t keepSizeAfter
Definition: LzFind.h:40
const unsigned char *(* Mf_GetPointerToCurrentPos_Func)(void *object)
Definition: LzFind.h:91
unsigned char directInput
Definition: LzFind.h:27
Mf_Init_Func Init
Definition: LzFind.h:97
GLuint GLuint num
Definition: glext.h:10525
uint32_t numHashBytes
Definition: LzFind.h:42
void MatchFinder_MoveBlock(CMatchFinder *p)
Definition: LzFind.c:98
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
Definition: LzFind.c:789
uint32_t(* Mf_GetMatches_Func)(void *object, uint32_t *distances)
Definition: LzFind.h:92
void MatchFinder_Init_2(CMatchFinder *p, int readData)
Definition: LzFind.c:295
void MatchFinder_Init(CMatchFinder *p)
Definition: LzFind.c:315
uint32_t hashSizeSum
Definition: LzFind.h:46
void MatchFinder_Construct(CMatchFinder *p)
Definition: LzFind.c:139
#define EXTERN_C_END
Definition: 7zTypes.h:16
int SRes
Definition: 7zTypes.h:44
uint32_t crc[256]
Definition: LzFind.h:48
uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
Definition: LzFind.c:537
ISeqInStream * stream
Definition: LzFind.h:36
int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter, ISzAlloc *alloc)
Definition: LzFind.c:177
Mf_Skip_Func Skip
Definition: LzFind.h:101
Definition: LzFind.h:95
GLfloat GLfloat p
Definition: glext.h:9809
int MatchFinder_NeedMove(CMatchFinder *p)
Definition: LzFind.c:106
uint32_t streamPos
Definition: LzFind.h:18
void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue)
Definition: LzFind.c:51
struct _IMatchFinder IMatchFinder
uint32_t fixedHashSize
Definition: LzFind.h:45
uint32_t historySize
Definition: LzFind.h:44
unsigned char * buffer
Definition: LzFind.h:15
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
Definition: LzFind.c:163
uint32_t matchMaxLen
Definition: LzFind.h:29
CLzRef * hash
Definition: LzFind.h:30
uint32_t hashMask
Definition: LzFind.h:32
#define EXTERN_C_BEGIN
Definition: 7zTypes.h:15
CLzRef * son
Definition: LzFind.h:31
Mf_GetNumAvailableBytes_Func GetNumAvailableBytes
Definition: LzFind.h:98
unsigned char btMode
Definition: LzFind.h:25
unsigned char bigHash
Definition: LzFind.h:26
uint32_t cutValue
Definition: LzFind.h:33
Definition: 7zTypes.h:74
Definition: video4linux2.c:51
Definition: LzFind.h:13
uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
Definition: LzFind.c:697
unsigned char * MatchFinder_GetPointerToCurrentPos(CMatchFinder *p)
Definition: LzFind.c:47
unsigned int uint32_t
Definition: stdint.h:126
uint32_t lenLimit
Definition: LzFind.h:19
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
Definition: LzFind.c:722
GLuint object
Definition: glsym_es2.h:109
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
Definition: LzFind.c:803