MCPcopy Create free account
hub / github.com/coreboot/coreboot / LzmaDecode

Function LzmaDecode

src/lib/lzmadecode.c:208–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206#define kLzmaStreamWasFinishedId (-1)
207
208__lzma_attribute_Ofast__
209int LzmaDecode(CLzmaDecoderState *vs,
210 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
211 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
212{
213 CProb *p = vs->Probs;
214 SizeT nowPos = 0;
215 Byte previousByte = 0;
216 UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
217 UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
218 int lc = vs->Properties.lc;
219
220
221 int state = 0;
222 UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
223 int len = 0;
224 const Byte *Buffer;
225 const Byte *BufferLim;
226 int look_ahead_ptr = sizeof(SizeT);
227 union {
228 Byte raw[sizeof(SizeT)];
229 SizeT dw;
230 } look_ahead;
231 UInt32 Range;
232 UInt32 Code;
233
234 *inSizeProcessed = 0;
235 *outSizeProcessed = 0;
236
237 {
238 UInt32 i;
239 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc
240 + vs->Properties.lp));
241 for (i = 0; i < numProbs; i++)
242 p[i] = kBitModelTotal >> 1;
243 }
244
245 RC_INIT(inStream, inSize);
246
247
248 while (nowPos < outSize) {
249 CProb *prob;
250 UInt32 bound;
251 int posState = (int)((nowPos)&posStateMask);
252
253 prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
254 IfBit0(prob) {
255 int symbol = 1;
256 UpdateBit0(prob);
257 prob = p + Literal + (LZMA_LIT_SIZE *
258 ((((nowPos) & literalPosMask) << lc)
259 + (previousByte >> (8 - lc))));
260
261 if (state >= kNumLitStates) {
262 int matchByte;
263 matchByte = outStream[nowPos - rep0];
264 do {
265 int bit;

Callers 1

ulzmanFunction · 0.70

Calls 1

ifFunction · 0.50

Tested by

no test coverage detected