Java ByteBuffer Get getNaluStartLength(ByteBuffer buffer)

Here you can find the source of getNaluStartLength(ByteBuffer buffer)

Description

get Nalu Start Length

License

Open Source License

Declaration

public static int getNaluStartLength(ByteBuffer buffer) 

Method Source Code

//package com.java2s;
/***/*from  w  ww  .j a  v  a2s  . c o m*/
 * The content of this file or document is CONFIDENTIAL and PROPRIETARY
 * to ChengZhen(anyou@msn.com). It is subject to the terms of a
 * License Agreement between Licensee and ChengZhen(anyou@msn.com).
 * restricting among other things, the use, reproduction, distribution
 * and transfer. Each of the embodiments, including this information and
 * any derivative work shall retain this copyright notice.
 *
 * Copyright (c) 2005-2014 ChengZhen(anyou@msn.com) All Rights Reserved.
 *
 */

import java.nio.ByteBuffer;

public class Main {

    public static int getNaluStartLength(ByteBuffer buffer) {
        if (buffer.remaining() <= 4) {
            return 0;
        }

        // byte 2
        if (buffer.get() != 0x00) {
            return 0;
        }

        // byte 3
        byte ch = buffer.get();
        if (ch == 0x01) {
            return 3;

        } else if (ch != 0x00) {
            return 0;
        }

        // byte 4
        ch = buffer.get();
        if (ch == 0x01) {
            return 4;
        }

        return 0;
    }
}

Related

  1. getMean(ByteBuffer simulationResults)
  2. getMedium(ByteBuffer buffer)
  3. getMediumInt(ByteBuffer buffer)
  4. getModularShort(ByteBuffer bb)
  5. getMultiString(ByteBuffer bb, boolean wideChar)
  6. getNextTagNum(ByteBuffer message)
  7. getNTString(ByteBuffer buffer)
  8. getNullTerminatedByte(ByteBuffer buffer)
  9. getNumeric(java.nio.ByteBuffer buffer, int len)