| |
| |  |  |  | |  |
status of this document: work in progress
|
Table of Contents
Last updated: Jan 14. 1998
|
Basic
Description
RIFFs are capable of holding various types
of data. The file extension for RIFFs is dependent on its content.
Examples are:
-
ANI for animated cursors
-
AVI for videos
-
BND file bundles
-
DXR Macromedia Director Files (notice: Network byte order!)
-
PAL for color palette information
-
RDI for bitmaps
-
RMI for MIDI
-
WAV for digital audio
|
Basic
File Format
The price for the flexibility of holding different
types of data is a file structure, that isn't easy to understand. A RIFF
is - more or less - a hierarchical structure. The 'directory entries' are
defined by chunks. Every chunk contains either data or a list of
chunks. This document will occasionally refer to the analogy of a file
system, every chunk is either a file or a subdirectory. All chunks have
the same structure:
| Name |
Size |
Description |
| ID |
4 byte |
four ASCII character identifier, padded
with ASCII 32 (space) if less than 4 characters |
| Size |
4 byte |
size of Data |
| Data |
Size bytes |
the 'payload' |
| unused |
1 byte |
present, if size is odd |
|
Structure of the
'RIFF', 'RIFX', and 'LIST' chunks
The first chunk is the root entry and must
have a ID of 'RIFF'
or 'RIFX', the prior being
the most common version. 'RIFX'
specifies 'Motorola' byte order (most significant byte first), whereas
'RIFF' specifies 'Intel' byte
ordering (least significant byte first). This document will stick to 'RIFF'.
That first chunk contains all other chunks of the file in its Data.
Its Size field will therefore always contain a value of filesize
- 8.
The structure of Data is dependent
on its ID. There are two directory- IDs, 'RIFF'
and 'LIST'. They contain a
4-byte ASCII header, leaving the following structure:
| Name |
Size |
Description |
| ID |
4 byte |
four ASCII character identifier |
| Size |
4 byte |
size of Data |
| Data |
Size bytes |
the 'payload' |
| |
HeaderID |
4 bytes |
'Name' of the list |
| Data |
Size - 4 bytes |
List of chunks |
There will never be a final extra byte, since
the Size will always be even. The HeaderID in the RIFF chunk usually
matches the file's extension. |
Structure of the
'JUNK' chunk
To align RIFF chunks to certain boundaries
(i.e. 2048bytes for CD-ROMs) the RIFF specification includes a JUNK chunk.
Its contents are to be skipped when reading. When writing RIFFs, JUNK chunks
should not have odd number as Size.
| Name |
Size |
Description |
| ID |
4 byte |
four ASCII character identifier 'JUNK' |
| Size |
4 byte |
size of Data |
| Data |
Size bytes |
nothing |
| unused |
1 byte |
present if Size is odd |
|
The 'INFO' List
RIFF files may include a 'LIST' chunk with
a HeaderID of 'INFO'. All chunks listed in this 'directory' should be pure
ASCII chunks, and give various information on the file.
| Name |
Description |
| IART |
artist |
| ICOP |
copyright |
| INAM |
name |
|
Knowing these structures, one can implement
a program that produces a hierarchical list of the file's contents. The
DaubNet
RIFF Viewer does this. A simple RIFF could look like this:
| RIFF |
first chunk, the 'root directory' |
| |
data |
some data |
| JUNK |
some padding to align the next chunk |
| LIST |
a list of chunks 'subdirectory' |
| |
data |
a 'file' in the list |
| data |
another 'file' |
| data |
another 'file' in the 'root directory' |
That's all for generic RIFFs. All other chunks
are part of a special file type. For an interpretation these look at the
page with their corresponding file type. |
Portability
RIFFs were designed with mainly one target
platform in mind: MS-Windows. The existence of huge numbers of RIFF files
(i.e. WAV Collections) made it necessary to read them on other platforms.
The RIFX was included in the RIFF specs to for portability purposes, but
many RIFF decoders are not capable
of reading those files (DaubNet RIFF Viewer V1.3 now can!)
, so it may be wise for RIFF encoders to stick to
that byte order, even on systems with Motorola byte order. |
Trademarks,
Patents and Royalties
To my knowledge: none.
Note that the format of certain chunks
contained in RIFFs may very well be patented.
(please read the disclaimer) |
Cross-Checking
Software
This section is for programmers, who wish
to cross-check their implementation with others. This is an incomplete
list of programs, which are available as freeware / shareware / try-before-buy
etc.
The following software is able to decode
RIFFs:
-
DaubNet RIFF Viewer for Win95: Download
(freeware)
The is no generic RIFF encoder. Look at the
more specific file types for encoders. |
Online
Resources
O'Rielly: Encyclopedia of Graphics File Formats. |
Paper
Resources
|
|  | |  |  | |
|
| |
Disclaimer
| |  |  |  | |  |
This is not the official format documentation.
Although we're doing our best to keep this information as accurate as possible,
there is no way of checking all of it under all possible circumstances.
We're not taking any responsibility for the results of this information
or lack thereof. The 'trademarks, patents and royalties' section is here
just for your convenience, and is in no way complete. Please send us a
note, if you find any incorrect of missing information to fileformats@daubnet.com.
|  | |  |  | |
|