Examples of HuffmanEncoder


Examples of org.toubassi.femtozip.coding.huffman.HuffmanEncoder

    public void endEncoding(Object context) {
        throw new UnsupportedOperationException();
    }
   
    public void compress(byte[] data, OutputStream out) throws IOException {
        HuffmanEncoder encoder = new HuffmanEncoder(codeModel, out);
        for (int i = 0, count = data.length; i < count; i++) {
            encoder.encodeSymbol(((int)data[i]) & 0xff);
        }
        encoder.close();
    }
View Full Code Here

Examples of org.toubassi.femtozip.coding.huffman.HuffmanEncoder

    protected SubstringPacker.Consumer createModelBuilder() {
        return new ModelBuilder();
    }
   
    public void compress(byte[] data, OutputStream out) throws IOException {
        getSubstringPacker().pack(data, this, new HuffmanEncoder(codeModel.createModel(), out));
    }
View Full Code Here

Examples of org.toubassi.femtozip.coding.huffman.HuffmanEncoder

        getSubstringPacker().pack(data, this, new HuffmanEncoder(codeModel.createModel(), out));
    }
   
    public void encodeLiteral(int aByte, Object context) {
        try {
            HuffmanEncoder encoder = (HuffmanEncoder)context;
            encoder.encodeSymbol(aByte);
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.toubassi.femtozip.coding.huffman.HuffmanEncoder

        }
    }

    public void encodeSubstring(int offset, int length, Object context) {
        try {
            HuffmanEncoder encoder = (HuffmanEncoder)context;
            if (length < 1 || length > 255) {
                throw new IllegalArgumentException("Length " + length + " out of range [1,255]");
            }
            encoder.encodeSymbol(256 + length);
           
            offset = -offset;
            if (offset < 1 || offset > (2<<15)-1) {
                throw new IllegalArgumentException("Offset " + offset + " out of range [1, 65535]");
            }
            encoder.encodeSymbol(offset & 0xf);
            encoder.encodeSymbol((offset >> 4) & 0xf);
            encoder.encodeSymbol((offset >> 8) & 0xf);
            encoder.encodeSymbol((offset >> 12) & 0xf);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.toubassi.femtozip.coding.huffman.HuffmanEncoder

        }
    }
   
    public void endEncoding(Object context) {
        try {
            HuffmanEncoder encoder = (HuffmanEncoder)context;
            encoder.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.