Methods Summary |
---|
public static int | byte2int(byte b)
return b < 0 ? b + 256 : b;
|
public static java.lang.String | read4cc(java.nio.ByteBuffer bb)
byte[] b = new byte[4];
bb.get(b);
return IsoFile.bytesToFourCC(b);
|
public static double | readFixedPoint0230(java.nio.ByteBuffer bb)
byte[] bytes = new byte[4];
bb.get(bytes);
int result = 0;
result |= ((bytes[0] << 24) & 0xFF000000);
result |= ((bytes[1] << 16) & 0xFF0000);
result |= ((bytes[2] << 8) & 0xFF00);
result |= ((bytes[3]) & 0xFF);
return ((double) result) / (1 << 30);
|
public static double | readFixedPoint1616(java.nio.ByteBuffer bb)
byte[] bytes = new byte[4];
bb.get(bytes);
int result = 0;
result |= ((bytes[0] << 24) & 0xFF000000);
result |= ((bytes[1] << 16) & 0xFF0000);
result |= ((bytes[2] << 8) & 0xFF00);
result |= ((bytes[3]) & 0xFF);
return ((double) result) / 65536;
|
public static float | readFixedPoint88(java.nio.ByteBuffer bb)
byte[] bytes = new byte[2];
bb.get(bytes);
short result = 0;
result |= ((bytes[0] << 8) & 0xFF00);
result |= ((bytes[1]) & 0xFF);
return ((float) result) / 256;
|
public static java.lang.String | readIso639(java.nio.ByteBuffer bb)
int bits = readUInt16(bb);
StringBuilder result = new StringBuilder();
for (int i = 0; i < 3; i++) {
int c = (bits >> (2 - i) * 5) & 0x1f;
result.append((char) (c + 0x60));
}
return result.toString();
|
public static java.lang.String | readString(java.nio.ByteBuffer byteBuffer)Reads a zero terminated UTF-8 string.
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read;
while ((read = byteBuffer.get()) != 0) {
out.write(read);
}
return Utf8.convert(out.toByteArray());
|
public static java.lang.String | readString(java.nio.ByteBuffer byteBuffer, int length)
byte[] buffer = new byte[length];
byteBuffer.get(buffer);
return Utf8.convert(buffer);
|
public static int | readUInt16(java.nio.ByteBuffer bb)
int result = 0;
result += byte2int(bb.get()) << 8;
result += byte2int(bb.get());
return result;
|
public static int | readUInt16BE(java.nio.ByteBuffer bb)
int result = 0;
result += byte2int(bb.get());
result += byte2int(bb.get()) << 8;
return result;
|
public static int | readUInt24(java.nio.ByteBuffer bb)
int result = 0;
result += readUInt16(bb) << 8;
result += byte2int(bb.get());
return result;
|
public static long | readUInt32(java.nio.ByteBuffer bb)
long i = bb.getInt();
if (i < 0) {
i += 1l << 32;
}
return i;
|
public static long | readUInt32BE(java.nio.ByteBuffer bb)
long ch1 = readUInt8(bb);
long ch2 = readUInt8(bb);
long ch3 = readUInt8(bb);
long ch4 = readUInt8(bb);
return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
|
public static long | readUInt64(java.nio.ByteBuffer byteBuffer)
long result = 0;
// thanks to Erik Nicolas for finding a bug! Cast to long is definitivly needed
result += readUInt32(byteBuffer) << 32;
if (result < 0) {
throw new RuntimeException("I don't know how to deal with UInt64! long is not sufficient and I don't want to use BigInt");
}
result += readUInt32(byteBuffer);
return result;
|
public static int | readUInt8(java.nio.ByteBuffer bb)
return byte2int(bb.get());
|