Tuesday, March 24, 2009

QuickTime File Format Specification

Overview of QTFF

QuickTime movies are stored on disk, using two basic structures for storing information: atoms (also knownas simple atoms or classic atoms), and QT atoms. To understand how QuickTime movies are stored, you needto understand the basic atom structures described in this chapter. Most atoms you encounter in the QuickTimeFile Format are simple or classic atoms. Both simple atoms and QT atoms, however, allow you to constructarbitrarily complex hierarchical data structures. Both also allow your application to ignore data they don’tunderstand.

Metadata

A QuickTime file stores the description of its media separately from the media data. The description, ormetadata, is called the movie resource, movie atom, or simply the movie, and contains information such asthe number of tracks, the video compression format, and timing information. The movie resource also containsan index describing where all the media data is stored.

The media data is the actual sample data, such as video frames and audio samples, used in the movie. Themedia data may be stored in the same file as the QuickTime movie, in a separate file, in multiple files, inalternate sources such as databases or real-time streams, or in some combination of these.

Atoms

The basic data unit in a QuickTime file is the atom. Each atom contains size and type fields that precede anyother data. The size field indicates the total number of bytes in the atom, including the size and type fields.The type field specifies the type of data stored in the atom and, by implication, the format of that data. Insome cases, the size and type fields are followed by a version field and a flags field. An atom with theseversion and flags fields is sometimes called a full atom.

Atom types are specified by a 32-bit unsigned integer, typically interpreted as a four-character ASCII code.Apple, Inc. reserves all four-character codes consisting entirely of lowercase letters. Unless otherwise stated,all data in a QuickTime movie is stored in big-endian byte ordering, also known as network byte ordering,in which the most significant bytes are stored and transmitted first.

Atoms are hierarchical in nature. That is, one atom can contain other atoms, which can contain still others,and so on. This hierarchy is sometimes described in terms of a parent, children, siblings, grandchildren, andso on. An atom that contains other atoms is called a container atom. The parent atom is the container atomexactly one level above a given atom in the heirarchy.

For example, a movie atom contains several different kinds of atoms, including one track atom for each trackin the movie. The track atoms, in turn, contain one media atom each, along with other atoms that defineother track characteristics. The movie atom is the parent atom of the track atoms. The track atoms are siblings.The track atoms are parent atoms of the media atoms. The movie atom is not the parent of the media atoms,because it is more than one layer above them in the hierarchy.

An atom that does not contain other atoms is called a leaf atom, and typically contains data as one or morefields or tables. Some leaf atoms act as flags or placeholders, however, and contain no data beyond their sizeand type fields.

The format of the data stored within a given atom cannot always be determined by the type field of theatom alone; the type of the parent atom may also be significant. In other words, a given atom type cancontain different kinds of information depending on its parent atom. For example, the profile atom inside amovie atom contains information about the movie, while the profile atom inside a track atom containsinformation about the track. This means that all QuickTime file readers must take into consideration not onlythe atom type, but also the atom’s containment hierarchy.

No comments:

Post a Comment