Lines Matching refs:p
30 unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value) in Xz_ReadVarInt() argument
38 Byte b = p[i]; in Xz_ReadVarInt()
73 CBraState *p = ((CBraState *)pp); in BraState_SetProps() local
75 p->encodeMode = 0; in BraState_SetProps()
76 p->ip = 0; in BraState_SetProps()
77 if (p->methodId == XZ_ID_Delta) in BraState_SetProps()
81 p->delta = (unsigned)props[0] + 1; in BraState_SetProps()
88 switch(p->methodId) in BraState_SetProps()
105 p->ip = v; in BraState_SetProps()
115 CBraState *p = ((CBraState *)pp); in BraState_Init() local
116 p->bufPos = p->bufConv = p->bufTotal = 0; in BraState_Init()
117 x86_Convert_Init(p->x86State); in BraState_Init()
118 if (p->methodId == XZ_ID_Delta) in BraState_Init()
119 Delta_Init(p->deltaState); in BraState_Init()
122 #define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: p->bufConv = isa ## _Convert(p->buf, p->bufTotal, p-…
127 CBraState *p = ((CBraState *)pp); in BraState_Code() local
136 if (p->bufPos != p->bufConv) in BraState_Code()
138 size_t curSize = p->bufConv - p->bufPos; in BraState_Code()
141 memcpy(dest, p->buf + p->bufPos, curSize); in BraState_Code()
142 p->bufPos += curSize; in BraState_Code()
148 p->bufTotal -= p->bufPos; in BraState_Code()
149 memmove(p->buf, p->buf + p->bufPos, p->bufTotal); in BraState_Code()
150 p->bufPos = 0; in BraState_Code()
151 p->bufConv = 0; in BraState_Code()
153 size_t curSize = BRA_BUF_SIZE - p->bufTotal; in BraState_Code()
156 memcpy(p->buf + p->bufTotal, src, curSize); in BraState_Code()
160 p->bufTotal += curSize; in BraState_Code()
162 if (p->bufTotal == 0) in BraState_Code()
164 switch(p->methodId) in BraState_Code()
167 if (p->encodeMode) in BraState_Code()
168 Delta_Encode(p->deltaState, p->delta, p->buf, p->bufTotal); in BraState_Code()
170 Delta_Decode(p->deltaState, p->delta, p->buf, p->bufTotal); in BraState_Code()
171 p->bufConv = p->bufTotal; in BraState_Code()
174 p->bufConv = x86_Convert(p->buf, p->bufTotal, p->ip, &p->x86State, p->encodeMode); in BraState_Code()
184 p->ip += (UInt32)p->bufConv; in BraState_Code()
186 if (p->bufConv == 0) in BraState_Code()
190 p->bufConv = p->bufTotal; in BraState_Code()
193 if (p->bufTotal == p->bufPos && srcLenOrig == 0 && srcWasFinished) in BraState_Code()
198 SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc) in BraState_SetFromMethod() argument
209 p->p = 0; in BraState_SetFromMethod()
214 p->p = decoder; in BraState_SetFromMethod()
215 p->Free = BraState_Free; in BraState_SetFromMethod()
216 p->SetProps = BraState_SetProps; in BraState_SetFromMethod()
217 p->Init = BraState_Init; in BraState_SetFromMethod()
218 p->Code = BraState_Code; in BraState_SetFromMethod()
228 CSubblockDec *p = (CSubblockDec *)pp; in SbState_Free() local
229 SubblockDec_Free(p, alloc); in SbState_Free()
256 SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc) in SbState_SetFromMethod() argument
259 p->p = 0; in SbState_SetFromMethod()
263 p->p = decoder; in SbState_SetFromMethod()
264 p->Free = SbState_Free; in SbState_SetFromMethod()
265 p->SetProps = SbState_SetProps; in SbState_SetFromMethod()
266 p->Init = SbState_Init; in SbState_SetFromMethod()
267 p->Code = SbState_Code; in SbState_SetFromMethod()
304 static SRes Lzma2State_SetFromMethod(IStateCoder *p, ISzAlloc *alloc) in Lzma2State_SetFromMethod() argument
307 p->p = decoder; in Lzma2State_SetFromMethod()
310 p->Free = Lzma2State_Free; in Lzma2State_SetFromMethod()
311 p->SetProps = Lzma2State_SetProps; in Lzma2State_SetFromMethod()
312 p->Init = Lzma2State_Init; in Lzma2State_SetFromMethod()
313 p->Code = Lzma2State_Code; in Lzma2State_SetFromMethod()
319 void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc) in MixCoder_Construct() argument
322 p->alloc = alloc; in MixCoder_Construct()
323 p->buf = 0; in MixCoder_Construct()
324 p->numCoders = 0; in MixCoder_Construct()
326 p->coders[i].p = NULL; in MixCoder_Construct()
329 void MixCoder_Free(CMixCoder *p) in MixCoder_Free() argument
332 for (i = 0; i < p->numCoders; i++) in MixCoder_Free()
334 IStateCoder *sc = &p->coders[i]; in MixCoder_Free()
335 if (p->alloc && sc->p) in MixCoder_Free()
336 sc->Free(sc->p, p->alloc); in MixCoder_Free()
338 p->numCoders = 0; in MixCoder_Free()
339 if (p->buf) in MixCoder_Free()
340 p->alloc->Free(p->alloc, p->buf); in MixCoder_Free()
343 void MixCoder_Init(CMixCoder *p) in MixCoder_Init() argument
346 for (i = 0; i < p->numCoders - 1; i++) in MixCoder_Init()
348 p->size[i] = 0; in MixCoder_Init()
349 p->pos[i] = 0; in MixCoder_Init()
350 p->finished[i] = 0; in MixCoder_Init()
352 for (i = 0; i < p->numCoders; i++) in MixCoder_Init()
354 IStateCoder *coder = &p->coders[i]; in MixCoder_Init()
355 coder->Init(coder->p); in MixCoder_Init()
359 SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId) in MixCoder_SetFromMethod() argument
361 IStateCoder *sc = &p->coders[coderIndex]; in MixCoder_SetFromMethod()
362 p->ids[coderIndex] = methodId; in MixCoder_SetFromMethod()
365 case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, p->alloc); in MixCoder_SetFromMethod()
367 case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc); in MixCoder_SetFromMethod()
372 return BraState_SetFromMethod(sc, methodId, p->alloc); in MixCoder_SetFromMethod()
375 SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, in MixCoder_Code() argument
386 if (p->buf == 0) in MixCoder_Code()
388 p->buf = p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1)); in MixCoder_Code()
389 if (p->buf == 0) in MixCoder_Code()
393 if (p->numCoders != 1) in MixCoder_Code()
405 for (i = 0; i < p->numCoders; i++) in MixCoder_Code()
408 IStateCoder *coder = &p->coders[i]; in MixCoder_Code()
423 srcCur = p->buf + (CODER_BUF_SIZE * (i - 1)) + p->pos[i - 1]; in MixCoder_Code()
424 srcLenCur = p->size[i - 1] - p->pos[i - 1]; in MixCoder_Code()
425 srcFinishedCur = p->finished[i - 1]; in MixCoder_Code()
428 if (i == p->numCoders - 1) in MixCoder_Code()
435 if (p->pos[i] != p->size[i]) in MixCoder_Code()
437 destCur = p->buf + (CODER_BUF_SIZE * i); in MixCoder_Code()
441 …res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, … in MixCoder_Code()
453 p->pos[i - 1] += srcLenCur; in MixCoder_Code()
456 if (i == p->numCoders - 1) in MixCoder_Code()
463 p->size[i] = destLenCur; in MixCoder_Code()
464 p->pos[i] = 0; in MixCoder_Code()
465 p->finished[i] = encodingWasFinished; in MixCoder_Code()
482 SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf) in Xz_ParseHeader() argument
484 *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE); in Xz_ParseHeader()
488 return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED; in Xz_ParseHeader()
505 SRes XzBlock_Parse(CXzBlock *p, const Byte *header) in XzBlock_Parse() argument
517 p->flags = header[pos++]; in XzBlock_Parse()
519 if (XzBlock_HasPackSize(p)) in XzBlock_Parse()
521 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize); in XzBlock_Parse()
522 if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63) in XzBlock_Parse()
526 if (XzBlock_HasUnpackSize(p)) in XzBlock_Parse()
527 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize); in XzBlock_Parse()
529 numFilters = XzBlock_GetNumFilters(p); in XzBlock_Parse()
532 CXzFilter *filter = p->filters + i; in XzBlock_Parse()
558 SRes XzDec_Init(CMixCoder *p, const CXzBlock *block) in XzDec_Init() argument
563 if (numFilters == p->numCoders) in XzDec_Init()
566 if (p->ids[i] != block->filters[numFilters - 1 - i].id) in XzDec_Init()
572 MixCoder_Free(p); in XzDec_Init()
573 p->numCoders = numFilters; in XzDec_Init()
577 RINOK(MixCoder_SetFromMethod(p, i, f->id)); in XzDec_Init()
583 IStateCoder *sc = &p->coders[i]; in XzDec_Init()
584 RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc)); in XzDec_Init()
586 MixCoder_Init(p); in XzDec_Init()
590 SRes XzUnpacker_Create(CXzUnpacker *p, ISzAlloc *alloc) in XzUnpacker_Create() argument
592 MixCoder_Construct(&p->decoder, alloc); in XzUnpacker_Create()
593 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Create()
594 p->pos = 0; in XzUnpacker_Create()
595 p->numStreams = 0; in XzUnpacker_Create()
599 void XzUnpacker_Free(CXzUnpacker *p) in XzUnpacker_Free() argument
601 MixCoder_Free(&p->decoder); in XzUnpacker_Free()
604 SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, in XzUnpacker_Code() argument
616 if (p->state == XZ_STATE_BLOCK) in XzUnpacker_Code()
627 res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status); in XzUnpacker_Code()
628 XzCheck_Update(&p->check, dest, destLen2); in XzUnpacker_Code()
632 p->packSize += srcLen2; in XzUnpacker_Code()
636 p->unpackSize += destLen2; in XzUnpacker_Code()
643 …unsigned num = Xz_WriteVarInt(temp, p->packSize + p->blockHeaderSize + XzFlags_GetCheckSize(p->str… in XzUnpacker_Code()
644 num += Xz_WriteVarInt(temp + num, p->unpackSize); in XzUnpacker_Code()
645 Sha256_Update(&p->sha, temp, num); in XzUnpacker_Code()
646 p->indexSize += num; in XzUnpacker_Code()
647 p->numBlocks++; in XzUnpacker_Code()
649 p->state = XZ_STATE_BLOCK_FOOTER; in XzUnpacker_Code()
650 p->pos = 0; in XzUnpacker_Code()
651 p->alignPos = 0; in XzUnpacker_Code()
665 switch(p->state) in XzUnpacker_Code()
669 if (p->pos < XZ_STREAM_HEADER_SIZE) in XzUnpacker_Code()
671 if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos]) in XzUnpacker_Code()
673 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
678 RINOK(Xz_ParseHeader(&p->streamFlags, p->buf)); in XzUnpacker_Code()
679 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
680 Sha256_Init(&p->sha); in XzUnpacker_Code()
681 p->indexSize = 0; in XzUnpacker_Code()
682 p->numBlocks = 0; in XzUnpacker_Code()
683 p->pos = 0; in XzUnpacker_Code()
690 if (p->pos == 0) in XzUnpacker_Code()
692 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
694 if (p->buf[0] == 0) in XzUnpacker_Code()
696 p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks); in XzUnpacker_Code()
697 p->indexPos = p->indexPreSize; in XzUnpacker_Code()
698 p->indexSize += p->indexPreSize; in XzUnpacker_Code()
699 Sha256_Final(&p->sha, p->shaDigest); in XzUnpacker_Code()
700 Sha256_Init(&p->sha); in XzUnpacker_Code()
701 p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize); in XzUnpacker_Code()
702 p->state = XZ_STATE_STREAM_INDEX; in XzUnpacker_Code()
704 p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4; in XzUnpacker_Code()
706 else if (p->pos != p->blockHeaderSize) in XzUnpacker_Code()
708 UInt32 cur = p->blockHeaderSize - p->pos; in XzUnpacker_Code()
711 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
712 p->pos += cur; in XzUnpacker_Code()
718 RINOK(XzBlock_Parse(&p->block, p->buf)); in XzUnpacker_Code()
719 p->state = XZ_STATE_BLOCK; in XzUnpacker_Code()
720 p->packSize = 0; in XzUnpacker_Code()
721 p->unpackSize = 0; in XzUnpacker_Code()
722 XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags)); in XzUnpacker_Code()
723 RINOK(XzDec_Init(&p->decoder, &p->block)); in XzUnpacker_Code()
730 if (((p->packSize + p->alignPos) & 3) != 0) in XzUnpacker_Code()
733 p->alignPos++; in XzUnpacker_Code()
739 UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags); in XzUnpacker_Code()
740 UInt32 cur = checkSize - p->pos; in XzUnpacker_Code()
745 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
746 p->pos += cur; in XzUnpacker_Code()
753 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
754 p->pos = 0; in XzUnpacker_Code()
755 if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0) in XzUnpacker_Code()
764 if (p->pos < p->indexPreSize) in XzUnpacker_Code()
767 if (*src++ != p->buf[p->pos++]) in XzUnpacker_Code()
772 if (p->indexPos < p->indexSize) in XzUnpacker_Code()
774 UInt64 cur = p->indexSize - p->indexPos; in XzUnpacker_Code()
777 p->crc = CrcUpdate(p->crc, src, srcRem); in XzUnpacker_Code()
778 Sha256_Update(&p->sha, src, srcRem); in XzUnpacker_Code()
781 p->indexPos += srcRem; in XzUnpacker_Code()
783 else if ((p->indexPos & 3) != 0) in XzUnpacker_Code()
786 p->crc = CRC_UPDATE_BYTE(p->crc, b); in XzUnpacker_Code()
788 p->indexPos++; in XzUnpacker_Code()
789 p->indexSize++; in XzUnpacker_Code()
796 p->state = XZ_STATE_STREAM_INDEX_CRC; in XzUnpacker_Code()
797 p->indexSize += 4; in XzUnpacker_Code()
798 p->pos = 0; in XzUnpacker_Code()
799 Sha256_Final(&p->sha, digest); in XzUnpacker_Code()
800 if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0) in XzUnpacker_Code()
809 if (p->pos < 4) in XzUnpacker_Code()
812 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
816 p->state = XZ_STATE_STREAM_FOOTER; in XzUnpacker_Code()
817 p->pos = 0; in XzUnpacker_Code()
818 if (CRC_GET_DIGEST(p->crc) != GetUi32(p->buf)) in XzUnpacker_Code()
826 UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos; in XzUnpacker_Code()
829 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
830 p->pos += cur; in XzUnpacker_Code()
833 if (p->pos == XZ_STREAM_FOOTER_SIZE) in XzUnpacker_Code()
835 p->state = XZ_STATE_STREAM_PADDING; in XzUnpacker_Code()
836 p->numStreams++; in XzUnpacker_Code()
837 p->padSize = 0; in XzUnpacker_Code()
838 if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf)) in XzUnpacker_Code()
848 if (((UInt32)p->padSize & 3) != 0) in XzUnpacker_Code()
850 p->pos = 0; in XzUnpacker_Code()
851 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Code()
857 p->padSize++; in XzUnpacker_Code()
872 Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p) in XzUnpacker_IsStreamWasFinished() argument
874 return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0); in XzUnpacker_IsStreamWasFinished()