Here you can find the source of skipToNALUnit(ByteBuffer buf)
public static final void skipToNALUnit(ByteBuffer buf)
//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 { public static final void skipToNALUnit(ByteBuffer buf) { if (!buf.hasRemaining()) return; int val = 0xffffffff; while (buf.hasRemaining()) { val <<= 8; val |= (buf.get() & 0xff); if ((val & 0xffffff) == 1) { buf.position(buf.position()); break; } } } }