1 /*
2  * LZMA2Decoder
3  *
4  * Author: Lasse Collin <lasse.collin@tukaani.org>
5  *
6  * This file has been put into the public domain.
7  * You can do whatever you want with this file.
8  */
9 
10 package org.tukaani.xz;
11 
12 import java.io.InputStream;
13 
14 class LZMA2Decoder extends LZMA2Coder implements FilterDecoder {
15     private int dictSize;
16 
LZMA2Decoder(byte[] props)17     LZMA2Decoder(byte[] props) throws UnsupportedOptionsException {
18         // Up to 1.5 GiB dictionary is supported. The bigger ones
19         // are too big for int.
20         if (props.length != 1 || (props[0] & 0xFF) > 37)
21             throw new UnsupportedOptionsException(
22                     "Unsupported LZMA2 properties");
23 
24         dictSize = 2 | (props[0] & 1);
25         dictSize <<= (props[0] >>> 1) + 11;
26     }
27 
getMemoryUsage()28     public int getMemoryUsage() {
29         return LZMA2InputStream.getMemoryUsage(dictSize);
30     }
31 
getInputStream(InputStream in, ArrayCache arrayCache)32     public InputStream getInputStream(InputStream in, ArrayCache arrayCache) {
33         return new LZMA2InputStream(in, dictSize, null, arrayCache);
34     }
35 }
36