FileDocCategorySizeDatePackage
CAVLCReader.javaAPI Docmp4parser 1.0-RC-175069Wed Dec 19 20:10:37 GMT 2012com.googlecode.mp4parser.h264.read

CAVLCReader

public class CAVLCReader extends BitstreamReader

Fields Summary
Constructors Summary
public CAVLCReader(InputStream is)

        super(is);
    
Methods Summary
public byte[]read(int payloadSize)

        byte[] result = new byte[payloadSize];
        for (int i = 0; i < payloadSize; i++) {
            result[i] = (byte) readByte();
        }
        return result;
    
public booleanreadAE()

        // TODO: do it!!
        throw new UnsupportedOperationException("Stan");
    
public intreadAEI()

        // TODO: do it!!
        throw new UnsupportedOperationException("Stan");
    
public booleanreadBool(java.lang.String message)


        boolean res = read1Bit() == 0 ? false : true;

        trace(message, res ? "1" : "0");

        return res;
    
public java.lang.ObjectreadCE(com.googlecode.mp4parser.h264.BTree bt, java.lang.String message)

        while (true) {
            int bit = read1Bit();
            bt = bt.down(bit);
            if (bt == null) {
                throw new RuntimeException("Illegal code");
            }
            Object i = bt.getValue();
            if (i != null) {
                trace(message, i.toString());
                return i;
            }
        }
    
public intreadME(java.lang.String string)

        return readUE(string);
    
public longreadNBit(int n, java.lang.String message)

        long val = readNBit(n);

        trace(message, String.valueOf(val));

        return val;
    
public intreadSE(java.lang.String message)

        int val = readUE();

        int sign = ((val & 0x1) << 1) - 1;
        val = ((val >> 1) + (val & 0x1)) * sign;

        trace(message, String.valueOf(val));

        return val;
    
public intreadTE(int max)

        if (max > 1)
            return readUE();
        return ~read1Bit() & 0x1;
    
public voidreadTrailingBits()

        read1Bit();
        readRemainingByte();
    
public intreadU(int i, java.lang.String string)

        return (int) readNBit(i, string);
    
private intreadUE()
Read unsigned exp-golomb code

return
throws
java.io.IOException
throws
java.io.IOException

        int cnt = 0;
        while (read1Bit() == 0)
            cnt++;

        int res = 0;
        if (cnt > 0) {
            long val = readNBit(cnt);

            res = (int) ((1 << cnt) - 1 + val);
        }

        return res;
    
public intreadUE(java.lang.String message)

        int res = readUE();

        trace(message, String.valueOf(res));

        return res;
    
public intreadZeroBitCount(java.lang.String message)

        int count = 0;
        while (read1Bit() == 0)
            count++;

        trace(message, String.valueOf(count));

        return count;
    
private voidtrace(java.lang.String message, java.lang.String val)

        StringBuilder traceBuilder = new StringBuilder();
        int spaces;
        String pos = String.valueOf(bitsRead - debugBits.length());
        spaces = 8 - pos.length();

        traceBuilder.append("@" + pos);

        for (int i = 0; i < spaces; i++)
            traceBuilder.append(' ");

        traceBuilder.append(message);
        spaces = 100 - traceBuilder.length() - debugBits.length();
        for (int i = 0; i < spaces; i++)
            traceBuilder.append(' ");
        traceBuilder.append(debugBits);
        traceBuilder.append(" (" + val + ")");
        debugBits.clear();

        println(traceBuilder.toString());