filter_common.c File Reference

Filter-specific stuff common for both encoder and decoder. More...

`#include "filter_common.h"`

## Functions

lzma_ret | lzma_filters_copy (const lzma_filter *src, lzma_filter *dest, const lzma_allocator *allocator)
| Copy the filters array. More...
static lzma_ret | validate_chain (const lzma_filter *filters, size_t *count)
lzma_ret | lzma_raw_coder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options, lzma_filter_find coder_find, bool is_encoder)
uint64_t | lzma_raw_coder_memusage (lzma_filter_find coder_find, const lzma_filter *filters)

## Variables

struct {
lzma_vli id
| Filter ID. More...
size_t options_size
| Size of the filter-specific options structure. More...
bool non_last_ok
bool last_ok
bool changes_size
} | features []

## Detailed Description

Filter-specific stuff common for both encoder and decoder.

## Function Documentation

## lzma_filters_copy()

lzma_ret lzma_filters_copy | ( | const lzma_filter * | src,
|  | lzma_filter * | dest,
|  | const lzma_allocator * | allocator
| ) |  |

Copy the filters array.

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.

Returns
  - LZMA_OK
  - LZMA_MEM_ERROR
  - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options is not NULL.
  - LZMA_PROG_ERROR: src or dest is NULL.

## Variable Documentation

## id

lzma_vli id

Filter ID.

## options_size

size_t options_size

Size of the filter-specific options structure.

## non_last_ok

bool non_last_ok

True if it is OK to use this filter as non-last filter in the chain.

## last_ok

bool last_ok

True if it is OK to use this filter as the last filter in the chain.

## changes_size

bool changes_size

True if the filter may change the size of the data (that is, the amount of encoded output can be different than the amount of uncompressed input).