QTFF
QTFF
QTFF
Specification
Contents
Overview of QTFF 20
Media Description 20
Atoms 20
Atom Layout 22
Atom Structure 22
QT Atoms and Atom Containers 24
QT Atom Containers 27
QuickTime Movie Files 30
The File Type Compatibility Atom 33
Free Space Atoms 35
Movie Data Atoms 35
Preview Atoms 35
Movie Atoms 37
Overview of Movie Atoms 38
The Movie Atom 40
The Movie Profile Atom 42
Movie Header Atoms 43
Color Table Atoms 46
User Data Atoms 47
Track Atoms 55
Track Profile Atom 57
Track Header Atoms 57
Track Exclude From Autoselection Atoms 61
Track Aperture Mode Dimension Atoms 61
Clipping Atoms 66
Clipping Region Atoms 67
Contents
Contents
Metadata 128
Overview 128
Data Type 128
Meaning or Purpose 128
Data Location 129
Localization 129
Storage Location in a QuickTime File 129
Metadata Structure 129
Metadata Atom 129
Metadata Handler Atom 130
Metadata Header Atom 131
Extensibility 132
Localization List Sets 132
Country List Atom 133
Language List Atom 134
Metadata Item Keys Atom 135
Metadata Item List Atom 137
Metadata Item Atom 138
Value Atom 139
Type Indicator 139
Locale Indicator 139
Item Information Atom (ID and flags) 141
Name 141
Data Atom Structure 142
Data Ordering 142
Well-Known Types 143
Location Metadata 145
QuickTime Metadata Keys 145
Direction Definition 154
Contents
Contents
Contents
VR Media 279
VR World Atom Container 280
Node Parent Atom 285
Node Location Atom Structure 285
Custom Cursor Atoms 286
Node Information Atom Container 287
Node Header Atom Structure 288
Hot Spot Parent Atom 289
Hot Spot Information Atom 290
Specific Information Atoms 292
Link Hot Spot Atom 292
URL Hot Spot Atom 295
Support for Wired Actions 295
QuickTime VR File Format 296
Single-Node Panoramic Movies 297
Single-Node Object Movies 298
Multinode Movies 299
QTVR Track 300
QuickTime VR Sample Description Structure 300
Panorama Tracks 301
Panorama Sample Atom Structure 301
Panorama Image Track 305
Cylindrical Panoramas 307
Cubic Panoramas 308
Image Tracks in Cubic Nodes 309
Panorama Tracks in Cubic Nodes 309
Nonstandard Cubes 311
Hot Spot Image Tracks 312
Low-Resolution Image Tracks 313
Track Reference Entry Structure 313
Object Tracks 314
Object Sample Atom Structure 314
Track References for Object Tracks 321
Movie Media 322
Movie Sample Description 322
Movie Media Sample Format 322
Contents
Contents
Contents
10
Overview of QTFF 20
Figure 1-1
Figure 1-2
Figure 1-3
Figure 1-4
Figure 1-5
Figure 1-6
Figure 1-7
Table 1-1
A sample atom 22
Calculating atom sizes 24
QT atom layout 26
QT atom container with parent and child atoms 28
A QT atom container with two child atoms 29
The structure of a QuickTime movie file 32
The layout of a preview atom 35
Basic atom types of a QuickTime file 32
Movie Atoms 37
Figure 2-1
Figure 2-2
Figure 2-3
Figure 2-4
Figure 2-5
Figure 2-6
Figure 2-7
Figure 2-8
Figure 2-9
Figure 2-10
Figure 2-11
Figure 2-12
Figure 2-13
Figure 2-14
Figure 2-15
Figure 2-16
Figure 2-17
Figure 2-18
Figure 2-19
Figure 2-20
Figure 2-21
Figure 2-22
Figure 2-23
11
Figure 2-24
Figure 2-25
Figure 2-26
Figure 2-27
Figure 2-28
Figure 2-29
Figure 2-30
Figure 2-31
Figure 2-32
Figure 2-33
Figure 2-34
Figure 2-35
Figure 2-36
Figure 2-37
Figure 2-38
Figure 2-39
Figure 2-40
Figure 2-41
Figure 2-42
Figure 2-43
Figure 2-44
Figure 2-45
Figure 2-46
Figure 2-47
Figure 2-48
Figure 2-49
Figure 2-50
Figure 2-51
Figure 2-52
Figure 2-53
Figure 2-54
Figure 2-55
Figure 2-56
Table 2-1
Table 2-2
Table 2-3
Table 2-4
Table 2-5
12
Metadata 128
Figure 3-1
Figure 3-2
Figure 3-3
Figure 3-4
Table 3-1
Table 3-2
Table 3-3
Table 3-4
Table 3-5
Table 3-6
Table 3-7
13
Figure 4-26
Figure 4-27
Figure 4-28
Figure 4-29
Figure 4-30
Figure 4-31
Table 4-1
Table 4-2
Table 4-3
Table 4-4
Table 4-5
Table 4-6
Table 4-7
Table 4-8
Table 4-9
Table 4-10
Table 4-11
Table 4-12
Table 4-13
Table 4-14
Table 4-15
Table 4-16
Table 4-17
Table 4-18
Table 4-19
Table 4-20
Table 4-21
Table 4-22
Table 4-23
Table 4-24
Table 4-25
Table 4-26
Table 4-27
Table 4-28
Listing 4-1
14
Figure 5-2
Table 5-1
Table 5-2
Table 5-3
15
16
The QuickTime File Format (QTFF) is designed to accommodate the many kinds of data that need to be stored
in order to work with digital multimedia. The QTFF is an ideal format for the exchange of digital media between
devices, applications, and operating systems, because it can be used to describe almost any media structure.
The file format is object-oriented, consisting of a flexible collection of objects that is easily parsed and easily
expanded. Unknown objects can simply be ignored or skipped, allowing considerable forward compatibility
as new object types are introduced.
QuickTime itself provides a number of high-level functions that you can use to create and manipulate QuickTime
files, without requiring you to understand the actual file format. These functions serve to insulate developers
from the low-level details of operation. That said, not all kinds of QuickTime files can be created without the
information presented here.
Important: The QuickTime File Format has been used as the basis of the MPEG-4 standard and the
JPEG-2000 standard, developed by the International Organization for Standardization (ISO). Although these
file types have similar structures and contain many functionally identical elements, they are distinct file
types.
Warning: Do not use this specification to interpret a file that conforms to a different specification,
however similar.
The QuickTime File Format Specification assumes that you are familiar with the basic concepts of digital video
and audio, as well as with programming QuickTime and the QuickTime API. Note that this version of the
document supersedes all previous versions of the QuickTime File Format Specification .
17
QuickTime files are described in general, rather than how they are supported on a specific computing platform
or in a specific programming language. As a result, the file format information is presented in a tabular manner,
rather than in coded data structures. Similarly, field names are presented in English rather than as programming
language tags. Furthermore, to the extent possible, data types are described generically. For example, this
book uses 32-bit signed integer rather than long to define a 32-bit integer value.
QuickTime files are used to store QuickTime movies, as well as other data. If you are writing an application that
parses QuickTime files, you should recognize that there may be non-movie data in the files.
QuickTime is a rich technology that continues to evolve as new practices and needs arise in audio/visual media.
Because of this, certain elements of QuickTime technology may become deprecated over time. In order to
preserve sufficient information about these legacy components for existing QuickTime files that include them,
deprecated elements are marked with a note at the top of their section in this revision of the QuickTime File
Format Specification .
Licensing Information
The QuickTime File Format Specification is provided for informational purposes. Apple may have patents, patent
applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this
document. The furnishing of this document does not give you a license to any patents, trademarks, copyrights,
or other intellectual property.
Important: For more information about licensing the QuickTime File Format, contact: Apple, Inc., Software
Licensing Department, 12545 Riata Vista Circle, MS 198 3-SWL, Austin, TX 78727. Email Address:
sw.license@apple.com
Special Fonts
All code listings, reserved words, and the names of actual data structures, constants, fields, parameters, and
routines are shown in code voice.
Words that appear in boldface are key terms or concepts and are defined in the Glossary (page 444).
18
19
Overview of QTFF
QuickTime movies are stored on disk, using two basic structures for storing information: atoms (also known
as simple atoms or classic atoms) and QT atoms. To understand how QuickTime movies are stored, you need
to understand the basic atom structures described in this chapter. Most atoms that you encounter in the
QuickTime File Format are simple or classic atoms. Both simple atoms and QT atoms, however, allow you to
construct arbitrarily complex hierarchical data structures. Both also allow your application to ignore data that
they dont understand.
Media Description
A QuickTime file stores the description of its media separately from the media data.
The description is called the movie resource, movie atom, or simply the movie, and contains information such
as the number of tracks, the video compression format, and timing information. The movie resource also
contains an 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. The
media data may be stored in the same file as the QuickTime movie, in a separate file, in multiple files, in alternate
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 any
other 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. In some
cases, the size and type fields are followed by a version field and a flags field. An atom with these version and
flags fields is sometimes called a full atom.
20
Overview of QTFF
Atoms
Note: An atom, as described in this document, is functionally identical to a box, as described in the
ISO specifications for MPEG-4 and Motion JPEG-2000. An atom that includes version and flags fields
is functionally identical to a full box as defined in those specifications.
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, and so on.
An atom that contains other atoms is called a container atom. The parent atom is the container atom exactly
one level above a given atom in the hierarchy.
For example, a movie atom contains several different kinds of atoms, including one track atom for each track
in the movie. The track atoms, in turn, contain one media atom each, along with other atoms that define other
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 more
fields or tables. Some leaf atoms act as flags or placeholders, however, and contain no data beyond their size
and type fields.
The format of the data stored within a given atom cannot always be determined by the type field of the atom
alone; the type of the parent atom may also be significant. In other words, a given atom type can contain
different kinds of information depending on its parent atom. For example, the profile atom inside a movie
atom contains information about the movie, while the profile atom inside a track atom contains information
about the track. This means that all QuickTime file readers must take into consideration not only the atom
type, but also the atoms containment hierarchy.
21
Overview of QTFF
Atoms
Atom Layout
Figure 1-1 (page 22) shows the layout of a sample atom. Each atom carries its own size and type information
as well as its data. Throughout this document, the name of a container atom (an atom that contains other
atoms, including other container atoms) is printed in a gray box, and the name of a leaf atom (an atom that
contains no other atoms) is printed in a white box. Leaf atoms contain data, usually in the form of tables.
Figure 1-1
A sample atom
Container atom
Atom size
Atom type
Container atom
Atom size
Atom type
Leaf atom
Atom size
Atom type
Atom data
.
.
.
A leaf atom, as shown in Figure 1-1 (page 22), simply contains a series of data fields accessible by offsets.
Atoms within container atoms do not generally have to be in any particular order, unless such an order is
specifically called out in this document. One such example is the handler description atom, which must come
before the data being handled. For example, a media handler description atom must come before a media
information atom, and a data handler description atom must come before a data information atom.
Atom Structure
Atoms consist of a header, followed by atom data. The header contains the atoms size and type fields, giving
the size of the atom in bytes and its type. It may also contain an extended size field, giving the size of a large
atom as a 64-bit integer. If an extended size field is present, the size field is set to 1. The actual size of an atom
cannot be less than 8 bytes (the minimum size of the type and size fields).
Some atoms also contain version and flags fields. These are sometimes called full atoms. The flag and version
fields are not treated as part of the atom header in this document; they are treated as data fields specific to
each atom type that contains them. Such fields must always be set to zero, unless otherwise specified.
22
Overview of QTFF
Atoms
0, which is allowed only for a top-level atom, designates the last atom in the file and indicates that
the atom extends to the end of the file.
1, which means that the actual size is given in the extended size field, an optional 64-bit field
that follows the type field.
This accommodates media data atoms that contain more than 2^32 bytes.
Figure 1-2 (page 24) shows how to calculate the size of an atom.
Type
A 32-bit integer that contains the type of the atom. This can often be usefully treated as a four-character
field with a mnemonic value, such as 'moov' (0x6D6F6F76) for a movie atom, or 'trak'
(0x7472616B) for a track atom, but non-ASCII values (such as 0x00000001) are also used.
Knowing an atom's type allows you to interpret its data. An atom's data can be arranged as any arbitrary
collection of fields, tables, or other atoms. The data structure is specific to the atom type. An atom of a
given type has a defined data structure.
If your application encounters an atom of an unknown type, it should not attempt to interpret the atom's
data. Use the atom's size field to skip this atom and all of its contents. This allows a degree of forward
compatibility with extensions to the QuickTime file format.
Warning: The internal structure of a given type of atom can change when a new version is introduced.
Always check the version field, if one exists. Never attempt to interpret data that falls outside of the
atom, as defined by the Size or Extended Size fields.
Extended Size
If the size field of an atom is set to 1, the type field is followed by a 64-bit extended size field, which
contains the actual size of the atom as a 64-bit unsigned integer. This is used when the size of a media
data atom exceeds 2^32 bytes.
23
Overview of QTFF
QT Atoms and Atom Containers
When the size field contains the actual size of the atom, the extended size field is not present. This means
that when a QuickTime atom is modified by adding data, and its size crosses the 2^32 byte limit, there is no
extended size field in which to record the new atom size. Consequently, it is not always possible to enlarge
an atom beyond 2^32 bytes without copying its contents to a new atom.
To prevent this inconvenience, media data atoms are typically created with a 64-bit placeholder atom
immediately preceding them in the movie file. The placeholder atom has a type of
kWideAtomPlaceholderType ('wide').
Much like a 'free' or 'skip' atom, the 'wide' atom is reserved space, but in this case the space is reserved
for a specific purpose. If a 'wide' atom immediately precedes a second atom, the second atom can be extended
from a 32-bit size to a 64-bit size simply by starting the atom header 8 bytes earlier (overwriting the 'wide'
atom), setting the size field to 1, and adding an extended size field. This way the offsets for sample data
do not need to be recalculated.
The 'wide' atom is exactly 8 bytes in size, and consists solely of its size and type fields. It contains no other
data.
Note: A common error is thinking that the 'wide' atom contains the extended size. The 'wide'
atom is merely a placeholder that can be overwritten if necessary, by an atom header containing an
extended size field.
Figure 1-2
Size = 1
Size = 0
Type
Type
Type
Size
Extended size
( if size = 1)
Size
Size
End
of file
24
Overview of QTFF
QT Atoms and Atom Containers
This allows multiple child atoms of the same type to be specified through identification numbers. It also makes
it possible to parse the contents of a QT atom of unknown type, by walking the tree of its child atoms.
QT atoms are normally wrapped in an atom container, a data structure with a header containing a lock count.
Each atom container contains exactly one root atom, which is the QT atom. Atom containers are not atoms,
and are not found in the hierarchy of atoms that makes up a QuickTime movie file. Atom containers may be
found as data structures inside some atoms, however. Examples include media input maps and media property
atoms.
Important: An atom container is not the same as a container atom. An atom container is a container , not
an atom.
Figure 1-3 (page 26) depicts the layout of a QT atom. Each QT atom starts with a QT atom container header,
followed by the root atom. The root atoms type is the QT atoms type. The root atom contains any other atoms
that are part of the structure.
25
Overview of QTFF
QT Atoms and Atom Containers
Each container atom starts with a QT atom header followed by the atoms contents. The contents are either
child atoms or data, but never both. If an atom contains children, it also contains all of its childrens data and
descendants. The root atom is always present and never has any siblings.
Figure 1-3
QT atom layout
QT atom container header
Reserved
Lock count
QT atom header
Size
Type
Atom ID
Reserved
Child count
Reserved
Child atom
Size
Size
Type
Type
Child atom
Size
Size
Type
Type
26
Overview of QTFF
QT Atoms and Atom Containers
Size
A 32-bit integer that indicates the size of the atom in bytes, including both the QT atom header and the
atoms contents. If the atom is a leaf atom, then this field contains the size of the single atom. The size
of container atoms includes all of the contained atoms. You can walk the atom tree using the size and
child count fields.
Type
A 32-bit integer that contains the type of the atom. If this is the root atom, the type value is set to 'sean'.
Atom ID
A 32-bit integer that contains the atoms ID value. This value must be unique among its siblings. The root
atom always has an atom ID value of 1.
Reserved
A 16-bit integer that must be set to 0.
Child count
A 16-bit integer that specifies the number of child atoms that an atom contains. This count includes only
immediate children. If this field is set to 0, the atom is a leaf atom and contains only data.
Reserved
A 32-bit integer that must be set to 0.
QT Atom Containers
A QuickTime atom container is a basic structure for storing information in QuickTime. An atom container is a
tree-structured hierarchy of QT atoms. You can think of a newly created QT atom container as the root of a
tree structure that contains no children.
An atom container is a container, not an atom. It has a reserved field and a lock count in its header, not a size
field and type field. Atom containers are not found in the atom hierarchy of a QuickTime movie file, because
they are not atoms. They may be found as data inside some atoms, however, such as in media input maps,
media property atoms, video effects sample data, and tween sample data.
27
Overview of QTFF
QT Atoms and Atom Containers
A QT atom container contains QT atoms, as shown in Figure 1-4 (page 28). Each QT atom contains either data
or other atoms. If a QT atom contains other atoms, it is a parent atom and the atoms it contains are its child
atoms. Each parents child atom is uniquely identified by its atom type and atom ID. A QT atom that contains
data is called a leaf atom.
Figure 1-4
Atom type
Atom type
Atom ID
Atom ID
Atom data
Child atoms
Atom type
Atom type
Atom ID
Atom ID
Atom data
Each QT atom has an offset that describes the atoms position within the QT atom container. In addition, each
QT atom has a type and an ID. The atom type describes the kind of information the atom represents. The atom
ID is used to differentiate child atoms of the same type with the same parent; an atoms ID must be unique for
a given parent and type. In addition to the atom ID, each atom has a 1-based index that describes its order
relative to other child atoms of the same parent with the same atom type. You can uniquely identify a QT atom
in one of three ways:
You can store and retrieve atoms in a QT atom container by index, ID, or both. For example, to use a QT atom
container as a dynamic array or tree structure, you can store and retrieve atoms by index. To use a QT atom
container as a database, you can store and retrieve atoms by ID. You can also create, store, and retrieve atoms
using both ID and index to create an arbitrarily complex, extensible data structure.
28
Overview of QTFF
QT Atoms and Atom Containers
Warning: Since QT atoms are offsets into a data structure, they can be changed during editing
operations on QT atom containers, such as inserting or deleting atoms. For a given atom, editing child
atoms is safe, but editing sibling or parent atoms invalidates that atoms offset.
Note: For cross-platform purposes, all data in a QT atom is expected to be in big-endian format.
However, leaf data can be little-endian if it is custom to an application.
Figure 1-5 (page 29) shows a QT atom container that has two child atoms. The first child atom (offset = 10) is
a leaf atom that has an atom type of 'abcd', an ID of 1000, and an index of 1. The second child atom (offset
= 20) has an atom type of 'abcd', an ID of 900, and an index of 2. Because the two child atoms have the same
type, they must have different IDs. The second child atom is also a parent atom of three atoms.
Figure 1-5
Index = 1
Offset = 10
'abcd'
'abcd'
900
1000
Data
Index = 1
Offset = 30
Index = 1
Offset = 40
Index = 2
Offset = 50
'abcd'
'word'
'abcd'
100
100
1000
"Hello"
The first child atom (offset = 30) has an atom type of 'abcd', an ID of 100, and an index of 1. It does not have
any children, nor does it have data. The second child atom (offset = 40) has an atom type of 'word', an ID of
100, and an index of 1. The atom has data, so it is a leaf atom. The second atom (offset = 40) has the same ID
as the first atom (offset = 30), but a different atom type. The third child atom (offset = 50) has an atom type
of 'abcd', an ID of 1000, and an index of 2. Its atom type and ID are the same as that of another atom (offset
= 10) with a different parent.
29
Overview of QTFF
QuickTime Movie Files
Note: If you are working with the QuickTime API, you do not need to parse QT atoms. Instead, the
QT atom functions can be used to create atom containers, add atoms to and remove atoms from
atom containers, search for atoms in atom containers, and retrieve data from atoms in atom containers.
Most QT atom functions take two parameters to specify a particular atom: the atom container that contains
the atom, and the offset of the atom in the atom container data structure. You obtain an atoms offset by
calling either QTFindChildByID or QTFindChildByIndex. An atoms offset may be invalidated if the QT
atom container that contains it is modified.
When calling any QT atom function for which you specify a parent atom as a parameter, you can pass the
constant kParentAtomIsContainer as an atom offset to indicate that the specified parent atom is the atom
container itself. For example, you would call the QTFindChildByIndex function and pass
kParentAtomIsContainer constant for the parent atom parameter to indicate that the requested child
atom is a child of the atom container itself.
30
Overview of QTFF
QuickTime Movie Files
Note: The use of resource forks for the storage of QuickTime media is deprecated in the QuickTime
file format. The information below is intended to document existing content and should not be used
for new development.
In file systems that support both a resource fork and a data fork, the movie resource may be contained
in the resource fork. The default, however, is for the movie resource to be contained in the data fork
for all file systems. If media sample data is included in the movie file, it is always in the data fork.
A QuickTime movie file is structured as a collection of atoms that together identify the file as a QuickTime
movie, describe the structure of the movie, and may contain the sample data needed to play the movie. Not
all atoms are required.
The file format is extensible, and from time to time new atom types are introduced. If your application encounters
an unknown atom type in a QuickTime file, it should simply ignore it. This allows the file format to be extended
without breaking existing applications, and provides a measure of forward compatibility. Because the first field
in any atom contains its size, including any contained atoms, it is easy to skip to the end of an unknown atom
type and continue parsing the file.
Important: Generally speaking, atoms can be present in any order. Do not conclude that a particular atom
is not present until you have parsed all the atoms in the file.
An exception is the file type atom, which typically identifies the file as a QuickTime movie. If present, this atom
precedes any movie atom, movie data, preview, or free space atoms. If you encounter one of these other atom
types prior to finding a file type atom, you may assume the file type atom is not present. (This atom is introduced
in the QuickTime File Format Specification for 2004, and is not present in QuickTime movie files created prior
to 2004).
While other atoms can be in any order, unless specified in this document, for practical reasons there is a
recommended order that you should use when creating a QuickTime movie file. For example, the atom
containing the movie resource should precede any atoms containing the movie's sample data. If you follow
this recommended atom order, it is possible to play a movie over a network while the movie file is in the
process of downloading.
A QuickTime movie file must contain a movie atom, which contains either the movie structure or a reference
to one or more alternate movie sources external to the file. Generally speaking, these alternate sources will be
QuickTime movie files that contain movie structures.
A QuickTime movie file typically contains one or more movie data atoms, which contain media sample data
such as video frames and groups of audio samples. There may be no movie data atoms in the file, however,
as the movie may depend on sample data external to the movie file, such as external data files or live streams
31
Overview of QTFF
QuickTime Movie Files
on the Internet. A single movie data atom may contain sample data for a variety of different media. Generally
speaking, it is possible to contain all the media samples used by a movie in a single movie data atom. Movie
data atoms can be quite large, and sometimes exceed 2^32 bytes.
Figure 1-6 (page 32) shows the essential atom types in a QuickTime movie file within which other atoms are
stored. In addition, the file may contain free space atoms, preview atoms, and other atoms not enumerated in
this file format specification. Unknown atom types should be ignored.
Figure 1-6
Type = 'ftyp'
Data
Variable
.
.
.
Movie atom
Atom size
Type = 'moov'
Data
Variable
.
.
.
Movie data atom
Atom size
Type = 'mdat'
Data
Variable
Atom type
Use
'ftyp'
File type compatibilityidentifies the file type and differentiates it from similar file types,
such as MPEG-4 files and JPEG-2000 files.
'moov'
Movie resource metadata about the movie (number and type of tracks, location of sample
data, and so on). Describes where the movie data can be found and how to interpret it.
32
Overview of QTFF
QuickTime Movie Files
Atom type
Use
'mdat'
Movie sample datamedia samples such as video frames and groups of audio samples.
Usually this data can be interpreted only by using the movie resource.
'free'
'skip'
'wide'
'pnot'
The following sections describe these basic atom types (except for the movie atom) in more detail, including
descriptions of other atoms that each basic atom may contain. The movie atom is described separately in
Movie Atoms (page 37)
The file type atom is optional, but strongly recommended. If present, it must be the first significant atom in
the file, preceding the movie atom (and any free space atoms, preview atom, or movie data atoms).
33
Overview of QTFF
QuickTime Movie Files
The file type atom has an atom type value of 'ftyp' and contains the following fields:
Size
A 32-bit unsigned integer that specifies the number of bytes in this atom.
Type
A 32-bit unsigned integer that identifies the atom type, typically represented as a four-character code;
this field must be set to 'ftyp'.
Major_Brand
A 32-bit unsigned integer that should be set to 'qt ' (note the two trailing ASCII space characters) for
QuickTime movie files. If a file is compatible with multiple brands, all such brands are listed in the
Compatible_Brands fields, and the Major_Brand identifies the preferred brand or best use.
Minor_Version
A 32-bit field that indicates the file format specification version. For QuickTime movie files, this takes the
form of four binary-coded decimal values, indicating the century, year, and month of the QuickTime File
Format Specification , followed by a binary coded decimal zero. For example, for the June 2004 minor
version, this field is set to the BCD values 20 04 06 00.
Compatible_Brands[ ]
A series of unsigned 32-bit integers listing compatible file formats. The major brand must appear in the
list of compatible brands. One or more placeholder entries with value zero are permitted; such entries
should be ignored.
If none of the Compatible_Brands fields is set to 'qt ', then the file is not a QuickTime movie file and is not
compatible with this specification. Applications should return an error and close the file, or else invoke a file
importer appropriate to one of the specified brands, preferably the major brand. QuickTime currently returns
an error when attempting to open a file whose file type, file extension, or MIME type identifies it as a QuickTime
movie, but whose file type atom does not include the 'qt ' brand.
Note: A common source of this error is an MPEG-4 file incorrectly named with the .mov file extension
or with the MIME type incorrectly set to video/quicktime. MPEG-4 files are automatically imported
by QuickTime only when they are correctly identified as MPEG-4 files using the Mac OS file type, file
extension, or MIME type.
If you are creating a file type that is fully compatible with the QuickTime file format, one of the Compatible_Brand
fields must be set to 'qt '; otherwise QuickTime will not recognize the file as a QuickTime movie.
Warning: Use of the QuickTime file format in this manner is subject to license from Apple, Inc.
34
Overview of QTFF
QuickTime Movie Files
Preview Atoms
The preview atom contains information that allows you to find the preview image associated with a QuickTime
movie. The preview image, or poster, is a representative image suitable for display to the user in, for example,
Open dialog boxes. Figure 1-7 (page 35) depicts the layout of the preview atom.
Figure 1-7
Type = 'pnot'
Modification date
Version number
Atom type
Atom index
The preview atom has an atom type value of 'pnot' and, following its atom header, contains the following
fields:
35
Overview of QTFF
QuickTime Movie Files
Size
A 32-bit integer that specifies the number of bytes in this preview atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'pnot'.
Modification date
A 32-bit unsigned integer containing a date that indicates when the preview was last updated. The data
is in standard Macintosh format.
Version number
A 16-bit integer that must be set to 0.
Atom type
A 32-bit integer that indicates the type of atom that contains the preview data. Typically, this is set to
'PICT' to indicate a QuickDraw picture.
Atom index
A 16-bit integer that identifies which atom of the specified type is to be used as the preview. Typically,
this field is set to 1 to indicate that you should use the first atom of the type specified in the atom type
field.
Note: This specification defines the preview atom primarily for backward compatibility. Current
practice is normally to define movie previews by placing information in the movie header atom. See
Movie Header Atoms (page 43).
36
Movie Atoms
This chapter provides a general introduction to QuickTime movie atoms, as well as specific details on the layout
and usage of these atoms. Each atom type discussed in this chapter is shown with an accompanying illustration
that contains offset information, followed by field descriptions.
This chapter is divided into the following major sections:
Overview of Movie Atoms (page 38) discusses QuickTime movie atoms, which act as containers for
information that describes a movies data. A conceptual illustration is provided that shows the organization
of a simple, one-track QuickTime movie. Color table atoms and user data atoms are also discussed.
Track Atoms (page 55) describes track atoms, which define a single track of a movie. Track user data atoms
and hint tracks are also discussed.
Media Atoms (page 79) discusses media atoms, which define a tracks movie data, such as the media type
and media time scale.
Sample Atoms (page 95) discusses sample table atoms, which specify where media samples are located,
their duration, and so on. The section also includes examples of how you use these atoms.
Note: Media atoms and sample atoms do not contain actual sample data, such as video frames
or audio samples. They contain metadata used to locate and interpret such samples.
Compressed Movie Resources (page 117) discusses compressed movie resources, in which a lossless
compression algorithm is used to compress the contents of the movie atom, including any track, media,
or sample atoms. The contents must be decompressed before the movie atom can be parsed.
Reference Movies (page 119) discusses movies that contain a reference movie atom (a list of references to
alternate movies, as well as the criteria for selecting the correct movie from a list of alternates). Movie
atoms that contain a reference movie atom do not necessarily contain track, media, or sample atoms.
37
Movie Atoms
Overview of Movie Atoms
38
Movie Atoms
Overview of Movie Atoms
It is also possible to create a reference movie, a movie that refers to other movies; in this case the movie atom
may contain only a reference movie atom ('rmra'). For details, see Reference Movies. Ultimately, the chain
must end in either a standard movie atom, such as the one in Figure 2-1 (page 39), or a compressed movie
atom, which can be uncompressed to obtain the same structure.
Figure 2-1
Atom size
Type = 'clip'
Atom size
Type = 'udta'
Atom size
Type = 'mvhd'
Atom size
Type = 'crgn'
Atom size
Type = User defined
Atom size
Type = 'prfl'
Track atom
Atom size
Type ='trak'
Track clipping atom
Atom size
Type = 'clip'
Atom size
Type = 'matt'
Edit atom
Atom size
Type = 'tkhd'
Atom size
Type = 'crgn'
Atom size
Type = 'kmat'
Atom size
Type = 'edts'
Edit list atom
Atom size
Type = 'elst'
Media atom
Media header atom
Atom size
Type ='mdia'
Atom size
Type = 'mdhd'
Atom size
Type = 'hdlr'
Video media information atom
Atom size
Type ='minf'
Atom size
Type = 'dref'
Data references
..
.
Atom size
Type ='stbl'
Sample-to-chunk atom
Atom size
Type = 'stsc'
Atom size
Type ='stss'
Atom size
Type = 'stsd'
Atom size
Type = 'stsz'
Atom size
Type = 'stco'
39
Movie Atoms
Overview of Movie Atoms
Note: Additional atoms may be present in a one-track QuickTime movie file that do not appear in
Figure 2-1 (page 39).
40
Movie Atoms
Overview of Movie Atoms
Note: As previously mentioned, leaf atoms are shown as white boxes, while container atoms are
shown as gray boxes.
Figure 2-2
'prfl'
'mvhd'
Clipping atom
'clip'
'udta'
'ctab'
'rmra'
Required atom
41
Movie Atoms
Overview of Movie Atoms
The movie profile atom summarizes the features and complexity of a movie, such as the required codecs and
maximum bit rate, in order to help player applications or devices quickly determine whether they have the
necessary resources to play the movie.
Features for a movie typically include the movies maximum video and audio bit rate, a list of audio and video
codec types, the movies video dimensions, and any applicable MPEG-4 profiles and levels. This is all information
that can also be obtained by examining the contents of the movie file in more detail. This summary is intended
to allow applications or devices to quickly determine whether they can play the movie. It is not intended as a
container for information that is not found elsewhere in the movie, and should not be used as one.
Note: The fact that a feature does not appear in the profile atom does not mean it is not present
in the movie. The profile atom itself may not be present, or may list only a subset of movie features.
The features listed in the profile atom are all present, but the list is not necessarily complete.
When creating a profile atom, it is permissible to omit some features that are present in the movie, but it is
required to fully specify any features that are included in the profile. For example, a movie containing video
may or may not have a video codec type feature in the profile atom, but if any video codec type feature is
included in the profile atom, every required video codec must be listed in the profile atom.
The movie profile atom is a profile atom ('prfl') whose parent is a movie atom. This is distinct from the track
profile atom, whose parent is a track atom. The structure of the profile atom is identical in both cases, but the
contents of a movie profile atom describe the movie as a whole, while the contents of a track profile atom are
specific to a particular track.
42
Movie Atoms
Overview of Movie Atoms
The profile atom contains a list of features. In a movie profile atom, these features summarize the movie as a
whole. In a track profile atom, these features describe a particular track.
Each entry in the feature list consists of four 32-bit fields:
The second field is the part-ID, which defines the feature as being either brand-specific or universal.
Brand-specific features are particular to a specific brand. Universal features are can be found in any file
type that uses the profile atom. Universal features have a part-ID of four ASCII spaces (0x20202020).
Brand-specific features have a part-ID that is one of the Compatible_Brand codes for that file type, as
specified in the file type atom ('ftyp'). For example, the part-ID for QuickTime-specific features is 'qt '.
All features described in this document, however, are universal.
The third field is the feature code, or name, a 32-bit unsigned integer that is usually best interpreted as
four ASCII characters. Example: the maximum video bit rate feature has a feature code or name of 'mvbr'.
It is permissible to use a feature code value of zero (0x00000000, not four ASCII zero characters) as a
placeholder in one or more name-value pairs. The reader should ignore feature codes of value zero.
The fourth field is the value, which is also a 32-bit field. The value may be a signed or unsigned integer,
or a fixed-point value, or contain subfields, or consist of a packed array; it can be interpreted only in relation
to the specific feature.
For details on the structure and contents of profile atoms, see Profile Atom Guidelines (page 401).
43
Movie Atoms
Overview of Movie Atoms
Figure 2-3 (page 44) shows the layout of the movie header atom. The movie header atom is a leaf atom.
Figure 2-3
a
b
u
c
d
v
x
y
w
Atom size
Type = 'mvhd'
Version
Flags
Creation time
Modification time
Time scale
Duration
Preferred rate
Preferred volume
Reserved
10
Matrix structure
36
Preview time
Preview duration
Poster time
Selection time
Selection duration
Current time
Next track ID
You define a movie header atom by specifying the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this movie header atom.
Type
A 32-bit integer that identifies the atom type; must be set to 'mvhd'.
Version
A 1-byte specification of the version of this movie header atom.
44
Movie Atoms
Overview of Movie Atoms
Flags
Three bytes of space for future movie header flags.
Creation time
A 32-bit integer that specifies the calendar date and time (in seconds since midnight, January 1, 1904)
when the movie atom was created. It is strongly recommended that this value should be specified using
coordinated universal time (UTC).
Modification time
A 32-bit integer that specifies the calendar date and time (in seconds since midnight, January 1, 1904)
when the movie atom was changed. BooleanIt is strongly recommended that this value should be specified
using coordinated universal time (UTC).
Time scale
A time value that indicates the time scale for this moviethat is, the number of time units that pass per
second in its time coordinate system. A time coordinate system that measures time in sixtieths of a second,
for example, has a time scale of 60.
Duration
A time value that indicates the duration of the movie in time scale units. Note that this property is derived
from the movies tracks. The value of this field corresponds to the duration of the longest track in the
movie.
Preferred rate
A 32-bit fixed-point number that specifies the rate at which to play this movie. A value of 1.0 indicates
normal rate.
Preferred volume
A 16-bit fixed-point number that specifies how loud to play this movies sound. A value of 1.0 indicates
full volume.
Reserved
Ten bytes reserved for use by Apple. Set to 0.
Matrix structure
The matrix structure associated with this movie. A matrix shows how to map points from one coordinate
space into another. See Matrices (page 332) for a discussion of how display matrices are used in QuickTime.
Preview time
The time value in the movie at which the preview begins.
Preview duration
The duration of the movie preview in movie time scale units.
Poster time
The time value of the time of the movie poster.
45
Movie Atoms
Overview of Movie Atoms
Selection time
The time value for the start time of the current selection.
Selection duration
The duration of the current selection in movie time scale units.
Current time
The time value for current time position within the movie.
Next track ID
A 32-bit integer that indicates a value to use for the track ID number of the next track added to this movie.
Note that 0 is not a valid track ID value.
Note: The creation and modification date should be set using coordinated universal time (UTC). In
prior versions of the QuickTime file format, this was not specified, and these fields were commonly
set to local time for the time zone where the movie was created.
Bytes
Atom size
Type = 'ctab'
Color array
46
Movie Atoms
Overview of Movie Atoms
Type
A 32-bit integer that identifies the atom type; this field must be set to 'ctab'.
Color table seed
A 32-bit integer that must be set to 0.
Color table flags
A 16-bit integer that must be set to 0x8000.
Color table size
A 16-bit integer that indicates the number of colors in the following color array. This is a zero-relative
value; setting this field to 0 means that there is one color in the array.
Color array
An array of colors. Each color is made of four unsigned 16-bit integers. The first integer must be set to 0,
the second is the red value, the third is the green value, and the fourth is the blue value.
47
Movie Atoms
Overview of Movie Atoms
Figure 2-5 (page 48) shows the layout of a user data atom.
Figure 2-5
Type = 'udta'
Atom size
Required atom
Description
For
Sorting
'arg'
Name of arranger
'ark'
48
Movie Atoms
Overview of Movie Atoms
Description
For
Sorting
'cok'
'com'
Name of composer
'cpy'
Copyright statement
'day'
'dir'
'ed1' to 'ed9'
'fmt'
'inf'
'isr'
ISRC code
'lab'
'lal'
'mak'
'mal'
'nak'
'nam'
'pdk'
'phg'
'prd'
Name of producer
'prf'
Names of performers
'prk'
'prl'
'req'
49
Movie Atoms
Overview of Movie Atoms
Description
For
Sorting
'snk'
'snm'
Subtitle of content
'src'
'swf'
Name of songwriter
'swk'
'swr'
'wrt'
'AllF'
'hinf'
'hnti'
'name'
Name of object
'tnam'
'tagc'
'LOOP'
'ptv '
50
Movie Atoms
Overview of Movie Atoms
Description
For
Sorting
'SelO'
'WLOC'
The user-data items labelled keywords and marked as For Sorting are for use when the display text does
not have a pre-determined sorting order (for example, in oriental languages when the sorting depends on the
contextual meaning). These keywords can be sorted algorithmically to place the corresponding items in correct
order.
The window location, looping, play selection only, play all frames, and print to video atoms control the way
QuickTime displays a movie. These atoms are interpreted only if the user data atoms immediate parent is a
movie atom ('moov'). If they are included as part of a track atoms user data, they are ignored.
51
Movie Atoms
Overview of Movie Atoms
Public tags allow shared semantics to be deployed widely. Public tags are currently defined by Apple.
A public tag starts with the prefix public., which is followed by one or more segments separated by
periods. Examples (not defined) might be public.subtitle or public.commentary.director.
Note: Public tags are public because they are documented in this specification or are available
in Apple APIs. Other definitions of tags with the "public." prefix are prohibited; use private tags
instead.
A private tag starts with the private entitys domain using a reverse DNS naming convention. For example,
apple.com becomes com.apple. This is followed by one or more segments separated by periods. Examples
(not defined) might be com.apple.this-is-a-tag, com.apple.video.includes-sign-language, and
org.w3c.html5.referenced-video.
52
Movie Atoms
Overview of Movie Atoms
The only allowed prefixes are public. and reversed domains. All other prefixes are reserved for future
use.
Note: Generic top-level domains other than public" (if it were to be assigned) are supported. The
string public" is reserved to signal public media characteristic tags.
This specification defines the following public media characteristic tags. Other public and private tags could
be defined outside the specification; unrecognized tags should be ignored.
Track Name
A movie atoms user data atom may contain a track name atom ('tnam').
The track name atoms payload data consists of the following data.
Language: 16-bit integer holding a packed ISO 639-2/T code as described in User Data Text Strings and
Language Codes (page 51).
53
Movie Atoms
Overview of Movie Atoms
Name: Null-terminated UTF-8 or UTF-16 string holding the track name. If this is a UTF-16 string, the string
must start with a byte-order mark (0xFEFF).
A track can have multiple 'tnam' atoms with different language codes. Normally it is sufficient for each track
to have a single 'tnam' atom in the same language as the track content. Alternate tracks might also have
'tnam' atoms; their presence implies only that the name is a good user-readable label for the track.
54
Movie Atoms
Track Atoms
Track Atoms
Track atoms define a single track of a movie. A movie may consist of one or more tracks. Each track is
independent of the other tracks in the movie and carries its own temporal and spatial information. Each track
atom contains its associated media atom.
Tracks are used specifically for the following purposes:
To contain packetization information for streaming protocols (hint tracks). Hint tracks may contain references
to media sample data or copies of media sample data. For more information about hint tracks, refer to
Hint Media (page 263).
Note: A QuickTime movie cannot consist solely of hint tracks or modifier tracks; there must be at
least one media track. Furthermore, media tracks cannot be deleted from a hinted movie, even if
the hint tracks contain copies of the media sample datain addition to the hint tracks, the entire
unhinted movie must remain.
Figure 2-6 (page 56) shows the layout of a track atom. Track atoms have an atom type value of 'trak'. The
track atom requires a track header atom ('tkhd') and a media atom ('mdia'). Other child atoms are optional,
and may include a track clipping atom ('clip'), a track matte atom ('matt'), an edit atom ('edts'), a track
reference atom ('tref'), a track load settings atom ('load'), a track input map atom ('imap'), and a user
data atom ('udta').
55
Movie Atoms
Track Atoms
Note: Figure 2-6 (page 56) contains an optional track profile atom prfl. Track profile atoms are
deprecated in the current version of QuickTime but may be present in existing QuickTime files. The
inclusion here is intended to document existing content containing profile atoms, they should not
be used for new development.
Figure 2-6
'prfl'
'tkhd'
'tapt'
Clipping atom
'clip'
'matt'
Edit atom
'edts'
'tref'
'txas'
'load'
'imap'
Media atom
'mdia'
'udta'
Required atom
56
Movie Atoms
Track Atoms
Clipping atom
See Clipping Atoms (page 66) for more information.
Track matte atom
See Track Matte Atoms (page 68) for more information.
Edit atom
See Edit Atoms (page 69) for details.
Track reference atom
See Track Reference Atoms (page 73) for details.
Track exclude from autoselection atom
See Track Exclude From Autoselection Atoms (page 61) for details.
Track load settings atom
See Track Load Settings Atoms (page 71) for details.
Track input map atom
See Track Input Map Atoms (page 76) for details.
Media atom
See Media Atoms (page 79) for details.
User-defined data atom
See User Data Atoms (page 47) for more information.
Profile atoms can be children of movie atoms or track atoms. For details on profile atoms, see The Movie Profile
Atom (page 42).
57
Movie Atoms
Track Atoms
Figure 2-7 (page 58) shows the structure of the track header atom.
Figure 2-7
Type = 'tkhd'
Version
Flags
Creation time
Modification time
Track ID
Reserved
Duration
Reserved
Layer
Alternate group
Volume
Reserved
Matrix structure
36
Track width
Track height
The track header atom contains the track characteristics for the track, including temporal, spatial, and volume
information.
Track header atoms contain the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this track header atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'tkhd'.
Version
A 1-byte specification of the version of this track header.
58
Movie Atoms
Track Atoms
Flags
Three bytes that are reserved for the track header flags. These flags indicate how the track is used in the
movie. The following flags are valid (all flags are enabled when set to 1).
Track enabled
Indicates that the track is enabled. Flag value is 0x0001.
Track in movie
Indicates that the track is used in the movie. Flag value is 0x0002.
Track in preview
Indicates that the track is used in the movies preview. Flag value is 0x0004.
Track in poster
Indicates that the track is used in the movies poster. Flag value is 0x0008.
Creation time
A 32-bit integer that indicates the calendar date and time (expressed in seconds since midnight, January
1, 1904) when the track header was created. It is strongly recommended that this value should be specified
using coordinated universal time (UTC).
Modification time
A 32-bit integer that indicates the calendar date and time (expressed in seconds since midnight, January
1, 1904) when the track header was changed. It is strongly recommended that this value should be
specified using coordinated universal time (UTC).
Track ID
A 32-bit integer that uniquely identifies the track. The value 0 cannot be used.
Reserved
A 32-bit integer that is reserved for use by Apple. Set this field to 0.
Duration
A time value that indicates the duration of this track (in the movies time coordinate system). Note that
this property is derived from the tracks edits. The value of this field is equal to the sum of the durations
of all of the tracks edits. If there is no edit list, then the duration is the sum of the sample durations,
converted into the movie timescale.
Reserved
An 8-byte value that is reserved for use by Apple. Set this field to 0.
Layer
A 16-bit integer that indicates this tracks spatial priority in its movie. The QuickTime Movie Toolbox uses
this value to determine how tracks overlay one another. Tracks with lower layer values are displayed in
front of tracks with higher layer values.
59
Movie Atoms
Track Atoms
Alternate group
A 16-bit integer that identifies a collection of movie tracks that contain alternate data for one another.
This same identifier appears in each 'tkhd' atom of the other tracks in the group. QuickTime chooses
one track from the group to be used when the movie is played. The choice may be based on such
considerations as playback quality, language, or the capabilities of the computer.
A value of zero indicates that the track is not in an alternate track group.
The most common reason for having alternate tracks is to provide versions of the same track in different
languages. Figure 2-8 (page 60) shows an example of several tracks. The video tracks Alternate Group
ID is 0, which means that it is not in an alternate group (and its language codes are empty; normally,
video tracks should have the appropriate language tags). The three sound tracks have the same Group
ID, so they form one alternate group, and the subtitle tracks have a different Group ID, so they form
another alternate group. The tracks would not be adjacent in an actual QuickTime file; this is just a list
of example track field values.
Figure 2-8
Alternate
Group ID
Extended
Language Tag
Language
Code
video (vide)
sound (soun)
en-US
eng
sound
fr-FR
fra
sound
jp-JP
jpn
subtitle (subt)
en-US
eng
subtitle
fr-FR
fra
Volume
A 16-bit fixed-point value that indicates how loudly this tracks sound is to be played. A value of 1.0
indicates normal volume.
Reserved
A 16-bit integer that is reserved for use by Apple. Set this field to 0.
Matrix structure
The matrix structure associated with this track. See Figure 2-3 (page 44) for an illustration of a matrix
structure.
Track width
A 32-bit fixed-point number that specifies the width of this track in pixels.
Track height
A 32-bit fixed-point number that indicates the height of this track in pixels.
60
Movie Atoms
Track Atoms
Considering this context, the dimensions recorded in the image description define the dimensions of the
encoded pixels (encoded dimensions). What's actually displayed is a result of applying the pixel aspect ratio
and the clean aperture (display dimensions).
61
Movie Atoms
Track Atoms
Although the result of applying the clean aperture and the pixel aspect ratio is what is intended for final display,
there are cases where it is useful to display all the pixels that exist in the content for various different
purposes. Readers parsing QuickTime movies require information allowing these different display modes in
order to provide this flexibility:
Clean Mode
In this mode both the clean aperture and the pixel aspect ratio are applied. The dimensions of the track
become equal to the clean dimensions which are equal to the display dimensions (with conformed
contents).
Production Mode
This mode applies the pixel aspect ratio but not the clean aperture. The image is presented in the correct
aspect ratio, but the extra pixels outside of the image that exists in the source material will be presented.
The track dimensions are equal to the result of applying the pixel aspect ratio.
Classic Mode
This mode displays the image without applying either the pixel aspect ratio or the clean aperture. The
image is displayed using the track header dimensions, meaning the decompressed picture is scaled into
the track header dimensions if the encoded dimensions are different.
Encoded Pixels
The encoded pixels are displayed intact in this mode. Under this mode the track dimensions are equal
to the encoded dimensions. No scaling or transformation takes place.
The information needed for each of these presentation modes are represented in the optional track aperture
mode dimensions atoms.
Note: Older applications built prior to QuickTime 7 will continue to use the dimension values stored
in the track header.
62
Movie Atoms
Track Atoms
Figure 2-9 (page 63) shows the layout of the track aperture mode dimensions atom.
Figure 2-9
'clef'
'enof'
Size
A 32-bit integer that specifies the number of bytes in the track aperture mode dimensions atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to tapt.
Track Clean Aperture Dimensions atom
See Track Clean Aperture Dimensions Atom (page 63)
Track Production Aperture Dimensions atom
See Track Production Aperture Dimensions Atom (page 64)
Track Encoded Pixels Dimensions atom
See Track Encoded Pixels Dimensions Atom (page 65)
63
Movie Atoms
Track Atoms
Figure 2-10 (page 64) shows the layout of the track clean aperture dimensions atom.
Figure 2-10
Bytes
Atom size
Type = 'clef'
Version
Flags
Width
Height
Size
A 32-bit integer that specifies the number of bytes in the track aperture mode dimensions atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to clef.
Version
A 1-byte specification of the version of this atom.
Flags
Three bytes that are reserved for the atom flags.
Width
A 32-bit fixed-point number that specifies the width of the track clean aperture in pixels.
Height
A 32-bit fixed-point number that specifies the height of the track clean aperture in pixels.
64
Movie Atoms
Track Atoms
Figure 2-11 (page 65) shows the layout of the track production aperture dimensions atom.
Figure 2-11
Bytes
Atom size
Type = 'prof'
Version
Flags
Width
Height
Size
A 32-bit integer that specifies the number of bytes in the track aperture mode dimensions atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to prof.
Version
A 1-byte specification of the version of this atom.
Flags
Three bytes that are reserved for the atom flags.
Width
A 32-bit fixed-point number that specifies the width of the track production aperture in pixels.
Height
A 32-bit fixed-point number that specifies the height of the track production aperture in pixels.
65
Movie Atoms
Track Atoms
Bytes
Atom size
Type = 'enof'
Version
Flags
Width
Height
Size
A 32-bit integer that specifies the number of bytes in the track aperture mode dimensions atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to enof.
Version
A 1-byte specification of the version of this atom.
Flags
Three bytes that are reserved for the atom flags.
Width
A 32-bit fixed-point number that specifies the width of the track encoded pixels dimensions in pixels.
Height
A 32-bit fixed-point number that specifies the height of the track encoded pixels dimensions in pixels.
Clipping Atoms
Clipping atoms specify the clipping regions for movies and for tracks. The clipping atom has an atom type
value of 'clip'.
66
Movie Atoms
Track Atoms
Type = 'clip'
Type = 'crgn'
Region size
Variable
67
Movie Atoms
Track Atoms
Region size
The region size, region boundary box, and clipping region data fields constitute a QuickDraw region.
Region boundary box
The region size, region boundary box, and clipping region data fields constitute a QuickDraw region.
Clipping region data
The region size, region boundary box, and clipping region data fields constitute a QuickDraw region.
Type = 'matt'
Type = 'kmat'
Version
Flags
Matte image
description structure
Variable
Matte data
Variable
68
Movie Atoms
Track Atoms
Edit Atoms
You use edit atoms to define the portions of the media that are to be used to build up a track for a movie. The
edits themselves are contained in an edit list table, which consists of time offset and duration values for each
segment. Edit atoms have an atom type value of 'edts'.
Figure 2-15 (page 70) shows the layout of an edit atom.
In the absence of an edit list, the presentation of a track starts immediately. An empty edit is used to offset
the start time of a track.
69
Movie Atoms
Track Atoms
Note: If the edit atom or the edit list atom is missing, you can assume that the entire media is used
by the track.
Figure 2-15
Type = 'edts'
Type = 'elst'
Version
Flags
Number of entries
Variable
70
Movie Atoms
Track Atoms
Type
A 32-bit integer that identifies the atom type; this field must be set to 'elst'.
Version
A 1-byte specification of the version of this edit list atom.
Flags
Three bytes of space for flags. Set this field to 0.
Number of entries
A 32-bit integer that specifies the number of entries in the edit list atom that follows.
Edit list table
An array of 32-bit values, grouped into entries containing 3 values each. Figure 2-16 (page 71) shows
the layout of the entries in this table.
Figure 2-16
Media time
4
Media rate
Field
Bytes
71
Movie Atoms
Track Atoms
Type = 'load'
Preload duration
Preload flags
Default hints
72
Movie Atoms
Track Atoms
Default hints
A 32-bit integer containing playback hints. More than one flag may be enabled. Flags are enabled by
setting them to 1. The following flags are defined.
Double buffer
This flag indicates that the track should be played using double-buffered I/O. This flags value is
0x0020.
High quality
This flag indicates that the track should be displayed at highest possible quality, without regard
to real-time performance considerations. This flags value is 0x0100.
73
Movie Atoms
Track Atoms
Figure 2-18 (page 74) shows the layout of a track reference atom.
Figure 2-18
Bytes
Atom size
Type = 'tref'
Track IDs
Variable
Reference type
Description
'cdsc'
The track reference is contained in a timed metadata track (see Timed Metadata
Media (page 156) for more detail) and provides links to the tracks for which it contains
descriptive characteristics.
Note: If the timed metadata track describes characteristics of the entire movie, there
will be no track reference of type cdsc between it and another track.
'chap'
74
Movie Atoms
Track Atoms
Reference type
Description
'clcp'
Closed caption. In any track, this identifies a closed captioning track that contains
text that is appropriate for the referring track. See Closed Captioning Media (page
211) for more information.
'fall'
In a sound track, this references a track in a different format but with identical content,
if one exists; for example, an AC3 track might reference an AAC track with identical
content. See Alternate Sound Tracks (page 347).
'folw'
In a sound track, this references a subtitle track that is to be used as the sound tracks
default subtitle track. If the subtitle track is part of a subtitle track pair, this should
reference the the forced subtitle track of the pair. This is needed only if language
tagging cannot be used. See Relationships Across Alternate Groups (page 348).
'forc'
Forced subtitle track. In the regular track of a subtitle track pair, this references the
forced track. See Subtitle Sample Data (page 216) for more information.
'hint'
The referenced tracks contain the original media for this hint track.
'scpt'
'ssrc'
Non-primary source. Indicates that the referenced track should send its data to this
track, rather than presenting it. The referencing track will use the data to modify
how it presents its data. See Track Input Map Atoms (page 76) for more information.
'sync'
Synchronization. Usually between a video and sound track. Indicates that the two
tracks are synchronized. The reference can be from either track to the other, or there
may be two references.
'tmcd'
Each track reference type atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this track reference type atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to one of the values shown in Table
2-2 (page 74).
Track IDs
A list of track ID values (32-bit integers) specifying the related tracks. Note that this is one case where
track ID values can be set to 0. Unused entries in the atom may have a track ID value of 0. Setting the
track ID to 0 may be more convenient than deleting the reference.
75
Movie Atoms
Track Atoms
You can determine the number of track references stored in a track reference type atom by subtracting its
header size from its overall size and then dividing by the size, in bytes, of a track ID.
Bytes
Atom size
Type = 'imap'
in'
4
4
Atom ID
Reserved
Child count
Reserved
ty'
Input type
4
4
4
Object ID atom
Atom size
Type = 'obid'
Object ID
Required atom
76
Movie Atoms
Track Atoms
Each track input map atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this track input map atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'imap'.
Track input atoms
A list of track input atoms specifying how to use the input data.
The input map defines all of the tracks secondary inputs. Each secondary input is defined using a separate
track input atom.
Each track input atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this track input atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to ' in' (note that the two leading
bytes must be set to 0x00).
Atom ID
A 32-bit integer relating this track input atom to its secondary input. The value of this field corresponds
to the index of the secondary input in the track reference atom. That is, the first secondary input
corresponds to the track input atom with an atom ID value of 1; the second to the track input atom with
an atom ID of 2, and so on.
Reserved
A 16-bit integer that must be set to 0.
Child count
A 16-bit integer specifying the number of child atoms in this atom.
Reserved
A 32-bit integer that must be set to 0.
The track input atom, in turn, may contain two other types of atoms: input type atoms and object ID atoms.
The input type atom is required; it specifies how the data is to be interpreted.
The input type atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this input type atom.
77
Movie Atoms
Track Atoms
Type
A 32-bit integer that identifies the atom type; this field must be set to ' ty' (note that the two leading
bytes must be set to 0x00).
Input type
A 32-bit integer that specifies the type of data that is to be received from the secondary data source.
Table 2-3 (page 78) lists valid values for this field.
Table 2-3
Input types
Input identifier
Value
Description
kTrackModifierTypeMatrix
kTrackModifierTypeClip
kTrackModifierTypeVolume
kTrackModifierTypeBalance
kTrackModifierTypeGraphicsMode
kTrackModifierObjectMatrix
kTrackModifierObjectGraphicsMode
kTrackModifierTypeImage
'vide
If the input is operating on an object within the track (for example, a sprite within a sprite track), an object ID
atom must be included in the track input atom to identify the object.
The object ID atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this object ID atom.
78
Movie Atoms
Media Atoms
Type
A 32-bit integer that identifies the atom type; this field must be set to 'obid'.
Object ID
A 32-bit integer identifying the object.
Media Atoms
Media atoms describe and define a tracks media type and sample data. The media atom contains information
that specifies:
The media data references, which typically specify the file where the sample data is stored
The sample table atoms, which, for each media sample, specify the sample description, duration, and byte
offset from the data reference
The media atom has an atom type of 'mdia'. It must contain a media header atom ('mdhd'), and it can
contain a handler reference ('hdlr') atom, media information ('minf') atom, and user data ('udta') atom.
79
Movie Atoms
Media Atoms
Note: Do not confuse the media atom ('mdia') with the media data atom ('mdat'). The media
atom contains only references to media data; the media data atom contains the actual media samples.
'mdhd'
'hdlr'
'minf'
'udta'
Required atom
80
Movie Atoms
Media Atoms
Type = 'mdhd'
Version
Flags
Creation time
Modification time
Time scale
Duration
Language
Quality
81
Movie Atoms
Media Atoms
Flags
Three bytes of space for media header flags. Set this field to 0.
Creation time
A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the media atom was
created. It is strongly recommended that this value should be specified using coordinated universal time
(UTC).
Modification time
A 32-bit integer that specifies (in seconds since midnight, January 1, 1904) when the media atom was
changed. It is strongly recommended that this value should be specified using coordinated universal
time (UTC).
Time scale
A time value that indicates the time scale for this mediathat is, the number of time units that pass per
second in its time coordinate system.
Duration
The duration of this media in units of its time scale.
Language
A 16-bit integer that specifies the language code for this media. See Language Code Values (page 328)
for valid language codes. Also see Extended Language Tag Atom (page 82) for the preferred code to use
here if an extended language tag is also included in the media atom.
Quality
A 16-bit integer that specifies the medias playback qualitythat is, its suitability for playback in a given
environment.
82
Movie Atoms
Media Atoms
To distinguish the extended language support from the old system, it is referred to as the extended language
tag as opposed to language code . The major advantage of the extended language tag is that it includes
additional information such as region, script, variation, and so on, as parts (or subtags). For instance, this
additional information allows distinguishing content in French as spoken in Canada from content in French
as spoken in France.
Figure 2-22 (page 83) shows the layout of this atom.
Figure 2-22 The layout of an extended language tag atom
Bytes
Extended Language Tag atom
Atom size
Type = 'elng'
Version
Flags
variable
The extended language tag overrides the media language if they are not consistent.
The extended language tag atom is optional, and if it is absent the media language should be used.
No validation of the language tag string is performed. Applications parsing QuickTime movies need to be
prepared for an invalid language tag, and are expected to behave as if no information is found.
83
Movie Atoms
Media Atoms
For best compatibility with earlier players, if an extended language tag is specified, the most compatible
language code should be specified in the language field of the 'mdhd' atom (for example, "eng" if the
extended language tag is "en-UK"). If there is no reasonably compatible tag, the packed form of 'und' can
be specified in the language code of the 'mdhd' atom.
Type = 'hdlr'
Version
Flags
Component type
Component subtype
Component manufacturer
Component flags
Component name
Variable
84
Movie Atoms
Media Atoms
Type
A 32-bit integer that identifies the atom type; this field must be set to 'hdlr'.
Version
A 1-byte specification of the version of this handler information.
Flags
A 3-byte space for handler information flags. Set this field to 0.
Component type
A four-character code that identifies the type of the handler. Only two values are valid for this field:
'mhlr' for media handlers and 'dhlr' for data handlers.
Component subtype
A four-character code that identifies the type of the media handler or data handler. For media handlers,
this field defines the type of datafor example, 'vide' for video data, 'soun' for sound data or subt
for subtitles. See Media Data Atom Types (page 155) for information about defined media data types.
For data handlers, this field defines the data reference type; for example, a component subtype value of
'alis' identifies a file alias.
Component manufacturer
Reserved. Set to 0.
Component flags
Reserved. Set to 0.
Component flags mask
Reserved. Set to 0.
Component name
A (counted) string that specifies the name of the componentthat is, the media handler used when this
media was created. This field may contain a zero-length (empty) string.
85
Movie Atoms
Media Atoms
Note: Using Sample Atoms (page 116) discusses how the video media handler locates samples in
a video media.
'vmhd'
'hdlr'
'dinf'
'stbl'
Required atom
The video media information atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this video media information atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'minf'.
Video media information atom
See Video Media Information Header Atoms (page 87).
Handler reference atom
See Handler Reference Atoms (page 84).
Data information atom
See Data Information Atoms (page 92).
Sample table atom
See Sample Table Atoms (page 96).
86
Movie Atoms
Media Atoms
Type = 'vmhd'
Version
Flags
Graphics mode
Opcolor
The video media information header atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this video media information header atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'vmhd'.
Version
A 1-byte specification of the version of this video media information header atom.
Flags
A 3-byte space for video media information flags. There is one defined flag.
No lean ahead
This is a compatibility flag that allows QuickTime to distinguish between movies created with
QuickTime 1.0 and newer movies. You should always set this flag to 1, unless you are creating a
movie intended for playback using version 1.0 of QuickTime. This flags value is 0x0001.
Graphics mode
A 16-bit integer that specifies the transfer mode. The transfer mode specifies which Boolean operation
QuickDraw should perform when drawing or transferring an image from one location to another. See
Graphics Modes (page 333) for a list of graphics modes supported by QuickTime.
87
Movie Atoms
Media Atoms
Opcolor
Three 16-bit values that specify the red, green, and blue colors for the transfer mode operation indicated
in the graphics mode field.
'smhd'
'hdlr'
'dinf'
'stbl'
Required atom
The sound media information atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this sound media information atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'minf'.
Sound media information header atom
See Sound Media Information Header Atoms (page 89).
Handler reference atom
See Handler Reference Atoms (page 84).
Data information atom
See Data Information Atoms (page 92).
Sample table atom
See Sample Table Atoms (page 96).
88
Movie Atoms
Media Atoms
Bytes
Atom size
Type = 'smhd'
Version
Flags
Balance
Reserved
The sound media information header atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this sound media information header atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'smhd'.
Version
A 1-byte specification of the version of this sound media information header atom.
Flags
A 3-byte space for sound media information flags. Set this field to 0.
Balance
A 16-bit integer that specifies the sound balance of this sound media. Sound balance is the setting that
controls the mix of sound between the two speakers of a computer. This field is normally set to 0. See
Balance (page 335) for more information about balance values.
Reserved
Reserved for use by Apple. Set this field to 0.
89
Movie Atoms
Media Atoms
Media types that are derived from the base media handler may add other atoms within the base media
information atom, as appropriate. At present, the only media type that defines additional atoms is timecode
media. See Timed Metadata Media (page 156) and Timecode Media (page 202) for more information about this
media types.
Figure 2-28 The layout of a base media information atom
Base media information atom
Atom size
Type = 'minf'
Base media information header atom
'gmhd'
Required atom
The base media information atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this base media information atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'minf'.
Base media information header atom
See Base Media Information Header Atoms (page 90).
'gmin'
'text'
Required atom
90
Movie Atoms
Media Atoms
The base media information header atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this base media information header atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'gmhd'.
Base media info atom
See Base Media Info Atoms (page 91).
Text media information atom
See Text Media Information Atom (page 209).
Bytes
Atom size
Type = 'gmin'
Version
Flags
Graphics mode
Opcolor
Balance
Reserved
The base media info atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this base media info atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'gmin'.
Version
A 1-byte specification of the version of this base media information header atom.
91
Movie Atoms
Media Atoms
Flags
A 3-byte space for base media information flags. Set this field to 0.
Graphics mode
A 16-bit integer that specifies the transfer mode. The transfer mode specifies which Boolean operation
QuickDraw should perform when drawing or transferring an image from one location to another. See
Graphics Modes (page 333) for more information about graphics modes supported by QuickTime.
Opcolor
Three 16-bit values that specify the red, green, and blue colors for the transfer mode operation indicated
in the graphics mode field.
Balance
A 16-bit integer that specifies the sound balance of this media. Sound balance is the setting that controls
the mix of sound between the two speakers of a computer. This field is normally set to 0. See Balance (page
335) for more information about balance values.
Reserved
Reserved for use by Apple. Set this field to 0.
92
Movie Atoms
Media Atoms
Figure 2-31 (page 93) shows the layout of the data information atom.
Figure 2-31
Type = 'dinf'
Type = 'dref'
Version
Flags
Number of entries
Data references
Size
Type
Version
Flags
Data
Variable
.
.
.
Size
Type
Version
Flags
Data
Variable
93
Movie Atoms
Media Atoms
94
Movie Atoms
Sample Atoms
Flags
A 3-byte space for data reference flags. There is one defined flag.
Self reference
This flag indicates that the medias data is in the same file as the movie atom. On the Macintosh,
and other file systems with multi-fork files, set this flag to 1 even if the data resides in a different
fork from the movie atom. This flags value is 0x0001.
Data
The data reference information.
Table 2-4 (page 95) shows the currently defined data reference types that can be stored in a header atom.
Table 2-4
Data reference
Description
type
'alis'
Data reference is a Macintosh alias. An alias contains information about the file it
refers to, including its full path name.
'rsrc'
Data reference is a Macintosh alias. Appended to the end of the alias is the resource
type (stored as a 32-bit integer) and ID (stored as a 16-bit signed integer) to use
within the specified file. This data reference type is deprecated in the QuickTime
file format. This information is intended to document existing content containing
'rsrc data references and should not be used for new development.
'url '
A C string that specifies a URL. There may be additional data after the C string.
Sample Atoms
QuickTime stores media data in samples. A sample is a single element in a sequence of time-ordered data.
Samples are stored in the media, and they may have varying durations.
95
Movie Atoms
Sample Atoms
Samples are stored in a series of chunks in a media. Chunks are a collection of data samples in a media that
allow optimized data access. A chunk may contain one or more samples. Chunks in a media may have different
sizes, and the individual samples within a chunk may have different sizes from one another, as shown in Figure
2-32 (page 96).
Figure 2-32 Samples in a media
Data stream
Sample 1
Sample 2
Chunk 1
Sample 3
Sample 4
Chunk 2
Sample 5
Sample 6
Chunk 3
Sample 7
Chunk 4
Sample 8
Chunk 5
Sample 9
One way to describe a sample is to use a sample table atom. The sample table atom acts as a storehouse of
information about the samples and contains a number of different types of atoms. The various atoms contain
information that allows the media handler to parse the samples in the proper order. This approach enforces
an ordering of the samples without requiring that the sample data be stored sequentially with respect to movie
time in the actual data stream.
The next section discusses the sample table atom. Subsequent sections discuss each of the atoms that may
reside in a sample table atom.
96
Movie Atoms
Sample Atoms
The sample table atom has an atom type of 'stbl'. It can contain the sample description atom, the
time-to-sample atom, the sync sample atom, the sample-to-chunk atom, the sample size atom, the chunk
offset atom, and the shadow sync atom. Recent additions to the list of atom types that a sample table atom
can contain are the optional sample group description and sample-to-group atoms included in Appendix G:
Audio Priming - Handling Encoder Delay in AAC (page 429).
The sample table atom contains all the time and data indexing of the media samples in a track. Using tables,
it is possible to locate samples in time, determine their type, and determine their size, container, and offset
into that container.
If the track that contains the sample table atom references no data, then the sample table atom does not need
to contain any child atoms (not a very useful media track).
If the track that the sample table atom is contained in does reference data, then the following child atoms are
required: sample description, sample size, sample to chunk, and chunk offset. All of the subtables of the sample
table use the same total sample count.
The sample description atom must contain at least one entry. A sample description atom is required because
it contains the data reference index field that indicates which data reference atom to use to retrieve the media
samples. Without the sample description, it is not possible to determine where the media samples are stored.
The sync sample atom is optional. If the sync sample atom is not present, all samples are implicitly sync samples.
97
Movie Atoms
Sample Atoms
Figure 2-33 (page 98) shows the layout of the sample table atom.
Figure 2-33 The layout of a sample table atom
Sample table atom
Atom size
Type ='stbl'
Sample description atom
'stsd'
Time-to-sample atom
'stts'
'ctts'
'cslg'
'stss'
'stps'
Sample-to-chunk atom
'stsc'
'stsz'
'stco'
'stsh'
'sgpd'
Sample-to-group atom
'sbgp'
'sdtp'
98
Movie Atoms
Sample Atoms
Type = 'stsd'
Version
Flags
Number of entries
Variable
99
Movie Atoms
Sample Atoms
The sample description atom has an atom type of 'stsd'. The sample description atom contains a table of
sample descriptions. A media may have one or more sample descriptions, depending upon the number of
different encoding schemes used in the media and on the number of files used to store the data. The
sample-to-chunk atom identifies the sample description for each sample in the media by specifying the index
into this table for the appropriate description (see Sample-to-Chunk Atoms (page 109)).
The sample description atom contains the following data elements.
Size
A 32-bit integer that specifies the number of bytes in this sample description atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'stsd'.
Version
A 1-byte specification of the version of this sample description atom.
Flags
A 3-byte space for sample description flags. Set this field to 0.
Number of entries
A 32-bit integer containing the number of sample descriptions that follow.
Sample description table
An array of sample descriptions. For details, see General Structure of a Sample Description (page 100).
100
Movie Atoms
Sample Atoms
Time-to-Sample Atoms
Time-to-sample atoms store duration information for a medias samples, providing a mapping from a time in
a media to the corresponding data sample. The time-to-sample atom has an atom type of 'stts'.
You can determine the appropriate sample for any time in a media by examining the time-to-sample atom
table, which is contained in the time-to-sample atom.
The atom contains a compact version of a table that allows indexing from time to sample number. Other tables
provide sample sizes and pointers from the sample number. Each entry in the table gives the number of
consecutive samples with the same time delta, and the delta of those samples. By adding the deltas, a complete
time-to-sample map can be built.
The atom contains time deltas: DT(n+1) = DT(n) + STTS(n) where STTS(n) is the (uncompressed) table
entry for sample n and DT is the display time for sample (n). The sample entries are ordered by time stamps;
therefore, the deltas are all nonnegative. The DT axis has a zero origin; DT(i) = SUM (for j=0 to i-1 of
delta(j)), and the sum of all deltas gives the length of the media in the track (not mapped to the overall
time scale, and not considering any edit list). The edit list atom provides the initial DT value if it is nonempty
(nonzero).
Figure 2-35 (page 101) shows the layout of the time-to-sample atom.
Figure 2-35 The layout of a time-to-sample atom
Bytes
Time-to-sample atom
Atom size
Type = 'stts'
Version
Flags
Number of entries
Time-to-sample table
Variable
101
Movie Atoms
Sample Atoms
Size
A 32-bit integer that specifies the number of bytes in this time-to-sample atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to 'stts'.
Version
A 1-byte specification of the version of this time-to-sample atom.
Flags
A 3-byte space for time-to-sample flags. Set this field to 0.
Number of entries
A 32-bit integer containing the count of entries in the time-to-sample table.
Time-to-sample table
A table that defines the duration of each sample in the media. Each table entry contains a count field
and a duration field. The structure of the time-to-sample table is shown in Figure 2-36 (page 102).
Figure 2-36 The layout of a time-to-sample table entry
Sample count
Sample duration
Field
Bytes
102
Movie Atoms
Sample Atoms
Figure 2-37 (page 103) presents an example of a time-to-sample table that is based on the chunked media data
shown in Figure 2-32 (page 96). That data stream contains a total of nine samples that correspond in count
and duration to the entries of the table shown here. Even though samples 4, 5, and 6 are in the same chunk,
sample 4 has a duration of 3, and samples 5 and 6 have a duration of 2.
Figure 2-37 An example of a time-to-sample table
Sample
count
Sample
duration
If the decode and presentation orders are the same, no composition offset atom will be present. The
time-to-sample atom provides both the decode and presentation ordering of the video stream, and allows
calculation of the start and end times.
If video samples are stored out of presentation order, the time-to-sample atom provides the decode order
and the composition offset atom provides the time of presentation for the decoded samples expressed
as a delta on a sample-by-sample basis.
Note: Decode time does not directly imply presentation time when working with out of order video
samples. The ordering is significant.
The composition offset atom contains a sample-by-sample mapping of the decode-to-presentation time. Each
entry in the composition offset table is a time delta from decode to presentation time: CT(n) = DT(n) + CTTS(n)
where CTTS(n) is the (uncompressed) table entry for sample n DT is the decode time and CT is the composition
(or display) time. The delta expressed in the composition offset table can be positive or negative.
When the time-to-sample atom and the composition offset atom are present, a reader parsing out-of-order
video samples has all the information necessary to calculate the start and end times, as well as the minimum
and maximum offsets between decode time and presentation time. The sample tables are scanned to obtain
these values.
103
Movie Atoms
Sample Atoms
Note: At the last displayed frame, the decode duration is used as presentation duration.
Type = 'ctts'
Version
Flags
Entry count
Composition-offset table
variable
Size
A 32-bit integer that specifies the number of bytes in the composition offset atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to ctts.
Version
A 1-byte specification of the version of this atom.
Flags
A 3-byte space reserved for offset flags. Set this field to 0.
104
Movie Atoms
Sample Atoms
Entry count
A 32-bit unsigned integer that specifies the number of sample numbers in the array that follows.
Following the entry count is a composition-offset table, shown in Figure 2-39 (page 105).
Figure 2-39 The layout of a composition-offset table entry
SampleCount
compositionOffset
Field
Bytes
sampleCount
A 32-bit unsigned integer that provides the number of consecutive samples with the calculated
composition offset in the field.
compositionOffset
A 32-bit signed integer indicating the value of the calculated compositionOffset.
Type = 'cslg'
Version
Flags
compositionOffsetToDisplayOffsetShift
leastDisplayOffset
displayStartTime
displayEndTime
105
Movie Atoms
Sample Atoms
Size
A 32-bit integer that specifies the number of bytes in the composition shift least greatest atom atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to cslg.
Version
A 1-byte specification of the version of this atom.
Flags
A 3-byte space reserved for flags. Set this field to 0.
compositionOffsetToDisplayOffsetShift
A 32-bit unsigned integer that specifies the calculated value.
leastDisplayOffset
A 32-bit signed integer that specifies the calculated value.
greatestDisplayOffset
A 32-bit signed integer that specifies the calculated value.
displayStartTime
A 32-bit signed integer that specifies the calculated value.
displayEndTime
A 32-bit signed integer that specifies the calculated value.
These values are stored in a composition shift least greatest atom within the sample table atom.
Then a composition offset table atom should be written that stores the display offsets, adjusting each offset
by subtracting compositionOffsetToDisplayOffsetShift:
compositionOffset[n] = displayOffset[n] - compositionOffsetToDisplayOffsetShift;
106
Movie Atoms
Sample Atoms
Note: If a composition shift least greatest atom is not present, a reader must assume
compositionOffsetToDisplayOffsetShift = 0. The sample tables will need to be scanned
to find the least and greatest offsets, as well as the presentation start and end times, to determine
the decode time offset required for presentation.
Type = 'stss'
Version
Flags
Number of entries
Variable
107
Movie Atoms
Sample Atoms
Version
A 1-byte specification of the version of this sync sample atom.
Flags
A 3-byte space for sync sample flags. Set this field to 0.
Number of entries
A 32-bit integer containing the count of entries in the sync sample table.
Sync sample table
A table of sample numbers; each sample number corresponds to a key frame. Figure 2-42 (page 108)
shows the layout of the sync sample table.
Figure 2-42 The layout of a sync sample table
Number
Sample 1
Number
Sample 2
Number
Sample 3
Number
Sample 4
Number
Sample 5
Type = 'stps'
Version
Flags
Entry count
variable
108
Movie Atoms
Sample Atoms
Size
A 32-bit integer that specifies the number of bytes in the partial sync sample atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to stps.
Version
A 1-byte specification of the version of this atom.
Flags
A 3-byte space reserved for flags. Set this field to 0.
Entry count
A 32-bit unsigned integer that specifies the number of sample numbers in the array that follows.
Partial sync sample table
A table of sample numbers. Figure 2-44 (page 109) shows the layout of the partial sync sample table.
Figure 2-44 The layout of a partial sync sample table
Number
Sample 1
Number
Sample 2
Number
Sample 3
Number
Sample 4
Number
Sample 5
Sample-to-Chunk Atoms
As samples are added to a media, they are collected into chunks that allow optimized data access. A chunk
contains one or more samples. Chunks in a media may have different sizes, and the samples within a chunk
may have different sizes. The sample-to-chunk atom stores chunk information for the samples in a media.
Sample-to-chunk atoms have an atom type of 'stsc'. The sample-to-chunk atom contains a table that maps
samples to chunks in the media data stream. By examining the sample-to-chunk atom, you can determine the
chunk that contains a specific sample.
109
Movie Atoms
Sample Atoms
Figure 2-45 (page 110) shows the layout of the sample-to-chunk atom.
Figure 2-45 The layout of a sample-to-chunk atom
Bytes
Sample-to-chunk atom
Atom size
Type = 'stsc'
Version
Flags
Number of entries
Sample-to-chunk table
Variable
Sample description ID
Fields
Bytes
110
Movie Atoms
Sample Atoms
You define a sample-to-chunk table entry by specifying the following data elements.
First chunk
The first chunk number using this table entry.
Samples per chunk
The number of samples in each chunk.
Sample description ID
The identification number associated with the sample description for the sample. For details on sample
description atoms, see Sample Description Atoms (page 99).
Figure 2-47 (page 111) shows an example of a sample-to-chunk table that is based on the data stream shown
in Figure 2-32 (page 96).
Figure 2-47 An example of a sample-to-chunk table
First
chunk
Samples
per chunk
Sample
description ID
23
23
24
Each table entry corresponds to a set of consecutive chunks, each of which contains the same number of
samples. Furthermore, each of the samples in these chunks must use the same sample description. Whenever
the number of samples per chunk or the sample description changes, you must create a new table entry. If all
the chunks have the same number of samples per chunk and use the same sample description, this table has
one entry.
111
Movie Atoms
Sample Atoms
Figure 2-48 (page 112) shows the layout of the sample size atom.
Figure 2-48 The layout of a sample size atom
Bytes
Sample size atom
Atom size
Type = 'stsz'
Version
Flags
Sample size
Number of entries
Variable
112
Movie Atoms
Sample Atoms
Figure 2-49 (page 113) shows the layout of an arbitrary sample size table.
Figure 2-49 An example of a sample size table
Size
Sample 1
Size
Sample 2
Size
Sample 3
Size
Sample 4
Size
Sample 5
113
Movie Atoms
Sample Atoms
Note: The sample table atom can contain a 64-bit chunk offset atom (STChunkOffset64AID =
'co64'). When this atom appears, it is used in place of the original chunk offset atom, which can
contain only 32-bit offsets. When QuickTime writes movie files, it uses the 64-bit chunk offset atom
only if there are chunks that use the high 32-bits of the chunk offset. Otherwise, the original 32-bit
chunk offset atom is used to ensure compatibility with previous versions of QuickTime.
Figure 2-50 (page 114) shows the layout of a chunk offset atom.
Figure 2-50 The layout of a chunk offset atom
Bytes
Chunk offset atom
Atom size
Type = 'stco'
Version
Flags
Number of entries
Variable
114
Movie Atoms
Sample Atoms
Figure 2-51 (page 115) shows the layout of an arbitrary chunk offset table.
Figure 2-51
Chunk 1
Offset
Chunk 2
Offset
Chunk 3
Offset
Chunk 4
Offset
Chunk 5
Type = 'sdtp'
Version
Flags
variable
Size
A 32-bit integer that specifies the number of bytes in the sample dependency flags atom.
Type
A 32-bit integer that identifies the atom type; this field must be set to sdtp.
Version
A 1-byte specification of the version of this atom.
Flags
A 3-byte space reserved for flags. Set this field to 0.
115
Movie Atoms
Sample Atoms
Sample 1
Flags
Sample 2
Flags
Sample 3
Flags
Sample 4
Flags
Sample 5
//
kQTSampleDependency_OtherSamplesDependOnThisSample = 1<<2,
kQTSampleDependency_ThereIsNoRedundantCodingInThisSample = 1<<1,
kQTSampleDependency_ThereIsRedundantCodingInThisSample = 1<<0
};
116
Movie Atoms
Compressed Movie Resources
Finding a Sample
When QuickTime displays a movie or track, it directs the appropriate media handler to access the media data
for a particular time. The media handler must correctly interpret the data stream to retrieve the requested
data. In the case of video media, the media handler traverses several atoms to find the location and size of a
sample for a given media time.
The media handler performs the following steps:
1.
2.
Examines the time-to-sample atom to determine the sample number that contains the data for the specified
time.
3.
Scans the sample-to-chunk atom to discover which chunk contains the sample in question.
4.
Extracts the offset to the chunk from the chunk offset atom.
5.
Finds the offset within the chunk and the samples size by using the sample size atom.
Examines the time-to-sample atom to determine the sample number that contains the data for the specified
time.
2.
Scans the sync sample atom to find the key frame that precedes the sample number chosen in step 1.
3.
Scans the sample-to-chunk atom to discover which chunk contains the key frame.
4.
Extracts the offset to the chunk from the chunk offset atom.
5.
Finds the offset within the chunk and the samples size by using the sample size atom.
117
Movie Atoms
Compressed Movie Resources
Compressing movie resources using data compression typically reduces the size of the movie resource by 50%
or more. For QuickTime movies that are streamed over the Internet, this can substantially reduce the startup
latency of the movie, and therefore has a number of distinct advantages.
Atom type
Four-character code
Movie
'moov'
Compressed movie
'cmov'
'dcom'
'cmvd'
32-bit integer
Uncompressed size
118
Movie Atoms
Reference Movies
Reference Movies
A QuickTime movie can act as a container for a set of alternate movies that should be displayed under specified
conditions. One of these movies may be contained within the same file; any others are included by reference.
For example, a QuickTime movie can contain a list of references to movies having different data rates, allowing
an application to choose the best-looking movie that can play smoothly as it downloads over the Internet,
based on the users connection speed.
A movie that contains references to alternate movies is called a reference movie.
A reference movie contains a reference movie atom ('rmra') at the top level of the movie atom as shown in
Figure 2-54 (page 119). The movie atom may also contain a movie header atom, or it may contain the reference
movie atom alone.
Figure 2-54 A movie atom containing a 'rmra' atom instead of a 'mvhd' atom
Movie atom
Atom size
Type = 'moov'
Reference movie atom
'rmra'
The reference movie atom contains one or more reference movie descriptor atoms, each of which describes
an alternate movie.
Each reference movie descriptor atom contains a data reference atom, which specifies the location of a movie.
Note: Movie locations are specified using QuickTime data references. QuickTime supports multiple
types of data reference, but alternate movies are generally specified using data reference types of
either url ('url ') or file alias ('alis').
A reference movie descriptor atom may contain other atoms that specify the movies system requirements
and the movie quality. If so, there will be an atom of an appropriate type for each requirement that must be
met for the movie to play, and there may be a quality atom as well.
119
Movie Atoms
Reference Movies
Applications should play the highest-quality movie whose requirements are met by the users system. If the
data reference to the selected movie cannot be resolvedbecause the file cannot be found, for examplethe
application should recursively attempt to play the next-highest-quality movie until it succeeds or has exhausted
the list of movies whose requirements are met.
If a movie contains both a reference movie atom and a movie header atom, applications should play the
appropriate movie indicated by the reference movie atom.
If the users system does not meet any of the alternate movies criteria, or none of the qualifying data references
can be resolved, applications should play the movie defined in the movie header atom. (The movie defined in
the movie header atom can also be indicated by one of the alternate movie references.)
The movie header atom is sometimes used to provide a fallback movie for applications that can play older
QuickTime movies but do not understand reference movies.
When parsing a reference movie, the reader should treat the URL or file reference in the reference movie atom
as a new starting point, making no assumptions that the reference is a valid URL, or an existing file, or a
well-formed and playable QuickTime movie.
'rmda'
'rmda'
'rmda'
120
Movie Atoms
Reference Movies
Size
The number of bytes in this reference movie atom.
Type
The type of this atom; this field must be set to 'rmra'.
Reference movie descriptor atom
A reference movie atom must contain at least one reference movie descriptor atom, and typically contains
more than one. See Reference Movie Descriptor Atom (page 121) for more information.
'rdrf'
'rmdr'
'rmcs'
'rmvc'
'rmcd'
Quality atom
'rmqu'
121
Movie Atoms
Reference Movies
122
Movie Atoms
Reference Movies
'moov' atom must contain both a 'rmra' atom and a 'mvhd' atom. To resolve this data
reference, an application uses the movie defined in the movie header atom, ignoring the remainder
of the fields in this data reference atom, which are used only to specify external movies.
Data reference type
The data reference type. A value of 'alis' indicates a file system alias record. A value of 'url ' indicates
a string containing a uniform resource locator. Note that the fourth character in 'url ' is an ASCII blank
(0x20).
Data reference size
The size of the data reference in bytes, expressed as a 32-bit integer.
Data reference
A data reference to a QuickTime movie, or to a stream or file that QuickTime can play. If the reference
type is 'alis' this field contains the contents of an AliasHandle. If the reference type is 'url ' this
field contains a NULL-terminated string that can be interpreted as a URL. The URL can be absolute or
relative, and can specify any protocol that QuickTime supports, including http://, ftp://, rtsp://,
file:///, and data:.
123
Movie Atoms
Reference Movies
124
Movie Atoms
Reference Movies
Size
The number of bytes in this version check atom.
Type
The type of this atom; this field must be set to 'rmvc'.
Flags
A 32-bit integer that is currently always 0.
Software package
A 32-bit Gestalt type, such as 'qtim', specifying the software package to check for.
Version
An unsigned 32-bit integer containing either the minimum required version or the required value after
a binary AND operation.
Mask
The mask for a binary AND operation on the Gestalt bitfield.
Check type
The type of check to perform, expressed as 16-bit integer. Set to 0 for a minimum version check, set to
1 for a required value after a binary AND of the Gestalt bitfield and the mask.
125
Movie Atoms
Reference Movies
Minimum version
An unsigned 32-bit integer containing the minimum required version of the specified component.
componentType;
OSType
componentSubType;
OSType
componentManufacturer;
unsigned long
componentFlags;
unsigned long
componentFlagsMask;
};
componentType
A four-character code that identifies the subtype of the component. For example, the subtype of an
image compressor component indicates the compression algorithm employed by the compressor. A
value of 0 matches any subtype.
componentManufacturer
A four-character code that identifies the manufacturer of the component. Components provided by Apple
have a manufacturer value of 'appl'. A value of 0 matches any manufacturer.
componentFlags
A 32-bit field that contains flags describing required component capabilities. The high-order 8 bits should
be set to 0. The low-order 24 bits are specific to each component type. These flags can be used to indicate
the presence of features or capabilities in a given component.
componentFlagsMask
A 32-bit field that indicates which flags in the componentFlags field are relevant to this operation. For
each flag in the componentFlags field that is to be considered as a search criterion, set the corresponding
bit in this field to 1. To ignore a flag, set the bit to 0.
126
Movie Atoms
Reference Movies
Set this bit if a movie import component must be able to create a movie from a file without having to
write to a separate disk file. Examples include MPEG and AIFF import components.
movieImportSubTypeIsFileExtension
Set this bit if the component's subtype is a file extension instead of a Macintosh file type. For example,
if you require an import component that opens files with an extension of .doc, set this flag and set your
component subtype to 'DOC '.
canMovieImportFiles
Quality Atom
A quality atom describes the relative quality of a movie. This acts as a tiebreaker if more than one movie meets
the specified requirements, and it is not otherwise obvious which movie should be played.
This would be the case if two qualified movies have the same data rate and CPU speed requirements, for
example, or if one movie requires a higher data rate and another requires a higher CPU speed, but both can
be played on the current system. In these cases, applications should play the movie with the highest quality,
as specified in the quality atom.
Only one quality atom is allowed in a given reference movie descriptor atom.
A quality atom may contain the following fields:
Size
The number of bytes in this quality atom.
Type
The type of this atom; this field must be set to 'rmqu'.
Quality
The relative quality of the movie, expressed as a 32-bit integer. A larger number indicates higher quality.
A unique value should be given to each movie.
127
Metadata
This chapter describes how to store metadata in QuickTime Movie files. It also defines keys for some common
metadata types as examples of how to employ the metadata capabilities in the QuickTime file format.
Overview
Metadata can be defined as useful information related to media. This section describes a method of associating
metadata with media in a QuickTime file that is extensible and allows for language and country tagging. In
addition, it provides a means to store the type of the metadata and associate a name with metadata. This
method of storing metadata is supported in both QuickTime 7 and QuickTime X.
This metadata format uses a keyvalue pair for each type of metadata being stored. Standard keys, with specific
formats for the values they indicate, have been defined. See QuickTime Metadata Keys (page 145) for details.
Note: The QuickTime file format also defines user data which, in some limited cases, can be used
to store metadata. The method of storing metadata defined in this section provides an extensible
and flexible design for handling a wide variety of metadata types.
Data Type
The storage type of metadata items is defined via an enumerated list of data types, defined statically; an
example might be plain Unicode text. See the Well-Known Types (page 143) table for details of the standard,
defined data types.
Meaning or Purpose
The meaning of a metadata item identifies what it represents: a copyright notice, the performers name, and
so on. It uses an extensible namespace allowing for meanings or keys to be added, and then referenced, from
metadata items. These keys may be four-character codes, names in reverse-address format (such as
com.apple.quicktime.windowlocation) or any other key format including native formats from external metadata
standards. A key is tagged with its namespace allowing for extension in the future. It is recommended that
reverse-address format be used in the general case: this provides an extensible syntax for vendor data or for
other organizations or standards bodies.
128
Metadata
Metadata Structure
Data Location
Metadata is stored immediately in the corresponding atom structures, by value.
Localization
A metadata item can be identified as specific to a country or set of countries, to a language or set of languages,
or to some combination of languages and countries. This identification allows for a default value (suitable for
any language or country not explicitly called out), a single value, or a list of values.
Metadata Structure
The container for metadata is an atom of type meta. The metadata atom must contain the following subatoms:
metadata handler atom (hdlr), metadata item keys atom (keys), and metadata item list atom (ilst).
Other optional atoms that may be contained in a metadata atom include the country list atom (ctry),
language list atom (lang) and free space atom (free). The country list and language list atoms can be
used to store localized data in an efficient manner. The free space atom may be used to reserve space in a
metadata atom for later additions to it, or to zero out bytes within a metadata atom after editing and removing
elements from it. The free space atom may not occur within any other subatom contained in the metadata
atom.
Metadata Atom
The metadata atom is the container for carrying metadata.
129
Metadata
Metadata Structure
Figure 3-1 (page 130) shows a sample layout for this atom.
Figure 3-1
'hdlr'
'mhdr'
'keys'
'ilst'
'data'
'itif'
Name atom
'name'
'ctry'
'lang'
Required
Optional
130
Metadata
Metadata Structure
Predefined
A 32-bit integer that is set to 0
Handler type
A 32-bit integer that indicates the structure used in the metadata atom, set to mdta
Reserved
An array of 3 const unsigned 32-bit integers set to 0
Name
The name is a NULL-terminated string in UTF-8 characters which gives a human-readable name for a
metadata type, for debugging and inspection purposes. The string may be empty or a single byte
containing 0.
Note: A reader parsing a metadata atom should confirm the handler type in the metadata handler
atom is mdta before interpreting any other structures in the metadata atom according to the
specification presented here. If the handler type is not mdta, the interpretation is defined by
another specification.
131
Metadata
Extensibility
Type
A 32-bit unsigned integer value set to 'mdhr'
Version
One byte that is set to 0.
Flags
Three bytes that are set to 0.
nextItemID
A 32-bit unsigned integer indicating the value to use for the item ID of the next item created or assigned
an item ID. If the value is all ones, it indicates that future additions will require a search for an unused
item ID.
Note: If the last metadata item with an item information atom is removed and value of nextItemID
is 0xFFFFFFFF, an implementation may reset the metadata header atoms nextItemID value to 0 so
that new assignments are again efficient (that is, they do not require a search for unused identifiers).
Extensibility
In order to allow metadata to be rewritten easily and without the need to rewrite the entire QuickTime movie
file, free space atoms may occur anywhere in the definition of the metadata atom between the positions of
other atoms contained by the metadata atom. Free space atoms may not be inserted between items in the
metadata item list atom or within atoms in the metadata item list atom. This restriction on free space atom
definition avoids the risk of confusing a free space atom with a meaning of a free identifier or a value atom
of type free defined in the context of the metadata atom structure.
Similarly, UUID atoms for specific extensions may be placed in any position where a succession of atoms is
permitted. Note that UUID atoms should not be created for atoms already defined using four-character codes.
Unrecognized atoms (that is, those atoms whose types not defined in the context of the metadata atom
structure and are contained within the metadata item list atom) are ignored.
132
Metadata
Country List Atom
Currently, there is a limit of 255 countries that may be recorded in a country list atom.
An example country list atom consisting of two country lists with two and three countries, respectively, is
shown in Table 3-1 (page 133).
Table 3-1
Field Size
Field
Field Contents
Comment
32-bit
atom_size
26
133
Metadata
Language List Atom
Field Size
Field
Field Contents
Comment
32-bit
atom_type
'ctry
32-bit
entry_count
16-bit
country_count
16-bit
country
'US
16-bit
country
'UK
16-bit
country_count
16-bit
country
'JP
16-bit
country
'US
16-bit
country
'FR
134
Metadata
Metadata Item Keys Atom
Language_count
A 16-bit integer indicating the number of languages in the array.
Language[Language_count]
An array of 16-bit integers, defined according to the ISO 639-2/T definition of language codes.
Note that:
Currently, there is a limit of 255 languages that may be recorded in a Language List atom.
Table 3-2 (page 135) shows an example Language List atom consisting of two language lists with three and
two languages, respectively.
Table 3-2
Field Size
Field
Field Contents
Comment
32-bit
atom_size
26
32-bit
atom_type
'lang
32-bit
entry_count
16-bit
language_count
16-bit
language
5575
16-bit
language
6721
16-bit
language
4277
16-bit
language_count
16-bit
language
19969
16-bit
language
16882
135
Metadata
Metadata Item Keys Atom
Indexes into the metadata item keys atom are 1-based (1entry_count).
136
Metadata
Metadata Item List Atom
Figure 3-2 (page 137) shows a sample layout for this atom.
Figure 3-2
Equals 4 in
this example
Key 1 definition
size
namespace
value
Key 2 definition
size
namespace
value
Key 3 definition
size
namespace
value
Key 4 definition
size
namespace
value
Figure 3-3 (page 137) shows an example of a metadata item keys atom consisting of three keys: two from one
key namespace and a third from another key namespace.
Figure 3-3
key_namespace (uint32)
key_value (uint8[ ])
38
mdta
com.apple.quicktime.copyright
35
mdta
com.apple.quicktime.author
12
udta
cpy
137
Metadata
Metadata Item Atom
Data
the_type
the_locale
value[ ]
name
entry_count = 4
key_index 4
the_locale
key 1
itif
Data
the_type
Keys
value[ ]
key 2
name
key 3
key 4
key_index 1
itif
Data
the_type
the_locale
value[ ]
name
Required
Optional
138
Metadata
Value Atom
Value Atom
The value of the metadata item is expressed as immediate data in a value atom. The value atom starts with
two fields: a type indicator, and a locale indicator. Both the type and locale indicators are four bytes long. There
may be multiple value entries, using different type, country or language codes (see the Data Ordering section
below for the required ordering).
The Value atom structure contains the following fields:
Type
A type indicator, defined in Type Indicator (page 139).
Locale
A locale indicator, defined in Locale Indicator (page 139).
Type Indicator
The type indicator is formed of four bytes split between two fields. The first byte indicates the set of types from
which the type is drawn. The second through fourth byte forms the second field and its interpretation depends
upon the value in the first field.
The indicator byte must have a value of 0, meaning the type is drawn from the well-known set of types. All
other values are reserved.
If the type indicator byte is 0, the following 24 bits hold the well-known type. Please refer to the list of
Well-Known Types, in the Well-Known Types section below.
Locale Indicator
The locale indicator is formatted as a four-byte value. It is formed from two two-byte values: a country indicator,
and a language indicator. In each case, the two-byte field has the possible values shown in Table 3-3 (page
139).
Table 3-3
Value
Meaning
This atom provides the default value of this datum for any locale not explicitly listed.
1 to 255
The value is an index into the country or language list (the upper byte is 0).
139
Metadata
Locale Indicator
Value
Meaning
otherwise
The value is an ISO 3166 code (for the country code) or a packed ISO 639-2/T code (for
the language).
Note that both ISO 3166 and ISO 639-2/T codes have a nonzero value in their top byte, and so will have a value
> 255.
Software applications that read metadata may be customized for a specific set of countries or languages. If a
metadata writer does not want to limit a metadata item to a specific set of countries, it should use the reserved
value ZZ from ISO 3166 as its country code. Similarly if the metadata writer does not want to limit the users
language (this is not recommended) it uses the value und (undetermined) from the ISO 639-2/T specification.
A software application matches a country code if either (a) the value to be matched to is 0 (default) or (b) the
codes are equal. A software application matches to a list of codes if its value is a member of that list. A software
application matches to a locale if both country and language match.
Table 3-4 (page 140) shows some example metadata tags.
Table 3-4
Country
Language
Meaning
eng
GB
CA
fra
DE,GB,FR,IT
DE,GB,FR,IT
deu,fra
To reiterate, if the country_indicator value is in the range 1 to 255, it is interpreted as the 1-based index for a
country list in the Country Language atom in the Metadata atom. If the language_indicator value is in the
range 1 to 255, it is interpreted as the 1-based index for a language list in the Language List atom in the
Metadata atom. Otherwise, the country_indicator or language_indicator is unspecified (0) or holds the immediate
value for a single country or language.
140
Metadata
Item Information Atom (ID and flags)
Name
The Name atom is a full atom with an atom type of name. This atom contains a metadata name formatted as
a string of UTF-8 characters, to fill the atom. It is optional. If it is not present, the item is unnamed, and cannot
be referred to by name. Names are not user visible; they provide a way to refer to metadata items. The maximum
length of a name may be limited in specific environments.
No two metadata items may have the same name.
This atom has the following structure:
Version
One byte that is set to 0.
Flags
Three bytes that are set to 0.
141
Metadata
Data Atom Structure
Name
An array of bytes, constituting a UTF-8 string, containing the name.
Data Ordering
Multiple values for the same tag represent multiple representations of the same information, differing either
by language or storage type or by the size or nature of the data. For example, an artist name may be supplied
in three ways:
as text
An application may then choose the variation of the the artist name to display based on the size it needs.
Data must be ordered in each item from the most-specific data to the most general. An application may, if it
wishes, stop searching for a value once it finds a value that it can display (it has an acceptable locale and
type).
142
Metadata
Well-Known Types
Well-Known Types
The basic data-type list is in Table 3-5 (page 143).
Table 3-5
Code
Type
Comment
reserved
UTF-8
UTF-16
S/JIS
UTF-8 sort
UTF-16 sort
13
JPEG
In a JFIF wrapper
14
PNG
In a PNG wrapper
21
BE Signed Integer
22
BE Unsigned Integer
23
BE Float32
24
BE Float64
27
BMP
28
QuickTime Metadata
atom
65
66
143
Metadata
Well-Known Types
Code
Type
Comment
67
70
BE PointF32
71
BE DimensionsF32
72
BE RectF32
74
75
76
BE 16-bit Unsigned
Integer
77
BE 32-bit Unsigned
Integer
78
BE 64-bit Unsigned
Integer
79
AffineTransformF64
The sorting variant of text is used for languages in which sorting is not evident from the written form (for
example, some forms of Asian languages). In these cases, the sorting can only be performed by a human who
can identify the actual words by understanding the context. For these languages, an alternative form of the
same information can be stored using a different representation of the same text which can be machine sorted.
144
Metadata
Location Metadata
This alternative representation is still sorted according to the sort rules of the language in question, as defined
for the text system in use (for example, Unicode). In general, a simple lexical sorting which compares the values
of the characters alone is not sufficient.
Location Metadata
Many systems have the ability to detect or establish their position in a coordinate reference system. The
specification ISO 6709:2008 Standard representation of geographic point location by coordinates describes
one way of storing such information. One of the common systems is the Global Positioning System (GPS)
developed by the US Department of Defense. Other systems include the ability of some cellular telephone
systems to triangulate the position of cell-phones, and the possibility that IEEE 802.11 Wireless Base Stations
are tagged with their position (whereupon mobile units that can see their signal can establish that they are
probably near that location).
This support is increasingly common in still and movie cameras, or composite devices (such as camera-phones)
that can function as cameras.
Apple has defined a key for storing the location coordinates as metadata, as well as several auxiliary pieces of
information about a location. For all the location metadata keys defined in this specification, the Metadata
atom handler-type should be mdta. See the com.apple.quicktime.location.ISO6709 entry in the following
table for a description of the main location metadata key, and the additional table describing auxiliary location
metadata keys.
Metadata keys
Key
Key
Value Payload
Definition
Example
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Album or
collection
name of
which the
movie
content
forms a part.
Technical documents
performed to blues tunes
Volume 1.
Type
com.apple.quicktime.album
'mdta
145
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.artist
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of the
artist who
created the
movie file
content.
com.apple.quicktime.artwork
'mdta
An
representative
image for the
movie content
in a format
such as JPEG
(value type
13), PNG
(value type 14)
or BMP (value
type 27). This
might be
album
artwork, a
movie poster,
etc.
A single
image that
can
represent
the movie
file content.
com.apple.quicktime.author
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of the
author of the
movie file
content.
146
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.comment
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
User entered
comment
regarding
the movie
file content.
com.apple.quicktime.copyright
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Copyright
statement
for the
movie file
content.
com.apple.quicktime.creationdate
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
4/21/2012
com.apple.quicktime.description
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Description
of the movie
file content.
147
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.director
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of the
director of
the movie
content.
Papa Doe
com.apple.quicktime.title
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
The title of
the movie
file content.
This is
typically a
single text
line.
com.apple.quicktime.genre
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Text
describing
the genre or
genres to
which the
movie
content
conforms.
There is no
prescribed
vocabulary
for names of
genres.
Blues
148
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.information
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Information
about the
movie file
content.
com.apple.quicktime.keywords
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Keywords
associated
with the
movie file
content.
com.apple.quicktime.location.ISO6709
'mdta
Defined in ISO
6709:2008.
Geographic
point
location by
coordinates
as defined in
ISO
6709:2008.
"+27.5916+086.5640+8850/
com.apple.quicktime.producer
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of
producer of
movie file
content.
149
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.publisher
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of
publisher of
movie file
content.
com.apple.quicktime.software
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of
software
used to
create the
movie file
content.
Do-the-Blues v2.3
com.apple.quicktime.year
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Year when
the movie
file or the
original
content was
created or
recorded.
2012
com.apple.quicktime.collection.user
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
A name
indicating a
user-defined
collection
that includes
this movie.
150
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
A BE Float32
(value type
23). The range
of this number
is 0.0 to 5.0,
inclusive.
A number,
assigned by
the user, that
indicates the
rating or
relative
value of the
movie. This
number can
range from
0.0 to 5.0. A
value of 0.0
indicates
that the user
has not rated
the movie.
4.5
Type
com.apple.quicktime.rating.user
'mdta
In addition, QuickTime recommends the auxiliary keys shown in Table 3-7 (page 151) for holding additional
metadata to be associated with a location.
Table 3-7
Key
Key
Value Payload
Definition
Example
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Name of the
location.
Sweden or
Grandmothers
house
Type
com.apple.quicktime.location.name
'mdta
151
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.location.body
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
The
astronomical
body, for
compatibility
with the
3GPP format.
'earth' is
assumed if
not present.
earth
com.apple.quicktime.location.note
'mdta
A UTF-8 string
(value type 1).
Can have
multiple
values with
different
language and
country code
designations.
Descriptive
comment.
following a dog
com.apple.quicktime.location.role
'mdta
An unsigned
integer (value
type 22).
A single byte,
binary value
containing a
value from
the set: 0
indicates
shooting
location, 1
indicates
real
location, 2
indicates
fictional
location.
Other values
are reserved.
1, for shooting
location
152
Metadata
QuickTime Metadata Keys
Key
Key
Value Payload
Definition
Example
Type
com.apple.quicktime.location.date
'mdta
Defined in
ISO8601:2004.
A date and
time, stored
using the
extended
format
defined in
ISO
8601:2004Data
elements and
interchange
format.
"2012-02-24T17:56Z"
for a date of February
24, 2012, time of
17:56, UTC.
com.apple.quicktime.direction.facing
'mdta
A UTF-8 string
(value type
1)holding a
machine
readable
direction
value, as
described
below. This
should not be
tagged with a
country or
language
code.
An indication
of the
direction the
camera is
facing during
the shot.
+20.34M/-5.3 for a
heading of 20.34
magnetic, looking or
going down at 5.3
below the
horizontal.
com.apple.quicktime.direction.motion
'mdta
A UTF-8 string
(value type 1)
holding a
machine
readable
direction
value, as
described
below. This
should not be
tagged with a
country or
language
code.
An indication
of the
direction the
camera is
moving
during the
shot.
+20.34M/-5.3 for a
heading of 20.34
magnetic, looking or
going down at 5.3
below the
horizontal.
153
Metadata
Direction Definition
Direction Definition
For the metadata keys which define a direction, com.apple.quicktime.direction.facing and
com.apple.quicktime.direction.motion, directions are specified as a string consisting of one or two angles,
separated by a slash if two occur. The first is a compass direction, expressed in degrees and decimal degrees,
optionally preceded by the characters + or -, and optionally followed by the character M. The direction
is determined as accurately as possible; the nominal due north (zero degrees) is defined as facing along a line
of longitude of the location system, unless the angle is followed by the M character indicating a magnetic
heading. The second is an elevation direction, expressed in degrees and decimal degrees between +90.0 and
-90.0, with 0 being horizontal (level), +90.0 being straight up, and -90.0 being straight down (and for these
two cases, the compass direction is irrelevant).
154
QuickTime uses atoms of different types to store different types of media datavideo media atoms for video
data, sound media atoms for audio data, and so on. This chapter discusses in detail each of these different
media data atom types.
If you are a QuickTime application or tool developer, youll want to read this chapter in order to understand
the fundamentals of how QuickTime uses atoms for storage of different media data. For the latest updates and
postings, be sure to see Apple's QuickTime developer website.
This chapter is divided into the following major sections:
Video Media (page 156) describes video media, which is used to store compressed and uncompressed
image data in QuickTime movies.
Sound Media (page 177) discusses sound media used to store compressed and uncompressed audio data
in QuickTime movies.
Timed Metadata Media (page 190) discusses time-based metadata media in QuickTime movies.
Timecode Media (page 202) describes time code media used to store time code data in QuickTime movies.
Text Media (page 205) discusses text media used to store text data in QuickTime movies.
Closed Captioning Media (page 211) discusses text media used to store CEA-608 closed captioning data
in QuickTime movies.
Subtitle Media (page 213) discusses tx3g text media used to store subtitle data in QuickTime movies.
Music Media (page 220) discusses music media used to store note-based audio data, such as MIDI data, in
QuickTime movies.
MPEG-1 Media (page 220) discusses MPEG-1 media used to store MPEG-1 video and MPEG-1 multiplexed
audio/video streams in QuickTime movies.
Sprite Media (page 221) discusses sprite media used to store character-based animation data in QuickTime
movies.
Tween Media (page 247) discusses tween media used to interpolate between pairs of stored values.
Track References (page 260) describes a feature of QuickTime that allows you to relate a movies tracks to
one another.
3D Media (page 261) discusses briefly how QuickTime movies store 3D image data in a base media.
155
Streaming Media (page 262) describes how streaming media is stored in a QuickTime file.
Hint Media (page 263) describes the additions to the QuickTime file format for streaming QuickTime movies
over the Internet.
VR Media (page 279) describes the QuickTime VR world and node information atom containers, as well as
cubic panoramas, which are new to QuickTime VR 3.0.
Movie Media (page 322) discusses movie media which is used to encapsulate embedded movies within
QuickTime movies.
Video Media
Video media is used to store compressed and uncompressed image data in QuickTime movies. It has a media
type of 'vide'.
The data format field of a video sample description indicates the type of compression that was used to compress
the image data, or the color space representation of uncompressed video data. Table 4-1 (page 156) shows
some of the formats supported. The list is not exhaustive, and is subject to addition.
Table 4-1
Compression type
Description
'cvid'
Cinepak
'jpeg'
JPEG
'smc '
Graphics
156
Compression type
Description
'rle '
Animation
'rpza'
Apple video
'kpcd'
Kodak Photo CD
'png '
'mjpa'
Motion-JPEG (format A)
'mjpb'
Motion-JPEG (format B)
'SVQ1'
'SVQ3'
Sorenson video 3
'mp4v'
MPEG-4 video
'avc1'
H.264 video
'dvc '
'dvcp'
'gif '
'h263'
H.263 video
'tiff'
'raw '
Uncompressed RGB
'2vuY
'yuv2'
'v308'
'v408'
'v216'
'v410'
'v210'
157
The video media sample description adds the following fields to the general sample description.
Version
A 16-bit integer indicating the version number of the compressed data. This is set to 0, unless a compressor
has changed its data format.
Revision level
A 16-bit integer that must be set to 0.
Vendor
A 32-bit integer that specifies the developer of the compressor that generated the compressed data.
Often this field contains 'appl' to indicate Apple, Inc.
Temporal quality
A 32-bit integer containing a value from 0 to 1023 indicating the degree of temporal compression.
Spatial quality
A 32-bit integer containing a value from 0 to 1024 indicating the degree of spatial compression.
Width
A 16-bit integer that specifies the width of the source image in pixels.
Height
A 16-bit integer that specifies the height of the source image in pixels.
Horizontal resolution
A 32-bit fixed-point number containing the horizontal resolution of the image in pixels per inch.
Vertical resolution
A 32-bit fixed-point number containing the vertical resolution of the image in pixels per inch.
Data size
A 32-bit integer that must be set to 0.
Frame count
A 16-bit integer that indicates how many frames of compressed data are stored in each sample. Usually
set to 1.
Compressor name
A 32-byte Pascal string containing the name of the compressor that created the image, such as "jpeg".
Depth
A 16-bit integer that indicates the pixel depth of the compressed image. Values of 1, 2, 4, 8 ,16, 24, and
32 indicate the depth of color images. The value 32 should be used only if the image contains an alpha
channel. Values of 34, 36, and 40 indicate 2-, 4-, and 8-bit grayscale, respectively, for grayscale images.
158
Color table ID
A 16-bit integer that identifies which color table to use. If this field is set to 1, the default color table
should be used for the specified depth. For all depths below 16 bits per pixel, this indicates a standard
Macintosh color table for the specified depth. Depths of 16, 24, and 32 have no color table.
If the color table ID is set to 0, a color table is contained within the sample description itself. The color
table immediately follows the color table ID field in the sample description. See Color Table Atoms (page
46) for a complete description of a color table.
type
'gama'
A 32-bit fixed-point number indicating the gamma level at which the image was
captured. The decompressor can use this value to gamma-correct at display time.
'fiel'
Two 8-bit integers that define field handling. This information is used by applications
to modify decompressed image data or by decompressor components to determine
field display order. This extension is mandatory for all uncompressed YCbCr data
formats. The first byte specifies the field count, and may be set to 1 or 2. A value of 1
is used for progressive-scan images; a value of 2 indicates interlaced images. When the
field count is 2, the second byte specifies the field ordering: which field contains the
topmost scan-line, which field should be displayed earliest, and which is stored first in
each sample. Each sample consists of two distinct compressed images, each coding
one field: the field with the topmost scan-line, T, and the other field, B. The following
defines the permitted variants: 0 There is only one field. 1 T is displayed earliest, T
is stored first in the file. 6 B is displayed earliest, B is stored first in the file. 9 B is
displayed earliest, T is stored first in the file. 14 T is displayed earliest, B is stored first
in the file.
'mjqt'
'mjht'
'esds'
An MPEG-4 elementary stream descriptor atom. This extension is required for MPEG-4
video. For details, see MPEG-4 Elementary Stream Descriptor Atom ('esds') (page 161).
159
Extension
Description
type
'avcC'
'pasp'
Pixel aspect ratio. This extension is mandatory for video formats that use non-square
pixels. For details, see Pixel Aspect Ratio ('pasp') (page 160).
'colr'
'clap'
160
Table 4-3
Description
hSpacing
vSpacing
10
11
59
54
40
33
118
81
113
118
1018
1062
Size
An unsigned 32-bit integer holding the size of the elementary stream descriptor atom.
Type
An unsigned 32-bit field containing the four-character code 'esds'
Version
An unsigned 8-bit integer set to zero.
Flags
A 24-bit field reserved for flags, currently set to zero.
Elementary Stream Descriptor
An elementary stream descriptor for MPEG-4 video, as defined in the MPEG-4 specification ISO/IEC 14496-1
and subject to the restrictions for storage in MPEG-4 files specified in ISO/IEC 14496-14.
161
Size
An unsigned 32-bit integer holding the size of the AVC decoder configuration atom.
Type
An unsigned 32-bit field containing the four-character-code 'avcC'.
AVC Decoder Configuration Record
An AVCDecoderConfigurationRecord for H.264 video, as defined in the MPEG-4 specification ISO/IEC
14496-15, and subject to the restrictions for storage in an MPEG-4 file, also specified in ISO/IEC 14496-15.
Color Parameter Atoms ('colr')
This atom is a required extension for uncompressed YCbCr data formats. The 'colr' extension is used to
map the numerical values of pixels in the file to a common representation of color in which images can be
correctly compared, combined, and displayed. The common representation is the CIE XYZ tristimulus values
(defined in Publication CIE No. 15.2).
Use of a common representation also allows you to correctly map between YCbCr and RGB color spaces and
to correctly compensate for gamma on different systems.
The 'colr' extension supersedes the previously defined 'gama' Image Description extension. Writers of
QuickTime files should never write both into an Image Description, and readers of QuickTime files should
ignore 'gama' if 'colr' is present.
The 'colr' extension is designed to work for multiple imaging applications such as video and print. Each
application, driven by its own set of historical and economic realities, has its own set of parameters needed to
map from pixel values to CIE XYZ.
The CIE XYZ representation is mapped to various stored YCbCr formats using a common set of transfer functions
and matrixes. The transfer function coefficients and matrix values are stored as indexes into a table of canonical
references. This provides support for multiple video systems while limiting the scope of possible values to a
set of recognized standards.
162
The 'colr' atom contains four fields: a color parameter type and three indexes. The indexes are to a table of
primaries, a table of transfer function coefficients, and a table of matrixes.
Figure 4-1 (page 163) shows the layout of this atom.
Figure 4-1
Type = 'colr'
Primaries index = 1
Matrix index = 1
The table of matrixes specifies the matrix used during the translation, as shown in Figure 4-2 (page 164).
Color parameter type
A 32-bit field containing a four-character code for the color parameter type. The currently defined types
are 'nclc' for video, and 'prof' for print. The color parameter type distinguishes between print and
video mappings.
If the color parameter type is 'prof', then this field is followed by an ICC profile. This is the color model
used by Apples ColorSync. The contents of this type are not defined in this document. Contact Apple
for more information on the 'prof' type 'colr' extension.
If the color parameter type is 'nclc' then this atom contains the following fields:
Primaries index
A 16-bit unsigned integer containing an index into a table specifying the CIE 1931 xy chromaticity
coordinates of the white point and the red, green, and blue primaries. The table of primaries specifies
the white point and the red, green, and blue primary color points for a video system.
Transfer function index
A 16-bit unsigned integer containing an index into a table specifying the nonlinear transfer function
coefficients used to translate between RGB color space values and YCbCr values. The table of transfer
function coefficients specifies the nonlinear function coefficients used to translate between the stored
YCbCr values and a video capture or display system, as shown in Figure 4-2 (page 164).
163
Matrix index
A 16-bit unsigned integer containing an index into a table specifying the transformation matrix coefficients
used to translate between RGB color space values and YCbCr values. The table of matrixes specifies the
matrix used during the translation, as shown in Figure 4-2 (page 164).
The transfer function and matrix are used as shown in Figure 4-2 (page 164).
Figure 4-2
Numerical
coding
in
QuickTime
file
G
B
EW' = f(W)
EW' = f(W)
EW' = f(W)
ECr
EY'
EG'
ECb
Matrix-1
Matrix
EB'
ER'
EY'
ECb
ER'
EG'
EB'
ECr
W = g(EW')
W = g(EW')
W = g(EW')
Numerical
coding
in
QuickTime
file
R
G
B
Display
circuitry
emits
light
The YCbCr values stored in a file are normalized to a range of [0,1]for Y and [-0.5, +0.5] for Cb and Cr when
performing these operations. The normalized values are then scaled to the proper bit depth for a particular
YCbCr format before storage in the file as shown in Figure 4-3 (page 164).
Figure 4-3
Note: The symbols used for these values are not intended to correspond to the use of these same
symbols in other standards. In particular, "E" should not be interpreted as voltage.
These normalized values can be mapped onto the stored integer values of a particular compression type's Y,
Cb, and Cr components using two different schemes, which we will call Scheme A and Scheme B.
Warning: Other, slightly different encoding/mapping schemes exist in the video industry, and data
encoded using these schemes must be converted to one of the QuickTime schemes defined here.
164
Scheme A uses "Wide-Range" mapping (full scale) with unsigned Y and twos-complement Cb and Cr values
as shown in Figure 4-4 (page 165).
Figure 4-4
This maps normalized values to stored values so that, for example, 8-bit unsigned values for Y go from 0-255
as the normalized value goes from 0 to 1, and 8-bit signed valued for Cb and Cr go from -127 to +127 as the
normalized values go from -0.5 to +0.5.
Warning: In specifications such as ITU-R BT.601-4, JFIF 1.02, and SPIFF (Rec. ITU-T T.84), the symbols
Cb and Cr are used to describe offset binary integers, not twos-complement signed integers shown
here.
Scheme B uses "Video-Range" mapping with unsigned Y and offset binary Cb and Cr values.
Note: Scheme B, shown in Figure 4-5 (page 165), comes from digital video industry specifications
such as Rec. ITU-R BT. 601-4. All standard digital video tape formats (e.g., SMPTE D-1, SMPTE D-5)
and all standard digital video links (e.g., SMPTE 259M-1997 serial digital video) use this scheme.
Professional video storage and processing equipment from vendors such as Abekas, Accom, and SGI
also use this scheme. MPEG-2, DVC and many other codecs specify source YCbCr pixels using this
scheme.
Figure 4-5
This maps the normalized values to stored values so that, for example, 8-bit unsigned values for Y go from 16
to 235 as the normalized value goes from 0 to1, and 8-bit unsigned valued for Cb and Cr go from 16 to 240 as
the normalized values go from -0.5 to +0.5.
For 10-bit samples, Y has a range of 64 to 940 as the normalized value goes from 0 to 1, and Cb and Cr have
the range of 65960 as the normalized values go from 0.5 to +0.5.
Y is an unsigned integer. Cb and Cr are offset binary integers.
165
Certain Y, Cb, and Cr component values v are reserved as synchronization signals and must not appear in a
buffer. For n = 8 bits, these are values 0 and 255. For n = 10 bits, these are values 0, 1, 2, 3, 1020, 1021, 1022,
and 1023. The writer of a QuickTime image is responsible for omitting these values. The reader of a QuickTime
image may assume that they are not present.
The remaining component values that fall outside the mapping for scheme B (1 to 15 and 241 to 254 for n =
8 bits and 4 to 63 and 961 to 1019 for n = 10 bits) accommodate occasional filter undershoot and overshoot
in image processing. In some applications, these values are used to carry other information (e.g., transparency).
The writer of a QuickTime image may use these values and the reader of a QuickTime image must expect these
values.
The following tables show the primary values, transfer functions, and matrixes indicated by the index entries
in the 'colr' atom.
The R, G, and B values in Table 4-4 (page 166) are tristimulus values (such as candelas/meter^2), whose
relationship to CIE XYZ values can be derived from the primaries and white point specified in the table, using
the method described in SMPTE RP 177-1993. In this instance, the R, G, and B values are normalized to the
range [0,1].
Table 4-4
Index
Values
Reserved
34
Reserved
ITU-R BT.709-2, SMPTE 274M-1995, and SMPTE 296M-1997 white x = 0.3127 y = 0.3290 (CIE
III. D65) red x = 0.630 y = 0.340 green x = 0.310 y = 0.595 blue x = 0.155 y = 0.070
765535
Reserved
The transfer functions listed in Table 4-5 (page 167) are used as shown in Figure 4-2 (page 164).
166
Table 4-5
Index
Video Standards
Reserved
36
Reserved
865535
Reserved
The MPEG-2 sequence display extension transfer_sics defines a code 6 whose transfer function is identical
to that in code 1. QuickTime writers should map 6 to 1 when converting from transfer_characteristics
to transferFunction.
Recommendation ITU-R BT.470-4 specified an "assumed gamma value of the receiver for which the primary
signals are pre-corrected" as 2.2 for NTSC and 2.8 for PAL systems. This information is both incomplete and
obsolete. Modern 525- and 625-line digital and NTSC/PAL systems use the transfer function with code 1.
The matrix values are shown in Table 4-6 (page 168) and in Matrix values for index code 1 (page ?). These
figures show a formula for obtaining the normalized value of Y in the range [0,1]. You can derive the formula
for normalized values of Cb and Cr as follows:
If the equation for normalized Y has the form:
EY = KGEG + KBEB+KRER
Then the formulas for normalized Cb and Cr are:
ECb = (0.5/(1-KB))(EB-EY)
ECr = (0.5/(1-KR))(ER-EY)
167
Table 4-6
Index
Video Standard
Reserved
35
Reserved
865535
Reserved
168
These values are given as ratios of two 32-bit numbers, so that applications can calculate precise values with
minimum roundoff error. For whole values, the value should be stored in the numerator field while the
denominator field is set to 1.
Size
A 32-bit unsigned integer containing the size of the 'clap' atom.
Type
A 32-bit unsigned integer containing the four-character code 'clap'.
apertureWidth_N (numerator)
A 32-bit signed integer containing either the width of the clean aperture in pixels or the numerator
portion of a fractional width.
apertureWidth_D (denominator)
A 32-bit signed integer containing either the denominator portion of a fractional width or the number
1.
apertureHeight_N (numerator)
A 32-bit signed integer containing either the height of the clean aperture in picture lines or the numerator
portion of a fractional height.
apertureHeight_D (denominator)
A 32-bit signed integer containing either the denominator portion of a fractional height or the number
1.
horizOff_N (numerator)
A 32-bit signed integer containing either the horizontal offset of the clean aperture center minus
(width1)/2 or the numerator portion of a fractional offset. This value is typically zero.
horizOff_D (denominator)
A 32-bit signed integer containing either the denominator portion of the horizontal offset or the number
1.
vertOff_N (numerator)
A 32-bit signed integer containing either the vertical offset of the clean aperture center minus (height1)/2
or the numerator portion of a fractional offset. This value is typically zero.
vertOff_D (denominator)
A 32-bit signed integer containing either the denominator portion of the vertical offset or the number
1.
169
Uncompressed RGB
Uncompressed RGB data is stored in a variety of different formats. The format used depends on the depth field
of the video sample description. For all depths, the image data is padded on each scan line to ensure that each
scan line begins on an even byte boundary.
For depths of 1, 2, 4, and 8, the values stored are indexes into the color table specified in the color table
ID field.
For a depth of 16, the pixels are stored as 5-5-5 RGB values with the high bit of each 16-bit integer set to
0.
For a depth of 24, the pixels are stored packed together in RGB order.
For a depth of 32, the pixels are stored with an 8-bit alpha channel, followed by 8-bit RGB components.
RGB data can be stored in composite or planar format. Composite format stores the RGB data for each pixel
contiguously, while planar format stores the R, G, and B data separately, so the RGB information for a given
pixel is found using the same offset into multiple tables. For example, the data for two pixels could be
represented in composite format as RGB-RGB or in planar format as RR-GG-BB.
170
The number of components (YCbCr with or without alpha) and any subsampling are denoted using ratios of
three or four numbers, such as 4:2:2 to indicate 4 bits of Y to 2 bits each of Cb and Cr (chroma subsampling),
or 4:4:4 for equal storage of Y, Cb, and Cr (no subsampling), or 4:4:4:4 for YCbCr plus alpha with no subsampling.
The ratios do not typically denote actual bit depths.
Uncompressed YCbCr video data is typically stored as follows:
Y, Cb, and Cr components of each line are stored spatially left to right and temporally from earliest to
latest.
The lines of a field or frame are stored spatially top to bottom and temporally earliest to latest.
The yuv2 stream, for example, is encoded in a series of 4-byte packets. Each packet represents two adjacent
pixels on the same scan line. The bytes within each packet are ordered as follows:
y0 u y1 v
y0 is the luminance value for the left pixel; y1 the luminance for the right pixel. u and v are chromatic values
JPEG
QuickTime stores JPEG images according to the rules described in the ISO JPEG specification, document number
DIS 10918-1.
171
MPEG-4 Video
MPEG-4 video uses the 'mp4v' data format. The sample description requires the elementary stream descriptor
('esds') extension to the standard video sample description. If non-square pixels are used, the pixel aspect
ratio ('pasp') extension is also required. For details on these extensions, see Pixel Aspect Ratio ('pasp') (page
160) and MPEG-4 Elementary Stream Descriptor Atom ('esds') (page 161).
MPEG-4 video conforms to ISO/IEC documents 14496-1/2000(E) and 14496-2:1999/Amd.1:2000(E).
Motion-JPEG
Motion-JPEG (M-JPEG) is a variant of the ISO JPEG specification for use with digital video streams. Instead of
compressing an entire image into a single bitstream, Motion-JPEG compresses each video field separately,
returning the resulting JPEG bitstreams consecutively in a single frame.
172
There are two flavors of Motion-JPEG currently in use. These two formats differ based on their use of markers.
Motion-JPEG format A supports markers; Motion-JPEG format B does not. The following paragraphs describe
how QuickTime stores Motion-JPEG sample data. Figure 4-6 (page 173) shows an example of Motion-JPEG A
dual-field sample data. Figure 4-7 (page 175) shows an example of Motion- JPEG B dual-field sample data.
Figure 4-6
FF D8
FF E1
00 2A
00 00 00 00
6D 6A 70 67
Field size
Byte
offsets
from
start
of
field
FF DB 00 84 .. ..
FF C4 01 A2 .. ..
FF C0 00 11 .. ..
FF DA 00 0C
.. .. .. ..
FF D9
FF FF FF
FF D8
00 00 00 00
Each field of Motion-JPEG format A fully complies with the ISO JPEG specification, and therefore supports
application markers. QuickTime uses the APP1 marker to store control information, as follows (all of the fields
are 32-bit integers):
173
Reserved
Unpredictable; should be set to 0.
Tag
Identifies the data type; this field must be set to 'mjpg'.
Field size
The actual size of the image data for this field, in bytes.
Padded field size
Contains the size of the image data, including pad bytes. Some video hardware may append pad bytes
to the image data; this field, along with the field size field, allows you to compute how many pad bytes
were added.
Offset to next field
The offset, in bytes, from the start of the field data to the start of the next field in the bitstream. This field
should be set to 0 in the last fields marker data.
Quantization table offset
The offset, in bytes, from the start of the field data to the quantization table marker. If this field is set to
0, check the image description for a default quantization table.
Huffman table offset
The offset, in bytes, from the start of the field data to the Huffman table marker. If this field is set to 0,
check the image description for a default Huffman table.
Start of frame offset
The offset from the start of the field data to the start of image marker. This field should never be set to
0.
Start of scan offset
The offset, in bytes, from the start of the field data to the start of the scan marker. This field should never
be set to 0.
Start of data offset
The offset, in bytes, from the start of the field data to the start of the data stream. Typically, this immediately
follows the start of scan data.
174
Note: The last two fields have been added since the original Motion-JPEG specification, and so they
may be missing from some Motion-JPEG A files. You should check the length of the APP1 marker
before using the start of scan offset and start of data offset fields.
Motion-JPEG format B does not support markers. In place of the marker, therefore, QuickTime inserts a header
at the beginning of the bitstream. Again, all of the fields are 32-bit integers.
Figure 4-7
00 00 00 00
6D 6A 70 67
Field size
Byte
offsets
from
start
of
field
00 00
00 84
00 00 .. ..
01 A2 .. ..
00 11 .. ..
00 0C .. ..
.. .. .. ..
00 00 00
175
00 00 00 00
Reserved
Unpredictable; should be set to 0.
Tag
The data type; this field must be set to 'mjpg'.
Field size
The actual size of the image data for this field, in bytes.
Padded field size
The size of the image data, including pad bytes. Some video hardware may append pad bytes to the
image data; this field, along with the field size field, allows you to compute how many pad bytes were
added.
Offset to next field
The offset, in bytes, from the start of the field data to the start of the next field in the bitstream. This field
should be set to 0 in the second fields header data.
Quantization table offset
The offset, in bytes, from the start of the field data to the quantization table. If this field is set to 0, check
the image description for a default quantization table.
Huffman table offset
The offset, in bytes, from the start of the field data to the Huffman table. If this field is set to 0, check the
image description for a default Huffman table.
Start of frame offset
The offset from the start of the field data to the fields image data. This field should never be set to 0.
Start of scan offset
The offset, in bytes, from the start of the field data to the start of scan data.
Start of data offset
The offset, in bytes, from the start of the field data to the start of the data stream. Typically, this immediately
follows the start of scan data.
Note: The last two fields were reserved, must be set to zero in the original Motion-JPEG specification.
The Motion-JPEG format B header must be a multiple of 16 in size. When you add pad bytes to the header, set
them to 0.
Because Motion-JPEG format B does not support markers, the JPEG bitstream does not have NULL bytes (0x00)
inserted after data bytes that are set to 0xFF.
176
Sound Media
Sound media is used to store compressed and uncompressed audio data in QuickTime movies. It has a media
type of 'soun'. This section describes the sound sample description and the storage format of sound files using
various data formats.
Format
4-Character
Description
code
Not specified
0x00000000
kSoundNotCompressed
'NONE'
k8BitOffsetBinaryFormat
'raw '
k16BitBigEndianFormat
'twos'
k16BitLittleEndianFormat
'sowt'
177
Format
4-Character
Description
code
kMACE3Compression
'MAC3 '
kMACE6Compression
'MAC6 '
kIMACompression
'ima4'
kFloat32Format
'fl32'
kFloat64Format
'fl64'
k24BitFormat
'in24'
24-bit integer
k32BitFormat
'in32'
32-bit integer
kULawCompression
'ulaw'
uLaw 2:1
kALawCompression
'alaw'
uLaw 2:1
kMicrosoftADPCMFormat
0x6D730002
kDVIIntelIMAFormat
0x6D730011
kDVAudioFormat
'dvca'
DV Audio
kQDesignCompression
'QDMC'
QDesign music
kQDesign2Compression
'QDM2'
kQUALCOMMCompression
'Qclp'
QUALCOMM PureVoice
kMPEGLayer3Format
0x6D730055
kFullMPEGLay3Format
'.mp3'
kMPEG4AudioFormat
'mp4a'
kAC3AudioFormat
'ac-3'
178
179
These added fields are used to support out-of-band configuration settings for decompression and to allow
some parsing of compressed QuickTime sound tracks without requiring the services of a decompressor.
These fields introduce the idea of a packet. For uncompressed audio, a packet is a sample from a single channel.
For compressed audio, this field has no real meaning; by convention, it is treated as 1/number-of-channels.
These fields also introduce the idea of a frame. For uncompressed audio, a frame is one sample from each
channel. For compressed audio, a frame is a compressed group of samples whose format is dependent on the
compressor.
Important: The value of all these fields has different meaning for compressed and uncompressed audio.
The meaning may not be easily deducible from the field name.
The four new fields are:
Samples per
packet
Bytes per
packet
For uncompressed audio, the number of bytes in a sample for a single channel. This replaces
the older sampleSize field, which is set to 16.This value is calculated by dividing the frame
size by the number of channels. The same calculation is performed to calculate the value of
this field for compressed audio, but the result of the calculation is not generally meaningful
for compressed audio.
Bytes per
frame
The number of bytes in a frame: for uncompressed audio, an uncompressed frame; for
compressed audio, a compressed frame. This can be calculated by multiplying the bytes per
packet field by the number of channels.
Bytes per
sample
The size of an uncompressed sample in bytes. This is set to 1 for 8-bit audio, 2 for all other
cases, even if the sample size is greater than 2 bytes.
When capturing or compressing audio using the QuickTime API, the value of these fields can be obtained by
calling the Apple Sound Managers GetCompression function. Historically, the value returned for the bytes
per frame field was not always reliable, however, so this field was set by multiplying bytes per packet by the
number of channels.
To facilitate playback on devices that support only one or two channels of audio in 'raw ' or 'twos' format
(such as most early Macintosh and Windows computers), all other uncompressed audio formats are treated as
compressed formats, allowing a simple decompressor component to perform the necessary format conversion
during playback. The audio samples are treated as opaque compressed frames for these data types, and the
fields for sample size and bytes per sample are not meaningful.
180
The new fields correspond to the CompressionInfo structure used by the Macintosh Sound Manager (which
uses 16-bit values) to describe the compression ratio of fixed ratio audio compression algorithms. If these fields
are not used, they are set to 0. File readers only need to check to see if samplesPerPacket is 0.
Redefined Sample Tables
If the compression ID in the sample description is set to 2, the sound track uses redefined sample tables
optimized for compressed audio.
Unlike video media, the data structures for QuickTime sound media were originally designed for uncompressed
samples. The extended version 1 sound description structure provides a great deal of support for compressed
audio, but it does not deal directly with the sample table atoms that point to the media data.
The ordinary sample tables do not point to compressed frames, which are the fundamental units of compressed
audio data. Instead, they appear to point to individual uncompressed audio samples, each one byte in size,
within the compressed frames. When used with the QuickTime API, QuickTime compensates for this fiction in
a largely transparent manner, but attempting to parse the sound samples using the original sample tables
alone can be quite complicated.
With the introduction of support for the playback of variable bit-rate (VBR) audio in QuickTime 4.1, the contents
of a number of these fields were redefined, so that a frame of compressed audio is treated as a single media
sample. The sample-to-chunk and chunk offset atoms point to compressed frames, and the sample size table
documents the size of the frames. The size is constant for CBR audio, but can vary for VBR.
The time-to-sample table documents the duration of the frames. If the time scale is set to the sampling rate,
which is typical, the duration equals the number of uncompressed samples in each frame, which is usually
constant even for VBR (it is common to use a fixed frame duration). If a different media timescale is used, it is
necessary to convert from timescale units to sampling rate units to calculate the number of samples.
This change in the meaning of the sample tables allows you to use the tables accurately to find compressed
frames.
To indicate that this new meaning is used, a version 1 sound description is used and the compression ID field
is set to 2. The samplesPerPacket field and the bytesPerSample field are not necessarily meaningful for
variable bit rate audio, but these fields should be set correctly in cases where the values are constant; the other
two new fields ( bytesPerPacket and bytesPerFrame) are reserved and should be set to 0.
If the compression ID field is set to zero, the sample tables describe uncompressed audio samples and cannot
be used directly to find and manipulate compressed audio frames. QuickTime has built-in support that allows
programmers to act as if these sample tables pointed to uncompressed 1-byte audio samples.
181
182
audioSampleRate
A 64-bit floating point number representing the number of audio frames per second, for example: 44,100.0.
numAudioChannels
A 32-bit integer field set to the number of audio channels; any channel assignment will be expressed in
an extension.
always7F000000
A 32-bit integer field that must be set to 0x7F000000.
constBitsPerChannel
A 32-bit integer field which is set only if constant and only for uncompressed audio. For all other cases
set to 0.
formatSpecificFlags
A 32-bit integer field which carries LPCM flag values defined in LPCM flag values (page 184) below.
constBytesPerAudioPacket
A 32-bit unsigned integer set to the number of bytes per packet only if this value is constant. For other
cases set to 0.
constLPCMFramesPerAudioPacket
A 32-bit unsigned integer set to the number of PCM frames per packet only if this value is constant. For
other cases set to 0.
Some definitions for sound sample description version 2:
LPCM Frame: one uncompressed sample in each of the channels (for instance, 44100Hz audio has 44100
LPCM frames per second, whether it is mono, stereo, 5.1, or other possible values). In other words, LPCM
Frames divided by the audioSampleRate value is duration in seconds.
Audio Packet: For compressed audio, an audio packet is the natural compressed access unit of that format.
For uncompressed audio, an audio packet is simply one LPCM frame.
Fields prefixed by const: Note the three sound sample description v2 fields whose names start with
"const". These fields are only nonzero if the value is a constant. A zero in each field implies that the value
is variable. For example: AAC audio would have a zero in constBytesPerAudioPacket because AAC
has variable sized audio packets. Codecs with variable duration audio packets set a zero in
constLPCMFramesPerAudioPacket.
183
=
=
=
=
=
=
=
=
(1
(1
(1
(1
(1
(1
(1
(1
<<
<<
<<
<<
<<
<<
<<
<<
0),
1),
2),
3),
4),
5),
6),
31),
//
//
//
//
//
//
//
0x1
0x2
0x4
0x8
0x10
0x20
0x40
kLinearPCMFormatFlagIsFloat
kLinearPCMFormatFlagIsBigEndian
kLinearPCMFormatFlagIsSignedInteger
kLinearPCMFormatFlagIsPacked
kLinearPCMFormatFlagIsAlignedHigh
kLinearPCMFormatFlagIsNonInterleaved
kLinearPCMFormatFlagIsNonMixable
kLinearPCMFormatFlagsSampleFractionShift
kLinearPCMFormatFlagsSampleFractionMask
kLinearPCMFormatFlagsSampleFractionShift),
kLinearPCMFormatFlagsAreAllClear
=
=
=
=
=
=
=
=
=
kAudioFormatFlagIsFloat,
kAudioFormatFlagIsBigEndian,
kAudioFormatFlagIsSignedInteger,
kAudioFormatFlagIsPacked,
kAudioFormatFlagIsAlignedHigh,
kAudioFormatFlagIsNonInterleaved,
kAudioFormatFlagIsNonMixable,
7,
(0x3F <<
kAppleLosslessFormatFlag_16BitSourceData
kAppleLosslessFormatFlag_20BitSourceData
kAppleLosslessFormatFlag_24BitSourceData
kAppleLosslessFormatFlag_32BitSourceData
=
=
=
=
= kAudioFormatFlagsAreAllClear,
1,
2,
3,
4
};
184
// original fields
SoundDescription
desc;
samplesPerPacket;
unsigned long
bytesPerPacket;
unsigned long
bytesPerFrame;
unsigned long
bytesPerSample;
// optional, additional atom-based fields -// ([long size, long type, some data], repeat)
};
Version 2 of the sound sample description maintains the same mechanism for the addition of extensions. In
the sound sample description v2 structure, the sizeOfStructOnly field value provides the offset to the
extensions.
siSlopeAndIntercept Atom
Note: The siSlopeAndIntercept atom is deprecated in the QuickTime file format. The information
that follows is intended to document existing content containing this atom and should not be used
for new development.
The siSlopeAndIntercept atom contains slope, intercept, minClip, and maxClip parameters relevant to
a decompressor component.
At runtime, the contents of the type siSlopeAndIntercept and siDecompressorSettings atoms are
provided to the decompressor component through the standard SetInfo mechanism of the Sound Manager.
struct SoundSlopeAndInterceptRecord {
Float64
slope;
Float64
intercept;
Float64
minClip;
Float64
maxClip;
};
typedef struct SoundSlopeAndInterceptRecord SoundSlopeAndInterceptRecord;
185
186
Type
An unsigned 32-bit integer set to zero (0x00000000). This is a rare instance in which the type field is not
a four-character ASCII code.
MPEG-4 Elementary Stream Descriptor Atom ('esds')
This atom is a required extension to the sound sample description for MPEG-4 audio. This atom contains an
elementary stream descriptor, which is defined in ISO/IEC FDIS 14496.
Size
An unsigned 32-bit integer holding the size of the elementary stream descriptor atom.
Type
An unsigned 32-bit field containing the four-character code 'esds'.
Version
An unsigned 32-bit field set to zero.
Elementary Stream Descriptor
An elementary stream descriptor for MPEG-4 audio, as defined in the MPEG-4 specification ISO/IEC 14496.
Audio Channel Layout Atom (chan)
This atom is an optional extension to the sound sample description specifying audio channel layouts for sound
media contained in QuickTime movies. It is a full atom followed by a big-endian audio channel layout structure
as defined by Apples Core Audio framework. Audio channel layouts can be applied to both compressed and
uncompressed sound formats.
Note: Audio channel layouts with more than two channels per track require implementation with
a version 2 sound sample description.
Size
An unsigned 32-bit integer holding the size of the audio channel layout atom.
Type
An unsigned 32-bit field containing the four-character code 'chan'
Version
A 1-byte specification of the version of the audio channel layout atom.
Flags
A 3-byte space for audio channel layout flags.
187
IMA 4:1
The IMA encoding scheme is based on a standard developed by the International Multimedia Association
for pulse code modulation (PCM) audio compression. QuickTime uses a slight variation of the format to
allow for random access. IMA is a 16-bit audio format which supports 4:1 compression. It is defined as
follows:
kIMACompression = FOUR_CHAR_CODE('ima4'), /*IMA 4:1*/
188
The uLaw (mu-law) encoding scheme is used on North American and Japanese phone systems, and is
coming into use for voice data interchange, and in PBXs, voice-mail systems, and Internet talk radio (via
MIME). In uLaw encoding, 14 bits of linear sample data are reduced to 8 bits of logarithmic data.
The aLaw encoding scheme is used in Europe and the rest of the world.
The kULawCompression and the kALawCompression formats are typically found in .au formats.
Floating-Point Formats
Both kFloat32Format and kFloat64Format are floating-point uncompressed formats. Depending upon
codec-specific data associated with the sample description, the floating-point values may be in big-endian
(network) or little-endian (Intel) byte order. This differs from the 16-bit formats, where there is a single format
for each endian layout.
189
MPEG-4 Audio
MPEG-4 audio is stored as a sound track with data format 'mp4a' and certain additions to the sound sample
description and sound track atom. Specifically:
The compression ID is set to -2 and redefined sample tables are used (see Redefined Sample Tables (page
181)).
An MPEG-4 elementary stream descriptor extension atom (see MPEG-4 Elementary Stream Descriptor
Atom ('esds') (page 187)).
The inclusion of a format atom is strongly recommended. See Format Atom ('frma') (page 186).
The last atom in the siDecompressionParam atom must be a terminator atom. See Terminator
Atom (0x00000000) (page 186).
The audio data is stored as an elementary MPEG-4 audio stream, as defined in ISO/IEC specification 14496-1.
190
A QuickTime movie can contain none, one, or several timed metadata tracks. Timed metadata tracks can refer
to multiple tracks. Metadata tracks are linked to the tracks they describe using a track-reference of type cdsc.
The metadata track holds the cdsc track reference. If a metadata track describes characteristics of the entire
movie, there should be no track reference of type 'cdsc' between it and another track. These metadata tracks
can be considered to hold global metadata for the movie.
Using a timed metadata track, any form of descriptive metadata that changes over time can be linked to a
range of media times for which it is valid. Examples of timed metadata can include:
Information such as scene changes and actor names added to the movie in production
As with other tracks, each metadata sample is associated with a single timed metadata sample description.
This sample description signals information needed to interpret the data in the metadata sample in a way that
is analogous to how a video tracks video sample atom indicates that video samples contain H.264 compressed
sample data of particular dimensions.
Zero, one, or many metadata values can be associated with a range of media time in the track. The
accommodation for no metadata values for a time allows runs of time with metadata interspersed with runs
of time with no metadata. Because the timed metadata is organized as a track, it is also possible to use track
edits to indicate the absence of metadata. For some situations, however, it would be better to include metadata
samples that themselves carry no metadata values.
191
The metadata sample description must contain a metadata key table atom and optionally contains a bit rate
atom following the standard sample description atom header, defined below. Other atoms may be introduced
in the future.
Metadata key table
An atom containing a table of keys and mappings to payload data in the corresponding timed metadata
media samples
Bit rate atom
An optional atom that contains data that signals the bit rate of a media stream
192
If the metadata key table atom does contain a particular key, this does not guarantee that timed metadata
media samples containing a value for the key were written. So, clients finding a key in the metadata key table
atom may still need to look through the tracks timed metadata media samples for values to determine if the
track has the particular metadata.
Note: Having the ability for the metadata key table atom to contain keys that are not associated
with any instances of timed metadata media samples allows a metadata sample description to be
populated with keys that might be discovered (say during a capture process) and then samples to
be written with a binding only for the keys found. If a key is never used, theres no requirement that
the timed metadata sample description be rewritten to exclude the key that isnt needed.
If it is possible to remove unused entries and rewrite the metadata sample description efficiently, this is
preferred.
If a timed metadata track includes a key in the metadata sample description but has values using the key in
associated media samples, the metadata sample description can still be rewritten to eliminate the key from
the metadata key table atom. While the metadata values remain in associated media samples, the data is no
longer reachable because the key is now gone. Care should be exercised if the values should themselves be
removed from the movie file. Although not a requirement, the remaining but now unreachable data can be
removed by copying only referenced metadata values when copying media samples to a new track.
Figure 4-8
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to 'keys
Metadata key table
An array of metadata key atoms
193
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to 'btrt
Buffer size
A 32-bit unsigned integer that indicates the suggested size of the associated data buffer
Max bit rate
A 32-bit unsigned integer that indicates the maximum bit rate in bits/second of the associated media
stream
Average bit rate
A 32-bit unsigned integer that indicates the average bit rate in bits/second of the associated media stream
194
A local_key_id of 0 indicates the metadata key atom is unused and should not be interpreted. This indication
allows the key to be marked as unused in the timed metadata sample description without requiring the sample
description and parent atoms to be rewritten or resized.
A local_key_id of 0xFFFFFFFF must not occur in a metadata key atom. It is reserved for future use and can
occur as an atom type in timed metadata samples.
All other type codes are available for use as a local_key_id.
Note: Because the atoms within the metadata key table atom can take on any atom type, there
should be no special interpretation of the type for contained atoms other than for the special value
0. Therefore, including a 'free' atom does not have the conventional meaning in the metadata
key atom. It is recommended that writers avoid the use of overly confusing existing atom type codes.
Each metadata key atom contains a variable number of atoms that define the key structure, optionally the
data type for values, and optionally locale information for values. Atoms may be introduced in the future.
A metadata key atom must contain a metadata declaration atom.
Figure 4-10
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to local_key_id
Variable array of atoms
An array of atoms carrying the definitions for key structure and other optional information
195
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to 'keyd
Key_namespace
A 32-bit identifier describing the domain and the structure of the key_value
For example, this could indicate that key_value is a reverse-address style string (such as
"com.apple.quicktime.ISO6709"), a binary four-character code (such as a 'cprt' user data key), a Uniform
Resource Identifier (URI), or other structures (such as native formats from other metadata standards).
New key namespaces must be registered but because a reverse-address style string can often be used,
using the reverse-address key namespace may be sufficient for most uses.
Key_value array
An array of unsigned 8-bit bytes holding the keys value
The interpretation of this array is defined by the associated key_namespace field. See the QuickTime
Metadata Keys (page 145) table for examples.
196
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to 'dtyp
Datatype namespace
A 32-bit identifier describing how to interpret the data type for the value
New namespace types should be registered with Apple.
Datatype array
An array of unsigned 8-bit bytes holding the data type designation for values in timed metadata media
samples having this key. The interpretation of this array is defined by the associated datatype
namespace.
The combination of datatype namespace and datatype array indicate the data type (or structure) of a
metadata item value. The datatype namespace type indicates the interpretation of the datatype array
value. This specification defines two datatype namespace types:
If datatype namespace is 1, datatype array contains a reverse-address style UTF-8 string indicating
an extended data type. This data type namespace type can be used if the data type does not have a
corresponding well-known data type. Datatype array consists of the bytes of a case-sensitive UTF-8
string without a nul (\0) terminator. For example, a hypothetical datatype array
com.company.my-custom-datatype could register a custom data type belonging to the owner of the
DNS registration mycompany.com.
197
A datatype namespace other than 0 or 1 may occur in a timed metadata track, perhaps written according
to a later version of this specification. Metadata item values with unrecognized data types should be ignored.
Even so, some processing is still possible on the metadata item with unrecognized data type, such as copying
it between tracks.
Note: New datatype namespaces must be registered with Apple.
Note: Many uses for proprietary or custom metadata data types can be satisfied by using the
extended data type namespace type code 1. This allows the new data type to be specified without
registration. The reason to add a custom datatype namespace type is to allow an existing
numbering or naming scheme from a foreign metadata standard to be used with metadata items.
Size
A 32-bit unsigned integer that indicates the size in bytes of the atom structure
Type
A 32-bit unsigned integer value set to 'loca
Locale string
A NULL-terminated string of UTF-8 characters holding a language tag complying with RFC 4646 (BCP 47).
Examples include 'en-US', 'fr-FR', or 'zh-CN'.
198
If no values for any key are present for a time range, one approach is to include a NULL or unreferenced
metadata media sample (see Unreferenced or NULL timed metadata sample data (page 200)) for the time range.
A zero-byte timed metadata media sample cannot be used because all sample sizes must be one or more
bytes. Alternatively, empty edit track edit list entries could be used to indicate there is no metadata for a
range of movie time.
In general, however, it is preferable to include a NULL metadata media sample data instead of using a track
edit with an empty edit list to indicate the absence of metadata. Some readers may be unprepared for complex
edits (more than one edit list entry and/or a non-contiguous presentation media time).
199
Example:
Consider the metadata format for a geographic point location using coordinates as defined in ISO-6709. The
timed metadata media sample created for this data might have a local_key_id value of wher and the
resulting metadata sample would contain the information (such as +27.5916+086.5640+8850/) in a
corresponding wher atom. There is no interpretation of this atom type or a requirement that it be wher.
2.
Fill in the atoms holding metadata values (see the Timed Metadata Media Sample Structure (page 199)
example above).
3.
If necessary, add one or more unreferenced atoms to reach the constant metadata media atom size.
Note: Because an atom has a minimum size of 8 bytes, the sum of the sizes of contained timed
metadata media samples either
must be 8 or more bytes smaller than the target constant atom size to allow for one or more
padding atoms.
200
in the Metadata Key Atom (page 194) description above. Using unreferenced atoms presents a useful way to
supply padding when structuring a track for constant-sized metadata sample data or when there are runs of
no-metadata interspersed with runs of metadata in a given track, instead of using multiple track edits.
Note: The combined timed metadata media samples from time t1 to t2 contain both the A and B
metadata values. This is done so that for any time t, it is possible to determine all applicable metadata
values without needing to scan through all timed metadata media tracks in backward or forward
directions.
In the new combined track, a single timed metadata sample description containing the keys A and B may be
used. Creating sample descriptions for each combination (A, B, {A,B}) is possible but discouraged as this makes
the determination of whether a key is in the tracks more complex.
201
There is a potential conflict if more than one metadata value of the same type is in the metadata tracks. In this
case, the layer of the metadata tracks should be used to establish which should be used. Tracks with lesser
layer values (that is, -1 is less than 0) take priority and their metadata values should be used. If two tracks have
the same layer value, the last track in movie track order (the order of 'trak' atoms in the 'moov' atom) shall
override metadata values from tracks earlier in order.
If a metadata track does not have a relationship to another track defined by a track reference of cdsc, it
should be considered a global metadata trackits metadata applying to the entire movie. If part of a track
would apply to a presentation track and part would apply globally, the metadata should be carried in two
tracks, the first referencing the presentation track and the other not referencing any track.
Timecode Media
Timecode media is used to store time code data in QuickTime movies. It has a media type of 'tmcd'.
202
Flags
A 32-bit integer containing flags that identify some timecode characteristics. The following flags are
defined.
Drop frame
Indicates whether the timecode is drop frame. Set it to 1 if the timecode is drop frame. This flags
value is 0x0001.
24 hour max
Indicates whether the timecode wraps after 24 hours. Set it to 1 if the timecode wraps. This flags
value is 0x0002.
Negative times OK
Indicates whether negative time values are allowed. Set it to 1 if the timecode supports negative
values. This flags value is 0x0004.
Counter
Indicates whether the time value corresponds to a tape counter value. Set it to 1 if the timecode
values are tape counter values. This flags value is 0x0008.
Time scale
A 32-bit integer that specifies the time scale for interpreting the frame duration field.
Frame duration
A 32-bit integer that indicates how long each frame lasts in real time.
Number of frames
An 8-bit integer that contains the number of frames per second for the timecode format. If the time is a
counter, this is the number of frames for each counter tick.
Reserved
An 8-bit quantity that must be set to 0.
Source reference
A user data atom containing information about the source tape. The only currently used user data list
entry is the 'name' type. This entry contains a text item specifying the name of the source tape.
203
Value
Meaning
0x0001
Bold
0x0002
Italic
0x0004
Underline
0x0008
Outline
0x0010
Shadow
0x0020
Condense
0x0040
Extend
Text size
A 16-bit integer that specifies the point size of the time code text.
Reserved
A 16-bit integer that is reserved for use by Apple. Set this field to 0.
204
Text color
A 48-bit RGB color value for the timecode text.
Background color
A 48-bit RGB background color for the timecode text.
Font name
A Pascal string specifying the name of the timecode texts font.
Text Media
Text media is used to store text data in QuickTime movies. It has a media type of 'text'.
205
206
Display flags
A 32-bit integer containing flags that describe how the text should be drawn. The following flags are
defined.
Dont auto scale
Controls text scaling. If this flag is set to 1, the text media handler reflows the text instead of
scaling when the track is scaled. This flags value is 0x0002.
Use movie background color
Controls background color. If this flag is set to 1, the text media handler ignores the background
color field in the text sample description and uses the movies background color instead. This
flags value is 0x0008.
Scroll in
Controls text scrolling. If this flag is set to 1, the text media handler scrolls the text until the last
of the text is in view. This flags value is 0x0020.
Scroll out
Controls text scrolling. If this flag is set to 1, the text media handler scrolls the text until the last
of the text is gone. This flags value is 0x0040.
Horizontal scroll
Controls text scrolling. If this flag is set to 1, the text media handler scrolls the text horizontally;
otherwise, it scrolls the text vertically. This flags value is 0x0080.
Reverse scroll
Controls text scrolling. If this flag is set to 1, the text media handler scrolls down (if scrolling
vertically) or backward (if scrolling horizontally; note that horizontal scrolling also depends upon
text justification). This flags value is 0x0100.
Continuous scroll
Controls text scrolling. If this flag is set to 1, the text media handler displays new samples by
scrolling out the old ones. This flags value is 0x0200.
Drop shadow
Controls drop shadow. If this flag is set to 1, the text media handler displays the text with a drop
shadow. This flags value is 0x1000.
Anti-alias
Controls anti-aliasing. If this flag is set to 1, the text media handler uses anti-aliasing when drawing
text. This flags value is 0x2000.
Key text
207
Controls background color. If this flag is set to 1, the text media handler does not display the
background color, so that the text overlay background tracks. This flags value is 0x4000.
Text justification
A 32-bit integer that indicates how the text should be aligned. Set this field to 0 for left-justified text, to
1 for centered text, and to 1 for right-justified text.
Background color
A 48-bit RGB color that specifies the texts background color.
Default text box
A 64-bit rectangle that specifies an area to receive text (top, left, bottom, right). Typically this field is set
to all zeros.
Reserved
A 64-bit value that must be set to 0.
Font number
A 16-bit value that must be set to 0.
Font face
A 16-bit integer that indicates the fonts style. Set this field to 0 for normal text. You can enable other
style options by using one or more of the bit masks listed in Table 4-9 (page 208).
Table 4-9
Value
Meaning
0x0001
Bold
0x0002
Italic
0x0004
Underline
0x0008
Outline
0x0010
Shadow
0x0020
Condense
0x0040
Extend
Reserved
An 8-bit value that must be set to 0.
208
Reserved
A 16-bit value that must be set to 0.
Foreground color
A 48-bit RGB color that specifies the texts foreground color.
Text name
A Pascal string specifying the name of the font to use to display the text.
extension
'styl'
Style information for the text. Allows you to override the default style in the sample
description or to define more than one style for a sample. The data is a TextEdit style
scrap.
209
Text sample
Description
extension
'ftab'
Table of font names. Each table entry contains a font number (stored in a 16-bit
integer) and a font name (stored in a Pascal string).This atom is required if the 'styl'
atom is present.
'hlit'
Highlight information. The atom data consists of two 32-bit integers. The first contains
the starting offset for the highlighted text, and the second has the ending offset. A
highlight sample can be in a key frame or in a differenced frame. When its used in
a differenced frame, the sample should contain a zero-length piece of text.
'hclr'
Highlight color. This atom specifies the 48-bit RGB color to use for highlighting.
'drpo'
Drop shadow offset. When the display flags indicate drop shadow style, this atom
can be used to override the default drop shadow placement. The data consists of
two 16-bit integers. The first indicates the horizontal displacement of the drop shadow,
in pixels; the second, the vertical displacement.
'drpt'
Drop shadow transparency. The data is a 16-bit integer between 0 and 256 indicating
the degree of transparency of the drop shadow. A value of 256 makes the drop
shadow completely opaque.
'imag'
Image font data. This atom contains two more atoms. An 'idat' atom contains
compressed image data to be used to draw the text when the required fonts are not
available. An 'idsc' atom contains a video sample description describing the format
of the compressed image data.
'metr'
Image font highlighting. This atom contains metric information that governs
highlighting when an 'imag' atom is used for drawing.
210
kRangeStart
kRangeEnd
end
// unsigned long
Child atoms of the parent atom are the events of type kQTEventType and the ID of the event type. The children
of these event atoms follow the same format as other wired events.
kAction
211
Sample data
For a CEA-608 track, the data is an array of one or more byte pairs for data channel 1/field 1 (CC1) of a
CEA-608 data stream, each byte pair corresponding to a video frame. For details about the content, refer
to the specification CEA-608-E, Line 21 Data Services, April, 2008 .
The durations of closed caption media samples can vary but should not be shorter than the number of
byte pairs in the byte pair array. A closed caption media sample duration that is longer than the array
length in video frames should treat additional durations as though null (0) byte pair bytes are received.
Note: The carriage of byte pairs for other elements of the source CEA-608-E frame data are not described here. If
supported, other atom types and their content will be documented.
For a CEA-708 track, the should be formatted according to the ANSI CEA-708-E specification, August,
2013.
212
The closed caption tracks must be part of the same alternate group. If the movie also includes subtitle
tracks or non-chapter text tracks, those tracks should also be part of this group.
The closed caption tracks should be tagged with the appropriate language.
Subtitle Media
Subtitle media is used to store text data used for subtitles in QuickTime movies. It has a media type of 'sbtl'.
Subtitles provide written versions of audio or visual content, such as to offer alternate language translations
or to supplement the content. Subtitles differ from closed captions in that subtitles are usually a translation
of the sound track into a different language rather than a transcription of the sound track in the same language.
The data format field in the sample description is currently always set to 'tx3g'. Unrecognized data formats
should be ignored. The text media described here is based on the text box defined in the 3GPP Timed Text
specification but provides a different track type and media handler designed specifically for subtitles.
The subtitle media handler adds some of its own fields to the sample description.
Display flags
A 32-bit integer containing flags that describe how the subtitle text should be drawn. The following flags
are defined.
Vertical placement
Controls vertical placement of the subtitle text. If this flag is set, the subtitle media handler uses
the top coordinate of the display bounds of the override 'tbox' text box to determine the
213
subtitles vertical placement as described in Subtitle Track Header Size and Placement (page 218).
Otherwise, the subtitle displays at the bottom of the video. This flags value is 0x20000000.
Some samples are forced
Indicates whether any subtitle samples contain forced atoms. If this flag is set, at least one sample
contains a forced ('frcd') atom as described in Subtitle Sample Data (page 216). This flags value
is 0x40000000.
All samples are forced
If this flag is set, the subtitle media handler treats all samples as forced subtitles, regardless of
the presence or absence of a 'frcd' atom. This flags value is 0x80000000. If this flag is set, the
Some Samples Are Forced flag must also be set (making 0xC0000000).
Reserved
An 8-bit integer that must be set to 1.
Reserved
An 8-bit integer that must be set to -1 (negative one).
Reserved
A 32-bit integer that must be set to 0.
Default text box
A 64-bit rectangle that specifies an area to receive text (each 16 bits indicate top, left, bottom, and right,
respectively) within the subtitle track. This rectangle must fill the track header dimensions exactly; that
is, top is 0, left is 0, bottom is the height of the subtitle track header, and right is the width of the subtitle
track header. See Subtitle Track Header Size and Placement (page 218).
Reserved
A 32-bit value that must be set to 0.
Font identifier
A 16-bit value that must be set to the same font identifier as in the font table ('ftab' extension).
Font face
An 8-bit integer that indicates the fonts style. Set this field to 0 for normal text. You can enable other
style options by using one or more of the bit masks listed in Table 4-11 (page 214).
Table 4-11
Value
Meaning
0x0001
Bold
0x0002
Italic
214
Value
Meaning
0x0004
Underline
Font size
An 8-bit value that should always be 0.05 multiplied by the video track header height. For example, if
the video track header is 720 points in height, this should be 36 (points). This size should be used in the
default style record and in any per-sample style records. If a subtitle does not fit in the text box, the
subtitle media handler may choose to shrink the font size so that the subtitle fits.
Foreground color
A 32-bit RGBA color that specifies the texts color, 8 bits each for red, green, blue, and alpha (transparency).
For example, this would be (0,0,0,255) for opaque black or (255,255,255,255) for opaque white. Dark
colors are not recommended, as the text could be placed onto a dark background.
Font table
An atom of type 'ftab' that identifies the font to use to display the text. See Font Table Atom (page
215).
215
sample
extension
'frcd'
The presence of this atom indicates that the sample contains a forced subtitle. This
extension has no data.
Forced subtitles are shown automatically when appropriate without any interaction
from the user. If any sample contains a forced subtitle, the Some Samples Are Forced
(0x40000000) flag must also be set in the display flags.
Consider an example where the primary language of the content is English, but the
user has chosen to listen to a French dub of the audio. If a scene in the video displays
something in English that is important to the plot or the content (such as a newspaper
headline), a forced subtitle displays the content translated into French. In this case, the
subtitle is linked (forced) to the French language sound track.
If this atom is not present, the subtitle is typically simply a translation of the audio
content, which a user can choose to display or hide.
'styl'
Style information for the subtitle. This atom allows you to override the default style in
the sample description or to define more than one style within a sample. See Subtitle
Style Atom (page 217).
'tbox'
Override of the default text box for this sample. Used only if the 0x20000000 display
flag is set in the sample description and, in that case, only the top is considered. Even
so, all fields should be set as though they are considered. See Text Box atom (page 218).
'twrp'
Text wrap. Set the one-byte payload to 0x00 for no wrapping or 0x01 for automatic
soft wrapping.
216
217
The subtitle tracks height should be 0.15 * the 'vide' track header height. This allows room for two lines
of subtitle text. For example, if the 'vide' track header height is 720 pixels, then the 'sbtl' track header
height should be 108 (pixels).
218
The subtitle tracks vertical placement is determined by the track matrix, which should be a simple vertical
translation matrix that shifts the subtitle down by 0.85 * the 'vide' track header height. For a subtitle
media handler that obeys the tx3g rules, this positions the subtitles atop the bottom 15 percent of the
video. Media handlers may choose to shift the subtitles further down in some modes; for example, in a
playback mode that displays black bars above and below content, the video could be shifted up and the
subtitles moved down into the black area.
Subtitle samples must not contain a text box sample data extension ('tbox') because no control over
vertical placement is allowed.
Alternatively, if the the Vertical Placement flag (0x20000000) display flag of the sample description is set, the
following should be true:
The height of the subtitle track should be the height of the video track header instead of 0.15 * the video
track height. Because the subtitle track dimensions match the video track dimensions, subtitle text can
be positioned at the bottom or top of the video, unlike when the Vertical Placement flag is not set.
A subtitles placement is determined by the top coordinate of one of two rectangles. If the override text
box sample data extension ('tbox') is present, it is used. Otherwise, the default text box in the sample
description is used. Some players will use the top coordinate to determine whether the subtitle is in the
top half of the track dimensions and place the subtitle at the top of the video, otherwise placing it at the
bottom of the video. Other players might use the top coordinate precisely, placing the subtitle at the
specified vertical coordinate. As both playback environments are possible for a piece of content, it is
recommend that a top coordinate of 0 be used for placing at the top and a top coordinate equal to the
track height minus the subtitle height be used. In this way, if the content is played in either kind of player,
its placement is predictable.
219
Note: The regular track in a pair provides a complete transcription of the audio as subtitle text. This
allows a user to listen in one language but to read subtitled dialogue in another language.
See Alternate Subtitle Tracks (page 347) and Track Reference Atoms (page 73) for more information.
Music Media
Music media is used to store note-based audio data, such as MIDI data, in QuickTime movies. It has a media
type of 'musi'.
MPEG-1 Media
MPEG-1 media is used to store MPEG-1 video streams, MPEG-1, layer 2 audio streams, and multiplexed MPEG-1
audio and video streams in QuickTime movies. It has a media type of 'MPEG'.
220
The data format field in the sample description is always set to 'MPEG'. The MPEG-1 media handler adds no
additional fields to the sample description.
Note: This data format is not used for MPEG-1, layer 3 audio, however (see MPEG-1 Layer 3 (MP3)
Codecs (page 190)).
Sprite Media
Note: Sprite media is deprecated in the QuickTime file format. The information that follows is
intended to document existing content containing sprite media and should not be used for new
development.
Sprite media is used to store character-based animation data in QuickTime movies. It has a media type of
'sprt'.
221
The sprite image container atom stores one or more sprite image atoms of type 'imag'. Each sprite image
atom contains an image sample description immediately followed by the sprites compressed image data. The
sprite image atoms should have ID numbers starting at 1 and counting consecutively upward.
The key frame also must contain definitions for each sprite in atoms of type 'sprt'. Sprite atoms should have
ID numbers start at 1 and count consecutively upward. Each sprite atom contains a list of properties. Table
4-13 (page 222) shows all currently defined sprite properties.
Table 4-13
Sprite properties
Property name
Value
Description
kSpritePropertyMatrix
kSpritePropertyVisible
kSpritePropertyLayer
kSpritePropertyGraphicsMode
kSpritePropertyActionHandlingSpriteID
kSpritePropertyImageIndex
100
222
The override sample differs from the key frame sample in two ways. First, the override sample does not contain
a shared data atom. All shared data must appear in the key frame. Second, only those sprite properties that
change need to be specified. If none of a sprites properties change in a given frame, then the sprite does not
need an atom in the differenced frame.
The override sample can be used in one of two ways: combined, as with video key frames, to construct the
current frame; or the current frame can be derived by combining only the key frame and the current override
sample.
Refer to the section Sprite Track Media Format (page 224) for information on how override samples are indicated
in the file, using kSpriteTrackPropertySampleFormat and the default behavior of the
kKeyFrameAndSingleOverride format.
In addition to defining properties for individual sprites, you can also define properties that apply to an entire
sprite track. These properties may override default behavior or provide hints to the sprite media handler. The
following sprite track properties are supported:
kSpriteTrackPropertyBackgroundColor
Specifies a background color for the sprite track. The background color is used for any area that is not
covered by regular sprites or background sprites. If you do not specify a background color, the sprite
track uses black as the default background color.
kSpriteTrackPropertyOffscreenBitDepth
Specifies a preferred bit depth for the sprite tracks offscreen buffer. The allowable values are 8 and 16.
To save memory, you should set the value of this property to the minimum depth needed. If you do not
specify a bit depth, the sprite track allocates an offscreen buffer with the depth of the deepest intersecting
monitor.
kSpriteTrackPropertySampleFormat
Specifies the sample format for the sprite track. If you do not specify a sample format, the sprite track
uses the default format, kKeyFrameAndSingleOverride.
223
To specify sprite track properties, you create a single QT atom container and add a leaf atom for each property
you want to specify. To add the properties to a sprite track, you call the media handler function
SetMediaPropertyAtom. To retrieve a sprite tracks properties, you call the media handler function
GetMediaPropertyAtom.
The sprite track properties and their corresponding data types are listed in Table 4-14 (page 224).
Table 4-14
Atom type
Atom ID
kSpriteTrackPropertyBackgroundColor
RGBColor
kSpriteTrackPropertyOffscreenBitDepth
unsigned short
kSpriteTrackPropertySampleFormat
long
kSpriteTrackPropertyHasActions
Boolean
kSpriteTrackPropertyQTIdleEventsFrequency
UInt32
kSpriteTrackPropertyVisible
Boolean
kSpriteTrackPropertyScaleSpritesToScaleWorld
Boolean
Note: When pasting portions of two different tracks together, the Movie Toolbox checks to see that
all sprite track properties match. If, in fact, they do match, the paste results in a single sprite track
instead of two.
The sprite track media format is hierarchical and based on QT atoms and atom containers. A sprite track is
defined by one or more key frame samples, each followed by any number of override samples. A key frame
sample and its subsequent override samples define a scene in the sprite track. A key frame sample is a QT atom
container that contains atoms defining the sprites in the scene and their initial properties. The override samples
224
are other QT atom containers that contain atoms that modify sprite properties, thereby animating the sprites
in the scene. In addition to defining properties for individual sprites, you can also define properties that apply
to an entire sprite track.
Figure 4-15 (page 225) shows the high-level structure of a sprite track key frame sample. Each atom in the atom
container is represented by its atom type, atom ID, and, if it is a leaf atom, the type of its data.
Figure 4-15
kSpriteAtomType
kSpriteAtomType
kSpriteSharedDataAtomType
ID:1
ID:numSprites
ID:1
The QT atom container contains one child atom for each sprite in the key frame sample. Each sprite atom has
a type of kSpriteAtomType. The sprite IDs are numbered from 1 to the number of sprites defined by the key
frame sample (numSprites).
Each sprite atom contains leaf atoms that define the properties of the sprite, as shown in Figure 4-16 (page
225). For example, the kSpritePropertyLayer property defines a sprites layer. Each sprite property atom
has an atom type that corresponds to the property and an ID of 1.
Figure 4-16
kSpritePropertyImageIndex
kSpritePropertyLayer
kSpritePropertyGraphicsMode
ID:1
ID:1
ID:1
short
short
ModifierTrackGraphicsModeRecord
kSpritePropertyMatrix
kSpritePropertyVisible
kSpriteNameAtomType
kSpriteURLLinkAtomType
ID:1
ID:1
ID:1
ID:1
MatrixRecord
short
The URL
225
In addition to the sprite atoms, the QT atom container contains one atom of type
kSpriteSharedDataAtomType with an ID of 1. The atoms contained by the shared data atom describe data
that is shared by all sprites. The shared data atom contains one atom of type
kSpriteImagesContainerAtomType with an ID of 1 (Figure 4-17 (page 226)).
The image container atom contains one atom of type kImageAtomType for each image in the key frame
sample. The image atom IDs are numbered from 1 to the number of images (numImages). Each image atom
contains a leaf atom that holds the image data (type kSpriteImageDataAtomType) and an optional leaf
atom (type kSpriteNameAtomType) that holds the name of the image.
Figure 4-17
kSpriteImageContainerAtomType
ID:1
kSpriteImageAtomType
kSpriteImageAtomType
ID:1
ID:numImages
kSpriteImageDataAtomType
kSpriteNameAtomType
kSpriteImageDataAtomType
ID:1
ID:1
ID:1
Image data
Image data
226
You must add an atom of this type with its leaf data set to true if you want the movie controller to
execute the actions in your sprite tracks media. The atoms leaf data is of type Boolean. The default
value is false, so it is very important to add an atom of this type if you want interactivity to take place.
kSpriteTrackPropertyQTIdleEventsFrequency
You must add an atom of this type if you want the sprites in your sprite track to receive kQTEventIdle
QuickTime events. The atoms leaf data is of type UInt32. The value is the minimum number of ticks
that must pass before the next QTIdle event is sent. Each tick is 1/60th of one second. To specify Idle
as fast as possible, set the value to 0. The default value is kNoQTIdleEvents, which means dont send
any idle events.
It is possible that for small idle event frequencies, the movie will not be able to keep up, in which case
idle events will be sent as fast as possible.
Since sending idle events takes up some time, it is best to specify the largest frequency that produces
the results that you desire, or kNoQTIdleEvents if you do not need them.
kSpriteTrackPropertyVisible
You can cause the entire sprite track to be invisible by setting the value of this Boolean property to
false. This is useful for using a sprite track as a hidden button trackfor example, placing an invisible
sprite track over a video track would allow the characters in the video to be clickable. The default value
is visible (true).
227
kSpriteTrackPropertyScaleSpritesToScaleWorld
You can cause each sprite to be rescaled when the sprite track is resized by setting the value of this
Boolean property to true. Setting this property can improve the drawing performance and quality of
a scaled sprite track. This is particularly useful for sprite images compressed with codecs that are
resolution-independent, such as the Curve codec. The default value for this property is false.
= 'sprt',
kSpriteImagesContainerAtomType
= 'imct',
kSpriteImageAtomType
= 'imag',
kSpriteImageDataAtomType
= 'imda',
kSpriteImageDataRefAtomType
= 'imre',
kSpriteImageDataRefTypeAtomType
= 'imrt',
kSpriteImageGroupIDAtomType
= 'imgr',
kSpriteImageRegistrationAtomType
= 'imrg',
kSpriteImageDefaultImageIndexAtomType ='defi',
kSpriteSharedDataAtomType
= 'dflt',
kSpriteNameAtomType
= 'name',
kSpriteImageNameAtomType
= 'name',
kSpriteUsesImageIDsAtomType
= 'uses',
kSpriteBehaviorsAtomType
= 'beha',
kSpriteImageBehaviorAtomType
= 'imag',
kSpriteCursorBehaviorAtomType
= 'crsr',
kSpriteStatusStringsBehaviorAtomType = 'sstr',
kSpriteVariablesContainerAtomType
= 'vars',
kSpriteStringVariableAtomType
= 'strv',
kSpriteFloatingPointVariableAtomType = 'flov'
kSpriteSharedDataAtomType
= 'dflt',
kSpriteURLLinkAtomType
= 'url '
kSpritePropertyMatrix
= 1
kSpritePropertyVisible
= 4
228
kSpritePropertyLayer
= 5
kSpritePropertyGraphicsMode
= 6
kSpritePropertyImageIndex
= 100
kSpritePropertyBackgroundColor
= 101
kSpritePropertyOffscreenBitDepth
= 102
kSpritePropertySampleFormat
= 103
};
Constant Descriptions
kSpriteAtomType
The atom is a parent atom that describes a sprite. It contains atoms that describe properties of the sprite.
Optionally, it may also include an atom of type kSpriteNameAtomType that defines the name of the
sprite.
kSpriteImagesContainerAtomType
The atom is a parent atom that contains an atom of type kSpriteImageDataAtomType. Optionally, it
may also include an atom of type kSpriteNameAtomType that defines the name of the image.
kSpriteImageDataAtomType
The atom is a parent atom that contains shared sprite data, such as an atom container of type
kSpriteImagesContainerAtomType.
kSpriteNameAtomType
The atom is a leaf atom that contains the name of a sprite or an image. The leaf data is composed of one
or more ASCII characters.
kSpritePropertyImageIndex
A leaf atom containing the image index property which is of type short. This atom is a child atom of
kSpriteAtom.
kSpritePropertyLayer
A leaf atom containing the layer property which is of type short. This atom is a child atom of
kSpriteAtom.
kSpritePropertyMatrix
A leaf atom containing the matrix property which is of type MatrixRecord. This atom is a child atom
of kSpriteAtom.
229
kSpritePropertyVisible
A leaf atom containing the visible property which is of type short. This atom is a child atom of
kSpriteAtom.
kSpritePropertyGraphicsMode
A leaf atom containing the background color property which is of type RGBColor. This atom is used in
a sprite tracks MediaPropertyAtom atom container.
kSpritePropertyOffscreenBitDepth
A leaf atom containing the preferred offscreen bit depth which is of type short. This atom is used in a
sprite tracks MediaPropertyAtom atom container.
kSpritePropertySampleFormat
A leaf atom containing the sample format property, which is of type short. This atom is used in a sprite
tracks MediaPropertyAtom atom container.
kSpriteImageRegistrationAtomType
Sprite images have a default registration point of 0, 0. To specify a different point, add an atom of type
kSpriteImageRegistrationAtomType as a child atom of the kSpriteImageAtomType and set its
leaf data to a FixedPoint value with the desired registration point.
kSpriteImageGroupIDAtomType
You must assign group IDs to sets of equivalent images in your key frame sample. For example, if the
sample contains ten images where the first two images are equivalent, and the last eight images are
equivalent, then you could assign a group ID of 1000 to the first two images, and a group ID of 1001 to
the last eight images. This divides the images in the sample into two sets. The actual ID does not matter,
it just needs to be a unique positive integer.
Each image in a sprite media key frame sample is assigned to a group. Add an atom of type
kSpriteImageGroupIDAtomType as a child of the kSpriteImageAtomType atom and set its leaf data
to a long containing the group ID.
Important: You must assign group IDs to your sprite sample if you want a sprite to display images with
non-equivalent image descriptions (i.e., images with different dimensions).
For each of the following atom types (added to QuickTime 4)except kSpriteBehaviorsAtomTypeyou
fill in the structure QTSpriteButtonBehaviorStruct, which contains a value for each of the four states.
230
kSpriteBehaviorsAtomType
Specifies an ID of a string variable contained in a sprite track to display in the status area of the browser.
Note: All sprite mediaspecifically the leaf data in the QT atom containers for sample and sprite track propertiesshould
be written in big-endian format.
kSpriteUsesImageIDsAtomType
This atom allows a sprite to specify which images it usesin other words, the subset of images that its
imageIndex property can refer to.
You add an atom of type kSpriteUsesImageIDsAtomType as a child of a kSpriteAtomType atom,
setting its leaf data to an array of QT atom IDs. This array contains the IDs of the images used, not the
indices.
Although QuickTime does not currently use this atom internally, tools that edit sprite media can use the
information provided to optimize certain operations, such as cut, copy, and paste.
kSpriteImageRegistrationAtomType
Sprite images have a default registration point of 0, 0. To specify a different point, you add an atom of
type kSpriteImageRegistrationAtomType as a child atom of the kSpriteImageAtomType and
set its leaf data to a FixedPoint value with the desired registration point.
kSpriteImageGroupIDAtomType
You must assign group IDs to sets of equivalent images in your key frame sample. For example, if the
sample contains ten images where the first two images are equivalent, and the last eight images are
equivalent, then you could assign a group ID of 1000 to the first two images, and a group ID of 1001 to
the last eight images. This divides the images in the sample into two sets. The actual ID does not matter;
it just needs to be a unique positive integer.
Each image in a sprite media key frame sample is assigned to a group. You add an atom of type
kSpriteImageGroupIDAtomType as a child of the kSpriteImageAtomType atom and set its leaf data
to a long containing the group ID.
231
Important: You must assign group IDs to your sprite sample if you want a sprite to display images with
non-equivalent image descriptions (that is, images with different dimensions).
You use the following atom types, which were added to QuickTime 4, to specify that an image is referenced
and how to access it.
kSpriteImageDataRefAtomType
Add this atom as a child of the kSpriteImageAtomType atom. Its ID should be 1. Its data should contain
the data reference type (similar to the dataRefType parameter of GetDataHandler).
kSpriteImageDefaultImageIndexAtomType
You may optionally add this atom as a child of the kSpriteImageAtomType atom. Its ID should be 1.
Its data should contain a short, which specifies an image index of a traditional image to use while waiting
for the referenced image to load.
The following constants represent formats of a sprite track. The value of the constant indicates how override
samples in a sprite track should be interpreted. You set a sprite tracks format by creating a
kSpriteTrackPropertySampleFormat atom.
enum {
kKeyFrameAndSingleOverride
= 1L << 1,
kKeyFrameAndAllOverrides
= 1L << 2
};
Constant Descriptions
kKeyFrameAndSingleOverride
The current state of the sprite track is defined by the most recent key frame sample and the current
override sample. This is the default format.
kKeyFrameAndAllOverrides
The current state of the sprite track is defined by the most recent key frame sample and all subsequent
override samples up to and including the current override sample.
232
In QuickTime 4 and later, sprites in a sprite track can specify simple button behaviors. These behaviors can
control the sprites image, the system cursor, and the status message displayed in a Web browser. They also
provide a shortcut for a common set of actions that may result in more efficient QuickTime movies.
Button behaviors can be added to a sprite. These behaviors are intended to make the common task of creating
buttons in a sprite track easyyou basically just fill in a template.
Three types of behaviors are available; you may choose one or more behaviors. Each change a type of property
associated with a button and are triggered by the mouse states notOverNotPressed, overNotPressed,
overPressed, and notOverPressed. The three properties changed are:
The ID of a status string variable displayed in the URL status area of a Web browser.
The sprite track handles letting one sprite act as an active button at a time.
The behaviors are added at the beginning of the sprites list of actions, so they may be overridden by actions
if desired.
To use the behaviors, you fill in the new atoms as follows, using the description key specified in QT Atom
Container Description Key (page 234):
kSpriteAtomType
<kSpriteBehaviorsAtomType>, 1
<kSpriteImageBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
233
<kSpriteCursorBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
<kSpriteStatusStringsBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
The atom ID may be a number if it is required to be a constant, or it may be a list of valid atom IDs, indicating
that multiple atoms of this type are allowed.
3
(1..3)
(1, 5, 7)
(anyUniqueIDs)
The atom index may be a 1 if only one atom of this type is allowed, or it may be a range from 1 to some constant
or variable.
234
(1..3)
(1..numAtoms)
The data may be leaf data in which its data type is listed inside of brackets [], or it may be a nested tree of
atoms.
[theDataType]
childAtoms
[(SpriteTrackProperties)]
<kSpriteTrackPropertyBackgroundColor, 1, 1>
[RGBColor]
<kSpriteTrackPropertyOffscreenBitDepth, 1, 1>
[short]
<kSpriteTrackPropertySampleFormat, 1, 1>
[long]
<kSpriteTrackPropertyScaleSpritesToScaleWorld, 1, 1>
[Boolean]
<kSpriteTrackPropertyHasActions, 1, 1>
[Boolean]
<kSpriteTrackPropertyVisible, 1, 1>
[Boolean]
<kSpriteTrackPropertyQTIdleEventsFrequency, 1, 1>
[UInt32]
235
[(SpriteKeySample)] =
[(SpritePropertyAtoms)]
[(SpriteImageAtoms)]
[(SpriteOverrideSample)] =
[(SpritePropertyAtoms)]
[(SpriteImageAtoms)]
kSpriteSharedDataAtomType, 1, 1
<kSpriteVariablesContainerAtomType>, 1
<kSpriteStringVariableAtomType>, (1..n) ID is
SpriteTrack
Variable ID to be set
[CString]
<kSpriteFloatingPointVariableAtomType>, (1..n)
ID is
kSpriteImagesContainerAtomType, 1, 1
kSpriteImageAtomType, theImageID, (1 .. numImages)
kSpriteImageDataAtomType, 1, 1
[ImageData is ImageDescriptionHandle prepended
image
<kSpriteImageRegistrationAtomType, 1, 1>
[FixedPoint]
<kSpriteImageNameAtomType, 1, 1>
[pString]
236
to
data]
<kSpriteImageGroupIDAtomType, 1, 1>
[long]
[(SpritePropertyAtoms)]
<kQTEventFrameLoaded>, 1, 1
[(ActionListAtoms)]
<kCommentAtomType>, (anyUniqueIDs), (1..numComments)
[CString]
<kSpriteUsesImageIDsAtomType, 1, 1>
[array of QTAtomID's, one per image used]
<kSpriteBehaviorsAtomType>, 1
<kSpriteImageBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
<kSpriteCursorBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
<kSpriteStatusStringsBehaviorAtomType>
[QTSpriteButtonBehaviorStruct]
<[(SpriteActionAtoms)]>
237
[(SpriteActionAtoms)] =
kQTEventType, theQTEventType, (1 .. numEventTypes)
[(ActionListAtoms)] //see the next section Wired Action
//Grammar for a description
<kCommentAtomType>, (anyUniqueIDs), (1..numComments)
[CString]
1, 1
[long whichActionConstant]
<kActionParameter>
(anyUniqueIDs), (1..numParameters)
parameterID,
(1..numParamsWithFlags)
[long actionFlags]
<kActionParameterMinValue>
parameterID,
(1.. numParamsWithMin)
parameterID,
(1.. numParamsWithMax)
[(ActionTargetAtoms)] =
238
<kActionTarget>
<kTargetMovie>
[no data]
<kTargetChildMovieTrackName>
<PString childMovieTrackName>
<kTargetChildMovieTrack>
[IDlong childMovieTrackID]
<kTargetChildMovieTrackIndex>
[long childMovieTrackIndex]
<kTargetChildMovieMovieName>
[PString childMovieName]
<kTargetChildMovieMovieID>
[long childMovieID]
<kTargetTrackName>
[PString trackName]
<kTargetTrackType>
[OSType trackType]
<kTargetTrackIndex>
[long trackIndex]
OR
[(kExpressionAtoms)]
<kTargetTrackID>
[long trackID]
OR
[(kExpressionAtoms)]
<kTargetSpriteName>
[PString spriteName]
<kTargetSpriteIndex>
[short spriteIndex]
OR
[(kExpressionAtoms)]
<kTargetSpriteID>
[QTAtomID spriteIID]
OR
[(kExpressionAtoms)]
239
<kTargetQD3DNamedObjectName>
[CString objectName]
[(kExpressionAtoms)] =
kExpressionContainerAtomType, 1, 1
<kOperatorAtomType, theOperatorType, 1>
kOperandAtomType, (anyUniqueIDs), (1..numOperands)
[(OperandAtoms)]
OR
<kOperandAtomType, 1, 1>
[(OperandAtoms)]
[(ActionTargetAtoms)] =
<kActionTarget>
<kTargetMovieName>
[Pstring MovieName]
OR
<kTargetMovieID>
[long MovieID]
OR
[(kExpressionAtoms)]
[(OperandAtoms)] =
<kOperandExpression> 1, 1
[(kExpressionAtoms)]
OR
<kOperandConstant> 1, 1
[ float theConstant ]
OR
<kOperandSpriteTrackVariable> 1, 1
[(ActionTargetAtoms)]
kActionParameter, 1, 1
[QTAtomID spriteVariableID]
OR
240
<kOperandKeyIsDown> 1, 1
kActionParameter, 1, 1
[UInt16 modifierKeys]
kActionParameter, 2, 2
[UInt8 asciiCharCode]
OR
<kOperandRandom> 1, 1
kActionParameter, 1, 1
[short minimum]
kActionParameter, 2, 2
[short maximum]
OR
<any other operand atom type>
[(ActionTargetAtoms)]
The format for parameter data depends on the action and parameter index.
In most cases, the kActionParameter atom is a leaf atom containing data; for a few parameters, it contains
child atoms.
whichAction corresponds to the action type that is specified by the leaf data of a kWhichAction atom.
paramIndex is the index of the parameters kActionParameter atom.
[(parameterData)] ( whichAction, paramIndex ) =
{
kActionMovieSetVolume:
param1:
short volume
kActionMovieSetRate
param1:
Fixed rate
kActionMovieSetLoopingFlags
param1:
long loopingFlags
kActionMovieGoToTime
param1:
TimeValue time
241
kActionMovieGoToTimeByName
param1:
Str255 timeName
kActionMovieGoToBeginning
no params
kActionMovieGoToEnd
no params
kActionMovieStepForward
no params
kActionMovieStepBackward
no params
kActionMovieSetSelection
param1:
TimeValue startTime
param2:
TimeValue endTime
kActionMovieSetSelectionByName
param1:
Str255 startTimeName
param2:
Str255 endTimeName
kActionMoviePlaySelection
param1:
Boolean selectionOnly
kActionMovieSetLanguage
param1:
long language
kActionMovieChanged
no params
kActionTrackSetVolume
242
param1:
short volume
kActionTrackSetBalance
param1:
short balance
kActionTrackSetEnabled
param1:
Boolean enabled
kActionTrackSetMatrix
param1:
MatrixRecord matrix
kActionTrackSetLayer
param1:
short layer
kActionTrackSetClip
param1:
RgnHandle clip
kActionSpriteSetMatrix
param1:
MatrixRecord matrix
kActionSpriteSetImageIndex
parm1:
short imageIndex
kActionSpriteSetVisible
param1:
short visible
kActionSpriteSetLayer
param1:
short layer
kActionSpriteSetGraphicsMode
param1:
ModifierTrackGraphicsModeRecord graphicsMode
kActionSpritePassMouseToCodec
no params
243
kActionSpriteClickOnCodec
param1:
Point localLoc
kActionSpriteTranslate
param1:
Fixed x
param2:
Fixed y
param3:
Boolean isRelative
kActionSpriteScale
param1:
Fixed xScale
param2:
Fixed yScale
kActionSpriteRotate
param1:
Fixed degrees
kActionSpriteStretch
param1:
Fixed p1x
param2:
Fixed p1y
param3:
Fixed p2x
param4:
Fixed p2y
param5:
Fixed p3x
param6:
Fixed p3y
param7:
Fixed p4x
param8:
Fixed p4y
kActionQTVRSetPanAngle
param1:
float panAngle
kActionQTVRSetTiltAngle
param1:
float tileAngle
kActionQTVRSetFieldOfView
param1:
float fieldOfView
244
kActionQTVRShowDefaultView
no params
kActionQTVRGoToNodeID
param1:
UInt32 nodeID
kActionMusicPlayNote
param1:
long sampleDescIndex
param2:
long partNumber
param3:
long delay
param4:
long pitch
param5:
long velocity
param6:
long duration
kActionMusicSetController
param1:
long sampleDescIndex
param2:
long partNumber
param3:
long delay
param4:
long controller
param5:
long value
kActionCase
param1:
[(CaseStatementActionAtoms)]
kActionWhile
param1:
[(WhileStatementActionAtoms)]
kActionGoToURL
param1:
CString urlLink
kActionSendQTEventToSprite
param1:
[(SpriteTargetAtoms)]
param2:
QTEventRecord theEvent
245
kActionDebugStr
param1:
Str255 theMessageString
kActionPushCurrentTime
no params
kActionPushCurrentTimeWithLabel
param1:
Str255 theLabel
kActionPopAndGotoTopTime
no params
kActionPopAndGotoLabeledTime
param1:
Str255 theLabel
kActionSpriteTrackSetVariable
param1:
QTAtomID variableID
param2:
float value
kActionApplicationNumberAndString
param1:
long aNumber
param2:
Str255 aString
[(WhileStatementActionAtoms)] =
kConditionalAtomType, 1, 1
246
actions
[(kExpressionAtoms)]
kActionListAtomType 1, 1
[(ActionListAtoms)] // may contain nested conditional
actions
Tween Media
Note: Tween media is deprecated in the QuickTime file format. The information that follows is
intended to document existing content containing tween media and should not be used for new
development.
Tween media is used to store pairs of values to be interpolated between in QuickTime movies. These interpolated
values modify the playback of other media types by using track references and track input maps. For example,
a tween media could generate gradually changing volume levels to cause a sound track to fade out. It has a
media type of 'twen'.
Every tween operation is based on a collection of one or more values from which a range of output values can
be algorithmically derived. Each tween is assigned a time duration, and an output value can be generated for
any time value within the duration. In the simplest kind of tween operation, a pair of values is provided as
input and values between the two values are generated as output.
A tween track is a special track in a movie that is used exclusively as a modifier track. The data it contains,
known as tween data, is used to generate values that modify the playback of other tracks, usually by interpolating
values. The tween media handler sends these values to other media handlers; it never presents data.
247
At the root level, there are one or more tween entry atoms; these atoms have an atom type value of 'twen'.
Each tween entry atom completely describes one interpolation operation. These atoms should be consecutively
numbered starting at 1, using the atom ID field.
Each tween entry atom contains several more atoms that describe how to perform the interpolation. The atom
ID field in each of these atoms must be set to 1.
Tween start atom (atom type is 'twst').
This atom specifies the time at which the interpolation is to start. The time is expressed in the medias
time coordinate system. If this atom is not present, the starting offset is assumed to be 0.
Tween duration atom (atom type is 'twdu').
This atom specifies how long the interpolation is to last. The time is expressed in the medias time
coordinate system. If this atom is not present, the duration is assumed to be the length of the sample.
Tween data atom (atom type is 'twdt').
This atom contains the actual values for the interpolation. The contents depend on the value of the tween
type atom.
Tween type atom (atom type is 'twnt').
Describes the type of interpolation to perform.
Table 4-15 (page 248) shows all currently defined tween types. All tween types are currently supported using
linear interpolation.
Table 4-15
Tween type
Value
Tween data
16-bit integer
32-bit integer
32-bit fixed-point
Two points.
Two rectangles.
QuickDraw region
Matrix
Two matrices.
248
Tween type
Value
Tween data
Two graphics modes with RGB color. Only the RGB color
is interpolated. The graphics modes must be the same.
Tween operations for each tween type are performed by a tween component that is specific to that type or,
for a number of tween types that are native to QuickTime, by QuickTime itself. Movies and applications that
use tweening do not need to specify the tween component to use; QuickTime identifies a tween type by its
tween type identifier and automatically routes its data to the correct tween component or to QuickTime.
When a movie contains a tween track, the tween media handler invokes the necessary component (or built-in
QuickTime code) for tween operations and delivers the results to another media handler. The receiving media
handler can then use the values it receives to modify its playback. For example, the data in a tween track can
be used to alter the volume of a sound track.
Tweening can also be used outside of movies by applications or other software that can use the values it
generates.
Numeric tween types, which have pairs of numeric values, such as long integers, as input. For these types,
linear interpolation is used to generate output values.
QuickDraw tween types, most of which have pairs of QuickDraw structures, such as points or rectangles,
as input. For these types, one or more structure elements are interpolated, such as the h and v values for
points, and each element that is interpolated is interpolated separately from others.
249
The polygon tween type, which takes three four-sided polygons as input. One polygon (such as the bounds
for a sprite or track) is transformed, and the two others specify the start and end of the range of polygons
into which the tween operation maps it. You can use the output (a MatrixRecord data structure) to map
the source polygon into any intermediate polygon. The intermediate polygon is interpolated from the
start and end polygons for each particular time in the tween duration.
Path tween types, which have as input a QuickTime vector data stream for a path. Four of the path tween
types also have as input a percentage of paths length; for these types, either a point on the path or a data
structure is returned. Two other path tween types treat the path as a function: one returns the y value of
the point on the path with a given x value, and the other returns the x value of the point on the path with
a given y value.
The list tween type, which has as input a QT atom container that contains leaf atoms of a specified atom
type. For this tween type category, the duration of the tween operation is divided by the number of leaf
atoms of the specified type. For time points within the first time division, the data for the first leaf atom
is returned; for the second time division, the data for the second leaf atom is returned; and so on. The
resulting tween operation proceeds in discrete steps (one step for each leaf atom), instead of the relatively
continuous tweening produced by other tween type categories.
Specifies a tween atom, which can be either a single tween atom, a tween atom in a tween sequence, or
an interpolation tween atom.
Its parent is the tween QT atom container (which you specify with the constant
kParentAtomIsContainer).
The index of a kTweenEntry atom specifies when it was added to the QT atom containerr; the first
added has the index 1, the second 2, and so on. The ID of a kTweenEntry atom can be any ID that is
unique among the kTweenEntry atoms contained in the same QuickTime atom container.
This atom is a parent atom. It must contain the following child atoms:
One or more kTweenData atoms that contain the data for the tween atom. Each kTweenData
atom can contain different data to be processed by the tween component, and a tween component
can process data from only one kTweenData atom a time. For example, an application can use a
250
list tween to animate sprites. The kTweenEntry atom for the tween atom could contain three sets
of animation data, one for moving the sprite from left to right, one for moving the sprite from right
to left, and one for moving the sprite from top to bottom. In this case, the kTweenEntry atom for
the tween atom would contain three kTweenData atoms, one for each data set. The application
specifies the desired data set by specifying the ID of the kTweenData atom to use.
A kTweenEntry atom can contain any of the following optional child atoms:
A kTweenStartOffset atom that specifies a time interval, beginning at the start of the tween
media sample, after which the tween operation begins. If this atom is not included, the tween
operation begins at the start of the tween media sample.
A kTweenDuration atom that specifies the duration of the tween operation. If this atom is not
included, the duration of the tween operation is the duration of the media sample that contains it.
If a kTweenEntry atom specifies a path tween, it can contain the following optional child atom:
A kTweenFlags atom containing flags that control the tween operation. If this atom is not included,
no flags are set.
Note that interpolation tween tracks are tween tracks that modify other tween tracks. The output
of an interpolation tween track must be a time value, and the time values generated are used in
place of the input time values of the tween track being modified.
If a kTweenEntry atom specifies an interpolation tween track, it must contain the following child
atoms:
A kTweenOutputMin atom that specifies the minimum output value of the interpolation tween
atom. The value of this atom is used only if there is also a kTweenOutputMax atom with the same
parent. If this atom is not included and there is a kTweenOutputMax atom with the same parent,
the tween component uses 0 as the minimum value when scaling output values of the interpolation
tween track.
A kTweenOutputMax atom that specifies the maximum output value of the interpolation tween
atom. If this atom is not included, the tween component does not scale the output values of the
interpolation tween track.
251
kTweenStartOffset
For a tween atom in a tween track of a QuickTime movie, specifies a time offset from the start of the
tween media sample to the start of the tween atom. The time units are the units used for the tween track.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenStartOffset atom. The ID of this atom is always
1. The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is TimeValue.
This atom is optional. If it is not included, the tween operation begins at the start of the tween media
sample.
kTweenDuration
Specifies the duration of a tween operation. When a QuickTime movie includes a tween track, the time
units for the duration are those of the tween track. If a tween component is used outside of a movie, the
application using the tween data determines how the duration value and values returned by the
component are interpreted.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenDuration atom. The ID of this atom is always 1.
The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is TimeValue.
This atom is optional. If it is not included, the duration of the tween operation is the duration of the media
sample that contains it.
252
kTweenData
A kListElementType atom that specifies the atom type of the elements of the tween atom.
One or more leaf atoms of the type specified by the kListElementType atom. The data for each
atom is the result of a list tween operation.
kNameAtom
Specifies the name of a tween atom. The name, which is optional, is not used by tween components, but
it can be used by applications or other software.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kNameAtom atom. The ID of this atom is always 1. The index
of this atom is always 1.
This atom is a leaf atom. Its data type is String.
This atom is optional. If it is not included, the tween atom does not have a name.
253
kTweenType
Specifies the tween type (the data type of the data for the tween operation).
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenType atom. The ID of this atom is always 1. The
index of this atom is always 1.
This atom is a leaf atom. The data type of its data is OSType.
This atom is required.
Path Tween Atoms
kTweenFlags
Contains flags that control the tween operation. One flag that controls path tween atoms is defined:
The kTweenReturnDelta flag applies only to path tween atoms (tweens of type
kTweenTypePathToFixedPoint, kTweenTypePathToMatrixTranslation,
kTweenTypePathToMatrixTranslationAndRotation, kTweenTypePathXtoY, or
kTweenTypePathYtoX). If the flag is set, the tween component returns the change in value from
the last time it was invoked. If the flag is not set, or if the tween component has not previously been
invoked, the tween component returns the normal result for the tween atom.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenFlags atom. The ID of this atom is always 1.
The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is Long.
This atom is optional. If it is not included, no flags are set.
kInitialRotationAtom
Specifies an initial angle of rotation for a path tween atom of type kTweenTypePathToMatrixRotation,
kTweenTypePathToMatrixTranslation, or kTweenTypePathToMatrixTranslationAndRotation.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kInitialRotationAtom atom. The ID of this atom is
always 1. The index of this atom is always 1.
This atom is a leaf atom. Its data type is Fixed.
This atom is optional. If it is not included, no initial rotation of the tween atom is performed.
254
Specifies an initial transform for a 3D tween atom whose tween type is one of the following:
kTweenType3dCameraData, kTweenType3dMatrix, kTweenType3dQuaternion,
kTweenType3dRotate, kTweenType3dRotateAboutAxis, kTweenType3dRotateAboutAxis,
kTweenType3dRotateAboutPoint, kTweenType3dRotateAboutVector, kTweenType3dScale, or
kTweenType3dTranslate.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTween3dInitialCondition atom. The ID of this atom
is always 1. The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is one of the values listed in Table 4-16 (page 255).
Table 4-16
Tween types
Tween Type
Data Type
kTweenType3dCameraData
TQ3CameraData
kTweenType3dMatrix
TQ3Matrix4x4
kTweenType3dQuaternion
TQ3Quaternion
kTweenType3dRotate
TQ3RotateTransformData
kTweenType3dRotateAboutAxis
TQ3RotateAboutAxisTransformData
kTweenType3dRotateAboutPoint
TQ3RotateAboutPointTransformData
kTweenType3dRotateAboutVector
TQ3PlaneEquation
kTweenType3dScale
TQ3Vector3D
255
Tween Type
Data Type
kTweenType3dTranslate
TQ3Vector3D
This atom is optional. For each tween type, the default value is the data structure that specifies an identity
transform, that is, a transform that does not alter the 3D data.
Interpolation Tween Atoms
kTweenOutputMax
Specifies the maximum output value of an interpolation tween atom. If a kTweenOutputMax atom is
included for an interpolation tween, output values for the tween atom are scaled to be within the minimum
and maximum values. The minimum value is either the value of the kTweenOutputMin atom or, if there
is no kTweenOutputMin atom, 0. For example, if an interpolation tween atom has values between 0 and
4, and it has kTweenOutputMin and kTweenOutputMax atoms with values 1 and 2, respectively, a value
of 0 (the minimum value before scaling) is scaled to 1 (the minimum specified by the kTweenOutputMin
atom), a value of 4 (the maximum value before scaling) is scaled to 2 (the maximum specified by the
kTweenOutputMax atom), and a value of 3 (three-quarters of the way between the maximum and
minimum values before scaling) is scaled to 1.75 (three-quarters of the way between the values of the
kTweenOutputMin and kTweenOutputMax atoms).
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenOutputMax atom. The ID of this atom is always 1.
The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is Fixed.
This atom is optional. If it is not included, QuickTime does not scale interpolation tween values.
kTweenOutputMin
Specifies the minimum output value of an interpolation tween atom. If both kTweenOutputMin and
kTweenOutputMax atoms are included for an interpolation tween atom, output values for the tween
atom are scaled to be within the minimum and maximum values. For example, if an interpolation tween
atom has values between 0 and 4, and it has kTweenOutputMin and kTweenOutputMax atoms with
values 1 and 2, respectively, a value of 0 (the minimum value before scaling) is scaled to 1 (the minimum
specified by the kTweenOutputMin atom), a value of 4 (the maximum value before scaling) is scaled to
2 (the maximum specified by the kTweenOutputMax atom), and a value of 3 (three-quarters of the way
256
between the maximum and minimum values before scaling) is scaled to 1.75 (three-quarters of the way
between the values of the kTweenOutputMin and kTweenOutputMax atoms).
If a kTweenOutputMin atom is included but a kTweenOutputMax atom is not, QuickTime does not scale
interpolation tween values.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenOutputMin atom. The ID of this atom is always 1.
The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is Fixed.
This atom is optional. If it is not included but a kTweenOutputMax atom is, the tween component uses
0 as the minimum value for scaling values of an interpolation tween atom.
kTweenInterpolationID
Specifies an interpolation tween atom to use for a specified kTweenData atom. There can be any number
of kTweenInterpolationID atoms for a tween atom, one for each kTweenData atom to be interpolated.
Its parent atom is a kTweenEntry atom.
The index of a kTweenInterpolationID atom specifies when it was added to the kTweenEntry atom;
the first added has the index 1, the second 2, and so on. The ID of a kTweenInterpolationID atom
must match the atom ID of the kTweenData atom to be interpolated, and be unique among the
kTweenInterpolationID atoms contained in the same kTweenEntry atom.
This atom is a leaf atom. The data type of its data is QTAtomID.
This atom is required for an interpolation tween atom.
Region Tween Atoms
kTweenPictureData
Contains the data for a QuickDraw picture. Used only by a kTweenTypeQDRegion atom.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenPictureData or kTweenRegionData atom. The
ID of this atom is always 1. The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is Picture.
Either a kTweenPictureData or kTweenRegionData atom is required for a kTweenTypeQDRegion
atom.
257
kTweenRegionData
Contains the data for a QuickDraw region. Used only by a kTweenTypeQDRegion atom.
Its parent atom is a kTweenEntry atom.
A kTweenEntry atom can contain only one kTweenRegionData or kTweenPictureData atom. The
ID of this atom is always 1. The index of this atom is always 1.
This atom is a leaf atom. The data type of its data is Region.
Either a kTweenPictureData or kTweenRegionData atom is required for a kTweenTypeQDRegion
tween.
Sequence Tween Atoms
kTweenSequenceElement
A value of type Fixed that specifies the point in the duration of the tween media sample at which
the sequence entry ends. This is expressed as a percentage; for example, if the value is 75.0, the
sequence entry ends after three-quarters of the total duration of the tween media sample have
elapsed. The sequence entry begins after the end of the previous sequence entry or, for the first
entry in the sequence, at the beginning of the tween media sample.
tweenAtomID
A value of type QTAtomID that specifies the kTweenEntry atom containing the tween for the
sequence element. The kTweenEntry atom and the kTweenSequenceElement atom must
both be a child atoms of the same tween QT atom container.
dataAtomID
A value of type QTAtomID that specifies the kTweenData atom containing the data for the tween.
This atom must be a child atom of the atom specified by the tweenAtomID field.
258
Modifier Tracks
The addition of modifier tracks in QuickTime 2.1 introduced the capability for creating dynamic movies. (A
modifier track sends data to another track; by comparison, a track reference is an association.) For example,
instead of playing video in a normal way, a video track could send its image data to a sprite track. The sprite
track then could use that video data to replace the image of one of its sprites. When the movie is played, the
video track appears as a sprite.
Modifier tracks are not a new type of track. Instead, they are a new way of using the data in existing tracks. A
modifier track does not present its data, but sends it to another track that uses the data to modify how it
presents its own data. Any track can be either a sender or a presenter, but not both. Previously, all tracks were
presenters.
Another use of modifier tracks is to store a series of sound volume levels, which is what occurs when you work
with a tween track. These sound levels can be sent to a sound track as it plays to dynamically adjust the volume.
A similar use of modifier tracks is to store location and size information. This data can be sent to a video track
to cause it to move and resize as it plays.
Because a modifier track can send its data to more than one track, you can easily synchronize actions between
multiple tracks. For example, a single modifier track containing matrices as its samples can make two separate
video tracks follow the same path.
See Creating Movies with Modifier Tracks (page 355) for more information about using modifier tracks.
259
Track References
Although QuickTime has always allowed the creation of movies that contain more than one track, it has not
been able to specify relationships between those tracks. Track references are a feature of QuickTime that allows
you to relate a movies tracks to one another. The QuickTime track-reference mechanism supports many-to-many
relationships. That is, any movie track may contain one or more track references, and any track may be related
to one or more other tracks in the movie.
Track references can be useful in a variety of ways. For example, track references can be used to relate timecode
tracks to other movie tracks. You can use track references to identify relationships between video and sound
tracks such as identifying the track that contains dialog and the track that contains background sounds. Another
use of track references is to associate one or more text tracks that contain subtitles with the appropriate sound
track or tracks.
Track references are also used to create chapter lists, as described in Chapter Lists (page 260).
Every movie track contains a list of its track references. Each track reference identifies another related track.
That related track is identified by its track identifier. The track reference itself contains information that allows
you to classify the references by type. This type information is stored in an OSType data type. You are free to
specify any type value you want. Note, however, that Apple has reserved all lowercase type values.
You may create as many track references as you want, and you may create more than one reference of a given
type. Each track reference of a given type is assigned an index value. The index values start at 1 for each different
reference type. The Movie Toolbox maintains these index values, so that they always start at 1 and count by
1.
Using the AddTrackReference function, you can relate one track to another. The DeleteTrackReference
function will remove that relationship. The SetTrackReference and GetTrackReference functions allow
you to modify an existing track reference so that it identifies a different track. The
GetNextTrackReferenceType and GetTrackReferenceCount functions allow you to scan all of a tracks
track references.
For a list of track reference types, see Track Reference Atoms (page 73).
Chapter Lists
A chapter list provides a set of named entry points into a movie, allowing the user to jump to a preselected
point in the movie from a convenient pop-up list.
260
The movie controller automatically recognizes a chapter list and will create a pop-up list from it. When the
user makes a selection from the pop-up, the controller will jump to the appropriate point in the movie. Note
that if the movie is sized so that the controller is too narrow to display the chapter names, the pop-up list will
not appear.
To create a chapter list, you must create a text track with one sample for each chapter. The display time for
each sample corresponds to the point in the movie that marks the beginning of that chapter. You must also
create a track reference of type 'chap' from an enabled track of the movie to the text track. It is the 'chap'
track reference that makes the text track into a chapter list. The track containing the reference can be of any
type (audio, video, MPEG, and so on), but it must be enabled for the chapter list to be recognized.
Given an enabled track myVideoTrack, for example, you can use the AddTrackReference function to create
the chapter reference:
AddTrackReference( myVideoTrack, theTextTrack,
kTrackReferenceChapterList,
&addedIndex );
The text track that constitutes the chapter list does not need to be enabled, and normally is not. If it is enabled,
the text track will be displayed as part of the movie, just like any other text track, in addition to functioning as
a chapter list.
If more than one enabled track includes a 'chap' track reference, QuickTime uses the first chapter list that it
finds.
3D Media
Note: 3D Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing 3D media and should not be used for new development.
QuickTime movies store 3D image data in a base media. This media has a media type of 'qd3d'.
3D Sample Description
The 3D sample description uses the standard sample description header, as described in Sample Table
Atoms (page 96).
261
The data format field in the sample description is always set to 'qd3d'. The 3D media handler adds no additional
fields to the sample description.
3D Sample Data
The 3D samples are stored in the 3D Metafile format developed for QuickDraw 3D.
Streaming Media
QuickTime movies store streaming data in a streaming media track. This media has a media type of 'strm'.
struct QTSSampleDescription {
long
descSize;
long
dataFormat;
long
resvd1;
/* set to 0*/
short
resvd2;
/* set to 0*/
short
dataRefIndex;
UInt32
version;
UInt32
resvd3;
SInt32
flags;
/* set to 0*/
/* qt atoms follow:*/
/* long size, long type, some
data*/
/* repeat as necessary*/
};
typedef struct QTSSampleDescription
QTSSampleDescription;
262
The sample format depends on the dataFormat field of the QTSSampleDescription. The dataFormat
field can be any value you specify. The currently defined values are 'rtsp' and 'sdp '.
If 'rtsp', the sample can be just an rtsp URL. It can also be any value that you can put in a .rtsp file, as
defined at
http://streaming.apple.com/qtstreaming/documentation/userdocs/rtsptags.htm
If 'sdp ', then the sample is an SDP file. This would be used to receive a multicast broadcast.
Hint Media
The QuickTime file format supports streaming of media data over a network as well as local playback. The
process of sending protocol data units is time-based, just like the display of time-based data, and is therefore
suitably described by a time-based format. A QuickTime file or movie that supports streaming includes
information about the data units to stream. This information is included in additional tracks of the movie called
hint tracks.
Hint tracks contain instructions for a streaming server which assist in the formation of packets. These instructions
may contain immediate data for the server to send (for example, header information) or reference segments
of the media data. These instructions are encoded in the QuickTime file in the same way that editing or
presentation information is encoded in a QuickTime file for local playback.
Instead of editing or presentation information, information is provided which allows a server to packetize the
media data in a manner suitable for streaming, using a specific network transport.
The same media data is used in a QuickTime file which contains hints, whether it is for local playback, or
streaming over a number of different transport types. Separate hint tracks for different transport types may
be included within the same file and the media will play over all such transport types without making any
additional copies of the media itself. In addition, existing media can be easily made streamable by the addition
of appropriate hint tracks for specific transports. The media data itself need not be recast or reformatted in
any way.
Typically, hinting is performed by media packetizer components. QuickTime selects an appropriate media
packetizer for each track and routes each packetizer's output through an Apple-provided packet builder to
create a hint track. One hint track is created for each streamable track in the movie.
Hint tracks are quite small compared with audio or video tracks. A movie that contains hint tracks can be played
from a local disk or streamed over HTTP, similar to any other QuickTime movie. Hint tracks are only used when
streaming a movie over a real-time media streaming protocol, such as RTP.
Support for streaming in the QuickTime file format is based upon the following considerations:
263
Media data represented as a set of network-independent standard QuickTime tracks, which may be played
or edited, as normal.
A common declaration and base structure for server hint tracks; this common format is protocol
independent, but contains the declarations of which protocols are described in the server tracks.
A specific design of the server hint tracks for each protocol which may be transmitted; all these designs
use the same basic structure.
The resulting streams, sent by the servers under the direction of hint tracks, do not need to contain any trace
of QuickTime information. This approach does not require that QuickTime, or its structures or declaration style,
be used either in the data on the wire or in the decoding station. For example, a QuickTime file using H.261
video and DVI audio, streamed under Real-Time Protocol (RTP), results in a packet stream which is fully compliant
with the IETF specifications for packing those codings into RTP.
Hint tracks are built and flagged, so that when the movie is viewed directly (not streamed), they are ignored.
The next section describes a generic format for streaming hints to be stored in a QuickTime movie.
264
sample descriptions to play at specific times, changes that affect those parts of the original track or media
make those hints invalid. Changes to a movie that do not invalidate existing hint tracks include flattening
(when there are no edit lists), and adding new tracks. Changes that invalidate hint tracks include:
This contains statistics for the hint track. The 'hinf' atom contains child atoms as defined in Table 4-17 (page
266). In some cases, there are both 32-bit and 64-bit counters available. Any unknown types should be ignored.
This may contain child atoms. Child atoms that start with 'sdp ' (note, again, the space) contain SDP text for
this track. Text from these child atoms must be inserted into the proper place in the SDP text for the movie,
after any common SDP text. This is analogous to the movie-level 'hnti' atom.
265
Type
Value
Description
'trpY
8 bytes
The total number of bytes that will be sent, including 12-byte RTP headers,
but not including any network headers.
'totl'
4 bytes
'nump'
8 bytes
The total number of network packets that will be sent (if the application
knows there is a 28-byte network header, it can multiply 28 by this number
and add it to the 'trpY value to get the true number of bytes sent.
'npck'
4 bytes
'tpyl'
8 bytes
The total number of bytes that will be sent, not including 12-byte RTP headers.
'tpaY
4 bytes
'maxr'
8 bytes
The maximum data rate. This atom contains two numbers: g, followed by m
(both 32-bit values). g is the granularity, in milliseconds. m is the maximum
data rate given that granularity.
For example, if g is 1 second, then m is the maximum data rate over any 1
second. There may be multiple 'maxr' atoms, with different values for g.
The maximum data rate calculation does not include any network headers
(but does include 12-byte RTP headers).
'dmed'
8 bytes
'dimm'
8 bytes
'drep'
8 bytes
266
Type
Value
Description
'tmin'
4 bytes
'tmax'
4 bytes
'pmax'
4 bytes
'dmax'
4 bytes
'payt'
Variable
Note: Any of the atoms shown in Table 4-17 (page 266) may or may not be present. These atoms
are not guaranteed.
267
In RTP, each media stream, such as an audio or video track, is sent as a separate RTP stream. Consequently,
each media track in the movie has an associated RTP hint track containing the data necessary to packetize it
for RTP transport, and each hint track contains a track reference back to its associated media track.
Media tracks that do not have an associated RTP hint track cannot be streamed over RTP and should be ignored
by RTP streaming servers.
It is possible for a media track to have more than one associated hint track. The hint track contains information
such as the packet size and time scale in the hint tracks sample description. This minimizes the runtime server
load, but in order to support multiple packet sizes it is necessary to have multiple RTP hint tracks for each
media track, each with different a packet size. A similar mechanism could be used to provide hint tracks for
multiple protocols in the future.
It is also possible for a single hint track to refer to more than one media stream. For example, audio and video
MPEG elementary streams could be multiplexed into a single systems stream RTP payload format, and a single
hint track would contain the necessary information to combine both elementary streams into a single series
of RTP packets.
This is the exception rather than the rule, however. In general, multiplexing is achieved by using IPs port-level
multiplexing, not by interleaving the data from multiple streams into a single RTP session.
The hint track is related to each base media track by a track reference declaration. The sample description for
RTP declares the maximum packet size that this hint track will generate. Partial session description (SDP)
information is stored in the tracks user data atom.
268
Table 4-18
Field
Bytes
Size
Data format
Reserved
variable
Field descriptions
Size
A 32-bit integer specifying the size of this sample description in bytes.
Data format
A four-character code indicating the data format of the hint track samples. Only 'rtp ' is currently
defined. Note that the fourth character in 'rtp ' is an ASCII blank space (0x20). Do not attempt to
packetize data whose format you do not recognize.
Reserved
Six bytes that must be set to 0.
Data reference index
This field indirectly specifies where to find the hint track sample data. The data reference is a file or
resource specified by the data reference atom ('dref') inside the data information atom ('dinf') of
the hint track. The data information atom can contain a table of data references, and the data reference
index is a 16-bit integer that tells you which entry in that table should be used. Normally, the hint track
has a single data reference, and this index entry is set to 0.
Hint track version
A 16-bit unsigned integer indicating the version of the hint track specification. This is currently set to 1.
Last compatible hint track version
A 16-bit unsigned integer indicating the oldest hint track version with which this hint track is
backward-compatible. If your application understands the hint track version specified by this field, it can
work with this hint track.
269
Field
Format
Bytes
Entry length
32-bit integer
Data tag
4-char code
Data
Variable
Entry length - 8
Tagged entries for the 'rtp ' data format are defined as follows:
'tims'
A 32-bit integer specifying the RTP time scale. This entry is required for RTP data.
'tsro'
A 32-bit integer specifying the offset to add to the stored time stamp when sending RTP packets. If this
entry is not present, a random offset should be used, as specified by the IETF. If this entry is 0, use an
offset of 0 (no offset).
'snro'
A 32-bit integer specifying the offset to add to the sequence number when sending RTP packets. If this
entry is not present, a random offset should be used, as specified by the IETF. If this entry is 0, use an
offset of 0 (no offset).
270
Bytes
Entry count
Reserved
Variable
Additional data
Variable
Field descriptions
Entry count
A 16-bit unsigned integer indicating the number of packet entries in the table. Each entry in the table
corresponds to a packet. Multiple entries in a single sample indicate that the media sample had to be
split into multiple packets. A sample with an entry count of 0 is reserved and, if encountered, must be
skipped.
Reserved
Two bytes that must be set to 0.
Packet entry table
A variable length table containing packet entries. Packet entries are defined below.
271
Additional data
A variable length field containing data pointed to by the entries in the data table.
The packet entry contains the data elements listed in Table 4-21 (page 272).
Table 4-21
Packet entry
Bytes
Flags
Entry count
0 or variable
Data table
variable
The RTP header information field contains the elements listed in Table 4-22 (page 273).
272
Table 4-22
Field
Bit#
Description
A 1-bit number corresponding to the padding (P) bit in the RTP header. This
bit should probably not be set, since a server that needs different packet
padding would need to unpad and repad the packet itself.
A 1-bit number corresponding to the extension (X) bit in the RTP header. This
bit should probably not be set, since a server that needs to send its own RTP
extension would either not be able to, or would be forced to replace any
extensions from the hint track.
A 1-bit number corresponding to the marker (M) bit in the RTP header.
Payload
type
9-15
A 7-bit number corresponding to the payload type (PT) field of the RTP header.
All undefined bits are reserved and must be set to zero. Note that the location of the defined bits are in
the same bit location as in the RTP header.
RTP sequence number
A 16-bit integer specifying the RTP sequence number for this packet. The RTP server adds a random offset
to this sequence number before transmitting the packet. This field allows re-transmission of packetsfor
example, the same packet can be assembled with the same sequence number and a different (later)
packet transmission time. A text sample with a duration of 5 minutes can be retransmitted every 10
seconds, so that clients that miss the original sample transmission (perhaps they started playing the
movie in the middle) will be refreshed after a maximum of 10 seconds.
Flags
A 16-bit field indicating certain attributes for this packet. Defined bits are shown in Figure 4-18 (page
273).
Figure 4-18
Entry count
A 16-bit unsigned integer specifying the number of entries in the data table.
Extra information TLVs
The extra information TLVs listed in Table 4-23 (page 274) are present if and only if the X bit is set in the
flags field. This provides a way of extending the hint track format without changing the version, while
allowing backward compatibility.
273
Table 4-23
Bytes
TLV size
TLV type
TLV data
TLV size
TLV type
TLV data
...
TLV type
Size
Type
Data Description
12
'rtpo'
A signed 32-bit integer to be added to the RTP timestamp, which is derived from
the hint sample timestamp.
274
Data table
A table that defines the data to be put in the payload portion of the RTP packet. This table defines various
places the data can be retrieved. Table entries are listed in Table 4-25 (page 275).
Table 4-25
Bytes
Data source
Data
15
The data source field of the entry table indicates how the other 15 bytes of the entry are to be interpreted.
Values of 0 through 4 are defined. The various data table formats are defined below.
Although there are various schemes, note that the entries in the various schemes are the same size, 16
bytes long.
Data Modes
No-Op Data Mode
The data table entry has the format for no-op mode shown in Figure 4-19 (page 275).
Figure 4-19
Field descriptions
Data source = 0
A value of 0 indicates that this data table entry is to be ignored.
275
Field descriptions
Data source = 1
A value of 1 indicates that the data is to be immediately taken from the bytes of data that follow.
Immediate length
An 8-bit integer indicating the number of bytes to take from the data that follows. Legal values range
from 0 to 14.
Immediate data
14 bytes of data to place into the payload portion of the packet. Only the first number of bytes indicated
by the immediate length field is used.
Sample Mode
The data table entry has the format for sample mode shown in Figure 4-21 (page 276).
Figure 4-21
Field descriptions
Data source = 2
A value of 2 indicates that the data is to be taken from a tracks sample data.
276
277
*/
*/
*/
/ SPCB;
data */
offset
reserved
Field descriptions
Data source = 3
A value of 3 indicates that the data is to be taken from the media track's sample description table.
Track ref index
A value that indicates which track the sample description will come from. A value of 0 means that there
is exactly one hint track reference, so use that. Values from 1 to 127 are indexes into the hint track reference
atom entries, indicating which original media track the sample is to be read from. A value of -1 means
the hint track itself, that is, get the sample description from the same track as the hint sample you are
currently parsing.
Length
A 16-bit integer specifying the number of bytes to copy.
Sample description index
A 32-bit integer specifying the index into the media's sample description table.
Offset
A 32-bit integer specifying the offset from the start of the sample description from which to start copying.
278
Reserved
Four bytes that must be set to 0.
Additional data
A variable length field containing data pointed to by hint track sample mode entries in the data table.
VR Media
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
This section describes the QuickTime VR world and node information atom containers, which can be obtained
by calling the QuickTime VR Manager routines QTVRGetVRWorld and QTVRGetNodeInfo. Those routines, as
well as a complete discussion of QuickTime VR and how your application can create QuickTime VR movies, are
described in detail in QuickTime VR .
Many atom types contained in the VR world and node information atom containers are unique within their
container. For example, each has a single header atom. Most parent atoms within an atom container are unique
as well, such as the node parent atom in the VR world atom container or the hot spot parent atom in the node
information atom container. For these one-time-only atoms, the atom ID is always set to 1. Unless otherwise
mentioned in the descriptions of the atoms that follow, assume that the atom ID is 1.
Note that many atom structures contain two version fields, majorVersion and minorVersion. The values
of these fields correspond to the constants kQTVRMajorVersion and kQTVRMinorVersion found in the
header file QuickTimeVRFormat.h. For QuickTime 2.0 files, these values are 2 and 0.
QuickTime provides a number of routines for both creating and accessing atom containers.
Some of the leaf atoms within the VR world and node information atom containers contain fields that specify
the ID of string atoms that are siblings of the leaf atom. For example, the VR world header atom contains a
field for the name of the scene. The string atom is a leaf atom whose atom type is kQTVRStringAtomType
('vrsg'). Its atom ID is that specified by the referring leaf atom.
A string atom contains a string. The structure of a string atom is defined by the QTVRStringAtom data type.
typedef struct QTVRStringAtom {
UInt16
stringUsage;
UInt16
stringLength;
unsigned char
theString[4];
279
} QTVRStringAtom, *QTVRStringAtomPtr;
Field descriptions
stringUsage
The string. The string atom structure is extended to hold this string.
Each string atom may also have a sibling leaf atom, called the string encoding atom. The string encoding
atoms atom type is kQTVRStringEncodingAtomType ('vrse'). Its atom ID is the same as that of the
corresponding string atom. The string encoding atom contains a single variable, TextEncoding, a UInt32,
as defined in the header file TextCommon.h. The value of TextEncoding is handed, along with the string,
to the routine QTTextToNativeText for conversion for display on the current machine. The routine
QTTextToNativeText is found in the header file Movies.h.
Note: The header file TextCommon.h contains constants and routines for generating and handling
text encodings.
280
The structure of the VR world atom container is shown in Figure 4-23 (page 281). The component atoms are
defined and their structures are shown in the sections that follow.
Figure 4-23 Structure of the VR world atom container
VR world
VR world header
Name string
Imaging parent
Panorama imaging
Panorama imaging
Node parent
Node ID
Node location
Node ID
Node location
Cursor parent
Cursor
Color cursor
majorVersion;
UInt16
minorVersion;
QTAtomID
nameAtomID;
UInt32
defaultNodeID;
UInt32
vrWorldFlags;
UInt32
reserved1;
281
UInt32
reserved2;
} VRWorldHeaderAtom, *QTVRWorldHeaderAtomPtr;
QT
QT
Field descriptions
majorVersion
The ID of the string atom that contains the name of the scene. That atom should be a sibling of the VR
world header atom. The value of this field is 0 if no name string atom exists.
defaultNodeID
The ID of the default node (that is, the node to be displayed when the file is first opened).
vrWorldFlags
Panorama-Imaging Atom
A panorama-imaging atom describes the default imaging characteristics for all the panoramic nodes in a scene.
This atom overrides QuickTime VRs own defaults.
The panorama-imaging atom has an atom type of kQTVRPanoImagingAtomType ('impn'). Generally, there
is one panorama-imaging atom for each imaging mode, so the atom ID, while it must be unique for each atom,
is ignored. QuickTime VR iterates through all the panorama-imaging atoms.
The structure of a panorama-imaging atom is defined by the QTVRPanoImagingAtom data type:
282
majorVersion;
UInt16
minorVersion;
UInt32
imagingMode;
UInt32
imagingValidFlags;
UInt32
correction;
UInt32
quality;
UInt32
directDraw;
UInt32
imagingProperties[6];
UInt32
reserved1;
UInt32
reserved2;
} QTVRPanoImagingAtom, *VRPanoImagingAtomPtr;
Field descriptions
majorVersion
The imaging mode to which the default values apply. Only kQTVRStatic and kQTVRMotion are allowed
here.
imagingValidFlags
A set of flags that indicate which imaging property fields in this structure are valid.
correction
The default correction mode for panoramic nodes. This can be either kQTVRNoCorrection,
kQTVRPartialCorrection, or kQTVRFullCorrection.
quality
The default direct-drawing property for panoramic nodes. This can be true or false.
imagingProperties
283
reserved2
= 1 << 0,
kQTVRValidQuality
= 1 << 1,
kQTVRValidDirectDraw
= 1 << 2,
kQTVRValidFirstExtraProperty
= 1 << 3
};
Constant Descriptions
kQTVRValidCorrection
The default correction mode for panorama-imaging properties. If this bit is set, the correction field
holds a default correction mode.
kQTVRValidQuality
The default imaging quality for panorama-imaging properties. If this bit is set, the quality field holds
a default imaging quality.
kQTVRValidDirectDraw
The default direct-draw quality for panorama-imaging properties. If this bit is set, the directDraw field
holds a default direct-drawing property.
kQTVRValidFirstExtraProperty
The default imaging property for panorama-imaging properties. If this bit is set, the first element in the
array in the imagingProperties field holds a default imaging property. As new imaging properties
are added, they will be stored in this array.
284
The node parent atom is the parent of one or more node ID atoms. The atom type of the node parent atom is
kQTVRNodeParentAtomType ('vrnp') and the atom type of the each node ID atom is kQTVRNodeIDAtomType
('vrni').
There is one node ID atom for each node in the file. The atom ID of the node ID atom is the node ID of the
node. The node ID atom is the parent of the node location atom. The node location atom is the only child atom
defined for the node ID atom. Its atom type is kQTVRNodeLocationAtomType ('nloc').
The node location atom is the only child atom defined for the node ID atom. Its atom type is
kQTVRNodeLocationAtomType ('nloc'). A node location atom describes the type of a node and its location.
The structure of a node location atom is defined by the QTVRNodeLocationAtom data type:
typedef struct VRNodeLocationAtom {
UInt16
majorVersion;
UInt16
minorVersion;
OSType
nodeType;
UInt32
locationFlags;
UInt32
locationData;
UInt32
reserved1;
UInt32
reserved2;
} VRNodeLocationAtom, *QTVRNodeLocationAtomPtr;
QT
QT
285
Field descriptions
majorVersion
The node type. This field should contain either kQTVRPanoramaType or kQTVRObjectType.
locationFlags
The location flags. This field must contain the value kQTVRSameFile, indicating that the node is to be
found in the current file. In the future, these flags may indicate that the node is in a different file or at
some URL location.
locationData
The location of the node data. When the locationFlags field is kQTVRSameFile, this field should be
0. The nodes are found in the file in the same order that they are found in the node list.
reserved1
The hot spot information atom, discussed in Hot Spot Information Atom (page 290), allows you to indicate
custom cursor IDs for particular hot spots that replace the default cursors used by QuickTime VR. QuickTime
VR allows you to store your custom cursors in the VR world of the movie file.
286
Note:
The use of resource forks for the storage of QuickTime media is deprecated in the QuickTime file
format. The information that follows is intended to document existing content and should not be
used for new development.
In Mac OS with a two-fork file system, custom cursors could be stored in the resource fork of the
movie file. However, this implementation does not work on any other operating system platform
(such as Windows).
The cursor parent atom is the parent of all of the custom cursor atoms stored in the VR world. Its atom type is
kQTVRCursorParentAtomType ('vrcp'). The child atoms of the cursor parent are either cursor atoms or
color cursor atoms. Their atom types are kQTVRCursorAtomType ('CURS') and kQTVRColorCursorAtomType
('crsr'). These atoms are stored exactly as cursors or color cursors would be stored as a resource.
The node information atom container includes general information about the node such as the nodes type,
ID, and name. The node information atom container also contains the list of hot spot atoms for the node. A
QuickTime VR movie contains one node information atom container for each node in the file. The routine
QTVRGetNodeInfo allows you to obtain the node information atom container for the current node or for any
other node in the movie.
287
Figure 4-24 (page 288) shows the structure of the node information atom container.
Figure 4-24 Structure of the node information atom container
Node Information
Node header
Name string
Comment string
Hot spot parent
Hot spot
Hot spot information
Name string
Comment string
Link hot spot information
Hot spot
Hot spot information
Name string
Comment string
URL hot spot information
majorVersion;
UInt16
minorVersion;
OSType
nodeType;
QTAtomID
nodeID;
QTAtomID
nameAtomID;
QTAtomID
commentAtomID;
UInt32
reserved1;
288
UInt32
reserved2;
} VRNodeHeaderAtom, *VRNodeHeaderAtomPtr;
Field descriptions
majorVersion
The node type. This field should contain either kQTVRPanoramaType or kQTVRObjectType.
nodeID
The ID of the string atom that contains the name of the node. This atom should be a sibling of the node
header atom. The value of this field is 0 if no name string atom exists.
commentAtomID
The ID of the string atom that contains a comment for the node. This atom should be a sibling of the
node header atom. The value of this field is 0 if no comment string atom exists.
reserved1
289
majorVersion;
UInt16
minorVersion;
OSType
hotSpotType;
QTAtomID
nameAtomID;
QTAtomID
commentAtomID;
SInt32
cursorID[3];
Float32
bestPan;
Float32
bestTilt;
Float32
bestFOV;
FloatPoint
bestViewCenter;
Rect
hotSpotRect;
UInt32
flags;
UInt32
reserved1;
UInt32
reserved2;
} VRHotSpotInfoAtom, *QTVRHotSpotInfoAtomPtr;
Field descriptions
majorVersion
The hot spot type. This type specifies which other information atomsif anyare siblings to this one.
QuickTime VR recognizes three types: kQTVRHotSpotLinkType, kQTVRHotSpotURLType, and
kQTVRHotSpotUndefinedType.
290
nameAtomID
The ID of the string atom that contains the name of the hot spot. This atom should be a sibling of the
hot spot information atom. This string is displayed in the QuickTime VR controller bar when the mouse
is moved over the hot spot.
commentAtomID
The ID of the string atom that contains a comment for the hot spot. This atom should be a sibling of the
hot spot information atom. The value of this field is 0 if no comment string atom exists.
cursorID
An array of three IDs for custom hot spot cursors (that is, cursors that override the default hot spot cursors
provided by QuickTime VR). The first ID (cursorID[0]) specifies the cursor that is displayed when it is
in the hot spot. The second ID (cursorID[1]) specifies the cursor that is displayed when it is in the hot
spot and the mouse button is down. The third ID (cursorID[2]) specifies the cursor that is displayed
when it is in the hot spot and the mouse button is released. To retain the default cursor for any of these
operations, set the corresponding cursor ID to 0. Custom cursors should be stored in the VR world atom
container, as described in VR World Atom Container (page 280).
bestPan
The best view center for viewing this hot spot; applies only to object nodes.
hotSpotRect
The boundary box for this hot spot, specified as the number of pixels in full panoramic space. This field
is valid only for panoramic nodes.
flags
291
Note: In QuickTime VR movie files, all angular values are stored as 32-bit floating-point values that
specify degrees. In addition, all floating-point values conform to the IEEE Standard 754 for binary
floating-point arithmetic, in big-endian format.
majorVersion;
UInt16
minorVersion;
UInt32
toNodeID;
UInt32
fromValidFlags;
Float32
fromPan;
Float32
fromTilt;
Float32
fromFOV;
FloatPoint
fromViewCenter;
UInt32
toValidFlags;
Float32
toPan;
Float32
toTilt;
Float32
toFOV;
FloatPoint
toViewCenter;
Float32
distance;
UInt32
flags;
UInt32
reserved1;
UInt32
reserved2;
} VRLinkHotSpotAtom, *VRLinkHotSpotAtomPtr;
292
Field descriptions
majorVersion
The ID of the destination node (that is, the node to which this hot spot is linked).
fromValidFlags
A set of flags that indicate which source node view settings are valid.
fromPan
The preferred from-pan angle at the source node (that is, the node containing the hot spot).
fromTilt
A set of flags that indicate which destination node view settings are valid.
toPan
The distance between the source node and the destination node.
flags
A set of link hot spot flags. This field is unused and should be set to 0.
reserved1
293
reserved2
= 1 << 0,
kQTVRValidTilt
= 1 << 1,
kQTVRValidFOV
= 1 << 2,
kQTVRValidViewCenter
= 1 << 3
};
Constant Descriptions
kQTVRValidPan
294
The URL hot spot atom has an atom type of kQTVRHotSpotURLType ('url '). The URL hot spot atom contains
a URL string for a particular Web location (for example, http://quicktimevr.apple.com). QuickTime VR
automatically links to this URL when the hot spot is clicked.
Certain actions on a QuickTime VR movie can trigger wired actions if the appropriate event handler atoms
have been added to the file. This section discusses what atoms must be included in the QuickTime VR file to
support wired actions.
As with sprite tracks, the presence of a certain atom in the media property atom container of the QTVR track
enables the handling of wired actions. This atom is of type kSpriteTrackPropertyHasActions, which has
a single Boolean value that must be set to true.
When certain events occur and the appropriate event handler atom is found in the QTVR file, then that atom
is passed to QuickTime to perform any actions specified in the atom. The event handler atoms themselves
must be added to the node information atom container in the QTVR track. There are two types of event handlers
for QTVR nodes: global and hot spot specific. The currently supported global event handlers are
kQTEventFrameLoaded and kQTEventIdle. The event handler atoms for these are located at the root level
of the node information atom container. A global event handler atoms type is set to the event type and its ID
is set to 1.
Hot spotspecific event handler atoms are located in the specific hot spot atom as a sibling to the hot spot
info atom. For these atoms, the atom type is always kQTEventType and the ID is the event type. Supported
hot spotspecific event types are kQTEventMouseClick, kQTEventMouseClickEnd,
kQTEventMouseClickEndTriggerButton, and kQTEventMouseEnter, kQTEventMouseExit.
The specific actions that cause these events to be generated are described as follows:
295
kQTEventFrameLoaded ('fram')
A wired action that is generated when a node is entered, before any application-installed entering-node
procedure is called (this event processing is considered part of the node setup that occurs before the
applications routine is called).
kQTEventIdle ('idle')
A wired action that is generated every n ticks, where n is defined by the contents of the
kSpriteTrackPropertyQTIdleEventsFrequency atom (SInt32) in the media property atom
container. When appropriate, this event is triggered before any normal idle processing occurs for the
QuickTime VR movie.
kQTEventMouseClick ('clik')
A wired action that is generated when the mouse goes down over a hot spot.
kQTEventMouseClickEnd ('cend')
A wired action that is generated when the mouse goes up after a kQTEventMouseClick is generated,
regardless of whether the mouse is still over the hot spot originally clicked. This event occurs prior to
QuickTime VRs normal mouse-up processing.
kQTEventMouseClickEndTriggerButton ('trig')
A wired action that is generated when a click end triggers a hot spot (using the same criterion as used
by QuickTime VR in 2.1 for link/url hot spot execution). This event occurs prior to QuickTime VRs normal
hot spottrigger processing.
kQTEventMouseEnter ('entr'), kQTEventMouseExit('exit')
Wired action that are generated when the mouse rolls into or out of a hot spot, respectively. These events
occur whether or not the mouse is down and whether or not the movie is being panned. These events
occur after any application-installed MouseOverHotSpotProc is called, and will be cancelled if the return
value from the applications routine indicates that QuickTimeVRs normal overhot spot processing should
not take place.
A QuickTime VR movie is stored on disk in a format known as the QuickTime VR file format. Beginning in
QuickTime VR 2.0, a QuickTime VR movie could contain one or more nodes. Each node is either a panorama
or an object. In addition, a QuickTime VR movie could contain various types of hot spots, including links between
any two types of nodes.
296
Important: This section describes the file format supported by version 2.1 of the QuickTime VR Manager.
All QuickTime VR movies contain a single QTVR track, a special type of QuickTime track that maintains a list of
the nodes in the movie. Each individual sample in a QTVR track contains general information and hot spot
information for a particular node.
If a QuickTime VR movie contains any panoramic nodes, that movie also contains a single panorama track, and
if it contains any object nodes, it also contains a single object track. The panorama and object tracks contain
information specific to the panoramas or objects in the movie. The actual image data for both panoramas and
objects is usually stored in standard QuickTime video tracks, hereafter referred to as image tracks. (An image
track can also be any type of track that is capable of displaying an image, such as a QuickTime 3D track.) The
individual frames in the image track for a panorama make up the diced frames of the original single panoramic
image. The frames for the image track of an object represent the many different views of the object. Hot spot
image data is stored in parallel video tracks for both panoramas and objects.
QTVR track
Panorama track
Panorama image track
For a single-node panoramic movie, the QTVR track contains just one sample. There is a corresponding sample
in the panorama track, whose time and duration are the same as the time and duration of the sample in the
QTVR track. The time base of the movie is used to locate the proper video samples in the panorama image
track. For a panoramic movie, the video sample for the first diced frame of a nodes panoramic image is located
at the same time as the corresponding QTVR and panorama track samples. The total duration of all the video
samples is the same as the duration of the corresponding QTVR sample and the panorama sample.
A panoramic movie can contain an optional hot spot image track and any number of standard QuickTime
tracks. A panoramic movie can also contain panoramic image tracks with a lower resolution. The video samples
in these low-resolution image tracks must be located at the same time and must have the same total duration
as the QTVR track. Likewise, the video samples for a hot spot image track, if one exists, must be located at the
same time and must have the same total duration as the QTVR track.
297
QTVR track
Object track
Object image track
For a single-node object movie, the QTVR track contains just one sample. There is a corresponding sample in
the object track, whose time and duration are the same as the time and duration of the sample in the QTVR
track. The time base of the movie is used to locate the proper video samples in the object image track.
For an object movie, the frame corresponding to the first row and column in the object image array is located
at the same time as the corresponding QTVR and object track samples. The total duration of all the video
samples is the same as the duration of the corresponding QTVR sample and the object sample.
In addition to these three required tracks, an object movie can also contain a hot spot image track and any
number of standard QuickTime tracks (such as video, sound, and text tracks). A hot spot image track for an
object is a QuickTime video track that contains images of colored regions delineating the hot spots; an image
in the hot spot image track must be synchronized to match the appropriate image in the object image track.
A hot spot image track should be 8 bits deep and can be compressed with any lossless compressor (including
temporal compressors). This is also true of panoramas.
Note: To assign a single fixed-position hot spot to all views of an object, you should create a hot
spot image track that consists of a single video frame whose duration is the entire node time.
To play a time-based track with the object movie, you must synchronize the sample data of that track to the
start and stop times of a view in the object image track. For example, to play a different sound with each view
of an object, you might store a sound track in the movie file with each set of sound samples synchronized to
play at the same time as the corresponding objects view image. (This technique also works for video samples.)
Another way to add sound or video is simply to play a sound or video track during the objects view animation;
to do this, you need to add an active track to the object that is equal in duration to the objects row duration.
298
Important: In a QuickTime VR movie file, the panorama image tracks and panorama hot spot tracks must
be disabled. For an object, the object image tracks must be enabled and the object hot spot tracks must
be disabled.
Multinode Movies
A multinode QuickTime VR movie can contain any number of object and panoramic nodes. Figure 4-27 (page
299) illustrates the structure of a QuickTime VR movie that contains five nodes (in this case, three panoramic
nodes and two object nodes).
Figure 4-27 The structure of a multinode movie file
QTVR track
1st node
2nd node
3rd node
4th node
Panorama track
Panorama image track
Panorama low-res
image track
Panorama hot spot
image track
Object track
Object image track
Object hot spot track
299
5th node
Important: Panoramic tracks and object tracks must never be located at the same time.
QTVR Track
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
A QTVR track is a special type of QuickTime track that maintains a list of all the nodes in a movie. The media
type for a QTVR track is 'qtvr'. All the media samples in a QTVR track share a common sample description.
This sample description contains the VR world atom container. The track contains one media sample for each
node in the movie. Each QuickTime VR media sample contains a node information atom container.
size;
UInt32
type;
UInt32
reserved1;
UInt16
reserved2;
UInt16
dataRefIndex;
UInt32
data;
Field descriptions
size
The size, in bytes, of the sample description header structure, including the VR world atom container
contained in the data field.
type
The sample description type. For QuickTime VR movies, this type should be 'qtvr'.
300
reserved1
The VR world atom container. The sample description structure is extended to hold this atom container.
Panorama Tracks
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
A movies panorama track is a track that contains information about the panoramic nodes in a scene. The
media type of the panorama track is 'pano'. Each sample in a panorama track corresponds to a single panoramic
node. This sample parallels the corresponding sample in the QTVR track. Panorama tracks do not have a sample
description (although QuickTime requires that you specify a dummy sample description when you call
AddMediaSample to add a sample to a panorama track). The sample itself contains an atom container that
includes a panorama sample atom and other optional atoms.
majorVersion;
UInt16
minorVersion;
UInt32
imageRefTrackIndex;
UInt32
hotSpotRefTrackIndex;
Float32
minPan;
Float32
maxPan;
301
Float32
minTilt;
Float32
maxTilt;
Float32
minFieldOfView;
Float32
maxFieldOfView;
Float32
defaultPan;
Float32
defaultTilt;
Float32
defaultFieldOfView;
UInt32
imageSizeX;
UInt32
imageSizeY;
UInt16
imageNumFramesX;
UInt16
imageNumFramesY;
UInt32
hotSpotSizeX;
UInt32
hotSpotSizeY;
UInt16
hotSpotNumFramesX;
UInt16
hotSpotNumFramesY;
UInt32
flags;
OSType
panoType;
UInt32
reserved2;
} VRPanoSampleAtom, *VRPanoSampleAtomPtr;
Field descriptions
majorVersion
The index of the image track reference. This is the index returned by the AddTrackReference function
when the image track is added as a reference to the panorama track. There can be more than one image
track for a given panorama track and hence multiple references. (A panorama track might have multiple
image tracks if the panoramas have different characteristics, which could occur if the panoramas were
shot with different size camera lenses.) The value in this field is 0 if there is no corresponding image track.
hotSpotRefTrackIndex
302
minPan
The minimum pan angle, in degrees. For a full panorama, the value of this field is usually 0.0.
maxPan
The maximum pan angle, in degrees. For a full panorama, the value of this field is usually 360.0.
minTilt
The minimum tilt angle, in degrees. For a high-resolution panorama, a typical value for this field is 42.5.
maxTilt
The maximum tilt angle, in degrees. For a high-resolution panorama, a typical value for this field is +42.5.
minFieldOfView
The minimum vertical field of view, in degrees. For a high-resolution panorama, a typical value for this
field is 5.0. The value in this field is 0 for the default minimum field of view, which is 5 percent of the
maximum field of view.
maxFieldOfView
The maximum vertical field of view, in degrees. For a high-resolution panorama, a typical value for this
field is 85.0. The value in this field is 0 for the default maximum field of view, which is maxTilt minTilt.
defaultPan
The width, in pixels, of the panorama stored in the highest resolution image track.
imageSizeY
The height, in pixels, of the panorama stored in the highest resolution image track.
imageNumFramesX
The number of frames into which the panoramic image is diced horizontally. The width of each frame
(which is imageSizeX/imageNumFramesX) should be divisible by 4.
imageNumFramesY
The number of frames into which the panoramic image is diced vertically. The height of each frame
(which is imageSizeY/imageNumFramesY) should be divisible by 4.
hotSpotSizeX
The width, in pixels, of the panorama stored in the highest resolution hot spot image track.
hotSpotSizeY
The height, in pixels, of the panorama stored in the highest resolution hot spot image track.
303
hotSpotNumFramesX
The number of frames into which the panoramic image is diced horizontally for the hot spot image track.
hotSpotNumFramesY
The number of frames into which the panoramic image is diced vertically for the hot spot image track.
flags
A set of panorama flags. kQTVRPanoFlagHorizontal has been superseded by the panoType field. It
is used only when the panoType field is nil to indicate a horizontally-oriented cylindrical panorama.
kQTVRPanoFlagAlwaysWrap is set if the panorama should wrap horizontally, regardless of whether or
not the pan range is 360 degrees. Note that these flags are currently supported only under OS X.
panoType
The minimum and maximum values in the panorama sample atom describe the physical limits of the panoramic
image. QuickTime VR allows you to set further constraints on what portion of the image a user can see by
calling the QTVRSetConstraints routine. You can also preset image constraints by adding constraint atoms
to the panorama sample atom container. The three constraint atom types are kQTVRPanConstraintAtomType,
kQTVRTiltConstraintAtomType, and kQTVRFOVConstraintAtomType. Each of these atom types share
a common structure defined by the QTVRAngleRangeAtom data type:
typedef struct QTVRAngleRangeAtom {
Float32
minimumAngle;
Float32
maximumAngle;
} QTVRAngleRangeAtom, *QTVRAngleRangeAtomPtr;
Field descriptions
304
minimumAngle
305
The rotated image is diced into smaller frames, and each diced frame is then compressed and added to the
video track as a video sample, as shown in Figure 4-28 (page 306). Frames can be compressed using any spatial
compressor; however, temporal compression is not allowed for panoramic image tracks.
Figure 4-28 Creating an image track for a panorama
Original panorama
Rotate 90
CCW
1
2
3
Dice
the
image
Image track
1
2
3
Add
samples
to image
track
24
24
306
QuickTime VR 2.2 does not require the original panoramic image to be rotated 90 degrees counterclockwise,
as was the case in QuickTime VR 2.1. The rotated image is still diced into smaller frames, and each diced frame
is then compressed and added to the video track as a video sample, as shown in Figure 4-29 (page 307).
Figure 4-29 Creating an image track for a panorama, with the image track oriented horizontally
Original panorama
24
24
In QuickTime 3.0, a panorama sample atom (which contains information about a single panorama) contains
the panoType field, which indicates whether the diced panoramic image is oriented horizontally or vertically.
Cylindrical Panoramas
The primary change to cylindrical panoramas in QuickTime VR 2.2 is that the panorama, as stored in the image
track of the movie, can be oriented horizontally. This means that the panorama does not need to be rotated
90 degrees counterclockwise, as required previously.
To indicate a horizontal orientation, the field in the VRPanoSampleAtom data structure formerly called
reserved1 has been renamed panoType. Its type is OSType. The panoType field value for a horizontally
oriented cylinder is kQTVRHorizontalCylinder ('hcyl'), while a vertical cylinder is
307
kQTVRVerticalCylinder ('vcyl'). For compatibility with older QuickTime VR files, when the panoType
field is nil, then a cylinder is assumed, with the low order bit of the flags field set to 1 to indicate if the cylinder
is horizontal and 0 if the cylinder is vertical.
One consequence of reorienting the panorama horizontally is that, when the panorama is divided into separate
tiles, the order of the samples in the file is now the reverse of what it was for vertical cylinders. Since vertical
cylinders were rotated 90 degrees counterclockwise, the first tile added to the image track was the rightmost
tile in the panorama. For unrotated horizontal cylinders, the first tile added to the image track is the left-most
tile in the panorama.
Cubic Panoramas
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
A new type of panorama was introduced in the current version of QuickTime: the cubic panorama. This panorama
in its simplest form is represented by six faces of a cube, thus enabling the viewer to see all the way up and
all the way down. The file format and the cubic rendering engine actually allow for more complicated
representations, such as special types of cubes with elongated sides or cube faces made up of separate tiles.
Atoms that describe the orientation of each face allow for these nonstandard representations. If these atoms
are not present, then the simplest representation is assumed. The following describes this simplest
representation: a cube with six square sides.
Tracks in a cubic movie are laid out as they are for cylindrical panoramas. This includes a QTVR track, a panorama
track, and an image track. Optionally, there may also be a hot spot track and a fast-start preview track. The
image, hot spot, and preview tracks are all standard QuickTime video tracks.
308
Cube faces
5
1
Note that the frames are oriented horizontally. There is no provision for frames that are rotated 90
counterclockwise as there are for cylindrical panoramas.
The media sample for a panorama track contains the pano sample atom container. For cubes, some of the
fields in the pano sample data atom have special values, which provide compatibility back to QuickTime VR
2.2. The cubic projection engine ignores these fields. They allow one to view cubic movies in older versions of
QuickTime VR using the cylindrical engine, although the view will be somewhat incorrect, and the top and
bottom faces will not be visible. The special values are shown in Table 4-26 (page 310).
309
Table 4-26
Fields and their special values as represented in the pano sample data atom, providing backward
compatibility to QuickTime VR 2.2
Field
Value
imageNumFramesX
imageNumFramesY
imageSizeX
Frame width * 4
imageSizeY
Frame height
minPan
0.0
maxPan
360.0
minTilt
-45.0
maxTilt
45.0
minFieldOfView
5.0
maxFieldOfView
90.0
flags
A 1 value in the flags field tells QuickTime VR 2.2 that the frames are not rotated. QuickTime VR 2.2 treats this
as a four-frame horizontal cylinder. The panoType field (formerly reserved1) must be set to kQTVRCube
('cube') so that QuickTime VR 3.0 can recognize this panorama as a cube.
Since certain viewing fields in the pano sample data atom are being used for backward compatibility, a new
atom must be added to indicate the proper viewing parameters for the cubic image. This atom is the cubic
view atom (atom type 'cuvw'). The data structure of the cubic view atom is as follows:
struct QTVRCubicViewAtom {
Float32
minPan;
Float32
maxPan;
Float32
minTilt;
Float32
maxTilt;
Float32
minFieldOfView;
Float32
maxFieldOfView;
310
Float32
defaultPan;
Float32
defaultTilt;
Float32
defaultFieldOfView;
};
typedef struct QTVRCubicViewAtom
QTVRCubicViewAtom;
The fields are filled in as desired for the cubic image. This atom is ignored by older versions of QuickTime VR.
Typical minimum and maximum field values are shown in Table 4-27 (page 311).
Table 4-27
Field
Value
minPan
0.0
maxPan
360.0
minTilt
-90.0
maxTilt
90.0
minFieldOfView
5.0
maxFieldOfView
120.0
You add the cubic view atom to the pano sample atom container (after adding the pano sample data atom).
Then use AddMediaSample to add the atom container to the panorama track.
Nonstandard Cubes
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
Although the default representation for a cubic panorama is that of six square faces of a cube, it is possible to
depart from this standard representation. When doing so, a new atom must be added to the pano sample
atom container. The atom type is 'cufa'. The atom is an array of data structures of type QTVRCubicFaceData.
Each entry in the array describes one face of whatever polyhedron is being defined. QTVRCubicFaceData is
defined as follows:
311
struct QTVRCubicFaceData {
float
orientation[4];
float
center[2];
float
aspect;
float
skew;
};
typedef struct QTVRCubicFaceData
QTVRCubicFaceData;
The mathematical explanation of these data structures is beyond the scope of this document but will be
described in a separate Apple Technote. Table 4-28 (page 312) shows what values QuickTime VR uses for the
default representation of six square sides.
Table 4-28
Orien-
Orien-
Orien-
Orien-
Center
Center
Aspect
Skew
Side
tation
tation
tation
tation
# front
.5
.5
# right
# back
.5
.5
# left
.5
.5
# top
.5
.5
# bottom
When a panorama contains hot spots, the movie file contains a hot spot image track, a video track that contains
a parallel panorama, with the hot spots designated by colored regions. Each diced frame of the hot spot
panoramic image must be compressed with a lossless compressor (such as QuickTimes graphics compressor).
312
The dimensions of the hot spot panoramic image are usually the same as those of the image tracks panoramic
image, but this is not required. The dimensions must, however, have the same aspect ratio as the image tracks
panoramic image. A hot spot image track should be 8 bits deep.
trackRefType;
UInt16
trackResolution;
UInt32
trackRefIndex;
} QTVRTrackRefEntry;
Field descriptions
trackRefType
313
The number of entries in the track reference array atom is determined by dividing the size of the atom by
sizeof (QTVRTrackRefEntry).
kQTVRPreviewTrackRes is a special value for the trackResolution field in the QTVRTrackRefEntry
structure. This is used to indicate the presence of a special preview image track.
Object Tracks
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR Media and should not be used for new development.
A movies object track is a track that contains information about the object nodes in a scene. The media type
of the object track is 'obje'. Each sample in an object track corresponds to a single object node in the scene.
The samples of the object track contain information describing the object images stored in the object image
track.
These object information samples parallel the corresponding node samples in the QTVR track and are equal
in time and duration to a particular object nodes image samples in the objects image track as well as the
object nodes hot spot samples in the objects hot spot track.
Object tracks do not have a sample description (although QuickTime requires that you specify a dummy sample
description when you call AddMediaSample to add a sample to an object track). The sample itself is an atom
container that contains a single object sample atom and other optional atoms.
majorVersion;
UInt16
minorVersion;
UInt16
movieType;
UInt16
viewStateCount;
UInt16
defaultViewState;
UInt16
mouseDownViewState;
UInt32
viewDuration;
314
UInt32
columns;
UInt32
rows;
Float32
mouseMotionScale;
Float32
minPan;
Float32
maxPan;
Float32
defaultPan;
Float32
minTilt;
Float32
maxTilt;
Float32
defaultTilt;
Float32
minFieldOfView;
Float32
fieldOfView;
Float32
defaultFieldOfView;
Float32
defaultViewCenterH;
Float32
defaultViewCenterV;
Float32
viewRate;
Float32
frameRate;
UInt32
animationSettings;
UInt32
controlSettings;
} VRObjectSampleAtom, *VRObjectSampleAtomPtr;
QT
QT
QT
Field descriptions
majorVersion
The number of view states of the object. A view state selects an alternate set of images for an objects
views. The value of this field must be positive.
315
defaultViewState
The 1-based index of the default view state. The default view state image for a given view is displayed
when the mouse button is not down.
mouseDownViewState
The 1-based index of the mouse-down view state. The mouse-down view state image for a given view
is displayed while the user holds the mouse button down and the cursor is over an object movie.
viewDuration
The total movie duration of all image frames contained in an objects view. In an object that uses a single
frame to represent a view, the duration is the image tracks sample duration time.
columns
The number of columns in the object image array (that is, the number of horizontal positions or increments
in the range defined by the minimum and maximum pan values). The value of this field must be positive.
rows
The number of rows in the object image array (that is, the number of vertical positions or increments in
the range defined by the minimum and maximum tilt values). The value of this field must be positive.
mouseMotionScale
The mouse motion scale factor (that is, the number of degrees that an object is panned or tilted when
the cursor is dragged the entire width of the VR movie image). The default value is 180.0.
minPan
The minimum pan angle, in degrees. The value of this field must be less than the value of the maxPan
field.
maxPan
The maximum pan angle, in degrees. The value of this field must be greater than the value of the minPan
field.
defaultPan
The default pan angle, in degrees. This is the pan angle used when the object is first displayed. The value
of this field must be greater than or equal to the value of the minPan field and less than or equal to the
value of the maxPan field.
minTilt
The minimum tilt angle, in degrees. The default value is +90.0. The value of this field must be less than
the value of the maxTilt field.
maxTilt
The maximum tilt angle, in degrees. The default value is 90.0. The value of this field must be greater
than the value of the minTilt field.
316
defaultTilt
The default tilt angle, in degrees. This is the tilt angle used when the object is first displayed. The value
of this field must be greater than or equal to the value of the minTilt field and less than or equal to the
value of the maxTilt field.
minFieldOfView
The minimum field of view to which the object can zoom. The valid range for this field is from 1 to the
value of the fieldOfView field. The value of this field must be positive.
fieldOfView
The image field of view, in degrees, for the entire object. The value in this field must be greater than or
equal to the value of the minFieldOfView field.
defaultFieldOfView
The default field of view for the object. This is the field of view used when the object is first displayed.
The value in this field must be greater than or equal to the value of the minFieldOfView field and less
than or equal to the value of the fieldOfView field.
defaultViewCenterH
The view rate (that is, the positive or negative rate at which the view animation in the object plays, if
view animation is enabled). The value of this field must be from 100.0 through +100.0, inclusive.
frameRate
The frame rate (that is, the positive or negative rate at which the frame animation in a view plays, if frame
animation is enabled). The value of this field must be from 100.0 through +100.0, inclusive.
animationSettings
A set of 32-bit flags that encode information about the animation settings of the object.
controlSettings
A set of 32-bit flags that encode information about the control settings of the object.
The movieType field of the object sample atom structure specifies an object controller type, that is, the user
interface to be used to manipulate the object.
QuickTime VR supports the following controller types:
enum ObjectUITypes {
kGrabberScrollerUI
= 1,
kOldJoyStickUI
= 2,
317
kJoystickUI
= 3,
kGrabberUI
= 4,
kAbsoluteUI
= 5
};
Constant Descriptions
kGrabberScrollerUI
The default controller, which displays a hand for dragging and rotation arrows when the cursor is along
the edges of the object window.
kOldJoyStickUI
A joystick controller, which displays a joystick-like interface for spinning the object. With this controller,
the direction of panning is reversed from the direction of the grabber.
kJoystickUI
A joystick controller, which displays a joystick-like interface for spinning the object. With this controller,
the direction of panning is consistent with the direction of the grabber.
kGrabberUI
A grabber-only interface, which displays a hand for dragging but does not display rotation arrows when
the cursor is along the edges of the object window.
kAbsoluteUI
An absolute controller, which displays a finger for pointing. The absolute controller switches views based
on a row-and-column grid mapped into the object window.
Animation Settings
The animationSettings field of the object sample atom is a long integer that specifies a set of animation
settings for an object node. Animation settings specify characteristics of the movie while it is playing. Use these
constants to specify animation settings:
enum QTVRAnimationSettings {
kQTVRObjectAnimateViewFramesOn
= (1 << 0),
kQTVRObjectPalindromeViewFramesOn
= (1 << 1),
kQTVRObjectStartFirstViewFrameOn
= (1 << 2),
kQTVRObjectAnimateViewsOn
= (1 << 3),
kQTVRObjectPalindromeViewsOn
= (1 << 4),
kQTVRObjectSyncViewToFrameRate
= (1 << 5),
318
kQTVRObjectDontLoopViewFramesOn
= (1 << 6),
kQTVRObjectPlayEveryViewFrameOn
= (1 << 7)
};
Constant Descriptions
kQTVRObjectAnimateViewFramesOn
The animation setting to play all frames in the current view state.
kQTVRObjectPalindromeViewFramesOn
The animation setting to play a back-and-forth animation of the frames of the current view state.
kQTVRObjectStartFirstViewFrameOn
The animation setting to play the frame animation starting with the first frame in the view (that is, at the
view start time).
kQTVRObjectAnimateViewsOn
The animation setting to play all views of the current object in the default row of views.
kQTVRObjectPalindromeViewsOn
The animation setting to play a back-and-forth animation of all views of the current object in the default
row of views.
kQTVRObjectSyncViewToFrameRate
The animation setting to synchronize the view animation to the frame animation and use the same
options as for frame animation.
kQTVRObjectDontLoopViewFramesOn
The animation setting to stop playing the frame animation in the current view at the end.
kQTVRObjectPlayEveryViewFrameOn
The animation setting to play every view frame regardless of play rate. The play rate is used to adjust the
duration in which a frame appears but no frames are skipped so the rate is not exact.
Control Settings
The controlSettings field of the object sample atom is a long integer that specifies a set of control settings
for an object node. Control settings specify whether the object can wrap during panning and tilting, as well
as other features of the node. The control settings are specified using these bit flags:
enum QTVRControlSettings {
kQTVRObjectWrapPanOn
= (1 << 0),
kQTVRObjectWrapTiltOn
= (1 << 1),
kQTVRObjectCanZoomOn
= (1 << 2),
319
kQTVRObjectReverseHControlOn
= (1 << 3),
kQTVRObjectReverseVControlOn
= (1 << 4),
kQTVRObjectSwapHVControlOn
= (1 << 5),
kQTVRObjectTranslationOn
= (1 << 6)
};
Constant Descriptions
kQTVRObjectWrapPanOn
The control setting to enable wrapping during panning. When this control setting is enabled, the user
can wrap around from the current pan constraint maximum value to the pan constraint minimum value
(or vice versa) using the mouse or arrow keys.
kQTVRObjectWrapTiltOn
The control setting to enable wrapping during tilting. When this control setting is enabled, the user can
wrap around from the current tilt constraint maximum value to the tilt constraint minimum value (or
vice versa) using the mouse or arrow keys.
kQTVRObjectCanZoomOn
The control setting to enable zooming. When this control setting is enabled, the user can change the
current field of view using the zoom-in and zoom-out keys on the keyboard (or using the VR controller
buttons).
kQTVRObjectReverseHControlOn
The control setting to enable translation. When this setting is enabled, the user can translate using the
mouse when either the translate key is held down or the controller translation mode button is toggled
on.
320
The track references to an objects image and hot spot tracks are not handled the same way as track references
to panoramas. The track reference types are the same (kQTVRImageTrackRefType and
kQTVRHotSpotTrackRefAtomType), but the location of the reference indexes is different. There is no entry
in the object sample atom for the track reference indexes. Instead, separate atoms using the VRTrackRefEntry
structure are stored as siblings to the object sample atom. The types of these atoms are
kQTVRImageTrackRefAtomType and kQTVRHotSpotTrackRefAtomType. If either of these atoms is not
present, then the reference index to the corresponding track is assumed to be 1.
Note: The trackResolution field in the VRTrackRefEntry structure is ignored for object tracks.
The actual views of an object for an object node are contained in an object image track, which is usually a
standard QuickTime video track. (An object image track can also be any type of track that is capable of displaying
an image, such as a QuickTime 3D track.)
As described in Chapter 1 of QuickTime VR , these views are often captured by moving a camera around the
object in a defined pattern of pan and tilt angles. The views must then be ordered into an object image array,
which is stored as a one-dimensional sequence of frames in the movies video track (see Figure 4-31 (page
321)).
Figure 4-31
1,1
1,2
1,3
1,4
......
1,m
2,1
2,2
2,3
.....
.....
n,1
n,2
.....
n,m
View duration
For object movies containing frame animation, each animated view in the object image array consists of the
animating frames. It is not necessary that each view in the object image array contain the same number of
frames, but the view duration of all views in the object movie must be the same.
321
For object movies containing alternate view states, alternate view states are stored as separate object image
arrays that immediately follow the preceding view state in the object image track. Each state does not need
to contain the same number of frames. However, the total movie time of each view state in an object node
must be the same.
Movie Media
Movie media is used to encapsulate embedded movies within QuickTime movies. This feature is available in
QuickTime 4.1.
A data reference type and a data reference. The data reference type is stored as an OSType at the start
of the atom. The data reference is stored following the data reference type. If the data reference type is
URL and the data reference is for a movie on the Apple website, the contents of the atom would be url
http://www.apple.com/foo.mov.
There may be more than one atom of this type. The first atom of this type should have an atom ID of 1.
Additional data references should be numbered sequentially.
kMovieMediaDefaultDataReferenceID
This atom contains a QTAtomID that indicates the ID of the data reference to use when instantiating the
embedded movie for this sample. If this atom is not present, the data reference with an ID of 1 is used.
kMovieMediaSlaveTime
A Boolean that indicates whether or not the TimeBase of the embedded movie should be slaved to the
TimeBase of the parent movie. If the TimeBase is slaved, the embedded movies zero time will correspond
to the start time of its movie media sample. Further, the playback rate of the embedded movie will always
be the same as the parent movies. If the TimeBase is not slaved, the embedded movie will default to a
rate of 0, and a default time of whatever default time value it instantiated with (which may not be 0). If
the TimeBase is not slaved, the embedded movie can be played by either including an AutoPlay atom
322
in the movie media sample or by using a wired action. If this atom is not present, the embedded movie
defaults to not slaved.
kMovieMediaSlaveAudio
A Boolean that indicates whether or not the audio properties of the embedded movie should be slaved
to those of the parent movie. When audio is slaved, all audio properties of the containing track are
duplicated in the embedded movie. These properties include sound volume, balance, bass and treble,
and level metering. If this atom is not present, the embedded movie defaults to not slaved audio.
kMovieMediaSlaveGraphicsMode
A Boolean that indicates how the graphics mode of the containing track is applied to the embedded
movie. If the graphics mode is not slaved, then the entire embedded movie is imaged using its own
graphics modes. The result of the drawing of the embedded movie is composited onto the containing
movie using the graphics mode of the containing track. If the graphics mode is slaved, then the graphics
mode of each track in the embedded movie is ignored and instead the graphics mode of the containing
track is used. In this case, the tracks of the embedded movie composite their drawing directly into the
parent movies contents. If this atom is not present, the graphics mode defaults to not slaved. Graphics
mode slaving is useful for compositing semi-transparent mediafor example, a PNG with an alpha
channelon top of other media.
kMovieMediaSlaveTrackDuration
A Boolean that indicates how the Movie Media Handler should react when the duration of the embedded
movie is different than the duration of the movie media sample that it is contained by. When the movie
media sample is created, the duration of the embedded movie may not yet be known. Therefore, the
duration of the media sample may not be correct. In this case, the Movie Media Handler can do one of
two things. If this atom is not present or it contains a value of false, the Movie Media Handler will respect
the duration of media sample that contains the embedded movie. If the embedded movie has a longer
duration than the movie media sample, the embedded movie will be truncated to the duration of the
containing movie media sample. If the embedded movie is shorter, there will be a gap after it is finished
playing. If this atom contains a value of true, the duration of the movie media sample will be adjusted
to match the actual duration of the embedded movie. Because it is not possible to change an existing
media sample, this will cause a new media sample to be added to the movie and the tracks edit list to
be updated to reference the new sample instead of the original sample.
323
Note: When the duration of the embedded movies sample is adjusted, by default no other tracks are adjusted. This
can cause the overall temporal composition to change in unintended ways. To maintain the complete temporal
composition, a higher-level data structure which describes the temporal relationships between the various tracks must
also be included with the movie.
kMovieMediaAutoPlay
A Boolean that indicates whether or not the embedded movie should start playing immediately after
being instantiated. This atom is only used if the TimeBase of the embedded movie is not slaved to the
parent movie. See the kMovieMediaSlaveTime atom in Movie Media Sample Format (page 322) for
more information. If auto play is requested, the movie will be played at its preferred rate after being
instantiated. If this atom is not present, the embedded movie will not automatically play.
kMovieMediaLoop
A UInt8 that indicates how the embedded movie should loop. This atom is only used if the TimeBase
of the embedded movie is not slaved to the parent movie. See the kMovieMediaSlaveTime atom in
Movie Media Sample Format (page 322) for more information. If this atom contains a 0, or if this atom is
not present, the embedded movie will not loop. If this atom contains a value of 1, the embedded movie
loops normallythat is, when it reaches the end it loops back to the beginning. If this atom contains a
value of 2, the embedded movie uses palindromic looping. All other values are reserved.
kMovieMediaUseMIMEType
Text (not a C string or a pascal string) that indicates the MIME type of the movie import component that
should be used to instantiate this media. This is useful in cases where the data reference may not contain
MIME type information. If this atom is not present, the MIME type of the data reference as determined
at instantiation time is used. This atom is intended to allow content creators a method for working around
MIME type binding problems. It should not typically be required, and should not be included in movie
media samples by default.
kMovieMediaTitle
Currently unused. It would contain text indicating the name of the embedded movie.
kMovieMediaAltText
Text (not a C string or a pascal string) that is displayed to the user when the embedded movie is being
instantiated or if the embedded movie cannot be instantiated. If this atom is not present, the name of
the data reference (typically the file name) is used.
kMovieMediaClipBegin
A MovieMediaTimeRecord that indicates the time of the embedded movie that should be used. The
clip begin atom provides a way to specify that a portion of the beginning of the embedded movie should
not be used. If this atom is not present, the beginning of the embedded movie is not changed. Note that
this atom does not change the time at which the embedded movie begins playing in the parent movies
324
time line. If the time specified in the clip begin atom is greater than the duration of the embedded movie,
then the embedded movie will not play at all.
struct MovieMediaTimeRecord {
wide
TimeScale
time;
scale;
};
kMovieMediaClipDuration
A MovieMediaTimeRecord that indicates the duration of the embedded movie that should be used.
The clip duration atom is applied by removing media from end of the embedded movie. If the clip duration
atom is not present, then no media is removed from the end of the embedded movie. In situations where
the sample contains both a clip duration and a clip begin atom, the clip begin is applied first. If the clip
duration specifies a value that is larger than the duration of the embedded movie, no change is made
to the embedded movie.
kMovieMediaEnableFrameStepping
A Boolean that indicates whether or not the embedded movie should be considered when performing
step operations, specifically using the interesting time calls with the nextTimeStep flag. If this atom is
not present or is set to false, the embedded movie is not included in step calculations. If the atom is
set to true, it is included in step calculations.
kMovieMediaBackgroundColor
An RGBColor that is used for filling the background when the movie is being instantiated or when it
fails to instantiate.
325
kMovieMediaRegionAtom
A number of child atoms, shown below, which describe how the Movie Media Handler should resize the
embedded movie. If this atom is not present, the Movie Media Handler resizes the child movie to
completely fill the containing tracks box.
kMovieMediaSpatialAdjustment
This atom contains an OSType that indicates how the embedded movie should be scaled to fit
the track box. If this atom is not present, the default value is kMovieMediaFitFill. These modes
are all based on SMIL layout options.
kMovieMediaFitClipIfNecessary
If the media is larger than the track box, it will be clipped; if it is smaller, any additional area will
be transparent.
kMovieMediaFitFill
The media is proportionally scaled so that it is entirely visible in the track box and fills the largest
area possible without changing the aspect ratio.
kMovieMediaFitSlice
The media is scaled proportionally so that the smaller dimension is completely visible.
kMovieMediaFitScroll
Four child atoms that define a rectangle. Not all child atoms must be present: top and left must both
appear together, width and height must both appear together. The dimensions contained in this rectangle
are used in place of the track box when applying the contents of the spatial adjustment atom. If the top
and left are not specified, the top and left of the containing tracks box are used. If the width and height
326
are not specified, the width and height of the containing tracks box are used. Each child atom contains
a UInt32.
kMovieMediaTop
327
This chapter describes a number of common data types that are used in QuickTime files.
328
Note: ISO language codes cannot be used for all elements of a QuickTime file. Currently, ISO language
codes can be used only for user data text . All other elements, including text tracks, must be specified
using Macintosh language codes.
Note: ISO 639-2/T codes do not distinguish between certain language variations. Use an extended
language tag atom ('elng') to make these distinctions. For example, ISO 639-2T does not distinguish
between traditional and simplified Chinese, so also use 'elng' with the value "zh-Hant" or "zh-Hans",
respectively. See Extended Language Tag Atom (page 82).
Language
Value
Language
Value
English
Georgian
52
French
Moldavian
53
German
Kirghiz
54
Italian
Tajiki
55
Dutch
Turkmen
56
Swedish
Mongolian
57
Spanish
MongolianCyr
58
Danish
Pashto
59
Portuguese
Kurdish
60
Norwegian
Kashmiri
61
Hebrew
10
Sindhi
62
Japanese
11
Tibetan
63
Arabic
12
Nepali
64
Finnish
13
Sanskrit
65
329
Language
Value
Language
Value
Greek
14
Marathi
66
Icelandic
15
Bengali
67
Maltese
16
Assamese
68
Turkish
17
Gujarati
69
Croatian
18
Punjabi
70
Traditional Chinese
19
Oriya
71
Urdu
20
Malayalam
72
Hindi
21
Kannada
73
Thai
22
Tamil
74
Korean
23
Telugu
75
Lithuanian
24
Sinhala
76
Polish
25
Burmese
77
Hungarian
26
Khmer
78
Estonian
27
Lao
79
Lettish
28
Vietnamese
80
Latvian
28
Indonesian
81
Saami
29
Tagalog
82
Sami
29
MalayRoman
83
Faroese
30
MalayArabic
84
Farsi
31
Amharic
85
Russian
32
Galla
87
Simplified Chinese
33
Oromo
87
Flemish
34
Somali
88
Irish
35
Swahili
89
330
Language
Value
Language
Value
Albanian
36
Kinyarwanda
90
Romanian
37
Rundi
91
Czech
38
Nyanja
92
Slovak
39
Malagasy
93
Slovenian
40
Esperanto
94
Yiddish
41
Welsh
128
Serbian
42
Basque
129
Macedonian
43
Catalan
130
Bulgarian
44
Latin
131
Ukrainian
45
Quechua
132
Belarusian
46
Guarani
133
Uzbek
47
Aymara
134
Kazakh
48
Tatar
135
Azerbaijani
49
Uighur
136
AzerbaijanAr
50
Dzongkha
137
Armenian
51
JavaneseRom
138
Unspecified
32767
331
One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from
the first character and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5
(0x20), subtract 0x60 from the third character, and add the three 16-bit values. This will result in a single 16-bit
value with the three codes correctly packed into the 15 least significant bits and the most significant bit set
to zero.
Example: The ISO language code 'jpn' consists of the three hexadecimal values 0x6A, 0x70, 0x6E. Subtracting
0x60 from each value yields the values 0xA, 0x10, 0xE, as shown in Table 5-2 (page 332).
Table 5-2
Character
UTF-8 code
5-bit value
Shifted value
0x6A
0xA (01010)
0x2800 (01010..........)
0x70
0x10 (10000)
0x200 (.....10000.....)
0x6E
0xE (01110)
0xE (..........01110)
The first value is shifted 10 bits to the left (multiplied by 0x400) and the second value is shifted 5 bits to the
left (multiplied by 0x20). This yields the values 0x2800, 0x200, 0xE. When added, this results in the 16-bit packed
language code value of 0x2A0E.
Matrices
QuickTime files use matrices to describe spatial information about many objects, such as tracks within a movie.
332
A transformation matrix defines how to map points from one coordinate space into another coordinate space.
By modifying the contents of a transformation matrix, you can perform several standard graphics display
operations, including translation, rotation, and scaling. The matrix used to accomplish two-dimensional
transformations is described mathematically by a 3-by-3 matrix.
All values in the matrix are 32-bit fixed-point numbers divided as 16.16, except for the {u, v, w} column, which
contains 32-bit fixed-point numbers divided as 2.30. Figure 5-1 (page 333) and Figure 5-2 (page 333) depict how
QuickTime uses matrices to transform displayed objects.
Figure 5-1
Figure 5-2
tx
ty
x'
y'
'mvhd'
Clipping atom
'clip'
'trak'
'udta'
'ctab'
Required atom
Graphics Modes
QuickTime files use graphics modes to describe how one video or graphics layer should be combined with the
layers beneath it. Graphics modes are also known as transfer modes. Some graphics modes require a color to
be specified for certain operations, such as blending to determine the blend level. QuickTime uses the graphics
modes defined by Apples QuickDraw.
The most common graphics modes are and ditherCopy, which simply indicate that the image should not
blend with the image behind it, but overwrite it. QuickTime also defines several additional graphics modes.
Table 5-3 (page 334) lists the additional graphics modes supported by QuickTime.
333
Table 5-3
Mode
Uses
Code
Description
Copy
0x0
Dither copy
0x40
opcolor
Blend
yes
0x20
Transparent
yes
0x24
Straight alpha
0x100
Premul white
alpha
0x101
Premul black
alpha
0x102
0x104
Similar to straight alpha, but the alpha value used for each
channel is the combination of the alpha channel and that
channel in the opcolor.
0x103
Straight alpha
blend
Composition
(dither copy)
yes
RGB Colors
Many atoms in the QuickTime file format contain RGB color values. These are usually stored as three consecutive
unsigned 16-bit integers in the following order: red, green, blue.
334
Balance
Balance values are represented as 16-bit, fixed-point numbers that range from -1.0 to +1.0. The high-order 8
bits contain the integer portion of the value; the low-order 8 bits contain the fractional part. Negative values
weight the balance toward the left speaker; positive values emphasize the right channel. Setting the balance
to 0 corresponds to a neutral setting.
335
This chapter contains a number of examples that can help you pull together all of the material in this book by
examining the atom structure that results from a number of different scenarios.
The chapter is divided into the following topics:
Creating, Copying, and Disposing of Atom Containers (page 337) discusses the various ways you can work
with atom containers, along with illustrations and sample code that show usage.
Preparing Sound and Subtitle Alternate Groups for Use with Apple Devices (page 346) discusses how
multiple tracks with different languages can be associated with each other.
Creating an Effect Description (page 349) discusses how you create an effect description by creating an
atom container, inserting a QT atom that specifies the effect, and inserting a set of QT atoms that set its
parameters.
Creating Movies with Modifier Tracks (page 355) provides sample code showing you how to create a movie
with modifier tracks.
Authoring Movies with External Movie Targets (page 357) discusses how to author movies with external
targets.
Creating Video Tracks at 30 Frames per Second (page 359) discusses creating 30 fps video.
Creating Video Tracks at 29.97 Frames per Second (page 360) describes creating 29.97 fps video.
Creating Sound Tracks at 44.1 kHz (page 360) provides an example of creating a sound track.
Creating a Timecode Track for 29.97 FPS Video (page 361) presents a timecode track example.
Playing with Edit Lists (page 365) discusses how to interpret edit list data.
Interleaving Movie Data (page 367) shows how a movies tracks are interleaved in the movie data file.
Referencing Two Data Files With a Single Track (page 369) shows how track data may reside in more than
one file.
Getting the Name of a QuickTime VR Node (page 371) discusses how you can use standard QuickTime
atom container functions to retrieve the information in a QuickTime VR node header atom.
Adding Custom Atoms in a QuickTime VR Movie (page 373) describes how to add custom atoms to either
the QuickTime VR world or node information atom containers.
Adding Atom Containers in a QuickTime VR Movie (page 374) shows the code you would use to add VR
world and node information atom containers to a QTVR track.
336
Optimizing QuickTime VR Movies for Web Playback (page 375) describes how to use the QTVR Flattener,
a movie export component that converts an existing QuickTime VR single node movie into a new movie
that is optimized for viewing on the Web.
QTAtomContainer spriteData;
OSErr err
// create an atom container to hold a sprites data
err=QTNewAtomContainer (&spriteData);
When you have finished using an atom container, you should dispose of it by calling the
QTDisposeAtomContainer function. The sample code shown in Listing 6-2 (page 337) calls
QTDisposeAtomContainer to dispose of the spriteData atom container.
Listing 6-2
if (spriteData)
QTDisposeAtomContainer (spriteData);
existing atoms at the same index or greater are moved toward the end of the child list. If you specify a value
of 0 for the index parameter, QTInsertChild inserts the atom at the end of the child list.
337
The code sample in Listing 6-3 (page 338) creates a new QT atom container and calls QTInsertChild to add
an atom. The resulting QT atom container is shown in Figure 6-1 (page 338). The offset value 10 is returned in
the firstAtom parameter.
Listing 6-3
QTAtom firstAtom;
QTAtomContainer container;
OSErr err
err = QTNewAtomContainer (&container);
if (!err)
err = QTInsertChild (container, kParentAtomIsContainer, 'abcd',
1000, 1, 0, nil, &firstAtom);
Figure 6-1
Index = 1
Offset = 10
'abcd'
1000
The following code sample calls QTInsertChild to create a second child atom. Because a value of 1 is specified
for the index parameter, the second atom is inserted in front of the first atom in the child list; the index of
the first atom is changed to 2. The resulting QT atom container is shown in Figure 6-2 (page 339).
QTAtom secondAtom;
338
Figure 6-2
Index = 1
Offset = 10
'abcd'
'abcd'
2000
1000
Index = 2
Offset = 20
You can call the QTFindChildByID function to retrieve the changed offset of the first atom that was inserted,
as shown in the following example. In this example, the QTFindChildByID function returns an offset of 20.
firstAtom = QTFindChildByID (container, kParentAtomIsContainer,
'abcd',
1000, nil);
Listing 6-4 (page 339) shows how the QTInsertChild function inserts a leaf atom into the atom container
sprite. The new leaf atom contains a sprite image index as its data.
Listing 6-4
339
Index= 1
Offset= 10
'abcd'
1000
QT atom
container B
Index = 1
Offset = 10
'defg'
'hijk'
900
2000
Index = 2
Offset = 20
Data
The following code sample calls QTFindChildByID to retrieve the offset of the atom in container A. Then,
the code sample calls the QTInsertChildren function to insert the atoms in container B as children of the
atom in container A. Figure 6-4 (page 341) shows what container A looks like after the atoms from container B
have been inserted.
QTAtom targetAtom;
340
'abcd',
Figure 6-4
'abcd'
Index = 1
Offset = 10
1000
Index = 1
Offset = 20
'defg'
'hijk'
900
2000
Index = 2
Offset = 30
Data
In Listing 6-5 (page 341), the QTInsertChild function inserts a parent atom into the atom container theSample.
Then, the code calls QTInsertChildren to insert the container theSprite into the container theSample.
The parent atom is newSpriteAtom.
Listing 6-5
QuickTime provides three other functions you can use to manipulate atoms in an atom container. The
QTReplaceAtom function replaces an atom and its children with a different atom and its children. You can
call the QTSwapAtoms function to swap the contents of two atoms in an atom container; after swapping, the
ID and index of each atom remains the same. The QTCopyAtom function copies an atom and its children to a
new atom container.
341
You can use the QTCountChildrenOfType and QTGetNextChildType functions to retrieve information
about the types of an atoms children. The QTCountChildrenOfType function returns the number of children
of a given atom type for a parent atom. The QTGetNextChildType function returns the next atom type in
the child list of a parent atom.
You can use the QTFindChildByIndex, QTFindChildByID, and QTNextChildAnyType functions to retrieve
an atom. You call the QTFindChildByIndex function to search for and retrieve a parent atoms child by its
type and index within that type.
Listing 6-6 (page 342) shows the sample code function SetSpriteData, which updates an atom container
that describes a sprite. (For more information about sprites and the Sprite Toolbox, refer to the book
Programming With Wired Movies and Sprite Animation, available at
http://developer.apple.com/techpubs/quicktime/qtdevdocs/RM/PDF.htm.) For each property
of the sprite that needs to be updated, SetSpriteData calls QTFindChildByIndex to retrieve the appropriate
atom from the atom container. If the atom is found, SetSpriteData calls QTSetAtomData to replace the
atoms data with the new value of the property. If the atom is not found, SetSpriteData calls QTInsertChild
to add a new atom for the property.
Listing 6-6
342
// ...
// handle other sprite properties
// ...
}
You can call the QTFindChildByID function to search for and retrieve a parent atoms child by its type and
ID. The sample code function AddSpriteToSample, shown in Listing 6-7 (page 343), adds a sprite, represented
by an atom container, to a key sample, represented by another atom container. AddSpriteToSample calls
QTFindChildByID to determine whether the atom container theSample contains an atom of type
kSpriteAtomType with the ID spriteID. If not, AddSpriteToSample calls QTInsertChild to insert an
atom with that type and ID. A value of 0 is passed for the index parameter to indicate that the atom should
be inserted at the end of the child list. A value of 0 is passed for the dataSize parameter to indicate that the
atom does not have any data. Then, AddSpriteToSample calls QTInsertChildren to insert the atoms in
the container theSprite as children of the new atom. FailIf and FailOSErr are macros that exit the
current function when an error occurs.
Listing 6-7
343
Once you have retrieved a child atom, you can call QTNextChildAnyType function to retrieve subsequent
children of a parent atom. QTNextChildAnyType returns an offset to the next atom of any type in a parent
atoms child list. This function is useful for iterating through a parent atoms children quickly.
QuickTime also provides functions for retrieving an atoms type, ID, and data. You can call QTGetAtomTypeAndID
function to retrieve an atoms type and ID. You can access an atoms data in one of three ways.
To copy an atoms data to a handle, you can use the QTCopyAtomDataToHandle function.
To copy an atoms data to a pointer, you can use the QTCopyAtomDataToPtr function.
To access an atoms data directly, you should lock the atom container in memory by calling
QTLockContainer. Once the container is locked, you can call QTGetAtomDataPtr to retrieve a pointer
to an atoms data. When you have finished accessing the atoms data, you should call the
QTUnlockContainer function to unlock the container in memory.
Modifying Atoms
QuickTime provides functions that you can call to modify attributes or data associated with an atom in an atom
container. To modify an atoms ID, you call the function QTSetAtomID.
You use the QTSetAtomData function to update the data associated with a leaf atom in an atom container.
The QTSetAtomData function replaces a leaf atoms data with new data. The code sample in Listing 6-8 (page
344) calls QTFindChildByIndex to determine whether an atom container contains a sprites visible property.
If so, the sample calls QTSetAtomData to replace the atoms data with a new visible property.
Listing 6-8
QTAtom propertyAtom;
344
// ...
// add the sprite key sample
// ...
// ...
// update the sprite:
// - update the imageIndex
// - update the location
// ...
345
// ...
// update other sprites
// ...
Preparing Sound and Subtitle Alternate Groups for Use with Apple
Devices
Alternate groups are collections of tracks that all serve the same purpose, where any track in the group can
be substituted for another in a movie. Members of the same alternate group have the same identifier value in
the alternate group field in the 'tkhd' (track header) atom; see Track Reference Atoms (page 73) for an
example of alternate tracks for different languages.
This section provides guidelines for the use of alternate groups in movies to be played on Apple devices.
General
For each alternate group:
The group must contain tracks of only one type; for example, only subtitle tracks or only sound tracks.
One track in the group must be enabled; that is, the Track Enabled flag must be set (0x0001) in its track
header ('tkhd').
346
The player must pick a subtitle track even when subtitle display is turned off.
If any of the requirements stated in General (page 346) does not hold, players may act as though there is
no alternate subtitle track information.
As described in Subtitle Sample Data (page 216), a subtitle track can contain any combination of forced (must
be displayed) and non-forced (optionally displayed) subtitle samples, including the possibility of a track that
contains only forced subtitle samples. Even if a user indicates, directly or indirectly, that no subtitles should
be displayed, any available appropriate subtitle track should be enabled so that any forced subtitles in the
track can be displayed. A means by which a player can make a default selection among subtitle alternates in
the absence of a user selection is covered in Relationships Across Alternate Groups (page 348).
For each language in a subtitle alternate group, subtitle tracks can be configured in either of the following
ways:
Single track: Contains any combination of forced and non-forced (regular) subtitle samples.
Track pairs: One track contains any combination of forced and non-forced (regular) subtitle samples and
has a track reference of type 'forc' that references the second track, which contains only forced samples,
as described in Subtitle Sample Data (page 216).
If the user or player picks the language of a track pair, the player application then selects the appropriate track
of the pair. It must select the regular subtitle track if subtitle display is on or the forced-only subtitle track if
subtitle display is off.
If a track pair is present in a subtitle alternate group, a player that displays the track languages of subtitle tracks
may choose to list the language only once. If a player lists both tracks of the pair, the player should display
some kind of distinction between the tracks (for example, including the track names from the 'tnam' user
data in a menu).
If more than one alternate group contains sound tracks, the alternate group that contains the enabled
sound track should be considered to be the primary alternate sound track group. Other alternate groups
containing sound tracks should be ignored.
If there is more than one enabled sound track, or if there is an enabled sound track and a non-sound track
inside the same alternate group, the player may act as though there is no alternate sound track information.
Players may ignore sound tracks that use codecs that are unavailable.
347
A sound track may include a 'folw' (follows) track reference to a corresponding subtitle track.
If a sound track has a 'folw' track reference to a subtitle track, that referenced subtitle track is the default
subtitle track for that sound track.
Each sound track can have either zero or one 'folw' track references to a subtitle track.
If a subtitle track pair is to be made the default, the sound track should have a 'folw' track reference to
the forced subtitle track of the track pair.
If there is no 'folw' track reference to a subtitle track, a player most commonly determines the default
subtitle track by matching aspects of the audio and subtitle tracks, typically by matching the extended
language tag (or language code if there is no language tag) in the set of candidate tracks.
If no match is found by language, a player might choose another candidate track based upon a user
preference (for example, from a list of preferred languages). Another player might choose the first track
in 'trak' box order in the 'moov' among the candidate tracks. Another player might have another mechanism
to choose the default. Possible fall-back approaches are neither enumerated nor restricted here. Note that
selecting no subtitle track may be appropriate.
If the default matching between audio language tagging and subtitle track language tagging cannot be
used, a 'folw' track reference must be authored in the media file. (For example, Norwegian as spoken uses
a different language tag than the two language tags for Norwegian as written.)
348
349
In addition to the kParameterWhatName atom, the effect description for an effect that uses sources must
contain one or more kEffectSourceName atoms. Each of these atoms contains the name of one of the effects
sources. An input map is used to map these names to the actual tracks of the movie that are the sources.
Creating an Input Map (page 352) describes how to create the input map.
350
The two kEffectSourceName atoms specify the two sources that this effect will use, in this case 'srcA' and
'srcB'. The names correspond to entries in the effect tracks input map.
The 'pcnt' parameter atom defines which frames of the effect are shown. This parameter contains a tween
entry, so that the value of this parameter is interpolated as the effect runs . The interpolation of the 'pcnt'
parameter causes consecutive frames of the effect to be rendered, creating the push effect.
The 'from' parameter determines the direction of the push. This parameter is set from an enumeration list,
with 2 being defined as the bottom of the screen.
In this example, the source 'srcB' will push in from the bottom, covering the source 'srcA'.
The 'pcnt' parameter is normally tweened from 0 to 100, so that the effect renders completely, from 0 to
100 percent. In this example, the 'pcnt' parameter is tweened from 25 to 75, so the effect will start 25 percent
of the way through (with 'srcB' already partly on screen) and finish 75 percent of the way through (with part
of 'srcA' still visible).
351
Figure 6-5 (page 352) shows the set of atoms that must be added to the entry description.
Figure 6-5
Byte
kParameterWhatName
'push'
The first source is 'srcA'
which is the name of a source
defined in the input map.
kEffectSourceName
kEffectSourceName
'srcA'
2
'srcB'
Parameter atoms
The percentage value, which
is tweened for 25% to 75%.
'pcnt'
'srcB'
kTweenType
kParamTypeDataFixed
kTweenData
0.25
0.75
'from'
An important property of effect parameters is that most can be tweened (and some must be tweened). Tweening
is QuickTimes general purpose interpolation mechanism (see Tween Media (page 247) for more information).
For many parameters, it is desirable to allow the value of the parameter to change as the effect executes. In
the example shown in Figure 6-5 (page 352), the 'pcnt' parameter must be a tween. This parameter controls
which frame of the effect is rendered at any given time, so it must change for the effect to progress. The 'from'
parameter is not a tween in the example above, but it could be if we wanted the direction of the push to
change during the course of the effect.
352
An input map works in concert with track reference atoms in the source tracks. A track reference atom of type
kTrackModifierReference is added to each source track, which causes that source tracks output to be
redirected to the effects track. An input map is added to the effects track to identify the source tracks and give
a name to each source, such as 'srcA' and 'srcB'. The effect can then refer to the sources by name, specifying
that 'srcB' should slide in over 'srcA', for example.
353
You refer to a kTrackModifierInput atom by its index number, which is returned by the
AddTrackReference function when you create the atom.
Figure 6-6
kTrackModifierInput
'srcB'
kTrackModifierType
It is a video track.
VideoMediaType
The name used in the effect
description is 'scrA'
kEffectDataSourceType
'scrA'
The second reference atom. The ID
number is the number returned
by AddTrackReference
kTrackModifierInput
'srcB'
kTrackModifierType
It is a video track.
2
1
VideoMediaType
The name used in the effect
description is 'scrB'
kEffectDataSourceType
'srcB'
For each source you are creating, you need to call the AddTrackReference function. The track IDs of the
effects track and the source track are passed as parameters to AddTrackReference, which creates an atom
of type kTrackModifierReference and returns an index number. You use this index as the ID of the atom
when you need to refer to it. You then insert the reference into the input map as an atom of type
kTrackModifierInput.
The code in Listing 6-11 (page 354) creates a reference to the track firstSourceTrack, and adds it to the
input map.
Listing 6-11 Adding an input reference atom to an input map
AddTrackReference(theEffectsTrack, firstSourceTrack,
354
kTrackModifierReference, &referenceIndex);
QTInsertChild(inputMap, kParentAtomIsContainer,
kTrackModifierInput, referenceIndex, 0, 0, nil, &inputAtom);
The QTInsertChild function returns the offset of the new modifier input atom in the inputAtom parameter.
You now need to add the name and type of the source track to the modifier input atom. Again, calling the
QTInsertChild function does this, as shown in the following code snippet:
inputType = VideoMediaType;
QTInsertChild(inputMap, inputAtom,
kTrackModifierType, 1, 0, sizeof(inputType), &inputType,
nil);
aType = 'srcA';
QTInsertChild(inputMap, inputAtom, kEffectDataSourceType, 1, 0,
sizeof(aType), &aType, nil);
355
The reference doesnt completely describe the modifier tracks relationship to the track it modifies. Instead,
the reference simply tells the modifier track to send its data to the specified track. The receiving track doesnt
know what it should do with that data. A single track may also be receiving data from more than one modifier
track.
To describe how each modifier input should be used, each tracks media also has an input map. The medias
input map describes how the data being sent to each input of a track should be interpreted by the receiving
track. After creating the reference, it is necessary to update the receiving tracks media input map. When
AddTrackReference is called, it returns the index of the reference added. That index is the index of the input
that needs to be described in the media input map. If the modifier track created above contains regions to
change the shape of the video track, the code shown in Listing 6-13 (page 356) updates the input map
appropriately.
Listing 6-13 Updating the input map
QTAtomContainer inputMap;
QTAtom inputAtom;
OSType inputType;
inputType = kTrackModifierTypeClip;
QTInsertChild (inputMap, inputAtom, kTrackModifierType, 1, 0,
sizeof(inputType), &inputType, nil);
SetMediaInputMap(aVideoMedia, inputMap);
QTDisposeAtomContainer(inputMap);
The media input map allows you to store additional information for each input. In the preceding example,
only the type of the input is specified. In other types of references, you may need to specify additional data.
356
When a modifier track is playing an empty track edit, or is disabled or deleted, all receiving tracks are notified
that the track input is inactive. When an input becomes inactive, it is reset to its default value. For example, if
a track is receiving data from a clip modifier track and that input becomes inactive, the shape of the track
reverts to the shape it would have if there were no clip modifier track.
<kTargetMovieName>
[Pstring MovieName]
OR
<kTargetMovieID>
[long MovieID]
OR
[(kExpressionAtoms)]
To tag a movie with a name or ID, you add a user data item of type 'plug' to the movies user data. The index
of the user data does not matter. The data specifies the name or ID.
You add a user data item of type 'plug' to the movies user data with its data set to
"Movieid=MovieName"
357
You add a user data item of type 'plug' to the movies user data with its data set to
"Movieid=MovieID"
kTargetRootMovie (leaf atom, no data). This is the root movie containing the action handler.
Note that there are five ways to specify an embedded child movie. Three of them specify movie track properties.
Two specify properties of the currently loaded movie in a movie track.
kTargetChildMovieMovieName. A child movie specified by the currently loaded movies movie name.
The child movie must contain movieName user data with the specified name.
358
kTargetChildMovieMovieID. A child movie specified by the currently loaded movies movie ID. The
child movie must contain movieID user data with the specified ID.
Field
Value
Atom size
24
Atom type
'stts'
Version/Flags
Number of entries
Sample count
Sample duration
20
359
Field
Value
Atom size
24
Atom type
'stts'
Version/Flags
Number of entries
Sample count
Sample duration
100
360
Table 6-3
Field
Value
Atom size
24
Atom type
'stts'
Version/Flags
Number of entries
Sample count
Sample duration
This atom does not indicate whether the audio is stereo or mono or whether it contains 8-bit or 16-bit samples.
That information is stored in the sound sample description atom, which is contained in the sample table atom.
80
Atom type
'gmhd'
Atom size
24
361
Atom type
'gmin'
Version/Flags
Graphics mode
0x0040
Opcolor (red)
0x8000
Opcolor (green)
0x8000
Opcolor (blue)
0x8000
Balance
Reserved
Atom size
48
Atom type
'tmcd'
Atom size
40
Atom type
'tcmi'
Version/Flags
Text font
0 (system font)
Text face
0 (plain)
Text size
12
Padding
Font name
362
The sample table atom contains all the standard sample atoms and has the following data values:
Atom
size
174
Atom
type
Atom size
74
Atom type
Version/Flags
Number of entries
58
'tmcd'
Reserved [1]
Flags[1]
Time scale[1]
2997
Frame duration[1]
100
20
Atom size
Atom size
24
Atom type
'name'
String length
12
Language code
0
(English)
Name
my
tape
name
24
363
Atom type
Version/Flags
Number of entries
Sample count[1]
Sample duration[1]
Atom size
28
Atom type
Version/Flags
Number of entries
First chunk[1]
Atom size
20
Atom type
Version/Flags
Sample size
Number of entries
Atom size
20
Atom type
Version/Flags
Number of entries
Offset [1]
In the example, lets assume that the segments beginning timecode is 1:15:32.4 (1 hour, 15 minutes, 32 seconds,
and 4 frames). The time would be expressed in the data file as 0x010F2004 (0x01 = 1 hour; 0x0F = 15 minutes;
0x20 = 32 seconds; 0x04 = 4 frames).
364
The video and sound tracks must contain a track reference atom to indicate that they reference this timecode
track. The track reference is the same for both and is contained in the track atom (at the same level as the track
header and media atoms).
This track reference would contain the data values listed in Table 6-4 (page 365).
Table 6-4
Field
Value
Atom size
12
Atom type
'tref'
Reference type
'tmcd'
In this example, the video and sound tracks are tracks 1 and 2. The timecode track is track 3.
Atom size
36
Atom type
'edts'
Atom size
28
Atom type
'elst'
Version/Flags
Number of entries
Track duration
Media time
365
Media rate
1.0
Because this is a single-track move, the tracks duration in the track header atom is 6000 and the movies
duration in the movie header atom is 6000.
If you change the track to play the media from time 0 to time 2 seconds, and then play the media from time
0 to time 10 seconds, the edit atom would now contain these data values:
Atom size
48
Atom type
'edts'
Atom size
40
Atom type
'elst'
Version/Flags
Number of entries
Track duration[1]
1200 (2 seconds)
Media time[1]
Media rate[1]
1.0
Track duration[2]
Media time[2]
Media rate[2]
1.0
Because the track is now 2 seconds longer, the tracks duration in the track header atom must now be 7200,
and the movies duration in the movie header atom must also be 7200.
Currently, the media plays from time 0 to time 2, then plays from time 0 to time 10. If you take that repeated
segment at the beginning (time 0 to time 2) and play it at double speed to maintain the original duration, the
edit atom would now contain the following values:
Atom size
60
Atom type
'edts'
Atom size
52
366
Atom type
'elst'
Version/Flags
Number of entries
Track duration[1]
600 (1 second)
Media time[1]
Media rate[1]
2.0
Track duration[2]
600 (1 second)
Media time[2]
Media rate[2]
2.0
Track duration[3]
4800 (8 seconds)
Media time[3]
200
Media rate[3]
1.0
Because the track is now back to its original duration of 10 seconds, its duration in the track header atom is
6000, and the movies duration in the movie header atom is 6000.
367
Figure 6-7 (page 368) shows how the movie data was collected, and how the data would need to be played
back for proper synchronization. In this example, the video data is recorded at 10 frames per second and the
audio data is grouped into half-second chunks.
Figure 6-7
2 sec
3 sec
Time
Video track
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Audio track
After the data has been interleaved on the disk, the movie data atom would contain movie data in the order
shown in Figure 6-8 (page 368).
Figure 6-8
'mdat'
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
In this example, the file begins with the movie atom ('moov'), followed by the movie data atom ('mdat'). In
order to overcome any latencies in sound playback, at least one second of sound data is placed at the beginning
of the interleaved data. This means that the sound and video data are offset from each other in the file by one
second.
368
Atom type
'stsd'
Version/Flags
Number of entries
2
Sample description size[1]
Data format
'tmcd'
Reserved
(sample data)
Data format
'tmcd'
Reserved
(sample data)
If there is only 1 sample per chunk and the first 10 samples are extracted from sample description 2 and the
next 30 samples are extracted from sample description 1, the sample-to-chunk atom would contain the following
data values:
Atom size
40
Atom type
'stsc'
Version/Flags
369
Number of entries
First chunk[1]
First chunk[2]
11
The data reference atom would contain the following data values:
Atom size
Atom type
'dinf'
Atom size
Atom type
'dref'
Version/Flags
Number of entries
Size[1]
Type[1]
'alis'
Version[1]
Flags[1]
Data reference[1]
Size[2]
Type[2]
'rsrc'
Version[2]
Flags[2]
Data reference[2]
370
theErr = noErr;
QTAtomContainer
theNodeInfo;
QTVRNodeHeaderAtomPtr
theNodeHeader;
QTAtom
theNodeHeaderAtom = 0;
1,
nil);
if (theNodeHeaderAtom != 0) {
QTLockContainer(theNodeInfo);
nil,
*)&theNodeHeader);
QTAtom theNameAtom;
theNameAtom = QTFindChildByID(theNodeInfo, kParentAtomIsContainer,
kQTVRStringAtomType, theNodeHeader->nameAtomID,
nil);
if (theNameAtom != 0) {
371
VRStringAtomPtr theStringAtomPtr;
the string.
nil,
(Ptr
*)&theStringAtomPtr);
if (!theErr) {
short theLen = theStringAtomPtr->stringLength;
if (theLen > 255)
theLen = 255;
BlockMove(theStringAtomPtr->string, &theStringPtr[1],
theLen);
theStringPtr[0] = theLen;
}
}
}
QTUnlockContainer(theNodeInfo);
}
QTDisposeAtomContainer(theNodeInfo);
return(theErr);
}
The MyGetNodeName function defined in Listing 6-14 (page 371) retrieves the node information atom container
(by calling QTVRGetNodeInfo) and then looks inside that container for the node header atom with atom ID
1. If it finds one, it locks the container and then gets a pointer to the node header atom data. The desired
information, the node name, is contained in the string atom whose atom ID is specified by the nameAtomID
field of the node header structure. Accordingly, the MyGetNodeName function then calls QTFindChildByID
once again to find that string atom. If the string atom is found, MyGetNodeName calls QTGetAtomDataPtr
to get a pointer to the string atom data. Finally, MyGetNodeName copies the string data into the appropriate
location and cleans up after itself before returning.
372
// It's our type of hot spot - don't let anyone else handle
*cancel = true;
373
it
0, 0);
1, nil);
if (myAtom != 0) {
OSErr err;
// Copy the custom data into our structure
err = QTCopyAtomDataToPtr (nodeInfo, myAtom, false,
sizeof(CustomData), &myCustomData, nil);
if (err == noErr)
// Do something with it
DoMyHotSpotStuff (hotSpotID, &myCustomData);
}
}
Your intercept procedure is called for clicks on any hot spot. You should check to see if it is your type of hot
spot and, if so, extract the custom hot spot atom and do whatever is appropriate for your hot spot type
(DoMyHotSpotStuff).
When you no longer need the intercept procedure you should call QTVRInstallInterceptProc again with
the same selector and a nil procedure pointer and then call DisposeRoutineDescriptor on myProc.
Apple reserves all hot spot and atom types with lowercase letters. Your custom hot spot type should contain
all uppercase letters.
// Create a
374
vrWorld) -
sizeof(UInt32);
qtvrSampleDesc = (QTVRSampleDescriptionHandle) NewHandleClear (descSize);
(*qtvrSampleDesc)->size = descSize;
(*qtvrSampleDesc)->type = kQTVRQTVRType;
// Copy the VR world atom container data into the QTVR sample description
BlockMove (*((Handle) vrWorld), &((*qtvrSampleDesc)->data),
GetHandleSize((Handle) vrWorld));
// Now add it to the QTVR track's media
err = BeginMediaEdits (qtvrMedia);
err = AddMediaSample (qtvrMedia, (Handle) nodeInfo, 0,
GetHandleSize((Handle) nodeInfo), duration,
(SampleDescriptionHandle) qtvrSampleDesc, 1, 0, &sampleTime);
err = EndMediaEdits (qtvrMedia);
InsertMediaIntoTrack (qtvrTrack, trackTime, sampleTime, duration,
1L<<16);
The duration value is computed based on the duration of the corresponding image track samples for the
node. The value of trackTime is the time for the beginning of the current node (zero for a single node movie).
The values of duration and sampleTime are in the time base of the media; the value of trackTime is in the
movies time base.
375
nil, 0, 0);
The code fragment shown in Listing 6-17 (page 376) creates a flattened movie file specified by the myFileSpec
parameter. If your QuickTime VR movie is a panorama, the flattened movie file includes a quarter size, blurred
JPEG, compressed preview of the panorama image.
Note: The constants MovieExportType and MovieFileType used in Listing 6-17 (page 376) are
defined in header files QuickTimeComponents.h and Movies.h respectively and are defined as
'spit' and 'MooV'.
You can present users with the QTVR Flatteners own dialog box to allow them to choose options such as how
to compress the preview image or to select a separate preview image file. Use the following code to show the
dialog box:
376
nil, 0, 0,
If the user cancels the dialog box, then the Boolean cancel is set to true.
If you do not want to present the user with the flatteners dialog box, you can communicate directly with the
component by using the MovieExportSetSettingsFromAtomContainer routine as described in the
following paragraphs.
If you want to specify a preview image other than the default, you need to create a special atom container
and then call MovieExportSetSettingsFromAtomContainer before calling MovieExportToFile. You
can specify how to compress the image, what resolution to use, and you can even specify your own preview
image file to be used. The atom container you pass in can have various atoms that specify certain export
options. These atoms must all be children of a flattener settings parent atom.
The preview resolution atom is a 16-bit value that allows you to specify the resolution of the preview image.
This value, which defaults to kQTVRQuarterRes, indicates how much to reduce the preview image.
The blur preview atom is a Boolean value that indicates whether to blur the image before compressing. Blurring
usually results in a much more highly compressed image. The default value is true.
The create preview atom is a Boolean value that indicates whether a preview image should be created. The
default value is true.
The import preview atom is a Boolean value that is used to indicate that the preview image should be imported
from an external file rather than generated from the image in the panorama file itself. This allows you to have
any image you want as the preview for the panorama. You can specify which file to use by also including the
import specification atom, which is an FSSpec data structure that identifies the image file. If you do not include
this atom, then the flattener presents the user with a dialog box asking the user to select a file. The default for
import preview is false. If an import file is used, the image is used at its natural size and the resolution setting
is ignored.
377
err = QTNewAtomContainer(&exportData);
// create a parent for the other settings atoms
err = QTInsertChild (exportData, kParentAtomIsContainer,
QTVRFlattenerParentAtomType, 1, 0, 0, nil, &parent);
// Add child atom to indicate we want to import the preview from
a file
1, 0,
1, 0,
Overriding the compression settings is a bit more complicated. You need to open a standard image compression
dialog component and make calls to obtain an atom container that you can then pass to the QTVR Flattener
component.
Listing 6-19 Overriding the compression settings
ComponentInstance sc;
QTAtomContainer compressorData;
SCSpatialSettings ss;
sc = OpenDefaultComponent(StandardCompressionType,StandardCompressionSubType);
ss.codecType = kCinepakCodecType;
ss.codec = nil;
ss.depth = 0;
ss.spatialQuality = codecHighQuality
err = SCSetInfo(sc, scSpatialSettingsType, &ss);
err = SCGetSettingsAsAtomContainer(sc, &compressorData);
MovieExportSetSettingsFromAtomContainer (qtvrExport, compressorData);
378
Note: The QuickTime Image File Format is deprecated in the QuickTime file format. The information
that follows is intended to document existing content containing QuickTime image file media and
should not be used for new development.
This appendix describes QuickTime image files, which provide a useful container for QuickTime-compressed
still images.
Most still image file formats define both how images should be stored and compressed. However, the QuickTime
image file format is a container format, which describes a storage mechanism independent of compression.
The QuickTime image file format uses the same atom-based structure as a QuickTime movie.
379
Figure A-1 (page 380) and Table A-1 (page 380) show an example QuickTime image file containing a
JPEG-compressed image.
Figure A-1
Type = 'idsc'
Image description
Variable
Type = 'idat'
Image data
Table A-1
Variable
0000005E
69647363
00000056
6A706567
00000000
Reserved, set to 0
0000
Reserved, set to 0
0000
Reserved, set to 0
00000000
6170706C
00000000
00000200
0140
380
00F0
00480000
00480000
00003C57
0001
Frame count, 1
0C 50 68 6F 74 6F 20 2D20
4A 50 45 47 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0018
FFFF
00003C5F
69646174
FF D8 FF E0 00 10 4A 46
49 46 00 01 01 01 00 48
...
Important: The exact order and size of atoms is not guaranteed to match the example in Figure A-1 (page
380). Applications reading QuickTime image files should always use the atom size to traverse the file and
ignore atoms of unrecognized types.
Note: Like QuickTime movie files, QuickTime image files are big-endian. However, image data is
typically stored in the same byte order as specified by the particular compression format.
381
The QuickTime file format provides a great deal of flexibility in how media data is physically arranged within
a file. However, it also allows media layouts to be created that may be inefficient for playback on a given device.
To complicate the matter, a media layout that is inefficient for one device may be, in fact, very efficient for
another. The purpose of this appendix is to define some common uses of QuickTime files and describe the
media layout in these circumstances.
382
Take a scenario where the QuickTime file contains a single hint track that references an audio and a visual
media stream. In order to eliminate all seeks, the hint track media must be interleaved with the audio and
visual stream data. Because the hint track sample must always be read before the audio and visual media that
it references, the hint track samples must always immediately precede the samples they reference.
A simple illustration of the ordering of data (that is, time and file offset increasing from left to right) is as follows:
H0 A0 H1 V1 H2 V2 H3 A1 H4 A2 V3 H5 V4
When a single hint sample references multiple pieces of media data, those pieces of media data must occur
in the order that they are referenced.
383
Random Access
This appendix describes how to seek with a QuickTime file using child atoms.
If the track contains an edit list, determine which edit contains the time T by iterating over the edits. The
start time of the edit in the movie time scale must then be subtracted from the time T to generate T', the
duration into the edit in the movie time scale. T' is next converted to the time scale of the tracks media
to generate T''. Finally, the time in the media scale to use is calculated by adding the media start time of
the edit to T''.
2.
The time-to-sample atom for a track indicates what times are associated with which sample for that track.
Use this atom to find the first sample prior to the given time.
3.
The sample that was located in step 1 may not be a random access point. Locating the nearest random
access point requires consulting two atoms. The sync sample table indicates which samples are in fact
random access points. Using this table, you can locate which is the first sync sample prior to the specified
time. The absence of the sync sample table indicates that all samples are synchronization points, and
makes this problem easy. The shadow sync atom gives the opportunity for a content author to provide
samples that are not delivered in the normal course of delivery, but which can be inserted to provide
additional random access points. This improves random access without impacting bit rate during normal
delivery. This atom maps samples that are not random access points to alternate samples which are. You
should also consult this table if present to find the first shadow sync sample prior to the sample in question.
Having consulted the sync sample table and the shadow sync table, you probably wish to seek to whichever
resultant sample is closest to, but prior to, the sample found in step 1.
4.
At this point you know the sample that will be used for random access. Use the sample-to-chunk table to
determine in which chunk this sample is located.
5.
Knowing which chunk contained the sample in question, use the chunk offset atom to figure out where
that chunk begins.
384
Random Access
Seeking With a QuickTime File
6.
Starting from this offset, you can use the information contained in the sample-to-chunk atom and the
sample size atom to figure out where within this chunk the sample in question is located. This is the desired
information.
385
Metadata Handling
This appendix describes how metadata is handled when QuickTime imports other file formats. (For more
information about metadata, refer to Overview of QTFF (page 20) and Compressed Movie Resources (page
117)).
These formats are grouped into the following categories and sections:
Each section includes a table with specific details on the following, where applicable:
The format supported by QuickTimefor example, the movie import component or the graphics import
component
Specific details for metadata handlingfor example, all Microsoft-defined tombstone data is transferred
to the imported movies user data. metadata fields that have QuickTime equivalents are mapped as follows.
Description
files
Supported by
'VfW '
.avi
386
Metadata Handling
Digital Audio File Formats
Description
files
metadata handling
Software required
QuickTime 3
Description
Supported by
.mp3, .swa
Metadata handling
Metadata from ID3v1-style MP3 files is imported into the QuickTime movie.Title
maps to kUserDataTextFullName, artist maps to 'ART', album maps to
'alb', year maps to 'day', comment maps to 'cmt', and track number
maps to 'des'.
Software required
QuickTime 4
WAV
Description
Supported by
'WAVE', '.WAV'
.wav
387
Metadata Handling
Still Image File Formats
WAV
Description
Metadata handling
Software required
Description
Supported by
'FPix'
.fpx
Metadata handling
Formats supported
1.0
Software required
QuickTime 4
GIF
Description
Supported by
.gif
388
Metadata Handling
Still Image File Formats
GIF
Description
Metadata handling
The GIF comment field is transferred to the kUserDataDateTextInformation user data item.
Software required
JFIF/JPEG
Description
Supported by
'JPEG
.jpg
Metadata handling
The JFIF comment field is transferred to the imported Movies user data in
the kUserDataTextInformation field.
Software required
Photoshop
Description
Supported by
'8BPS'
.psd
Metadata handling
Software required
Description
Supported by
'qtif'
389
Metadata Handling
Animation and 3D File Formats
Description
Metadata handling
Formats supported
All
Software required
TIFF
Description
Supported by
'TIFF'
.tif, .tiff
Metadata handling
Software required
QuickTime 3 or later
Description
Supported by
'GIFf'
.gif
Metadata handling
Software required
QuickTime 3 or later
390
Note: VR Media is deprecated in the QuickTime file format. The information that follows is intended
to document existing content containing VR media and should not be used for new development.
This appendix includes information that pertains to Chapter 3, VR World Atom Container (page 280) and Node
Information Atom Container (page 287).
C Summary
Constants
VR World Atom Types
enum {
kQTVRWorldHeaderAtomType
= FOUR_CHAR_CODE('vrsc'),
kQTVRImagingParentAtomType
= FOUR_CHAR_CODE('imgp'),
kQTVRPanoImagingAtomType
= FOUR_CHAR_CODE('impn'),
kQTVRObjectImagingAtomType
= FOUR_CHAR_CODE('imob'),
kQTVRNodeParentAtomType
= FOUR_CHAR_CODE('vrnp'),
kQTVRNodeIDAtomType
= FOUR_CHAR_CODE('vrni'),
kQTVRNodeLocationAtomType
= FOUR_CHAR_CODE('nloc')
};
= FOUR_CHAR_CODE('ndhd'),
kQTVRHotSpotParentAtomType
= FOUR_CHAR_CODE('hspa'),
kQTVRHotSpotAtomType
= FOUR_CHAR_CODE('hots'),
391
kQTVRHotSpotInfoAtomType
= FOUR_CHAR_CODE('hsin'),
kQTVRLinkInfoAtomType
= FOUR_CHAR_CODE('link')
};
= FOUR_CHAR_CODE('vrsg'),
kQTVRPanoSampleDataAtomType
= FOUR_CHAR_CODE('pdat'),
kQTVRObjectInfoAtomType
= FOUR_CHAR_CODE('obji'),
kQTVRAltImageTrackRefAtomType
= FOUR_CHAR_CODE('imtr'),
kQTVRAltHotSpotTrackRefAtomType = FOUR_CHAR_CODE('hstr'),
kQTVRAngleRangeAtomType
= FOUR_CHAR_CODE('arng'),
kQTVRTrackRefArrayAtomType
= FOUR_CHAR_CODE('tref'),
kQTVRPanConstraintAtomType
= FOUR_CHAR_CODE('pcon'),
kQTVRTiltConstraintAtomType
= FOUR_CHAR_CODE('tcon'),
kQTVRFOVConstraintAtomType
= FOUR_CHAR_CODE('fcon'),
kQTVRCubicViewAtomType
= FOUR_CHAR_CODE('cuvw'),
kQTVRCubicFaceDataAtomType
= FOUR_CHAR_CODE('cufa')
};
= FOUR_CHAR_CODE('imgt'),
kQTVRHotSpotTrackRefType
= FOUR_CHAR_CODE('hott')
};
= 1 << 0,
kQTVRValidQuality
= 1 << 1,
kQTVRValidDirectDraw
= 1 << 2,
kQTVRValidFirstExtraProperty
= 1 << 3
392
};
= 1 << 0,
kQTVRValidTilt
= 1 << 1,
kQTVRValidFOV
= 1 << 2,
kQTVRValidViewCenter
= 1 << 3
};
Animation Settings
enum QTVRAnimationSettings {
kQTVRObjectAnimateViewFramesOn
= (1 << 0),
kQTVRObjectPalindromeViewFramesOn
= (1 << 1),
kQTVRObjectStartFirstViewFrameOn
= (1 << 2),
kQTVRObjectAnimateViewsOn
= (1 << 3),
kQTVRObjectPalindromeViewsOn
= (1 << 4),
kQTVRObjectSyncViewToFrameRate
= (1 << 5),
kQTVRObjectDontLoopViewFramesOn
= (1 << 6),
kQTVRObjectPlayEveryViewFrameOn
= (1 << 7)
};
Control Settings
enum QTVRControlSettings {
kQTVRObjectWrapPanOn
= (1 << 0),
kQTVRObjectWrapTiltOn
= (1 << 1),
kQTVRObjectCanZoomOn
= (1 << 2),
kQTVRObjectReverseHControlOn
= (1 << 3),
kQTVRObjectReverseVControlOn
= (1 << 4),
kQTVRObjectSwapHVControlOn
= (1 << 5),
kQTVRObjectTranslationOn
= (1 << 6)
};
393
= FOUR_CHAR_CODE('ctyp').
kQTControllerID
= 1
};
= 1,
kOldJoyStickUI
= 2,
kJoystickUI
= 3,
kGrabberUI
= 4,
kAbsoluteUI
= 5
};
= 0
};
= 1 << 0,
kQTVRPanoFlagAlwaysWrap
= 1 << 2
};
Data Types
typedef float
Float32;
394
size;
UInt32
type;
UInt32
reserved1;
UInt16
reserved2;
UInt16
dataRefIndex;
UInt32
data;
stringUsage;
UInt16
stringLength;
unsigned char
string[4];
} QTVRStringAtom, *QTVRStringAtomPtr;
majorVersion;
UInt16
minorVersion;
QTAtomID
nameAtomID;
UInt32
defaultNodeID;
UInt32
vrWorldFlags;
UInt32
reserved1;
UInt32
reserved2;
} QTVRWorldHeaderAtom, *QTVRWorldHeaderAtomPtr;
majorVersion;
UInt16
minorVersion;
395
UInt32
imagingMode;
UInt32
imagingValidFlags;
UInt32
correction;
UInt32
quality;
UInt32
directDraw;
UInt32
imagingProperties[6];
UInt32
reserved1;
UInt32
reserved2;
} QTVRPanoImagingAtom, *QTVRPanoImagingAtomPtr;
majorVersion;
UInt16
minorVersion;
OSType
nodeType;
UInt32
locationFlags;
UInt32
locationData;
UInt32
reserved1;
UInt32
reserved2;
} QTVRNodeLocationAtom, *QTVRNodeLocationAtomPtr;
majorVersion;
UInt16
minorVersion;
OSType
nodeType;
QTAtomID
nodeID;
QTAtomID
nameAtomID;
QTAtomID
commentAtomID;
UInt32
reserved1;
UInt32
reserved2;
} QTVRNodeHeaderAtom, *QTVRNodeHeaderAtomPtr;
396
majorVersion;
UInt16
minorVersion;
OSType
hotSpotType;
QTAtomID
nameAtomID;
QTAtomID
commentAtomID;
SInt32
cursorID[3];
Float32
bestPan;
Float32
bestTilt;
Float32
bestFOV;
FloatPoint
bestViewCenter;
Rect
hotSpotRect;
UInt32
flags;
UInt32
reserved1;
UInt32
reserved2;
} QTVRHotSpotInfoAtom, *QTVRHotSpotInfoAtomPtr;
majorVersion;
UInt16
minorVersion;
UInt32
toNodeID;
UInt32
fromValidFlags;
Float32
fromPan;
Float32
fromTilt;
Float32
fromFOV;
FloatPoint
fromViewCenter;
UInt32
toValidFlags;
Float32
toPan;
Float32
toTilt;
Float32
toFOV;
FloatPoint
toViewCenter;
Float32
distance;
397
UInt32
flags;
UInt32
reserved1;
UInt32
reserved2;
} QTVRLinkHotSpotAtom, *QTVRLinkHotSpotAtomPtr;
minimumAngle;
Float32
maximumAngle;
} QTVRAngleRangeAtom, *QTVRAngleRangeAtomPtr;
majorVersion;
UInt16
minorVersion;
UInt32
imageRefTrackIndex;
UInt32
hotSpotRefTrackIndex;
Float32
minPan;
Float32
maxPan;
Float32
minTilt;
Float32
maxTilt;
Float32
minFieldOfView;
Float32
maxFieldOfView;
Float32
defaultPan;
Float32
defaultTilt;
Float32
defaultFieldOfView;
UInt32
imageSizeX;
UInt32
imageSizeY;
UInt16
imageNumFramesX;
UInt16
imageNumFramesY;
UInt32
hotSpotSizeX;
UInt32
hotSpotSizeY;
UInt16
hotSpotNumFramesX;
398
UInt16
hotSpotNumFramesY;
UInt32
flags;
UInt32
reserved1;
UInt32
reserved2;
} QTVRPanoSampleAtom, *QTVRPanoSampleAtomPtr;
minPan;
Float32
maxPan;
Float32
minTilt;
Float32
maxTilt;
Float32
minFieldOfView;
Float32
maxFieldOfView;
Float32
defaultPan;
Float32
defaultTilt;
Float32
defaultFieldOfView;
};
typedef struct QTVRCubicViewAtom
QTVRCubicViewAtom;
orientation[4];
float
center[2];
float
aspect;
float
skew;
};
typedef struct QTVRCubicFaceData
QTVRCubicFaceData;
399
UInt16
majorVersion;
UInt16
minorVersion;
UInt16
movieType;
UInt16
viewStateCount;
UInt16
defaultViewState;
UInt16
mouseDownViewState;
UInt32
viewDuration;
UInt32
columns;
UInt32
rows;
Float32
mouseMotionScale;
Float32
minPan;
Float32
maxPan;
Float32
defaultPan;
Float32
minTilt;
Float32
maxTilt;
Float32
defaultTilt;
Float32
minFieldOfView;
Float32
fieldOfView;
Float32
defaultFieldOfView;
Float32
defaultViewCenterH;
Float32
defaultViewCenterV;
Float32
viewRate;
Float32
frameRate;
UInt32
animationSettings;
UInt32
controlSettings;
} QTVRObjectSampleAtom, *QTVRObjectSampleAtomPtr;
trackRefType;
UInt16
trackResolution;
UInt32
trackRefIndex;
};
typedef struct QTVRTrackRefEntry QTVRTrackRefEntry;
400
Note: Profile atoms are deprecated in the QuickTime file format. The information that follows is
intended to document existing content containing profile atoms and should not be used for new
development.
This appendix introduces and defines some of the ways that profile information about a QuickTime movie file
can be summarized in a profile atom near the beginning of the file, so that software reading the file can easily
determine some aspects of its features and complexity.
The information in this appendix should not be seen as a replacement for, or even a functional overlap with,
the definition of the file-type atom. The file-type atom expresses which specifications a file is compatible with:
reading software should not attempt to play files unless they are compatible with one or more specifications
the reader implements, and should not refuse to play a file if it is marked as so compatible. However, reading
software may use profiling information to issue warnings, request user decisions, and so on.
Reading software should not present excessive warnings to the user in the absence of summarized features.
Additionally, readers are encouraged to try to play content even though crucial profile information is missing
or incomplete.
Profiles may exist at the movie level or the track level. Track-level profiles summarize features of that track
only. Movie-level profiles may summarize features across tracks or summarize features that are only relevant
at the movie level (for example, the movies maximum bit rate).
If the movie contains runtime variables that might affect a feature, such as the presence of alternate tracks
that would affect the movie bit-rate, the affected feature should either be absent or report the worst case (for
example, the highest bit-rate).
If a feature value cannot be accurately represented (for example, the value is not an integer, but the field is
formatted as an integer) then the value should be rounded up to the nearest representable value.
401
The responsibilities placed upon a writer of a movie (such as QuickTime or a consumer electronics (CE) device)
are described in the features Writer Responsibilities section. A description of the algorithm to be used to
calculate values is provided.
The features Reader Responsibilities section explains how reading software should interpret the value. In some
cases, there are warnings to indicate how the reader must not use the value (for example, not interpreting the
maximum bit rate value as the current bit rate).
Container
Movie atom ('moov') or track atom ('trak')
Mandatory
No
Quantity
Zero or one
At the movie level, the profile atom must occur within the movie atom before the movie header atom. A reader
may stop the search for the profile atom once the profile atom or the movie header atom is found. Because
new atoms may be introduced into the movie atom (type 'moov') in the future, a reader must not expect the
first child atom of the movie atom to be either the profile (type 'prfl') or the movie header ('mvhd') atom.
This rule allows for new atoms in the future but still accommodates readers that do not want to perform an
exhaustive enumeration of all the child atoms in a movie atom.
The profile atom expresses profiles or feature codes for features that occur in the movie. The list is not necessarily
exhaustive, and there may be multiple profile values recorded for the same profile code. For example, if there
are two independent sequences of MPEG-4 video in the movie, using different profile-level IDs, both might
be recorded here.
Each feature is either universal or is documented in a specific specification, identified by a brand as used in
the file type atom. The only brands that should occur in a given profile atom are the universal brand or brands
that occur in the file type atom in the same file.
402
Feature value ranges should in general never include an unknown point; if the value of a feature is unknown,
the feature should be absent from the profile atom.
Feature values should be deducible by fairly simple inspection of the rest of the movie: for example, extracting
the profile-level ID from a video header, or calculations using information from the sample table (for example,
overall average bit rate by summing the sample sizes and the sample durations). It is not appropriate to have
features which cannot be computed, or only computed with difficulty (e.g. a buffer model estimation which
requires emulating a video decoder on the entire bit stream). The algorithm to extract or deduce the feature
value from the rest of the file must be defined.
Empty slots in the profile atom structure must be filled with zeroes.
If there are multiple parts of the file to which the same feature apply, yet they have different feature values,
then either there must be entries for each occurrence or none at all. For example, if there are two MPEG-4
visual sequences, using different visual profiles, there are either two profile entries in the profile table (one for
each sequence) or none at all. Features must not be partially documented.
Profile atoms may also occur at the track level. A track-level profile atom must occur within the track atom
before the track header atom ('tkhd'). A reader should stop searching for a tracks profile atom if either the
profile or the track header atom is found, ignoring any other atoms present.
A track profile atom should only summarize features within that track. If track profile atoms exist, a movie
profile atom can be built largely by copying feature entries from the profile atom of the movies tracks to the
profile atom at the movie level. It is possible to have multiple track profiles with different values which must
be resolved to a single value for the movie as whole, howeversuch as multiple video tracks with different
maximum bit ratesso not all features can be copied directly from the track to the movie profile. Additionally,
the movie profile may summarize features that cannot occur at the track level, such as total movie bit rate.
When building a movie profile, you must include either all instances of a track-level feature or no instances of
that feature. For example, if you have multiple video tracks that use different codecs, you must either include
an entry at the movie level for each codec, or put no codec feature entries at the movie level at all.
403
Figure F-1 (page 404) shows the layout of the profile atom.
Figure F-1
Type = 'prfl'
Version
Flags
4
n x 32
Syntax
aligned(8) class ProfileAtom
extends FullAtom('prfl') {
unsigned int(32) feature-record-count;
for (i=1; i<feature-record-count; i++) {
unsigned int(32) reserved = 0;
unsigned int(32) part-ID;
unsigned int(32) feature-code;
unsigned int(32) feature-value
}
}
Semantics
reserved
Either a brand identifier that occurs in the file-type atom of the same file, indicating a feature that is
specific to this brand, or the value 0x20202020 (four ASCII spaces) indicating a universal feature that can
be found in any file type that allows the profile atom. The value 0 is reserved for an empty slot.
404
feature-code
A four-character code either documented here (universal features), or in the specification identified by
the brand. The value of 0 is reserved for an empty slot with no meaningful feature-value.
feature-value
Either a value from an enumerated set (for example, 1 or 0 for true or false, or an MPEG-4 profile-level
ID) or a value that can compared (for example, bit rate as an integer or dimensions as a 32-bit packed
structure).
The profile atom is a full atom, so it has an 8-bit version and 24 bits of flags. For this specification, the version
is 0 and the flags have the value 0. A reader compliant with this specification should treat any profile atom
with a nonzero version value as if it did not exist.
Figure F-2 (page 405) shows the layout of a typical feature.
Figure F-2
Value = 0x00000001
Universal Features
A feature consists of four fields: a reserved field, which is set to zero; a part-ID, which specifies which brand
the feature belongs to; a feature code, which identifies the feature; and a value field, which holds the feature
value).
The part-ID can be either universal or brand-specific. Universal features have a part-ID of four ASCII spaces
(0x20202020). Brand-specific features have a part-ID for a particular brand, which is taken from the
Compatible_brands field of the file type atom. Brand-specific features of QuickTime files have a part-ID of 'qt
'. All features listed in this section are universal features; that is, they can be used in any file that includes a
profile atom.
It is permissible to use the feature code of 0x00000000 as a placeholder, paired with a feature value of
0x00000000 for one or more features. Readers should simply ignore features having a feature code of zero.
No feature will exist to describe the unit of other features, such as bit rate. The device should consider the
magnitude and tailor its display appropriately.
405
This specification describes only how features are stored in files. It does not require that the values of features
be reported (for example, in a user interface) in the same manner as they are stored, or require that they be
reported at all.
Table of Features
Table F-1 (page 406) lists the universal features described in this appendix.
Table F-1
Universal features
Brand
Code
Description
Profile Parent
0x20202020
mvbr
0x20202020
avvb
0x20202020
mabr
Movie or Track
0x20202020
avab
0x20202020
vfmt
0x20202020
afmt
0x20202020
m4vp
0x20202020
mp4v
0x20202020
m4vo
0x20202020
mp4a
0x20202020
mvsz
Movie
0x20202020
tvsz
0x20202020
vfps
0x20202020
tafr
0x20202020
vvfp
0x20202020
ausr
406
Brand
Code
Description
Profile Parent
0x20202020
avbr
0x20202020
achc
Unsigned int(32) indicating maximum video bit rate in bits per second
Feature Values
The value is an unsigned 32-bit integer indicating the maximum video bit rate in bits per second. The value
may be larger than the actual video bit rate, so it should not be interpreted as a bit rate that will actually occur.
Example: 1 Mbps = 1000000.
Writer Responsibilities
A writer of the maximum video bit rate should record a value that is equal to or greater than the actual bit rate
for the video track. A writer (such as a CE device) may choose to record a constant value so long as that value
is greater than or equal to the bit rate that may be encoded. It is also permitted to record a value set by the
video encoder during initialization, so long as the value is never exceeded.
407
For each sample, calculate the average 1-second bit rate; choose the shortest run of samples, including
the candidate sample, that comprise 1 second or more of video, then divide the total data size of those
samples by their total duration.
2.
Choose the maximum value from the list of calculated 1-second averages.
Reader Responsibilities
A reader of the maximum video bit rate feature value should compare the recorded value with its own limits
to determine if the content can be played. The reader should not perform an equality comparison (=) but
instead a relative comparison (<, <=, >, or >=).
The recorded value may be larger than the actual maximum video bit rate. Since this value may be an
over-estimate, the reader should not use it as a basis for refusing to play the file, though a warning may be
appropriate. To determine the actual bit rate, the reader may need to perform an inspection of the video tracks
sample table.
Comments
The value of this feature should be deducible from information found in the sample table. Track edits must be
considered in its calculation; if the track is edited, this value must be recalculated. Even though this value may
exceed the actual maximum video bit rate, writers should attempt to minimize any over-estimation.
Unsigned int(32) indicating average video bit rate in bits per second
Feature Values
The value is an unsigned 32-bit integer indicating the average video bit rate in bits per second.
Example: 1 Mbps = 1000000.
408
Writer Responsibilities
A writer of the average video bit rate feature should record a value that is equal to or greater than the average
bit rate for the video track, measured across all media samples. A writer (such as a CE device) may choose to
record a constant value so long as that value is greater than or equal to the average bit rate that may be
encoded. It is also permitted to record a value set by the video encoder during initialization so long as the
value equals or exceeds the average calculated from the resulting file.
Reader Responsibilities
A reader of the average video bit rate feature value should compare the recorded value with its own limits to
determine if the content can be played. The reader should not perform an equality comparison (=) but instead
a relative comparison (<, <=, >, or >=).
Because a writer may record a larger value than the actual video bit rate, a reader should not interpret this as
the actual video bit rate. To determine the current or actual bit rate, the reader may need to perform an
inspection of the video track's sample table.
Comments
The value of this feature should be deducible from information found in the sample table. Track edits must be
considered in its calculation. Note that for highly variable bit rate video, the average rate may not be a typical
rate.
409
feature-value
Unsigned int(32) indicating maximum audio bit rate in bits per second
Feature Values
The value is an unsigned 32-bit integer indicating the maximum audio bit rate in bits per second that must
be supported to guarantee playback of the audio. The actual maximum bit rate may be smaller, so a reader
should not display this as the current bit rate.
Example: 128 kbps = 128000.
Writer Responsibilities
A writer of the maximum audio bit rate feature should record a value that is equal to or greater than the current
bit rate for the sound track. While the value may exceed the actual maximum bit-rate, the writer should attempt
to minimize any over-estimation.
While recording the precise bit rate is preferred, it is not required. A writer (such as a CE device) may choose
instead to record a constant value so long as that value is greater than or equal to the bit rate that may be
encoded. It is also permitted to record a value set by the audio encoder during initialization so long as the
value is never exceeded.
For each sample, calculate the average 1-second bit rate; choose the shortest run of samples, including
the candidate sample, that comprise 1 second or more of audio, then divide the total data size of those
samples by their total duration.
2.
Choose the maximum value from the list of calculated 1-second averages.
410
Reader Responsibilities
A reader of this feature code should compare the recorded value with its own limits to determine if the content
can be played. The reader should not perform an equality comparison (=) but instead a relative comparison
(<, <=, >, or >=).
Because this value may be an over-estimate of the true maximum bit rate, the reader should not refuse to play
a file on the basis of this value, although a warning may be appropriate. To determine the current or actual
bit rate, the reader may need to perform an inspection of the video track's sample table.
Unsigned int(32) indicating average audio bit rate in bits per second
Feature Values
The value is an unsigned 32-bit integer indicating the average audio bit rate in bits per second.
Example: 128 kbps = 128000.
Writer Responsibilities
A writer of the average audio bit rate feature should record a value that is equal to or greater than the average
bit rate for the sound track, measured across all media samples. A writer (such as a CE device) may choose to
record a constant value so long as that value is greater than or equal to the average bit rate that may be
encoded. It is also permitted to record a value set by the audio encoder during initialization so long as the
value is never exceeded on average.
411
Reader Responsibilities
A reader of the average audio bit rate feature value should compare the recorded value with its own limits to
determine if the content can be played. The reader should not perform an equality comparison (=) but instead
a relative comparison (<, <=, >, or >=).
Comments
The value of this feature should be deducible from information found in the sample table. Track edits normally
need not be considered in the calculation for constant bit rate audio, but must be considered for variable bit
rate audio or when track or movie segments containing constant bit rate audio are edited to alter their duration.
Unsigned int(32) (a four-character-code) holding the QuickTime video codec type copied from the
ImageDescription structures cType field
Feature Values
This is the four-character-code found in a video sample description.
Examples: 'mp4v', 'jpeg'.
Writer Responsibilities
A writer of the QuickTime video codec type feature should record the four-character code corresponding to
the QuickTime video format type or types also recorded in the video tracks sample descriptions.
412
Note: A writer that records the QuickTime Video Codec type for the 'mp4v' codec is encouraged
also to write the MPEG-4 Video Profile feature.
Reader Responsibilities
A reader of this feature code should compare the recorded value by an equality comparison (using =) with the
format codes supported by the reader.
Unsigned int(32) (a four-character-code) holding the QuickTime audio codec type copied from
SoundDescription structures dataFormat field
Feature Values
This is the four-character-code found in a sound sample description.
Examples: 'mp4a', 'twos'.
Writer Responsibilities
A writer of the QuickTime audio codec type feature should record the four-character-code corresponding to
the QuickTime audio format type or types also recorded in the sound tracks sample descriptions.
413
Note: A writer that records the QuickTime Audio Codec type for the 'mp4a' codec is encouraged
also to write the MPEG-4 Audio Codec feature.
Reader Responsibilities
A reader of this feature code should compare the recorded value by an equality comparison (using =) with the
format codes supported by the reader.
Unsigned int(32) where least significant 8 bits hold the profile_and_level_indication from the
visual_object_sequence, as defined in specification ISO/IEC 14496-2, retrieved from the video
parameters for the MPEG-4 video codec description. The top 24 bits must be set to 0.
Feature Values
The least significant 8 bits hold the value. The most significant 24 bits of the feature value should be set to 0.
Writer Responsibilities
A writer of the MPEG-4 video profile feature should record the 8 bits corresponding to the
profile_and_level_indication from the visual_object_sequence, as defined in specification ISO/IEC
14496-2, found in the video parameters encoded in the esds of the MPEG-4 video codec sample description
(with QuickTime codec type 'mp4v').
414
Note: A writer that records the MPEG-4 video profile feature is encouraged also to write the
QuickTime Video Codec Type feature.
Reader Responsibilities
A reader of this feature code should compare the recorded value with the set of profiles and levels supported
by the reader.
Comments
This feature may be present only if MPEG-4 video is used. Normally, the video codec type profile entry will also
record that MPEG-4 video is present, unless no codec types are present (when, for example, an exhaustive list
cannot be formed).
Unsigned int(32) where the least significant 4 bits holds the visual_object_type as found in the
VisualObject (as defined in specification ISO/IEC 14496-2, subclause 6.2.2) found in the esds of the
MPEG-4 video codec (QuickTime type 'mp4v') sample description
Feature Values
The least significant 4 bits hold the value. The most significant 28 bits of the feature value should be set to 0.
The list of visual object type constants is defined in specification ISO/IEC 14496-2, subclause 6.3.2.
Example: Video ID is indicated by the value 1.
415
Writer Responsibilities
A writer of the MPEG-4 Video Codec feature should record the 4 bits corresponding to the
visual_object_type found in the VisualObject within the ES_descriptor's video
DecoderSpecificConfig. The most significant 28 bits of the value should be set to 0.
Note: A writer that records the MPEG-4 Video Codec feature is encouraged also to write the
QuickTime Video Codec Type feature.
Reader Responsibilities
A reader of this feature code should compare the recorded value with the set of MPEG-4 video decoders
supported by the reader.
Comments
Because the QuickTime 'mp4v' codec may implement multiple video decoders defined in specification ISO/IEC
14496 in the future, this feature allows the reader to determine the specific video decoder needed to interpret
the video bit-stream.
Unsigned int(32) where the least significant 8 bits hold the video_object_type_indication
found in the VideoObjectLayer (Described in ISO/IEC 14496-2, subclause 6.2.3). The VideoObjectLayer
416
is found in the MPEG-4 Elementary Stream Descriptor Atom within the 'esds' sample description atom
of the video sample description for the QuickTime video codec of type 'mp4v'.
Feature Values
The value is a video object type constant that indicates a set of video tools. The list of video object type
constants is defined in specification ISO/IEC 14496-2, subclause 6.3.3. The least significant 8 bits hold the value.
The most significant 24 bits should be set to 0.
Example: The Simple Object Type video object is indicated by the value 1.
Writer Responsibilities
A writer of the MPEG-4 Video Object Type feature should record the 8 bits corresponding to the
video_object_type_indication found in the VideoObjectLayer within the ES_descriptors video
DecoderSpecificConfig. The most significant 24 bits of the value should be set to 0.This feature should
be written only for MPEG-4 video of video object type 1 (Video ID). If the MPEG-4 video does not use Video ID
(1) for visual_object_type, the esds will have no VideoObjectLayer and consequently no
video_object_type_indication. In this case, no MPEG-4 Video Object Type feature should be written.
Note: A writer that records the MPEG-4 Video Object Type feature for encoded video using the
Video ID visual object type is encouraged to write the MPEG-4 Video Codec and MPEG-4 Video Profile
features as well.
Reader Responsibilities
A reader of this feature code should compare the recorded value with the set of MPEG-4 video tools supported
by the reader.
417
part-ID
Unsigned int(32) where least significant 5 bits hold the AudioObjectType as found in the
AudioSpecificInfo (as defined in specification ISO/IEC 14496-3, subclause 1.6) found in the esds of
the MPEG-4 audio codec (QuickTime type 'mp4a') sample description
Feature Values
The least significant 5 bits hold the value. The most significant 27 bits of the feature value should be set to 0.
The list of audio object type constants is defined in specification ISO/IEC 14496-3, subclause 1.5.1.1.
Examples: AAC LC is indicated by the value 2, CELP is indicated by the value 8.
Writer Responsibilities
A writer of the MPEG-4 Audio Codec feature should record the 5 bits corresponding to the AudioObjectType
found in the ES_descriptor's audio DecoderSpecificConfig. The most significant 27 bits of the value
should be set to 0.
Note: A writer that records the MPEG-4 Audio Codec feature is encouraged also to write the
QuickTime Audio Codec Type feature.
Reader Responsibilities
A reader of this feature code should compare the recorded value with the set of MPEG-4 audio decoders
supported by the reader.
418
Comments
Because the QuickTime 'mp4a' codec may implement multiple audio decoders defined in specification ISO/IEC
14496 in the future, this feature allows the reader to determine the specific audio decoder needed to interpret
the audio bit stream. The MPEG-4 Audio Codec feature should be present only if the 'mp4a' audio codec is
used in a sound track.
A 32-bit packed structure holding width and height of the largest bounds needed to display the movie
Feature Values
A packed structure in a 32-bit value:
struct {
unsigned integer(16) width;
unsigned integer(16) height;
};
In big-endian order, the top 16 bits correspond to the width. The lower 16 bits correspond to the height.
Writer Responsibilities
A writer of the Maximum Movie Video Size feature should record a value that is equal to or greater than the
display size needed by the moviethe actual width and height needed to display the movie at its normal size,
taking into account all matrices (all track matrices and the movie matrix).
A writer (such as a CE device) may choose to record a constant size based upon its current recording mode
even if the actual size recorded in the movie is smaller.
419
Reader Responsibilities
A reader of this feature code should compare the recorded value with its own video size limits.
The reader should not interpret the value of this feature as the current video size. To determine the current
video size, the reader should use the dimensions of all currently displaying video tracks, their matrices, and
the movie matrix.
Comments
The width and height correspond to the maximum visual area needed to display the movie.
The summarized width and height should take into account all components of all track matrices and the movie
matrix. The goal is to understand the maximum contribution of all tracks to the movies bounds.
For the case where there is a single video track with an identity track matrix, the movies maximum video size
feature would typically have the same value as the tracks maximum video size feature.
A 32-bit packed structure holding width and height of the largest picture buffer needed for a video track.
Feature Values
A packed structure in a 32-bit value:
struct {
420
In big-endian order, the top 16 bits correspond to the width. The lower 16 bits correspond to the height.
Writer Responsibilities
A writer of the Maximum Track Video Size feature should record a value that is equal to or greater than the
largest height and width of any sample description in the video track. This does not include the effect of any
scaling or offset applied by the track matrix and may not be the same as the track height and track width.
A writer (such as a CE device) may choose to record a constant size based upon its current recording mode
even if the actual size recorded in the track is smaller.
Reader Responsibilities
A reader of this feature code should compare the recorded value with its own image buffer limits.
The reader should not interpret the value of this feature as the current video size. To determine the current
video size, the reader should use the dimensions of all currently displaying video tracks, their matrices, and
the movie matrix.
Comments
The width and height correspond to the largest image buffer dimensions needed for a visual track. When
present in a movie-level profile, these atoms document the maximum video size found in each of the movies
tracks.
The summarized width and height do not take into account any scaling or translation caused by the track or
movie matrices, and are not necessarily the same as the track height and width.
For the case where there is a single video track with an identity track and matrix and an identity movie matrix,
the movies maximum video size feature would have the same value as the tracks feature.
421
Warning: Use of the "clean aperture" sample description extension does not affect the value of the
track visual size, as the picture buffer is needed immediately after decoding, prior to any clean aperture
clipping.
An unsigned fixed-point (16.16) number holding the maximum video frame rate
Feature Values
This is an unsigned fixed-point (16.16) number holding the maximum video frame rate. The integer portion of
the number can range from 0 to 65535.
Examples: 25 fps = 0x00190000; 24 fps = 0x00180000; 29.97 = 0x001DF853 (close approximation of a 30000/1001
ratio). The value may be rounded up to the nearest integer.
Writer Responsibilities
A writer of the Maximum Video Frame Rate feature should record a 16.16 fixed-point value that is equal to or
greater than the current video frame rate. A writer (such as a CE device) may choose to record a constant for
the feature based on its current recording mode, even if the actual frame rate is less.
A writer of a new video track (such as a CE device recorder) may set the maximum frame rate feature value to
a value set during video encoder initialization, so long as this frame rate is never exceeded.
If the current calculated frame rate is fractional (such as 22.3 fps), a writer may choose to round the value up
to the nearest integer value (such as 23.0 fps for 22.3 fps).
A writer calculating the video frame rate using the video tracks sample table should not consider the first or
the last sample duration if they differ from the other sample durations. The reason for this is that captured
movie files often have longer or shorter first and last sample durations. By not considering them in the
calculation, a more accurate calculation is achieved.
422
Reader Responsibilities
A reader of this feature code should compare the recorded value with its own video frame rate limits. It should
not expect exact values.
The reader should not interpret the value of this feature as the current frame rate. To determine the current
frame rate, the reader should use the video tracks sample table.
Comments
A writer may choose to round up any fractional value of the fixed-point number to the nearest 16-bit integer
leaving the lower 16 bits of the Fixed value set to 0. So, in the case of the 29.97 approximation of 0x001DF853,
the writer could round this up to 0x001E0000 (which equals 30).
An unsigned fixed-point (16.16) number holding the average video frame rate
Feature Values
This is an unsigned fixed-point (16.16) number holding the average video frame rate. The integer portion of
the number can range from 0 to 65535.
Examples: 25 fps = 0x00190000; 24 fps = 0x00180000; 29.97 = 0x001DF853 (close approximation of a 30000/1001
ratio). The value may be rounded up to the nearest integer.
When present in a movie-level profile, these atoms document the average video frame rate of each track in
the movie.
423
Writer Responsibilities
A writer of the Average Video Frame Rate feature should record a 16.16 fixed-point value that is equal to or
greater than the average video frame rate. A writer (such as a CE device) may choose to record a constant for
the feature based on its current recording mode, even if the actual frame rate is less.
A writer of a new video track (such as a CE device recorder) may set the average frame rate feature value to a
value set during video encoder initialization, so long as this frame rate is not exceeded by the actual average,
as determined by the feature value algorithm described below.
If the average calculated frame rate is fractional (such as 22.3 fps), a writer may choose to round the value up
to the nearest integer value (such as 23.0 fps for 22.3 fps).
Reader Responsibilities
A reader of this feature code should understand that each frame is a video sample with its own independent
and explicit duration. While it is possible for all frames to have the same duration, it is equally possible for the
duration of any frame to be radically different from any other. Therefore, the average frame rate may not always
be meaningful information.
The reader should not interpret the value of this feature as the current frame rate. To determine the current
frame rate, the reader should use the video tracks sample table.
Comments
A writer may choose to round up any fractional value of the fixed-point number to the nearest 16-bit integer
leaving the lower 16 bits of the Fixed value set to 0. So, in the case of the 29.97 approximation of 0x001DF853,
the writer could round this up to 0x001E0000 (which equals 30).
424
feature-code
'vvfp'
feature-value
Unsigned int(32) holding the value 0 if the frame rate is constant or the value 1 if the frame durations
vary
Feature Values
The feature value holds one of the following two values: 0 if all video samples have the same display duration,
or 1 if any video samples vary in duration.
Writer Responsibilities
A writer of the Video Variable Frame Rate Indication feature should compare the video track sample durations.
If all considered durations have the same value, the value 0 indicating constant frame rate should be recorded.
If any durations differ, the value 1 should be recorded for the feature. No other value should be recorded.
Reader Responsibilities
A reader of this feature code should only expect the values 0 or 1.
Unsigned int(32) holding the audio sample rate in units per second (for example, 44100 for 44.1 kHz)
Feature Values
This feature value is an unsigned 32-bit integer holding the audio sample rate in units per seconds (cycles per
second). The value should be rounded up to the nearest integer if it has a fractional portion.
425
Writer Responsibilities
A writer of the Audio Sample Rate feature should record the integer portion (rounded up if there is a fractional
portion) of the audio sample rate found in a sound tracks SoundDescription structure.
If multiple audio sample rates are used in the movie, then either all must recorded in the profile atom, or none
must be recorded.
Reader Responsibilities
A reader of this feature code should compare the recorded value with its own audio sample rate limits. If the
reader only supports discrete values (such as 44100), it can perform equality comparisons (=). If the reader
supports ranges of audio sample rates (such as all rates less than or equal to 32000), the reader can perform
relative comparisons (<, <=, >, or >=).
Unsigned int(32) holding the value 0 if the audio is constant bit rate or 1 if the audio is variable bit
rate
426
Feature Values
The feature value holds one of the following two values: 0 if the audio is constant bit rate, or 1 if the audio is
variable bit rate.
Writer Responsibilities
A writer of the Audio Variable Bit Rate Indication feature should determine if the audio frames are constant or
variable bit rate in nature and record either 0 or 1, respectively.
Reader Responsibilities
A reader of this feature code should only expect the values 0 or 1.
Feature Values
The feature value is an unsigned 32-bit integer holding the number of audio channels encoded by a Sound
Track in the movie. For monaural, the value would be 1. For stereo, the value would be 2. Note that the audio
channel count is a standard field in the sound sample description.
Writer Responsibilities
A writer of the Audio Channel Count feature should determine the number of audio channels encoded in the
sound track or tracks of the movie.
427
Reader Responsibilities
The reader should be prepared to either play the specified number of channels or to map the audio to the
number of channels the reader supports (for example, mixing down stereo sound for a monaural speaker).
428
This appendix describes temporal positioning of a source audio signal after AAC encoding into a sound track
for QuickTime media files. The mechanisms described here are specified in ISO MPEG-4 standards (ISO/IEC
14496-12, 2008) and are used here with additional constraints.
Note on language use:
AAC implementations typically represent 1024 PCM audio samples in one AAC packet (synonymous
in this context with a QuickTime media sample, and also referred to in ISO documents as an access
unit). The terms sample and audio sample in this appendix are used to refer to PCM samples.
For the encoded audio data, the terms AAC packet and QuickTime media sample are used.
Encoder delay is the delay incurred during encoding to produce properly formed, encoded audio packets.
It typically refers to the number of silent media samples (priming samples) added to the front of an AAC
encoded bitstream.
Decoder delay is the number of pre-roll audio samples required to reproduce an encoded source audio
signal for a given time index. For AAC this number is typically 1024 and is algorithmically based. This is in
contrast to encoder delay which is determined by the encoder and encoding configuration used. However,
decoder delay establishes the minimum encoder delay possible (that is, 1024 for AAC).
The common practice is to propagate the encoder delay in the AAC bitstream. When these audio packets are
then decoded back to the PCM domain, the source waveform represented will be offset in its entirety by this
encoder delay amount. Since encoded audio packets hold a fixed number of audio samples (for instance, 1024
samples) additional trailing or remainder silent samples following the last source sample are required so as
to pad the final audio packet to the required length.
429
Figure G-1 (page 430) gives an example of a typical encoded AAC audio bitstream. The upper portion of the
illustration represents the AAC encoded domain with equal-sized AAC packets, the lower portion represents
the PCM sample domain:
Figure G-1
Source Audio
Remainder
The source audio to be encoded, shown as the red waveform, is 5389 samples long. You can see how it is
represented with the blue priming and remainder samples against the fixed size access unitsAAC packetsdrawn
above it.
This data will be represented in 8 AAC packets, where each packet represents 1024 audio samples. The total
duration represented by these 8 AAC packets is 8192 audio samples (note that this is longer than the duration
of the source audio).
The result breaks down into the following values:
2112 priming samples at the startRequired to correctly encode the start of the audio.
5389 samples of actual audio.
691 remainder samplesRequired to pad out to the AAC packet size.
Therefore, to correctly extract the original 5389 samples of source audio, the first 2112 samples of priming and
the last 691 samples of the remainder must be removed.
8192 - 2112 - 691 = 5389 original source samples.
430
Therefore, a playback system must trim the silent priming samples to preserve correct synchronization. This
trimming by the playback system should be done in two places:
When the playback position is moved to another location. For example, the user skips ahead or back to
another part of the media and begins playback from that new location.
In summary, the historical technique to handle the timing and synchronization problem is to assume an implicit
2112 sample standard encoder delay in AAC data streams and indicate start timethe first media sample or
AAC packetin the sound track edit list (see Edit List Atoms (page 70)) at the start of encoder delay.
431
432
Note: Track duration uses the movie timescale instead of the media timescale used by media time.
If the media timescale and movie timescale differ, the track duration may not be sample accurate.
Sample group structures of roll-group type with a constant roll distance are used to represent decoder
dependencies for AAC encoded media. The sample group structures are intended to serve two purposes:
To signal to readers parsing QuickTime movies that the sound track includes explicit information for
encoder delay and remainder samples for the AAC packets encoded in the file
Note: The effect of using sample group structures in the track in this manner is that the edit
lists media time and track duration fields do not include encoder delay, as specified above in
Edit List Atom (page 432).
Two sample group structure atoms are used to represent the amount of encoder delay and remainder samples
which must be trimmed.
433
In a general case:
Each instance of a sample group description atom has a type code that distinguishes different sample
groupings. There can be multiple instances of this atom if there is more than one sample grouping
for the samples in a track. At most one instance of a sample group description with a particular
grouping type exists in a track. An associated sample-to-group atom has the same value associated
with that grouping type. The information or payload data is stored in the sample group description
atom, after the entry count, as an array of entries for which the meanings vary according to the
characteristics of grouping type.
For use in AAC encoder delay representation, there is one instance of a sample group description atom in a
given QuickTime sound track with grouping type roll. The specifics for audio data (AudioRollRecovery())
are used and articulate the rolling decode dependency. Because the sample group description atom for this
purpose is describing the entirety of the AAC audio stream, the payload data field resolves to a single signed
16-bit integer representing the roll distance, which is set to -1. In other words, one AAC packet (1024 encoded
PCM audio samples) preceding the media sample is indicated as being of the same type as the encoded source
data, allowing the decode transform to operate over the required two AAC packets for the first media sample
specified in the edit list.
Note: The payload data value (roll distance in this use) of -1 is a typical value for existing AAC codecs,
but the payload data can have other values. Codecs could use alternative values depending upon
their implementation details.
Type = 'sgpd'
Version
Flags
Grouping Type
Default length
Entry count
Payload data
variable
434
The sample group description atom contains the following data elements:
Size
A 32-bit integer that specifies the number of bytes in this sample group description atom.
Type
A 32-bit integer that identifies the atom type, set to 'sgpd'.
Version
A 1-byte specification of the version of this sample group description, set to 1.
Flags
A 3-byte reserved space, set to 0
Grouping type
A 32-bit integer that identifies the grouping type of this sample group description, set to roll.
Default length
A 32-bit integer indicating the length of the group entry in the payload data, set to 2 (bytes).
Entry count
A 32-bit integer giving the number of entries in the payload data field, set to 1.
Payload data
A 16-bit signed integer giving the roll distance, set to -1 value for AAC audio.
Sample-To-Group Atoms
Sample-to-group atoms are used to find the group that a sample belongs to and the associated description
of that sample group. The sample-to-group atom has an atom type of sbgp.
435
In a general case:
There may be multiple instances of sample-to-group atoms if there is more than one sample grouping
for the samples in a track. Each instance of the sample-to group atom has a grouping type code that
distinguishes different sample groupings. Within a track there can be at most one instance of this
atom with a particular grouping type. An associated sample group description atom indicates the
same value for the grouping type.
The sample-to-group atom contains a table with a sample count and group description index pairs.
The sample count is the number of media samples in the run of samples with the same sample group
description. The group description index is an index into the array of payload data entries in the
associated sample group description atom's payload data table, the association defined by having
the same grouping type value.
For use in AAC encoder delay representation, there is one sample-to-group atom instance in a given QuickTime
sound track with grouping type roll matching the single instance of the sample group description atom.
The entry count field value is set to 1, indicating one entry in the table data array. That entry is describing all
the AAC packets in the track. The sample count in the table data array is typically the same as the sample size
atoms number of entries field, see Sample Size Atoms (page 111), which represents the number of media
samples in the track (in this use, AAC packets). For AAC encoder delay representation, the only entry in the
associated sample group description atoms payload data table is the first, which provides the value of 1 for
the group description index.
Figure G-3 (page 436) shows the layout of this atom.
Figure G-3
Type = 'sbgp'
Version
Flags
Grouping type
Entry count
Table data
variable
436
Size
A 32-bit integer that specifies the number of bytes in this sample-to-group atom.
Type
A 32-bit integer that identifies the atom type; set to 'sbgp'.
Version
A 1-byte specification of the version of this sample-to-group atom, set to 0
Flags
A 3-byte reserved space, set to 0.
Grouping type
A 32-bit integer identifying the grouping type, set to roll.
Entry count
A 32-bit integer giving the number of entries in the table table data that follows.
Table data
A table of sample count and group description index pairs as shown in Figure G-4 (page 437).
Figure G-4
Field
Bytes
Sample count
A 32-bit integer that provides the number of consecutive media samples with the same sample
group descriptor. The value is typically the same as in the sample size atoms number of entries
field.
Group description index
A 32-bit integer the value of which is the index into the sample group description atoms payload
data table which describes the samples in this group. The index ranges from 1 to the number of
payload data entries in the sample group description atom, or takes the value 0 to indicate that
this group of samples is a member of no group of this type.
437
The goal is to represent the temporal position of 5 seconds of 48kHz PCM audio encoded in a 48kHz AAC sound
track. Assume a media timescale of 48000 and an encoder delay of 2112. For convenience, assume a movie
timescale of 48000 as well.
Audio Data
Source PCM audio data prior to encoding:
Sample rate: 48000 per second
Sample count: 240000 PCM samples (5 seconds)
Duration in timescale ticks: 240000 (with media timescale the same as sample rate)
AAC in the encoded sound track:
Encoder delay: 2112 audio samples
Samples per AAC packet: 1024
Decoder delay: 1024 samples (or 1 AAC packet)
Number of AAC packets: 237 (=((2112+240000) / 1024) rounded up to an integer value)
Sample count: 242688 (= 237 * 1024)
Remainder samples: 576 (= 242688 - (2112 + 240000))
The transformation from source PCM to encoded AAC results in a sound track with 237 AAC media samples
corresponding to 242688 PCM audio samples if decoded and presented in its entirety. Of that total, only 240000
audio samples of source starting at sample offset 2112 (skipping the first 2111 samples) are to be presented.
From this, the edit list atom and sample group atom described in Track Structures (page 438) are used to
represent the encoder delay.
Track Structures
Based on the Audio Data (page 438), the following edit list and sample group atoms are used to represent the
encoder delay.
The edit list atom contains this data:
Size: 28
Type: elst
Version: 0
Flags: 0
438
Entry count: 1
Number of entries: 1
with this table data:
Track duration: 240000 (source duration)
Media time: 2112 (accounts for the encoder delay)
Media rate: 1.0
Note: For this example, the conventional encoder delay value of 2112 audio samples has been used.
Alternative encoder delay values can also be explicitly represented with this mechanism, depending
upon codec implementation.
Note: Recall that the payload data value could be an alternative value, depending upon the particular
codec in use. -1 is typical for current AAC codecs.
439
You cannot use the edit list by itself to determine the encoder delay or remainder sample count. The
sample group atoms provide the encoder delay. The placement of the end of the edit in a compressed
audio packet allows calculation of the remainder samples.
If the encoder delay was the theoretical minimum for AAC of 1024, then the media time field value in the
edit list table data shown in this example would be 1024, not 2112.
Include a version 1 sample group description atom with grouping type set to roll. Set default length
to 2 (bytes) for audio entries. Follow that with the payload data: the typical value is -1, meaning one
preceding AAC packet, which is the theoretical minimum decoder delay of 1024 samples.
Include a version 0 sample-to-group atom with a 'roll' grouping type. By including this, you associate
the AAC packets with the corresponding sample group description atom. All AAC packets including the
encoder delay must be associated with the sample group in the table datas sample count field. Typically,
the sample count for this sample-to-group atoms table data corresponds with the number of media
samples in the track.
These two sample group structure atoms in addition to the edit list atom, properly composed, form a complete
implementation to explicitly represent the temporal position of the source audio samples in an AAC encoded
track.
440
Date
Notes
2015-02-14
2014-02-11
2012-08-14
2012-08-01
441
Date
Notes
2011-07-13
The following updates are included in this revision: The sound sample
description v2 format along with the definition of two new sound sample
description extensions are incorporated, see Sound Sample Description
(Version 2) (page 182). New atoms for the display of track aperture in
different modes have been documented, see Track Aperture Mode
Dimension Atoms (page 61). New sample atoms for handling out-of-order
movie samples have been added, see Sample Atoms (page 95). Appendix
G, Audio Priming - Handling Encoder Delay in AAC (page 429), has been
added which treats how to handle temporal positioning of AAC audio
data explicitly. The Macintosh language codes table has been updated
with current language names, see Table 5-1 (page 329) and the related
Extended Language Tag Atom (page 82) defined.
2010-08-03
2010-05-03
2007-09-04
442
Date
Notes
A QuickTime file may now contain a file type compatibility atom. See The
File Type Compatibility Atom (page 33). A movie atom may now contain
a movie profile atom. See The Movie Profile Atom (page 42). A track atom
may now contain a track profile atom. See Track Profile Atom (page 57).
Video sample descriptions may now contain a pixel aspect ratio atom for
non-square pixels. See Pixel Aspect Ratio ('pasp') (page 160). Video sample
descriptions may now also contain a color parameter atom. See Color
Parameter Atoms ('colr') (page 162). Video sample descriptions may now
a clean aperture atom. See Clean Aperture ('clap') (page 168). The sound
description record has been expanded to represent variable bit-rate
compression more accurately. See Sound Sample Descriptions (page 177).
The section describing MPEG-4 audio has been modified. See MPEG-4
Audio (page 190).
It is now recommended that the file creation and modification times be
set using UTC, rather than local time zones. See Calendar Date and Time
Values (page 332). User data text may now be encoded using either
Macintosh text encoding or ISO text encoding (Unicode). See User Data
Text Strings and Language Codes (page 51). MPEG-4 video and audio
sample descriptions may now contain elementary stream descriptor atoms.
See MPEG-4 Elementary Stream Descriptor Atom ('esds') (page 161) and
MPEG-4 Elementary Stream Descriptor Atom ('esds') (page 187). It is now
possible to specify languages using either Macintosh language codes or
ISO language codes. See Language Code Values (page 328).
443
Glossary
444
Glossary
445
Glossary
446
Glossary
447
Glossary
448
Glossary
449
Glossary
450
Glossary
451
Glossary
452
Glossary
453
Apple Inc.
Copyright 2004, 2015 Apple Inc.
All rights reserved.
No part of this publication may be reproduced,
stored in a retrieval system, or transmitted, in any
form or by any means, mechanical, electronic,
photocopying, recording, or otherwise, without
prior written permission of Apple Inc., with the
following exceptions: Any person is hereby
authorized to store documentation on a single
computer or device for personal use only and to
print copies of documentation for personal use
provided that the documentation contains
Apples copyright notice.
No licenses, express or implied, are granted with
respect to any of the technology described in this
document. Apple retains all intellectual property
rights associated with the technology described
in this document. This document is intended to
assist application developers to develop
applications only for Apple-branded products.
Apple Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, Aperture, Chicago,
ColorSync, Mac, Mac OS, Macintosh, OS X,
QuickDraw, and QuickTime are trademarks of
Apple Inc., registered in the U.S. and other
countries.
Intel and Intel Core are registered trademarks of
Intel Corporation or its subsidiaries in the United
States and other countries.
Java is a registered trademark of Oracle and/or
its affiliates.
Times is a registered trademark of Heidelberger
Druckmaschinen AG, available from Linotype
Library GmbH.
APPLE MAKES NO WARRANTY OR REPRESENTATION,
EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS
DOCUMENT, ITS QUALITY, ACCURACY,
MERCHANTABILITY, OR FITNESS FOR A PARTICULAR
PURPOSE. AS A RESULT, THIS DOCUMENT IS PROVIDED
AS IS, AND YOU, THE READER, ARE ASSUMING THE
ENTIRE RISK AS TO ITS QUALITY AND ACCURACY.
IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES RESULTING FROM ANY DEFECT, ERROR OR
INACCURACY IN THIS DOCUMENT, even if advised of
the possibility of such damages.
Some jurisdictions do not allow the exclusion of
implied warranties or liability, so the above exclusion
may not apply to you.