On 2011-09-14 Christian Schlichtherle wrote:
> I am looking into integrating LZMA compression to my TrueZIP Driver
> Zip
> <http://truezip.java.net/truezip-driver/truezip-driver-zip/index.html>
> as explained in the ZIP File Format Specification
> <http://www.pkware.com/documents/casestudies/APPNOTE.TXT> . Now I
> wonder what I need to do to restrict the compression to LZMA-only,
> not LZMA2 or XZ, or if I should not restrict it at all because
> supporting method 14 (LZMA) may imply supporting LZMA2 or XZ, too.

Internally LZMA2 uses the same code as the original LZMA, but it needs
some work to adapt the LZMA2 Java code to do LZMA streams:

  - See the comment about RangeEncoder.cacheSize in the code.

  - You will need to modify RangeEncoder.shiftLow so that it writes
    directly to an output stream (instead of to a buffer).

  - You need to add a function to write LZMA end of stream marker:
    rc.encodeBit(isMatch[state.get()], posState, 1);
    rc.encodeBit(isRep, state.get(), 0);
    encodeMatch(0xFFFFFFFF, MATCH_LEN_MIN, posState);

  - A little code is needed to glue the components together.
    LZMA2OutputStream does this for LZMA2. Note that LZMA
    doesn't support flush() like LZMA2 does.

LZMA might be needed for Apache Commons Compress. I don't know yet.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to