1370b324cSopenharmony_ci/* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread
2370b324cSopenharmony_ci2023-04-13 : Igor Pavlov : Public domain */
3370b324cSopenharmony_ci
4370b324cSopenharmony_ci#ifndef ZIP7_INC_LZMA2_DEC_MT_H
5370b324cSopenharmony_ci#define ZIP7_INC_LZMA2_DEC_MT_H
6370b324cSopenharmony_ci
7370b324cSopenharmony_ci#include "7zTypes.h"
8370b324cSopenharmony_ci
9370b324cSopenharmony_ciEXTERN_C_BEGIN
10370b324cSopenharmony_ci
11370b324cSopenharmony_citypedef struct
12370b324cSopenharmony_ci{
13370b324cSopenharmony_ci  size_t inBufSize_ST;
14370b324cSopenharmony_ci  size_t outStep_ST;
15370b324cSopenharmony_ci
16370b324cSopenharmony_ci  #ifndef Z7_ST
17370b324cSopenharmony_ci  unsigned numThreads;
18370b324cSopenharmony_ci  size_t inBufSize_MT;
19370b324cSopenharmony_ci  size_t outBlockMax;
20370b324cSopenharmony_ci  size_t inBlockMax;
21370b324cSopenharmony_ci  #endif
22370b324cSopenharmony_ci} CLzma2DecMtProps;
23370b324cSopenharmony_ci
24370b324cSopenharmony_ci/* init to single-thread mode */
25370b324cSopenharmony_civoid Lzma2DecMtProps_Init(CLzma2DecMtProps *p);
26370b324cSopenharmony_ci
27370b324cSopenharmony_ci
28370b324cSopenharmony_ci/* ---------- CLzma2DecMtHandle Interface ---------- */
29370b324cSopenharmony_ci
30370b324cSopenharmony_ci/* Lzma2DecMt_ * functions can return the following exit codes:
31370b324cSopenharmony_ciSRes:
32370b324cSopenharmony_ci  SZ_OK           - OK
33370b324cSopenharmony_ci  SZ_ERROR_MEM    - Memory allocation error
34370b324cSopenharmony_ci  SZ_ERROR_PARAM  - Incorrect paramater in props
35370b324cSopenharmony_ci  SZ_ERROR_WRITE  - ISeqOutStream write callback error
36370b324cSopenharmony_ci  // SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
37370b324cSopenharmony_ci  SZ_ERROR_PROGRESS - some break from progress callback
38370b324cSopenharmony_ci  SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
39370b324cSopenharmony_ci*/
40370b324cSopenharmony_ci
41370b324cSopenharmony_citypedef struct CLzma2DecMt CLzma2DecMt;
42370b324cSopenharmony_citypedef CLzma2DecMt * CLzma2DecMtHandle;
43370b324cSopenharmony_ci// Z7_DECLARE_HANDLE(CLzma2DecMtHandle)
44370b324cSopenharmony_ci
45370b324cSopenharmony_ciCLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid);
46370b324cSopenharmony_civoid Lzma2DecMt_Destroy(CLzma2DecMtHandle p);
47370b324cSopenharmony_ci
48370b324cSopenharmony_ciSRes Lzma2DecMt_Decode(CLzma2DecMtHandle p,
49370b324cSopenharmony_ci    Byte prop,
50370b324cSopenharmony_ci    const CLzma2DecMtProps *props,
51370b324cSopenharmony_ci    ISeqOutStreamPtr outStream,
52370b324cSopenharmony_ci    const UInt64 *outDataSize, // NULL means undefined
53370b324cSopenharmony_ci    int finishMode,            // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished
54370b324cSopenharmony_ci    // Byte *outBuf, size_t *outBufSize,
55370b324cSopenharmony_ci    ISeqInStreamPtr inStream,
56370b324cSopenharmony_ci    // const Byte *inData, size_t inDataSize,
57370b324cSopenharmony_ci
58370b324cSopenharmony_ci    // out variables:
59370b324cSopenharmony_ci    UInt64 *inProcessed,
60370b324cSopenharmony_ci    int *isMT,  /* out: (*isMT == 0), if single thread decoding was used */
61370b324cSopenharmony_ci
62370b324cSopenharmony_ci    // UInt64 *outProcessed,
63370b324cSopenharmony_ci    ICompressProgressPtr progress);
64370b324cSopenharmony_ci
65370b324cSopenharmony_ci
66370b324cSopenharmony_ci/* ---------- Read from CLzma2DecMtHandle Interface ---------- */
67370b324cSopenharmony_ci
68370b324cSopenharmony_ciSRes Lzma2DecMt_Init(CLzma2DecMtHandle pp,
69370b324cSopenharmony_ci    Byte prop,
70370b324cSopenharmony_ci    const CLzma2DecMtProps *props,
71370b324cSopenharmony_ci    const UInt64 *outDataSize, int finishMode,
72370b324cSopenharmony_ci    ISeqInStreamPtr inStream);
73370b324cSopenharmony_ci
74370b324cSopenharmony_ciSRes Lzma2DecMt_Read(CLzma2DecMtHandle pp,
75370b324cSopenharmony_ci    Byte *data, size_t *outSize,
76370b324cSopenharmony_ci    UInt64 *inStreamProcessed);
77370b324cSopenharmony_ci
78370b324cSopenharmony_ci
79370b324cSopenharmony_ciEXTERN_C_END
80370b324cSopenharmony_ci
81370b324cSopenharmony_ci#endif
82