FileDocCategorySizeDatePackage
BitReaderBufferTest.javaAPI Docmp4parser 1.0-RC-172013Wed Dec 19 20:10:21 GMT 2012com.googlecode.mp4parser.boxes.mp4.objectdescriptors

BitReaderBufferTest

public class BitReaderBufferTest extends Object

Fields Summary
ByteBuffer
testSequence
Constructors Summary
Methods Summary
public voidreadFromTheMiddle()


    
       
        ByteBuffer b = ByteBuffer.wrap(new byte[]{0, -1});
        b.get();
        BitReaderBuffer brb = new BitReaderBuffer(b);
        Assert.assertEquals(15, brb.readBits(4));
        Assert.assertEquals(15, brb.readBits(4));

    
public voidtestReadCrossByte()

        BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence);
        Assert.assertEquals(31, bitReaderBuffer.readBits(5));
        Assert.assertEquals(14, bitReaderBuffer.readBits(4));
        Assert.assertEquals(0, bitReaderBuffer.readBits(3));
        Assert.assertEquals(0, bitReaderBuffer.readBits(4));
    
public voidtestReadMultiByte()

        BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence);
        Assert.assertEquals(510, bitReaderBuffer.readBits(9));
    
public voidtestReadMultiByte2()

        BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence);
        Assert.assertEquals(0x1fe01, bitReaderBuffer.readBits(17));
    
public voidtestRead_8()

        BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence);
        Assert.assertEquals(15, bitReaderBuffer.readBits(4));
        Assert.assertEquals(15, bitReaderBuffer.readBits(4));
        Assert.assertEquals(0, bitReaderBuffer.readBits(4));
        Assert.assertEquals(0, bitReaderBuffer.readBits(4));
    
public voidtestRemainingBits()

        BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence);
        Assert.assertEquals(32, bitReaderBuffer.remainingBits());
        int six = 6;
        bitReaderBuffer.readBits(six);
        Assert.assertEquals(32 - six, bitReaderBuffer.remainingBits());