03_compress_custom.c | 03_compress_custom.c | |||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
#include <string.h> | #include <string.h> | |||
#include <errno.h> | #include <errno.h> | |||
#include <lzma.h> | #include <lzma.h> | |||
static bool | static bool | |||
init_encoder(lzma_stream *strm) | init_encoder(lzma_stream *strm) | |||
{ | { | |||
// Use the default preset (6) for LZMA2. | // Use the default preset (6) for LZMA2. | |||
// | // | |||
// The lzma_options_lzma structure and the lzma_lzma_preset() functi on | // The lzma_options_lzma structure and the lzma_lzma_preset() functi on | |||
// are declared in lzma/lzma.h (src/liblzma/api/lzma/lzma.h in the | // are declared in lzma/lzma12.h (src/liblzma/api/lzma/lzma12.h in t | |||
// source package or e.g. /usr/include/lzma/lzma.h depending on | he | |||
// source package or e.g. /usr/include/lzma/lzma12.h depending on | ||||
// the install prefix). | // the install prefix). | |||
lzma_options_lzma opt_lzma2; | lzma_options_lzma opt_lzma2; | |||
if (lzma_lzma_preset(&opt_lzma2, LZMA_PRESET_DEFAULT)) { | if (lzma_lzma_preset(&opt_lzma2, LZMA_PRESET_DEFAULT)) { | |||
// It should never fail because the default preset | // It should never fail because the default preset | |||
// (and presets 0-9 optionally with LZMA_PRESET_EXTREME) | // (and presets 0-9 optionally with LZMA_PRESET_EXTREME) | |||
// are supported by all stable liblzma versions. | // are supported by all stable liblzma versions. | |||
// | // | |||
// (The encoder initialization later in this function may | // (The encoder initialization later in this function may | |||
// still fail due to unsupported preset *if* the features | // still fail due to unsupported preset *if* the features | |||
// required by the preset have been disabled at build time, | // required by the preset have been disabled at build time, | |||
// but no-one does such things except on embedded systems.) | // but no-one does such things except on embedded systems.) | |||
fprintf(stderr, "Unsupported preset, possibly a bug\n"); | fprintf(stderr, "Unsupported preset, possibly a bug\n"); | |||
return false; | return false; | |||
} | } | |||
// Now we could customize the LZMA2 options if we wanted. For exampl e, | // Now we could customize the LZMA2 options if we wanted. For exampl e, | |||
// we could set the the dictionary size (opt_lzma2.dict_size) to | // we could set the the dictionary size (opt_lzma2.dict_size) to | |||
// something else than the default (8 MiB) of the default preset. | // something else than the default (8 MiB) of the default preset. | |||
// See lzma/lzma.h for details of all LZMA2 options. | // See lzma/lzma12.h for details of all LZMA2 options. | |||
// | // | |||
// The x86 BCJ filter will try to modify the x86 instruction stream so | // The x86 BCJ filter will try to modify the x86 instruction stream so | |||
// that LZMA2 can compress it better. The x86 BCJ filter doesn't nee d | // that LZMA2 can compress it better. The x86 BCJ filter doesn't nee d | |||
// any options so it will be set to NULL below. | // any options so it will be set to NULL below. | |||
// | // | |||
// Construct the filter chain. The uncompressed data goes first to | // Construct the filter chain. The uncompressed data goes first to | |||
// the first filter in the array, in this case the x86 BCJ filter. | // the first filter in the array, in this case the x86 BCJ filter. | |||
// The array is always terminated by setting .id = LZMA_VLI_UNKNOWN. | // The array is always terminated by setting .id = LZMA_VLI_UNKNOWN. | |||
// | // | |||
// See lzma/filter.h for more information about the lzma_filter | // See lzma/filter.h for more information about the lzma_filter | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 4 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |