X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=blobdiff_plain;f=misc%2Ftools%2FNexuizDemoRecorder%2Fmain%2Fsrc%2Fmain%2Fjava%2Fcom%2Fnexuiz%2Fdemorecorder%2Fapplication%2Fdemocutter%2FDemoCutterUtils.java;h=0de518aef576dbfd169de1a9be0a469b58d47182;hp=dd8f9ca45f58f84d27e89b3a88b7568ab80a1361;hb=d36387088cb9338aa4484a7e6e82bfe69defa1e2;hpb=6cac8f921eb4ac15017ef13206a595f600390b42 diff --git a/misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/democutter/DemoCutterUtils.java b/misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/democutter/DemoCutterUtils.java index dd8f9ca4..0de518ae 100644 --- a/misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/democutter/DemoCutterUtils.java +++ b/misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/democutter/DemoCutterUtils.java @@ -1,40 +1,40 @@ -package com.nexuiz.demorecorder.application.democutter; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -public class DemoCutterUtils { - - public static float byteArrayToFloat(byte[] array) { - byte[] tmp = new byte[4]; - System.arraycopy(array, 0, tmp, 0, 4); - int accum = 0; - int i = 0; - for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { - accum |= ((long) (tmp[i++] & 0xff)) << shiftBy; - } - return Float.intBitsToFloat(accum); - } - - public static byte[] convertLittleEndian(int i) { - ByteBuffer bb = ByteBuffer.allocate(4); - bb.order(ByteOrder.LITTLE_ENDIAN); - bb.putInt(i); - return bb.array(); - } - - public static byte[] mergeByteArrays(byte[] array1, byte[] array2) { - ByteBuffer bb = ByteBuffer.allocate(array1.length + array2.length); - bb.put(array1); - bb.put(array2); - return bb.array(); - } - - public static int convertLittleEndian(byte[] b) { - ByteBuffer bb = ByteBuffer.allocate(4); - bb.order(ByteOrder.LITTLE_ENDIAN); - bb.put(b); - bb.position(0); - return bb.getInt(); - } -} +package com.nexuiz.demorecorder.application.democutter; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + + +public class DemoCutterUtils { + + public static float byteArrayToFloat(byte[] array) { + byte[] tmp = new byte[4]; + System.arraycopy(array, 0, tmp, 0, 4); + int accum = 0; + int i = 0; + for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { + accum |= ((long) (tmp[i++] & 0xff)) << shiftBy; + } + return Float.intBitsToFloat(accum); + } + + public static byte[] convertLittleEndian(int i) { + ByteBuffer bb = ByteBuffer.allocate(4); + bb.order(ByteOrder.LITTLE_ENDIAN); + bb.putInt(i); + return bb.array(); + } + + public static byte[] mergeByteArrays(byte[] array1, byte[] array2) { + ByteBuffer bb = ByteBuffer.allocate(array1.length + array2.length); + bb.put(array1); + bb.put(array2); + return bb.array(); + } + + public static int convertLittleEndian(byte[] b) { + ByteBuffer bb = ByteBuffer.allocate(4); + bb.order(ByteOrder.LITTLE_ENDIAN); + bb.put(b); + bb.position(0); + return bb.getInt(); + } +}