Rizin
unix-like reverse engineering framework and cli tools
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"

Go to the source code of this file.

Classes

struct  lzma_filter_decoder
 

Functions

static const lzma_filter_decoderdecoder_find (lzma_vli id)
 
 LZMA_API (lzma_bool)
 
lzma_ret lzma_raw_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options)
 
 LZMA_API (lzma_ret)
 
 LZMA_API (uint64_t)
 Calculate approximate memory usage of easy encoder. More...
 

Variables

static const lzma_filter_decoder decoders []
 

Detailed Description

Filter ID mapping to filter-specific functions.

Definition in file filter_decoder.c.

Function Documentation

◆ decoder_find()

static const lzma_filter_decoder* decoder_find ( lzma_vli  id)
static

Definition at line 122 of file filter_decoder.c.

123 {
124  for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)
125  if (decoders[i].id == id)
126  return decoders + i;
127 
128  return NULL;
129 }
#define ARRAY_SIZE(a)
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
static const lzma_filter_decoder decoders[]

References ARRAY_SIZE, decoders, i, and NULL.

Referenced by LZMA_API(), and lzma_raw_decoder_init().

◆ LZMA_API() [1/3]

LZMA_API ( lzma_bool  )

Definition at line 132 of file filter_decoder.c.

134 {
135  return decoder_find(id) != NULL;
136 }
static const lzma_filter_decoder * decoder_find(lzma_vli id)

References decoder_find(), and NULL.

◆ LZMA_API() [2/3]

LZMA_API ( lzma_ret  )

Definition at line 148 of file filter_decoder.c.

150 {
152 
155 
156  return LZMA_OK;
157 }
lzma_ret lzma_raw_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options)
static lzma_stream strm
Definition: full_flush.c:20
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
bool supported_actions[LZMA_ACTION_MAX+1]
Indicates which lzma_action values are allowed by next.code.
Definition: common.h:220
lzma_internal * internal
Definition: base.h:505
#define lzma_next_strm_init(func, strm,...)
Definition: common.h:303
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58
@ LZMA_FINISH
Finish the coding operation.
Definition: base.h:328
@ LZMA_RUN
Continue coding.
Definition: base.h:251

References lzma_stream::internal, LZMA_FINISH, lzma_next_strm_init, LZMA_OK, lzma_raw_decoder_init(), LZMA_RUN, options, strm, and lzma_internal_s::supported_actions.

◆ LZMA_API() [3/3]

LZMA_API ( uint64_t  )

Calculate approximate memory usage of easy encoder.

Get the total amount of physical memory (RAM) in bytes.

Calculate approximate memory usage of multithreaded .xz encoder.

Calculate approximate decoder memory usage of a preset.

This function is a wrapper for lzma_raw_encoder_memusage().

Parameters
presetCompression preset (level and possible flags)
Returns
Number of bytes of memory required for the given preset when encoding. If an error occurs, for example due to unsupported preset, UINT64_MAX is returned.

This function is a wrapper for lzma_raw_decoder_memusage().

Parameters
presetCompression preset (level and possible flags)
Returns
Number of bytes of memory required to decompress a file that was compressed using the given preset. If an error occurs, for example due to unsupported preset, UINT64_MAX is returned.

Since doing the encoding in threaded mode doesn't affect the memory requirements of single-threaded decompressor, you can use lzma_easy_decoder_memusage(options->preset) or lzma_raw_decoder_memusage(options->filters) to calculate the decompressor memory requirements.

Parameters
optionsCompression options
Returns
Number of bytes of memory required for encoding with the given options. If an error occurs, for example due to unsupported preset or filter chain, UINT64_MAX is returned.

Calculate approximate memory usage of easy encoder.

Get the uncompressed size of the file.

Get the total size of the file.

Get the total size of the Blocks.

Get the total size of the Stream.

Get the size of the Index field as bytes.

Get the number of Blocks.

Get the number of Streams.

Calculate the memory usage of an existing lzma_index.

On disk, the size of the Index field depends on both the number of Records stored and how big values the Records store (due to variable-length integer encoding). When the Index is kept in lzma_index structure, the memory usage depends only on the number of Records/Blocks stored in the Index(es), and in case of concatenated lzma_indexes, the number of Streams. The size in RAM is almost always significantly bigger than in the encoded form on disk.

This function calculates an approximate amount of memory needed hold the given number of Streams and Blocks in lzma_index structure. This value may vary between CPU architectures and also between liblzma versions if the internal implementation is modified.

This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), lzma_index_block_count(i)).

This returns the total number of Blocks in lzma_index. To get number of Blocks in individual Streams, use lzma_index_iter.

This is needed to verify the Backward Size field in the Stream Footer.

If multiple lzma_indexes have been combined, this works as if the Blocks were in a single Stream. This is useful if you are going to combine Blocks from multiple Streams into a single new Stream.

This doesn't include the Stream Header, Stream Footer, Stream Padding, or Index fields.

When no lzma_indexes have been combined with lzma_index_cat() and there is no Stream Padding, this function is identical to lzma_index_stream_size(). If multiple lzma_indexes have been combined, this includes also the headers of each separate Stream and the possible Stream Padding fields.

Definition at line 160 of file filter_decoder.c.

162 {
165 }
const lzma_filter * filters
Definition: container.h:315
uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find, const lzma_filter *filters)
const lzma_filter_coder *(* lzma_filter_find)(lzma_vli id)
Definition: filter_common.h:35

References decoder_find(), filters, and lzma_raw_coder_memusage().

◆ lzma_raw_decoder_init()

lzma_ret lzma_raw_decoder_init ( lzma_next_coder next,
const lzma_allocator allocator,
const lzma_filter options 
)

Definition at line 140 of file filter_decoder.c.

142 {
143  return lzma_raw_coder_init(next, allocator,
145 }
const lzma_allocator * allocator
Definition: block.h:377
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)

References allocator, decoder_find(), lzma_raw_coder_init(), and options.

Referenced by LZMA_API(), and lzma_block_decoder_init().

Variable Documentation

◆ decoders

const lzma_filter_decoder decoders[]
static

Definition at line 45 of file filter_decoder.c.

Referenced by decoder_find().