Rizin
unix-like reverse engineering framework and cli tools
lzma_encoder_presets.c File Reference

Encoder presets. More...

#include "common.h"

Go to the source code of this file.

Functions

 LZMA_API (lzma_bool)
 

Detailed Description

Encoder presets.

Note
xz needs this even when only decoding is enabled.

Definition in file lzma_encoder_presets.c.

Function Documentation

◆ LZMA_API()

LZMA_API ( lzma_bool  )

Definition at line 17 of file lzma_encoder_presets.c.

19 {
22  const uint32_t supported_flags = LZMA_PRESET_EXTREME;
23 
24  if (level > 9 || (flags & ~supported_flags))
25  return true;
26 
27  options->preset_dict = NULL;
28  options->preset_dict_size = 0;
29 
33 
34  static const uint8_t dict_pow2[]
35  = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
36  options->dict_size = UINT32_C(1) << dict_pow2[level];
37 
38  if (level <= 3) {
39  options->mode = LZMA_MODE_FAST;
40  options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
41  options->nice_len = level <= 1 ? 128 : 273;
42  static const uint8_t depths[] = { 4, 8, 24, 48 };
43  options->depth = depths[level];
44  } else {
45  options->mode = LZMA_MODE_NORMAL;
46  options->mf = LZMA_MF_BT4;
47  options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64;
48  options->depth = 0;
49  }
50 
51  if (flags & LZMA_PRESET_EXTREME) {
52  options->mode = LZMA_MODE_NORMAL;
53  options->mf = LZMA_MF_BT4;
54  if (level == 3 || level == 5) {
55  options->nice_len = 192;
56  options->depth = 0;
57  } else {
58  options->nice_len = 273;
59  options->depth = 512;
60  }
61  }
62 
63  return false;
64 }
uint32_t preset
Definition: container.h:259
#define LZMA_PRESET_LEVEL_MASK
Mask for preset level.
Definition: container.h:40
#define LZMA_PRESET_EXTREME
Extreme compression preset.
Definition: container.h:60
#define NULL
Definition: cris-opc.c:27
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
@ LZMA_MODE_FAST
Fast compression.
Definition: lzma12.h:139
@ LZMA_MODE_NORMAL
Normal compression.
Definition: lzma12.h:147
#define LZMA_PB_DEFAULT
Definition: lzma12.h:319
@ LZMA_MF_HC4
Hash Chain with 2-, 3-, and 4-byte hashing.
Definition: lzma12.h:70
@ LZMA_MF_BT4
Binary Tree with 2-, 3-, and 4-byte hashing.
Definition: lzma12.h:101
@ LZMA_MF_HC3
Hash Chain with 2- and 3-byte hashing.
Definition: lzma12.h:59
#define LZMA_LC_DEFAULT
Definition: lzma12.h:284
#define LZMA_LP_DEFAULT
Definition: lzma12.h:294
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
unsigned int uint32_t
Definition: sftypes.h:29
unsigned char uint8_t
Definition: sftypes.h:31
#define UINT32_C(val)
static int level
Definition: vmenus.c:2424

References flags, level, LZMA_LC_DEFAULT, LZMA_LP_DEFAULT, LZMA_MF_BT4, LZMA_MF_HC3, LZMA_MF_HC4, LZMA_MODE_FAST, LZMA_MODE_NORMAL, LZMA_PB_DEFAULT, LZMA_PRESET_EXTREME, LZMA_PRESET_LEVEL_MASK, NULL, options, preset, and UINT32_C.