@@ -0,0 +1,1334 @@
+package org.q3df.common;%0A%0A/**%0A * Created by michael on 21.06.17.%0A */%0Apublic class BitStream %7B%0A%0A%0A    private static int BIT_POS%5B%5D = new int%5B32%5D;%0A    private static int BIT_POS_REV%5B%5D = new int%5B32%5D;%0A%0A    static %7B%0A        int mask = 0x01;%0A        for (int i = 0; i %3C 32; i++)%7B%0A            BIT_POS%5Bi%5D = mask;%0A            BIT_POS_REV%5B31-i%5D = mask;%0A            mask %3C%3C= 1;%0A        %7D%0A    %7D%0A%0A%0A    private byte%5B%5D data;%0A    private int bitsSize;%0A    private int size;%0A%0A    private int readBitPos;%0A    private int writeBitPos;%0A%0A    public BitStream(byte%5B%5D data, int bitsLen) %7B%0A        if (bitsLen %3C= 0)%0A            throw new RuntimeException(%22wrong bits length : %22 + bitsLen);%0A%0A        this.data = data;%0A        this.bitsSize = Math.min(data.length*8, bitsLen);%0A        this.size = Math.min(data.length, (int)Math.ceil((double)bitsLen/8.0));%0A        this.readBitPos = 0;%0A        this.writeBitPos = 0;%0A    %7D%0A%0A    public int getBitsSize() %7B%0A        return bitsSize;%0A    %7D%0A%0A    public int getSize() %7B%0A        return size;%0A    %7D%0A%0A    public int getReadBitPos () %7B%0A        return readBitPos;%0A    %7D%0A%0A    public int getWriteBitPos() %7B%0A        return writeBitPos;%0A    %7D%0A%0A    public boolean write (int val, int bits) %7B%0A        if (bits + writeBitPos %3E= bitsSize)%0A            return false;%0A%0A%0A    %7D%0A%0A    public byte%5B%5D data () %7B%0A        return data;%0A    %7D%0A%7D%0A

add bit-stream