xref: /aosp_15_r20/external/lzma/CPP/7zip/Compress/BZip2Const.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Compress/BZip2Const.h
2 
3 #ifndef ZIP7_INC_COMPRESS_BZIP2_CONST_H
4 #define ZIP7_INC_COMPRESS_BZIP2_CONST_H
5 
6 namespace NCompress {
7 namespace NBZip2 {
8 
9 const Byte kArSig0 = 'B';
10 const Byte kArSig1 = 'Z';
11 const Byte kArSig2 = 'h';
12 const Byte kArSig3 = '0';
13 
14 const Byte kFinSig0 = 0x17;
15 const Byte kFinSig1 = 0x72;
16 const Byte kFinSig2 = 0x45;
17 const Byte kFinSig3 = 0x38;
18 const Byte kFinSig4 = 0x50;
19 const Byte kFinSig5 = 0x90;
20 
21 const Byte kBlockSig0 = 0x31;
22 const Byte kBlockSig1 = 0x41;
23 const Byte kBlockSig2 = 0x59;
24 const Byte kBlockSig3 = 0x26;
25 const Byte kBlockSig4 = 0x53;
26 const Byte kBlockSig5 = 0x59;
27 
28 const unsigned kNumOrigBits = 24;
29 
30 const unsigned kNumTablesBits = 3;
31 const unsigned kNumTablesMin = 2;
32 const unsigned kNumTablesMax = 6;
33 
34 const unsigned kNumLevelsBits = 5;
35 
36 const unsigned kMaxHuffmanLen = 20; // Check it
37 
38 const unsigned kMaxAlphaSize = 258;
39 
40 const unsigned kGroupSize = 50;
41 
42 const unsigned kBlockSizeMultMin = 1;
43 const unsigned kBlockSizeMultMax = 9;
44 
45 const UInt32 kBlockSizeStep = 100000;
46 const UInt32 kBlockSizeMax = kBlockSizeMultMax * kBlockSizeStep;
47 
48 const unsigned kNumSelectorsBits = 15;
49 const UInt32 kNumSelectorsMax = (2 + (kBlockSizeMax / kGroupSize));
50 
51 const unsigned kRleModeRepSize = 4;
52 
53 /*
54 The number of selectors stored in bzip2 block:
55 (numSelectors <= 18001) - must work with any decoder.
56 (numSelectors == 18002) - works with bzip2 1.0.6 decoder and all derived decoders.
57 (numSelectors  > 18002)
58    lbzip2 2.5: encoder can write up to (18001 + 7) selectors.
59 
60    7-Zip before 19.03: decoder doesn't support it.
61    7-Zip        19.03: decoder allows 8 additional selector records for lbzip2 compatibility.
62 
63    bzip2 1.0.6: decoder can overflow selector[18002] arrays. But there are another
64                arrays after selector arrays. So the compiled code works.
65    bzip2 1.0.7: decoder doesn't support it.
66    bzip2 1.0.8: decoder allows additional selector records for lbzip2 compatibility.
67 */
68 
69 }}
70 
71 #endif
72