We just moved to a different server. Please be patient until all files and pages are restored and the MediaWiki software has been updated. Thank you

.IFF

From REWiki
Jump to: navigation, search


This is a very versatile format which was originally designed by Electronic Arts. It can store almost every kind of data, like images, audio, animations, MIDI and more. Lots of descriptions can be found on the Web, so this is only a small overview. It mainly focuses on the formats of the lesser known chunks.

Contents

General structure

An .IFF file consists of one or more so-called chunks.

struct IFFChunkHeader
{
  uint32  ID;      // 4 upper case ASCII chars, padded with 0x20 (space)
  uint32  length;  // big-endian
}

Each chunk starts with a 4-byte ID, which is an 4-char ASCII string padded with spaces if needed. Directly after that comes the chunk length, and then the chunk-specific data. Notice that, since this format comes from the Amiga, which has a Motorola 68000 CPU, the chunk size is a big-endian field, i.e. it must be byteswapped before it can be used on x86. Also, each chunk must start on an even address, use padding if neccessary. This implies that if a chunk's length field is odd, you have to treat it as being +1 larger (however, the data in this padding byte should be ignored)

There are three special chunk types which themselves contain one or more other chunks. These so-called group chunks are explained in the next section.

Known IFF file formats

Some of the better known IFF file formats are:

  • ILBM bitmap (file extension LBM or IFF)
+-----------------+
| FORM.ILBM       |
+-----------------+
| +-------------+ |
| | BMHD        | |
| +-------------+ |
| +-------------+ |
| | CMAP (opt.) | |
| +-------------+ |
| +-------------+ |
| | BODY        | |
| +-------------+ |
+-----------------+
  • PBM bitmap (file extension LBM or IFF)
+-----------------+
| FORM.PBM        |
+-----------------+
| +-------------+ |
| | BMHD        | |
| +-------------+ |
| +-------------+ |
| | CMAP (opt.) | |
| +-------------+ |
| +-------------+ |
| | BODY        | |
| +-------------+ |
+-----------------+
  • XMidi file (file extension XMI)
+--------------------+
| FORM.XDIR          |
+--------------------+
| +----------------+ |
| | INFO           | |
| +----------------+ |
| +----------------+ |
| | CAT.XMID       | |
| +----------------+ |
| | +------------+ | |
| | | FORM.XMID  | | |
| | +------------+ | |
| | | +--------+ | | |
| | | |TIMB    | | | |
| | | +--------+ | | |
| | | +--------+ | | |
| | | |EVNT    | | | |
| | | +--------+ | | |
| | +------------+ | |
| | +------------+ | |
| | | FORM.XMID  | | |
| | +------------+ | |
| | | ...        | | |
| | +------------+ | |
| +----------------+ |
+--------------------+

(i.e. there's only one CAT.XMID in each file, and one FORM.XMID for each MIDI track)

Group chunks

The three group chunks are FORM (records), LIST (property lists) and CAT (simple lists). Each group chunk has a type ID' directly after it's chunk header:

struct GroupChunkHeader
{
  uint32  ID;        // 4 byte ASCII string, either 'FORM', 'CAT ' or 'LIST'
  uint32  length;
  uint32  type;      // 4 byte ASCII string
}

FORM

The FORM chunk is like a record, a well-defined collection of other chunks. It's chunk header is followed by another 4-byte ID which describes the record type. After that comes the first sub-chunk.

Known FORM record types are

  • ILBM: Interleaved bitmap, normally consists of BMHD, CMAP and BODY chunks
  • PBM: Planar bitmap, normally consists of BMHD, CMAP and BODY chunks
  • XDIR: XMidi directory, contains only a single INFO chunk. Normally directly followed by a CAT.XMID chunk.
  • XMID: XMidi track data, contains TIMB, EVNT subchunks
  • AIFF: Audio data, AIFF format

LIST

(Haven't seen that one yet)

CAT

The CAT chunk (more appropriately: the 'CAT ' chunk) is a simple concatenation of chunks. Known CAT types are:

  • XMID: A CAT.XMID chunk contains XMIDI data. Normally contains one FORM.XMID subchunk for each track

Chunk descriptions

Here are some descriptions of various chunk types.

CMAP

Found in: FORM.ILBM, FORM.PBM

This is simply a list of RGB values for a color indexed image. It is used in FORM.ILBM (and FORM.PBM?) chunks.

struct CMAPChunk
{
  uint32 ID;      // == 'CMAP'
  uint32 length;
  struct {
    uint8 r;
    uint8 g;
    uint8 b;
  } rgb[];  
}

remember that this chunk should be padded if it doesn't fit into an even number of bytes.

BMHD

Found in: FORM.ILBM, FORM.PBM

This chunk type describes the properties of a bitmapped (FORM.ILBM and FORM.PBM) image. It has the following structure.

struct BMHDChunk
{
  uint32 ID;         // == 'BMHD'
  uint32 length;     // == 0x14
  uint16 width;      // image size
  uint16 height;
  uint16 xOrigin;    // image position on screen
  uint16 yOrigin;
  uint8  numPlanes;  // number of planes the image has
  uint8  mask;
  uint8  compression;
  uint8  padding;    // =0, used for padding
  uint16 transp;
  uint16 aspect;     // 2 bytes describing the aspect ratio of the image
  uint16 pageWidth;  // width of the page, normally same as .width
  uint16 pageHeight;
};

Still unknown are the mask and transp fields. The compression field should be 0 for uncompressed images.

BODY

Found in: FORM.ILBM, FORM.PBM

The actual pixel data for images

TIMB

Found in: FORM.XMID

This contains the XMidi timbre data for XMI files

EVNT

Found in: FORM.XMID

This is an event chunk used in XMidi files. It's purpose is currently unknown

INFO

Found in: FORM.XDIR

This chunk contains the number of tracks for an XMidi file.

struct INFOChunk
{
  uint32 ID;     // == 'INFO'
  uint32 length; // == 2, normally (other values not yet encountered)
  uint16 numTracks;
}

The numTracks field contains the number of MIDI tracks in this file as a big-endian number. Each track is represented by it's own FORM.XMID chunk inside the CAT.XMID.

Personal tools