Exemplo n.º 1
0
 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");
 }
Exemplo n.º 2
0
 @SuppressWarnings("deprecation")
 private void addImplClassUIDReplacements(long pos, int len, int eoffmipos) {
   int uidlen = FixJpegLS.this.newImplClassUID.length();
   int newlen = (uidlen + 1) & ~1;
   if (eoffmipos > 0) {
     byte[] newfmilen = new byte[4];
     ByteUtils.int2bytesLE(eoffmipos - 144 - len + newlen, newfmilen, 0);
     replacements.add(new Replacement(140, 4, newfmilen));
   }
   byte[] newval = new byte[newlen + 2];
   ByteUtils.ushort2bytesLE(newlen, newval, 0);
   FixJpegLS.this.newImplClassUID.getBytes(0, uidlen, newval, 2);
   replacements.add(new Replacement(pos - 2, len + 2, newval));
 }
Exemplo n.º 3
0
 private void addItemReplacements(long pos, int len, byte[] lse, boolean padded) {
   int newlen = len + (padded ? 14 : 15);
   replacements.add(
       new Replacement(pos - 4, 4, ByteUtils.int2bytesLE((newlen + 1) & ~1, new byte[4], 0)));
   replacements.add(new Replacement(pos + 15, 0, lse));
   boolean newPadded = (newlen & 1) != 0;
   if (newPadded != padded)
     replacements.add(
         newPadded
             ? new Replacement(pos + len, 0, PADDING_BYTE)
             : new Replacement(pos + len - 1, 1, null));
 }