Maven module :un.storage : archive-xz :
Class : un.storage.archive.xz.lzma.LZMAEncoder
Extends/Implements : un.storage.archive.xz.lzma.LZMACoder
Subclasses : -

/*
LZMAEncoder

Authors: Lasse Collin
Igor Pavlov

This file has been put into the public domain.
You can do whatever you want with this file.


Variables : MODE_FAST, MODE_NORMAL, lz, literalEncoder, matchLenEncoder, repLenEncoder, niceLen, back, readAhead
Functions : getMemoryUsage, getInstance, getDistSlot, getNextSymbol, LZMAEncoder, getLZEncoder, reset, getUncompressedSize, resetUncompressedSize, encodeForLZMA2, getMatches, skip, getAnyMatchPrice, getNormalMatchPrice, getAnyRepPrice, getShortRepPrice, getLongRepPrice, getLongRepAndLenPrice, getMatchAndLenPrice, updatePrices


public int MODE_FAST

public int MODE_NORMAL

LZEncoder lz

LiteralEncoder literalEncoder

LengthEncoder matchLenEncoder

LengthEncoder repLenEncoder

int niceLen

int back

int readAhead


public int getMemoryUsage (int mode, int dictSize, int extraSizeBefore, int mf)

public LZMAEncoder getInstance (RangeEncoder rc, int lc, int lp, int pb, int mode, int dictSize, int extraSizeBefore, int niceLen, int mf, int depthLimit)


Gets an integer [0, 63] matching the highest two bits of an integer.
This is like bit scan reverse (BSR) on x86 except that this also
cares about the second highest bit.
public int getDistSlot (int dist)


Gets the next LZMA symbol.


There are three types of symbols: literal (a single byte),
repeated match, and normal match. The symbol is indicated
by the return value and by the variable back.


Literal: back == -1 and return value is 1.
The literal itself needs to be read from lz separately.


Repeated match: back is in the range [0, 3] and
the return value is the length of the repeated match.


Normal match: back - REPS (back - 4)
is the distance of the match and the return value is the length
of the match.

int getNextSymbol ()

void LZMAEncoder (RangeEncoder rc, LZEncoder lz, int lc, int lp, int pb, int dictSize, int niceLen)

public LZEncoder getLZEncoder ()

public void reset ()

public int getUncompressedSize ()

public void resetUncompressedSize ()


Compresses for LZMA2.
return   true if the LZMA2 chunk became full, false otherwise
public boolean encodeForLZMA2 ()

Matches getMatches ()

void skip (int len)

int getAnyMatchPrice (State state, int posState)

int getNormalMatchPrice (int anyMatchPrice, State state)

int getAnyRepPrice (int anyMatchPrice, State state)

int getShortRepPrice (int anyRepPrice, State state, int posState)

int getLongRepPrice (int anyRepPrice, int rep, State state, int posState)

int getLongRepAndLenPrice (int rep, int len, State state, int posState)

int getMatchAndLenPrice (int normalMatchPrice, int dist, int len, int posState)


Updates the lookup tables used for calculating match distance
and length prices. The updating is skipped for performance reasons
if the tables haven't changed much since the previous update.
void updatePrices ()