Skip to content

Commit

Permalink
ability to set encoder parameters, thanks to Mick Francis
Browse files Browse the repository at this point in the history
darcs-hash:20081016190837-e5a07-2e8fb9b8258e535bf53e55252168257c25969ee4.gz
  • Loading branch information
league committed Oct 16, 2008
1 parent 38fd793 commit 4e3d046
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
14 changes: 13 additions & 1 deletion EncoderThread.java
Expand Up @@ -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;
Expand All @@ -32,20 +33,31 @@ class EncoderThread extends Thread
}

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);
Expand Down
7 changes: 6 additions & 1 deletion LzmaOutputStream.java
Expand Up @@ -31,9 +31,14 @@ public class LzmaOutputStream extends FilterOutputStream
}

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( );
Expand Down
4 changes: 2 additions & 2 deletions Makefile
@@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 4e3d046

Please sign in to comment.