• Home
  • Raw
  • Download

Lines Matching +full:p +full:- +full:limit

1 /* LzmaDec.c -- LZMA Decoder
2 2023-04-07 : Igor Pavlov : Public domain */
24 #define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; … argument
25 #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits… argument
26 #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); argument
27 #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ argument
28 { UPDATE_0(p) i = (i + i); A0; } else \
29 { UPDATE_1(p) i = (i + i) + 1; A1; }
33 #define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \ argument
34 { UPDATE_0(p + i) A0; } else \
35 { UPDATE_1(p + i) A1; }
36 #define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; ) argument
37 #define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; ) argument
38 #define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; ) argument
40 #define TREE_DECODE(probs, limit, i) \ argument
41 { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
56 i -= 0x40; }
72 #define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK bound = (range >> kNumBitModelTotalBits) * (U… argument
74 #define UPDATE_1_CHECK range -= bound; code -= bound;
75 #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ argument
78 #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) argument
79 #define TREE_DECODE_CHECK(probs, limit, i) \ argument
80 { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
83 #define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \ argument
121 #define kMatchSpecLen_Error_Fail (kMatchSpecLen_Error_Data - 1)
130 #define GET_PROBS p->probs_1664
132 #define GET_PROBS p->probs + kStartOffset
135 #define GET_PROBS p->probs
139 #define SpecPos (-kStartOffset)
164 #define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) argument
174 p->remainLen : shows status of LZMA decoder:
175 < kMatchSpecLenStart : the number of bytes to be copied with (p->rep0) offset
183 /* ---------- LZMA_DECODE_REAL ---------- */
186 3 - is the code compatibility version of that function for check at link time.
195 if (p->dicPos == limit)
197 LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases.
198 So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol
200 the function returns SZ_OK, and the caller can use (p->remainLen) and (p->reps[0]) later.
206 It decodes additional LZMA-symbols while (p->buf < bufLimit && dicPos < limit),
207 RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked.
208 But if (p->buf < bufLimit), the caller provided at least (LZMA_REQUIRED_INPUT_MAX + 1) bytes for
209 next iteration before limit (bufLimit + LZMA_REQUIRED_INPUT_MAX),
216 SZ_OK - OK
217 p->remainLen:
218 < kMatchSpecLenStart : the number of bytes to be copied with (p->reps[0]) offset
221 SZ_ERROR_DATA - error, when the MATCH-Symbol refers out of dictionary
222 p->remainLen : undefined
223 p->reps[*] : undefined
229 int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit);
234 int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) in LZMA_DECODE_REAL() argument
237 unsigned state = (unsigned)p->state; in LZMA_DECODE_REAL()
238 UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; in LZMA_DECODE_REAL()
239 unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; in LZMA_DECODE_REAL()
240 unsigned lc = p->prop.lc; in LZMA_DECODE_REAL()
241 unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc); in LZMA_DECODE_REAL()
243 Byte *dic = p->dic; in LZMA_DECODE_REAL()
244 SizeT dicBufSize = p->dicBufSize; in LZMA_DECODE_REAL()
245 SizeT dicPos = p->dicPos; in LZMA_DECODE_REAL()
247 UInt32 processedPos = p->processedPos; in LZMA_DECODE_REAL()
248 UInt32 checkDicSize = p->checkDicSize; in LZMA_DECODE_REAL()
251 const Byte *buf = p->buf; in LZMA_DECODE_REAL()
252 UInt32 range = p->range; in LZMA_DECODE_REAL()
253 UInt32 code = p->code; in LZMA_DECODE_REAL()
269 …prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMas… in LZMA_DECODE_REAL()
274 state -= (state < 4) ? state : 3; in LZMA_DECODE_REAL()
291 unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; in LZMA_DECODE_REAL()
293 state -= (state < 10) ? 3 : 6; in LZMA_DECODE_REAL()
346 // The caller doesn't allow (dicPos == limit) case here in LZMA_DECODE_REAL()
348 // if (dicPos == limit) { state = state < kNumLitStates ? 9 : 11; len = 1; break; } in LZMA_DECODE_REAL()
350 dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; in LZMA_DECODE_REAL()
436 len -= 8; in LZMA_DECODE_REAL()
466 ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); in LZMA_DECODE_REAL()
471 unsigned numDirectBits = (unsigned)(((distance >> 1) - 1)); in LZMA_DECODE_REAL()
484 while (--numDirectBits); in LZMA_DECODE_REAL()
485 distance -= m; in LZMA_DECODE_REAL()
490 numDirectBits -= kNumAlignBits; in LZMA_DECODE_REAL()
498 code -= range; in LZMA_DECODE_REAL()
499 t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ in LZMA_DECODE_REAL()
507 code -= range; in LZMA_DECODE_REAL()
512 while (--numDirectBits); in LZMA_DECODE_REAL()
526 state -= kNumStates; in LZMA_DECODE_REAL()
553 if ((rem = limit - dicPos) == 0) in LZMA_DECODE_REAL()
565 pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); in LZMA_DECODE_REAL()
569 len -= curLen; in LZMA_DECODE_REAL()
570 if (curLen <= dicBufSize - pos) in LZMA_DECODE_REAL()
573 ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; in LZMA_DECODE_REAL()
588 while (--curLen != 0); in LZMA_DECODE_REAL()
593 while (dicPos < limit && buf < bufLimit); in LZMA_DECODE_REAL()
597 p->buf = buf; in LZMA_DECODE_REAL()
598 p->range = range; in LZMA_DECODE_REAL()
599 p->code = code; in LZMA_DECODE_REAL()
600p->remainLen = (UInt32)len; // & (kMatchSpecLen_Error_Data - 1); // we can write real length for e… in LZMA_DECODE_REAL()
601 p->dicPos = dicPos; in LZMA_DECODE_REAL()
602 p->processedPos = processedPos; in LZMA_DECODE_REAL()
603 p->reps[0] = rep0; in LZMA_DECODE_REAL()
604 p->reps[1] = rep1; in LZMA_DECODE_REAL()
605 p->reps[2] = rep2; in LZMA_DECODE_REAL()
606 p->reps[3] = rep3; in LZMA_DECODE_REAL()
607 p->state = (UInt32)state; in LZMA_DECODE_REAL()
616 static void Z7_FASTCALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) in LzmaDec_WriteRem() argument
618 unsigned len = (unsigned)p->remainLen; in LzmaDec_WriteRem()
622 SizeT dicPos = p->dicPos; in LzmaDec_WriteRem()
627 SizeT rem = limit - dicPos; in LzmaDec_WriteRem()
636 if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) in LzmaDec_WriteRem()
637 p->checkDicSize = p->prop.dicSize; in LzmaDec_WriteRem()
639 p->processedPos += (UInt32)len; in LzmaDec_WriteRem()
640 p->remainLen -= (UInt32)len; in LzmaDec_WriteRem()
641 dic = p->dic; in LzmaDec_WriteRem()
642 rep0 = p->reps[0]; in LzmaDec_WriteRem()
643 dicBufSize = p->dicBufSize; in LzmaDec_WriteRem()
646 dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; in LzmaDec_WriteRem()
649 while (--len); in LzmaDec_WriteRem()
650 p->dicPos = dicPos; in LzmaDec_WriteRem()
657 - Literal - is allowed
658 - Non-Rep-Match - is allowed only if it's end marker symbol
659 - Rep-Match - is not allowed
664 #define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))
665 #define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTota…
666 #if kBadRepCode != (0xC0000000 - 0x400)
673 It calls LZMA_DECODE_REAL() and it adjusts limit according (p->checkDicSize).
675 We correct (p->checkDicSize) after LZMA_DECODE_REAL() and in LzmaDec_WriteRem(),
676 and we support the following state of (p->checkDicSize):
677 if (total_processed < p->prop.dicSize) then
679 (total_processed == p->processedPos)
680 (p->checkDicSize == 0)
683 (p->checkDicSize == p->prop.dicSize)
686 static int Z7_FASTCALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) in LzmaDec_DecodeReal2() argument
688 if (p->checkDicSize == 0) in LzmaDec_DecodeReal2()
690 UInt32 rem = p->prop.dicSize - p->processedPos; in LzmaDec_DecodeReal2()
691 if (limit - p->dicPos > rem) in LzmaDec_DecodeReal2()
692 limit = p->dicPos + rem; in LzmaDec_DecodeReal2()
695 int res = LZMA_DECODE_REAL(p, limit, bufLimit); in LzmaDec_DecodeReal2()
696 if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize) in LzmaDec_DecodeReal2()
697 p->checkDicSize = p->prop.dicSize; in LzmaDec_DecodeReal2()
715 static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byte **bufOut) in LzmaDec_TryDummy() argument
717 UInt32 range = p->range; in LzmaDec_TryDummy()
718 UInt32 code = p->code; in LzmaDec_TryDummy()
721 unsigned state = (unsigned)p->state; in LzmaDec_TryDummy()
729 unsigned posState = CALC_POS_STATE(p->processedPos, ((unsigned)1 << p->prop.pb) - 1); in LzmaDec_TryDummy()
737 if (p->checkDicSize != 0 || p->processedPos != 0) in LzmaDec_TryDummy()
739 ((((p->processedPos) & (((unsigned)1 << (p->prop.lp)) - 1)) << p->prop.lc) + in LzmaDec_TryDummy()
740 … ((unsigned)p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); in LzmaDec_TryDummy()
749 unsigned matchByte = p->dic[p->dicPos - p->reps[0] + in LzmaDec_TryDummy()
750 (p->dicPos < p->reps[0] ? p->dicBufSize : 0)]; in LzmaDec_TryDummy()
825 unsigned limit, offset; in LzmaDec_TryDummy() local
832 limit = 1 << kLenNumLowBits; in LzmaDec_TryDummy()
843 limit = 1 << kLenNumLowBits; in LzmaDec_TryDummy()
850 limit = 1 << kLenNumHighBits; in LzmaDec_TryDummy()
853 TREE_DECODE_CHECK(probLen, limit, len) in LzmaDec_TryDummy()
861 ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << in LzmaDec_TryDummy()
866 unsigned numDirectBits = ((posSlot >> 1) - 1); in LzmaDec_TryDummy()
874 numDirectBits -= kNumAlignBits; in LzmaDec_TryDummy()
879 code -= range & (((code - range) >> 31) - 1); in LzmaDec_TryDummy()
880 /* if (code >= range) code -= range; */ in LzmaDec_TryDummy()
882 while (--numDirectBits); in LzmaDec_TryDummy()
893 while (--numDirectBits); in LzmaDec_TryDummy()
906 void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState);
907 void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState) in LzmaDec_InitDicAndState() argument
909 p->remainLen = kMatchSpecLenStart + 1; in LzmaDec_InitDicAndState()
910 p->tempBufSize = 0; in LzmaDec_InitDicAndState()
914 p->processedPos = 0; in LzmaDec_InitDicAndState()
915 p->checkDicSize = 0; in LzmaDec_InitDicAndState()
916 p->remainLen = kMatchSpecLenStart + 2; in LzmaDec_InitDicAndState()
919 p->remainLen = kMatchSpecLenStart + 2; in LzmaDec_InitDicAndState()
922 void LzmaDec_Init(CLzmaDec *p) in LzmaDec_Init() argument
924 p->dicPos = 0; in LzmaDec_Init()
925 LzmaDec_InitDicAndState(p, True, True); in LzmaDec_Init()
931 So the decoder can lookahead for one additional LZMA-Symbol to check end_marker.
932 That additional LZMA-Symbol can require up to LZMA_REQUIRED_INPUT_MAX bytes in input stream.
952 SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, in LzmaDec_DecodeToDic() argument
959 if (p->remainLen > kMatchSpecLenStart) in LzmaDec_DecodeToDic()
961 if (p->remainLen > kMatchSpecLenStart + 2) in LzmaDec_DecodeToDic()
962 return p->remainLen == kMatchSpecLen_Error_Fail ? SZ_ERROR_FAIL : SZ_ERROR_DATA; in LzmaDec_DecodeToDic()
964 for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) in LzmaDec_DecodeToDic()
965 p->tempBuf[p->tempBufSize++] = *src++; in LzmaDec_DecodeToDic()
966 if (p->tempBufSize != 0 && p->tempBuf[0] != 0) in LzmaDec_DecodeToDic()
968 if (p->tempBufSize < RC_INIT_SIZE) in LzmaDec_DecodeToDic()
973 p->code = in LzmaDec_DecodeToDic()
974 ((UInt32)p->tempBuf[1] << 24) in LzmaDec_DecodeToDic()
975 | ((UInt32)p->tempBuf[2] << 16) in LzmaDec_DecodeToDic()
976 | ((UInt32)p->tempBuf[3] << 8) in LzmaDec_DecodeToDic()
977 | ((UInt32)p->tempBuf[4]); in LzmaDec_DecodeToDic()
979 if (p->checkDicSize == 0 in LzmaDec_DecodeToDic()
980 && p->processedPos == 0 in LzmaDec_DecodeToDic()
981 && p->code >= kBadRepCode) in LzmaDec_DecodeToDic()
984 p->range = 0xFFFFFFFF; in LzmaDec_DecodeToDic()
985 p->tempBufSize = 0; in LzmaDec_DecodeToDic()
987 if (p->remainLen > kMatchSpecLenStart + 1) in LzmaDec_DecodeToDic()
989 SizeT numProbs = LzmaProps_GetNumProbs(&p->prop); in LzmaDec_DecodeToDic()
991 CLzmaProb *probs = p->probs; in LzmaDec_DecodeToDic()
994 p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; in LzmaDec_DecodeToDic()
995 p->state = 0; in LzmaDec_DecodeToDic()
998 p->remainLen = 0; in LzmaDec_DecodeToDic()
1003 if (p->remainLen == kMatchSpecLenStart) in LzmaDec_DecodeToDic()
1005 if (p->code != 0) in LzmaDec_DecodeToDic()
1011 LzmaDec_WriteRem(p, dicLimit); in LzmaDec_DecodeToDic()
1014 // (p->remainLen == 0 || p->dicPos == dicLimit) in LzmaDec_DecodeToDic()
1018 if (p->dicPos >= dicLimit) in LzmaDec_DecodeToDic()
1020 if (p->remainLen == 0 && p->code == 0) in LzmaDec_DecodeToDic()
1030 if (p->remainLen != 0) in LzmaDec_DecodeToDic()
1037 // (p->remainLen == 0) in LzmaDec_DecodeToDic()
1039 if (p->tempBufSize == 0) in LzmaDec_DecodeToDic()
1042 int dummyProcessed = -1; in LzmaDec_DecodeToDic()
1048 ELzmaDummy dummyRes = LzmaDec_TryDummy(p, src, &bufOut); in LzmaDec_DecodeToDic()
1056 p->tempBufSize = (unsigned)inSize; in LzmaDec_DecodeToDic()
1058 p->tempBuf[i] = src[i]; in LzmaDec_DecodeToDic()
1063 dummyProcessed = (int)(bufOut - src); in LzmaDec_DecodeToDic()
1071 p->tempBufSize = (unsigned)dummyProcessed; in LzmaDec_DecodeToDic()
1073 p->tempBuf[i] = src[i]; in LzmaDec_DecodeToDic()
1074 // p->remainLen = kMatchSpecLen_Error_Data; in LzmaDec_DecodeToDic()
1082 bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; in LzmaDec_DecodeToDic()
1084 p->buf = src; in LzmaDec_DecodeToDic()
1087 int res = LzmaDec_DecodeReal2(p, dicLimit, bufLimit); in LzmaDec_DecodeToDic()
1089 SizeT processed = (SizeT)(p->buf - src); in LzmaDec_DecodeToDic()
1100 inSize -= processed; in LzmaDec_DecodeToDic()
1105 p->remainLen = kMatchSpecLen_Error_Data; in LzmaDec_DecodeToDic()
1113 // we have some data in (p->tempBuf) in LzmaDec_DecodeToDic()
1117 unsigned rem = p->tempBufSize; in LzmaDec_DecodeToDic()
1119 int dummyProcessed = -1; in LzmaDec_DecodeToDic()
1122 p->tempBuf[rem++] = src[ahead++]; in LzmaDec_DecodeToDic()
1124 // ahead - the size of new data copied from (src) to (p->tempBuf) in LzmaDec_DecodeToDic()
1125 // rem - the size of temp buffer including new data from (src) in LzmaDec_DecodeToDic()
1129 const Byte *bufOut = p->tempBuf + rem; in LzmaDec_DecodeToDic()
1131 ELzmaDummy dummyRes = LzmaDec_TryDummy(p, p->tempBuf, &bufOut); in LzmaDec_DecodeToDic()
1137 p->tempBufSize = rem; in LzmaDec_DecodeToDic()
1143 dummyProcessed = (int)(bufOut - p->tempBuf); in LzmaDec_DecodeToDic()
1145 if ((unsigned)dummyProcessed < p->tempBufSize) in LzmaDec_DecodeToDic()
1150 (*srcLen) += (unsigned)dummyProcessed - p->tempBufSize; in LzmaDec_DecodeToDic()
1151 p->tempBufSize = (unsigned)dummyProcessed; in LzmaDec_DecodeToDic()
1152 // p->remainLen = kMatchSpecLen_Error_Data; in LzmaDec_DecodeToDic()
1157 p->buf = p->tempBuf; in LzmaDec_DecodeToDic()
1160 // we decode one symbol from (p->tempBuf) here, so the (bufLimit) is equal to (p->buf) in LzmaDec_DecodeToDic()
1161 int res = LzmaDec_DecodeReal2(p, dicLimit, p->buf); in LzmaDec_DecodeToDic()
1163 SizeT processed = (SizeT)(p->buf - p->tempBuf); in LzmaDec_DecodeToDic()
1164 rem = p->tempBufSize; in LzmaDec_DecodeToDic()
1176 processed -= rem; in LzmaDec_DecodeToDic()
1179 inSize -= processed; in LzmaDec_DecodeToDic()
1181 p->tempBufSize = 0; in LzmaDec_DecodeToDic()
1185 p->remainLen = kMatchSpecLen_Error_Data; in LzmaDec_DecodeToDic()
1194 p->remainLen = kMatchSpecLen_Error_Fail; in LzmaDec_DecodeToDic()
1200 SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, E… in LzmaDec_DecodeToBuf() argument
1210 if (p->dicPos == p->dicBufSize) in LzmaDec_DecodeToBuf()
1211 p->dicPos = 0; in LzmaDec_DecodeToBuf()
1212 dicPos = p->dicPos; in LzmaDec_DecodeToBuf()
1213 if (outSize > p->dicBufSize - dicPos) in LzmaDec_DecodeToBuf()
1215 outSizeCur = p->dicBufSize; in LzmaDec_DecodeToBuf()
1224 res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); in LzmaDec_DecodeToBuf()
1226 inSize -= inSizeCur; in LzmaDec_DecodeToBuf()
1228 outSizeCur = p->dicPos - dicPos; in LzmaDec_DecodeToBuf()
1229 memcpy(dest, p->dic + dicPos, outSizeCur); in LzmaDec_DecodeToBuf()
1231 outSize -= outSizeCur; in LzmaDec_DecodeToBuf()
1240 void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc) in LzmaDec_FreeProbs() argument
1242 ISzAlloc_Free(alloc, p->probs); in LzmaDec_FreeProbs()
1243 p->probs = NULL; in LzmaDec_FreeProbs()
1246 static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc) in LzmaDec_FreeDict() argument
1248 ISzAlloc_Free(alloc, p->dic); in LzmaDec_FreeDict()
1249 p->dic = NULL; in LzmaDec_FreeDict()
1252 void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc) in LzmaDec_Free() argument
1254 LzmaDec_FreeProbs(p, alloc); in LzmaDec_Free()
1255 LzmaDec_FreeDict(p, alloc); in LzmaDec_Free()
1258 SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) in LzmaProps_Decode() argument
1270 p->dicSize = dicSize; in LzmaProps_Decode()
1276 p->lc = (Byte)(d % 9); in LzmaProps_Decode()
1278 p->pb = (Byte)(d / 5); in LzmaProps_Decode()
1279 p->lp = (Byte)(d % 5); in LzmaProps_Decode()
1284 static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc) in LzmaDec_AllocateProbs2() argument
1287 if (!p->probs || numProbs != p->numProbs) in LzmaDec_AllocateProbs2()
1289 LzmaDec_FreeProbs(p, alloc); in LzmaDec_AllocateProbs2()
1290 p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb)); in LzmaDec_AllocateProbs2()
1291 if (!p->probs) in LzmaDec_AllocateProbs2()
1293 p->probs_1664 = p->probs + 1664; in LzmaDec_AllocateProbs2()
1294 p->numProbs = numProbs; in LzmaDec_AllocateProbs2()
1299 SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) in LzmaDec_AllocateProbs() argument
1303 RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)) in LzmaDec_AllocateProbs()
1304 p->prop = propNew; in LzmaDec_AllocateProbs()
1308 SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) in LzmaDec_Allocate() argument
1313 RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)) in LzmaDec_Allocate()
1317 SizeT mask = ((UInt32)1 << 12) - 1; in LzmaDec_Allocate()
1318 if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1; in LzmaDec_Allocate()
1319 else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1; in LzmaDec_Allocate()
1325 if (!p->dic || dicBufSize != p->dicBufSize) in LzmaDec_Allocate()
1327 LzmaDec_FreeDict(p, alloc); in LzmaDec_Allocate()
1328 p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize); in LzmaDec_Allocate()
1329 if (!p->dic) in LzmaDec_Allocate()
1331 LzmaDec_FreeProbs(p, alloc); in LzmaDec_Allocate()
1335 p->dicBufSize = dicBufSize; in LzmaDec_Allocate()
1336 p->prop = propNew; in LzmaDec_Allocate()
1344 CLzmaDec p; in LzmaDecode() local
1351 LzmaDec_CONSTRUCT(&p) in LzmaDecode()
1352 RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc)) in LzmaDecode()
1353 p.dic = dest; in LzmaDecode()
1354 p.dicBufSize = outSize; in LzmaDecode()
1355 LzmaDec_Init(&p); in LzmaDecode()
1357 res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); in LzmaDecode()
1358 *destLen = p.dicPos; in LzmaDecode()
1361 LzmaDec_FreeProbs(&p, alloc); in LzmaDecode()