• Home
  • Raw
  • Download

Lines Matching +full:- +full:p

1 /* XzDec.c -- Xz Decode
2 2019-02-02 : Igor Pavlov : Public domain */
54 unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value) in Xz_ReadVarInt() argument
62 Byte b = p[i]; in Xz_ReadVarInt()
70 /* ---------- BraState ---------- */
98 CBraState *p = ((CBraState *)pp); in BraState_SetProps() local
100 p->ip = 0; in BraState_SetProps()
101 if (p->methodId == XZ_ID_Delta) in BraState_SetProps()
105 p->delta = (unsigned)props[0] + 1; in BraState_SetProps()
112 switch (p->methodId) in BraState_SetProps()
129 p->ip = v; in BraState_SetProps()
139 CBraState *p = ((CBraState *)pp); in BraState_Init() local
140 p->bufPos = p->bufConv = p->bufTotal = 0; in BraState_Init()
141 x86_Convert_Init(p->x86State); in BraState_Init()
142 if (p->methodId == XZ_ID_Delta) in BraState_Init()
143 Delta_Init(p->deltaState); in BraState_Init()
147 #define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: size = isa ## _Convert(data, size, p->ip, p->encodeM…
151 CBraState *p = ((CBraState *)pp); in BraState_Filter() local
152 switch (p->methodId) in BraState_Filter()
155 if (p->encodeMode) in BraState_Filter()
156 Delta_Encode(p->deltaState, p->delta, data, size); in BraState_Filter()
158 Delta_Decode(p->deltaState, p->delta, data, size); in BraState_Filter()
161 size = x86_Convert(data, size, p->ip, &p->x86State, p->encodeMode); in BraState_Filter()
169 p->ip += (UInt32)size; in BraState_Filter()
181 CBraState *p = ((CBraState *)pp); in BraState_Code2() local
193 if (p->bufPos != p->bufConv) in BraState_Code2()
195 size_t size = p->bufConv - p->bufPos; in BraState_Code2()
198 memcpy(dest, p->buf + p->bufPos, size); in BraState_Code2()
199 p->bufPos += size; in BraState_Code2()
202 destRem -= size; in BraState_Code2()
206 p->bufTotal -= p->bufPos; in BraState_Code2()
207 memmove(p->buf, p->buf + p->bufPos, p->bufTotal); in BraState_Code2()
208 p->bufPos = 0; in BraState_Code2()
209 p->bufConv = 0; in BraState_Code2()
211 size_t size = BRA_BUF_SIZE - p->bufTotal; in BraState_Code2()
214 memcpy(p->buf + p->bufTotal, src, size); in BraState_Code2()
217 srcRem -= size; in BraState_Code2()
218 p->bufTotal += size; in BraState_Code2()
220 if (p->bufTotal == 0) in BraState_Code2()
223 p->bufConv = BraState_Filter(pp, p->buf, p->bufTotal); in BraState_Code2()
225 if (p->bufConv == 0) in BraState_Code2()
229 p->bufConv = p->bufTotal; in BraState_Code2()
233 if (p->bufTotal == p->bufPos && srcRem == 0 && srcWasFinished) in BraState_Code2()
243 SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc) in BraState_SetFromMethod() argument
248 decoder = (CBraState *)p->p; in BraState_SetFromMethod()
254 p->p = decoder; in BraState_SetFromMethod()
255 p->Free = BraState_Free; in BraState_SetFromMethod()
256 p->SetProps = BraState_SetProps; in BraState_SetFromMethod()
257 p->Init = BraState_Init; in BraState_SetFromMethod()
258 p->Code2 = BraState_Code2; in BraState_SetFromMethod()
259 p->Filter = BraState_Filter; in BraState_SetFromMethod()
261 decoder->methodId = (UInt32)id; in BraState_SetFromMethod()
262 decoder->encodeMode = encodeMode; in BraState_SetFromMethod()
268 /* ---------- SbState ---------- */
274 CSbDec *p = (CSbDec *)pp; in SbState_Free() local
275 SbDec_Free(p); in SbState_Free()
297 CSbDec *p = (CSbDec *)pp; in SbState_Code2() local
300 p->dest = dest; in SbState_Code2()
301 p->destLen = *destLen; in SbState_Code2()
302 p->src = src; in SbState_Code2()
303 p->srcLen = *srcLen; in SbState_Code2()
304 p->finish = finishMode; /* change it */ in SbState_Code2()
306 *destLen -= p->destLen; in SbState_Code2()
307 *srcLen -= p->srcLen; in SbState_Code2()
315 static SRes SbState_SetFromMethod(IStateCoder *p, ISzAllocPtr alloc) in SbState_SetFromMethod() argument
317 CSbDec *decoder = (CSbDec *)p->p; in SbState_SetFromMethod()
323 p->p = decoder; in SbState_SetFromMethod()
324 p->Free = SbState_Free; in SbState_SetFromMethod()
325 p->SetProps = SbState_SetProps; in SbState_SetFromMethod()
326 p->Init = SbState_Init; in SbState_SetFromMethod()
327 p->Code2 = SbState_Code2; in SbState_SetFromMethod()
328 p->Filter = NULL; in SbState_SetFromMethod()
339 /* ---------- Lzma2 ---------- */
350 CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; in Lzma2State_Free() local
351 if (p->outBufMode) in Lzma2State_Free()
352 Lzma2Dec_FreeProbs(&p->decoder, alloc); in Lzma2State_Free()
354 Lzma2Dec_Free(&p->decoder, alloc); in Lzma2State_Free()
363 CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; in Lzma2State_SetProps() local
364 if (p->outBufMode) in Lzma2State_SetProps()
365 return Lzma2Dec_AllocateProbs(&p->decoder, props[0], alloc); in Lzma2State_SetProps()
367 return Lzma2Dec_Allocate(&p->decoder, props[0], alloc); in Lzma2State_SetProps()
373 Lzma2Dec_Init(&((CLzma2Dec_Spec *)pp)->decoder); in Lzma2State_Init()
379 Data is unpacked to (spec->decoder.decoder.dic) output buffer.
392 if (spec->outBufMode) in Lzma2State_Code2()
394 SizeT dicPos = spec->decoder.decoder.dicPos; in Lzma2State_Code2()
396 …res = Lzma2Dec_DecodeToDic(&spec->decoder, dicLimit, src, srcLen, (ELzmaFinishMode)finishMode, &st… in Lzma2State_Code2()
397 *destLen = spec->decoder.decoder.dicPos - dicPos; in Lzma2State_Code2()
400 …res = Lzma2Dec_DecodeToBuf(&spec->decoder, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode… in Lzma2State_Code2()
408 static SRes Lzma2State_SetFromMethod(IStateCoder *p, Byte *outBuf, size_t outBufSize, ISzAllocPtr a… in Lzma2State_SetFromMethod() argument
410 CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; in Lzma2State_SetFromMethod()
416 p->p = spec; in Lzma2State_SetFromMethod()
417 p->Free = Lzma2State_Free; in Lzma2State_SetFromMethod()
418 p->SetProps = Lzma2State_SetProps; in Lzma2State_SetFromMethod()
419 p->Init = Lzma2State_Init; in Lzma2State_SetFromMethod()
420 p->Code2 = Lzma2State_Code2; in Lzma2State_SetFromMethod()
421 p->Filter = NULL; in Lzma2State_SetFromMethod()
422 Lzma2Dec_Construct(&spec->decoder); in Lzma2State_SetFromMethod()
424 spec->outBufMode = False; in Lzma2State_SetFromMethod()
427 spec->outBufMode = True; in Lzma2State_SetFromMethod()
428 spec->decoder.decoder.dic = outBuf; in Lzma2State_SetFromMethod()
429 spec->decoder.decoder.dicBufSize = outBufSize; in Lzma2State_SetFromMethod()
435 static SRes Lzma2State_ResetOutBuf(IStateCoder *p, Byte *outBuf, size_t outBufSize) in Lzma2State_ResetOutBuf() argument
437 CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; in Lzma2State_ResetOutBuf()
438 if ((spec->outBufMode && !outBuf) || (!spec->outBufMode && outBuf)) in Lzma2State_ResetOutBuf()
442 spec->decoder.decoder.dic = outBuf; in Lzma2State_ResetOutBuf()
443 spec->decoder.decoder.dicBufSize = outBufSize; in Lzma2State_ResetOutBuf()
450 static void MixCoder_Construct(CMixCoder *p, ISzAllocPtr alloc) in MixCoder_Construct() argument
453 p->alloc = alloc; in MixCoder_Construct()
454 p->buf = NULL; in MixCoder_Construct()
455 p->numCoders = 0; in MixCoder_Construct()
457 p->outBufSize = 0; in MixCoder_Construct()
458 p->outBuf = NULL; in MixCoder_Construct()
459 // p->SingleBufMode = False; in MixCoder_Construct()
462 p->coders[i].p = NULL; in MixCoder_Construct()
466 static void MixCoder_Free(CMixCoder *p) in MixCoder_Free() argument
469 p->numCoders = 0; in MixCoder_Free()
472 IStateCoder *sc = &p->coders[i]; in MixCoder_Free()
473 if (sc->p) in MixCoder_Free()
475 sc->Free(sc->p, p->alloc); in MixCoder_Free()
476 sc->p = NULL; in MixCoder_Free()
479 if (p->buf) in MixCoder_Free()
481 ISzAlloc_Free(p->alloc, p->buf); in MixCoder_Free()
482 p->buf = NULL; /* 9.31: the BUG was fixed */ in MixCoder_Free()
486 static void MixCoder_Init(CMixCoder *p) in MixCoder_Init() argument
489 for (i = 0; i < MIXCODER_NUM_FILTERS_MAX - 1; i++) in MixCoder_Init()
491 p->size[i] = 0; in MixCoder_Init()
492 p->pos[i] = 0; in MixCoder_Init()
493 p->finished[i] = 0; in MixCoder_Init()
495 for (i = 0; i < p->numCoders; i++) in MixCoder_Init()
497 IStateCoder *coder = &p->coders[i]; in MixCoder_Init()
498 coder->Init(coder->p); in MixCoder_Init()
499 p->results[i] = SZ_OK; in MixCoder_Init()
501 p->outWritten = 0; in MixCoder_Init()
502 p->wasFinished = False; in MixCoder_Init()
503 p->res = SZ_OK; in MixCoder_Init()
504 p->status = CODER_STATUS_NOT_SPECIFIED; in MixCoder_Init()
508 static SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outBuf… in MixCoder_SetFromMethod() argument
510 IStateCoder *sc = &p->coders[coderIndex]; in MixCoder_SetFromMethod()
511 p->ids[coderIndex] = methodId; in MixCoder_SetFromMethod()
514 case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, outBuf, outBufSize, p->alloc); in MixCoder_SetFromMethod()
516 case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc); in MixCoder_SetFromMethod()
521 return BraState_SetFromMethod(sc, methodId, 0, p->alloc); in MixCoder_SetFromMethod()
525 static SRes MixCoder_ResetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outB… in MixCoder_ResetFromMethod() argument
527 IStateCoder *sc = &p->coders[coderIndex]; in MixCoder_ResetFromMethod()
538 if (destFinish) - then unpack data block is finished at (*destLen) position,
544 CODER_STATUS_NEEDS_MORE_INPUT - not implemented still
547 static SRes MixCoder_Code(CMixCoder *p, in MixCoder_Code() argument
558 if (p->wasFinished) in MixCoder_Code()
559 return p->res; in MixCoder_Code()
561 p->status = CODER_STATUS_NOT_FINISHED; in MixCoder_Code()
563 // if (p->SingleBufMode) in MixCoder_Code()
564 if (p->outBuf) in MixCoder_Code()
570 PRF_STR("------- MixCoder Single ----------"); in MixCoder_Code()
576 IStateCoder *coder = &p->coders[0]; in MixCoder_Code()
577 res = coder->Code2(coder->p, NULL, &destLen2, src, &srcLen2, srcWasFinished, finishMode, in MixCoder_Code()
579 &p->status); in MixCoder_Code()
580 wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); in MixCoder_Code()
583 p->res = res; in MixCoder_Code()
587 p->status = CODER_STATUS_FINISHED_WITH_MARK; in MixCoder_Code()
592 p->status = CODER_STATUS_NEEDS_MORE_INPUT; in MixCoder_Code()
599 p->outWritten += destLen2; in MixCoder_Code()
602 p->wasFinished = True; in MixCoder_Code()
604 if (p->numCoders == 1) in MixCoder_Code()
606 else if (p->wasFinished) in MixCoder_Code()
609 size_t processed = p->outWritten; in MixCoder_Code()
611 for (i = 1; i < p->numCoders; i++) in MixCoder_Code()
613 IStateCoder *coder = &p->coders[i]; in MixCoder_Code()
614 processed = coder->Filter(coder->p, p->outBuf, processed); in MixCoder_Code()
615 if (wasFinished || (destFinish && p->outWritten == destLenOrig)) in MixCoder_Code()
616 processed = p->outWritten; in MixCoder_Code()
626 if (p->numCoders != 1) in MixCoder_Code()
628 if (!p->buf) in MixCoder_Code()
630 p->buf = (Byte *)ISzAlloc_Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1)); in MixCoder_Code()
631 if (!p->buf) in MixCoder_Code()
645 p->status = CODER_STATUS_NOT_FINISHED; in MixCoder_Code()
647 if (p->numCoders == 1 && *destLen == destLenOrig && finishMode == LZMA_FINISH_ANY) in MixCoder_Code()
651 for (i = 0; i < p->numCoders; i++) in MixCoder_Code()
654 IStateCoder *coder = &p->coders[i]; in MixCoder_Code()
665 srcLen2 = srcLenOrig - *srcLen; in MixCoder_Code()
670 size_t k = i - 1; in MixCoder_Code()
671 src2 = p->buf + (CODER_BUF_SIZE * k) + p->pos[k]; in MixCoder_Code()
672 srcLen2 = p->size[k] - p->pos[k]; in MixCoder_Code()
673 srcFinished2 = p->finished[k]; in MixCoder_Code()
676 if (i == p->numCoders - 1) in MixCoder_Code()
679 destLen2 = destLenOrig - *destLen; in MixCoder_Code()
683 if (p->pos[i] != p->size[i]) in MixCoder_Code()
685 dest2 = p->buf + (CODER_BUF_SIZE * i); in MixCoder_Code()
691 if (p->results[i] != SZ_OK) in MixCoder_Code()
694 resMain = p->results[i]; in MixCoder_Code()
698 res = coder->Code2(coder->p, in MixCoder_Code()
707 p->results[i] = res; in MixCoder_Code()
717 if (p->numCoders == 1 && res == SZ_OK) in MixCoder_Code()
718 p->status = status2; in MixCoder_Code()
727 p->pos[(size_t)i - 1] += srcLen2; in MixCoder_Code()
729 if (i == p->numCoders - 1) in MixCoder_Code()
736 p->size[i] = destLen2; in MixCoder_Code()
737 p->pos[i] = 0; in MixCoder_Code()
738 p->finished[i] = encodingWasFinished; in MixCoder_Code()
748 p->status = CODER_STATUS_FINISHED_WITH_MARK; in MixCoder_Code()
755 SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf) in Xz_ParseHeader() argument
757 *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE); in Xz_ParseHeader()
761 return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED; in Xz_ParseHeader()
774 { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \
778 static BoolInt XzBlock_AreSupportedFilters(const CXzBlock *p) in XzBlock_AreSupportedFilters() argument
780 unsigned numFilters = XzBlock_GetNumFilters(p) - 1; in XzBlock_AreSupportedFilters()
783 const CXzFilter *f = &p->filters[numFilters]; in XzBlock_AreSupportedFilters()
784 if (f->id != XZ_ID_LZMA2 || f->propsSize != 1 || f->props[0] > 40) in XzBlock_AreSupportedFilters()
790 const CXzFilter *f = &p->filters[i]; in XzBlock_AreSupportedFilters()
791 if (f->id == XZ_ID_Delta) in XzBlock_AreSupportedFilters()
793 if (f->propsSize != 1) in XzBlock_AreSupportedFilters()
796 else if (f->id < XZ_ID_Delta in XzBlock_AreSupportedFilters()
797 || f->id > XZ_ID_SPARC in XzBlock_AreSupportedFilters()
798 || (f->propsSize != 0 && f->propsSize != 4)) in XzBlock_AreSupportedFilters()
805 SRes XzBlock_Parse(CXzBlock *p, const Byte *header) in XzBlock_Parse() argument
817 p->flags = header[pos++]; in XzBlock_Parse()
819 p->packSize = (UInt64)(Int64)-1; in XzBlock_Parse()
820 if (XzBlock_HasPackSize(p)) in XzBlock_Parse()
822 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize); in XzBlock_Parse()
823 if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63) in XzBlock_Parse()
827 p->unpackSize = (UInt64)(Int64)-1; in XzBlock_Parse()
828 if (XzBlock_HasUnpackSize(p)) in XzBlock_Parse()
829 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize); in XzBlock_Parse()
831 numFilters = XzBlock_GetNumFilters(p); in XzBlock_Parse()
834 CXzFilter *filter = p->filters + i; in XzBlock_Parse()
836 READ_VARINT_AND_CHECK(header, pos, headerSize, &filter->id); in XzBlock_Parse()
838 if (size > headerSize - pos || size > XZ_FILTER_PROPS_SIZE_MAX) in XzBlock_Parse()
840 filter->propsSize = (UInt32)size; in XzBlock_Parse()
841 memcpy(filter->props, header + pos, (size_t)size); in XzBlock_Parse()
845 printf("\nf[%u] = %2X: ", i, (unsigned)filter->id); in XzBlock_Parse()
849 printf(" %2X", filter->props[i]); in XzBlock_Parse()
854 if (XzBlock_HasUnsupportedFlags(p)) in XzBlock_Parse()
866 static SRes XzDecMix_Init(CMixCoder *p, const CXzBlock *block, Byte *outBuf, size_t outBufSize) in XzDecMix_Init() argument
872 if (numFilters == p->numCoders && ((p->outBuf && outBuf) || (!p->outBuf && !outBuf))) in XzDecMix_Init()
876 if (p->ids[i] != block->filters[numFilters - 1 - i].id) in XzDecMix_Init()
883 // p->SingleBufMode = (outBuf != NULL); in XzDecMix_Init()
884 p->outBuf = outBuf; in XzDecMix_Init()
885 p->outBufSize = outBufSize; in XzDecMix_Init()
887 // p->SingleBufMode = False; in XzDecMix_Init()
892 MixCoder_Free(p); in XzDecMix_Init()
895 … RINOK(MixCoder_SetFromMethod(p, i, block->filters[numFilters - 1 - i].id, outBuf, outBufSize)); in XzDecMix_Init()
897 p->numCoders = numFilters; in XzDecMix_Init()
901 RINOK(MixCoder_ResetFromMethod(p, 0, block->filters[numFilters - 1].id, outBuf, outBufSize)); in XzDecMix_Init()
906 const CXzFilter *f = &block->filters[numFilters - 1 - i]; in XzDecMix_Init()
907 IStateCoder *sc = &p->coders[i]; in XzDecMix_Init()
908 RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc)); in XzDecMix_Init()
911 MixCoder_Init(p); in XzDecMix_Init()
917 void XzUnpacker_Init(CXzUnpacker *p) in XzUnpacker_Init() argument
919 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Init()
920 p->pos = 0; in XzUnpacker_Init()
921 p->numStartedStreams = 0; in XzUnpacker_Init()
922 p->numFinishedStreams = 0; in XzUnpacker_Init()
923 p->numTotalBlocks = 0; in XzUnpacker_Init()
924 p->padSize = 0; in XzUnpacker_Init()
925 p->decodeOnlyOneBlock = 0; in XzUnpacker_Init()
927 p->parseMode = False; in XzUnpacker_Init()
928 p->decodeToStreamSignature = False; in XzUnpacker_Init()
930 // p->outBuf = NULL; in XzUnpacker_Init()
931 // p->outBufSize = 0; in XzUnpacker_Init()
932 p->outDataWritten = 0; in XzUnpacker_Init()
936 void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize) in XzUnpacker_SetOutBuf() argument
938 p->outBuf = outBuf; in XzUnpacker_SetOutBuf()
939 p->outBufSize = outBufSize; in XzUnpacker_SetOutBuf()
943 void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc) in XzUnpacker_Construct() argument
945 MixCoder_Construct(&p->decoder, alloc); in XzUnpacker_Construct()
946 p->outBuf = NULL; in XzUnpacker_Construct()
947 p->outBufSize = 0; in XzUnpacker_Construct()
948 XzUnpacker_Init(p); in XzUnpacker_Construct()
952 void XzUnpacker_Free(CXzUnpacker *p) in XzUnpacker_Free() argument
954 MixCoder_Free(&p->decoder); in XzUnpacker_Free()
958 void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p) in XzUnpacker_PrepareToRandomBlockDecoding() argument
960 p->indexSize = 0; in XzUnpacker_PrepareToRandomBlockDecoding()
961 p->numBlocks = 0; in XzUnpacker_PrepareToRandomBlockDecoding()
962 Sha256_Init(&p->sha); in XzUnpacker_PrepareToRandomBlockDecoding()
963 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_PrepareToRandomBlockDecoding()
964 p->pos = 0; in XzUnpacker_PrepareToRandomBlockDecoding()
965 p->decodeOnlyOneBlock = 1; in XzUnpacker_PrepareToRandomBlockDecoding()
969 static void XzUnpacker_UpdateIndex(CXzUnpacker *p, UInt64 packSize, UInt64 unpackSize) in XzUnpacker_UpdateIndex() argument
974 Sha256_Update(&p->sha, temp, num); in XzUnpacker_UpdateIndex()
975 p->indexSize += num; in XzUnpacker_UpdateIndex()
976 p->numBlocks++; in XzUnpacker_UpdateIndex()
981 SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, in XzUnpacker_Code() argument
995 if (p->state == XZ_STATE_BLOCK) in XzUnpacker_Code()
997 SizeT destLen2 = destLenOrig - *destLen; in XzUnpacker_Code()
998 SizeT srcLen2 = srcLenOrig - *srcLen; in XzUnpacker_Code()
1005 if (p->block.packSize != (UInt64)(Int64)-1) in XzUnpacker_Code()
1007 UInt64 rem = p->block.packSize - p->packSize; in XzUnpacker_Code()
1013 if (rem == 0 && p->block.unpackSize == p->unpackSize) in XzUnpacker_Code()
1017 if (p->block.unpackSize != (UInt64)(Int64)-1) in XzUnpacker_Code()
1019 UInt64 rem = p->block.unpackSize - p->unpackSize; in XzUnpacker_Code()
1037 res = MixCoder_Code(&p->decoder, in XzUnpacker_Code()
1038 (p->outBuf ? NULL : dest), &destLen2, destFinish, in XzUnpacker_Code()
1042 *status = p->decoder.status; in XzUnpacker_Code()
1043 XzCheck_Update(&p->check, (p->outBuf ? p->outBuf + p->outDataWritten : dest), destLen2); in XzUnpacker_Code()
1044 if (!p->outBuf) in XzUnpacker_Code()
1046 p->outDataWritten += destLen2; in XzUnpacker_Code()
1051 p->packSize += srcLen2; in XzUnpacker_Code()
1053 p->unpackSize += destLen2; in XzUnpacker_Code()
1059 if (p->block.packSize == p->packSize in XzUnpacker_Code()
1070 XzUnpacker_UpdateIndex(p, XzUnpacker_GetPackSizeForIndex(p), p->unpackSize); in XzUnpacker_Code()
1071 p->state = XZ_STATE_BLOCK_FOOTER; in XzUnpacker_Code()
1072 p->pos = 0; in XzUnpacker_Code()
1073 p->alignPos = 0; in XzUnpacker_Code()
1076 if ((p->block.packSize != (UInt64)(Int64)-1 && p->block.packSize != p->packSize) in XzUnpacker_Code()
1077 || (p->block.unpackSize != (UInt64)(Int64)-1 && p->block.unpackSize != p->unpackSize)) in XzUnpacker_Code()
1086 srcRem = srcLenOrig - *srcLen; in XzUnpacker_Code()
1089 if (srcRem == 0 && p->state != XZ_STATE_BLOCK_FOOTER) in XzUnpacker_Code()
1095 switch (p->state) in XzUnpacker_Code()
1099 if (p->pos < XZ_STREAM_HEADER_SIZE) in XzUnpacker_Code()
1101 if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos]) in XzUnpacker_Code()
1103 if (p->decodeToStreamSignature) in XzUnpacker_Code()
1105 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
1110 RINOK(Xz_ParseHeader(&p->streamFlags, p->buf)); in XzUnpacker_Code()
1111 p->numStartedStreams++; in XzUnpacker_Code()
1112 p->indexSize = 0; in XzUnpacker_Code()
1113 p->numBlocks = 0; in XzUnpacker_Code()
1114 Sha256_Init(&p->sha); in XzUnpacker_Code()
1115 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
1116 p->pos = 0; in XzUnpacker_Code()
1123 if (p->pos == 0) in XzUnpacker_Code()
1125 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
1127 if (p->buf[0] == 0) in XzUnpacker_Code()
1129 if (p->decodeOnlyOneBlock) in XzUnpacker_Code()
1131 p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks); in XzUnpacker_Code()
1132 p->indexPos = p->indexPreSize; in XzUnpacker_Code()
1133 p->indexSize += p->indexPreSize; in XzUnpacker_Code()
1134 Sha256_Final(&p->sha, p->shaDigest); in XzUnpacker_Code()
1135 Sha256_Init(&p->sha); in XzUnpacker_Code()
1136 p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize); in XzUnpacker_Code()
1137 p->state = XZ_STATE_STREAM_INDEX; in XzUnpacker_Code()
1140 p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4; in XzUnpacker_Code()
1144 if (p->pos != p->blockHeaderSize) in XzUnpacker_Code()
1146 UInt32 cur = p->blockHeaderSize - p->pos; in XzUnpacker_Code()
1149 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
1150 p->pos += cur; in XzUnpacker_Code()
1156 RINOK(XzBlock_Parse(&p->block, p->buf)); in XzUnpacker_Code()
1157 if (!XzBlock_AreSupportedFilters(&p->block)) in XzUnpacker_Code()
1159 p->numTotalBlocks++; in XzUnpacker_Code()
1160 p->state = XZ_STATE_BLOCK; in XzUnpacker_Code()
1161 p->packSize = 0; in XzUnpacker_Code()
1162 p->unpackSize = 0; in XzUnpacker_Code()
1163 XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags)); in XzUnpacker_Code()
1164 if (p->parseMode) in XzUnpacker_Code()
1166 p->headerParsedOk = True; in XzUnpacker_Code()
1169 RINOK(XzDecMix_Init(&p->decoder, &p->block, p->outBuf, p->outBufSize)); in XzUnpacker_Code()
1176 if ((((unsigned)p->packSize + p->alignPos) & 3) != 0) in XzUnpacker_Code()
1184 p->alignPos++; in XzUnpacker_Code()
1190 UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags); in XzUnpacker_Code()
1191 UInt32 cur = checkSize - p->pos; in XzUnpacker_Code()
1201 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
1202 p->pos += cur; in XzUnpacker_Code()
1205 if (checkSize != p->pos) in XzUnpacker_Code()
1210 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
1211 p->pos = 0; in XzUnpacker_Code()
1212 if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0) in XzUnpacker_Code()
1214 if (p->decodeOnlyOneBlock) in XzUnpacker_Code()
1226 if (p->pos < p->indexPreSize) in XzUnpacker_Code()
1229 if (*src++ != p->buf[p->pos++]) in XzUnpacker_Code()
1234 if (p->indexPos < p->indexSize) in XzUnpacker_Code()
1236 UInt64 cur = p->indexSize - p->indexPos; in XzUnpacker_Code()
1239 p->crc = CrcUpdate(p->crc, src, srcRem); in XzUnpacker_Code()
1240 Sha256_Update(&p->sha, src, srcRem); in XzUnpacker_Code()
1243 p->indexPos += srcRem; in XzUnpacker_Code()
1245 else if ((p->indexPos & 3) != 0) in XzUnpacker_Code()
1248 p->crc = CRC_UPDATE_BYTE(p->crc, b); in XzUnpacker_Code()
1250 p->indexPos++; in XzUnpacker_Code()
1251 p->indexSize++; in XzUnpacker_Code()
1258 p->state = XZ_STATE_STREAM_INDEX_CRC; in XzUnpacker_Code()
1259 p->indexSize += 4; in XzUnpacker_Code()
1260 p->pos = 0; in XzUnpacker_Code()
1261 Sha256_Final(&p->sha, digest); in XzUnpacker_Code()
1262 if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0) in XzUnpacker_Code()
1271 if (p->pos < 4) in XzUnpacker_Code()
1274 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
1278 p->state = XZ_STATE_STREAM_FOOTER; in XzUnpacker_Code()
1279 p->pos = 0; in XzUnpacker_Code()
1280 if (CRC_GET_DIGEST(p->crc) != GetUi32(p->buf)) in XzUnpacker_Code()
1288 UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos; in XzUnpacker_Code()
1291 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
1292 p->pos += cur; in XzUnpacker_Code()
1295 if (p->pos == XZ_STREAM_FOOTER_SIZE) in XzUnpacker_Code()
1297 p->state = XZ_STATE_STREAM_PADDING; in XzUnpacker_Code()
1298 p->numFinishedStreams++; in XzUnpacker_Code()
1299 p->padSize = 0; in XzUnpacker_Code()
1300 if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf)) in XzUnpacker_Code()
1310 if (((UInt32)p->padSize & 3) != 0) in XzUnpacker_Code()
1312 p->pos = 0; in XzUnpacker_Code()
1313 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Code()
1319 p->padSize++; in XzUnpacker_Code()
1328 if (p->state == XZ_STATE_FINISHED) in XzUnpacker_Code()
1335 SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen, in XzUnpacker_CodeFull() argument
1339 XzUnpacker_Init(p); in XzUnpacker_CodeFull()
1340 XzUnpacker_SetOutBuf(p, dest, *destLen); in XzUnpacker_CodeFull()
1342 return XzUnpacker_Code(p, in XzUnpacker_CodeFull()
1349 BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p) in XzUnpacker_IsBlockFinished() argument
1351 return (p->state == XZ_STATE_BLOCK_HEADER) && (p->pos == 0); in XzUnpacker_IsBlockFinished()
1354 BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p) in XzUnpacker_IsStreamWasFinished() argument
1356 return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0); in XzUnpacker_IsStreamWasFinished()
1359 UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p) in XzUnpacker_GetExtraSize() argument
1362 if (p->state == XZ_STATE_STREAM_PADDING) in XzUnpacker_GetExtraSize()
1363 num = p->padSize; in XzUnpacker_GetExtraSize()
1364 else if (p->state == XZ_STATE_STREAM_HEADER) in XzUnpacker_GetExtraSize()
1365 num = p->padSize + p->pos; in XzUnpacker_GetExtraSize()
1394 void XzDecMtProps_Init(CXzDecMtProps *p) in XzDecMtProps_Init() argument
1396 p->inBufSize_ST = 1 << 18; in XzDecMtProps_Init()
1397 p->outStep_ST = 1 << 20; in XzDecMtProps_Init()
1398 p->ignoreErrors = False; in XzDecMtProps_Init()
1401 p->numThreads = 1; in XzDecMtProps_Init()
1402 p->inBufSize_MT = 1 << 18; in XzDecMtProps_Init()
1403 p->memUseMax = sizeof(size_t) << 28; in XzDecMtProps_Init()
1411 /* ---------- CXzDecMtThread ---------- */
1446 /* ---------- CXzDecMt ---------- */
1513 CXzDecMt *p = (CXzDecMt *)ISzAlloc_Alloc(alloc, sizeof(CXzDecMt)); in XzDecMt_Create() local
1514 if (!p) in XzDecMt_Create()
1517 AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); in XzDecMt_Create()
1518 p->alignOffsetAlloc.baseAlloc = alloc; in XzDecMt_Create()
1519 p->alignOffsetAlloc.numAlignBits = 7; in XzDecMt_Create()
1520 p->alignOffsetAlloc.offset = 0; in XzDecMt_Create()
1522 p->allocMid = allocMid; in XzDecMt_Create()
1524 p->outBuf = NULL; in XzDecMt_Create()
1525 p->outBufSize = 0; in XzDecMt_Create()
1526 p->inBuf = NULL; in XzDecMt_Create()
1527 p->inBufSize = 0; in XzDecMt_Create()
1529 XzUnpacker_Construct(&p->dec, &p->alignOffsetAlloc.vt); in XzDecMt_Create()
1531 p->unpackBlockMaxSize = 0; in XzDecMt_Create()
1533 XzDecMtProps_Init(&p->props); in XzDecMt_Create()
1536 p->mtc_WasConstructed = False; in XzDecMt_Create()
1541 CXzDecMtThread *coder = &p->coders[i]; in XzDecMt_Create()
1542 coder->dec_created = False; in XzDecMt_Create()
1543 coder->outBuf = NULL; in XzDecMt_Create()
1544 coder->outBufSize = 0; in XzDecMt_Create()
1549 return p; in XzDecMt_Create()
1555 static void XzDecMt_FreeOutBufs(CXzDecMt *p) in XzDecMt_FreeOutBufs() argument
1560 CXzDecMtThread *coder = &p->coders[i]; in XzDecMt_FreeOutBufs()
1561 if (coder->outBuf) in XzDecMt_FreeOutBufs()
1563 ISzAlloc_Free(p->allocMid, coder->outBuf); in XzDecMt_FreeOutBufs()
1564 coder->outBuf = NULL; in XzDecMt_FreeOutBufs()
1565 coder->outBufSize = 0; in XzDecMt_FreeOutBufs()
1568 p->unpackBlockMaxSize = 0; in XzDecMt_FreeOutBufs()
1575 static void XzDecMt_FreeSt(CXzDecMt *p) in XzDecMt_FreeSt() argument
1577 XzUnpacker_Free(&p->dec); in XzDecMt_FreeSt()
1579 if (p->outBuf) in XzDecMt_FreeSt()
1581 ISzAlloc_Free(p->allocMid, p->outBuf); in XzDecMt_FreeSt()
1582 p->outBuf = NULL; in XzDecMt_FreeSt()
1584 p->outBufSize = 0; in XzDecMt_FreeSt()
1586 if (p->inBuf) in XzDecMt_FreeSt()
1588 ISzAlloc_Free(p->allocMid, p->inBuf); in XzDecMt_FreeSt()
1589 p->inBuf = NULL; in XzDecMt_FreeSt()
1591 p->inBufSize = 0; in XzDecMt_FreeSt()
1597 CXzDecMt *p = (CXzDecMt *)pp; in XzDecMt_Destroy() local
1599 XzDecMt_FreeSt(p); in XzDecMt_Destroy()
1603 if (p->mtc_WasConstructed) in XzDecMt_Destroy()
1605 MtDec_Destruct(&p->mtc); in XzDecMt_Destroy()
1606 p->mtc_WasConstructed = False; in XzDecMt_Destroy()
1612 CXzDecMtThread *t = &p->coders[i]; in XzDecMt_Destroy()
1613 if (t->dec_created) in XzDecMt_Destroy()
1616 XzUnpacker_Free(&t->dec); in XzDecMt_Destroy()
1617 t->dec_created = False; in XzDecMt_Destroy()
1621 XzDecMt_FreeOutBufs(p); in XzDecMt_Destroy()
1625 ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); in XzDecMt_Destroy()
1635 CXzDecMtThread *coder = &me->coders[coderIndex]; in XzDecMt_Callback_Parse()
1636 size_t srcSize = cc->srcSize; in XzDecMt_Callback_Parse()
1638 cc->srcSize = 0; in XzDecMt_Callback_Parse()
1639 cc->outPos = 0; in XzDecMt_Callback_Parse()
1640 cc->state = MTDEC_PARSE_CONTINUE; in XzDecMt_Callback_Parse()
1642 cc->canCreateNewThread = True; in XzDecMt_Callback_Parse()
1644 if (cc->startCall) in XzDecMt_Callback_Parse()
1646 coder->outPreSize = 0; in XzDecMt_Callback_Parse()
1647 coder->inPreSize = 0; in XzDecMt_Callback_Parse()
1648 coder->inPreHeaderSize = 0; in XzDecMt_Callback_Parse()
1649 coder->parseState = MTDEC_PARSE_CONTINUE; in XzDecMt_Callback_Parse()
1650 coder->parsing_Truncated = False; in XzDecMt_Callback_Parse()
1651 coder->skipMode = False; in XzDecMt_Callback_Parse()
1652 coder->codeRes = SZ_OK; in XzDecMt_Callback_Parse()
1653 coder->status = CODER_STATUS_NOT_SPECIFIED; in XzDecMt_Callback_Parse()
1654 coder->inCodeSize = 0; in XzDecMt_Callback_Parse()
1655 coder->outCodeSize = 0; in XzDecMt_Callback_Parse()
1657 coder->numStreams = me->numStreams; in XzDecMt_Callback_Parse()
1658 coder->numTotalBlocks = me->numTotalBlocks; in XzDecMt_Callback_Parse()
1659 coder->numBlocks = me->numBlocks; in XzDecMt_Callback_Parse()
1661 if (!coder->dec_created) in XzDecMt_Callback_Parse()
1663 XzUnpacker_Construct(&coder->dec, &me->alignOffsetAlloc.vt); in XzDecMt_Callback_Parse()
1664 coder->dec_created = True; in XzDecMt_Callback_Parse()
1667 XzUnpacker_Init(&coder->dec); in XzDecMt_Callback_Parse()
1669 if (me->isBlockHeaderState_Parse) in XzDecMt_Callback_Parse()
1671 coder->dec.streamFlags = me->streamFlags; in XzDecMt_Callback_Parse()
1672 coder->atBlockHeader = True; in XzDecMt_Callback_Parse()
1673 XzUnpacker_PrepareToRandomBlockDecoding(&coder->dec); in XzDecMt_Callback_Parse()
1677 coder->atBlockHeader = False; in XzDecMt_Callback_Parse()
1678 me->isBlockHeaderState_Parse = True; in XzDecMt_Callback_Parse()
1681 coder->dec.numStartedStreams = me->numStreams; in XzDecMt_Callback_Parse()
1682 coder->dec.numTotalBlocks = me->numTotalBlocks; in XzDecMt_Callback_Parse()
1683 coder->dec.numBlocks = me->numBlocks; in XzDecMt_Callback_Parse()
1686 while (!coder->skipMode) in XzDecMt_Callback_Parse()
1691 size_t destSize = (size_t)0 - 1; in XzDecMt_Callback_Parse()
1693 coder->dec.parseMode = True; in XzDecMt_Callback_Parse()
1694 coder->dec.headerParsedOk = False; in XzDecMt_Callback_Parse()
1698 res = XzUnpacker_Code(&coder->dec, in XzDecMt_Callback_Parse()
1700 cc->src, &srcSize2, cc->srcFinished, in XzDecMt_Callback_Parse()
1705 coder->codeRes = res; in XzDecMt_Callback_Parse()
1706 coder->status = status; in XzDecMt_Callback_Parse()
1707 cc->srcSize += srcSize2; in XzDecMt_Callback_Parse()
1708 srcSize -= srcSize2; in XzDecMt_Callback_Parse()
1709 coder->inPreHeaderSize += srcSize2; in XzDecMt_Callback_Parse()
1710 coder->inPreSize = coder->inPreHeaderSize; in XzDecMt_Callback_Parse()
1714 cc->state = in XzDecMt_Callback_Parse()
1715 coder->parseState = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1724 if (coder->dec.headerParsedOk) in XzDecMt_Callback_Parse()
1726 const CXzBlock *block = &coder->dec.block; in XzDecMt_Callback_Parse()
1728 // && block->unpackSize <= me->props.outBlockMax in XzDecMt_Callback_Parse()
1732 if (block->unpackSize * 2 * me->mtc.numStartedThreads > me->props.memUseMax) in XzDecMt_Callback_Parse()
1734 cc->state = MTDEC_PARSE_OVERFLOW; in XzDecMt_Callback_Parse()
1739 UInt64 packSize = block->packSize; in XzDecMt_Callback_Parse()
1740 UInt64 packSizeAligned = packSize + ((0 - (unsigned)packSize) & 3); in XzDecMt_Callback_Parse()
1741 UInt32 checkSize = XzFlags_GetCheckSize(coder->dec.streamFlags); in XzDecMt_Callback_Parse()
1742 UInt64 blockPackSum = coder->inPreSize + packSizeAligned + checkSize; in XzDecMt_Callback_Parse()
1743 // if (blockPackSum <= me->props.inBlockMax) in XzDecMt_Callback_Parse()
1746 … coder->blockPackSize_for_Index = (size_t)(coder->dec.blockHeaderSize + packSize + checkSize); in XzDecMt_Callback_Parse()
1747 coder->blockPackTotal = (size_t)blockPackSum; in XzDecMt_Callback_Parse()
1748 coder->outPreSize = (size_t)block->unpackSize; in XzDecMt_Callback_Parse()
1749 coder->streamFlags = coder->dec.streamFlags; in XzDecMt_Callback_Parse()
1750 me->streamFlags = coder->dec.streamFlags; in XzDecMt_Callback_Parse()
1751 coder->skipMode = True; in XzDecMt_Callback_Parse()
1758 // if (coder->inPreSize <= me->props.inBlockMax) in XzDecMt_Callback_Parse()
1760 if (!cc->srcFinished) in XzDecMt_Callback_Parse()
1762 cc->state = in XzDecMt_Callback_Parse()
1763 coder->parseState = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1766 cc->state = MTDEC_PARSE_OVERFLOW; in XzDecMt_Callback_Parse()
1770 // ---------- skipMode ---------- in XzDecMt_Callback_Parse()
1772 UInt64 rem = coder->blockPackTotal - coder->inPreSize; in XzDecMt_Callback_Parse()
1776 cc->srcSize += cur; in XzDecMt_Callback_Parse()
1777 coder->inPreSize += cur; in XzDecMt_Callback_Parse()
1778 srcSize -= cur; in XzDecMt_Callback_Parse()
1780 if (coder->inPreSize == coder->blockPackTotal) in XzDecMt_Callback_Parse()
1784 if (!cc->srcFinished) in XzDecMt_Callback_Parse()
1786 cc->state = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1788 else if ((cc->src)[cc->srcSize] == 0) // we check control byte of next block in XzDecMt_Callback_Parse()
1789 cc->state = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1792 cc->state = MTDEC_PARSE_NEW; in XzDecMt_Callback_Parse()
1795 size_t blockMax = me->unpackBlockMaxSize; in XzDecMt_Callback_Parse()
1796 if (blockMax < coder->outPreSize) in XzDecMt_Callback_Parse()
1797 blockMax = coder->outPreSize; in XzDecMt_Callback_Parse()
1799 UInt64 required = (UInt64)blockMax * (me->mtc.numStartedThreads + 1) * 2; in XzDecMt_Callback_Parse()
1800 if (me->props.memUseMax < required) in XzDecMt_Callback_Parse()
1801 cc->canCreateNewThread = False; in XzDecMt_Callback_Parse()
1805 if (me->outSize_Defined) in XzDecMt_Callback_Parse()
1808 const UInt64 rem2 = me->outSize - me->outProcessed_Parse; in XzDecMt_Callback_Parse()
1809 if (rem2 < coder->outPreSize) in XzDecMt_Callback_Parse()
1811 coder->parsing_Truncated = True; in XzDecMt_Callback_Parse()
1812 cc->state = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1814 me->outProcessed_Parse += coder->outPreSize; in XzDecMt_Callback_Parse()
1818 else if (cc->srcFinished) in XzDecMt_Callback_Parse()
1819 cc->state = MTDEC_PARSE_END; in XzDecMt_Callback_Parse()
1823 coder->parseState = cc->state; in XzDecMt_Callback_Parse()
1824 cc->outPos = coder->outPreSize; in XzDecMt_Callback_Parse()
1826 me->numStreams = coder->dec.numStartedStreams; in XzDecMt_Callback_Parse()
1827 me->numTotalBlocks = coder->dec.numTotalBlocks; in XzDecMt_Callback_Parse()
1828 me->numBlocks = coder->dec.numBlocks + 1; in XzDecMt_Callback_Parse()
1837 CXzDecMtThread *coder = &me->coders[coderIndex]; in XzDecMt_Callback_PreCode()
1840 if (!coder->dec.headerParsedOk) in XzDecMt_Callback_PreCode()
1843 dest = coder->outBuf; in XzDecMt_Callback_PreCode()
1845 if (!dest || coder->outBufSize < coder->outPreSize) in XzDecMt_Callback_PreCode()
1849 ISzAlloc_Free(me->allocMid, dest); in XzDecMt_Callback_PreCode()
1850 coder->outBuf = NULL; in XzDecMt_Callback_PreCode()
1851 coder->outBufSize = 0; in XzDecMt_Callback_PreCode()
1854 size_t outPreSize = coder->outPreSize; in XzDecMt_Callback_PreCode()
1857 dest = (Byte *)ISzAlloc_Alloc(me->allocMid, outPreSize); in XzDecMt_Callback_PreCode()
1861 coder->outBuf = dest; in XzDecMt_Callback_PreCode()
1862 coder->outBufSize = coder->outPreSize; in XzDecMt_Callback_PreCode()
1864 if (coder->outBufSize > me->unpackBlockMaxSize) in XzDecMt_Callback_PreCode()
1865 me->unpackBlockMaxSize = coder->outBufSize; in XzDecMt_Callback_PreCode()
1870 XzUnpacker_SetOutBuf(&coder->dec, coder->outBuf, coder->outBufSize); in XzDecMt_Callback_PreCode()
1873 …SRes res = XzDecMix_Init(&coder->dec.decoder, &coder->dec.block, coder->outBuf, coder->outBufSize); in XzDecMt_Callback_PreCode()
1875 coder->codeRes = res; in XzDecMt_Callback_PreCode()
1879 if (me->props.ignoreErrors && res != SZ_ERROR_MEM) in XzDecMt_Callback_PreCode()
1895 CXzDecMtThread *coder = &me->coders[coderIndex]; in XzDecMt_Callback_Code()
1897 *inCodePos = coder->inCodeSize; in XzDecMt_Callback_Code()
1898 *outCodePos = coder->outCodeSize; in XzDecMt_Callback_Code()
1901 if (coder->inCodeSize < coder->inPreHeaderSize) in XzDecMt_Callback_Code()
1903 UInt64 rem = coder->inPreHeaderSize - coder->inCodeSize; in XzDecMt_Callback_Code()
1908 srcSize -= step; in XzDecMt_Callback_Code()
1909 coder->inCodeSize += step; in XzDecMt_Callback_Code()
1910 if (coder->inCodeSize < coder->inPreHeaderSize) in XzDecMt_Callback_Code()
1917 if (!coder->dec.headerParsedOk) in XzDecMt_Callback_Code()
1919 if (!coder->outBuf) in XzDecMt_Callback_Code()
1922 if (coder->codeRes == SZ_OK) in XzDecMt_Callback_Code()
1927 size_t outSizeCur = coder->outPreSize - coder->dec.outDataWritten; in XzDecMt_Callback_Code()
1931 res = XzUnpacker_Code(&coder->dec, in XzDecMt_Callback_Code()
1934 // coder->finishedWithMark ? CODER_FINISH_END : CODER_FINISH_ANY, in XzDecMt_Callback_Code()
1940 coder->codeRes = res; in XzDecMt_Callback_Code()
1941 coder->status = status; in XzDecMt_Callback_Code()
1942 coder->inCodeSize += srcProcessed; in XzDecMt_Callback_Code()
1943 coder->outCodeSize = coder->dec.outDataWritten; in XzDecMt_Callback_Code()
1944 *inCodePos = coder->inCodeSize; in XzDecMt_Callback_Code()
1945 *outCodePos = coder->outCodeSize; in XzDecMt_Callback_Code()
1955 if (me->props.ignoreErrors && coder->codeRes != SZ_ERROR_MEM) in XzDecMt_Callback_Code()
1957 *inCodePos = coder->inPreSize; in XzDecMt_Callback_Code()
1958 *outCodePos = coder->outPreSize; in XzDecMt_Callback_Code()
1961 return coder->codeRes; in XzDecMt_Callback_Code()
1975 const CXzDecMtThread *coder = &me->coders[coderIndex]; in XzDecMt_Callback_Write()
1977 …// PRF(printf("\nWrite processed = %d srcSize = %d\n", (unsigned)me->mtc.inProcessed, (unsigned)sr… in XzDecMt_Callback_Write()
1985 if (!coder->dec.headerParsedOk || !coder->outBuf) in XzDecMt_Callback_Write()
1987 if (me->finishedDecoderIndex < 0) in XzDecMt_Callback_Write()
1988 me->finishedDecoderIndex = coderIndex; in XzDecMt_Callback_Write()
1992 if (me->finishedDecoderIndex >= 0) in XzDecMt_Callback_Write()
1995 me->mtc.inProcessed += coder->inCodeSize; in XzDecMt_Callback_Write()
2001 size_t size = coder->outCodeSize; in XzDecMt_Callback_Write()
2002 Byte *data = coder->outBuf; in XzDecMt_Callback_Write()
2004 // we use in me->dec: sha, numBlocks, indexSize in XzDecMt_Callback_Write()
2006 if (!me->isBlockHeaderState_Write) in XzDecMt_Callback_Write()
2008 XzUnpacker_PrepareToRandomBlockDecoding(&me->dec); in XzDecMt_Callback_Write()
2009 me->dec.decodeOnlyOneBlock = False; in XzDecMt_Callback_Write()
2010 me->dec.numStartedStreams = coder->dec.numStartedStreams; in XzDecMt_Callback_Write()
2011 me->dec.streamFlags = coder->streamFlags; in XzDecMt_Callback_Write()
2013 me->isBlockHeaderState_Write = True; in XzDecMt_Callback_Write()
2016 me->dec.numTotalBlocks = coder->dec.numTotalBlocks; in XzDecMt_Callback_Write()
2017 XzUnpacker_UpdateIndex(&me->dec, coder->blockPackSize_for_Index, coder->outPreSize); in XzDecMt_Callback_Write()
2019 if (coder->outPreSize != size) in XzDecMt_Callback_Write()
2021 if (me->props.ignoreErrors) in XzDecMt_Callback_Write()
2023 memset(data + size, 0, coder->outPreSize - size); in XzDecMt_Callback_Write()
2024 size = coder->outPreSize; in XzDecMt_Callback_Write()
2026 // me->numBadBlocks++; in XzDecMt_Callback_Write()
2027 if (me->mainErrorCode == SZ_OK) in XzDecMt_Callback_Write()
2029 if ((int)coder->status == LZMA_STATUS_NEEDS_MORE_INPUT) in XzDecMt_Callback_Write()
2030 me->mainErrorCode = SZ_ERROR_INPUT_EOF; in XzDecMt_Callback_Write()
2032 me->mainErrorCode = SZ_ERROR_DATA; in XzDecMt_Callback_Write()
2036 if (me->writeRes != SZ_OK) in XzDecMt_Callback_Write()
2037 return me->writeRes; in XzDecMt_Callback_Write()
2041 if (me->outSize_Defined) in XzDecMt_Callback_Write()
2043 const UInt64 rem = me->outSize - me->outProcessed; in XzDecMt_Callback_Write()
2055 written = ISeqOutStream_Write(me->outStream, data, cur); in XzDecMt_Callback_Write()
2059 me->outProcessed += written; in XzDecMt_Callback_Write()
2062 me->writeRes = SZ_ERROR_WRITE; in XzDecMt_Callback_Write()
2063 res = me->writeRes; in XzDecMt_Callback_Write()
2067 size -= cur; in XzDecMt_Callback_Write()
2071 res = MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0); in XzDecMt_Callback_Write()
2077 if (coder->codeRes != SZ_OK) in XzDecMt_Callback_Write()
2078 if (!me->props.ignoreErrors) in XzDecMt_Callback_Write()
2080 me->finishedDecoderIndex = coderIndex; in XzDecMt_Callback_Write()
2086 if (coder->inPreSize != coder->inCodeSize in XzDecMt_Callback_Write()
2087 || coder->blockPackTotal != coder->inCodeSize) in XzDecMt_Callback_Write()
2089 me->finishedDecoderIndex = coderIndex; in XzDecMt_Callback_Write()
2093 if (coder->parseState != MTDEC_PARSE_END) in XzDecMt_Callback_Write()
2100 // (coder->state == MTDEC_PARSE_END) means that there are no other working threads in XzDecMt_Callback_Write()
2103 PRF_STR_INT("Write MTDEC_PARSE_END", me->mtc.inProcessed); in XzDecMt_Callback_Write()
2105 me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; in XzDecMt_Callback_Write()
2107 CXzUnpacker *dec = &me->dec; in XzDecMt_Callback_Write()
2117 // dec->decodeOnlyOneBlock = False; in XzDecMt_Callback_Write()
2118 dec->decodeToStreamSignature = True; in XzDecMt_Callback_Write()
2120 me->mainDecoderWasCalled = True; in XzDecMt_Callback_Write()
2122 if (coder->parsing_Truncated) in XzDecMt_Callback_Write()
2124 me->parsing_Truncated = True; in XzDecMt_Callback_Write()
2131 me->mtc.readWasFinished, // srcFinished in XzDecMt_Callback_Write()
2135 me->status = status; in XzDecMt_Callback_Write()
2136 me->codeRes = res; in XzDecMt_Callback_Write()
2138 me->mtc.inProcessed += srcProcessed; in XzDecMt_Callback_Write()
2139 me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; in XzDecMt_Callback_Write()
2147 if (dec->state == XZ_STATE_STREAM_HEADER) in XzDecMt_Callback_Write()
2150 me->isBlockHeaderState_Parse = False; in XzDecMt_Callback_Write()
2151 me->isBlockHeaderState_Write = False; in XzDecMt_Callback_Write()
2153 Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); in XzDecMt_Callback_Write()
2156 memcpy(crossBuf, src + srcProcessed, srcSize - srcProcessed); in XzDecMt_Callback_Write()
2158 me->mtc.crossStart = 0; in XzDecMt_Callback_Write()
2159 me->mtc.crossEnd = srcSize - srcProcessed; in XzDecMt_Callback_Write()
2168 if (me->mtc.readWasFinished) in XzDecMt_Callback_Write()
2178 UInt64 inProgressPrev = me->mtc.inProcessed; in XzDecMt_Callback_Write()
2180 // XzDecMt_Prepare_InBuf_ST(p); in XzDecMt_Callback_Write()
2181 Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); in XzDecMt_Callback_Write()
2200 if (!me->mtc.readWasFinished) in XzDecMt_Callback_Write()
2203 inLim = me->mtc.inBufSize; in XzDecMt_Callback_Write()
2204 me->mtc.readRes = ISeqInStream_Read(me->inStream, (void *)inData, &inLim); in XzDecMt_Callback_Write()
2205 me->mtc.readProcessed += inLim; in XzDecMt_Callback_Write()
2206 if (inLim == 0 || me->mtc.readRes != SZ_OK) in XzDecMt_Callback_Write()
2207 me->mtc.readWasFinished = True; in XzDecMt_Callback_Write()
2211 inProcessed = inLim - inPos; in XzDecMt_Callback_Write()
2220 me->codeRes = res; in XzDecMt_Callback_Write()
2221 me->status = status; in XzDecMt_Callback_Write()
2223 me->mtc.inProcessed += inProcessed; in XzDecMt_Callback_Write()
2224 me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; in XzDecMt_Callback_Write()
2232 if (dec->state == XZ_STATE_STREAM_HEADER) in XzDecMt_Callback_Write()
2235 me->mtc.crossStart = inPos; in XzDecMt_Callback_Write()
2236 me->mtc.crossEnd = inLim; in XzDecMt_Callback_Write()
2237 me->isBlockHeaderState_Parse = False; in XzDecMt_Callback_Write()
2238 me->isBlockHeaderState_Write = False; in XzDecMt_Callback_Write()
2245 if (me->mtc.progress) in XzDecMt_Callback_Write()
2247 UInt64 inDelta = me->mtc.inProcessed - inProgressPrev; in XzDecMt_Callback_Write()
2250 RINOK(MtProgress_Progress_ST(&me->mtc.mtProgress)); in XzDecMt_Callback_Write()
2251 inProgressPrev = me->mtc.inProcessed; in XzDecMt_Callback_Write()
2254 if (me->mtc.readWasFinished) in XzDecMt_Callback_Write()
2266 void XzStatInfo_Clear(CXzStatInfo *p) in XzStatInfo_Clear() argument
2268 p->InSize = 0; in XzStatInfo_Clear()
2269 p->OutSize = 0; in XzStatInfo_Clear()
2271 p->NumStreams = 0; in XzStatInfo_Clear()
2272 p->NumBlocks = 0; in XzStatInfo_Clear()
2274 p->UnpackSize_Defined = False; in XzStatInfo_Clear()
2276 p->NumStreams_Defined = False; in XzStatInfo_Clear()
2277 p->NumBlocks_Defined = False; in XzStatInfo_Clear()
2279 // p->IsArc = False; in XzStatInfo_Clear()
2280 // p->UnexpectedEnd = False; in XzStatInfo_Clear()
2281 // p->Unsupported = False; in XzStatInfo_Clear()
2282 // p->HeadersError = False; in XzStatInfo_Clear()
2283 // p->DataError = False; in XzStatInfo_Clear()
2284 // p->CrcError = False; in XzStatInfo_Clear()
2286 p->DataAfterEnd = False; in XzStatInfo_Clear()
2287 p->DecodingTruncated = False; in XzStatInfo_Clear()
2289 p->DecodeRes = SZ_OK; in XzStatInfo_Clear()
2290 p->ReadRes = SZ_OK; in XzStatInfo_Clear()
2291 p->ProgressRes = SZ_OK; in XzStatInfo_Clear()
2293 p->CombinedRes = SZ_OK; in XzStatInfo_Clear()
2294 p->CombinedRes_Type = SZ_OK; in XzStatInfo_Clear()
2300 static SRes XzDecMt_Decode_ST(CXzDecMt *p in XzDecMt_Decode_ST() argument
2316 XzDecMt_FreeOutBufs(p); in XzDecMt_Decode_ST()
2317 tMode = MtDec_PrepareRead(&p->mtc); in XzDecMt_Decode_ST()
2321 if (!p->outBuf || p->outBufSize != p->props.outStep_ST) in XzDecMt_Decode_ST()
2323 ISzAlloc_Free(p->allocMid, p->outBuf); in XzDecMt_Decode_ST()
2324 p->outBufSize = 0; in XzDecMt_Decode_ST()
2325 p->outBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.outStep_ST); in XzDecMt_Decode_ST()
2326 if (!p->outBuf) in XzDecMt_Decode_ST()
2328 p->outBufSize = p->props.outStep_ST; in XzDecMt_Decode_ST()
2331 if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) in XzDecMt_Decode_ST()
2333 ISzAlloc_Free(p->allocMid, p->inBuf); in XzDecMt_Decode_ST()
2334 p->inBufSize = 0; in XzDecMt_Decode_ST()
2335 p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); in XzDecMt_Decode_ST()
2336 if (!p->inBuf) in XzDecMt_Decode_ST()
2338 p->inBufSize = p->props.inBufSize_ST; in XzDecMt_Decode_ST()
2341 dec = &p->dec; in XzDecMt_Decode_ST()
2342 dec->decodeToStreamSignature = False; in XzDecMt_Decode_ST()
2343 // dec->decodeOnlyOneBlock = False; in XzDecMt_Decode_ST()
2347 inPrev = p->inProcessed; in XzDecMt_Decode_ST()
2348 outPrev = p->outProcessed; in XzDecMt_Decode_ST()
2373 inData = MtDec_Read(&p->mtc, &inLim); in XzDecMt_Decode_ST()
2382 if (!p->readWasFinished) in XzDecMt_Decode_ST()
2385 inLim = p->inBufSize; in XzDecMt_Decode_ST()
2386 inData = p->inBuf; in XzDecMt_Decode_ST()
2387 p->readRes = ISeqInStream_Read(p->inStream, (void *)inData, &inLim); in XzDecMt_Decode_ST()
2388 p->readProcessed += inLim; in XzDecMt_Decode_ST()
2389 if (inLim == 0 || p->readRes != SZ_OK) in XzDecMt_Decode_ST()
2390 p->readWasFinished = True; in XzDecMt_Decode_ST()
2394 outSize = p->props.outStep_ST - outPos; in XzDecMt_Decode_ST()
2397 if (p->outSize_Defined) in XzDecMt_Decode_ST()
2399 const UInt64 rem = p->outSize - p->outProcessed; in XzDecMt_Decode_ST()
2403 if (p->finishMode) in XzDecMt_Decode_ST()
2408 inProcessed = inLim - inPos; in XzDecMt_Decode_ST()
2411 res = XzUnpacker_Code(dec, p->outBuf + outPos, &outProcessed, in XzDecMt_Decode_ST()
2416 p->codeRes = res; in XzDecMt_Decode_ST()
2417 p->status = status; in XzDecMt_Decode_ST()
2421 p->inProcessed += inProcessed; in XzDecMt_Decode_ST()
2422 p->outProcessed += outProcessed; in XzDecMt_Decode_ST()
2429 size_t written = ISeqOutStream_Write(p->outStream, p->outBuf, outPos); in XzDecMt_Decode_ST()
2430 p->outProcessed += written; in XzDecMt_Decode_ST()
2433 stat->CombinedRes_Type = SZ_ERROR_WRITE; in XzDecMt_Decode_ST()
2439 if (p->progress && res == SZ_OK) in XzDecMt_Decode_ST()
2441 UInt64 inDelta = p->inProcessed - inPrev; in XzDecMt_Decode_ST()
2442 UInt64 outDelta = p->outProcessed - outPrev; in XzDecMt_Decode_ST()
2445 res = ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed); in XzDecMt_Decode_ST()
2448 stat->CombinedRes_Type = SZ_ERROR_PROGRESS; in XzDecMt_Decode_ST()
2449 stat->ProgressRes = res; in XzDecMt_Decode_ST()
2452 inPrev = p->inProcessed; in XzDecMt_Decode_ST()
2453 outPrev = p->outProcessed; in XzDecMt_Decode_ST()
2471 stat->DecodingTruncated = (Byte)(decodingTruncated ? 1 : 0); in XzStatInfo_SetStat()
2472 stat->InSize = inProcessed; in XzStatInfo_SetStat()
2473 stat->NumStreams = dec->numStartedStreams; in XzStatInfo_SetStat()
2474 stat->NumBlocks = dec->numTotalBlocks; in XzStatInfo_SetStat()
2476 stat->UnpackSize_Defined = True; in XzStatInfo_SetStat()
2477 stat->NumStreams_Defined = True; in XzStatInfo_SetStat()
2478 stat->NumBlocks_Defined = True; in XzStatInfo_SetStat()
2498 XZ_STATE_STREAM_HEADER - if bad signature or bad CRC in XzStatInfo_SetStat()
2499 XZ_STATE_STREAM_PADDING - if non-zero padding data in XzStatInfo_SetStat()
2505 stat->DataAfterEnd = True; in XzStatInfo_SetStat()
2511 stat->DecodeRes = res; in XzStatInfo_SetStat()
2513 stat->InSize -= extraSize; in XzStatInfo_SetStat()
2529 CXzDecMt *p = (CXzDecMt *)pp; in XzDecMt_Decode() local
2536 p->props = *props; in XzDecMt_Decode()
2538 p->inStream = inStream; in XzDecMt_Decode()
2539 p->outStream = outStream; in XzDecMt_Decode()
2540 p->progress = progress; in XzDecMt_Decode()
2541 // p->stat = stat; in XzDecMt_Decode()
2543 p->outSize = 0; in XzDecMt_Decode()
2544 p->outSize_Defined = False; in XzDecMt_Decode()
2547 p->outSize_Defined = True; in XzDecMt_Decode()
2548 p->outSize = *outDataSize; in XzDecMt_Decode()
2551 p->finishMode = finishMode; in XzDecMt_Decode()
2553 // p->outSize = 457; p->outSize_Defined = True; p->finishMode = False; // for test in XzDecMt_Decode()
2555 p->writeRes = SZ_OK; in XzDecMt_Decode()
2556 p->outProcessed = 0; in XzDecMt_Decode()
2557 p->inProcessed = 0; in XzDecMt_Decode()
2558 p->readProcessed = 0; in XzDecMt_Decode()
2559 p->readWasFinished = False; in XzDecMt_Decode()
2561 p->codeRes = 0; in XzDecMt_Decode()
2562 p->status = CODER_STATUS_NOT_SPECIFIED; in XzDecMt_Decode()
2564 XzUnpacker_Init(&p->dec); in XzDecMt_Decode()
2569 p->outBuf = NULL; in XzDecMt_Decode()
2570 p->outBufSize = 0; in XzDecMt_Decode()
2573 p->outBuf = outBuf; in XzDecMt_Decode()
2574 p->outBufSize = *outBufSize; in XzDecMt_Decode()
2582 p->isBlockHeaderState_Parse = False; in XzDecMt_Decode()
2583 p->isBlockHeaderState_Write = False; in XzDecMt_Decode()
2584 // p->numBadBlocks = 0; in XzDecMt_Decode()
2585 p->mainErrorCode = SZ_OK; in XzDecMt_Decode()
2586 p->mainDecoderWasCalled = False; in XzDecMt_Decode()
2590 if (p->props.numThreads > 1) in XzDecMt_Decode()
2596 XzDecMt_FreeSt(p); in XzDecMt_Decode()
2598 p->outProcessed_Parse = 0; in XzDecMt_Decode()
2599 p->parsing_Truncated = False; in XzDecMt_Decode()
2601 p->numStreams = 0; in XzDecMt_Decode()
2602 p->numTotalBlocks = 0; in XzDecMt_Decode()
2603 p->numBlocks = 0; in XzDecMt_Decode()
2604 p->finishedDecoderIndex = -1; in XzDecMt_Decode()
2606 if (!p->mtc_WasConstructed) in XzDecMt_Decode()
2608 p->mtc_WasConstructed = True; in XzDecMt_Decode()
2609 MtDec_Construct(&p->mtc); in XzDecMt_Decode()
2612 p->mtc.mtCallback = &vt; in XzDecMt_Decode()
2613 p->mtc.mtCallbackObject = p; in XzDecMt_Decode()
2615 p->mtc.progress = progress; in XzDecMt_Decode()
2616 p->mtc.inStream = inStream; in XzDecMt_Decode()
2617 p->mtc.alloc = &p->alignOffsetAlloc.vt; in XzDecMt_Decode()
2618 // p->mtc.inData = inData; in XzDecMt_Decode()
2619 // p->mtc.inDataSize = inDataSize; in XzDecMt_Decode()
2620 p->mtc.inBufSize = p->props.inBufSize_MT; in XzDecMt_Decode()
2621 // p->mtc.inBlockMax = p->props.inBlockMax; in XzDecMt_Decode()
2622 p->mtc.numThreadsMax = p->props.numThreads; in XzDecMt_Decode()
2634 SRes res = MtDec_Code(&p->mtc); in XzDecMt_Decode()
2636 stat->InSize = p->mtc.inProcessed; in XzDecMt_Decode()
2638 p->inProcessed = p->mtc.inProcessed; in XzDecMt_Decode()
2639 p->readRes = p->mtc.readRes; in XzDecMt_Decode()
2640 p->readWasFinished = p->mtc.readWasFinished; in XzDecMt_Decode()
2641 p->readProcessed = p->mtc.readProcessed; in XzDecMt_Decode()
2648 if (p->mtc.mtProgress.res != SZ_OK) in XzDecMt_Decode()
2650 res = p->mtc.mtProgress.res; in XzDecMt_Decode()
2651 stat->ProgressRes = res; in XzDecMt_Decode()
2652 stat->CombinedRes_Type = SZ_ERROR_PROGRESS; in XzDecMt_Decode()
2655 needContinue = p->mtc.needContinue; in XzDecMt_Decode()
2665 stat->OutSize = p->outProcessed; in XzDecMt_Decode()
2667 if (p->finishedDecoderIndex >= 0) in XzDecMt_Decode()
2669 CXzDecMtThread *coder = &p->coders[(unsigned)p->finishedDecoderIndex]; in XzDecMt_Decode()
2670 codeRes = coder->codeRes; in XzDecMt_Decode()
2671 dec = &coder->dec; in XzDecMt_Decode()
2672 status = coder->status; in XzDecMt_Decode()
2674 else if (p->mainDecoderWasCalled) in XzDecMt_Decode()
2676 codeRes = p->codeRes; in XzDecMt_Decode()
2677 dec = &p->dec; in XzDecMt_Decode()
2678 status = p->status; in XzDecMt_Decode()
2679 truncated = p->parsing_Truncated; in XzDecMt_Decode()
2684 XzStatInfo_SetStat(dec, p->finishMode, in XzDecMt_Decode()
2685 p->mtc.readProcessed, p->mtc.inProcessed, in XzDecMt_Decode()
2692 if (p->writeRes != SZ_OK) in XzDecMt_Decode()
2694 res = p->writeRes; in XzDecMt_Decode()
2695 stat->CombinedRes_Type = SZ_ERROR_WRITE; in XzDecMt_Decode()
2697 else if (p->mtc.readRes != SZ_OK && p->mtc.inProcessed == p->mtc.readProcessed) in XzDecMt_Decode()
2699 res = p->mtc.readRes; in XzDecMt_Decode()
2700 stat->ReadRes = res; in XzDecMt_Decode()
2701 stat->CombinedRes_Type = SZ_ERROR_READ; in XzDecMt_Decode()
2703 else if (p->mainErrorCode != SZ_OK) in XzDecMt_Decode()
2705 res = p->mainErrorCode; in XzDecMt_Decode()
2709 stat->CombinedRes = res; in XzDecMt_Decode()
2710 if (stat->CombinedRes_Type == SZ_OK) in XzDecMt_Decode()
2711 stat->CombinedRes_Type = res; in XzDecMt_Decode()
2715 PRF_STR("----- decoding ST -----"); in XzDecMt_Decode()
2725 SRes res = XzDecMt_Decode_ST(p in XzDecMt_Decode()
2732 XzStatInfo_SetStat(&p->dec, in XzDecMt_Decode()
2733 p->finishMode, in XzDecMt_Decode()
2734 p->readProcessed, p->inProcessed, in XzDecMt_Decode()
2735 p->codeRes, p->status, in XzDecMt_Decode()
2742 if (p->writeRes != SZ_OK) in XzDecMt_Decode()
2744 res = p->writeRes; in XzDecMt_Decode()
2745 stat->CombinedRes_Type = SZ_ERROR_WRITE; in XzDecMt_Decode()
2749 if (p->readRes != SZ_OK && p->inProcessed == p->readProcessed) in XzDecMt_Decode()
2751 res = p->readRes; in XzDecMt_Decode()
2752 stat->ReadRes = res; in XzDecMt_Decode()
2753 stat->CombinedRes_Type = SZ_ERROR_READ; in XzDecMt_Decode()
2756 else if (p->mainErrorCode != SZ_OK) in XzDecMt_Decode()
2757 res = p->mainErrorCode; in XzDecMt_Decode()
2761 stat->CombinedRes = res; in XzDecMt_Decode()
2762 if (stat->CombinedRes_Type == SZ_OK) in XzDecMt_Decode()
2763 stat->CombinedRes_Type = res; in XzDecMt_Decode()