RetroArch
Macros | Enumerations | Functions
LzmaDec.c File Reference
#include <stdint.h>
#include <string.h>
#include <boolean.h>
#include "LzmaDec.h"
Include dependency graph for LzmaDec.c:

Macros

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

Enumerations

enum  ELzmaDummy { DUMMY_ERROR, DUMMY_LIT, DUMMY_MATCH, DUMMY_REP }
 

Functions

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

Macro Definition Documentation

◆ Align

#define Align   (SpecPos + kNumFullDistances - kEndPosModelIndex)

◆ GET_BIT

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

◆ GET_BIT2

#define GET_BIT2 (   p,
  i,
  A0,
  A1 
)
Value:
{ UPDATE_0(p); i = (i + i); A0; } else \
{ LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; }
#define UPDATE_0(p)
Definition: LzmaDec.c:21
#define LZMADEC_IF_BIT_0(prob)
Definition: LzmaDec.c:20
GLfloat GLfloat p
Definition: glext.h:9809
#define LZMADEC_UPDATE_1(p)
Definition: LzmaDec.c:22

◆ GET_BIT2_CHECK

#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; }
#define UPDATE_1_CHECK
Definition: LzmaDec.c:52
GLfloat GLfloat p
Definition: glext.h:9809
#define IF_BIT_0_CHECK(p)
Definition: LzmaDec.c:50
#define UPDATE_0_CHECK
Definition: LzmaDec.c:51

◆ GET_BIT_CHECK

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

◆ IF_BIT_0_CHECK

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

◆ IsMatch

#define IsMatch   0

◆ IsRep

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

◆ IsRep0Long

#define IsRep0Long   (IsRepG2 + kNumStates)

◆ IsRepG0

#define IsRepG0   (IsRep + kNumStates)

◆ IsRepG1

#define IsRepG1   (IsRepG0 + kNumStates)

◆ IsRepG2

#define IsRepG2   (IsRepG1 + kNumStates)

◆ kAlignTableSize

#define kAlignTableSize   (1 << kNumAlignBits)

◆ kBitModelTotal

#define kBitModelTotal   (1 << kNumBitModelTotalBits)

◆ kEndPosModelIndex

#define kEndPosModelIndex   14

◆ kLenNumHighBits

#define kLenNumHighBits   8

◆ kLenNumHighSymbols

#define kLenNumHighSymbols   (1 << kLenNumHighBits)

◆ kLenNumLowBits

#define kLenNumLowBits   3

◆ kLenNumLowSymbols

#define kLenNumLowSymbols   (1 << kLenNumLowBits)

◆ kLenNumMidBits

#define kLenNumMidBits   3

◆ kLenNumMidSymbols

#define kLenNumMidSymbols   (1 << kLenNumMidBits)

◆ kMatchMinLen

#define kMatchMinLen   2

◆ kMatchSpecLenStart

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

◆ kNumAlignBits

#define kNumAlignBits   4

◆ kNumBitModelTotalBits

#define kNumBitModelTotalBits   11

◆ kNumFullDistances

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

◆ kNumLenProbs

#define kNumLenProbs   (LenHigh + kLenNumHighSymbols)

◆ kNumLenToPosStates

#define kNumLenToPosStates   4

◆ kNumLitStates

#define kNumLitStates   7

◆ kNumMoveBits

#define kNumMoveBits   5

◆ kNumPosBitsMax

#define kNumPosBitsMax   4

◆ kNumPosSlotBits

#define kNumPosSlotBits   6

◆ kNumPosStatesMax

#define kNumPosStatesMax   (1 << kNumPosBitsMax)

◆ kNumStates

#define kNumStates   12

◆ kNumTopBits

#define kNumTopBits   24

◆ kStartPosModelIndex

#define kStartPosModelIndex   4

◆ kTopValue

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

◆ LenChoice

#define LenChoice   0

◆ LenChoice2

#define LenChoice2   (LenChoice + 1)

◆ LenCoder

#define LenCoder   (Align + kAlignTableSize)

◆ LenHigh

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

◆ LenLow

#define LenLow   (LenChoice2 + 1)

◆ LenMid

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

◆ Literal

#define Literal   (RepLenCoder + kNumLenProbs)

◆ LZMA_BASE_SIZE

#define LZMA_BASE_SIZE   1846

◆ LZMA_DIC_MIN

#define LZMA_DIC_MIN   (1 << 12)

◆ LZMA_LIT_SIZE

#define LZMA_LIT_SIZE   768

◆ LZMADEC_IF_BIT_0

#define LZMADEC_IF_BIT_0 (   prob)    ttt = *(prob); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound)

◆ LZMADEC_NORMALIZE

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

◆ LZMADEC_UPDATE_1

#define LZMADEC_UPDATE_1 (   p)    range -= bound; codes -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits));

◆ LzmaProps_GetNumProbs

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

◆ NORMALIZE_CHECK

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

◆ PosSlot

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

◆ RC_INIT_SIZE

#define RC_INIT_SIZE   5

◆ RepLenCoder

#define RepLenCoder   (LenCoder + kNumLenProbs)

◆ SpecPos

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

◆ TREE_6_DECODE

#define TREE_6_DECODE (   probs,
 
)
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; }

◆ TREE_DECODE

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

◆ TREE_DECODE_CHECK

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

◆ TREE_GET_BIT

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

◆ UPDATE_0

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

◆ UPDATE_0_CHECK

#define UPDATE_0_CHECK   range = bound;

◆ UPDATE_1_CHECK

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

Enumeration Type Documentation

◆ ELzmaDummy

enum ELzmaDummy
Enumerator
DUMMY_ERROR 
DUMMY_LIT 
DUMMY_MATCH 
DUMMY_REP 

Function Documentation

◆ LzmaDec_Allocate()

SRes LzmaDec_Allocate ( CLzmaDec p,
const uint8_t props,
unsigned  propsSize,
ISzAlloc alloc 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_AllocateProbs()

SRes LzmaDec_AllocateProbs ( CLzmaDec p,
const uint8_t props,
unsigned  propsSize,
ISzAlloc alloc 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_AllocateProbs2()

static SRes LzmaDec_AllocateProbs2 ( CLzmaDec p,
const CLzmaProps propNew,
ISzAlloc alloc 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_DecodeReal()

static int MY_FAST_CALL LzmaDec_DecodeReal ( CLzmaDec p,
size_t  limit,
const uint8_t bufLimit 
)
static
Here is the caller graph for this function:

◆ LzmaDec_DecodeReal2()

static int MY_FAST_CALL LzmaDec_DecodeReal2 ( CLzmaDec p,
size_t  limit,
const uint8_t bufLimit 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_DecodeToBuf()

SRes LzmaDec_DecodeToBuf ( CLzmaDec p,
uint8_t dest,
size_t *  destLen,
const uint8_t src,
size_t *  srcLen,
ELzmaFinishMode  finishMode,
ELzmaStatus status 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_DecodeToDic()

SRes LzmaDec_DecodeToDic ( CLzmaDec p,
size_t  dicLimit,
const uint8_t src,
size_t *  srcLen,
ELzmaFinishMode  finishMode,
ELzmaStatus status 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_Free()

void LzmaDec_Free ( CLzmaDec p,
ISzAlloc alloc 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_FreeDict()

static void LzmaDec_FreeDict ( CLzmaDec p,
ISzAlloc alloc 
)
static
Here is the caller graph for this function:

◆ LzmaDec_FreeProbs()

void LzmaDec_FreeProbs ( CLzmaDec p,
ISzAlloc alloc 
)
Here is the caller graph for this function:

◆ LzmaDec_Init()

void LzmaDec_Init ( CLzmaDec p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LzmaDec_InitDicAndState()

void LzmaDec_InitDicAndState ( CLzmaDec p,
bool  initDic,
bool  initState 
)
Here is the caller graph for this function:

◆ LzmaDec_InitRc()

static void LzmaDec_InitRc ( CLzmaDec p,
const uint8_t data 
)
static
Here is the caller graph for this function:

◆ LzmaDec_InitStateReal()

static void LzmaDec_InitStateReal ( CLzmaDec p)
static
Here is the caller graph for this function:

◆ LzmaDec_TryDummy()

static ELzmaDummy LzmaDec_TryDummy ( const CLzmaDec p,
const uint8_t buf,
size_t  inSize 
)
static
Here is the caller graph for this function:

◆ LzmaDec_WriteRem()

static void MY_FAST_CALL LzmaDec_WriteRem ( CLzmaDec p,
size_t  limit 
)
static
Here is the caller graph for this function:

◆ LzmaDecode()

SRes LzmaDecode ( uint8_t dest,
size_t *  destLen,
const uint8_t src,
size_t *  srcLen,
const uint8_t propData,
unsigned  propSize,
ELzmaFinishMode  finishMode,
ELzmaStatus status,
ISzAlloc alloc 
)
Here is the call graph for this function:

◆ LzmaProps_Decode()

SRes LzmaProps_Decode ( CLzmaProps p,
const uint8_t data,
unsigned  size 
)
Here is the caller graph for this function: