FileDocCategorySizeDatePackage
IsoTypeWriter.javaAPI Docmp4parser 1.0-RC-173172Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso

IsoTypeWriter

public final class IsoTypeWriter extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidwriteFixedPoint0230(java.nio.ByteBuffer bb, double v)

        int result = (int) (v * (1 << 30));
        bb.put((byte) ((result & 0xFF000000) >> 24));
        bb.put((byte) ((result & 0x00FF0000) >> 16));
        bb.put((byte) ((result & 0x0000FF00) >> 8));
        bb.put((byte) ((result & 0x000000FF)));
    
public static voidwriteFixedPoint1616(java.nio.ByteBuffer bb, double v)

        int result = (int) (v * 65536);
        bb.put((byte) ((result & 0xFF000000) >> 24));
        bb.put((byte) ((result & 0x00FF0000) >> 16));
        bb.put((byte) ((result & 0x0000FF00) >> 8));
        bb.put((byte) ((result & 0x000000FF)));
    
public static voidwriteFixedPoint88(java.nio.ByteBuffer bb, double v)

        short result = (short) (v * 256);
        bb.put((byte) ((result & 0xFF00) >> 8));
        bb.put((byte) ((result & 0x00FF)));
    
public static voidwriteIso639(java.nio.ByteBuffer bb, java.lang.String language)

        if (language.getBytes().length != 3) {
            throw new IllegalArgumentException("\"" + language + "\" language string isn't exactly 3 characters long!");
        }
        int bits = 0;
        for (int i = 0; i < 3; i++) {
            bits += (language.getBytes()[i] - 0x60) << (2 - i) * 5;
        }
        writeUInt16(bb, bits);
    
public static voidwriteUInt16(java.nio.ByteBuffer bb, int i)

        i = i & 0xFFFF;
        writeUInt8(bb, i >> 8);
        writeUInt8(bb, i & 0xFF);
    
public static voidwriteUInt16BE(java.nio.ByteBuffer bb, int i)

        i = i & 0xFFFF;
        writeUInt8(bb, i & 0xFF);
        writeUInt8(bb, i >> 8);
    
public static voidwriteUInt24(java.nio.ByteBuffer bb, int i)

        i = i & 0xFFFFFF;
        writeUInt16(bb, i >> 8);
        writeUInt8(bb, i);

    
public static voidwriteUInt32(java.nio.ByteBuffer bb, long u)

        bb.putInt((int) u);

    
public static voidwriteUInt32BE(java.nio.ByteBuffer bb, long u)

        assert u >= 0 && u <= 1L << 32 : "The given long is not in the range of uint32 (" + u + ")";
        writeUInt16BE(bb, (int) u & 0xFFFF);
        writeUInt16BE(bb, (int) ((u >> 16) & 0xFFFF));

    
public static voidwriteUInt64(java.nio.ByteBuffer bb, long u)

        bb.putLong(u);
    
public static voidwriteUInt8(java.nio.ByteBuffer bb, int i)

        i = i & 0xFF;
        bb.put((byte) i);
    
public static voidwriteUtf8String(java.nio.ByteBuffer bb, java.lang.String string)


        bb.put(Utf8.convert(string));
        writeUInt8(bb, 0);