aboutsummaryrefslogtreecommitdiff
path: root/C/Lzma2DecMt.c
diff options
context:
space:
mode:
Diffstat (limited to 'C/Lzma2DecMt.c')
-rw-r--r--C/Lzma2DecMt.c155
1 files changed, 80 insertions, 75 deletions
diff --git a/C/Lzma2DecMt.c b/C/Lzma2DecMt.c
index 9f1dc52..4bc4dde 100644
--- a/C/Lzma2DecMt.c
+++ b/C/Lzma2DecMt.c
@@ -1,44 +1,44 @@
1/* Lzma2DecMt.c -- LZMA2 Decoder Multi-thread 1/* Lzma2DecMt.c -- LZMA2 Decoder Multi-thread
22021-04-01 : Igor Pavlov : Public domain */ 22023-04-13 : Igor Pavlov : Public domain */
3 3
4#include "Precomp.h" 4#include "Precomp.h"
5 5
6// #define SHOW_DEBUG_INFO 6// #define SHOW_DEBUG_INFO
7 7// #define Z7_ST
8// #define _7ZIP_ST
9 8
10#ifdef SHOW_DEBUG_INFO 9#ifdef SHOW_DEBUG_INFO
11#include <stdio.h> 10#include <stdio.h>
12#endif 11#endif
13 12
14#ifndef _7ZIP_ST
15#ifdef SHOW_DEBUG_INFO
16#define PRF(x) x
17#else
18#define PRF(x)
19#endif
20#define PRF_STR(s) PRF(printf("\n" s "\n"))
21#define PRF_STR_INT_2(s, d1, d2) PRF(printf("\n" s " %d %d\n", (unsigned)d1, (unsigned)d2))
22#endif
23
24#include "Alloc.h" 13#include "Alloc.h"
25 14
26#include "Lzma2Dec.h" 15#include "Lzma2Dec.h"
27#include "Lzma2DecMt.h" 16#include "Lzma2DecMt.h"
28 17
29#ifndef _7ZIP_ST 18#ifndef Z7_ST
30#include "MtDec.h" 19#include "MtDec.h"
31 20
32#define LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT (1 << 28) 21#define LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT (1 << 28)
33#endif 22#endif
34 23
35 24
25#ifndef Z7_ST
26#ifdef SHOW_DEBUG_INFO
27#define PRF(x) x
28#else
29#define PRF(x)
30#endif
31#define PRF_STR(s) PRF(printf("\n" s "\n");)
32#define PRF_STR_INT_2(s, d1, d2) PRF(printf("\n" s " %d %d\n", (unsigned)d1, (unsigned)d2);)
33#endif
34
35
36void Lzma2DecMtProps_Init(CLzma2DecMtProps *p) 36void Lzma2DecMtProps_Init(CLzma2DecMtProps *p)
37{ 37{
38 p->inBufSize_ST = 1 << 20; 38 p->inBufSize_ST = 1 << 20;
39 p->outStep_ST = 1 << 20; 39 p->outStep_ST = 1 << 20;
40 40
41 #ifndef _7ZIP_ST 41 #ifndef Z7_ST
42 p->numThreads = 1; 42 p->numThreads = 1;
43 p->inBufSize_MT = 1 << 18; 43 p->inBufSize_MT = 1 << 18;
44 p->outBlockMax = LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT; 44 p->outBlockMax = LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT;
@@ -48,7 +48,7 @@ void Lzma2DecMtProps_Init(CLzma2DecMtProps *p)
48 48
49 49
50 50
51#ifndef _7ZIP_ST 51#ifndef Z7_ST
52 52
53/* ---------- CLzma2DecMtThread ---------- */ 53/* ---------- CLzma2DecMtThread ---------- */
54 54
@@ -81,7 +81,7 @@ typedef struct
81 81
82/* ---------- CLzma2DecMt ---------- */ 82/* ---------- CLzma2DecMt ---------- */
83 83
84typedef struct 84struct CLzma2DecMt
85{ 85{
86 // ISzAllocPtr alloc; 86 // ISzAllocPtr alloc;
87 ISzAllocPtr allocMid; 87 ISzAllocPtr allocMid;
@@ -90,9 +90,9 @@ typedef struct
90 CLzma2DecMtProps props; 90 CLzma2DecMtProps props;
91 Byte prop; 91 Byte prop;
92 92
93 ISeqInStream *inStream; 93 ISeqInStreamPtr inStream;
94 ISeqOutStream *outStream; 94 ISeqOutStreamPtr outStream;
95 ICompressProgress *progress; 95 ICompressProgressPtr progress;
96 96
97 BoolInt finishMode; 97 BoolInt finishMode;
98 BoolInt outSize_Defined; 98 BoolInt outSize_Defined;
@@ -111,14 +111,13 @@ typedef struct
111 size_t inPos; 111 size_t inPos;
112 size_t inLim; 112 size_t inLim;
113 113
114 #ifndef _7ZIP_ST 114 #ifndef Z7_ST
115 UInt64 outProcessed_Parse; 115 UInt64 outProcessed_Parse;
116 BoolInt mtc_WasConstructed; 116 BoolInt mtc_WasConstructed;
117 CMtDec mtc; 117 CMtDec mtc;
118 CLzma2DecMtThread coders[MTDEC__THREADS_MAX]; 118 CLzma2DecMtThread coders[MTDEC_THREADS_MAX];
119 #endif 119 #endif
120 120};
121} CLzma2DecMt;
122 121
123 122
124 123
@@ -142,11 +141,11 @@ CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid)
142 141
143 // Lzma2DecMtProps_Init(&p->props); 142 // Lzma2DecMtProps_Init(&p->props);
144 143
145 #ifndef _7ZIP_ST 144 #ifndef Z7_ST
146 p->mtc_WasConstructed = False; 145 p->mtc_WasConstructed = False;
147 { 146 {
148 unsigned i; 147 unsigned i;
149 for (i = 0; i < MTDEC__THREADS_MAX; i++) 148 for (i = 0; i < MTDEC_THREADS_MAX; i++)
150 { 149 {
151 CLzma2DecMtThread *t = &p->coders[i]; 150 CLzma2DecMtThread *t = &p->coders[i];
152 t->dec_created = False; 151 t->dec_created = False;
@@ -156,16 +155,16 @@ CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid)
156 } 155 }
157 #endif 156 #endif
158 157
159 return p; 158 return (CLzma2DecMtHandle)(void *)p;
160} 159}
161 160
162 161
163#ifndef _7ZIP_ST 162#ifndef Z7_ST
164 163
165static void Lzma2DecMt_FreeOutBufs(CLzma2DecMt *p) 164static void Lzma2DecMt_FreeOutBufs(CLzma2DecMt *p)
166{ 165{
167 unsigned i; 166 unsigned i;
168 for (i = 0; i < MTDEC__THREADS_MAX; i++) 167 for (i = 0; i < MTDEC_THREADS_MAX; i++)
169 { 168 {
170 CLzma2DecMtThread *t = &p->coders[i]; 169 CLzma2DecMtThread *t = &p->coders[i];
171 if (t->outBuf) 170 if (t->outBuf)
@@ -196,13 +195,15 @@ static void Lzma2DecMt_FreeSt(CLzma2DecMt *p)
196} 195}
197 196
198 197
199void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp) 198// #define GET_CLzma2DecMt_p CLzma2DecMt *p = (CLzma2DecMt *)(void *)pp;
199
200void Lzma2DecMt_Destroy(CLzma2DecMtHandle p)
200{ 201{
201 CLzma2DecMt *p = (CLzma2DecMt *)pp; 202 // GET_CLzma2DecMt_p
202 203
203 Lzma2DecMt_FreeSt(p); 204 Lzma2DecMt_FreeSt(p);
204 205
205 #ifndef _7ZIP_ST 206 #ifndef Z7_ST
206 207
207 if (p->mtc_WasConstructed) 208 if (p->mtc_WasConstructed)
208 { 209 {
@@ -211,7 +212,7 @@ void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp)
211 } 212 }
212 { 213 {
213 unsigned i; 214 unsigned i;
214 for (i = 0; i < MTDEC__THREADS_MAX; i++) 215 for (i = 0; i < MTDEC_THREADS_MAX; i++)
215 { 216 {
216 CLzma2DecMtThread *t = &p->coders[i]; 217 CLzma2DecMtThread *t = &p->coders[i];
217 if (t->dec_created) 218 if (t->dec_created)
@@ -226,19 +227,19 @@ void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp)
226 227
227 #endif 228 #endif
228 229
229 ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); 230 ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, p);
230} 231}
231 232
232 233
233 234
234#ifndef _7ZIP_ST 235#ifndef Z7_ST
235 236
236static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) 237static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc)
237{ 238{
238 CLzma2DecMt *me = (CLzma2DecMt *)obj; 239 CLzma2DecMt *me = (CLzma2DecMt *)obj;
239 CLzma2DecMtThread *t = &me->coders[coderIndex]; 240 CLzma2DecMtThread *t = &me->coders[coderIndex];
240 241
241 PRF_STR_INT_2("Parse", coderIndex, cc->srcSize); 242 PRF_STR_INT_2("Parse", coderIndex, cc->srcSize)
242 243
243 cc->state = MTDEC_PARSE_CONTINUE; 244 cc->state = MTDEC_PARSE_CONTINUE;
244 245
@@ -246,7 +247,7 @@ static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCa
246 { 247 {
247 if (!t->dec_created) 248 if (!t->dec_created)
248 { 249 {
249 Lzma2Dec_Construct(&t->dec); 250 Lzma2Dec_CONSTRUCT(&t->dec)
250 t->dec_created = True; 251 t->dec_created = True;
251 AlignOffsetAlloc_CreateVTable(&t->alloc); 252 AlignOffsetAlloc_CreateVTable(&t->alloc);
252 { 253 {
@@ -297,7 +298,7 @@ static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCa
297 // that must be finished at position <= outBlockMax. 298 // that must be finished at position <= outBlockMax.
298 299
299 { 300 {
300 const SizeT srcOrig = cc->srcSize; 301 const size_t srcOrig = cc->srcSize;
301 SizeT srcSize_Point = 0; 302 SizeT srcSize_Point = 0;
302 SizeT dicPos_Point = 0; 303 SizeT dicPos_Point = 0;
303 304
@@ -306,10 +307,10 @@ static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCa
306 307
307 for (;;) 308 for (;;)
308 { 309 {
309 SizeT srcCur = srcOrig - cc->srcSize; 310 SizeT srcCur = (SizeT)(srcOrig - cc->srcSize);
310 311
311 status = Lzma2Dec_Parse(&t->dec, 312 status = Lzma2Dec_Parse(&t->dec,
312 limit - t->dec.decoder.dicPos, 313 (SizeT)limit - t->dec.decoder.dicPos,
313 cc->src + cc->srcSize, &srcCur, 314 cc->src + cc->srcSize, &srcCur,
314 checkFinishBlock); 315 checkFinishBlock);
315 316
@@ -333,7 +334,7 @@ static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCa
333 if (t->dec.decoder.dicPos >= (1 << 14)) 334 if (t->dec.decoder.dicPos >= (1 << 14))
334 break; 335 break;
335 dicPos_Point = t->dec.decoder.dicPos; 336 dicPos_Point = t->dec.decoder.dicPos;
336 srcSize_Point = cc->srcSize; 337 srcSize_Point = (SizeT)cc->srcSize;
337 continue; 338 continue;
338 } 339 }
339 340
@@ -391,7 +392,7 @@ static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCa
391 if (unpackRem != 0) 392 if (unpackRem != 0)
392 { 393 {
393 /* we also reserve space for max possible number of output bytes of current LZMA chunk */ 394 /* we also reserve space for max possible number of output bytes of current LZMA chunk */
394 SizeT rem = limit - dicPos; 395 size_t rem = limit - dicPos;
395 if (rem > unpackRem) 396 if (rem > unpackRem)
396 rem = unpackRem; 397 rem = unpackRem;
397 dicPos += rem; 398 dicPos += rem;
@@ -444,7 +445,7 @@ static SRes Lzma2DecMt_MtCallback_PreCode(void *pp, unsigned coderIndex)
444 } 445 }
445 446
446 t->dec.decoder.dic = dest; 447 t->dec.decoder.dic = dest;
447 t->dec.decoder.dicBufSize = t->outPreSize; 448 t->dec.decoder.dicBufSize = (SizeT)t->outPreSize;
448 449
449 t->needInit = True; 450 t->needInit = True;
450 451
@@ -462,7 +463,7 @@ static SRes Lzma2DecMt_MtCallback_Code(void *pp, unsigned coderIndex,
462 463
463 UNUSED_VAR(srcFinished) 464 UNUSED_VAR(srcFinished)
464 465
465 PRF_STR_INT_2("Code", coderIndex, srcSize); 466 PRF_STR_INT_2("Code", coderIndex, srcSize)
466 467
467 *inCodePos = t->inCodeSize; 468 *inCodePos = t->inCodeSize;
468 *outCodePos = 0; 469 *outCodePos = 0;
@@ -476,13 +477,13 @@ static SRes Lzma2DecMt_MtCallback_Code(void *pp, unsigned coderIndex,
476 477
477 { 478 {
478 ELzmaStatus status; 479 ELzmaStatus status;
479 size_t srcProcessed = srcSize; 480 SizeT srcProcessed = (SizeT)srcSize;
480 BoolInt blockWasFinished = 481 BoolInt blockWasFinished =
481 ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK 482 ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK
482 || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK); 483 || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK);
483 484
484 SRes res = Lzma2Dec_DecodeToDic(&t->dec, 485 SRes res = Lzma2Dec_DecodeToDic(&t->dec,
485 t->outPreSize, 486 (SizeT)t->outPreSize,
486 src, &srcProcessed, 487 src, &srcProcessed,
487 blockWasFinished ? LZMA_FINISH_END : LZMA_FINISH_ANY, 488 blockWasFinished ? LZMA_FINISH_END : LZMA_FINISH_ANY,
488 &status); 489 &status);
@@ -540,7 +541,7 @@ static SRes Lzma2DecMt_MtCallback_Write(void *pp, unsigned coderIndex,
540 UNUSED_VAR(srcSize) 541 UNUSED_VAR(srcSize)
541 UNUSED_VAR(isCross) 542 UNUSED_VAR(isCross)
542 543
543 PRF_STR_INT_2("Write", coderIndex, srcSize); 544 PRF_STR_INT_2("Write", coderIndex, srcSize)
544 545
545 *needContinue = False; 546 *needContinue = False;
546 *canRecode = True; 547 *canRecode = True;
@@ -588,7 +589,7 @@ static SRes Lzma2DecMt_MtCallback_Write(void *pp, unsigned coderIndex,
588 *needContinue = needContinue2; 589 *needContinue = needContinue2;
589 return SZ_OK; 590 return SZ_OK;
590 } 591 }
591 RINOK(MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0)); 592 RINOK(MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0))
592 } 593 }
593 } 594 }
594 595
@@ -611,11 +612,11 @@ static SRes Lzma2Dec_Prepare_ST(CLzma2DecMt *p)
611{ 612{
612 if (!p->dec_created) 613 if (!p->dec_created)
613 { 614 {
614 Lzma2Dec_Construct(&p->dec); 615 Lzma2Dec_CONSTRUCT(&p->dec)
615 p->dec_created = True; 616 p->dec_created = True;
616 } 617 }
617 618
618 RINOK(Lzma2Dec_Allocate(&p->dec, p->prop, &p->alignOffsetAlloc.vt)); 619 RINOK(Lzma2Dec_Allocate(&p->dec, p->prop, &p->alignOffsetAlloc.vt))
619 620
620 if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) 621 if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST)
621 { 622 {
@@ -634,7 +635,7 @@ static SRes Lzma2Dec_Prepare_ST(CLzma2DecMt *p)
634 635
635 636
636static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p 637static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
637 #ifndef _7ZIP_ST 638 #ifndef Z7_ST
638 , BoolInt tMode 639 , BoolInt tMode
639 #endif 640 #endif
640 ) 641 )
@@ -646,7 +647,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
646 647
647 CLzma2Dec *dec; 648 CLzma2Dec *dec;
648 649
649 #ifndef _7ZIP_ST 650 #ifndef Z7_ST
650 if (tMode) 651 if (tMode)
651 { 652 {
652 Lzma2DecMt_FreeOutBufs(p); 653 Lzma2DecMt_FreeOutBufs(p);
@@ -654,7 +655,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
654 } 655 }
655 #endif 656 #endif
656 657
657 RINOK(Lzma2Dec_Prepare_ST(p)); 658 RINOK(Lzma2Dec_Prepare_ST(p))
658 659
659 dec = &p->dec; 660 dec = &p->dec;
660 661
@@ -681,7 +682,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
681 682
682 if (inPos == inLim) 683 if (inPos == inLim)
683 { 684 {
684 #ifndef _7ZIP_ST 685 #ifndef Z7_ST
685 if (tMode) 686 if (tMode)
686 { 687 {
687 inData = MtDec_Read(&p->mtc, &inLim); 688 inData = MtDec_Read(&p->mtc, &inLim);
@@ -710,7 +711,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
710 { 711 {
711 SizeT next = dec->decoder.dicBufSize; 712 SizeT next = dec->decoder.dicBufSize;
712 if (next - wrPos > p->props.outStep_ST) 713 if (next - wrPos > p->props.outStep_ST)
713 next = wrPos + p->props.outStep_ST; 714 next = wrPos + (SizeT)p->props.outStep_ST;
714 size = next - dicPos; 715 size = next - dicPos;
715 } 716 }
716 717
@@ -726,7 +727,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
726 } 727 }
727 } 728 }
728 729
729 inProcessed = inLim - inPos; 730 inProcessed = (SizeT)(inLim - inPos);
730 731
731 res = Lzma2Dec_DecodeToDic(dec, dicPos + size, inData + inPos, &inProcessed, finishMode, &status); 732 res = Lzma2Dec_DecodeToDic(dec, dicPos + size, inData + inPos, &inProcessed, finishMode, &status);
732 733
@@ -755,7 +756,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
755 dec->decoder.dicPos = 0; 756 dec->decoder.dicPos = 0;
756 wrPos = dec->decoder.dicPos; 757 wrPos = dec->decoder.dicPos;
757 758
758 RINOK(res2); 759 RINOK(res2)
759 760
760 if (needStop) 761 if (needStop)
761 { 762 {
@@ -788,7 +789,7 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
788 UInt64 outDelta = p->outProcessed - outPrev; 789 UInt64 outDelta = p->outProcessed - outPrev;
789 if (inDelta >= (1 << 22) || outDelta >= (1 << 22)) 790 if (inDelta >= (1 << 22) || outDelta >= (1 << 22))
790 { 791 {
791 RINOK(ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed)); 792 RINOK(ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed))
792 inPrev = p->inProcessed; 793 inPrev = p->inProcessed;
793 outPrev = p->outProcessed; 794 outPrev = p->outProcessed;
794 } 795 }
@@ -798,20 +799,20 @@ static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p
798 799
799 800
800 801
801SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp, 802SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p,
802 Byte prop, 803 Byte prop,
803 const CLzma2DecMtProps *props, 804 const CLzma2DecMtProps *props,
804 ISeqOutStream *outStream, const UInt64 *outDataSize, int finishMode, 805 ISeqOutStreamPtr outStream, const UInt64 *outDataSize, int finishMode,
805 // Byte *outBuf, size_t *outBufSize, 806 // Byte *outBuf, size_t *outBufSize,
806 ISeqInStream *inStream, 807 ISeqInStreamPtr inStream,
807 // const Byte *inData, size_t inDataSize, 808 // const Byte *inData, size_t inDataSize,
808 UInt64 *inProcessed, 809 UInt64 *inProcessed,
809 // UInt64 *outProcessed, 810 // UInt64 *outProcessed,
810 int *isMT, 811 int *isMT,
811 ICompressProgress *progress) 812 ICompressProgressPtr progress)
812{ 813{
813 CLzma2DecMt *p = (CLzma2DecMt *)pp; 814 // GET_CLzma2DecMt_p
814 #ifndef _7ZIP_ST 815 #ifndef Z7_ST
815 BoolInt tMode; 816 BoolInt tMode;
816 #endif 817 #endif
817 818
@@ -845,7 +846,7 @@ SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp,
845 *isMT = False; 846 *isMT = False;
846 847
847 848
848 #ifndef _7ZIP_ST 849 #ifndef Z7_ST
849 850
850 tMode = False; 851 tMode = False;
851 852
@@ -939,7 +940,7 @@ SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp,
939 p->readWasFinished = p->mtc.readWasFinished; 940 p->readWasFinished = p->mtc.readWasFinished;
940 p->inProcessed = p->mtc.inProcessed; 941 p->inProcessed = p->mtc.inProcessed;
941 942
942 PRF_STR("----- decoding ST -----"); 943 PRF_STR("----- decoding ST -----")
943 } 944 }
944 } 945 }
945 946
@@ -950,7 +951,7 @@ SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp,
950 951
951 { 952 {
952 SRes res = Lzma2Dec_Decode_ST(p 953 SRes res = Lzma2Dec_Decode_ST(p
953 #ifndef _7ZIP_ST 954 #ifndef Z7_ST
954 , tMode 955 , tMode
955 #endif 956 #endif
956 ); 957 );
@@ -967,7 +968,7 @@ SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp,
967 res = p->readRes; 968 res = p->readRes;
968 969
969 /* 970 /*
970 #ifndef _7ZIP_ST 971 #ifndef Z7_ST
971 if (res == SZ_OK && tMode && p->mtc.parseRes != SZ_OK) 972 if (res == SZ_OK && tMode && p->mtc.parseRes != SZ_OK)
972 res = p->mtc.parseRes; 973 res = p->mtc.parseRes;
973 #endif 974 #endif
@@ -980,13 +981,13 @@ SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp,
980 981
981/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ 982/* ---------- Read from CLzma2DecMtHandle Interface ---------- */
982 983
983SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, 984SRes Lzma2DecMt_Init(CLzma2DecMtHandle p,
984 Byte prop, 985 Byte prop,
985 const CLzma2DecMtProps *props, 986 const CLzma2DecMtProps *props,
986 const UInt64 *outDataSize, int finishMode, 987 const UInt64 *outDataSize, int finishMode,
987 ISeqInStream *inStream) 988 ISeqInStreamPtr inStream)
988{ 989{
989 CLzma2DecMt *p = (CLzma2DecMt *)pp; 990 // GET_CLzma2DecMt_p
990 991
991 if (prop > 40) 992 if (prop > 40)
992 return SZ_ERROR_UNSUPPORTED; 993 return SZ_ERROR_UNSUPPORTED;
@@ -1015,11 +1016,11 @@ SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp,
1015} 1016}
1016 1017
1017 1018
1018SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, 1019SRes Lzma2DecMt_Read(CLzma2DecMtHandle p,
1019 Byte *data, size_t *outSize, 1020 Byte *data, size_t *outSize,
1020 UInt64 *inStreamProcessed) 1021 UInt64 *inStreamProcessed)
1021{ 1022{
1022 CLzma2DecMt *p = (CLzma2DecMt *)pp; 1023 // GET_CLzma2DecMt_p
1023 ELzmaFinishMode finishMode; 1024 ELzmaFinishMode finishMode;
1024 SRes readRes; 1025 SRes readRes;
1025 size_t size = *outSize; 1026 size_t size = *outSize;
@@ -1055,8 +1056,8 @@ SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp,
1055 readRes = ISeqInStream_Read(p->inStream, p->inBuf, &p->inLim); 1056 readRes = ISeqInStream_Read(p->inStream, p->inBuf, &p->inLim);
1056 } 1057 }
1057 1058
1058 inCur = p->inLim - p->inPos; 1059 inCur = (SizeT)(p->inLim - p->inPos);
1059 outCur = size; 1060 outCur = (SizeT)size;
1060 1061
1061 res = Lzma2Dec_DecodeToBuf(&p->dec, data, &outCur, 1062 res = Lzma2Dec_DecodeToBuf(&p->dec, data, &outCur,
1062 p->inBuf + p->inPos, &inCur, finishMode, &status); 1063 p->inBuf + p->inPos, &inCur, finishMode, &status);
@@ -1088,3 +1089,7 @@ SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp,
1088 return readRes; 1089 return readRes;
1089 } 1090 }
1090} 1091}
1092
1093#undef PRF
1094#undef PRF_STR
1095#undef PRF_STR_INT_2