Lines Matching refs:p
22 #define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code… argument
23 #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits… argument
24 #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); argument
25 #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ argument
26 { UPDATE_0(p); i = (i + i); A0; } else \
27 { UPDATE_1(p); i = (i + i) + 1; A1; }
28 #define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) argument
52 #define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * t… argument
55 #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ argument
58 #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) argument
113 #define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) argument
134 static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) in LzmaDec_DecodeReal() argument
136 CLzmaProb *probs = p->probs; in LzmaDec_DecodeReal()
138 unsigned state = p->state; in LzmaDec_DecodeReal()
139 UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; in LzmaDec_DecodeReal()
140 unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; in LzmaDec_DecodeReal()
141 unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; in LzmaDec_DecodeReal()
142 unsigned lc = p->prop.lc; in LzmaDec_DecodeReal()
144 Byte *dic = p->dic; in LzmaDec_DecodeReal()
145 SizeT dicBufSize = p->dicBufSize; in LzmaDec_DecodeReal()
146 SizeT dicPos = p->dicPos; in LzmaDec_DecodeReal()
148 UInt32 processedPos = p->processedPos; in LzmaDec_DecodeReal()
149 UInt32 checkDicSize = p->checkDicSize; in LzmaDec_DecodeReal()
152 const Byte *buf = p->buf; in LzmaDec_DecodeReal()
153 UInt32 range = p->range; in LzmaDec_DecodeReal()
154 UInt32 code = p->code; in LzmaDec_DecodeReal()
186 unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; in LzmaDec_DecodeReal()
439 p->buf = buf; in LzmaDec_DecodeReal()
440 p->range = range; in LzmaDec_DecodeReal()
441 p->code = code; in LzmaDec_DecodeReal()
442 p->remainLen = len; in LzmaDec_DecodeReal()
443 p->dicPos = dicPos; in LzmaDec_DecodeReal()
444 p->processedPos = processedPos; in LzmaDec_DecodeReal()
445 p->reps[0] = rep0; in LzmaDec_DecodeReal()
446 p->reps[1] = rep1; in LzmaDec_DecodeReal()
447 p->reps[2] = rep2; in LzmaDec_DecodeReal()
448 p->reps[3] = rep3; in LzmaDec_DecodeReal()
449 p->state = state; in LzmaDec_DecodeReal()
454 static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) in LzmaDec_WriteRem() argument
456 if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) in LzmaDec_WriteRem()
458 Byte *dic = p->dic; in LzmaDec_WriteRem()
459 SizeT dicPos = p->dicPos; in LzmaDec_WriteRem()
460 SizeT dicBufSize = p->dicBufSize; in LzmaDec_WriteRem()
461 unsigned len = p->remainLen; in LzmaDec_WriteRem()
462 UInt32 rep0 = p->reps[0]; in LzmaDec_WriteRem()
466 if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) in LzmaDec_WriteRem()
467 p->checkDicSize = p->prop.dicSize; in LzmaDec_WriteRem()
469 p->processedPos += len; in LzmaDec_WriteRem()
470 p->remainLen -= len; in LzmaDec_WriteRem()
476 p->dicPos = dicPos; in LzmaDec_WriteRem()
480 static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) in LzmaDec_DecodeReal2() argument
485 if (p->checkDicSize == 0) in LzmaDec_DecodeReal2()
487 UInt32 rem = p->prop.dicSize - p->processedPos; in LzmaDec_DecodeReal2()
488 if (limit - p->dicPos > rem) in LzmaDec_DecodeReal2()
489 limit2 = p->dicPos + rem; in LzmaDec_DecodeReal2()
491 RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); in LzmaDec_DecodeReal2()
492 if (p->processedPos >= p->prop.dicSize) in LzmaDec_DecodeReal2()
493 p->checkDicSize = p->prop.dicSize; in LzmaDec_DecodeReal2()
494 LzmaDec_WriteRem(p, limit); in LzmaDec_DecodeReal2()
496 while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); in LzmaDec_DecodeReal2()
498 if (p->remainLen > kMatchSpecLenStart) in LzmaDec_DecodeReal2()
500 p->remainLen = kMatchSpecLenStart; in LzmaDec_DecodeReal2()
513 static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) in LzmaDec_TryDummy() argument
515 UInt32 range = p->range; in LzmaDec_TryDummy()
516 UInt32 code = p->code; in LzmaDec_TryDummy()
518 CLzmaProb *probs = p->probs; in LzmaDec_TryDummy()
519 unsigned state = p->state; in LzmaDec_TryDummy()
526 unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); in LzmaDec_TryDummy()
536 if (p->checkDicSize != 0 || p->processedPos != 0) in LzmaDec_TryDummy()
538 ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + in LzmaDec_TryDummy()
539 (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); in LzmaDec_TryDummy()
548 unsigned matchByte = p->dic[p->dicPos - p->reps[0] + in LzmaDec_TryDummy()
549 ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; in LzmaDec_TryDummy()
704 static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) in LzmaDec_InitRc() argument
706 …p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)da… in LzmaDec_InitRc()
707 p->range = 0xFFFFFFFF; in LzmaDec_InitRc()
708 p->needFlush = 0; in LzmaDec_InitRc()
711 void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) in LzmaDec_InitDicAndState() argument
713 p->needFlush = 1; in LzmaDec_InitDicAndState()
714 p->remainLen = 0; in LzmaDec_InitDicAndState()
715 p->tempBufSize = 0; in LzmaDec_InitDicAndState()
719 p->processedPos = 0; in LzmaDec_InitDicAndState()
720 p->checkDicSize = 0; in LzmaDec_InitDicAndState()
721 p->needInitState = 1; in LzmaDec_InitDicAndState()
724 p->needInitState = 1; in LzmaDec_InitDicAndState()
727 void LzmaDec_Init(CLzmaDec *p) in LzmaDec_Init() argument
729 p->dicPos = 0; in LzmaDec_Init()
730 LzmaDec_InitDicAndState(p, True, True); in LzmaDec_Init()
733 static void LzmaDec_InitStateReal(CLzmaDec *p) in LzmaDec_InitStateReal() argument
735 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); in LzmaDec_InitStateReal()
737 CLzmaProb *probs = p->probs; in LzmaDec_InitStateReal()
740 p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; in LzmaDec_InitStateReal()
741 p->state = 0; in LzmaDec_InitStateReal()
742 p->needInitState = 0; in LzmaDec_InitStateReal()
745 SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, in LzmaDec_DecodeToDic() argument
750 LzmaDec_WriteRem(p, dicLimit); in LzmaDec_DecodeToDic()
754 while (p->remainLen != kMatchSpecLenStart) in LzmaDec_DecodeToDic()
758 if (p->needFlush != 0) in LzmaDec_DecodeToDic()
760 for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) in LzmaDec_DecodeToDic()
761 p->tempBuf[p->tempBufSize++] = *src++; in LzmaDec_DecodeToDic()
762 if (p->tempBufSize < RC_INIT_SIZE) in LzmaDec_DecodeToDic()
767 if (p->tempBuf[0] != 0) in LzmaDec_DecodeToDic()
770 LzmaDec_InitRc(p, p->tempBuf); in LzmaDec_DecodeToDic()
771 p->tempBufSize = 0; in LzmaDec_DecodeToDic()
775 if (p->dicPos >= dicLimit) in LzmaDec_DecodeToDic()
777 if (p->remainLen == 0 && p->code == 0) in LzmaDec_DecodeToDic()
787 if (p->remainLen != 0) in LzmaDec_DecodeToDic()
795 if (p->needInitState) in LzmaDec_DecodeToDic()
796 LzmaDec_InitStateReal(p); in LzmaDec_DecodeToDic()
798 if (p->tempBufSize == 0) in LzmaDec_DecodeToDic()
804 int dummyRes = LzmaDec_TryDummy(p, src, inSize); in LzmaDec_DecodeToDic()
807 memcpy(p->tempBuf, src, inSize); in LzmaDec_DecodeToDic()
808 p->tempBufSize = (unsigned)inSize; in LzmaDec_DecodeToDic()
822 p->buf = src; in LzmaDec_DecodeToDic()
823 if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) in LzmaDec_DecodeToDic()
825 processed = (SizeT)(p->buf - src); in LzmaDec_DecodeToDic()
832 unsigned rem = p->tempBufSize, lookAhead = 0; in LzmaDec_DecodeToDic()
834 p->tempBuf[rem++] = src[lookAhead++]; in LzmaDec_DecodeToDic()
835 p->tempBufSize = rem; in LzmaDec_DecodeToDic()
838 int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); in LzmaDec_DecodeToDic()
851 p->buf = p->tempBuf; in LzmaDec_DecodeToDic()
852 if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) in LzmaDec_DecodeToDic()
854 lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); in LzmaDec_DecodeToDic()
858 p->tempBufSize = 0; in LzmaDec_DecodeToDic()
861 if (p->code == 0) in LzmaDec_DecodeToDic()
863 return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; in LzmaDec_DecodeToDic()
866 SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, E… in LzmaDec_DecodeToBuf() argument
876 if (p->dicPos == p->dicBufSize) in LzmaDec_DecodeToBuf()
877 p->dicPos = 0; in LzmaDec_DecodeToBuf()
878 dicPos = p->dicPos; in LzmaDec_DecodeToBuf()
879 if (outSize > p->dicBufSize - dicPos) in LzmaDec_DecodeToBuf()
881 outSizeCur = p->dicBufSize; in LzmaDec_DecodeToBuf()
890 res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); in LzmaDec_DecodeToBuf()
894 outSizeCur = p->dicPos - dicPos; in LzmaDec_DecodeToBuf()
895 memcpy(dest, p->dic + dicPos, outSizeCur); in LzmaDec_DecodeToBuf()
906 void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) in LzmaDec_FreeProbs() argument
908 alloc->Free(alloc, p->probs); in LzmaDec_FreeProbs()
909 p->probs = 0; in LzmaDec_FreeProbs()
912 static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) in LzmaDec_FreeDict() argument
914 alloc->Free(alloc, p->dic); in LzmaDec_FreeDict()
915 p->dic = 0; in LzmaDec_FreeDict()
918 void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) in LzmaDec_Free() argument
920 LzmaDec_FreeProbs(p, alloc); in LzmaDec_Free()
921 LzmaDec_FreeDict(p, alloc); in LzmaDec_Free()
924 SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) in LzmaProps_Decode() argument
936 p->dicSize = dicSize; in LzmaProps_Decode()
942 p->lc = d % 9; in LzmaProps_Decode()
944 p->pb = d / 5; in LzmaProps_Decode()
945 p->lp = d % 5; in LzmaProps_Decode()
950 static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) in LzmaDec_AllocateProbs2() argument
953 if (p->probs == 0 || numProbs != p->numProbs) in LzmaDec_AllocateProbs2()
955 LzmaDec_FreeProbs(p, alloc); in LzmaDec_AllocateProbs2()
956 p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); in LzmaDec_AllocateProbs2()
957 p->numProbs = numProbs; in LzmaDec_AllocateProbs2()
958 if (p->probs == 0) in LzmaDec_AllocateProbs2()
964 SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) in LzmaDec_AllocateProbs() argument
968 RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); in LzmaDec_AllocateProbs()
969 p->prop = propNew; in LzmaDec_AllocateProbs()
973 SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) in LzmaDec_Allocate() argument
978 RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); in LzmaDec_Allocate()
980 if (p->dic == 0 || dicBufSize != p->dicBufSize) in LzmaDec_Allocate()
982 LzmaDec_FreeDict(p, alloc); in LzmaDec_Allocate()
983 p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); in LzmaDec_Allocate()
984 if (p->dic == 0) in LzmaDec_Allocate()
986 LzmaDec_FreeProbs(p, alloc); in LzmaDec_Allocate()
990 p->dicBufSize = dicBufSize; in LzmaDec_Allocate()
991 p->prop = propNew; in LzmaDec_Allocate()
999 CLzmaDec p; in LzmaDecode() local
1007 LzmaDec_Construct(&p); in LzmaDecode()
1008 res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); in LzmaDecode()
1011 p.dic = dest; in LzmaDecode()
1012 p.dicBufSize = outSize; in LzmaDecode()
1014 LzmaDec_Init(&p); in LzmaDecode()
1017 res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); in LzmaDecode()
1022 (*destLen) = p.dicPos; in LzmaDecode()
1023 LzmaDec_FreeProbs(&p, alloc); in LzmaDecode()