AVI文件采用标准的RIFF格式进行封装,在分析AVI文件格式之前我们先简单介绍RIFF格式。
1. RIFF格式简介
资源文件交换格式,Resource Interchange FileFormat(简称RIFF)。是一种按照标记区块存储数据(tagged chunks)的的通用文件存储格式,多用于存储音视频等多媒体数据。Microsoft在Windows下的AVI、ANI、WAV等都是基于RIFF格式的文件封装。
2. RIFF文件结构
RIFF文件结构是标准的树形结构,RIFF结构中包含两种节点:
(1) Leaf节点,该节点为叶子节点,不能包含子节点。
(2) Container节点,该节点可以包含Leaf节点。
Leaf节点的数据结构为:
typedef struct {
DWORD ID; // 4字节,4个可打印ASCII字符,标识类型
DWORD Size; // 4字节,数据块长度
BYTE Data[Size]; // 数据块
}Leaf
Container节点的数据结构为: