Class HuffmanDecoder
java.lang.Object
org.apache.commons.compress.compressors.deflate64.HuffmanDecoder
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
private class
private static class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]
When using dynamic huffman codes the order in which the values are stored follows the positioning belowprivate static final int[]
-------------------------------------------------------------------- idx xtra dist idx xtra dist idx xtra dist -------------------------------------------------------------------- 0 0 1 10 4 33-48 20 9 1025-1536 1 0 2 11 4 49-64 21 9 1537-2048 2 0 3 12 5 65-96 22 10 2049-3072 3 0 4 13 5 97-128 23 10 3073-4096 4 1 5,6 14 6 129-192 24 11 4097-6144 5 1 7,8 15 6 193-256 25 11 6145-8192 6 2 9-12 16 7 257-384 26 12 8193-12288 7 2 13-16 17 7 385-512 27 12 12289-16384 8 3 17-24 18 8 513-768 28 13 16385-24576 9 3 25-32 19 8 769-1024 29 13 24577-32768 30 14 32769-49152 31 14 49153-65536 --------------------------------------------------------------------private boolean
private static final int[]
private static final int[]
Huffman Fixed Literal / Distance tables for mode 1private final InputStream
private final HuffmanDecoder.DecodingMemory
private BitInputStream
private static final short[]
-------------------------------------------------------------------- idx xtra base idx xtra base idx xtra base -------------------------------------------------------------------- 257 0 3 267 1 15,16 277 4 67-82 258 0 4 268 1 17,18 278 4 83-98 259 0 5 269 2 19-22 279 4 99-114 260 0 6 270 2 23-26 280 4 115-130 261 0 7 271 2 27-30 281 5 131-162 262 0 8 272 2 31-34 282 5 163-194 263 0 9 273 3 35-42 283 5 195-226 264 0 10 274 3 43-50 284 5 227-257 265 1 11,12 275 3 51-58 285 16 3 266 1 13,14 276 3 59-66 --------------------------------------------------------------------private HuffmanDecoder.DecoderState
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) int
private static HuffmanDecoder.BinaryTreeNode
buildTree
(int[] litTable) void
close()
int
decode
(byte[] b) int
decode
(byte[] b, int off, int len) (package private) long
private static int[]
getCodes
(int[] litTable) private static int
nextSymbol
(BitInputStream reader, HuffmanDecoder.BinaryTreeNode tree) private static void
populateDynamicTables
(BitInputStream reader, int[] literals, int[] distances) private long
readBits
(int numBits) private static long
readBits
(BitInputStream reader, int numBits) private int[][]
private void
-
Field Details
-
RUN_LENGTH_TABLE
private static final short[] RUN_LENGTH_TABLE-------------------------------------------------------------------- idx xtra base idx xtra base idx xtra base -------------------------------------------------------------------- 257 0 3 267 1 15,16 277 4 67-82 258 0 4 268 1 17,18 278 4 83-98 259 0 5 269 2 19-22 279 4 99-114 260 0 6 270 2 23-26 280 4 115-130 261 0 7 271 2 27-30 281 5 131-162 262 0 8 272 2 31-34 282 5 163-194 263 0 9 273 3 35-42 283 5 195-226 264 0 10 274 3 43-50 284 5 227-257 265 1 11,12 275 3 51-58 285 16 3 266 1 13,14 276 3 59-66 --------------------------------------------------------------------
value = (base of run length) << 5 | (number of extra bits to read) -
DISTANCE_TABLE
private static final int[] DISTANCE_TABLE-------------------------------------------------------------------- idx xtra dist idx xtra dist idx xtra dist -------------------------------------------------------------------- 0 0 1 10 4 33-48 20 9 1025-1536 1 0 2 11 4 49-64 21 9 1537-2048 2 0 3 12 5 65-96 22 10 2049-3072 3 0 4 13 5 97-128 23 10 3073-4096 4 1 5,6 14 6 129-192 24 11 4097-6144 5 1 7,8 15 6 193-256 25 11 6145-8192 6 2 9-12 16 7 257-384 26 12 8193-12288 7 2 13-16 17 7 385-512 27 12 12289-16384 8 3 17-24 18 8 513-768 28 13 16385-24576 9 3 25-32 19 8 769-1024 29 13 24577-32768 30 14 32769-49152 31 14 49153-65536 --------------------------------------------------------------------
value = (base of distance) << 4 | (number of extra bits to read) -
CODE_LENGTHS_ORDER
private static final int[] CODE_LENGTHS_ORDERWhen using dynamic huffman codes the order in which the values are stored follows the positioning below -
FIXED_LITERALS
private static final int[] FIXED_LITERALSHuffman Fixed Literal / Distance tables for mode 1 -
FIXED_DISTANCE
private static final int[] FIXED_DISTANCE -
finalBlock
private boolean finalBlock -
state
-
reader
-
in
-
memory
-
-
Constructor Details
-
HuffmanDecoder
HuffmanDecoder(InputStream in)
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
decode
- Throws:
IOException
-
decode
- Throws:
IOException
-
getBytesRead
long getBytesRead()- Since:
- 1.17
-
switchToUncompressedState
- Throws:
IOException
-
readDynamicTables
- Throws:
IOException
-
available
- Throws:
IOException
-
nextSymbol
private static int nextSymbol(BitInputStream reader, HuffmanDecoder.BinaryTreeNode tree) throws IOException - Throws:
IOException
-
populateDynamicTables
private static void populateDynamicTables(BitInputStream reader, int[] literals, int[] distances) throws IOException - Throws:
IOException
-
buildTree
-
getCodes
private static int[] getCodes(int[] litTable) -
readBits
- Throws:
IOException
-
readBits
- Throws:
IOException
-