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.