Class ANIMKeyFrame

java.lang.Object
org.monte.media.anim.ANIMFrame
org.monte.media.anim.ANIMKeyFrame

public class ANIMKeyFrame extends ANIMFrame
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
  • Field Details

    • VDAT_ID

      protected static final int VDAT_ID
  • Constructor Details

    • ANIMKeyFrame

      public ANIMKeyFrame()
  • Method Details

    • setData

      public void setData(byte[] data)
      Overrides:
      setData in class ANIMFrame
    • setCompression

      public void setCompression(int compression)
      For possible values see ANIMMovieResources.
    • decode

      public void decode(AmigaBitmapImage bitmap, ANIMMovieResources track)
      Specified by:
      decode in class ANIMFrame
    • unpackByteRun1

      public static int unpackByteRun1(byte[] in, byte[] out)
      ByteRun1 run decoder.

      The run encoding scheme by byteRun1 is best described by pseudo code for the decoder Unpacker (called UnPackBits in the Macintosh toolbox.

       UnPacker:
        LOOP until produced the desired number of bytes
            Read the next source byte into n
            SELECT n FROM
                [0..127] => copy the next n+1 bytes literally
                [-1..-127] => replicate the next byte -n+1 times
                -128    => no operation
            ENDCASE;
         ENDLOOP;
       
    • unpackVertical

      public void unpackVertical(byte[] in, AmigaBitmapImage bm)
      Vertical run decoder.

      Each plane is stored in a separate VDAT chunk.

      A VDAT chunk consists of an id, a length, and a body.

       struct {
          uint16 id;  // The 4 ASCII characters "VDAT"
          uint16 length,
          byte[length] body
       }
       
      The body consists of a command list and a data list.
       struct {
          uint16         cnt;        // Command count + 2
          uint8[cnt - 2] cmd;        // The commands
          uint16[]       data;       // Data words
       }
       
      Pseudo code for the unpacker:
       UnPacker:
        Read cnt;
        LOOP cnt - 2 TIMES
            Read the next command byte into cmd
            SELECT cmd FROM
                0 =>
                        Read the next data word into n
                        Copy the next n data words literally
                1    =>
                        Read the next data word into n
                        Replicate the next data word n times
                [2..127] =>
                        Replicate the next data word cmd times
                [-1..-128] =>
                        Copy the next -cmd data words literally
            ENDCASE;
            IF end of data reached THEN EXIT END;
         ENDLOOP;