clzmaxz

How to use XZ / liblxma-dev to compress data using LZMA_FILTER_LZMA1 filters


I'm trying to use liblzma to compress data using lzma1, but I'm having an issue where lzma_stream_encoder returns LZMA_PROG_ERROR before I get a chance.

I've tried modifying options and swapping in other filters, but I haven't been able to get the lzma_stream_encoder to return anything other than 11 for lzma1. If I swap it out with the lzma2 it does work.

Minimal Example

lzma_stream stream = LZMA_STREAM_INIT;
lzma_options_lzma options;
lzma_lzma_preset(&options, LZMA_PRESET_DEFAULT);
lzma_filter filters[] = {
    {.id = LZMA_FILTER_LZMA1, .options = &options},
    {.id = LZMA_VLI_UNKNOWN, .options = NULL}
};
// this returns LZMA_PROG_ERROR (11)
lzma_stream_encoder(&stream, filters, LZMA_CHECK_CRC64);

Solution

  • I solved my issue by using source from the original lzma implementation by Igor Pavlov instead of liblzma.