@Override
    public Container load(InputStream is) throws FormatException, IOException {

        byte[] headerBytes = new byte[11];

        int bytesRead = is.read(headerBytes);

        if (bytesRead < 11) {
            throw new FormatException("MLA header is too small");
        } else {
            short headerSize = ByteBuffer.wrap(headerBytes, 0, 2).getShort();

            if (headerSize < 16) {
                throw new FormatException("MLA header specified invalid header size");
            }

            AudioFormat audioFormat = audioFormatFromHeaderValue(headerBytes[2]);

            if (audioFormat == null) {
                throw new FormatException("MLA header specified unsupported audio format");
            }

            int loopAreaOffset = ByteBuffer.wrap(headerBytes, 3, 4).getInt();
            int loopAreaSize = ByteBuffer.wrap(headerBytes, 7, 4).getInt();

            int extraDataSize = headerSize - 16;
            byte[] extraData = new byte[extraDataSize];

            bytesRead = Math.max(0, is.read(extraData));

            if (bytesRead < extraDataSize) {
                throw new FormatException("MLA extra data is truncated");
            }

            Header header = new Header();
            header.setSize(headerSize);
            header.setAudioFormat(audioFormat);
            header.setLoopAreaOffset(loopAreaOffset);
            header.setLoopAreaSize(loopAreaSize);
            header.setExtraData(extraData);

            Container container = new pm.monkey.mla4j.v1.Container();
            container.setHeader(header);

            return container;
        }
    }