home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / FLI_FLC.TXT < prev    next >
Internet Message Format  |  1995-10-13  |  11KB

  1. From mike@htsmm1.Las-Vegas.NV.US Mon Sep 28 09:04:14 1992
  2. From: mike@htsmm1.Las-Vegas.NV.US (Mike Haaland)
  3. Newsgroups: comp.graphics.animation
  4. Subject: Re: FLI format request
  5. Summary: FLI animation format
  6. Keywords: FLI format
  7. Date: 26 Sep 92 07:05:50 GMT
  8. Organization: HyperTech Software
  9.  
  10. ] terjeve@ifi.uio.no (Terje Vernly) asks:
  11. ]
  12. ] BTW. Has anyone got a description of the FLI-format?
  13.  
  14. Here you go.
  15.  
  16. -----------------------------------------------------------------------
  17.  
  18. Flic Files (.FLI) Format description:
  19.  
  20.      The details of a FLI file are moderately complex, but the
  21. idea behind it is simple: don't bother storing the parts of a
  22. frame that are the same as the last frame.  Not only does this
  23. save space, but it's very quick.  It's faster to leave a pixel
  24. alone than to set it.
  25.  
  26.      A FLI file has a 128-byte header followed by a sequence of
  27. frames. The first frame is compressed using a bytewise run-length
  28. compression scheme.  Subsequent frames are stored as the
  29. difference from the previous frame.  (Occasionally the first
  30. frame and/or subsequent frames are uncompressed.)  There is one
  31. extra frame at the end of a FLI which contains the difference
  32. between the last frame and the first frame.
  33.  
  34.      The FLI header:
  35.  
  36.      byte size name      meaning
  37.      offset
  38.  
  39.      0    4    size      Length of file, for programs that want
  40.                          to read the FLI all at once if possible.
  41.      4    2    magic     Set to hex AF11.  Please use another
  42.                          value here if you change format (even to
  43.                          a different resolution) so Autodesk
  44.                          Animator won't crash trying to read it.
  45.      6    2    frames    Number of frames in FLI.  FLI files have
  46.                          a maxium length of 4000 frames.
  47.      8    2    width     Screen width (320).
  48.      10   2    height    Screen height (200).
  49.      12   2    depth     Depth of a pixel (8).
  50.      14   2    flags     Must be 0.
  51.      16   2    speed     Number of video ticks between frames.
  52.      18   4    next      Set to 0.
  53.      22   4    frit      Set to 0.
  54.      26   102  expand    All zeroes -- for future enhancement.
  55.  
  56.      Next are the frames, each of which has a header:
  57.  
  58.      byte size name      meaning
  59.      offset
  60.      0    4    size      Bytes in this frame.  Autodesk Animator
  61.                          demands that this be less than 64K.
  62.      4    2    magic     Always hexadecimal F1FA
  63.      6    2    chunks    Number of 'chunks' in frame.
  64.      8    8    expand    Space for future enhancements.  All
  65.                          zeros.
  66.  
  67.      After the frame header come the chunks that make up the
  68. frame.  First comes a color chunk if the color map has changed
  69. >from the last frame.  Then comes a pixel chunk if the pixels have
  70. changed.  If the frame is absolutely identical to the last frame
  71. there will be no chunks at all.
  72.  
  73.      A chunk itself has a header, followed by the data.  The
  74. chunk header is:
  75.  
  76.      byte size name meaning
  77.      offset
  78.      0    4    size Bytes in this chunk.
  79.      4    2    type Type of chunk (see below).
  80.  
  81.      There are currently five types of chunks you'll see in a FLI
  82. file.
  83.  
  84.      number    name      meaning
  85.      11        FLI_COLOR Compressed color map
  86.      12        FLI_LC    Line compressed -- the most common type
  87.                          of compression for any but the first
  88.                          frame.  Describes the pixel difference
  89.                          from the previous frame.
  90.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  91.                          on the first frame).
  92.      15        FLI_BRUN  Bytewise run-length compression -- first
  93.                          frame only
  94.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  95.                          to follow.  For those times when
  96.                          compression just doesn't work!
  97.  
  98.      The compression schemes are all byte-oriented.  If the
  99. compressed data ends up being an odd length a single pad byte is
  100. inserted so that the FLI_COPY's always start at an even address
  101. for faster DMA.
  102.  
  103. FLI_COLOR Chunks
  104.      The first word is the number of packets in this chunk. This
  105. is followed directly by the packets.  The first byte of a packet
  106. says how many colors to skip.  The next byte says how many colors
  107. to change.  If this byte is zero it is interpreted to mean 256. 
  108. Next follows 3 bytes for each color to change (one each for red,
  109. green and blue).
  110.  
  111. FLI_LC Chunks
  112.      This is the most common, and alas, most complex chunk.   The
  113. first word (16 bits) is the number of lines starting from the top
  114. of the screen that are the same as the previous frame. (For
  115. example, if there is motion only on the bottom line of screen
  116. you'd have a 199 here.)  The next word is the number of lines
  117. that do change.  Next there is the data for the changing lines
  118. themselves.  Each line is compressed individually; among other
  119. things this makes it much easier to play back the FLI at a
  120. reduced size.
  121.  
  122.      The first byte of a compressed line is the number of packets
  123. in this line.  If the line is unchanged from the last frame this 
  124. is zero.  The format of an individual packet is:
  125.  
  126. skip_count
  127. size_count
  128. data
  129.  
  130.      The skip count is a single byte.  If more than 255 pixels
  131. are to be skipped it must be broken into 2 packets. The size
  132. count is also a byte.  If it is positive, that many bytes of data
  133. follow and are to be copied to the screen.  If it's negative a
  134. single byte follows, and is repeated -skip_count times.
  135.  
  136.      In the worst case a FLI_LC frame can be about 70K.  If it
  137. comes out to be 60000 bytes or more Autodesk Animator decides
  138. compression isn't worthwhile and saves the frame as FLI_COPY.
  139.  
  140. FLI_BLACK Chunks
  141.      These are very simple.  There is no data associated with
  142. them at all. In fact they are only generated for the first frame
  143. in Autodesk Animator after the user selects NEW under the FLIC
  144. menu.
  145.  
  146. FLI_BRUN Chunks
  147.      These are much like FLI_LC chunks without the skips.  They
  148. start immediately with the data for the first line, and go line-
  149. by-line from there.  The first byte contains the number of
  150. packets in that line.  The format for a packet is:
  151.  
  152. size_count
  153. data
  154.  
  155.      If size_count is positive the data consists of a single byte
  156. which is repeated size_count times. If size_count is negative
  157. there are -size_count bytes of data which are copied to the
  158. screen. In Autodesk Animator if the "compressed" data shows signs
  159. of exceeding 60000 bytes the frame is stored as FLI_COPY instead.
  160.  
  161. FLI_COPY Chunks
  162.      These are 64000 bytes of data for direct reading onto the
  163. screen.
  164.  
  165. -----------------------------------------------------------------------
  166. And here's the PRO extensions:
  167. -----------------------------------------------------------------------
  168.  
  169. This is supplemental info on the AutoDesk Animator FLI and FLC formats.
  170.  
  171. The following is an attempt at describing the newer chunks and frames
  172. that are not described in the Turbo C FLI library documentation.
  173.  
  174.   Chunk type       Chunk ID 
  175.   ----------       -----------
  176.   FLI_DELTA        7 (decimal)
  177.   
  178.   First WORD (16 bits) is the number of compressed lines to follow.  Next
  179.   is the data for the changing lines themselves, always starting with the
  180.   first line.   Each line is compressed individually.
  181.  
  182.   The first WORD (16 bits) of a compressed line is the number of packets in
  183.   the line.  If the number of packets is a negative skip -packets lines.
  184.   If the number of packets is positive, decode the packets.  The format of
  185.   an individual packet is:
  186.  
  187.   skip_count
  188.   size_count
  189.   data
  190.  
  191.   The skip count is a single byte.  If more than 255 pixels are to be
  192.   skipped, it must be broken into 2 packets.  The size_count is also a byte.
  193.   If it is positive, that many WORDS of data follow and are to be copied to
  194.   the screen.  If it is negative, a single WORDS value follows, and is to be
  195.   repeated -size_count times.
  196.   
  197.   Chunk type       Chunk ID 
  198.   ----------       -----------
  199.   FLI_256_COLOR    4 (decimal)
  200.  
  201.   The first WORD is the number of packets in this chunk.  This is followed
  202.   directly by the packets.  The first byte of a packet is how many colors
  203.   to skip.  The next byte is how many colors to change.  If this number is
  204.   0, (zero), it means 256.  Next follow 3 bytes for each color to change.
  205.   (One each for red, green and blue).
  206.  
  207.   The only difference between a FLI_256_COLOR chunk (type 4 decimal) and a
  208.   FLI_COLOR chunk (type 11 decimal) is that the values in the type 4 chunk
  209.   range from 0 to 255, and the values in a type 11 chunk range from 0 to 63.
  210.  
  211.   NOTE:  WORD  refer to a 16 bit int in INTEL (Little Endian) format.
  212.          WORDS refer to two-bytes (16 bits) of consecutive data. (Big Endian)
  213.  
  214.   .FLC special frames and chunks
  215.  
  216.   FLC's may contain all the above chunks plus one other:
  217.  
  218.   Chunk type       Chunk ID 
  219.   ----------       -----------
  220.   FLI_MINI         18 (decimal) 12 (Hex)
  221.  
  222.   From what I understand,  this is a miniture 64 x 32 version of the first
  223.   frame in FLI_BRUN format, used as an button for selecting flc's from
  224.   within Animator Pro.  Simply do nothing with this chunk.
  225.  
  226.   FLC New Frame
  227.  
  228.   FLC's also contains a frame with the magic bytes set to hex 00A1.  This
  229.   is the first frame in the .flc file.  Actually it isn't a frame at all
  230.   but to have several chunks within it that specify file location info
  231.   specific to Animator Pro.  IE:  filepath, font to use, and .COL file info.
  232.   This FRAME may be skipped while loading.  That's right!  Ignore it!  The
  233.   frame header is the same length as all other frames.  So you may read the
  234.   frame header, then skip past the rest of the frame.
  235.  
  236.  
  237.   NOTE:  When reading the FLI header on the newer FLI and FLC files, the
  238.   FLI signature bytes are AF12 instead of AF11 used in the older FLI files.
  239.   Also, you cannot ignore the screen width and height they may not be
  240.   320 x 200.
  241.  
  242.   Allowable screen sizes include:
  243.  
  244.   320 x 200, 640 x 480, 800 x 600, 1280 x 1024
  245.  
  246.  
  247.   NOTE:  the delay value between frames appears to be in 1000th's of a
  248.   second instead of 70th's.
  249.  
  250. If you have any questions or more info on the FLI or FLC formats,
  251. please let me know.
  252.  
  253. Mike Haaland
  254.  
  255. CompuServe : 72300,1433
  256. Delphi     : MikeHaaland
  257. Internet   : mike@htsmm1.las-vegas.nv.us
  258. Usenet     : ...!htsmm1.las-vegas.nv.us!mike
  259.  
  260. -----------------------------------------------------------------------
  261. Can someone archive this somewhere and can the FAQ writer add a pointer
  262. to it, please.
  263.  
  264. Mike Haaland
  265.  
  266. CompuServe : 72300,1433
  267. Delphi     : MikeHaaland
  268. Internet   : mike@htsmm1.las-vegas.nv.us
  269. Usenet     : ...!htsmm1.las-vegas.nv.us!mike
  270. --
  271.  
  272.