RIFF stands for Resource Interchange File Format. It is a simple format for storing tagged data structures, introduced[1] in 1991 by Microsoft and IBM.
RIFF file consist of building blocks called chunks. Chunk can be described as the following C structure[2]:
struct chunk {
char id[4]; // four character code describing chunk content unsigned long size; // length of the content, excluding id, size and padding char data[size]; // chunk content, padded to the word boundary
};
Chunks having id of either "RIFF" or "LIST" store any number of other chunks.
"RIFF" chunk defines the whole file container. First four bytes of the chunk data form a file type identifier (eg."AVI "[3], "WAVE" etc), after which there are chunks describing the file placed one after another.
"LIST" chunk is just an ordered collection of other chunks, for example a collection of movie frames. First four bytes of the data is a collection identifier (eg."movi" for frame data etc), after which chunks of the collection follow.
For description of other chunk types please refer to the following Microsoft's documents:
- Resource Interchange File Format Services
- RIFF AVI file reference
- Reading WAVE files
- DirectMusic file format
- Multimedia Registration Kit
Footnotes:
- RIFF format is almost identical to IFF file format introduced earlier by Electronic Arts, and very popular mostly among Amiga users.
- All data in a RIFF file is in little-endian notation, thus simply dumping this structure to disk will not work on big-endian machines.
- Less than four character identifiers are padded with spaces.