filter_flags_encoder.c File Reference

Encodes a Filter Flags field. More...

`#include "filter_encoder.h"`

## Functions

lzma_ret | lzma_filter_flags_size (uint32_t *size, const lzma_filter *filter)
| Calculate encoded size of a Filter Flags field. More...
lzma_ret | lzma_filter_flags_encode (const lzma_filter *filter, uint8_t *out, size_t *out_pos, size_t out_size)
| Encode Filter Flags into given buffer. More...

## Detailed Description

Encodes a Filter Flags field.

## Function Documentation

## lzma_filter_flags_size()

lzma_ret lzma_filter_flags_size | ( | uint32_t * | size,
|  | const lzma_filter * | filter
| ) |  |

Calculate encoded size of a Filter Flags field.

Knowing the size of Filter Flags is useful to know when allocating memory to hold the encoded Filter Flags.

Parameters

  size | Pointer to integer to hold the calculated size
  filter | Filter ID and associated options whose encoded size is to be calculated

Returns
  - LZMA_OK: *size set successfully. Note that this doesn't guarantee that filter->options is valid, thus lzma_filter_flags_encode() may still fail.
  - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
  - LZMA_PROG_ERROR: Invalid options

Note
  If you need to calculate size of List of Filter Flags, you need to loop over every lzma_filter entry.

References LZMA_FILTER_RESERVED_START, LZMA_OK, LZMA_PROG_ERROR, lzma_properties_size(), lzma_vli_size(), and return_if_error.

Referenced by lzma_block_header_size().

## lzma_filter_flags_encode()

lzma_ret lzma_filter_flags_encode | ( | const lzma_filter * | filter,
|  | uint8_t * | out,
|  | size_t * | out_pos,
|  | size_t | out_size
| ) |  |

Encode Filter Flags into given buffer.

In contrast to some functions, this doesn't allocate the needed buffer. This is due to how this function is used internally by liblzma.

Parameters

  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.

Returns
  - LZMA_OK: Encoding was successful.
  - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
  - LZMA_PROG_ERROR: Invalid options or not enough output buffer space (you should have checked it with lzma_filter_flags_size()).

References LZMA_FILTER_RESERVED_START, LZMA_OK, LZMA_PROG_ERROR, lzma_properties_encode(), lzma_properties_size(), lzma_vli_encode(), and return_if_error.

Referenced by lzma_block_header_encode().