Microsoft AVI file format: GraphViz block diagram (.dot) source

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.7

This page hosts a formal specification of Microsoft AVI file format using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

avi.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__avi {
		label="Avi";
		graph[style=dotted];

		avi__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="magic1_pos">0</TD><TD PORT="magic1_size">4</TD><TD>52 49 46 46</TD><TD PORT="magic1_type">magic1</TD></TR>
			<TR><TD PORT="file_size_pos">4</TD><TD PORT="file_size_size">4</TD><TD>u4le</TD><TD PORT="file_size_type">file_size</TD></TR>
			<TR><TD PORT="magic2_pos">8</TD><TD PORT="magic2_size">4</TD><TD>41 56 49 20</TD><TD PORT="magic2_type">magic2</TD></TR>
			<TR><TD PORT="data_pos">12</TD><TD PORT="data_size">(file_size - 4)</TD><TD>Blocks</TD><TD PORT="data_type">data</TD></TR>
		</TABLE>>];
		subgraph cluster__list_body {
			label="Avi::ListBody";
			graph[style=dotted];

			list_body__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="list_type_pos">0</TD><TD PORT="list_type_size">4</TD><TD>u4le→ChunkType</TD><TD PORT="list_type_type">list_type</TD></TR>
				<TR><TD PORT="data_pos">4</TD><TD PORT="data_size">...</TD><TD>Blocks</TD><TD PORT="data_type">data</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__rect {
			label="Avi::Rect";
			graph[style=dotted];

			rect__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="left_pos">0</TD><TD PORT="left_size">2</TD><TD>s2le</TD><TD PORT="left_type">left</TD></TR>
				<TR><TD PORT="top_pos">2</TD><TD PORT="top_size">2</TD><TD>s2le</TD><TD PORT="top_type">top</TD></TR>
				<TR><TD PORT="right_pos">4</TD><TD PORT="right_size">2</TD><TD>s2le</TD><TD PORT="right_type">right</TD></TR>
				<TR><TD PORT="bottom_pos">6</TD><TD PORT="bottom_size">2</TD><TD>s2le</TD><TD PORT="bottom_type">bottom</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__blocks {
			label="Avi::Blocks";
			graph[style=dotted];

			blocks__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="entries_pos">0</TD><TD PORT="entries_size">...</TD><TD>Block</TD><TD PORT="entries_type">entries</TD></TR>
				<TR><TD COLSPAN="4" PORT="entries__repeat">repeat to end of stream</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__avih_body {
			label="Avi::AvihBody";
			graph[style=dotted];

			avih_body__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="micro_sec_per_frame_pos">0</TD><TD PORT="micro_sec_per_frame_size">4</TD><TD>u4le</TD><TD PORT="micro_sec_per_frame_type">micro_sec_per_frame</TD></TR>
				<TR><TD PORT="max_bytes_per_sec_pos">4</TD><TD PORT="max_bytes_per_sec_size">4</TD><TD>u4le</TD><TD PORT="max_bytes_per_sec_type">max_bytes_per_sec</TD></TR>
				<TR><TD PORT="padding_granularity_pos">8</TD><TD PORT="padding_granularity_size">4</TD><TD>u4le</TD><TD PORT="padding_granularity_type">padding_granularity</TD></TR>
				<TR><TD PORT="flags_pos">12</TD><TD PORT="flags_size">4</TD><TD>u4le</TD><TD PORT="flags_type">flags</TD></TR>
				<TR><TD PORT="total_frames_pos">16</TD><TD PORT="total_frames_size">4</TD><TD>u4le</TD><TD PORT="total_frames_type">total_frames</TD></TR>
				<TR><TD PORT="initial_frames_pos">20</TD><TD PORT="initial_frames_size">4</TD><TD>u4le</TD><TD PORT="initial_frames_type">initial_frames</TD></TR>
				<TR><TD PORT="streams_pos">24</TD><TD PORT="streams_size">4</TD><TD>u4le</TD><TD PORT="streams_type">streams</TD></TR>
				<TR><TD PORT="suggested_buffer_size_pos">28</TD><TD PORT="suggested_buffer_size_size">4</TD><TD>u4le</TD><TD PORT="suggested_buffer_size_type">suggested_buffer_size</TD></TR>
				<TR><TD PORT="width_pos">32</TD><TD PORT="width_size">4</TD><TD>u4le</TD><TD PORT="width_type">width</TD></TR>
				<TR><TD PORT="height_pos">36</TD><TD PORT="height_size">4</TD><TD>u4le</TD><TD PORT="height_type">height</TD></TR>
				<TR><TD PORT="reserved_pos">40</TD><TD PORT="reserved_size">16</TD><TD></TD><TD PORT="reserved_type">reserved</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__block {
			label="Avi::Block";
			graph[style=dotted];

			block__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="four_cc_pos">0</TD><TD PORT="four_cc_size">4</TD><TD>u4le→ChunkType</TD><TD PORT="four_cc_type">four_cc</TD></TR>
				<TR><TD PORT="block_size_pos">4</TD><TD PORT="block_size_size">4</TD><TD>u4le</TD><TD PORT="block_size_type">block_size</TD></TR>
				<TR><TD PORT="data_pos">8</TD><TD PORT="data_size">...</TD><TD>switch (four_cc)</TD><TD PORT="data_type">data</TD></TR>
			</TABLE>>];
block__seq_data_switch [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
	<TR><TD BGCOLOR="#F0F2E4">case</TD><TD BGCOLOR="#F0F2E4">type</TD></TR>
	<TR><TD>:chunk_type_list</TD><TD PORT="case0">ListBody</TD></TR>
	<TR><TD>:chunk_type_avih</TD><TD PORT="case1">AvihBody</TD></TR>
	<TR><TD>:chunk_type_strh</TD><TD PORT="case2">StrhBody</TD></TR>
</TABLE>>];
		}
		subgraph cluster__strh_body {
			label="Avi::StrhBody";
			graph[style=dotted];

			strh_body__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="fcc_type_pos">0</TD><TD PORT="fcc_type_size">4</TD><TD>u4le→StreamType</TD><TD PORT="fcc_type_type">fcc_type</TD></TR>
				<TR><TD PORT="fcc_handler_pos">4</TD><TD PORT="fcc_handler_size">4</TD><TD>u4le→HandlerType</TD><TD PORT="fcc_handler_type">fcc_handler</TD></TR>
				<TR><TD PORT="flags_pos">8</TD><TD PORT="flags_size">4</TD><TD>u4le</TD><TD PORT="flags_type">flags</TD></TR>
				<TR><TD PORT="priority_pos">12</TD><TD PORT="priority_size">2</TD><TD>u2le</TD><TD PORT="priority_type">priority</TD></TR>
				<TR><TD PORT="language_pos">14</TD><TD PORT="language_size">2</TD><TD>u2le</TD><TD PORT="language_type">language</TD></TR>
				<TR><TD PORT="initial_frames_pos">16</TD><TD PORT="initial_frames_size">4</TD><TD>u4le</TD><TD PORT="initial_frames_type">initial_frames</TD></TR>
				<TR><TD PORT="scale_pos">20</TD><TD PORT="scale_size">4</TD><TD>u4le</TD><TD PORT="scale_type">scale</TD></TR>
				<TR><TD PORT="rate_pos">24</TD><TD PORT="rate_size">4</TD><TD>u4le</TD><TD PORT="rate_type">rate</TD></TR>
				<TR><TD PORT="start_pos">28</TD><TD PORT="start_size">4</TD><TD>u4le</TD><TD PORT="start_type">start</TD></TR>
				<TR><TD PORT="length_pos">32</TD><TD PORT="length_size">4</TD><TD>u4le</TD><TD PORT="length_type">length</TD></TR>
				<TR><TD PORT="suggested_buffer_size_pos">36</TD><TD PORT="suggested_buffer_size_size">4</TD><TD>u4le</TD><TD PORT="suggested_buffer_size_type">suggested_buffer_size</TD></TR>
				<TR><TD PORT="quality_pos">40</TD><TD PORT="quality_size">4</TD><TD>u4le</TD><TD PORT="quality_type">quality</TD></TR>
				<TR><TD PORT="sample_size_pos">44</TD><TD PORT="sample_size_size">4</TD><TD>u4le</TD><TD PORT="sample_size_type">sample_size</TD></TR>
				<TR><TD PORT="frame_pos">48</TD><TD PORT="frame_size">8</TD><TD>Rect</TD><TD PORT="frame_type">frame</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__strf_body {
			label="Avi::StrfBody";
			graph[style=dotted];

			strf_body__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			</TABLE>>];
		}
	}
	avi__seq:file_size_type -> avi__seq:data_size [color="#404040"];
	avi__seq:data_type -> blocks__seq [style=bold];
	list_body__seq:data_type -> blocks__seq [style=bold];
	blocks__seq:entries_type -> block__seq [style=bold];
	block__seq:data_type -> block__seq_data_switch [style=bold];
	block__seq_data_switch:case0 -> list_body__seq [style=bold];
	block__seq_data_switch:case1 -> avih_body__seq [style=bold];
	block__seq_data_switch:case2 -> strh_body__seq [style=bold];
	block__seq:four_cc_type -> block__seq:data_type [color="#404040"];
	strh_body__seq:frame_type -> rect__seq [style=bold];
}