Java ByteBuffer Skip skipToNALUnit(ByteBuffer buf)

Here you can find the source of skipToNALUnit(ByteBuffer buf)

Description

skip To NAL Unit

License

BSD License

Declaration

public static final void skipToNALUnit(ByteBuffer buf) 

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 {
    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;
            }
        }
    }
}

Related

  1. skip(ByteBuffer buffer, int length)
  2. skip(ByteBuffer dest, int length)
  3. skipBufs(ByteBuffer[] bufs, int nextWithRemaining)
  4. skipBytes(ByteBuffer buf, int count)
  5. skipChars(ByteBuffer buffer, byte[] chars)
  6. skipUnknown(ByteBuffer buf, int length)