Merge pull request #461 from negativeExponent/libchdr
[pcsx_rearmed.git] / deps / lzma-16.04 / C / MtCoder.h
CommitLineData
ce188d4d 1/* MtCoder.h -- Multi-thread Coder\r
22009-11-19 : Igor Pavlov : Public domain */\r
3\r
4#ifndef __MT_CODER_H\r
5#define __MT_CODER_H\r
6\r
7#include "Threads.h"\r
8\r
9EXTERN_C_BEGIN\r
10\r
11typedef struct\r
12{\r
13 CThread thread;\r
14 CAutoResetEvent startEvent;\r
15 CAutoResetEvent finishedEvent;\r
16 int stop;\r
17 \r
18 THREAD_FUNC_TYPE func;\r
19 LPVOID param;\r
20 THREAD_FUNC_RET_TYPE res;\r
21} CLoopThread;\r
22\r
23void LoopThread_Construct(CLoopThread *p);\r
24void LoopThread_Close(CLoopThread *p);\r
25WRes LoopThread_Create(CLoopThread *p);\r
26WRes LoopThread_StopAndWait(CLoopThread *p);\r
27WRes LoopThread_StartSubThread(CLoopThread *p);\r
28WRes LoopThread_WaitSubThread(CLoopThread *p);\r
29\r
30#ifndef _7ZIP_ST\r
31#define NUM_MT_CODER_THREADS_MAX 32\r
32#else\r
33#define NUM_MT_CODER_THREADS_MAX 1\r
34#endif\r
35\r
36typedef struct\r
37{\r
38 UInt64 totalInSize;\r
39 UInt64 totalOutSize;\r
40 ICompressProgress *progress;\r
41 SRes res;\r
42 CCriticalSection cs;\r
43 UInt64 inSizes[NUM_MT_CODER_THREADS_MAX];\r
44 UInt64 outSizes[NUM_MT_CODER_THREADS_MAX];\r
45} CMtProgress;\r
46\r
47SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize);\r
48\r
49struct _CMtCoder;\r
50\r
51typedef struct\r
52{\r
53 struct _CMtCoder *mtCoder;\r
54 Byte *outBuf;\r
55 size_t outBufSize;\r
56 Byte *inBuf;\r
57 size_t inBufSize;\r
58 unsigned index;\r
59 CLoopThread thread;\r
60\r
61 Bool stopReading;\r
62 Bool stopWriting;\r
63 CAutoResetEvent canRead;\r
64 CAutoResetEvent canWrite;\r
65} CMtThread;\r
66\r
67typedef struct\r
68{\r
69 SRes (*Code)(void *p, unsigned index, Byte *dest, size_t *destSize,\r
70 const Byte *src, size_t srcSize, int finished);\r
71} IMtCoderCallback;\r
72\r
73typedef struct _CMtCoder\r
74{\r
75 size_t blockSize;\r
76 size_t destBlockSize;\r
77 unsigned numThreads;\r
78 \r
79 ISeqInStream *inStream;\r
80 ISeqOutStream *outStream;\r
81 ICompressProgress *progress;\r
82 ISzAlloc *alloc;\r
83\r
84 IMtCoderCallback *mtCallback;\r
85 CCriticalSection cs;\r
86 SRes res;\r
87\r
88 CMtProgress mtProgress;\r
89 CMtThread threads[NUM_MT_CODER_THREADS_MAX];\r
90} CMtCoder;\r
91\r
92void MtCoder_Construct(CMtCoder* p);\r
93void MtCoder_Destruct(CMtCoder* p);\r
94SRes MtCoder_Code(CMtCoder *p);\r
95\r
96EXTERN_C_END\r
97\r
98#endif\r