Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: src/liblzma/lzma/lzma_encoder_presets.c

Issue 7109015: Update XZ Utils to 5.0.3 (in deps) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/xz/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/liblzma/lzma/lzma_encoder.c ('k') | src/liblzma/simple/arm.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /////////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////////
2 // 2 //
3 /// \file lzma_encoder_presets.c 3 /// \file lzma_encoder_presets.c
4 /// \brief Encoder presets 4 /// \brief Encoder presets
5 // 5 //
6 // Author: Lasse Collin 6 // Author: Lasse Collin
7 // 7 //
8 // This file has been put into the public domain. 8 // This file has been put into the public domain.
9 // You can do whatever you want with this file. 9 // You can do whatever you want with this file.
10 // 10 //
11 /////////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////////
12 12
13 #include "common.h" 13 #include "common.h"
14 14
15 15
16 extern LZMA_API(lzma_bool) 16 extern LZMA_API(lzma_bool)
17 lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) 17 lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
18 { 18 {
19 const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK; 19 const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;
20 const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK; 20 const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;
21 const uint32_t supported_flags = LZMA_PRESET_EXTREME; 21 const uint32_t supported_flags = LZMA_PRESET_EXTREME;
22 22
23 if (level > 9 || (flags & ~supported_flags)) 23 if (level > 9 || (flags & ~supported_flags))
24 return true; 24 return true;
25 25
26 const uint32_t dict_shift = level <= 1 ? 16 : level + 17;
27 options->dict_size = UINT32_C(1) << dict_shift;
28
29 options->preset_dict = NULL; 26 options->preset_dict = NULL;
30 options->preset_dict_size = 0; 27 options->preset_dict_size = 0;
31 28
32 options->lc = LZMA_LC_DEFAULT; 29 options->lc = LZMA_LC_DEFAULT;
33 options->lp = LZMA_LP_DEFAULT; 30 options->lp = LZMA_LP_DEFAULT;
34 options->pb = LZMA_PB_DEFAULT; 31 options->pb = LZMA_PB_DEFAULT;
35 32
36 » options->mode = level <= 2 ? LZMA_MODE_FAST : LZMA_MODE_NORMAL; 33 » options->dict_size = UINT32_C(1) << (uint8_t []){
34 » » » 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level];
37 35
38 » options->nice_len = level == 0 ? 8 : level <= 5 ? 32 : 64; 36 » if (level <= 3) {
39 » options->mf = level <= 1 ? LZMA_MF_HC3 : level <= 2 ? LZMA_MF_HC4 37 » » options->mode = LZMA_MODE_FAST;
40 » » » : LZMA_MF_BT4; 38 » » options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
41 » options->depth = 0; 39 » » options->nice_len = level <= 1 ? 128 : 273;
40 » » options->depth = (uint8_t []){ 4, 8, 24, 48 }[level];
41 » } else {
42 » » options->mode = LZMA_MODE_NORMAL;
43 » » options->mf = LZMA_MF_BT4;
44 » » options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64;
45 » » options->depth = 0;
46 » }
42 47
43 if (flags & LZMA_PRESET_EXTREME) { 48 if (flags & LZMA_PRESET_EXTREME) {
44 options->lc = 4; // FIXME?
45 options->mode = LZMA_MODE_NORMAL; 49 options->mode = LZMA_MODE_NORMAL;
46 options->mf = LZMA_MF_BT4; 50 options->mf = LZMA_MF_BT4;
47 » » options->nice_len = 273; 51 » » if (level == 3 || level == 5) {
48 » » options->depth = 512; 52 » » » options->nice_len = 192;
53 » » » options->depth = 0;
54 » » } else {
55 » » » options->nice_len = 273;
56 » » » options->depth = 512;
57 » » }
49 } 58 }
50 59
51 return false; 60 return false;
52 } 61 }
OLDNEW
« no previous file with comments | « src/liblzma/lzma/lzma_encoder.c ('k') | src/liblzma/simple/arm.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698