Resource Interchange File Format: Difference between revisions

Content deleted Content added
on AVI and WAV
Kyz (talk | contribs)
Spruce of article, note that RIFF is basically IFF saves much repetition.
Line 1:
The '''RIFF''' stands for ''Resource Interchange File Format''.' It('''RIFF''') is a simplegeneric meta-format for storing data in tagged datachunks. structures,It was introduced[1] in [[1991]] by [[Microsoft]] and [[International Business Machines|IBM]]. TheIt Microsoftis implementationa isclone mostlyof known[[Electronic throughArts]]'s the[[IFF|IFF file formatsformat]], knownintroducted asin [[AVI1985]], (Audiothe Videoonly Interleaved)difference andbeing that multi-byte integers are in [[WAVendianness|little-endian]] (Waveformformat, Audionative Format)to whichthe are[[80x86]] bothprocessor basicallyseries RIFFused in IBM PCs, rather than the big-endian format native to the [[680x0]] processor series used in [[Amiga]] and [[Apple Macintosh]] computers, where IFF files were heavily used.
 
The Microsoft implementation is mostly known through file formats like [[AVI]] and [[WAV]], which both use the RIFF meta-format as their basis.
'''RIFF''' file consist of building blocks called ''chunks''. Chunk can be described as the following [[C_language|C]] structure[2]:
 
RIFF files consist of a simple header followed by "chunks". The format is identical to IFF, except for the endianness as previously stated.
struct chunk {
* Header
char id[4]; // four character code describing chunk content
** 4 bytes: The ASCII identifier "RIFF".
unsigned long size; // length of the content, excluding id, size and padding
** 4 bytes: an unsigned, little-endian 32-bit integer with the length of the overall file (except this field itself and the RIFF identifier).
char data[size]; // chunk content, padded to the word boundary
** 4 bytes: An ASCII identifer for this particular filetype, such as "AVI " or "WAVE".
};
* Chunks follow from here on. Each chunk consists of
** 4 bytes: An ASCII identifier for this chunk, e.g. "fmt " or "data"
** 4 bytes: an unsigned, little-endian 32-bit integer with the length of this hunk (except this field itself and the chunk identifier).
** Variable-sized field: the chunk data itself, of the size given in the previous field.
** A pad byte, if the chunk's length is not even.
 
More information about the format can be found in the [[IFF]] article.
Chunks having id of either <tt>"RIFF"</tt> or <tt>"LIST"</tt> store any number of other chunks.
 
==External links==
<tt>"RIFF"</tt> chunk defines the whole file container. First four bytes of the chunk data form a file type identifier (eg.<tt>"AVI "</tt>[3], <tt>"WAVE"</tt> etc), after which there are chunks describing the file placed one after another.
 
<tt>"LIST"</tt> 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.<tt>"movi"</tt> for frame data etc), after which chunks of the collection follow.
 
To learn more about other chunk types and '''RIFF''' format, please refer to the following Microsoft's documents:
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmio_2uyb.asp Resource Interchange File Format Services]
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/htm/avirifffilereference.asp RIFF AVI file reference]
Line 21 ⟶ 22:
* [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/directx_cpp/htm/_dx_directmusic_file_format_dxaudio.asp DirectMusic file format]
* [http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q120253 Multimedia Registration Kit]
 
''Footnotes:''
# '''RIFF''' format is almost identical to [[IFF|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|little-endian]] notation, thus simply dumping this structure to disk will not work on [[Big-endian|big-endian]] machines.
# Less than four character identifiers are padded with spaces.