Java ByteBuffer Read readLen(ByteBuffer dup, int nls)

Here you can find the source of readLen(ByteBuffer dup, int nls)

Description

read Len

License

BSD License

Declaration

private static int readLen(ByteBuffer dup, int nls) 

Method Source Code

//package com.java2s;
/**/*from   w  w w.  j a va 2 s.com*/
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author Jay Codec
 * 
 */

import java.nio.ByteBuffer;

public class Main {
    private static int readLen(ByteBuffer dup, int nls) {
        switch (nls) {
        case 1:
            return dup.get() & 0xff;
        case 2:
            return dup.getShort() & 0xffff;
        case 3:
            return ((dup.getShort() & 0xffff) << 8) | (dup.get() & 0xff);
        case 4:
            return dup.getInt();
        default:
            throw new IllegalArgumentException("NAL Unit length size can not be " + nls);
        }
    }
}

Related

  1. readFully(final FileChannel src, final ByteBuffer dst, final long position)
  2. readHealthFloat16(ByteBuffer data)
  3. readHexString(ByteBuffer buffer, int nrBytes)
  4. readIso639(ByteBuffer bb)
  5. readKatakana(ByteBuffer b, char s[], int off, int len)
  6. readLink(ByteBuffer bb)
  7. readLink(ByteBuffer bb)
  8. readNewLine(ByteBuffer buf)
  9. readNullTerminatedString(ByteBuffer buf)