Package SevenZip.Compression.LZMA

Examples of SevenZip.Compression.LZMA.Encoder


  public long compress(InputStream is, OutputStream os, long maxReadLength, long maxWriteLength) throws IOException, CompressionOutputSizeException {
    CountedInputStream cis = null;
    CountedOutputStream cos = null;
    cis = new CountedInputStream(is);
    cos = new CountedOutputStream(os);
    Encoder encoder = new Encoder();
        encoder.SetEndMarkerMode( true );
        int dictionarySize = 1;
        if(maxReadLength == Long.MAX_VALUE || maxReadLength < 0) {
          dictionarySize = MAX_DICTIONARY_SIZE;
          Logger.error(this, "No indication of size, having to use maximum dictionary size", new Exception("debug"));
        } else {
          while(dictionarySize < maxReadLength && dictionarySize < MAX_DICTIONARY_SIZE)
            dictionarySize <<= 1;
        }
        encoder.SetDictionarySize( dictionarySize );
        encoder.WriteCoderProperties(os);
        encoder.Code( cis, cos, maxReadLength, maxWriteLength, null );
    if(cos.written() > maxWriteLength)
      throw new CompressionOutputSizeException(cos.written());
        cos.flush();
    if(logMINOR)
      Logger.minor(this, "Read "+cis.count()+" written "+cos.written());
View Full Code Here


  public long compress(InputStream is, OutputStream os, long maxReadLength, long maxWriteLength) throws IOException, CompressionOutputSizeException {
    CountedInputStream cis = null;
    CountedOutputStream cos = null;
    cis = new CountedInputStream(is);
    cos = new CountedOutputStream(os);
    Encoder encoder = new Encoder();
        encoder.SetEndMarkerMode( true );
        // Dictionary size 1MB, this is equivalent to lzma -4, it uses 16MB to compress and 2MB to decompress.
        // Next one up is 2MB = -5 = 26M compress, 3M decompress.
        encoder.SetDictionarySize( 1 << 20 );
        // enc.WriteCoderProperties( out );
        // 5d 00 00 10 00
        encoder.Code( cis, cos, -1, -1, null );
    if(logMINOR)
      Logger.minor(this, "Read "+cis.count()+" written "+cos.written());
    if(cos.written() > maxWriteLength)
      throw new CompressionOutputSizeException();
    cos.flush();
View Full Code Here

    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)
        {
View Full Code Here

public class LZMACompressor
{
    public LZMACompressor()
    {
        // init the encoder to it is ready for work
        encoder = new Encoder();

        // Note: algorithm doesn't do anything at this time.
        /// value 1 is supposed to be "max"
        if (!encoder.SetAlgorithm(1))
            assert false;
View Full Code Here

  public class EncodeThread extends Thread {
    final Encoder encoder;
    final OutputStream stream;
   
    public EncodeThread(OutputStream stream, long origSize, int dictionarySize, int literalContextBits, int literalPosStateBits, int posStateBits, int fastBytes) throws IOException {
      this.encoder = new Encoder();
      this.encoder.SetEndMarkerMode(origSize < 0);
      this.encoder.WriteCoderProperties(stream);
      BinCoder.putInt8(origSize, stream);
      this.encoder.SetDictionarySize(dictionarySize);
      // note: in the 9.20 SDK, setting the algorithm does nothing
View Full Code Here

        try {
            outputPipe = new DigestOutputStream(uncompressedSize, MessageDigest.getInstance("SHA1"));
        } catch (NoSuchAlgorithmException e) {
           throw new IOException("Could not create LZMAOutputStream", e);
        }
        lzma = new Encoder();
        lzma.SetDictionarySize(compressionProfile.dictionarySize);
        lzma.SetNumFastBytes(compressionProfile.fastBytes);
        lzma.SetMatchFinder(compressionProfile.matchFinder);
        lzma.SetLcLpPb(compressionProfile.lc, compressionProfile.lp, compressionProfile.pb);
        lzma.SetEndMarkerMode(true);
View Full Code Here

        }
        inputPipe = new PipedInputStream();
        outputPipe = new PipedOutputStream(inputPipe);
       
        compressedSize = new CountingInputStream(inputPipe);
        lzma = new Encoder();
        lzma.SetDictionarySize(compressionProfile.dictionarySize);
        lzma.SetNumFastBytes(compressionProfile.fastBytes);
        lzma.SetMatchFinder(compressionProfile.matchFinder);
        lzma.SetLcLpPb(compressionProfile.lc, compressionProfile.lp, compressionProfile.pb);
        lzma.SetEndMarkerMode(true);
View Full Code Here

TOP

Related Classes of SevenZip.Compression.LZMA.Encoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.