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

Side by Side Diff: third_party/lzma/v4_65/files/Java/SevenZip/Compression/RangeCoder/BitTreeDecoder.java

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
(Empty)
1 package SevenZip.Compression.RangeCoder;
2
3 public class BitTreeDecoder
4 {
5 short[] Models;
6 int NumBitLevels;
7
8 public BitTreeDecoder(int numBitLevels)
9 {
10 NumBitLevels = numBitLevels;
11 Models = new short[1 << numBitLevels];
12 }
13
14 public void Init()
15 {
16 Decoder.InitBitModels(Models);
17 }
18
19 public int Decode(Decoder rangeDecoder) throws java.io.IOException
20 {
21 int m = 1;
22 for (int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)
23 m = (m << 1) + rangeDecoder.DecodeBit(Models, m);
24 return m - (1 << NumBitLevels);
25 }
26
27 public int ReverseDecode(Decoder rangeDecoder) throws java.io.IOExceptio n
28 {
29 int m = 1;
30 int symbol = 0;
31 for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
32 {
33 int bit = rangeDecoder.DecodeBit(Models, m);
34 m <<= 1;
35 m += bit;
36 symbol |= (bit << bitIndex);
37 }
38 return symbol;
39 }
40
41 public static int ReverseDecode(short[] Models, int startIndex,
42 Decoder rangeDecoder, int NumBitLevels) throws java.io.I OException
43 {
44 int m = 1;
45 int symbol = 0;
46 for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
47 {
48 int bit = rangeDecoder.DecodeBit(Models, startIndex + m) ;
49 m <<= 1;
50 m += bit;
51 symbol |= (bit << bitIndex);
52 }
53 return symbol;
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698