Lines Matching refs:p

33 unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value)  in Xz_ReadVarInt()  argument
41 Byte b = p[i]; in Xz_ReadVarInt()
76 CBraState *p = ((CBraState *)pp); in BraState_SetProps() local
78 p->ip = 0; in BraState_SetProps()
79 if (p->methodId == XZ_ID_Delta) in BraState_SetProps()
83 p->delta = (unsigned)props[0] + 1; in BraState_SetProps()
90 switch(p->methodId) in BraState_SetProps()
107 p->ip = v; in BraState_SetProps()
117 CBraState *p = ((CBraState *)pp); in BraState_Init() local
118 p->bufPos = p->bufConv = p->bufTotal = 0; in BraState_Init()
119 x86_Convert_Init(p->x86State); in BraState_Init()
120 if (p->methodId == XZ_ID_Delta) in BraState_Init()
121 Delta_Init(p->deltaState); in BraState_Init()
124 #define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: p->bufConv = isa ## _Convert(p->buf, p->bufTotal, p-…
129 CBraState *p = ((CBraState *)pp); in BraState_Code() local
138 if (p->bufPos != p->bufConv) in BraState_Code()
140 size_t curSize = p->bufConv - p->bufPos; in BraState_Code()
143 memcpy(dest, p->buf + p->bufPos, curSize); in BraState_Code()
144 p->bufPos += curSize; in BraState_Code()
150 p->bufTotal -= p->bufPos; in BraState_Code()
151 memmove(p->buf, p->buf + p->bufPos, p->bufTotal); in BraState_Code()
152 p->bufPos = 0; in BraState_Code()
153 p->bufConv = 0; in BraState_Code()
155 size_t curSize = BRA_BUF_SIZE - p->bufTotal; in BraState_Code()
158 memcpy(p->buf + p->bufTotal, src, curSize); in BraState_Code()
162 p->bufTotal += curSize; in BraState_Code()
164 if (p->bufTotal == 0) in BraState_Code()
166 switch(p->methodId) in BraState_Code()
169 if (p->encodeMode) in BraState_Code()
170 Delta_Encode(p->deltaState, p->delta, p->buf, p->bufTotal); in BraState_Code()
172 Delta_Decode(p->deltaState, p->delta, p->buf, p->bufTotal); in BraState_Code()
173 p->bufConv = p->bufTotal; in BraState_Code()
176 p->bufConv = x86_Convert(p->buf, p->bufTotal, p->ip, &p->x86State, p->encodeMode); in BraState_Code()
186 p->ip += (UInt32)p->bufConv; in BraState_Code()
188 if (p->bufConv == 0) in BraState_Code()
192 p->bufConv = p->bufTotal; in BraState_Code()
195 if (p->bufTotal == p->bufPos && srcLenOrig == 0 && srcWasFinished) in BraState_Code()
200 SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc *alloc) in BraState_SetFromMethod() argument
211 p->p = 0; in BraState_SetFromMethod()
217 p->p = decoder; in BraState_SetFromMethod()
218 p->Free = BraState_Free; in BraState_SetFromMethod()
219 p->SetProps = BraState_SetProps; in BraState_SetFromMethod()
220 p->Init = BraState_Init; in BraState_SetFromMethod()
221 p->Code = BraState_Code; in BraState_SetFromMethod()
231 CSbDec *p = (CSbDec *)pp; in SbState_Free() local
232 SbDec_Free(p); in SbState_Free()
252 CSbDec *p = (CSbDec *)pp; in SbState_Code() local
255 p->dest = dest; in SbState_Code()
256 p->destLen = *destLen; in SbState_Code()
257 p->src = src; in SbState_Code()
258 p->srcLen = *srcLen; in SbState_Code()
259 p->finish = finishMode; /* change it */ in SbState_Code()
261 *destLen -= p->destLen; in SbState_Code()
262 *srcLen -= p->srcLen; in SbState_Code()
267 SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc) in SbState_SetFromMethod() argument
270 p->p = 0; in SbState_SetFromMethod()
274 p->p = decoder; in SbState_SetFromMethod()
275 p->Free = SbState_Free; in SbState_SetFromMethod()
276 p->SetProps = SbState_SetProps; in SbState_SetFromMethod()
277 p->Init = SbState_Init; in SbState_SetFromMethod()
278 p->Code = SbState_Code; in SbState_SetFromMethod()
316 static SRes Lzma2State_SetFromMethod(IStateCoder *p, ISzAlloc *alloc) in Lzma2State_SetFromMethod() argument
319 p->p = decoder; in Lzma2State_SetFromMethod()
322 p->Free = Lzma2State_Free; in Lzma2State_SetFromMethod()
323 p->SetProps = Lzma2State_SetProps; in Lzma2State_SetFromMethod()
324 p->Init = Lzma2State_Init; in Lzma2State_SetFromMethod()
325 p->Code = Lzma2State_Code; in Lzma2State_SetFromMethod()
331 void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc) in MixCoder_Construct() argument
334 p->alloc = alloc; in MixCoder_Construct()
335 p->buf = 0; in MixCoder_Construct()
336 p->numCoders = 0; in MixCoder_Construct()
338 p->coders[i].p = NULL; in MixCoder_Construct()
341 void MixCoder_Free(CMixCoder *p) in MixCoder_Free() argument
344 for (i = 0; i < p->numCoders; i++) in MixCoder_Free()
346 IStateCoder *sc = &p->coders[i]; in MixCoder_Free()
347 if (p->alloc && sc->p) in MixCoder_Free()
348 sc->Free(sc->p, p->alloc); in MixCoder_Free()
350 p->numCoders = 0; in MixCoder_Free()
351 if (p->buf) in MixCoder_Free()
353 p->alloc->Free(p->alloc, p->buf); in MixCoder_Free()
354 p->buf = 0; /* 9.31: the BUG was fixed */ in MixCoder_Free()
358 void MixCoder_Init(CMixCoder *p) in MixCoder_Init() argument
361 for (i = 0; i < p->numCoders - 1; i++) in MixCoder_Init()
363 p->size[i] = 0; in MixCoder_Init()
364 p->pos[i] = 0; in MixCoder_Init()
365 p->finished[i] = 0; in MixCoder_Init()
367 for (i = 0; i < p->numCoders; i++) in MixCoder_Init()
369 IStateCoder *coder = &p->coders[i]; in MixCoder_Init()
370 coder->Init(coder->p); in MixCoder_Init()
374 SRes MixCoder_SetFromMethod(CMixCoder *p, int coderIndex, UInt64 methodId) in MixCoder_SetFromMethod() argument
376 IStateCoder *sc = &p->coders[coderIndex]; in MixCoder_SetFromMethod()
377 p->ids[coderIndex] = methodId; in MixCoder_SetFromMethod()
380 case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, p->alloc); in MixCoder_SetFromMethod()
382 case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc); in MixCoder_SetFromMethod()
387 return BraState_SetFromMethod(sc, methodId, 0, p->alloc); in MixCoder_SetFromMethod()
390 SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen, in MixCoder_Code() argument
401 if (p->buf == 0) in MixCoder_Code()
403 p->buf = (Byte *)p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1)); in MixCoder_Code()
404 if (p->buf == 0) in MixCoder_Code()
408 if (p->numCoders != 1) in MixCoder_Code()
420 for (i = 0; i < p->numCoders; i++) in MixCoder_Code()
423 IStateCoder *coder = &p->coders[i]; in MixCoder_Code()
438 srcCur = p->buf + (CODER_BUF_SIZE * (i - 1)) + p->pos[i - 1]; in MixCoder_Code()
439 srcLenCur = p->size[i - 1] - p->pos[i - 1]; in MixCoder_Code()
440 srcFinishedCur = p->finished[i - 1]; in MixCoder_Code()
443 if (i == p->numCoders - 1) in MixCoder_Code()
450 if (p->pos[i] != p->size[i]) in MixCoder_Code()
452 destCur = p->buf + (CODER_BUF_SIZE * i); in MixCoder_Code()
456 …res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, … in MixCoder_Code()
468 p->pos[i - 1] += srcLenCur; in MixCoder_Code()
471 if (i == p->numCoders - 1) in MixCoder_Code()
478 p->size[i] = destLenCur; in MixCoder_Code()
479 p->pos[i] = 0; in MixCoder_Code()
480 p->finished[i] = encodingWasFinished; in MixCoder_Code()
497 SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf) in Xz_ParseHeader() argument
499 *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE); in Xz_ParseHeader()
503 return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED; in Xz_ParseHeader()
520 SRes XzBlock_Parse(CXzBlock *p, const Byte *header) in XzBlock_Parse() argument
532 p->flags = header[pos++]; in XzBlock_Parse()
534 if (XzBlock_HasPackSize(p)) in XzBlock_Parse()
536 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize); in XzBlock_Parse()
537 if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63) in XzBlock_Parse()
541 if (XzBlock_HasUnpackSize(p)) in XzBlock_Parse()
542 READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize); in XzBlock_Parse()
544 numFilters = XzBlock_GetNumFilters(p); in XzBlock_Parse()
547 CXzFilter *filter = p->filters + i; in XzBlock_Parse()
573 SRes XzDec_Init(CMixCoder *p, const CXzBlock *block) in XzDec_Init() argument
578 if (numFilters == p->numCoders) in XzDec_Init()
581 if (p->ids[i] != block->filters[numFilters - 1 - i].id) in XzDec_Init()
587 MixCoder_Free(p); in XzDec_Init()
588 p->numCoders = numFilters; in XzDec_Init()
592 RINOK(MixCoder_SetFromMethod(p, i, f->id)); in XzDec_Init()
598 IStateCoder *sc = &p->coders[i]; in XzDec_Init()
599 RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc)); in XzDec_Init()
601 MixCoder_Init(p); in XzDec_Init()
605 void XzUnpacker_Init(CXzUnpacker *p) in XzUnpacker_Init() argument
607 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Init()
608 p->pos = 0; in XzUnpacker_Init()
609 p->numStartedStreams = 0; in XzUnpacker_Init()
610 p->numFinishedStreams = 0; in XzUnpacker_Init()
611 p->numTotalBlocks = 0; in XzUnpacker_Init()
612 p->padSize = 0; in XzUnpacker_Init()
615 void XzUnpacker_Construct(CXzUnpacker *p, ISzAlloc *alloc) in XzUnpacker_Construct() argument
617 MixCoder_Construct(&p->decoder, alloc); in XzUnpacker_Construct()
618 XzUnpacker_Init(p); in XzUnpacker_Construct()
621 void XzUnpacker_Free(CXzUnpacker *p) in XzUnpacker_Free() argument
623 MixCoder_Free(&p->decoder); in XzUnpacker_Free()
626 SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, in XzUnpacker_Code() argument
638 if (p->state == XZ_STATE_BLOCK) in XzUnpacker_Code()
649 res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status); in XzUnpacker_Code()
650 XzCheck_Update(&p->check, dest, destLen2); in XzUnpacker_Code()
654 p->packSize += srcLen2; in XzUnpacker_Code()
658 p->unpackSize += destLen2; in XzUnpacker_Code()
665 …unsigned num = Xz_WriteVarInt(temp, p->packSize + p->blockHeaderSize + XzFlags_GetCheckSize(p->str… in XzUnpacker_Code()
666 num += Xz_WriteVarInt(temp + num, p->unpackSize); in XzUnpacker_Code()
667 Sha256_Update(&p->sha, temp, num); in XzUnpacker_Code()
668 p->indexSize += num; in XzUnpacker_Code()
669 p->numBlocks++; in XzUnpacker_Code()
671 p->state = XZ_STATE_BLOCK_FOOTER; in XzUnpacker_Code()
672 p->pos = 0; in XzUnpacker_Code()
673 p->alignPos = 0; in XzUnpacker_Code()
687 switch (p->state) in XzUnpacker_Code()
691 if (p->pos < XZ_STREAM_HEADER_SIZE) in XzUnpacker_Code()
693 if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos]) in XzUnpacker_Code()
695 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
700 RINOK(Xz_ParseHeader(&p->streamFlags, p->buf)); in XzUnpacker_Code()
701 p->numStartedStreams++; in XzUnpacker_Code()
702 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
703 Sha256_Init(&p->sha); in XzUnpacker_Code()
704 p->indexSize = 0; in XzUnpacker_Code()
705 p->numBlocks = 0; in XzUnpacker_Code()
706 p->pos = 0; in XzUnpacker_Code()
713 if (p->pos == 0) in XzUnpacker_Code()
715 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
717 if (p->buf[0] == 0) in XzUnpacker_Code()
719 p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks); in XzUnpacker_Code()
720 p->indexPos = p->indexPreSize; in XzUnpacker_Code()
721 p->indexSize += p->indexPreSize; in XzUnpacker_Code()
722 Sha256_Final(&p->sha, p->shaDigest); in XzUnpacker_Code()
723 Sha256_Init(&p->sha); in XzUnpacker_Code()
724 p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize); in XzUnpacker_Code()
725 p->state = XZ_STATE_STREAM_INDEX; in XzUnpacker_Code()
727 p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4; in XzUnpacker_Code()
729 else if (p->pos != p->blockHeaderSize) in XzUnpacker_Code()
731 UInt32 cur = p->blockHeaderSize - p->pos; in XzUnpacker_Code()
734 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
735 p->pos += cur; in XzUnpacker_Code()
741 RINOK(XzBlock_Parse(&p->block, p->buf)); in XzUnpacker_Code()
742 p->numTotalBlocks++; in XzUnpacker_Code()
743 p->state = XZ_STATE_BLOCK; in XzUnpacker_Code()
744 p->packSize = 0; in XzUnpacker_Code()
745 p->unpackSize = 0; in XzUnpacker_Code()
746 XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags)); in XzUnpacker_Code()
747 RINOK(XzDec_Init(&p->decoder, &p->block)); in XzUnpacker_Code()
754 if (((p->packSize + p->alignPos) & 3) != 0) in XzUnpacker_Code()
757 p->alignPos++; in XzUnpacker_Code()
763 UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags); in XzUnpacker_Code()
764 UInt32 cur = checkSize - p->pos; in XzUnpacker_Code()
769 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
770 p->pos += cur; in XzUnpacker_Code()
777 p->state = XZ_STATE_BLOCK_HEADER; in XzUnpacker_Code()
778 p->pos = 0; in XzUnpacker_Code()
779 if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0) in XzUnpacker_Code()
788 if (p->pos < p->indexPreSize) in XzUnpacker_Code()
791 if (*src++ != p->buf[p->pos++]) in XzUnpacker_Code()
796 if (p->indexPos < p->indexSize) in XzUnpacker_Code()
798 UInt64 cur = p->indexSize - p->indexPos; in XzUnpacker_Code()
801 p->crc = CrcUpdate(p->crc, src, srcRem); in XzUnpacker_Code()
802 Sha256_Update(&p->sha, src, srcRem); in XzUnpacker_Code()
805 p->indexPos += srcRem; in XzUnpacker_Code()
807 else if ((p->indexPos & 3) != 0) in XzUnpacker_Code()
810 p->crc = CRC_UPDATE_BYTE(p->crc, b); in XzUnpacker_Code()
812 p->indexPos++; in XzUnpacker_Code()
813 p->indexSize++; in XzUnpacker_Code()
820 p->state = XZ_STATE_STREAM_INDEX_CRC; in XzUnpacker_Code()
821 p->indexSize += 4; in XzUnpacker_Code()
822 p->pos = 0; in XzUnpacker_Code()
823 Sha256_Final(&p->sha, digest); in XzUnpacker_Code()
824 if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0) in XzUnpacker_Code()
833 if (p->pos < 4) in XzUnpacker_Code()
836 p->buf[p->pos++] = *src++; in XzUnpacker_Code()
840 p->state = XZ_STATE_STREAM_FOOTER; in XzUnpacker_Code()
841 p->pos = 0; in XzUnpacker_Code()
842 if (CRC_GET_DIGEST(p->crc) != GetUi32(p->buf)) in XzUnpacker_Code()
850 UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos; in XzUnpacker_Code()
853 memcpy(p->buf + p->pos, src, cur); in XzUnpacker_Code()
854 p->pos += cur; in XzUnpacker_Code()
857 if (p->pos == XZ_STREAM_FOOTER_SIZE) in XzUnpacker_Code()
859 p->state = XZ_STATE_STREAM_PADDING; in XzUnpacker_Code()
860 p->numFinishedStreams++; in XzUnpacker_Code()
861 p->padSize = 0; in XzUnpacker_Code()
862 if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf)) in XzUnpacker_Code()
872 if (((UInt32)p->padSize & 3) != 0) in XzUnpacker_Code()
874 p->pos = 0; in XzUnpacker_Code()
875 p->state = XZ_STATE_STREAM_HEADER; in XzUnpacker_Code()
881 p->padSize++; in XzUnpacker_Code()
896 Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p) in XzUnpacker_IsStreamWasFinished() argument
898 return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0); in XzUnpacker_IsStreamWasFinished()
901 UInt64 XzUnpacker_GetExtraSize(CXzUnpacker *p) in XzUnpacker_GetExtraSize() argument
904 if (p->state == XZ_STATE_STREAM_PADDING) in XzUnpacker_GetExtraSize()
905 num += p->padSize; in XzUnpacker_GetExtraSize()
906 else if (p->state == XZ_STATE_STREAM_HEADER) in XzUnpacker_GetExtraSize()
907 num += p->padSize + p->pos; in XzUnpacker_GetExtraSize()