Permalink
Browse files

ability to set encoder parameters, thanks to Mick Francis

darcs-hash:20081016190837-e5a07-2e8fb9b8258e535bf53e55252168257c25969ee4.gz
  • Loading branch information...
1 parent 38fd793 commit 4e3d046fb534cb125c3121c76b5305e8ccd0d396 @league committed Oct 16, 2008
Showing with 21 additions and 4 deletions.
  1. +13 −1 EncoderThread.java
  2. +6 −1 LzmaOutputStream.java
  3. +2 −2 Makefile
View
@@ -15,6 +15,7 @@
class EncoderThread extends Thread
{
+ public static final Integer DEFAULT_DICT_SZ_POW2 = new Integer(1<<20);
protected ArrayBlockingQueue<byte[]> q;
protected InputStream in;
protected OutputStream out;
@@ -33,19 +34,30 @@
EncoderThread( OutputStream _out )
{
+ this(_out, DEFAULT_DICT_SZ_POW2, null);
+ }
+
+ /**
+ * @param dictSzPow2 If non-null, equivalent to the N in the -dN arg to LzmaAlone
+ * @param fastBytes If non-null, equivalent to the N in the -fbN arg to LzmaAlone
+ */
+ EncoderThread( OutputStream _out, Integer dictSzPow2, Integer fastBytes)
+ {
q = ConcurrentBufferOutputStream.newQueue();
in = ConcurrentBufferInputStream.create( q );
out = _out;
enc = new Encoder();
exn = null;
+ enc.SetDictionarySize(1 << (dictSzPow2 == null ? DEFAULT_DICT_SZ_POW2 : dictSzPow2).intValue());
+ if (fastBytes != null)
+ enc.SeNumFastBytes(fastBytes.intValue());
if(DEBUG) dbg.printf("%s << %s (%s)%n", this, in, q);
}
public void run( )
{
try {
enc.SetEndMarkerMode( true );
- enc.SetDictionarySize( 1 << 20 );
// enc.WriteCoderProperties( out );
// 5d 00 00 10 00
if(DEBUG) dbg.printf("%s begins%n", this);
View
@@ -32,8 +32,13 @@
public LzmaOutputStream( OutputStream _out )
{
+ this(_out, EncoderThread.DEFAULT_DICT_SZ_POW2, null);
+ }
+
+ public LzmaOutputStream( OutputStream _out, Integer dictSzPow2, Integer fastBytes )
+ {
super( null );
- eth = new EncoderThread( _out );
+ eth = new EncoderThread( _out, dictSzPow2, fastBytes );
out = ConcurrentBufferOutputStream.create( eth.q );
if(DEBUG) dbg.printf("%s >> %s (%s)%n", this, out, eth.q);
eth.start( );
View
@@ -1,6 +1,6 @@
LZMA_SDK_VERSION = 4.57
LZMA_JIO_MAJOR = 0
-LZMA_JIO_MINOR = 9
+LZMA_JIO_MINOR = 92
LZMA_JIO_VERSION = $(LZMA_JIO_MAJOR).$(LZMA_JIO_MINOR)
JAR = jar
@@ -15,7 +15,7 @@ all: build $(AUX_FILES)
javac -d build $(shell find SevenZip -name '*.java') *.java
build:
- mkdir build
+ -mkdir build
jar: $(JAR_FILE)

0 comments on commit 4e3d046

Please sign in to comment.