Java ByteBuffer to Float toFloat16BE(ByteBuffer buf, FloatBuffer out)

Here you can find the source of toFloat16BE(ByteBuffer buf, FloatBuffer out)

Description

to Float BE

License

BSD License

Declaration

private static void toFloat16BE(ByteBuffer buf, FloatBuffer out) 

Method Source Code

//package com.java2s;
/**//from ww w. ja  v a2 s  .c  o  m
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author The JCodec project
 * 
 */

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

public class Main {
    public final static float r16 = 1f / 32768f;

    private static void toFloat16BE(ByteBuffer buf, FloatBuffer out) {
        while (buf.remaining() >= 2 && out.hasRemaining()) {
            out.put(r16 * (short) (((buf.get() & 0xff) << 8) | (buf.get() & 0xff)));
        }
    }
}

Related

  1. readFloats(final ByteBuffer bb, final int length)
  2. toFloat(AudioFormat format, ByteBuffer buf, float[] floatBuf)
  3. toFloat(ByteBuffer buffer)
  4. toFloat(ByteBuffer bytes)
  5. toFloat(ByteBuffer value)
  6. toFloat24BE(ByteBuffer buf, float[] out)