Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
MtDec.h
Go to the documentation of this file.
1/* MtDec.h -- Multi-thread Decoder
22023-04-02 : Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_MT_DEC_H
5#define ZIP7_INC_MT_DEC_H
6
7#include "7zTypes.h"
8
9#ifndef Z7_ST
10#include "Threads.h"
11#endif
12
14
15#ifndef Z7_ST
16
17#ifndef Z7_ST
18 #define MTDEC_THREADS_MAX 32
19#else
20 #define MTDEC_THREADS_MAX 1
21#endif
22
23
32
33void MtProgress_Init(CMtProgress *p, ICompressProgressPtr progress);
38
39struct CMtDec;
40
41typedef struct
42{
43 struct CMtDec_ *mtDec;
44 unsigned index;
45 void *inBuf;
46
47 size_t inDataSize_Start; // size of input data in start block
48 UInt64 inDataSize; // total size of input data in all blocks
49
53 void *allocaPtr;
55
57
58
59typedef enum
60{
61 MTDEC_PARSE_CONTINUE, // continue this block with more input data
62 MTDEC_PARSE_OVERFLOW, // MT buffers overflow, need switch to single-thread
63 MTDEC_PARSE_NEW, // new block
64 MTDEC_PARSE_END // end of block threading. But we still can return to threading after Write(&needContinue)
66
67typedef struct
68{
69 // in
71 const Byte *src;
72 size_t srcSize;
73 // in : (srcSize == 0) is allowed
74 // out : it's allowed to return less that actually was used ?
76
77 // out
80 UInt64 outPos; // check it (size_t)
82
83
84typedef struct
85{
86 void (*Parse)(void *p, unsigned coderIndex, CMtDecCallbackInfo *ci);
87
88 // PreCode() and Code():
89 // (SRes_return_result != SZ_OK) means stop decoding, no need another blocks
90 SRes (*PreCode)(void *p, unsigned coderIndex);
91 SRes (*Code)(void *p, unsigned coderIndex,
92 const Byte *src, size_t srcSize, int srcFinished,
93 UInt64 *inCodePos, UInt64 *outCodePos, int *stop);
94 // stop - means stop another Code calls
95
96
97 /* Write() must be called, if Parse() was called
98 set (needWrite) if
99 {
100 && (was not interrupted by progress)
101 && (was not interrupted in previous block)
102 }
103
104 out:
105 if (*needContinue), decoder still need to continue decoding with new iteration,
106 even after MTDEC_PARSE_END
107 if (*canRecode), we didn't flush current block data, so we still can decode current block later.
108 */
109 SRes (*Write)(void *p, unsigned coderIndex,
110 BoolInt needWriteToStream,
111 const Byte *src, size_t srcSize, BoolInt isCross,
112 // int srcFinished,
114 BoolInt *canRecode);
115
117
118
119
120typedef struct CMtDec_
121{
122 /* input variables */
123
124 size_t inBufSize; /* size of input block */
126 // size_t inBlockMax;
128
129 ISeqInStreamPtr inStream;
130 // const Byte *inData;
131 // size_t inDataSize;
132
133 ICompressProgressPtr progress;
135
138
139
140 /* internal variables */
141
143
146
151
153
154 // CAutoResetEvent finishedEvent;
155
158
160
163
166 size_t crossEnd;
170
173
174 #ifndef Z7_ST
179 #endif
181
182
183void MtDec_Construct(CMtDec *p);
184void MtDec_Destruct(CMtDec *p);
185
186/*
187MtDec_Code() returns:
188 SZ_OK - in most cases
189 MY_SRes_HRESULT_FROM_WRes(WRes_error) - in case of unexpected error in threading function
190*/
191
194
196const Byte *MtDec_Read(CMtDec *p, size_t *inLim);
197
198#endif
199
201
202#endif
int BoolInt
Definition 7zTypes.h:259
int WRes
Definition 7zTypes.h:75
#define EXTERN_C_BEGIN
Definition 7zTypes.h:20
unsigned long long int UInt64
Definition 7zTypes.h:234
int SRes
Definition 7zTypes.h:45
#define EXTERN_C_END
Definition 7zTypes.h:21
SRes MtProgress_GetError(CMtProgress *p)
Definition MtDec.c:62
struct CMtDec_ CMtDec
SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize)
Definition MtDec.c:45
Byte * MtDec_GetCrossBuff(CMtDec *p)
Definition MtDec.c:214
const Byte * MtDec_Read(CMtDec *p, size_t *inLim)
Definition MtDec.c:882
SRes MtDec_Code(CMtDec *p)
Definition MtDec.c:1017
EMtDecParseState
Definition MtDec.h:60
@ MTDEC_PARSE_END
Definition MtDec.h:64
@ MTDEC_PARSE_CONTINUE
Definition MtDec.h:61
@ MTDEC_PARSE_OVERFLOW
Definition MtDec.h:62
@ MTDEC_PARSE_NEW
Definition MtDec.h:63
SRes MtProgress_Progress_ST(CMtProgress *p)
Definition MtDec.c:36
void MtDec_Destruct(CMtDec *p)
Definition MtDec.c:1009
void MtDecThread_FreeInBufs(CMtDecThread *t)
Definition MtDec.c:129
void MtProgress_Init(CMtProgress *p, ICompressProgressPtr progress)
Definition MtDec.c:27
void MtProgress_SetError(CMtProgress *p, SRes res)
Definition MtDec.c:72
void MtDec_Construct(CMtDec *p)
Definition MtDec.c:946
int MtDec_PrepareRead(CMtDec *p)
Definition MtDec.c:859
EMtDecParseState
Definition MtDec.h:60
#define Code
Definition deflate.h:80
char int srcSize
Definition lz4.h:806
const char * src
Definition lz4.h:866
#define MTDEC_THREADS_MAX
Definition MtDec.h:18
Definition Threads.h:232
Definition Threads.h:186
Definition MtDec.h:121
BoolInt exitThread
Definition MtDec.h:144
WRes exitThreadWRes
Definition MtDec.h:145
UInt64 inProcessed
Definition MtDec.h:169
UInt64 interruptIndex
Definition MtDec.h:176
IMtDecCallback2 * mtCallback
Definition MtDec.h:136
size_t crossStart
Definition MtDec.h:165
size_t inBufSize
Definition MtDec.h:124
size_t allocatedBufsSize
Definition MtDec.h:142
BoolInt needInterrupt
Definition MtDec.h:175
UInt64 readProcessed
Definition MtDec.h:167
BoolInt needContinue
Definition MtDec.h:152
unsigned filledThreadStart
Definition MtDec.h:171
CMtDecThread threads[MTDEC_THREADS_MAX]
Definition MtDec.h:178
size_t crossEnd
Definition MtDec.h:166
CMtProgress mtProgress
Definition MtDec.h:177
unsigned numThreadsMax_2
Definition MtDec.h:127
BoolInt overflow
Definition MtDec.h:149
SRes codeRes
Definition MtDec.h:157
void * mtCallbackObject
Definition MtDec.h:137
SRes readRes
Definition MtDec.h:156
ICompressProgressPtr progress
Definition MtDec.h:133
BoolInt isAllocError
Definition MtDec.h:148
ISzAllocPtr alloc
Definition MtDec.h:134
Byte * crossBlock
Definition MtDec.h:164
unsigned numStartedThreads
Definition MtDec.h:162
UInt64 blockIndex
Definition MtDec.h:147
BoolInt readWasFinished
Definition MtDec.h:168
unsigned numFilledThreads
Definition MtDec.h:172
SRes threadingErrorSRes
Definition MtDec.h:150
unsigned numStartedThreads_Limit
Definition MtDec.h:161
unsigned numThreadsMax
Definition MtDec.h:125
ISeqInStreamPtr inStream
Definition MtDec.h:129
BoolInt wasInterrupted
Definition MtDec.h:159
Definition MtDec.h:68
size_t srcSize
Definition MtDec.h:72
UInt64 outPos
Definition MtDec.h:80
int srcFinished
Definition MtDec.h:75
BoolInt canCreateNewThread
Definition MtDec.h:79
EMtDecParseState state
Definition MtDec.h:78
int startCall
Definition MtDec.h:70
const Byte * src
Definition MtDec.h:71
Definition MtDec.h:42
void * allocaPtr
Definition MtDec.h:53
CAutoResetEvent canWrite
Definition MtDec.h:52
unsigned index
Definition MtDec.h:44
size_t inDataSize_Start
Definition MtDec.h:47
struct CMtDec_ * mtDec
Definition MtDec.h:43
CAutoResetEvent canRead
Definition MtDec.h:51
void * inBuf
Definition MtDec.h:45
CThread thread
Definition MtDec.h:50
UInt64 inDataSize
Definition MtDec.h:48
Definition MtDec.h:25
UInt64 totalInSize
Definition MtDec.h:28
ICompressProgressPtr progress
Definition MtDec.h:26
UInt64 totalOutSize
Definition MtDec.h:29
SRes res
Definition MtDec.h:27
CCriticalSection cs
Definition MtDec.h:30
Definition Threads.h:76
Definition MtDec.h:85
Definition 7zTypes.h:460
unsigned char Byte
Definition zconf.h:391