Easy .xz Stream encoder initialization. More...
#include "easy_preset.h"
#include "stream_encoder.h"
Functions | |
lzma_ret | lzma_easy_encoder (lzma_stream *strm, uint32_t preset, lzma_check check) |
Initialize .xz Stream encoder using a preset number. |
Easy .xz Stream encoder initialization.
lzma_ret lzma_easy_encoder | ( | lzma_stream * | strm, | |
uint32_t | preset, | |||
lzma_check | check | |||
) |
Initialize .xz Stream encoder using a preset number.
This function is intended for those who just want to use the basic features if liblzma (that is, most developers out there).
strm | Pointer to lzma_stream that is at least initialized with LZMA_STREAM_INIT. | |
preset | Compression preset to use. A preset consist of level number and zero or more flags. Usually flags aren't used, so preset is simply a number [0, 9] which match the options -0 ... -9 of the xz command line tool. Additional flags can be be set using bitwise-or with the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. | |
check | Integrity check type to use. See check.h for available checks. The xz command line tool defaults to LZMA_CHECK_CRC64, which is a good choice if you are unsure. LZMA_CHECK_CRC32 is good too as long as the uncompressed file is not many gigabytes. |
If initialization fails (return value is not LZMA_OK), all the memory allocated for *strm by liblzma is always freed. Thus, there is no need to call lzma_end() after failed initialization.
If initialization succeeds, use lzma_code() to do the actual encoding. Valid values for `action' (the second argument of lzma_code()) are LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
References lzma_options_easy::filters, lzma_easy_preset(), and lzma_stream_encoder().