filter_decoder.c File Reference

Filter ID mapping to filter-specific functions. More...

`#include "filter_decoder.h"`
`#include "filter_common.h"`
`#include "lzma_decoder.h"`
`#include "lzma2_decoder.h"`
`#include "simple_decoder.h"`
`#include "delta_decoder.h"`

## Data Structures

struct | lzma_filter_decoder

## Functions

static const lzma_filter_decoder * | decoder_find (lzma_vli id)
lzma_bool | lzma_filter_decoder_is_supported (lzma_vli id)
| Test if the given Filter ID is supported for decoding. More...
lzma_ret | lzma_raw_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options)
lzma_ret | lzma_raw_decoder (lzma_stream *strm, const lzma_filter *options)
| Initialize raw decoder. More...
uint64_t | lzma_raw_decoder_memusage (const lzma_filter *filters)
| Calculate approximate memory requirements for raw decoder. More...
lzma_ret | lzma_properties_decode (lzma_filter *filter, const lzma_allocator *allocator, const uint8_t *props, size_t props_size)
| Decode the Filter Properties field. More...

## Variables

static const lzma_filter_decoder | decoders []

## Detailed Description

Filter ID mapping to filter-specific functions.

## Function Documentation

## lzma_filter_decoder_is_supported()

lzma_bool lzma_filter_decoder_is_supported | ( | lzma_vli | id | ) | const

Test if the given Filter ID is supported for decoding.

Return true if the give Filter ID is supported for decoding by this liblzma build. Otherwise false is returned.

## lzma_raw_decoder()

lzma_ret lzma_raw_decoder | ( | lzma_stream * | strm,
|  | const lzma_filter * | filters
| ) |  |

Initialize raw decoder.

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.

Returns
  - LZMA_OK
  - LZMA_MEM_ERROR
  - LZMA_OPTIONS_ERROR
  - LZMA_PROG_ERROR

References lzma_next_strm_init.

## lzma_raw_decoder_memusage()

uint64_t lzma_raw_decoder_memusage | ( | const lzma_filter * | filters | ) |

Calculate approximate memory requirements for raw decoder.

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.

Parameters

  filters | Array of filters terminated with .id == LZMA_VLI_UNKNOWN.

Returns
  Number of bytes of memory required for the given filter chain when decoding. If an error occurs, for example due to unsupported filter chain, UINT64_MAX is returned.

## lzma_properties_decode()

lzma_ret lzma_properties_decode | ( | lzma_filter * | filter,
|  | const lzma_allocator * | allocator,
|  | const uint8_t * | props,
|  | size_t | props_size
| ) |  |

Decode the Filter Properties field.

Parameters

  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.

Returns
  - LZMA_OK
  - LZMA_OPTIONS_ERROR
  - LZMA_MEM_ERROR