Defines | Enumerations | Functions

/tmp/buildd/xz-utils-5.0.0/src/liblzma/lzma/lzma_common.h File Reference

Private definitions common to LZMA encoder and decoder. More...

#include "common.h"
#include "range_common.h"

Defines

#define POS_STATES_MAX   (1 << LZMA_PB_MAX)
#define STATES   12
 Total number of states.
#define LIT_STATES   7
 The lowest 7 states indicate that the previous state was a literal.
#define update_literal(state)
 Indicate that the latest state was a literal.
#define update_match(state)   state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH)
 Indicate that the latest state was a match.
#define update_long_rep(state)   state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP)
 Indicate that the latest state was a long repeated match.
#define update_short_rep(state)   state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP)
 Indicate that the latest state was a short match.
#define is_literal_state(state)   ((state) < LIT_STATES)
 Test if the previous state was a literal.
#define LITERAL_CODER_SIZE   0x300
#define LITERAL_CODERS_MAX   (1 << LZMA_LCLP_MAX)
 Maximum number of literal coders.
#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte)   ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))])
#define MATCH_LEN_MIN   2
#define LEN_LOW_BITS   3
#define LEN_LOW_SYMBOLS   (1 << LEN_LOW_BITS)
#define LEN_MID_BITS   3
#define LEN_MID_SYMBOLS   (1 << LEN_MID_BITS)
#define LEN_HIGH_BITS   8
#define LEN_HIGH_SYMBOLS   (1 << LEN_HIGH_BITS)
#define LEN_SYMBOLS   (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
#define MATCH_LEN_MAX   (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
#define LEN_TO_POS_STATES   4
#define get_len_to_pos_state(len)
#define POS_SLOT_BITS   6
#define POS_SLOTS   (1 << POS_SLOT_BITS)
#define START_POS_MODEL_INDEX   4
#define END_POS_MODEL_INDEX   14
#define FULL_DISTANCES_BITS   (END_POS_MODEL_INDEX / 2)
#define FULL_DISTANCES   (1 << FULL_DISTANCES_BITS)
#define ALIGN_BITS   4
#define ALIGN_TABLE_SIZE   (1 << ALIGN_BITS)
#define ALIGN_MASK   (ALIGN_TABLE_SIZE - 1)
#define REP_DISTANCES   4

Enumerations

enum  lzma_lzma_state {
  STATE_LIT_LIT, STATE_MATCH_LIT_LIT, STATE_REP_LIT_LIT, STATE_SHORTREP_LIT_LIT,
  STATE_MATCH_LIT, STATE_REP_LIT, STATE_SHORTREP_LIT, STATE_LIT_MATCH,
  STATE_LIT_LONGREP, STATE_LIT_SHORTREP, STATE_NONLIT_MATCH, STATE_NONLIT_REP
}

Functions

static bool is_lclppb_valid (const lzma_options_lzma *options)
 Validates lc, lp, and pb.
static void literal_init (probability(*probs)[LITERAL_CODER_SIZE], uint32_t lc, uint32_t lp)

Detailed Description

Private definitions common to LZMA encoder and decoder.


Define Documentation

#define POS_STATES_MAX   (1 << LZMA_PB_MAX)

Maximum number of position states. A position state is the lowest pos bits number of bits of the current uncompressed offset. In some places there are different sets of probabilities for different pos states.

#define STATES   12

Total number of states.

#define LIT_STATES   7

The lowest 7 states indicate that the previous state was a literal.

#define update_literal (   state  ) 
Value:
state = ((state) <= STATE_SHORTREP_LIT_LIT \
                        ? STATE_LIT_LIT \
                        : ((state) <= STATE_LIT_SHORTREP \
                                ? (state) - 3 \
                                : (state) - 6))

Indicate that the latest state was a literal.

#define update_match (   state  )     state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH)

Indicate that the latest state was a match.

#define update_long_rep (   state  )     state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP)

Indicate that the latest state was a long repeated match.

#define update_short_rep (   state  )     state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP)

Indicate that the latest state was a short match.

#define is_literal_state (   state  )     ((state) < LIT_STATES)

Test if the previous state was a literal.

#define LITERAL_CODER_SIZE   0x300

Each literal coder is divided in three sections:

  • 0x001-0x0FF: Without match byte
  • 0x101-0x1FF: With match byte; match bit is 0
  • 0x201-0x2FF: With match byte; match bit is 1

Match byte is used when the previous LZMA symbol was something else than a literal (that is, it was some kind of match).

#define LITERAL_CODERS_MAX   (1 << LZMA_LCLP_MAX)

Maximum number of literal coders.

#define literal_subcoder (   probs,
  lc,
  lp_mask,
  pos,
  prev_byte 
)    ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))])

Locate the literal coder for the next literal byte. The choice depends on

  • the lowest literal_pos_bits bits of the position of the current byte; and
  • the highest literal_context_bits bits of the previous byte.
#define get_len_to_pos_state (   len  ) 
Value:
((len) < LEN_TO_POS_STATES + MATCH_LEN_MIN \
                ? (len) - MATCH_LEN_MIN \
                : LEN_TO_POS_STATES - 1)

Enumeration Type Documentation

This enum is used to track which events have occurred most recently and in which order. This information is used to predict the next event.

Events:

  • Literal: One 8-bit byte
  • Match: Repeat a chunk of data at some distance
  • Long repeat: Multi-byte match at a recently seen distance
  • Short repeat: One-byte repeat at a recently seen distance

The event names are in from STATE_oldest_older_previous. REP means either short or long repeated match, and NONLIT means any non-literal.


Function Documentation

static bool is_lclppb_valid ( const lzma_options_lzma options  )  [inline, static]