Rizin
unix-like reverse engineering framework and cli tools
|
Common filter related types and functions. More...
Go to the source code of this file.
Classes | |
struct | lzma_filter |
Filter options. More... | |
Macros | |
#define | LZMA_FILTERS_MAX 4 |
Maximum number of filters in a chain. More... | |
Functions | |
LZMA_API (lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) lzma_nothrow lzma_attr_const | |
Test if the given Filter ID is supported for encoding. More... | |
LZMA_API (lzma_ret) lzma_filters_copy(const lzma_filter *src | |
Copy the filters array. More... | |
LZMA_API (uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) lzma_nothrow lzma_attr_pure | |
Calculate approximate memory requirements for raw encoder. More... | |
Common filter related types and functions.
Definition in file filter.h.
#define LZMA_FILTERS_MAX 4 |
LZMA_API | ( | lzma_bool | ) | const |
Test if the given Filter ID is supported for encoding.
Test if the given Filter ID is supported for decoding.
Return true if the give Filter ID is supported for encoding by this liblzma build. Otherwise false is returned.
There is no way to list which filters are available in this particular liblzma version and build. It would be useless, because the application couldn't know what kind of options the filter would need.
Return true if the give Filter ID is supported for decoding by this liblzma build. Otherwise false is returned.
Test if the given Filter ID is supported for encoding.
Test if the given Check ID is supported.
Locate a Block.
iter | Iterator initialized with lzma_index_iter_init() |
mode | Specify what kind of information the caller wants to get. See lzma_index_iter_mode for details. |
If it is possible to seek in the .xz file, it is possible to parse the Index field(s) and use lzma_index_iter_locate() to do random-access reading with granularity of Block size.
iter | Iterator that was earlier initialized with lzma_index_iter_init(). |
target | Uncompressed target offset which the caller would like to locate from the Stream |
If the target is smaller than the uncompressed size of the Stream (can be checked with lzma_index_uncompressed_size()):
If target is greater than the uncompressed size of the Stream, *iter is not modified, and this function returns true.
Test if the given Filter ID is supported for encoding.
Test if the given Check ID is supported.
Set a compression preset to lzma_options_lzma structure.
Test if given compression mode is supported.
Return true if the given match finder is supported by this liblzma build. Otherwise false is returned. It is safe to call this with a value that isn't listed in lzma_match_finder enumeration; the return value will be false.
There is no way to list which match finders are available in this particular liblzma version and build. It would be useless, because a new match finder, which the application developer wasn't aware, could require giving additional options to the encoder that the older match finders don't need.
Return true if the given compression mode is supported by this liblzma build. Otherwise false is returned. It is safe to call this with a value that isn't listed in lzma_mode enumeration; the return value will be false.
There is no way to list which modes are available in this particular liblzma version and build. It would be useless, because a new compression mode, which the application developer wasn't aware, could require giving additional options to the encoder that the older modes don't need.
0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 of the xz command line tool. In addition, it is possible to bitwise-or flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. The flags are defined in container.h, because the flags are used also with lzma_easy_encoder().
The preset values are subject to changes between liblzma versions.
This function is available only if LZMA1 or LZMA2 encoder has been enabled when building liblzma.
Definition at line 514 of file index.c.
LZMA_API | ( | lzma_ret | ) | const |
Copy the filters array.
Decode Filter Flags from given buffer.
Encode Filter Flags into given buffer.
Calculate encoded size of a Filter Flags field.
Decode the Filter Properties field.
Encode the Filter Properties field.
Get the size of the Filter Properties field.
Single-call raw decoder.
Single-call raw encoder.
Update the filter chain in the encoder.
Initialize raw decoder.
Initialize raw encoder.
Copy the Filter IDs and filter-specific options from src to dest. Up to LZMA_FILTERS_MAX filters are copied, plus the terminating .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least LZMA_FILTERS_MAX + 1 elements space unless the caller knows that src is smaller than that.
Unless the filter-specific options is NULL, the Filter ID has to be supported by liblzma, because liblzma needs to know the size of every filter-specific options structure. The filter-specific options are not validated. If options is NULL, any unsupported Filter IDs are copied without returning an error.
Old filter-specific options in dest are not freed, so dest doesn't need to be initialized by the caller in any way.
If an error occurs, memory possibly already allocated by this function is always freed.
This function may be useful when implementing custom file formats.
strm | Pointer to properly prepared lzma_stream |
filters | Array of lzma_filter structures. The end of the array must be marked with .id = LZMA_VLI_UNKNOWN. |
The ‘action’ with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the filter chain supports it), or LZMA_FINISH.
The initialization of raw decoder goes similarly to raw encoder.
The ‘action’ with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using LZMA_FINISH is not required, it is supported just for convenience.
This function is for advanced users only. This function has two slightly different purposes:
While rarely useful, this function may be called also when no data has been compressed yet. In that case, this function will behave as if LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block encoder) had been used right before calling this function.
filters | Array of lzma_filter structures. The end of the array must be marked with .id = LZMA_VLI_UNKNOWN. |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). |
in | Beginning of the input buffer |
in_size | Size of the input buffer |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
filters | Array of lzma_filter structures. The end of the array must be marked with .id = LZMA_VLI_UNKNOWN. |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). |
in | Beginning of the input buffer |
in_pos | The next byte will be read from in[*in_pos]. *in_pos is updated only if decoding succeeds. |
in_size | Size of the input buffer; the first byte that won't be read is in[in_size]. |
out | Beginning of the output buffer |
out_pos | The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds. |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
This function may be useful when implementing custom file formats using the raw encoder and decoder.
size | Pointer to uint32_t to hold the size of the properties |
filter | Filter ID and options (the size of the properties may vary depending on the options) |
filter | Filter ID and options |
props | Buffer to hold the encoded options. The size of buffer must have been already determined with lzma_properties_size(). |
filter | filter->id must have been set to the correct Filter ID. filter->options doesn't need to be initialized (it's not freed by this function). The decoded options will be stored in filter->options; it's application's responsibility to free it when appropriate. filter->options is set to NULL if there are no properties or if an error occurs. |
allocator | Custom memory allocator used to allocate the options. Set to NULL to use the default malloc(), and in case of an error, also free(). |
props | Input buffer containing the properties. |
props_size | Size of the properties. This must be the exact size; giving too much or too little input will return LZMA_OPTIONS_ERROR. |
Knowing the size of Filter Flags is useful to know when allocating memory to hold the encoded Filter Flags.
size | Pointer to integer to hold the calculated size |
filter | Filter ID and associated options whose encoded size is to be calculated |
In contrast to some functions, this doesn't allocate the needed buffer. This is due to how this function is used internally by liblzma.
filter | Filter ID and options to be encoded |
out | Beginning of the output buffer |
out_pos | out[*out_pos] is the next write position. This is updated by the encoder. |
out_size | out[out_size] is the first byte to not write. |
The decoded result is stored into *filter. The old value of filter->options is not free()d.
LZMA_API | ( | uint64_t | ) | const |
Calculate approximate memory requirements for raw encoder.
Calculate approximate memory requirements for raw decoder.
This function can be used to calculate the memory requirements for Block and Stream encoders too because Block and Stream encoders don't need significantly more memory than raw encoder.
filters | Array of filters terminated with .id == LZMA_VLI_UNKNOWN. |
This function can be used to calculate the memory requirements for Block and Stream decoders too because Block and Stream decoders don't need significantly more memory than raw decoder.
filters | Array of filters terminated with .id == LZMA_VLI_UNKNOWN. |
Calculate approximate memory requirements for raw encoder.
Calculate Unpadded Size.
Get the memory usage of decoder filter chain.
Calculate CRC64 using the polynomial from the ECMA-182 standard.
This function is used similarly to lzma_crc32(). See its documentation.
Definition at line 131 of file block_util.c.
const lzma_allocator* allocator |
lzma_filter* dest |
const lzma_allocator const uint8_t size_t size_t in_size lzma_nothrow lzma_attr_warn_unused_result |
const lzma_allocator const uint8_t size_t props_size lzma_nothrow |
const lzma_allocator const uint8_t* props |
Definition at line 362 of file filter.h.
Referenced by lzma_delta_props_decode(), lzma_lzma_props_decode(), and lzma_simple_props_decode().