A RIFF chunk size is 32 bits, so the plain AVI layout runs out at 4 GB, and many programs
stop at 1 or 2 GB. The OpenDML extensions, published by the OpenDML AVI M-JPEG File Format
Subcommittee and sometimes called AVI 2.0, get round this. The file continues in further
RIFF AVIX sections, each with its own LIST movi, and a two-level
index replaces idx1. Microsoft’s aviriff.h gives the structures;
the OpenDML document itself is a PDF that this reference could not read, so what follows
comes from Microsoft’s pages and the Wine copy of the header file.
Layout of a large file
0RIFF AVI the first sectionunder 4 GB…LIST hdrl withindxin eachstrl, andLIST odmlvaries…LIST movi data andnnixindex chunksvaries…idx1 optional, for old players, covering this section onlyvaries
…RIFF AVIX further sections, each with oneLIST movirepeated
The LIST odml holds a dmlh chunk, Microsoft’s
AVIEXTHEADER. It is taken here from memory of the header file, so treat it as
unconfirmed: a DWORD dwGrandFrames, the true frame count of the whole file,
and 61 reserved DWORDs.
The common index header
All OpenDML indexes share the AVIMETAINDEX start. The chunk ID is
indx, or nnix with nn the stream number.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | FOURCC | fcc | indx or nnix. |
| 4 | 4 | UINT | cb | Size of the structure, not counting these 8 bytes. |
| 8 | 2 | WORD | wLongsPerEntry | Size of each entry in 4-byte units. |
| 10 | 1 | BYTE | bIndexSubType | Meaning depends on bIndexType. |
| 11 | 1 | BYTE | bIndexType | The type; see below. |
| 12 | 4 | DWORD | nEntriesInUse | Number of valid entries. |
| 16 | 4 | DWORD | dwChunkId | What is indexed; for a stream, the same ID as a data chunk, such as 00dc. |
| 20 | 12 | DWORD[3] | dwReserved | Depends on the index type; see the standard index. |
| 32 | varies | adwIndex | The entries. |
| bIndexType | Name | Meaning |
|---|---|---|
0x00 | AVI_INDEX_OF_INDEXES | Each entry points to another index: a super index. bIndexSubType is zero. |
0x01 | AVI_INDEX_OF_CHUNKS | Each entry points to a data chunk: a standard index, or a field index if the subtype is AVI_INDEX_SUB_2FIELD. |
0x02 | AVI_INDEX_OF_TIMED_CHUNKS | A timed index, whose entries add a duration. Named in the header file. |
0x03 | AVI_INDEX_OF_SUB_2FIELD | Named in the header file; its use is not described in the pages read. |
0x80 | AVI_INDEX_IS_DATA | adwIndex holds a table of data, not index entries. |
| bIndexSubType | Name | Meaning |
|---|---|---|
0x00 | AVI_INDEX_SUB_DEFAULT | Frame index. |
0x01 | AVI_INDEX_SUB_2FIELD | Field index. Microsoft notes that DirectShow does not support field indexes. |
Super index
An indx chunk in a strl list. wLongsPerEntry is 4
and bIndexType is AVI_INDEX_OF_INDEXES. Each entry describes
one standard index:
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 8 | DWORDLONG | qwOffset | Offset in bytes from the start of the file to the sub-index. |
| 8 | 4 | DWORD | dwSize | Size of the sub-index in bytes. |
| 12 | 4 | DWORD | dwDuration | Duration the sub-index covers, in stream ticks. |
Standard index
An indx or nnix chunk. wLongsPerEntry
is 2, bIndexSubType is zero and bIndexType is
AVI_INDEX_OF_CHUNKS. The reserved words at offset 20 become
qwBaseOffset (8 bytes), the base of the entries’ offsets, and
dwReserved_3 (4 bytes).
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | DWORD | dwOffset | Added to qwBaseOffset, the offset of the data from the start of the file. |
| 4 | 4 | DWORD | dwSize | The chunk’s size in the low 31 bits. The top bit, AVISTDINDEX_DELTAFRAME (0x80000000), is set on a frame that is not a key frame. |
Field and timed indexes
Both share the standard index header. In AVIFIELDINDEX each entry is
dwOffset, dwSize and dwOffsetField2, the offset of
the second field of the frame. In AVITIMEDINDEX each entry is
dwOffset, dwSize and dwDuration.