CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Macros | Enumerations | Functions
LzmaDec.cc File Reference
#include "LzmaDec.h"
#include <string.h>

Go to the source code of this file.

Macros

#define Align   (SpecPos + kNumFullDistances - kEndPosModelIndex)
 
#define GET_BIT(p, i)   GET_BIT2(p, i, ; , ;)
 
#define GET_BIT2(p, i, A0, A1)
 
#define GET_BIT2_CHECK(p, i, A0, A1)
 
#define GET_BIT_CHECK(p, i)   GET_BIT2_CHECK(p, i, ; , ;)
 
#define IF_BIT_0(p)   ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
 
#define IF_BIT_0_CHECK(p)   ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
 
#define IsMatch   0
 
#define IsRep   (IsMatch + (kNumStates << kNumPosBitsMax))
 
#define IsRep0Long   (IsRepG2 + kNumStates)
 
#define IsRepG0   (IsRep + kNumStates)
 
#define IsRepG1   (IsRepG0 + kNumStates)
 
#define IsRepG2   (IsRepG1 + kNumStates)
 
#define kAlignTableSize   (1 << kNumAlignBits)
 
#define kBitModelTotal   (1 << kNumBitModelTotalBits)
 
#define kEndPosModelIndex   14
 
#define kLenNumHighBits   8
 
#define kLenNumHighSymbols   (1 << kLenNumHighBits)
 
#define kLenNumLowBits   3
 
#define kLenNumLowSymbols   (1 << kLenNumLowBits)
 
#define kLenNumMidBits   3
 
#define kLenNumMidSymbols   (1 << kLenNumMidBits)
 
#define kMatchMinLen   2
 
#define kMatchSpecLenStart   (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
 
#define kNumAlignBits   4
 
#define kNumBitModelTotalBits   11
 
#define kNumFullDistances   (1 << (kEndPosModelIndex >> 1))
 
#define kNumLenProbs   (LenHigh + kLenNumHighSymbols)
 
#define kNumLenToPosStates   4
 
#define kNumLitStates   7
 
#define kNumMoveBits   5
 
#define kNumPosBitsMax   4
 
#define kNumPosSlotBits   6
 
#define kNumPosStatesMax   (1 << kNumPosBitsMax)
 
#define kNumStates   12
 
#define kNumTopBits   24
 
#define kStartPosModelIndex   4
 
#define kTopValue   ((UInt32)1 << kNumTopBits)
 
#define LenChoice   0
 
#define LenChoice2   (LenChoice + 1)
 
#define LenCoder   (Align + kAlignTableSize)
 
#define LenHigh   (LenMid + (kNumPosStatesMax << kLenNumMidBits))
 
#define LenLow   (LenChoice2 + 1)
 
#define LenMid   (LenLow + (kNumPosStatesMax << kLenNumLowBits))
 
#define Literal   (RepLenCoder + kNumLenProbs)
 
#define LZMA_BASE_SIZE   1846
 
#define LZMA_DIC_MIN   (1 << 12)
 
#define LZMA_LIT_SIZE   768
 
#define LzmaProps_GetNumProbs(p)   ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
 
#define NORMALIZE   if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
 
#define NORMALIZE_CHECK   if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
 
#define PosSlot   (IsRep0Long + (kNumStates << kNumPosBitsMax))
 
#define RC_INIT_SIZE   5
 
#define RepLenCoder   (LenCoder + kNumLenProbs)
 
#define SpecPos   (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
 
#define TREE_6_DECODE(probs, i)
 
#define TREE_DECODE(probs, limit, i)   { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
 
#define TREE_DECODE_CHECK(probs, limit, i)   { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
 
#define TREE_GET_BIT(probs, i)   { GET_BIT((probs + i), i); }
 
#define UPDATE_0(p)   range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
 
#define UPDATE_0_CHECK   range = bound;
 
#define UPDATE_1(p)   range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
 
#define UPDATE_1_CHECK   range -= bound; code -= bound;
 

Enumerations

enum  ELzmaDummy { DUMMY_ERROR, DUMMY_LIT, DUMMY_MATCH, DUMMY_REP }
 

Functions

SRes LzmaDec_Allocate (CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
 
SRes LzmaDec_AllocateProbs (CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
 
static SRes LzmaDec_AllocateProbs2 (CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
 
static int MY_FAST_CALL LzmaDec_DecodeReal (CLzmaDec *p, SizeT limit, const Byte *bufLimit)
 
static int MY_FAST_CALL LzmaDec_DecodeReal2 (CLzmaDec *p, SizeT limit, const Byte *bufLimit)
 
SRes LzmaDec_DecodeToBuf (CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
 
SRes LzmaDec_DecodeToDic (CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
 
void LzmaDec_Free (CLzmaDec *p, ISzAlloc *alloc)
 
static void LzmaDec_FreeDict (CLzmaDec *p, ISzAlloc *alloc)
 
void LzmaDec_FreeProbs (CLzmaDec *p, ISzAlloc *alloc)
 
void LzmaDec_Init (CLzmaDec *p)
 
void LzmaDec_InitDicAndState (CLzmaDec *p, Bool initDic, Bool initState)
 
static void LzmaDec_InitRc (CLzmaDec *p, const Byte *data)
 
static void LzmaDec_InitStateReal (CLzmaDec *p)
 
static ELzmaDummy LzmaDec_TryDummy (const CLzmaDec *p, const Byte *buf, SizeT inSize)
 
static void MY_FAST_CALL LzmaDec_WriteRem (CLzmaDec *p, SizeT limit)
 
SRes LzmaDecode (Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
 
SRes LzmaProps_Decode (CLzmaProps *p, const Byte *data, unsigned size)
 

Macro Definition Documentation

#define Align   (SpecPos + kNumFullDistances - kEndPosModelIndex)

Definition at line 102 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define GET_BIT (   p,
  i 
)    GET_BIT2(p, i, ; , ;)

Definition at line 25 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define GET_BIT2 (   p,
  i,
  A0,
  A1 
)
Value:
{ UPDATE_0(p); i = (i + i); A0; } else \
{ UPDATE_1(p); i = (i + i) + 1; A1; }
#define UPDATE_0(p)
Definition: LzmaDec.cc:20
int i
Definition: DBlmapReader.cc:9
#define UPDATE_1(p)
Definition: LzmaDec.cc:21
#define IF_BIT_0(p)
Definition: LzmaDec.cc:19

Definition at line 22 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define GET_BIT2_CHECK (   p,
  i,
  A0,
  A1 
)
Value:
{ UPDATE_0_CHECK; i = (i + i); A0; } else \
{ UPDATE_1_CHECK; i = (i + i) + 1; A1; }
int i
Definition: DBlmapReader.cc:9
#define IF_BIT_0_CHECK(p)
Definition: LzmaDec.cc:49
#define UPDATE_1_CHECK
Definition: LzmaDec.cc:51
#define UPDATE_0_CHECK
Definition: LzmaDec.cc:50

Definition at line 52 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define GET_BIT_CHECK (   p,
  i 
)    GET_BIT2_CHECK(p, i, ; , ;)

Definition at line 55 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define IF_BIT_0 (   p)    ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)

Definition at line 19 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define IF_BIT_0_CHECK (   p)    ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)

Definition at line 49 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define IsMatch   0

Definition at line 94 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define IsRep   (IsMatch + (kNumStates << kNumPosBitsMax))

Definition at line 95 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define IsRep0Long   (IsRepG2 + kNumStates)

Definition at line 99 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define IsRepG0   (IsRep + kNumStates)

Definition at line 96 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define IsRepG1   (IsRepG0 + kNumStates)

Definition at line 97 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define IsRepG2   (IsRepG1 + kNumStates)

Definition at line 98 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kAlignTableSize   (1 << kNumAlignBits)

Definition at line 89 of file LzmaDec.cc.

#define kBitModelTotal   (1 << kNumBitModelTotalBits)

Definition at line 12 of file LzmaDec.cc.

Referenced by LzmaDec_InitStateReal().

#define kEndPosModelIndex   14

Definition at line 82 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kLenNumHighBits   8

Definition at line 67 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kLenNumHighSymbols   (1 << kLenNumHighBits)

Definition at line 68 of file LzmaDec.cc.

#define kLenNumLowBits   3

Definition at line 63 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kLenNumLowSymbols   (1 << kLenNumLowBits)

Definition at line 64 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kLenNumMidBits   3

Definition at line 65 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kLenNumMidSymbols   (1 << kLenNumMidBits)

Definition at line 66 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kMatchMinLen   2

Definition at line 91 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define kMatchSpecLenStart   (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
#define kNumAlignBits   4

Definition at line 88 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumBitModelTotalBits   11

Definition at line 11 of file LzmaDec.cc.

#define kNumFullDistances   (1 << (kEndPosModelIndex >> 1))

Definition at line 83 of file LzmaDec.cc.

#define kNumLenProbs   (LenHigh + kLenNumHighSymbols)

Definition at line 75 of file LzmaDec.cc.

#define kNumLenToPosStates   4

Definition at line 86 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumLitStates   7

Definition at line 79 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumMoveBits   5

Definition at line 13 of file LzmaDec.cc.

#define kNumPosBitsMax   4

Definition at line 60 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumPosSlotBits   6

Definition at line 85 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumPosStatesMax   (1 << kNumPosBitsMax)

Definition at line 61 of file LzmaDec.cc.

#define kNumStates   12

Definition at line 78 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kNumTopBits   24

Definition at line 8 of file LzmaDec.cc.

#define kStartPosModelIndex   4

Definition at line 81 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define kTopValue   ((UInt32)1 << kNumTopBits)

Definition at line 9 of file LzmaDec.cc.

#define LenChoice   0

Definition at line 70 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define LenChoice2   (LenChoice + 1)

Definition at line 71 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define LenCoder   (Align + kAlignTableSize)

Definition at line 103 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define LenHigh   (LenMid + (kNumPosStatesMax << kLenNumMidBits))

Definition at line 74 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define LenLow   (LenChoice2 + 1)

Definition at line 72 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define LenMid   (LenLow + (kNumPosStatesMax << kLenNumLowBits))

Definition at line 73 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define Literal   (RepLenCoder + kNumLenProbs)

Definition at line 105 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), LzmaDec_InitStateReal(), and LzmaDec_TryDummy().

#define LZMA_BASE_SIZE   1846

Definition at line 107 of file LzmaDec.cc.

#define LZMA_DIC_MIN   (1 << 12)

Definition at line 116 of file LzmaDec.cc.

Referenced by LzmaProps_Decode().

#define LZMA_LIT_SIZE   768

Definition at line 108 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), LzmaDec_InitStateReal(), and LzmaDec_TryDummy().

#define LzmaProps_GetNumProbs (   p)    ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))

Definition at line 110 of file LzmaDec.cc.

Referenced by LzmaDec_AllocateProbs2().

#define NORMALIZE   if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }

Definition at line 17 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define NORMALIZE_CHECK   if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }

Definition at line 47 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define PosSlot   (IsRep0Long + (kNumStates << kNumPosBitsMax))

Definition at line 100 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define RC_INIT_SIZE   5

Definition at line 15 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeToDic(), and LzmaDecode().

#define RepLenCoder   (LenCoder + kNumLenProbs)

Definition at line 104 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define SpecPos   (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))

Definition at line 101 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal(), and LzmaDec_TryDummy().

#define TREE_6_DECODE (   probs,
  i 
)
Value:
{ i = 1; \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
TREE_GET_BIT(probs, i); \
i -= 0x40; }
int i
Definition: DBlmapReader.cc:9
#define TREE_GET_BIT(probs, i)
Definition: LzmaDec.cc:27

Definition at line 36 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define TREE_DECODE (   probs,
  limit,
  i 
)    { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }

Definition at line 28 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define TREE_DECODE_CHECK (   probs,
  limit,
  i 
)    { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }

Definition at line 56 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define TREE_GET_BIT (   probs,
  i 
)    { GET_BIT((probs + i), i); }

Definition at line 27 of file LzmaDec.cc.

#define UPDATE_0 (   p)    range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));

Definition at line 20 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define UPDATE_0_CHECK   range = bound;

Definition at line 50 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

#define UPDATE_1 (   p)    range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));

Definition at line 21 of file LzmaDec.cc.

Referenced by LzmaDec_DecodeReal().

#define UPDATE_1_CHECK   range -= bound; code -= bound;

Definition at line 51 of file LzmaDec.cc.

Referenced by LzmaDec_TryDummy().

Enumeration Type Documentation

enum ELzmaDummy
Enumerator
DUMMY_ERROR 
DUMMY_LIT 
DUMMY_MATCH 
DUMMY_REP 

Definition at line 479 of file LzmaDec.cc.

480 {
481  DUMMY_ERROR, /* unexpected end of input stream */
482  DUMMY_LIT,
483  DUMMY_MATCH,
484  DUMMY_REP
485 } ELzmaDummy;
ELzmaDummy
Definition: LzmaDec.cc:479

Function Documentation

SRes LzmaDec_Allocate ( CLzmaDec p,
const Byte props,
unsigned  propsSize,
ISzAlloc alloc 
)

Definition at line 947 of file LzmaDec.cc.

References ISzAlloc::Alloc, CLzmaDec::dic, CLzmaDec::dicBufSize, _CLzmaProps::dicSize, LzmaDec_AllocateProbs2(), LzmaDec_FreeDict(), LzmaDec_FreeProbs(), LzmaProps_Decode(), CLzmaDec::prop, RINOK, SZ_ERROR_MEM, and SZ_OK.

Referenced by LzmaFile::Open().

948 {
949  CLzmaProps propNew;
950  SizeT dicBufSize;
951  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
952  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
953  dicBufSize = propNew.dicSize;
954  if (p->dic == 0 || dicBufSize != p->dicBufSize)
955  {
956  LzmaDec_FreeDict(p, alloc);
957  p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
958  if (p->dic == 0)
959  {
960  LzmaDec_FreeProbs(p, alloc);
961  return SZ_ERROR_MEM;
962  }
963  }
964  p->dicBufSize = dicBufSize;
965  p->prop = propNew;
966  return SZ_OK;
967 }
SizeT dicBufSize
Definition: LzmaDec.h:58
#define SZ_OK
Definition: Types.h:25
unsigned char Byte
Definition: Types.h:55
CLzmaProps prop
Definition: LzmaDec.h:52
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:880
static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:886
Byte * dic
Definition: LzmaDec.h:54
#define SZ_ERROR_MEM
Definition: Types.h:28
void *(* Alloc)(void *p, size_t size)
Definition: Types.h:229
UInt32 dicSize
Definition: LzmaDec.h:31
size_t SizeT
Definition: Types.h:92
#define RINOK(x)
Definition: Types.h:52
static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
Definition: LzmaDec.cc:924
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
Definition: LzmaDec.cc:898
SRes LzmaDec_AllocateProbs ( CLzmaDec p,
const Byte props,
unsigned  propsSize,
ISzAlloc alloc 
)

Definition at line 938 of file LzmaDec.cc.

References LzmaDec_AllocateProbs2(), LzmaProps_Decode(), CLzmaDec::prop, RINOK, and SZ_OK.

Referenced by LzmaDecode().

939 {
940  CLzmaProps propNew;
941  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
942  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
943  p->prop = propNew;
944  return SZ_OK;
945 }
#define SZ_OK
Definition: Types.h:25
CLzmaProps prop
Definition: LzmaDec.h:52
#define RINOK(x)
Definition: Types.h:52
static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
Definition: LzmaDec.cc:924
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
Definition: LzmaDec.cc:898
static SRes LzmaDec_AllocateProbs2 ( CLzmaDec p,
const CLzmaProps propNew,
ISzAlloc alloc 
)
static

Definition at line 924 of file LzmaDec.cc.

References ISzAlloc::Alloc, CLzmaProb, LzmaDec_FreeProbs(), LzmaProps_GetNumProbs, CLzmaDec::numProbs, CLzmaDec::probs, SZ_ERROR_MEM, and SZ_OK.

Referenced by LzmaDec_Allocate(), and LzmaDec_AllocateProbs().

925 {
926  UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
927  if (p->probs == 0 || numProbs != p->numProbs)
928  {
929  LzmaDec_FreeProbs(p, alloc);
930  p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
931  p->numProbs = numProbs;
932  if (p->probs == 0)
933  return SZ_ERROR_MEM;
934  }
935  return SZ_OK;
936 }
#define SZ_OK
Definition: Types.h:25
#define LzmaProps_GetNumProbs(p)
Definition: LzmaDec.cc:110
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:880
#define SZ_ERROR_MEM
Definition: Types.h:28
void *(* Alloc)(void *p, size_t size)
Definition: Types.h:229
CLzmaProb * probs
Definition: LzmaDec.h:53
#define CLzmaProb
Definition: LzmaDec.h:20
unsigned int UInt32
Definition: Types.h:64
UInt32 numProbs
Definition: LzmaDec.h:66
static int MY_FAST_CALL LzmaDec_DecodeReal ( CLzmaDec p,
SizeT  limit,
const Byte bufLimit 
)
static

Definition at line 131 of file LzmaDec.cc.

References Align, CLzmaDec::buf, CLzmaDec::checkDicSize, CLzmaProb, CLzmaDec::code, alignCSCRings::dest, CLzmaDec::dic, CLzmaDec::dicBufSize, CLzmaDec::dicPos, GET_BIT, GET_BIT2, i, IF_BIT_0, IsMatch, IsRep, IsRep0Long, IsRepG0, IsRepG1, IsRepG2, kEndPosModelIndex, kLenNumHighBits, kLenNumLowBits, kLenNumLowSymbols, kLenNumMidBits, kLenNumMidSymbols, kMatchMinLen, kMatchSpecLenStart, kNumAlignBits, kNumLenToPosStates, kNumLitStates, kNumPosBitsMax, kNumPosSlotBits, kNumStates, kStartPosModelIndex, _CLzmaProps::lc, LenChoice, LenChoice2, LenCoder, LenHigh, LenLow, LenMid, MessageLogger_cff::limit, Literal, _CLzmaProps::lp, LZMA_LIT_SIZE, NORMALIZE, evf::evtn::offset(), _CLzmaProps::pb, pos, PosSlot, mix_2012_Summer_inTimeOnly_cff::prob, CLzmaDec::probs, CLzmaDec::processedPos, CLzmaDec::prop, CLzmaDec::range, CLzmaDec::remainLen, RepLenCoder, CLzmaDec::reps, SpecPos, alcazmumu_cfi::src, CLzmaDec::state, evf::utils::state, SZ_ERROR_DATA, SZ_OK, lumiQTWidget::t, TREE_6_DECODE, TREE_DECODE, UPDATE_0, and UPDATE_1.

Referenced by LzmaDec_DecodeReal2().

132 {
133  CLzmaProb *probs = p->probs;
134 
135  unsigned state = p->state;
136  UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
137  unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
138  unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
139  unsigned lc = p->prop.lc;
140 
141  Byte *dic = p->dic;
142  SizeT dicBufSize = p->dicBufSize;
143  SizeT dicPos = p->dicPos;
144 
145  UInt32 processedPos = p->processedPos;
146  UInt32 checkDicSize = p->checkDicSize;
147  unsigned len = 0;
148 
149  const Byte *buf = p->buf;
150  UInt32 range = p->range;
151  UInt32 code = p->code;
152 
153  do
154  {
155  CLzmaProb *prob;
156  UInt32 bound;
157  unsigned ttt;
158  unsigned posState = processedPos & pbMask;
159 
160  prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
161  IF_BIT_0(prob)
162  {
163  unsigned symbol;
164  UPDATE_0(prob);
165  prob = probs + Literal;
166  if (checkDicSize != 0 || processedPos != 0)
167  prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
168  (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
169 
170  if (state < kNumLitStates)
171  {
172  state -= (state < 4) ? state : 3;
173  symbol = 1;
174  do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
175  }
176  else
177  {
178  unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
179  unsigned offs = 0x100;
180  state -= (state < 10) ? 3 : 6;
181  symbol = 1;
182  do
183  {
184  unsigned bit;
185  CLzmaProb *probLit;
186  matchByte <<= 1;
187  bit = (matchByte & offs);
188  probLit = prob + offs + bit + symbol;
189  GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
190  }
191  while (symbol < 0x100);
192  }
193  dic[dicPos++] = (Byte)symbol;
194  processedPos++;
195  continue;
196  }
197  else
198  {
199  UPDATE_1(prob);
200  prob = probs + IsRep + state;
201  IF_BIT_0(prob)
202  {
203  UPDATE_0(prob);
204  state += kNumStates;
205  prob = probs + LenCoder;
206  }
207  else
208  {
209  UPDATE_1(prob);
210  if (checkDicSize == 0 && processedPos == 0)
211  return SZ_ERROR_DATA;
212  prob = probs + IsRepG0 + state;
213  IF_BIT_0(prob)
214  {
215  UPDATE_0(prob);
216  prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
217  IF_BIT_0(prob)
218  {
219  UPDATE_0(prob);
220  dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
221  dicPos++;
222  processedPos++;
223  state = state < kNumLitStates ? 9 : 11;
224  continue;
225  }
226  UPDATE_1(prob);
227  }
228  else
229  {
230  UInt32 distance;
231  UPDATE_1(prob);
232  prob = probs + IsRepG1 + state;
233  IF_BIT_0(prob)
234  {
235  UPDATE_0(prob);
236  distance = rep1;
237  }
238  else
239  {
240  UPDATE_1(prob);
241  prob = probs + IsRepG2 + state;
242  IF_BIT_0(prob)
243  {
244  UPDATE_0(prob);
245  distance = rep2;
246  }
247  else
248  {
249  UPDATE_1(prob);
250  distance = rep3;
251  rep3 = rep2;
252  }
253  rep2 = rep1;
254  }
255  rep1 = rep0;
256  rep0 = distance;
257  }
258  state = state < kNumLitStates ? 8 : 11;
259  prob = probs + RepLenCoder;
260  }
261  {
262  unsigned limit, offset;
263  CLzmaProb *probLen = prob + LenChoice;
264  IF_BIT_0(probLen)
265  {
266  UPDATE_0(probLen);
267  probLen = prob + LenLow + (posState << kLenNumLowBits);
268  offset = 0;
269  limit = (1 << kLenNumLowBits);
270  }
271  else
272  {
273  UPDATE_1(probLen);
274  probLen = prob + LenChoice2;
275  IF_BIT_0(probLen)
276  {
277  UPDATE_0(probLen);
278  probLen = prob + LenMid + (posState << kLenNumMidBits);
279  offset = kLenNumLowSymbols;
280  limit = (1 << kLenNumMidBits);
281  }
282  else
283  {
284  UPDATE_1(probLen);
285  probLen = prob + LenHigh;
287  limit = (1 << kLenNumHighBits);
288  }
289  }
290  TREE_DECODE(probLen, limit, len);
291  len += offset;
292  }
293 
294  if (state >= kNumStates)
295  {
296  UInt32 distance;
297  prob = probs + PosSlot +
298  ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
299  TREE_6_DECODE(prob, distance);
300  if (distance >= kStartPosModelIndex)
301  {
302  unsigned posSlot = (unsigned)distance;
303  int numDirectBits = (int)(((distance >> 1) - 1));
304  distance = (2 | (distance & 1));
305  if (posSlot < kEndPosModelIndex)
306  {
307  distance <<= numDirectBits;
308  prob = probs + SpecPos + distance - posSlot - 1;
309  {
310  UInt32 mask = 1;
311  unsigned i = 1;
312  do
313  {
314  GET_BIT2(prob + i, i, ; , distance |= mask);
315  mask <<= 1;
316  }
317  while (--numDirectBits != 0);
318  }
319  }
320  else
321  {
322  numDirectBits -= kNumAlignBits;
323  do
324  {
325  NORMALIZE
326  range >>= 1;
327 
328  {
329  UInt32 t;
330  code -= range;
331  t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
332  distance = (distance << 1) + (t + 1);
333  code += range & t;
334  }
335  /*
336  distance <<= 1;
337  if (code >= range)
338  {
339  code -= range;
340  distance |= 1;
341  }
342  */
343  }
344  while (--numDirectBits != 0);
345  prob = probs + Align;
346  distance <<= kNumAlignBits;
347  {
348  unsigned i = 1;
349  GET_BIT2(prob + i, i, ; , distance |= 1);
350  GET_BIT2(prob + i, i, ; , distance |= 2);
351  GET_BIT2(prob + i, i, ; , distance |= 4);
352  GET_BIT2(prob + i, i, ; , distance |= 8);
353  }
354  if (distance == (UInt32)0xFFFFFFFF)
355  {
356  len += kMatchSpecLenStart;
357  state -= kNumStates;
358  break;
359  }
360  }
361  }
362  rep3 = rep2;
363  rep2 = rep1;
364  rep1 = rep0;
365  rep0 = distance + 1;
366  if (checkDicSize == 0)
367  {
368  if (distance >= processedPos)
369  return SZ_ERROR_DATA;
370  }
371  else if (distance >= checkDicSize)
372  return SZ_ERROR_DATA;
373  state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
374  }
375 
376  len += kMatchMinLen;
377 
378  if (limit == dicPos)
379  return SZ_ERROR_DATA;
380  {
381  SizeT rem = limit - dicPos;
382  unsigned curLen = ((rem < len) ? (unsigned)rem : len);
383  SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
384 
385  processedPos += curLen;
386 
387  len -= curLen;
388  if (pos + curLen <= dicBufSize)
389  {
390  Byte *dest = dic + dicPos;
391  ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
392  const Byte *lim = dest + curLen;
393  dicPos += curLen;
394  do
395  *(dest) = (Byte)*(dest + src);
396  while (++dest != lim);
397  }
398  else
399  {
400  do
401  {
402  dic[dicPos++] = dic[pos];
403  if (++pos == dicBufSize)
404  pos = 0;
405  }
406  while (--curLen != 0);
407  }
408  }
409  }
410  }
411  while (dicPos < limit && buf < bufLimit);
412  NORMALIZE;
413  p->buf = buf;
414  p->range = range;
415  p->code = code;
416  p->remainLen = len;
417  p->dicPos = dicPos;
418  p->processedPos = processedPos;
419  p->reps[0] = rep0;
420  p->reps[1] = rep1;
421  p->reps[2] = rep2;
422  p->reps[3] = rep3;
423  p->state = state;
424 
425  return SZ_OK;
426 }
UInt32 reps[4]
Definition: LzmaDec.h:62
#define UPDATE_0(p)
Definition: LzmaDec.cc:20
int i
Definition: DBlmapReader.cc:9
#define IsRepG0
Definition: LzmaDec.cc:96
SizeT dicBufSize
Definition: LzmaDec.h:58
#define SZ_OK
Definition: Types.h:25
unsigned pb
Definition: LzmaDec.h:30
SizeT dicPos
Definition: LzmaDec.h:57
unsigned char Byte
Definition: Types.h:55
#define SZ_ERROR_DATA
Definition: Types.h:27
#define IsRepG1
Definition: LzmaDec.cc:97
CLzmaProps prop
Definition: LzmaDec.h:52
#define GET_BIT2(p, i, A0, A1)
Definition: LzmaDec.cc:22
#define LenChoice2
Definition: LzmaDec.cc:71
unsigned lp
Definition: LzmaDec.h:30
#define UPDATE_1(p)
Definition: LzmaDec.cc:21
UInt32 range
Definition: LzmaDec.h:56
#define LZMA_LIT_SIZE
Definition: LzmaDec.cc:108
Byte * dic
Definition: LzmaDec.h:54
#define kLenNumLowSymbols
Definition: LzmaDec.cc:64
#define NORMALIZE
Definition: LzmaDec.cc:17
UInt32 code
Definition: LzmaDec.h:56
#define kStartPosModelIndex
Definition: LzmaDec.cc:81
#define Literal
Definition: LzmaDec.cc:105
#define TREE_DECODE(probs, limit, i)
Definition: LzmaDec.cc:28
#define SpecPos
Definition: LzmaDec.cc:101
#define RepLenCoder
Definition: LzmaDec.cc:104
unsigned remainLen
Definition: LzmaDec.h:63
#define LenMid
Definition: LzmaDec.cc:73
#define IsRepG2
Definition: LzmaDec.cc:98
#define LenCoder
Definition: LzmaDec.cc:103
#define IsRep0Long
Definition: LzmaDec.cc:99
#define LenChoice
Definition: LzmaDec.cc:70
CLzmaProb * probs
Definition: LzmaDec.h:53
#define kMatchSpecLenStart
Definition: LzmaDec.cc:92
#define Align
Definition: LzmaDec.cc:102
#define kEndPosModelIndex
Definition: LzmaDec.cc:82
size_t SizeT
Definition: Types.h:92
unsigned int offset(bool)
#define kNumStates
Definition: LzmaDec.cc:78
#define LenLow
Definition: LzmaDec.cc:72
#define CLzmaProb
Definition: LzmaDec.h:20
UInt32 processedPos
Definition: LzmaDec.h:59
#define kLenNumMidBits
Definition: LzmaDec.cc:65
unsigned lc
Definition: LzmaDec.h:30
unsigned int UInt32
Definition: Types.h:64
const Byte * buf
Definition: LzmaDec.h:55
#define kNumPosBitsMax
Definition: LzmaDec.cc:60
#define kMatchMinLen
Definition: LzmaDec.cc:91
#define kLenNumMidSymbols
Definition: LzmaDec.cc:66
char state
Definition: procUtils.cc:75
unsigned state
Definition: LzmaDec.h:61
UInt32 checkDicSize
Definition: LzmaDec.h:60
#define kNumLenToPosStates
Definition: LzmaDec.cc:86
#define GET_BIT(p, i)
Definition: LzmaDec.cc:25
#define kLenNumHighBits
Definition: LzmaDec.cc:67
#define PosSlot
Definition: LzmaDec.cc:100
#define IF_BIT_0(p)
Definition: LzmaDec.cc:19
#define kLenNumLowBits
Definition: LzmaDec.cc:63
#define TREE_6_DECODE(probs, i)
Definition: LzmaDec.cc:36
#define kNumPosSlotBits
Definition: LzmaDec.cc:85
#define LenHigh
Definition: LzmaDec.cc:74
#define IsMatch
Definition: LzmaDec.cc:94
#define kNumLitStates
Definition: LzmaDec.cc:79
#define kNumAlignBits
Definition: LzmaDec.cc:88
#define IsRep
Definition: LzmaDec.cc:95
static int MY_FAST_CALL LzmaDec_DecodeReal2 ( CLzmaDec p,
SizeT  limit,
const Byte bufLimit 
)
static

Definition at line 454 of file LzmaDec.cc.

References CLzmaDec::buf, CLzmaDec::checkDicSize, CLzmaDec::dicPos, _CLzmaProps::dicSize, kMatchSpecLenStart, MessageLogger_cff::limit, LzmaDec_DecodeReal(), LzmaDec_WriteRem(), CLzmaDec::processedPos, CLzmaDec::prop, CLzmaDec::remainLen, and RINOK.

Referenced by LzmaDec_DecodeToDic().

455 {
456  do
457  {
458  SizeT limit2 = limit;
459  if (p->checkDicSize == 0)
460  {
461  UInt32 rem = p->prop.dicSize - p->processedPos;
462  if (limit - p->dicPos > rem)
463  limit2 = p->dicPos + rem;
464  }
465  RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
466  if (p->processedPos >= p->prop.dicSize)
467  p->checkDicSize = p->prop.dicSize;
469  }
470  while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
471 
472  if (p->remainLen > kMatchSpecLenStart)
473  {
475  }
476  return 0;
477 }
SizeT dicPos
Definition: LzmaDec.h:57
CLzmaProps prop
Definition: LzmaDec.h:52
static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
Definition: LzmaDec.cc:428
unsigned remainLen
Definition: LzmaDec.h:63
static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
Definition: LzmaDec.cc:131
#define kMatchSpecLenStart
Definition: LzmaDec.cc:92
UInt32 dicSize
Definition: LzmaDec.h:31
size_t SizeT
Definition: Types.h:92
UInt32 processedPos
Definition: LzmaDec.h:59
unsigned int UInt32
Definition: Types.h:64
const Byte * buf
Definition: LzmaDec.h:55
UInt32 checkDicSize
Definition: LzmaDec.h:60
#define RINOK(x)
Definition: Types.h:52
SRes LzmaDec_DecodeToBuf ( CLzmaDec p,
Byte dest,
SizeT destLen,
const Byte src,
SizeT srcLen,
ELzmaFinishMode  finishMode,
ELzmaStatus status 
)

Definition at line 840 of file LzmaDec.cc.

References CLzmaDec::dic, CLzmaDec::dicBufSize, CLzmaDec::dicPos, LZMA_FINISH_ANY, LzmaDec_DecodeToDic(), and SZ_OK.

Referenced by LzmaFile::DecodeAll(), and LzmaFile::DecodeBuffer().

841 {
842  SizeT outSize = *destLen;
843  SizeT inSize = *srcLen;
844  *srcLen = *destLen = 0;
845  for (;;)
846  {
847  SizeT inSizeCur = inSize, outSizeCur, dicPos;
848  ELzmaFinishMode curFinishMode;
849  SRes res;
850  if (p->dicPos == p->dicBufSize)
851  p->dicPos = 0;
852  dicPos = p->dicPos;
853  if (outSize > p->dicBufSize - dicPos)
854  {
855  outSizeCur = p->dicBufSize;
856  curFinishMode = LZMA_FINISH_ANY;
857  }
858  else
859  {
860  outSizeCur = dicPos + outSize;
861  curFinishMode = finishMode;
862  }
863 
864  res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
865  src += inSizeCur;
866  inSize -= inSizeCur;
867  *srcLen += inSizeCur;
868  outSizeCur = p->dicPos - dicPos;
869  memcpy(dest, p->dic + dicPos, outSizeCur);
870  dest += outSizeCur;
871  outSize -= outSizeCur;
872  *destLen += outSizeCur;
873  if (res != 0)
874  return res;
875  if (outSizeCur == 0 || outSize == 0)
876  return SZ_OK;
877  }
878 }
SizeT dicBufSize
Definition: LzmaDec.h:58
#define SZ_OK
Definition: Types.h:25
SizeT dicPos
Definition: LzmaDec.h:57
ELzmaFinishMode
Definition: LzmaDec.h:79
Byte * dic
Definition: LzmaDec.h:54
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
Definition: LzmaDec.cc:719
size_t SizeT
Definition: Types.h:92
tuple status
Definition: ntuplemaker.py:245
int SRes
Definition: Types.h:43
SRes LzmaDec_DecodeToDic ( CLzmaDec p,
SizeT  dicLimit,
const Byte src,
SizeT srcLen,
ELzmaFinishMode  finishMode,
ELzmaStatus status 
)

Definition at line 719 of file LzmaDec.cc.

References CLzmaDec::buf, CLzmaDec::code, CLzmaDec::dicPos, DUMMY_ERROR, DUMMY_MATCH, reco::if(), kMatchSpecLenStart, LZMA_FINISH_ANY, LZMA_REQUIRED_INPUT_MAX, LZMA_STATUS_FINISHED_WITH_MARK, LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK, LZMA_STATUS_NEEDS_MORE_INPUT, LZMA_STATUS_NOT_FINISHED, LZMA_STATUS_NOT_SPECIFIED, LzmaDec_DecodeReal2(), LzmaDec_InitRc(), LzmaDec_InitStateReal(), LzmaDec_TryDummy(), LzmaDec_WriteRem(), CLzmaDec::needFlush, CLzmaDec::needInitState, RC_INIT_SIZE, CLzmaDec::remainLen, alcazmumu_cfi::src, SZ_ERROR_DATA, SZ_OK, CLzmaDec::tempBuf, and CLzmaDec::tempBufSize.

Referenced by LzmaDec_DecodeToBuf(), and LzmaDecode().

721 {
722  SizeT inSize = *srcLen;
723  (*srcLen) = 0;
724  LzmaDec_WriteRem(p, dicLimit);
725 
727 
728  while (p->remainLen != kMatchSpecLenStart)
729  {
730  int checkEndMarkNow;
731 
732  if (p->needFlush != 0)
733  {
734  for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
735  p->tempBuf[p->tempBufSize++] = *src++;
737  {
739  return SZ_OK;
740  }
741  if (p->tempBuf[0] != 0)
742  return SZ_ERROR_DATA;
743 
744  LzmaDec_InitRc(p, p->tempBuf);
745  p->tempBufSize = 0;
746  }
747 
748  checkEndMarkNow = 0;
749  if (p->dicPos >= dicLimit)
750  {
751  if (p->remainLen == 0 && p->code == 0)
752  {
754  return SZ_OK;
755  }
756  if (finishMode == LZMA_FINISH_ANY)
757  {
759  return SZ_OK;
760  }
761  if (p->remainLen != 0)
762  {
764  return SZ_ERROR_DATA;
765  }
766  checkEndMarkNow = 1;
767  }
768 
769  if (p->needInitState)
771 
772  if (p->tempBufSize == 0)
773  {
774  SizeT processed;
775  const Byte *bufLimit;
776  if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
777  {
778  int dummyRes = LzmaDec_TryDummy(p, src, inSize);
779  if (dummyRes == DUMMY_ERROR)
780  {
781  memcpy(p->tempBuf, src, inSize);
782  p->tempBufSize = (unsigned)inSize;
783  (*srcLen) += inSize;
785  return SZ_OK;
786  }
787  if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
788  {
790  return SZ_ERROR_DATA;
791  }
792  bufLimit = src;
793  }
794  else
795  bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
796  p->buf = src;
797  if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
798  return SZ_ERROR_DATA;
799  processed = (SizeT)(p->buf - src);
800  (*srcLen) += processed;
801  src += processed;
802  inSize -= processed;
803  }
804  else
805  {
806  unsigned rem = p->tempBufSize, lookAhead = 0;
807  while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
808  p->tempBuf[rem++] = src[lookAhead++];
809  p->tempBufSize = rem;
810  if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
811  {
812  int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
813  if (dummyRes == DUMMY_ERROR)
814  {
815  (*srcLen) += lookAhead;
817  return SZ_OK;
818  }
819  if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
820  {
822  return SZ_ERROR_DATA;
823  }
824  }
825  p->buf = p->tempBuf;
826  if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
827  return SZ_ERROR_DATA;
828  lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
829  (*srcLen) += lookAhead;
830  src += lookAhead;
831  inSize -= lookAhead;
832  p->tempBufSize = 0;
833  }
834  }
835  if (p->code == 0)
837  return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
838 }
#define SZ_OK
Definition: Types.h:25
SizeT dicPos
Definition: LzmaDec.h:57
unsigned char Byte
Definition: Types.h:55
#define SZ_ERROR_DATA
Definition: Types.h:27
static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
Definition: LzmaDec.cc:428
UInt32 code
Definition: LzmaDec.h:56
int needFlush
Definition: LzmaDec.h:64
unsigned tempBufSize
Definition: LzmaDec.h:67
unsigned remainLen
Definition: LzmaDec.h:63
static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
Definition: LzmaDec.cc:678
static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
Definition: LzmaDec.cc:454
#define LZMA_REQUIRED_INPUT_MAX
Definition: LzmaDec.h:48
#define kMatchSpecLenStart
Definition: LzmaDec.cc:92
size_t SizeT
Definition: Types.h:92
const Byte * buf
Definition: LzmaDec.h:55
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]
Definition: LzmaDec.h:68
int needInitState
Definition: LzmaDec.h:65
#define RC_INIT_SIZE
Definition: LzmaDec.cc:15
if(dp >Float(M_PI)) dp-
tuple status
Definition: ntuplemaker.py:245
static void LzmaDec_InitStateReal(CLzmaDec *p)
Definition: LzmaDec.cc:707
static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
Definition: LzmaDec.cc:487
void LzmaDec_Free ( CLzmaDec p,
ISzAlloc alloc 
)

Definition at line 892 of file LzmaDec.cc.

References LzmaDec_FreeDict(), and LzmaDec_FreeProbs().

Referenced by LzmaFile::Close().

893 {
894  LzmaDec_FreeProbs(p, alloc);
895  LzmaDec_FreeDict(p, alloc);
896 }
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:880
static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:886
static void LzmaDec_FreeDict ( CLzmaDec p,
ISzAlloc alloc 
)
static

Definition at line 886 of file LzmaDec.cc.

References CLzmaDec::dic, and ISzAlloc::Free.

Referenced by LzmaDec_Allocate(), and LzmaDec_Free().

887 {
888  alloc->Free(alloc, p->dic);
889  p->dic = 0;
890 }
Byte * dic
Definition: LzmaDec.h:54
void(* Free)(void *p, void *address)
Definition: Types.h:230
void LzmaDec_FreeProbs ( CLzmaDec p,
ISzAlloc alloc 
)

Definition at line 880 of file LzmaDec.cc.

References ISzAlloc::Free, and CLzmaDec::probs.

Referenced by LzmaDec_Allocate(), LzmaDec_AllocateProbs2(), LzmaDec_Free(), and LzmaDecode().

881 {
882  alloc->Free(alloc, p->probs);
883  p->probs = 0;
884 }
CLzmaProb * probs
Definition: LzmaDec.h:53
void(* Free)(void *p, void *address)
Definition: Types.h:230
void LzmaDec_Init ( CLzmaDec p)

Definition at line 701 of file LzmaDec.cc.

References CLzmaDec::dicPos, LzmaDec_InitDicAndState(), and True.

Referenced by LzmaDecode(), and LzmaFile::Open().

702 {
703  p->dicPos = 0;
705 }
SizeT dicPos
Definition: LzmaDec.h:57
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
Definition: LzmaDec.cc:685
#define True
Definition: Types.h:96
void LzmaDec_InitDicAndState ( CLzmaDec p,
Bool  initDic,
Bool  initState 
)

Definition at line 685 of file LzmaDec.cc.

References CLzmaDec::checkDicSize, CLzmaDec::needFlush, CLzmaDec::needInitState, CLzmaDec::processedPos, CLzmaDec::remainLen, and CLzmaDec::tempBufSize.

Referenced by LzmaDec_Init().

686 {
687  p->needFlush = 1;
688  p->remainLen = 0;
689  p->tempBufSize = 0;
690 
691  if (initDic)
692  {
693  p->processedPos = 0;
694  p->checkDicSize = 0;
695  p->needInitState = 1;
696  }
697  if (initState)
698  p->needInitState = 1;
699 }
int needFlush
Definition: LzmaDec.h:64
unsigned tempBufSize
Definition: LzmaDec.h:67
unsigned remainLen
Definition: LzmaDec.h:63
UInt32 processedPos
Definition: LzmaDec.h:59
int needInitState
Definition: LzmaDec.h:65
UInt32 checkDicSize
Definition: LzmaDec.h:60
static void LzmaDec_InitRc ( CLzmaDec p,
const Byte data 
)
static

Definition at line 678 of file LzmaDec.cc.

References CLzmaDec::code, CLzmaDec::needFlush, and CLzmaDec::range.

Referenced by LzmaDec_DecodeToDic().

679 {
680  p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
681  p->range = 0xFFFFFFFF;
682  p->needFlush = 0;
683 }
UInt32 range
Definition: LzmaDec.h:56
UInt32 code
Definition: LzmaDec.h:56
int needFlush
Definition: LzmaDec.h:64
unsigned int UInt32
Definition: Types.h:64
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static void LzmaDec_InitStateReal ( CLzmaDec p)
static

Definition at line 707 of file LzmaDec.cc.

References CLzmaProb, i, kBitModelTotal, _CLzmaProps::lc, Literal, _CLzmaProps::lp, LZMA_LIT_SIZE, CLzmaDec::needInitState, CLzmaDec::probs, CLzmaDec::prop, CLzmaDec::reps, and CLzmaDec::state.

Referenced by LzmaDec_DecodeToDic().

708 {
709  UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
710  UInt32 i;
711  CLzmaProb *probs = p->probs;
712  for (i = 0; i < numProbs; i++)
713  probs[i] = kBitModelTotal >> 1;
714  p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
715  p->state = 0;
716  p->needInitState = 0;
717 }
UInt32 reps[4]
Definition: LzmaDec.h:62
int i
Definition: DBlmapReader.cc:9
CLzmaProps prop
Definition: LzmaDec.h:52
unsigned lp
Definition: LzmaDec.h:30
#define LZMA_LIT_SIZE
Definition: LzmaDec.cc:108
#define Literal
Definition: LzmaDec.cc:105
#define kBitModelTotal
Definition: LzmaDec.cc:12
CLzmaProb * probs
Definition: LzmaDec.h:53
#define CLzmaProb
Definition: LzmaDec.h:20
unsigned lc
Definition: LzmaDec.h:30
unsigned int UInt32
Definition: Types.h:64
int needInitState
Definition: LzmaDec.h:65
unsigned state
Definition: LzmaDec.h:61
static ELzmaDummy LzmaDec_TryDummy ( const CLzmaDec p,
const Byte buf,
SizeT  inSize 
)
static

Definition at line 487 of file LzmaDec.cc.

References Align, CLzmaDec::checkDicSize, CLzmaProb, CLzmaDec::code, CLzmaDec::dic, CLzmaDec::dicBufSize, CLzmaDec::dicPos, DUMMY_LIT, DUMMY_MATCH, DUMMY_REP, GET_BIT2_CHECK, GET_BIT_CHECK, i, IF_BIT_0_CHECK, IsMatch, IsRep, IsRep0Long, IsRepG0, IsRepG1, IsRepG2, kEndPosModelIndex, kLenNumHighBits, kLenNumLowBits, kLenNumLowSymbols, kLenNumMidBits, kLenNumMidSymbols, kNumAlignBits, kNumLenToPosStates, kNumLitStates, kNumPosBitsMax, kNumPosSlotBits, kNumStates, kStartPosModelIndex, _CLzmaProps::lc, LenChoice, LenChoice2, LenCoder, LenHigh, LenLow, LenMid, MessageLogger_cff::limit, Literal, _CLzmaProps::lp, LZMA_LIT_SIZE, NORMALIZE_CHECK, evf::evtn::offset(), _CLzmaProps::pb, PosSlot, mix_2012_Summer_inTimeOnly_cff::prob, CLzmaDec::probs, CLzmaDec::processedPos, CLzmaDec::prop, CLzmaDec::range, RepLenCoder, CLzmaDec::reps, SpecPos, CLzmaDec::state, evf::utils::state, TREE_DECODE_CHECK, UPDATE_0_CHECK, and UPDATE_1_CHECK.

Referenced by LzmaDec_DecodeToDic().

488 {
489  UInt32 range = p->range;
490  UInt32 code = p->code;
491  const Byte *bufLimit = buf + inSize;
492  CLzmaProb *probs = p->probs;
493  unsigned state = p->state;
494  ELzmaDummy res;
495 
496  {
497  CLzmaProb *prob;
498  UInt32 bound;
499  unsigned ttt;
500  unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
501 
502  prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
503  IF_BIT_0_CHECK(prob)
504  {
506 
507  /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
508 
509  prob = probs + Literal;
510  if (p->checkDicSize != 0 || p->processedPos != 0)
511  prob += (LZMA_LIT_SIZE *
512  ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
513  (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
514 
515  if (state < kNumLitStates)
516  {
517  unsigned symbol = 1;
518  do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
519  }
520  else
521  {
522  unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
523  ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
524  unsigned offs = 0x100;
525  unsigned symbol = 1;
526  do
527  {
528  unsigned bit;
529  CLzmaProb *probLit;
530  matchByte <<= 1;
531  bit = (matchByte & offs);
532  probLit = prob + offs + bit + symbol;
533  GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
534  }
535  while (symbol < 0x100);
536  }
537  res = DUMMY_LIT;
538  }
539  else
540  {
541  unsigned len;
543 
544  prob = probs + IsRep + state;
545  IF_BIT_0_CHECK(prob)
546  {
548  state = 0;
549  prob = probs + LenCoder;
550  res = DUMMY_MATCH;
551  }
552  else
553  {
555  res = DUMMY_REP;
556  prob = probs + IsRepG0 + state;
557  IF_BIT_0_CHECK(prob)
558  {
560  prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
561  IF_BIT_0_CHECK(prob)
562  {
565  return DUMMY_REP;
566  }
567  else
568  {
570  }
571  }
572  else
573  {
575  prob = probs + IsRepG1 + state;
576  IF_BIT_0_CHECK(prob)
577  {
579  }
580  else
581  {
583  prob = probs + IsRepG2 + state;
584  IF_BIT_0_CHECK(prob)
585  {
587  }
588  else
589  {
591  }
592  }
593  }
594  state = kNumStates;
595  prob = probs + RepLenCoder;
596  }
597  {
598  unsigned limit, offset;
599  CLzmaProb *probLen = prob + LenChoice;
600  IF_BIT_0_CHECK(probLen)
601  {
603  probLen = prob + LenLow + (posState << kLenNumLowBits);
604  offset = 0;
605  limit = 1 << kLenNumLowBits;
606  }
607  else
608  {
610  probLen = prob + LenChoice2;
611  IF_BIT_0_CHECK(probLen)
612  {
614  probLen = prob + LenMid + (posState << kLenNumMidBits);
615  offset = kLenNumLowSymbols;
616  limit = 1 << kLenNumMidBits;
617  }
618  else
619  {
621  probLen = prob + LenHigh;
623  limit = 1 << kLenNumHighBits;
624  }
625  }
626  TREE_DECODE_CHECK(probLen, limit, len);
627  len += offset;
628  }
629 
630  if (state < 4)
631  {
632  unsigned posSlot;
633  prob = probs + PosSlot +
634  ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
636  TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
637  if (posSlot >= kStartPosModelIndex)
638  {
639  int numDirectBits = ((posSlot >> 1) - 1);
640 
641  /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
642 
643  if (posSlot < kEndPosModelIndex)
644  {
645  prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
646  }
647  else
648  {
649  numDirectBits -= kNumAlignBits;
650  do
651  {
653  range >>= 1;
654  code -= range & (((code - range) >> 31) - 1);
655  /* if (code >= range) code -= range; */
656  }
657  while (--numDirectBits != 0);
658  prob = probs + Align;
659  numDirectBits = kNumAlignBits;
660  }
661  {
662  unsigned i = 1;
663  do
664  {
665  GET_BIT_CHECK(prob + i, i);
666  }
667  while (--numDirectBits != 0);
668  }
669  }
670  }
671  }
672  }
674  return res;
675 }
UInt32 reps[4]
Definition: LzmaDec.h:62
int i
Definition: DBlmapReader.cc:9
#define IsRepG0
Definition: LzmaDec.cc:96
SizeT dicBufSize
Definition: LzmaDec.h:58
unsigned pb
Definition: LzmaDec.h:30
SizeT dicPos
Definition: LzmaDec.h:57
unsigned char Byte
Definition: Types.h:55
#define IsRepG1
Definition: LzmaDec.cc:97
#define GET_BIT_CHECK(p, i)
Definition: LzmaDec.cc:55
CLzmaProps prop
Definition: LzmaDec.h:52
#define LenChoice2
Definition: LzmaDec.cc:71
unsigned lp
Definition: LzmaDec.h:30
UInt32 range
Definition: LzmaDec.h:56
#define LZMA_LIT_SIZE
Definition: LzmaDec.cc:108
Byte * dic
Definition: LzmaDec.h:54
#define kLenNumLowSymbols
Definition: LzmaDec.cc:64
#define NORMALIZE_CHECK
Definition: LzmaDec.cc:47
UInt32 code
Definition: LzmaDec.h:56
#define kStartPosModelIndex
Definition: LzmaDec.cc:81
#define Literal
Definition: LzmaDec.cc:105
#define SpecPos
Definition: LzmaDec.cc:101
#define GET_BIT2_CHECK(p, i, A0, A1)
Definition: LzmaDec.cc:52
#define RepLenCoder
Definition: LzmaDec.cc:104
ELzmaDummy
Definition: LzmaDec.cc:479
#define LenMid
Definition: LzmaDec.cc:73
#define IsRepG2
Definition: LzmaDec.cc:98
#define LenCoder
Definition: LzmaDec.cc:103
#define IsRep0Long
Definition: LzmaDec.cc:99
#define LenChoice
Definition: LzmaDec.cc:70
CLzmaProb * probs
Definition: LzmaDec.h:53
#define Align
Definition: LzmaDec.cc:102
#define kEndPosModelIndex
Definition: LzmaDec.cc:82
unsigned int offset(bool)
#define kNumStates
Definition: LzmaDec.cc:78
#define IF_BIT_0_CHECK(p)
Definition: LzmaDec.cc:49
#define LenLow
Definition: LzmaDec.cc:72
#define CLzmaProb
Definition: LzmaDec.h:20
UInt32 processedPos
Definition: LzmaDec.h:59
#define kLenNumMidBits
Definition: LzmaDec.cc:65
unsigned lc
Definition: LzmaDec.h:30
#define UPDATE_1_CHECK
Definition: LzmaDec.cc:51
unsigned int UInt32
Definition: Types.h:64
#define kNumPosBitsMax
Definition: LzmaDec.cc:60
#define kLenNumMidSymbols
Definition: LzmaDec.cc:66
#define UPDATE_0_CHECK
Definition: LzmaDec.cc:50
char state
Definition: procUtils.cc:75
unsigned state
Definition: LzmaDec.h:61
UInt32 checkDicSize
Definition: LzmaDec.h:60
#define kNumLenToPosStates
Definition: LzmaDec.cc:86
#define kLenNumHighBits
Definition: LzmaDec.cc:67
#define PosSlot
Definition: LzmaDec.cc:100
#define TREE_DECODE_CHECK(probs, limit, i)
Definition: LzmaDec.cc:56
#define kLenNumLowBits
Definition: LzmaDec.cc:63
#define kNumPosSlotBits
Definition: LzmaDec.cc:85
#define LenHigh
Definition: LzmaDec.cc:74
#define IsMatch
Definition: LzmaDec.cc:94
#define kNumLitStates
Definition: LzmaDec.cc:79
#define kNumAlignBits
Definition: LzmaDec.cc:88
#define IsRep
Definition: LzmaDec.cc:95
static void MY_FAST_CALL LzmaDec_WriteRem ( CLzmaDec p,
SizeT  limit 
)
static

Definition at line 428 of file LzmaDec.cc.

References CLzmaDec::checkDicSize, CLzmaDec::dic, CLzmaDec::dicBufSize, CLzmaDec::dicPos, _CLzmaProps::dicSize, kMatchSpecLenStart, CLzmaDec::processedPos, CLzmaDec::prop, CLzmaDec::remainLen, and CLzmaDec::reps.

Referenced by LzmaDec_DecodeReal2(), and LzmaDec_DecodeToDic().

429 {
430  if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
431  {
432  Byte *dic = p->dic;
433  SizeT dicPos = p->dicPos;
434  SizeT dicBufSize = p->dicBufSize;
435  unsigned len = p->remainLen;
436  UInt32 rep0 = p->reps[0];
437  if (limit - dicPos < len)
438  len = (unsigned)(limit - dicPos);
439 
440  if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
441  p->checkDicSize = p->prop.dicSize;
442 
443  p->processedPos += len;
444  p->remainLen -= len;
445  while (len-- != 0)
446  {
447  dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
448  dicPos++;
449  }
450  p->dicPos = dicPos;
451  }
452 }
UInt32 reps[4]
Definition: LzmaDec.h:62
SizeT dicBufSize
Definition: LzmaDec.h:58
SizeT dicPos
Definition: LzmaDec.h:57
unsigned char Byte
Definition: Types.h:55
CLzmaProps prop
Definition: LzmaDec.h:52
Byte * dic
Definition: LzmaDec.h:54
unsigned remainLen
Definition: LzmaDec.h:63
#define kMatchSpecLenStart
Definition: LzmaDec.cc:92
UInt32 dicSize
Definition: LzmaDec.h:31
size_t SizeT
Definition: Types.h:92
UInt32 processedPos
Definition: LzmaDec.h:59
unsigned int UInt32
Definition: Types.h:64
UInt32 checkDicSize
Definition: LzmaDec.h:60
SRes LzmaDecode ( Byte dest,
SizeT destLen,
const Byte src,
SizeT srcLen,
const Byte propData,
unsigned  propSize,
ELzmaFinishMode  finishMode,
ELzmaStatus status,
ISzAlloc alloc 
)

Definition at line 969 of file LzmaDec.cc.

References alignCSCRings::dest, CLzmaDec::dic, CLzmaDec::dicBufSize, CLzmaDec::dicPos, LZMA_STATUS_NEEDS_MORE_INPUT, LzmaDec_AllocateProbs(), LzmaDec_Construct, LzmaDec_DecodeToDic(), LzmaDec_FreeProbs(), LzmaDec_Init(), AlCaHLTBitMon_ParallelJobs::p, RC_INIT_SIZE, SZ_ERROR_INPUT_EOF, and SZ_OK.

972 {
973  CLzmaDec p;
974  SRes res;
975  SizeT inSize = *srcLen;
976  SizeT outSize = *destLen;
977  *srcLen = *destLen = 0;
978  if (inSize < RC_INIT_SIZE)
979  return SZ_ERROR_INPUT_EOF;
980 
981  LzmaDec_Construct(&p);
982  res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
983  if (res != 0)
984  return res;
985  p.dic = dest;
986  p.dicBufSize = outSize;
987 
988  LzmaDec_Init(&p);
989 
990  *srcLen = inSize;
991  res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
992 
993  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
994  res = SZ_ERROR_INPUT_EOF;
995 
996  (*destLen) = p.dicPos;
997  LzmaDec_FreeProbs(&p, alloc);
998  return res;
999 }
SizeT dicBufSize
Definition: LzmaDec.h:58
#define SZ_OK
Definition: Types.h:25
SizeT dicPos
Definition: LzmaDec.h:57
void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
Definition: LzmaDec.cc:880
Byte * dic
Definition: LzmaDec.h:54
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
Definition: LzmaDec.cc:719
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
Definition: LzmaDec.cc:938
size_t SizeT
Definition: Types.h:92
#define LzmaDec_Construct(p)
Definition: LzmaDec.h:71
#define RC_INIT_SIZE
Definition: LzmaDec.cc:15
void LzmaDec_Init(CLzmaDec *p)
Definition: LzmaDec.cc:701
tuple status
Definition: ntuplemaker.py:245
int SRes
Definition: Types.h:43
SRes LzmaProps_Decode ( CLzmaProps p,
const Byte data,
unsigned  size 
)

Definition at line 898 of file LzmaDec.cc.

References _CLzmaProps::dicSize, _CLzmaProps::lc, _CLzmaProps::lp, LZMA_DIC_MIN, LZMA_PROPS_SIZE, _CLzmaProps::pb, SZ_ERROR_UNSUPPORTED, and SZ_OK.

Referenced by LzmaDec_Allocate(), and LzmaDec_AllocateProbs().

899 {
900  UInt32 dicSize;
901  Byte d;
902 
903  if (size < LZMA_PROPS_SIZE)
904  return SZ_ERROR_UNSUPPORTED;
905  else
906  dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
907 
908  if (dicSize < LZMA_DIC_MIN)
909  dicSize = LZMA_DIC_MIN;
910  p->dicSize = dicSize;
911 
912  d = data[0];
913  if (d >= (9 * 5 * 5))
914  return SZ_ERROR_UNSUPPORTED;
915 
916  p->lc = d % 9;
917  d /= 9;
918  p->pb = d / 5;
919  p->lp = d % 5;
920 
921  return SZ_OK;
922 }
#define SZ_OK
Definition: Types.h:25
unsigned pb
Definition: LzmaDec.h:30
#define LZMA_PROPS_SIZE
Definition: LzmaDec.h:26
unsigned char Byte
Definition: Types.h:55
unsigned lp
Definition: LzmaDec.h:30
UInt32 dicSize
Definition: LzmaDec.h:31
#define SZ_ERROR_UNSUPPORTED
Definition: Types.h:30
unsigned lc
Definition: LzmaDec.h:30
#define LZMA_DIC_MIN
Definition: LzmaDec.cc:116
unsigned int UInt32
Definition: Types.h:64
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple size
Write out results.