private byte[] selectLSE(byte[] jpegheader) throws NoFixException { if (ByteUtils.bytesBE2ushort(jpegheader, 0) != SOI) throw new NoFixException("SOI marker is missing"); if (ByteUtils.bytesBE2ushort(jpegheader, 2) != SOF55) throw new NoFixException("SOI marker is not followed by JPEG-LS SOF marker"); if (ByteUtils.bytesBE2ushort(jpegheader, 4) != 11) throw new NoFixException("unexpected length of JPEG-LS SOF marker segment"); int marker = ByteUtils.bytesBE2ushort(jpegheader, 15); if (marker != SOS) { throw new NoFixException( marker == LSE ? "contains already LSE marker segment" : "JPEG-LS SOF marker segment is not followed by SOS marker"); } switch (bitsStored = jpegheader[6]) { case 13: return LSE_13; case 14: return LSE_14; case 15: return LSE_15; case 16: return LSE_16; } throw new NoFixException("JPEG-LS " + bitsStored + "-bit"); }