Here you can find the source of readLen(ByteBuffer dup, int nls)
private static int readLen(ByteBuffer dup, int nls)
//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); } } }