home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / qt / spec / qt.txt
Encoding:
Text File  |  1994-06-20  |  67.7 KB  |  1,750 lines

  1. INSIDE MACINTOSH
  2. QuickTime
  3. ISBN 0-201-62201-7
  4.  
  5.  
  6. 1 2 3 4 5 6 7 8 9-MU-9796959493
  7. First Printing, March 1993
  8. pApple Computer, Inc.
  9. (c) 1993, Apple Computer, Inc.
  10. All rights reserved. 
  11.  
  12.  
  13. No part of this publication may be reproduced, stored in a retrieval 
  14. system, or transmitted, in any form or by any means, mechanical, 
  15. electronic, photocopying, recording, or otherwise, without prior 
  16. written permission of Apple Computer, Inc. Printed in the United States 
  17. of America.
  18.  
  19. No licenses, express or implied, are granted with respect to any 
  20. of the technology described in this book. Apple retains all intellectual 
  21. property rights associated with the technology described in this book. 
  22. This book is intended to assist application developers to develop 
  23. applications only for Apple Macintosh computers.
  24.  
  25. Apple Computer, Inc.
  26. 20525 Mariani Avenue
  27. Cupertino, CA 95014
  28. 408-996-1010
  29.  
  30. Apple, the Apple logo, APDA, AppleLink, LaserWriter, Macintosh, and 
  31. MPW are trademarks of Apple Computer, Inc., registered in the United 
  32. States and other countries.
  33.  
  34. QuickDraw, QuickTime, and System 7 are trademarks of Apple Computer, Inc.
  35. Adobe Illustrator and PostScript are trademarks of Adobe Systems Incorporated,
  36. which may be registered in certain jurisdictions.
  37. AGFA is a trademark of Agfa-Gevaert.
  38. America Online is a service mark of Quantum Computer Services, Inc.
  39. CompuServe is a registered service mark of CompuServe, Inc.
  40. FrameMaker is a registered trademark of Frame Technology Corporation.
  41. Helvetica and Palatino are registered trademarks of Linotype Company.
  42. Internet is a trademark of Digital Equipment Corporation.
  43. ITC Zapf Dingbats is a registered trademark of International Typeface 
  44. Corporation.
  45. Windows is a trademark of Microsoft Corporation.
  46. Simultaneously published in the United States and Canada.
  47.  
  48. LIMITED WARRANTY ON MEDIA AND REPLACEMENT
  49. ALL IMPLIED WARRANTIES ON THIS MANUAL, INCLUDING IMPLIED WARRANTIES 
  50. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED 
  51. IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL 
  52. PURCHASE OF THIS PRODUCT.
  53.  
  54. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR 
  55. REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, 
  56. ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR 
  57. PURPOSE. AS A RESULT, THIS MANUAL IS SOLD AS IS, AND YOU, THE PURCHASER, 
  58. ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY.
  59. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, 
  60. INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR 
  61. INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages.
  62. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF 
  63. ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, 
  64. or employee is authorized to make any modification, extension, or 
  65. addition to this warranty.
  66.  
  67. Some states do not allow the exclusion or limitation of implied 
  68. warranties or liability for incidental or consequential damages, so 
  69. the above limitation or exclusion may not apply to you. This warranty gives 
  70. you specific legal rights, and you may also have other rights which vary 
  71. from state to state.
  72.  
  73. ED. NOTE:  THE FOLLOWING ARE EXCERPTS FROM THE DOCUMENT:
  74.  
  75.  
  76. About This Book
  77.  
  78. This book describes QuickTime, an extension of Macintosh system software 
  79. that enables you to integrate time-based data into mainstream Macintosh 
  80. applications. This book also provides a complete technical reference 
  81. to the Movie Toolbox, the Image Compression Manager, and the movie resources.
  82. Time-based data types contain data that can be stored and retrieved as 
  83. values over time. Examples include sound, video, animation, data produced 
  84. by scientific instruments, and financial results. Time-based data can 
  85. now be manipulated in the same ways as other standard types of data in 
  86. the Macintosh environment. In QuickTime, a set of time-based data is 
  87. referred to as a movie. This book shows in detail how your application can 
  88. allow users to display, edit, cut, copy, and paste movies and movie data 
  89. in the same way that they can work with text and graphic elements today. 
  90.  
  91. If you want your application to be able to handle time-based data, 
  92. you should first read the chapter Introduction to QuickTime for an 
  93. introduction to the QuickTime concepts, architecture, managers, and 
  94. components.  If you want your application to be able to paste and run 
  95. QuickTime movies, to edit them, or to create new movies, you should read 
  96. the chapter Movie Toolbox. Your application may only need to paste a 
  97. movie from the Clipboard and play it; for example, a word processor might 
  98. paste a movie as it does a picture, and the user might use a movie 
  99. controller to play the movie. A more media-intensive application might 
  100. add the ability to edit the movie after it is pasted; for example, 
  101. the user might cut a segment of the movie, add a video segment, 
  102. or add a different sound track. Full "mediagenic" applications could create 
  103. a movie from disparate sources such as CD tracks, video clips, sounds, 
  104. animation from graphics programs, or still images.
  105.  
  106. If you want your application to use the facilities of QuickTime to compress 
  107. and decompress still images, you should read the chapter Image Compression 
  108. Manager. These single images are not QuickTime movies; they do not 
  109. contain time-based data. Nevertheless, you can use the image compression 
  110. and decompression facilities of QuickTime for images that are not stored 
  111. in movies. The chapter describes the Image Compression Manager, 
  112. including compression and decompression algorithms, and the steps involved 
  113. in compressing and decompressing single images and sequences of images.
  114. If you are going to play movies or compress images, you should be 
  115. familiar with QuickDraw and Color QuickDraw, described in Inside 
  116. Macintosh: Imaging. 
  117.  
  118. If you are going to create QuickTime movies, 
  119. you should also be familiar with the Sound Manager, described in Inside 
  120. Macintosh: More Macintosh Toolbox, and with the human interface guidelines 
  121. as described in Macintosh Human Interface Guidelines. If you are going to use 
  122. QuickTime components, you should be familiar with the Component Manager 
  123. as described in Inside Macintosh: More Macintosh Toolbox.
  124.  
  125. If your application imports or exports movies to other platforms, 
  126. you should read the chapter Movie Resource Formats. It presents 
  127. details of the movie file format used by QuickTime. Most applications do 
  128. not need this information.
  129.  
  130. The companion to this book, Inside Macintosh: QuickTime Components, 
  131. includes descriptions of the Apple-supplied QuickTime components: 
  132. clock components, compressor components, standard image-compression 
  133. dialog components, movie controller components, sequence grabber 
  134. components, sequence grabber channel components, sequence grabber 
  135. panel components, video digitizer components, media data-exchange 
  136. components, preview components, and media handler components.
  137.  
  138. Format of a Typical Chapter
  139.  
  140. Almost all chapters in this book follow a standard structure. For 
  141. example, the chapter Image Compression Manager contains these sections:
  142.  
  143. Introduction to the Image Compression Manager. 
  144. This section presents a general introduction to image compression.
  145.  
  146. About Image Compression. 
  147. This section provides an overview of the features provided by the 
  148. Image Compression Manager.
  149.  
  150. Using the Image Compression Manager.
  151. This section describes the tasks you can accomplish using the Image
  152. Compression Manager. It describes how to use the most common
  153. functions, gives related user interface information, provides code
  154. samples, and supplies additional information.
  155.  
  156. Image Compression Manager Reference.
  157. This section provides a complete reference to the Image Compression
  158. Manager by describing the constants, data structures, and functions
  159. that it uses. Each function description also follows a standard
  160. format, which gives the function declaration and description of every
  161. parameter of the function. Some function descriptions also give
  162. additional descriptive information, such as assembly-language
  163. information or result codes.
  164.  
  165. Summary of the Image Compression Manager.
  166. This section provides the Image Compression Manager's C interface, as 
  167. well as the Pascal interface, for the constants, data structures, 
  168. functions, and result codes associated with the Image Compression Manager.
  169.  
  170. Conventions Used in This Book
  171.  
  172. Inside Macintosh uses various conventions to present information. 
  173. Words that require special treatment appear in specific fonts or font 
  174. styles. Certain types of information, such as parameter blocks, use 
  175. special formats so that you can scan them quickly.
  176.  
  177. Special Fonts
  178. All code listings, reserved words, and the names of actual data structures, 
  179. constants, fields, parameters, and functions are shown in Courier (this 
  180. is Courier).
  181.  
  182. Words that appear in boldface are key terms or concepts and are defined 
  183. in the glossary.
  184.  
  185. Types of Notes
  186. There are several types of notes used in this book. 
  187.  
  188. Note
  189. A note like this contains information that is interesting but possibly 
  190. not essential to an understanding of the main text. (An example appears 
  191. on page 1-3.)
  192.  
  193. IMPORTANT
  194. A note like this contains information that is essential for an 
  195. understanding of the main text. (An example appears on page 2-84.)
  196.  
  197. WARNING
  198. Warnings like this indicate potential problems that you should be 
  199. aware of as you design your application. Failure to heed these warnings 
  200. could result in system crashes or loss of data. (An example appears 
  201. on page 2-59.)
  202.  
  203. Development Environment
  204.  
  205. The system software functions described in this book are available using 
  206. C or Pascal interfaces. How you access these functions depends on the 
  207. development environment you are using. This book shows system software 
  208. functions in their C interface using the Macintosh Programmer's Workshop 
  209. (MPW) version 3.2. 
  210.  
  211. All code listings in this book are shown in C. They show methods of 
  212. using various functions and illustrate techniques for accomplishing 
  213. particular tasks. All code listings have been compiled and, in most 
  214. cases, tested. However, Apple Computer, Inc., does not intend that you 
  215. use these code samples in your application.
  216.  
  217. In a few cases, the functions documented in one chapter may be listed 
  218. in the MPW interface files associated with another manager. An example 
  219. is the MakeFilePreview function, which is documented for conceptual 
  220. consistency in the chapter Movie Toolbox. This function does not 
  221. appear in the Movies.h MPW interface file; rather, it is listed in 
  222. the ImageCompression.h MPW interface file. When this occurs, the 
  223. disparity is noted in the function descriptions.
  224.  
  225. APDA, Apple's source for developer tools, offers worldwide access to 
  226. a broad range of programming products, resources, and information for 
  227. anyone developing on Apple platforms. You'll find the most current versions 
  228. of Apple and third-party development tools, debuggers, compilers, 
  229. languages, and technical references for all Apple platforms. To establish 
  230. an APDA account, obtain additional ordering information, or find out about 
  231. site licensing and developer training programs, contact
  232.  
  233. APDA
  234. Apple Computer, Inc.
  235. P. O. Box 319
  236. Buffalo, NY 14207-0319
  237. Telephone: 800-282-2732 (United States)
  238. 800-637-0029 (Canada)
  239. 716-871-6555 (International)
  240. Fax: 716-871-6511
  241. AppleLink: APDA
  242. America Online: APDA
  243. CompuServe: 76666,2405
  244. Internet: APDA@applelink.apple.com
  245.  
  246. If you provide commercial products and services, call 408-974-4897 for 
  247. information on the developer support programs available from Apple.
  248. For information on registering signatures, file types, Apple events, 
  249. and other technical information, contact
  250.  
  251. Macintosh Developer Technical Support
  252. Apple Computer, Inc.
  253. 20525 Mariani Avenue, M/S 75-3T
  254. Cupertino, CA 95014-6299
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. Movie Resource Formats
  262. Contents
  263.  
  264. Introduction to Movie Resources  4-3
  265. Storing Movies in Files  4-4
  266. Atoms  4-5
  267. Atom Types  4-6
  268. The Layout of a QuickTime Atom  4-7
  269. Overview of the Movie Resource Atom  4-8
  270. Movie Atoms  4-10
  271. Movie Header Atoms  4-11
  272. Track Atoms  4-13
  273. Track Header Atoms  4-14
  274. Media Atoms  4-16
  275. Media Header Atoms  4-17
  276. Handler Reference Atoms  4-18
  277. User-Defined Data Atoms  4-19
  278. Clipping Atoms  4-22
  279. Clipping Region Atoms  4-22
  280. Track Matte Atoms  4-23
  281. Compressed Matte Atoms  4-23
  282. Edit Atoms  4-24
  283. Edit List Atoms  4-25
  284. Media Information Atoms  4-26
  285. Video Media Information Atoms  4-26
  286. Video Media Information Header Atoms  4-27
  287. Sound Media Information Atoms  4-28
  288. Sound Media Information Header Atoms  4-29
  289. Data Information Atoms  4-30
  290. Data Reference Atoms  4-32
  291. An Introduction to Samples  4-32
  292. Sample Table Atoms  4-33
  293. Sample Description Atoms  4-35
  294. Time-to-Sample Atoms  4-36
  295. Sync Sample Atoms  4-38
  296. Sample-to-Chunk Atoms  4-39
  297. Sample Size Atoms  4-41
  298. Chunk Offset Atoms  4-42
  299. Shadow Sync Atoms  4-44
  300. Using Media Information Atoms  4-45
  301. Finding a Sample  4-46
  302. Finding a Key Frame  4-46
  303.  
  304.  
  305.  
  306. Movie Resource Formats
  307.  
  308. This chapter describes the format of QuickTime movie resources. 
  309. Movie resources are the data structures that provide the medium 
  310. of exchange for movie data. Movie resources may be exchanged between
  311. applications on a single Macintosh computer or between applications on
  312. several Macintosh and non-Macintosh computers.
  313.  
  314. IMPORTANT
  315. The information in this chapter is intended for developers who need 
  316. to know about the content of movie resources. You need to learn about 
  317. movie resources if you want to create movies on other computer
  318. environments and import them to the Macintosh environment, or
  319. if you want to interpret QuickTime movies on other types of
  320. computers.  Developers of Macintosh applications do not need
  321. to know about the layout of movie resources--the Movie Toolbox
  322. functions handle the details of movie storage and exchange.
  323.  
  324. This chapter describes atoms, the basic storage elements that, 
  325. taken together, make up a movie resource.
  326.  
  327. The chapter is divided into the following major sections:
  328.  
  329. Storing Movies in Files describes the two ways that QuickTime 
  330. movies may be stored in files.
  331.  
  332. Atoms describes the format and content of the most basic movie 
  333. storage element and the standard atoms that may be found in a 
  334. movie resource.
  335.  
  336. Overview of the Movie Resource Atom provides a look at the movie 
  337. resource structure of a QuickTime movie.
  338.  
  339. Using Media Information Atoms provides examples of the media information 
  340. atoms.
  341.  
  342. To understand fully the information presented in this chapter, you should 
  343. be familiar with the Movie Toolbox (see the chapter Movie Toolbox in
  344. this book.)  In particular, you should read about the characteristics
  345. of movie, track, and media structures.
  346.  
  347. If you are developing a movie application that runs on another type of 
  348. computer, you do not have the facilities of the Movie Toolbox available 
  349. to you.  If you want that application to exchange data with QuickTime
  350. applications on the Macintosh computer, you need to know the format of
  351. QuickTime movie resources.
  352.  
  353. Introduction to Movie Resources
  354.  
  355. Movie resources define the data interchange format for movies. The Movie 
  356. Toolbox allows your application to create, view, edit, and store QuickTime
  357. movies.  The functions of the Movie Toolbox shield your program from
  358. the details of how a movie is stored in the Macintosh file system (in
  359. the file type 'moov'.)  As a result, applications that run on
  360. Macintosh computers do not need to know anything about the internal
  361. structures of movie resources or movie files.
  362.  
  363. Storing Movies in Files
  364.  
  365. In the Macintosh file system, the Movie Toolbox typically uses both the 
  366. resource fork and the data fork to store a QuickTime movie. The resource 
  367. fork contains the movie resource. The data fork contains the actual movie 
  368. data 
  369.  
  370. To facilitate data exchange between Macintosh computers and other computers, 
  371. the Movie Toolbox can also understand movie files that store all the
  372. information for a movie in the data fork.  These movie files are called
  373. single-fork movie files.  Single-fork movie files are a possible way
  374. to export QuickTime movies to other systems, such as a computer using
  375. QuickTime for Windows.
  376.  
  377. Your application can create single-fork movie files from normal movie
  378. files by calling the Movie Toolbox's FlattenMovieData function (see
  379. the chapter "Movie Toolbox" for more information about this function.)
  380. Your application can read single-fork movie files using the standard
  381. Movie Toolbox functions--you do not need to perform any special
  382. processing.
  383.  
  384. Figure 4-1 shows the difference between single-fork and normal movie 
  385. files. A standard Macintosh movie file contains information in both 
  386. the data and resource forks.  A single-fork movie file contains a data
  387. fork.
  388.  
  389. ED.NOTE:  Figures are not available in this plain text version
  390. of the specification.
  391.  
  392. Figure 4-1 Movie files and single-fork movie files
  393.  
  394.  
  395. Single-fork movie files store all the information for a movie in the 
  396. data fork. The data fork contains two atoms: a movie data atom ('mdat') 
  397. and a movie resource atom. The movie's media data is stored in the
  398. movie data atom. Other atoms may follow the movie data atom. The movie
  399. resource atom follows the movie data atom and holds the description of
  400. the movie. There is no resource fork for this kind of movie file.
  401. Figure 4-2 shows the layout of a single-fork movie file. The movie
  402. data atom contains no other atoms, whereas the movie atom may contain
  403. other atoms.
  404.  
  405.  
  406. Figure 4-2 The structure of a single-fork movie file
  407.  
  408.  
  409. Atoms
  410.  
  411. The basic data unit in a QuickTime movie resource is the atom. Each
  412. atom contains size and type information along with its data. The size
  413. field indicates the number of bytes in the atom, including the size
  414. and type fields. The type field specifies the type of data stored in
  415. the atom and, by implication, the format of that data.
  416.  
  417. Atom Types
  418.  
  419. Table 4-1 lists the atom types defined by Apple and their
  420. corresponding constants and atom names.
  421.  
  422. Table 4-1 Apple-defined atom types
  423.  
  424. Constant        Atom type    Atom name
  425. --------        ---------    ---------
  426. MovieAID        'moov'        Movie atom
  427. MovieHeaderAID        'mvhd'        Movie header atom
  428. ClipAID            'clip'        Clipping atom
  429. RgnClipAID        'crgn'        Clipping region atom
  430. MatteAID        'matt'        Track matte atom
  431. MatteCompAID        'kmat'        Compressed matte atom
  432. TrackAID        'trak'        Track atom
  433. UserDataAID        'udta'        User-defined data atom
  434. TrackHeaderAID        'tkhd'        Track header atom
  435. EditsAID        'edts'        Edit atom
  436. EditsListAID        'elst'        Edit list atom
  437. MediaAID        'mdia'        Media atom
  438. MediaHeaderAID        'mdhd'        Media header atom
  439. MediaInfoAID        'minf'        Media information atom
  440. VideoMediaInfoHeaderAID    'vmhd'        Video media information header atom
  441. SoundMediaInfoHeaderAID    'smhd'        Sound media information header atom
  442. DataInfoAID        'dinf'        Data information atom
  443. DataRefAID        'dref'        Data reference atom
  444. SampleTableAID        'stbl'        Sample table atom
  445. STSampleDescAID        'stsd'        Sample description atom
  446. STTimeToSampAID        'stts'        Time-to-sample atom
  447. STSyncSampleAID        'stss'        Sync sample atom
  448. STShadowSyncAID        'stsh'        Shadow sync atom
  449. STSampleToChunkAID    'stsc'        Sample-to-chunk atom
  450. HandlerAID        'hdlr'        Handler reference atom
  451. STSampleSizeAID        'stsz'        Sample size atom
  452. STChunkOffsetAID    'stco'        Chunk offset atom
  453.  
  454. The Layout of a QuickTime Atom
  455.  
  456. Figure 4-3 shows the layout of a sample QuickTime atom. Each atom
  457. carries its own size and type information as well as its data.
  458. Throughout this chapter, the name of a container atom (an atom that
  459. contains other atoms, including other container atoms) is printer
  460. across a horizontal gray band, and the name of a leaf atom (an atom
  461. that contains no other atoms) is printed across a horizontal drop
  462. shadow box. Leaf atoms contain data, usually in the form of tables.
  463.  
  464. Figure 4-3 A sample QuickTime atom
  465.  
  466.  
  467. Overview of the Movie Resource Atom
  468.  
  469. Movie resources consist of movie atoms, which in turn contain track
  470. atoms, which in turn contain media atoms (see the chapter Movie
  471. Toolbox in this book for information about the relationships between
  472. movies, tracks, and media structures). Leaf atoms usually contain
  473. tables of data. For example, the track atom contains the edit atom,
  474. which contains a leaf atom called the edit list atom. The edit list
  475. atom contains an edit list table. (See Figure 4-15 on page 4-24 for an
  476. illustration of the edit atom, and see Figure 4-16 on page 4-25 for an
  477. illustration of the edit list table).
  478.  
  479. Figure 4-4 provides a conceptual view of the organization of a
  480. QuickTime movie, which, in this case, has one track containing video
  481. information. Each nested box in the illustration represents an atom
  482. that belongs to the atom underlying it. The figure does not show the
  483. data regions of any of the atoms. These areas are described in the
  484. pertinent sections that follow.
  485.  
  486. Figure 4-4 Sample organization of a one-track video movie
  487.  
  488.  
  489. Movie Atoms
  490.  
  491. You can use movie atoms to specify information that defines a
  492. movie. The movie atom contains the movie header atom, which defines
  493. the time scale and duration information for the entire movie, as well
  494. as its display characteristics. In addition, the movie atom contains
  495. each track in the movie.
  496.  
  497. The movie atom has an atom type of 'moov'. It contains other types of
  498. atoms, including one leaf atom--the movie header ('mvhd')--and several
  499. atoms that contain other atoms: a clipping atom ('clip'), one or more
  500. track atoms ('trak'), and user-defined data ('udta').
  501.  
  502. Figure 4-5 shows the layout of a movie atom. The movie header atom is
  503. the only required atom in the movie atom.
  504.  
  505. Figure 4-5 The layout of a movie atom
  506.  
  507.  
  508. You define a movie atom by specifying these elements:
  509.  
  510. * Size. The number of bytes in this movie atom.
  511.  
  512. * Type. The type of this movie atom (the atom type, 'moov').
  513.  
  514. * Movie header. The movie header atom associated with this movie. See
  515. the next section for details on the movie header atom.
  516.  
  517. * Movie clipping atom. The clipping atom associated with this
  518. movie. See Clipping Atoms, which begins on page 4-22, for more
  519. information.
  520.  
  521. * Track list. One or more track atoms associated with this movie. See
  522. Track Atoms, which begins on page 4-13, for details on track atoms
  523. and their associated atoms.
  524.  
  525. * User data. The user-defined data atom associated with this movie. See
  526. User-Defined Data Atoms, which begins on page 4-19, for a discussion
  527. of user-defined data.
  528.  
  529. Movie Header Atoms
  530.  
  531. You can use the movie header atom to specify the characteristics of an
  532. entire movie. Figure 4-6 shows the layout of the movie header
  533. atom. The movie header atom is a leaf atom, which contains time
  534. information for the entire movie, such as time scale and duration. It
  535. also illustrates the data stream specified in the matrix structure field.
  536.  
  537. Figure 4-6 The layout of a movie header atom
  538.  
  539.  
  540. You define a movie header atom by specifying these elements:
  541.  
  542. * Size. A long integer that specifies the number of bytes in this
  543. movie header atom.
  544.  
  545. * Type. A long integer that specifies the format of the data in this
  546. movie header atom (defined by the atom type, 'mvhd').
  547.  
  548. * Version. A 1-byte specification of the version of this movie header
  549. atom.
  550.  
  551. * Flags. Three bytes of space for future movie header flags. 
  552.  
  553. * Creation time. A long integer that specifies (in seconds since
  554. midnight, January 1, 1904) when the movie atom was created.
  555.  
  556. * Modification time. A long integer that specifies (in seconds since
  557. midnight, January 1, 1904) when the movie atom was changed.
  558.  
  559. * Time scale. A time value that indicates the time scale for this
  560. movie--that is, the number of time units that pass per second in its
  561. time coordinate system. A time coordinate system that measures time in
  562. sixtieths of a second, for example, has a time scale of 60.
  563.  
  564. * Duration. A time value that indicates the duration of the movie in
  565. time scale units.
  566.  
  567. * Preferred rate. A fixed number that specifies the rate at which to
  568. play this movie.
  569.  
  570. * Preferred volume. A 16-bit fixed number that specifies how loud to
  571. play this movie's sound.
  572.  
  573. * Reserved. Ten bytes reserved for use by Apple. Set to 0.
  574.  
  575. * Matrix. The matrix structure associated with this movie. A matrix
  576. shows how to map points from one coordinate space into another
  577. coordinate space. See the chapter Movie Toolbox in this book for
  578. details on matrix structures.
  579.  
  580. * Preview time. The time value in the movie at which the preview
  581. begins.
  582.  
  583. * Preview duration. The duration of the movie preview in movie time
  584. scale units. For more on time, see the chapter Movie Toolbox in this
  585. book.
  586.  
  587. * Poster time. The time value of the time of the movie poster.
  588.  
  589. * Selection time. The time value for the start time of the current
  590. selection.
  591.  
  592. * Selection duration. The duration of the current selection in movie
  593. time scale units.
  594.  
  595. * Current time. The time value for current time position within the
  596. movie.
  597.  
  598. * Next track ID. A long integer that indicates a value to use for the
  599. track ID number of the next track added to this movie.
  600.  
  601. Track Atoms
  602.  
  603. Track atoms define a single track of a movie. A movie may consist of
  604. one or more tracks. Each track is independent of the other tracks in
  605. the movie and carries its own temporal and spatial information. Each
  606. track atom contains its associated media atom. Figure 4-7 shows the
  607. layout of a track atom. The track atom requires the track header atom
  608. and the media atom.
  609.  
  610. Figure 4-7 The layout of a track atom 
  611.  
  612.  
  613. The track atom contains a track header atom ('tkhd'), a track clipping
  614. atom ('clip'), a track matte atom ('matt'), an edit atom ('edts'), a
  615. media atom ('mdia'), and a user-defined data atom ('udta'). You define
  616. a track atom by specifying these elements:
  617.  
  618. * Size. The number of bytes in this track atom.
  619.  
  620. * Type. The type of this track atom (the atom type, 'trak').
  621.  
  622. * Track header. The track header atom associated with this track. See
  623. the next section for details.
  624.  
  625. * Track clipping. The track clipping atom associated with this
  626. track. See Clipping Atoms, which begins on page 4-22, for more on
  627. clipping atoms.
  628.  
  629. * Track matte. The track matte atom associated with this track. See
  630. Track Matte Atoms, which begins on page 4-23, for more on track
  631. matte atoms.
  632.  
  633. * Edits. The edit atom associated with this track. See Edit Atoms,
  634. which begins on page 4-24, for details.
  635.  
  636. * Media. The media atom associated with this track. See Media Atoms,
  637. which begins on page 4-16, for details.
  638.  
  639. * User data. The user-defined data atom associated with this
  640. track. This field is used for extension with new data types. See
  641. User-Defined Data Atoms, which begins on page 4-19 for details.
  642.  
  643. Track Header Atoms
  644.  
  645. The track header atom specifies the characteristics of a single track
  646. within a movie. A track header atom contains a size field that
  647. specifies the number of bytes and a type field that indicates the
  648. format of the data (defined by the atom type, 'tkhd'). Figure 4-8
  649. shows the structure of the track header atom.
  650.  
  651. Figure 4-8 The layout of a track header atom
  652.  
  653.  
  654. The track header atom contains the track characteristics for the
  655. track, including temporal, spatial, and volume information. You define
  656. a track header atom by specifying these elements:
  657.  
  658. * Size. A long integer that specifies the number of bytes in this
  659. track header atom.
  660.  
  661. * Type. A long integer that specifies the type of data in this track
  662. header atom (defined by the atom type, 'tkhd').
  663.  
  664. * Version. A 1-byte specification of the version of this track header.
  665.  
  666. * Track header flags. Three bytes that are reserved for the track
  667. header flags, which adjust the remaining fields in the track header
  668. according to the kind of movie track you specify with the following
  669. enumeration:
  670.  
  671. enum 
  672. {
  673. TrackEnable = 1<<0,    /* enabled track */
  674. TrackInMovie = 1<<1,   /* track in playback */
  675. TrackInPreview = 1<<2, /* track in preview */
  676. TrackInPoster = 1<<3   /* track in poster */
  677. };
  678.  
  679. * Creation time. A long integer that indicates (in seconds since
  680. midnight, January 1, 1904) when the track header was created.
  681.  
  682. * Modification time. A long integer that indicates (in seconds since
  683. midnight, January 1, 1904) when the track header was changed.
  684.  
  685. * Track ID. A long integer that specifies the value to use for the
  686. track ID number.
  687.  
  688. * Reserved. A long integer that is reserved for use by Apple. Set the
  689. value of this field to 0.
  690.  
  691. * Duration. The duration of this track (in movie time).
  692.  
  693. * Reserved. An 8-byte value that is reserved for use by Apple. Set the
  694. value of this field to 0.
  695.  
  696. * Layer. The priority of playing this track in a movie. When it plays
  697. a movie, the Movie Toolbox displays the movie's tracks according to
  698. their layer--tracks with lower layer numbers are displayed in front;
  699. tracks with higher layer numbers are displayed in back.
  700.  
  701. * Alternate group. A short integer that specifies a collection of
  702. movie tracks that contain alternate data for one another. QuickTime
  703. chooses one track from the group to be used when the movie is played.
  704. The choice may be based on such considerations as playback quality or
  705. language and the capabilities of the computer.
  706.  
  707. * Volume. A short integer that indicates how loudly this track's sound
  708. is to be played.
  709.  
  710. * Reserved. A short integer that is reserved for use by Apple. Set the
  711. value of this field to 0.
  712.  
  713. * Matrix. The matrix structure associated with this track. See Figure
  714. 4-6 on page 4-11 for an illustration of a matrix structure.
  715.  
  716. * Track width. A fixed number that specifies the width of this track.
  717.  
  718. * Track height. A fixed number that indicates the height of this
  719. track.
  720.  
  721. Media Atoms
  722.  
  723. Media atoms define the data for a movie track. The media atom contains
  724. information that specifies the component that is to interpret the
  725. media data, and it also specifies the data references. Figure 4-9
  726. shows the layout of a media atom.
  727.  
  728. Figure 4-9 The layout of a media atom
  729.  
  730.  
  731. The media atom has an atom type of 'mdia'. It may contain other atoms,
  732. such as a media header ('mdhd'), a handler reference ('hdlr'), media
  733. information ('minf'), and user-defined data ('udata'). The only
  734. requred atom in a media atom is the media header atom.
  735.  
  736. Note
  737. The handler reference atom lets you know what kind of media this media
  738. atom contains--for example, video or sound. The layout of the media
  739. information atom is specific to the media handler that is to interpret
  740. the media. Media Information Atoms, which begins on page 4-26,
  741. discusses how data may be stored in a media, using the video media
  742. format defined by Apple as an example.
  743.  
  744. You define a media atom by specifying these elements:
  745.  
  746. * Size. A long integer that specifies the number of bytes in this media
  747. atom.
  748.  
  749. * Type. A long integer that specifies the type of the data in this
  750. media atom (defined by the 'mdia' atom type).
  751.  
  752. * Media header. The media header atom, which is described in the next
  753. section. It contains the standard media information.
  754.  
  755. * Media handler. The media handler, which is defined by the handler
  756. reference atom, described in Handler Reference Atoms, which begins
  757. on page 4-18.
  758.  
  759. * Media information. The media information atom. For an example of a
  760. media information atom, see Video Media Information Atoms, which
  761. begins on page 4-26.
  762.  
  763. * User data. The user-defined data atom associated with this
  764. media. This field is used for extension with new data types. See
  765. User-Defined Data Atoms, which begins on page 4-19, for details.
  766.  
  767. Media Header Atoms
  768.  
  769. The media header atom specifies the characteristics of the media that
  770. is used to store data for the movie track defined in its associated
  771. track atom. The media header atom contains the number of bytes in the
  772. media header atom, the format of the data in the media header atom
  773. (defined by the 'mdhd' atom type), and the media header. The media
  774. characteristics include temporal information. Figure 4-10 shows the
  775. layout of the media header atom.
  776.  
  777. Figure 4-10 The layout of a media header atom
  778.  
  779.     
  780. You define a media header atom by specifying these elements:
  781.  
  782. * Size. A long integer that specifies the number of bytes in this
  783. media header atom.
  784.  
  785. * Type. A long integer that specifies the type of data in this media
  786. header atom (defined by the atom type, 'mdhd').
  787.  
  788. * Version. One byte that specifies the version of this movie.
  789.  
  790. * Flags. Three bytes of space for future media header flags.
  791.  
  792. * Creation time. A long integer that specifies (in seconds since
  793. midnight, January 1, 1904) when the media atom was created.
  794.  
  795. * Modification time. A long integer that specifies (in seconds since
  796. midnight, January 1, 1904) when the media atom was changed.
  797.  
  798. * Time scale. A time value that indicates the time scale for this
  799. media--that is, the number of time units that pass per second in its
  800. time coordinate system.
  801.  
  802. * Duration. The duration of this media in media time scale units.
  803.  
  804. * Language. A short integer that specifies the language code for this
  805. media. See Inside Macintosh: Text for more on language codes.
  806.  
  807. * Quality. A short integer that specifies the playback quality (that
  808. is, its suitability for playback in a given environment) for this
  809. media. See the chapter Movie Toolbox in this book for details on
  810. playback quality.
  811.  
  812. Handler Reference Atoms
  813.  
  814. The handler reference atom specifies the component that is to
  815. interpret a media's data. This component is called a media
  816. handler. (See the chapter Component Manager in Inside Macintosh: More
  817. Macintosh Toolbox for more information about components.) Figure 4-11
  818. shows the layout of a handler reference atom.
  819.  
  820. Figure 4-11 The layout of a handler reference atom
  821.  
  822.  
  823. You define a handler reference atom by specifying these elements:
  824.  
  825. * Size. The number of bytes in this handler reference atom.
  826.  
  827. * Type. The type of the data (defined by the 'hdlr' atom type) in the
  828. handler reference atom.
  829.  
  830. * Flags. A 1-byte specification of the version of this handler
  831. information.
  832.  
  833. * Version. A 3-byte space for future handler information flags.
  834.  
  835. * Component type. A four-character code that identifies the type of
  836. the media handler. All components of a particular type must support a
  837. common set of functions. Examples of component types are 'mhlr' and
  838. dhlr'.
  839.  
  840. * Component subtype. A four-character code that identifies the type of
  841. the media handler. Different types of a component type may support
  842. additional features or provide interfaces that extend beyond the
  843. standard functions for a given component type value. For media
  844. handlers, this field defines the type of data--for example, 'vide' or
  845. 'soun'.
  846.  
  847. * Component manufacturer. A four-character code that identifies the
  848. manufacturer of this media handler. This field allows for further
  849. differentiation between indicidual components. For example, components
  850. made by a specific manufacturer may support an extended feature set.
  851.  
  852. * Component flags. A 32-bit field that provides additional information
  853. about a particular media handler. The most significant 8 bits are
  854. reserved for use by the Component Manager and provide both static and
  855. dynamic information about the component.
  856.  
  857. * Component flags mask. A 32-bit field that indicates which flags in
  858. the component mask are relevant to a particular search
  859. operation. These flags are used when searching for a handler component.
  860.  
  861. * Component name. A Pascal string that specifies the name of the
  862. component--that is, the original handler used when this movie was
  863. created.
  864.  
  865. User-Defined Data Atoms
  866.  
  867. Many movie, track, and media atoms contain atoms that store
  868. user-defined data. Your application may store data in these
  869. user-defined data atoms.
  870.  
  871. Figure 4-12 shows the layout of a user-defined data atom.
  872.  
  873. Figure 4-12 The layout of a user-defined data atom
  874.  
  875.  
  876. You define a user-defined data atom by specifying these elements:
  877.  
  878. * Size. The number of bytes in the data element.
  879.  
  880. * Type. The type of the data in the data element (defined by the
  881. 'udta' atom type).
  882.  
  883. * User data list. The movie user data atom contains a user data list
  884. that is itself formatted like a series of atoms. Each data element in
  885. the private data portion of the user-defined data atom contains size
  886. and type information along with the data. Furthermore, the list of
  887. atoms is optionally terminated by a 0.
  888.  
  889. The following user data types are currently defined:
  890.  
  891. '(c)cpy'    Copyright statement
  892. '(c)day'    Date the movie content was created
  893. '(c)dir'    Name of movie's director
  894. '(c)ed1' to
  895. '(c)ed9'    Edit dates and descriptions
  896. '(c)fmt'    Indication of movie format (computer-generated, digitized,
  897.         and so on)
  898. '(c)inf'    Information about the movie
  899. '(c)prd'    Name of movie's producer
  900. '(c)prf'    Names of performers
  901. '(c)req'    Special hardware and software requirements
  902. '(c)src'    Credits for those who provided movie source content
  903. '(c)wrt'    Name of movie's writer
  904.  
  905. User data items of these types must contain text data only.
  906.  
  907. Clipping Atoms
  908.  
  909. Clipping atoms specify the clipping regions for movies and for
  910. tracks. Figure 4-13 shows the layout of clipping atoms.
  911.  
  912. Figure 4-13 The layout of a clipping atom
  913.  
  914.  
  915. You define a clipping atom by specifying these elements:
  916.  
  917. * Size. The number of bytes in this clipping atom.
  918.  
  919. * Type. The type of the data in this clipping atom (defined by the
  920. 'clip' atom type).
  921.  
  922. * Clipping region atom. Described in the next section.
  923.  
  924. Clipping Region Atoms
  925.  
  926. The clipping region atom specifies the clipping data. The layout of
  927. the clipping region atom is shown in Figure 4-13. You define a
  928. clipping region atom by specifying these elements:
  929.  
  930. * Size. A long integer that indicates the number of bytes in the
  931. clipping region data atom.
  932.  
  933. * Type. A long integer that indicates the type of the clipping region
  934. data (defined by the 'crgn' atom type).
  935.  
  936. The region size, region boundary box, and data fields constitute a
  937. QuickDraw region. See the chapter QuickDraw in Inside Macintosh:
  938. Imaging for details on QuickDraw regions.
  939.  
  940. Track Matte Atoms
  941.  
  942. Track matte atoms specify the mattes for tracks. (A track matte is a
  943. pixel map that defines the blending of visual track data. See the
  944. chapter Movie Toolbox in this book for details.) Figure 4-14 shows the
  945. layout of track matte atoms.
  946.  
  947. Figure 4-14 The layout of a track matte atom 
  948.  
  949.  
  950. You define a track matte atom by specifying these elements:
  951.  
  952. * Size. A long integer that specifies that number of bytes in this
  953. track matte atom.
  954.  
  955. * Type. A long integer that specifies the type of this track matte atom
  956. (defined by the 'matt' atom type).
  957.  
  958. * Compressed matte atom. The compressed matte atom, which is described
  959. in the next section.
  960.  
  961. Compressed Matte Atoms
  962.  
  963. The compressed matte atom specifies the image description structure
  964. associated with a particular matte atom. The layout of the compressed
  965. matte atom is shown in Figure 4-14.
  966.  
  967. You define a compressed matte atom by specifying these elements:
  968.  
  969. * Size. A long integer that indicates the number of bytes in this
  970. compressed matte atom.
  971.  
  972. * Type. A long integer that indicates the type of the data in this atom
  973. (defined by the 'kmat' atom type).
  974.  
  975. * Version. A 1-byte specification of the version of this compressed
  976. matte atom.
  977.  
  978. * Flags. Three bytes of space for future flags associated with this
  979. compressed matte atom.
  980.  
  981. * Matte image description. An image description structure of variable
  982. length and associated with this matte data. See the chapter Image
  983. Compression Manager in this book for details on the image description
  984. structure.
  985.  
  986. * Matte data. The compressed matte data, which is of variable length.
  987.  
  988. Edit Atoms
  989.  
  990. You can use edit atoms to define the portions of the media that are to
  991. be used to build up a track for a movie. Figure 4-15 shows the layout
  992. of an edit atom.
  993.  
  994. Note
  995. If the edit atom or the edit list atom is missing, you can assume that
  996. the entire media is contained in the track.
  997.  
  998. Figure 4-15 The layout of an edit atom 
  999.  
  1000.  
  1001. You define an edit atom by specifying these elements:
  1002.  
  1003. * Size. A long integer that indicates the number of bytes in this edit
  1004. atom.
  1005.  
  1006. * Type. A long integer that indicates the type of the data in this edit
  1007. atom (defined by the 'edts' atom type).
  1008.  
  1009. * Edit list. The edit list atom that contains the edit list
  1010. information, described in the next section.
  1011.  
  1012. Edit List Atoms
  1013.  
  1014. You can use the edit list atom, also shown in Figure 4-15, to tell
  1015. QuickTime how to map from a time in a movie to a time in a media, and
  1016. ultimately to media data. This information is in the form of an edit
  1017. list table, shown in Figure 4-16.
  1018.  
  1019. You define an edit list atom by specifying the following elements:
  1020.  
  1021. * Size. A long integer that specifies the number of bytes in the edit
  1022. list atom.
  1023.  
  1024. * Type. A long integer that specifies the type of the edit list data
  1025. (defined by the 'elst' atom type).
  1026.  
  1027. * Version. A 1-byte specification of the version of this edit list
  1028. atom.
  1029.  
  1030. * Flags. Three bytes of space for future flags to be associated with
  1031. this edit list atom.
  1032.  
  1033. * Number of entries. The number of entries in the edit list atom.
  1034.  
  1035. * Edit list table. Each entry in the edit list table (shown in Figure
  1036. 4-16) describes a single edit and contains a track duration field, a
  1037. media time field, and a media rate field.
  1038.  
  1039. Figure 4-16 The layout of an edit list table
  1040.  
  1041.  
  1042. You create an edit list table by specifying these elements:
  1043.  
  1044. * Track duration. The duration of this edit segment in movie time scale
  1045. units.
  1046.  
  1047. * Media time. The starting time within the media of this edit segment
  1048. (in media time scale units). If -1, it is an empty edit.
  1049.  
  1050. * Media rate. A fixed number that specifies the relative rate at which
  1051. to play the media for this edit segment.
  1052.  
  1053. Media Information Atoms
  1054.  
  1055. Media information atoms (defined by the 'minf' data type) store
  1056. handler-specific information for the media data that constitutes a
  1057. track. The media handler uses this information to map from media time
  1058. to media data. These atoms are formatted differently based on the type
  1059. of media data stored in the atom. The format and content of media
  1060. information atoms are dictated by the media handler that is
  1061. responsible for interpreting the media data stream. Another media
  1062. handler would not know how to interpret this information. This section
  1063. describes examples of atoms that store media information for the video
  1064. (defined by the 'vmhd' atom type) and sound (defined by the 'smhd'
  1065. atom type) portions of QuickTime movies.
  1066.  
  1067. Note
  1068. Using Media Information Atoms, which begins on page 4-45, discusses
  1069. how the video media handler locates samples in a video media.
  1070.  
  1071. Video Media Information Atoms
  1072.  
  1073. Video media information atoms are the highest-level atoms in video
  1074. media. A number of other atoms define specific characteristics of the
  1075. video media data. Figure 4-17 shows the layout of a video media
  1076. information atom.
  1077.  
  1078. Figure 4-17 The layout of a media information atom for video
  1079.  
  1080.  
  1081. You define a video media information atom by specifying these elements:
  1082.  
  1083. * Size. A long integer that specifies the number of bytes in this video
  1084. media information atom.
  1085.  
  1086. * Type. A long integer that specifies the type of the data (defined by
  1087. the 'minf' atom type) in this media information header.
  1088.  
  1089. * Video media information. The video media information header atom (a
  1090. required atom), which is described in the next section.
  1091.  
  1092. * Handler reference. The handler reference atom (a required atom),
  1093. which contains information specifying the data handler component that
  1094. provides access to the media data. See the chapter Component Manager in
  1095. Inside Macintosh: More Macintosh Toolbox for more information about
  1096. components. Figure 4-11 on page 4-18 shows the layout of a handler
  1097. reference atom. The handler reference uses the data information atom,
  1098. described by the datainfo field in the video media information
  1099. structure.
  1100.  
  1101. * Data information. The data information atom, described in Data
  1102. Information Atoms on page 4-30.
  1103.  
  1104. * Sample table. The sample table atom, described in Sample Table
  1105. Atoms on page 4-33.
  1106.  
  1107. Video Media Information Header Atoms
  1108.  
  1109. Video media information atoms are the highest-level atoms in video
  1110. media. A number of other atoms define specific characteristics of the
  1111. video media ddata. Figure 4-18 shows the structure of a video media
  1112. information header atom.
  1113.  
  1114. Figure 4-18 The layout of a media information header atom for video
  1115.  
  1116.  
  1117. You define a video media information header atom by specifying these elements:
  1118.  
  1119. * Size. A long integer that specifies the number of bytes in the media
  1120. information in this video media information header.
  1121.  
  1122. * Type. A long integer that specifies the type of the data (defined by
  1123. the 'vmhd' atom type) in this video media information header.
  1124.  
  1125. * Version. A 1-byte specification of the version of this video media
  1126. information header.
  1127.  
  1128. * Flags. A 3-byte space for video media information flags. The
  1129. videoFlagNoLeanAhead flag is available, which instructs QuickTime that
  1130. the video was not created skewed and that it should use a technique
  1131. having greater accuracy.
  1132.  
  1133. * Graphics mode. A short integer that specifies the transfer mode,
  1134. which is a specification of which Boolean operation QuickDraw should
  1135. perform when drawing or transferring an image from one location to another.
  1136.  
  1137. * Opcolor. Three 16-bit values that specify the red, green, and blue
  1138. colors for the transfer mode operation indicated in the graphics mode
  1139. field.
  1140.  
  1141. For comprehensive details on QuickDrawUs transfer modes and opcolors
  1142. and their values, see Inside Macintosh: Imaging.
  1143.  
  1144. Sound Media Information Atoms
  1145.  
  1146. Sound media information atoms are the highest-level atoms in sound
  1147. media. These atoms define specific characteristics of the sound media
  1148. data. Figure 4-19 shows the layout of a sound media information atom.
  1149.  
  1150. Figure 4-19 The layout of a media information atom for sound
  1151.  
  1152.  
  1153. In addition to the size and type information, the sound media
  1154. information atom contains the sound media information header atom,
  1155. which is described in the next section, and the handler reference
  1156. atom, the data information atom, and the sample table atom.
  1157.  
  1158. You define a sound media information atom by specifying these elements:
  1159.  
  1160. * Size. A long integer that specifies the number of bytes in this sound
  1161. media information atom.
  1162.  
  1163. * Type. A long integer that specifies the type of the data in this
  1164. sound media information header (defined by the 'minf' data type).
  1165.  
  1166. * Sound media information. The sound media information header atom (a
  1167. required atom), which is described in the next section.
  1168.  
  1169. * Handler reference. The handler reference atom (a required atom),
  1170. which contains information specifying the data handler component that
  1171. provides access to the media data. See the chapter Component Manager
  1172. in Inside Macintosh: More Macintosh Toolbox for more information about
  1173. components. Figure 4-11 on page 4-18 shows the layout of a handler
  1174. reference atom. The handler reference atom uses the data information
  1175. atom, described by the dataInfo field in this sound media information
  1176. structure.
  1177.  
  1178. * Data information. The data information atom, described in Data
  1179. Information Atoms, which begins on page 4-30.
  1180.  
  1181. * Sample table. The sample table atom, described in Sample Table
  1182. Atoms, which begins on page 4-33.
  1183.  
  1184. Sound Media Information Header Atoms
  1185.  
  1186. The sound media information header atom (shown in Figure 4-20) stores
  1187. the sound media information.
  1188.  
  1189. Figure 4-20 The layout of a sound media information header atom
  1190.  
  1191.  
  1192. You define a sound media information header atom by specifying these
  1193. elements:
  1194.  
  1195. * Size. A long integer that specifies the number of bytes in this sound
  1196. media information header atom.
  1197.  
  1198. * Type. A long integer that specifies the type of the data in this
  1199. sound media information header atom (defined by the 'smhd' data type).
  1200.  
  1201. * Version. A 1-byte specification of the version of this sound media
  1202. information header.
  1203.  
  1204. * Flags. Three bytes of space for future associated flags.
  1205.  
  1206. * Balance. A short integer that specifies the sound balance of this
  1207. sound media. (Sound balance is the setting that controls the mix of
  1208. sound between the two speakers of a computer.) This field is normally
  1209. set to 0. See the chapter Movie Toolbox in this book for more on sound
  1210. balance.
  1211.  
  1212. * Reserved. Reserved for use by Apple. Set this field to 0.
  1213.  
  1214. Data Information Atoms
  1215.  
  1216. The handler reference atom (described in Handler Reference Atoms,
  1217. which begins on page 4-18) contains information specifying the data
  1218. handler component that provides access to the media data. See the
  1219. chapter Component Manager in Inside Macintosh: More Macintosh Toolbox
  1220. for more about components. The handler uses the data information atom,
  1221. which you can use to specify where the media data is stored. Figure
  1222. 4-21 shows the layout of the data information atom.
  1223.  
  1224. Figure 4-21 The layout of a data information atom
  1225.  
  1226.  
  1227. You define a data information atom by specifying these elements:
  1228.  
  1229. * Size. A long integer that specifies the number of bytes in this data
  1230. information atom.
  1231.  
  1232. * Type. A long integer that specifies the format (defined by the 'dinf'
  1233. atom type) of the data in this data information atom.
  1234.  
  1235. * Data references. The data reference atom, described in the next
  1236. section, contains the data references.
  1237.  
  1238. Data Reference Atoms 
  1239.  
  1240. Figure 4-21 also shows the data reference atom, which encompasses the
  1241. data references.
  1242.  
  1243. You define a data reference atom by specifying these elements:
  1244.  
  1245. * Size. A long integer that specifies the number of bytes in this data
  1246. reference container atom.
  1247.  
  1248. * Type. A long integer that specifies the type of the data in the data
  1249. reference atom (defined by the 'dref' data type).
  1250.  
  1251. * Version. A 1-byte specification of the version of this data reference
  1252. atom.
  1253.  
  1254. * Flags. Three bytes that contain space for future flags.
  1255.  
  1256. * Number of entries. A count of entries in the data references field.
  1257.  
  1258. * Data references. Data references are formatted like atoms, as
  1259. follows:
  1260.  
  1261.   * Size. A long integer that specifies the number of bytes in these data
  1262.   references.
  1263.  
  1264.   * Type. A long integer that specifies the type of the data (currently
  1265.   defined by the 'alis' data type on the Macintosh computer) in the data
  1266.   references.
  1267.  
  1268.   * Version. A 1-byte specification of the version of these data
  1269.   references.
  1270.  
  1271.   * Flags. Three bytes that contain the attributes of the data in these
  1272.   data references. One enumerated constant is available. The
  1273.   dataRefSelfReference attribute denotes that the data comes from the
  1274.   same location as the movie resource. If the movie resource came from a
  1275.   resource fork, the movie data is in the data fork of the same file. In
  1276.   the case of a single-fork file, the movie data is also in the data
  1277.   fork of the file.
  1278.  
  1279.   * Data references. The data reference information. (For the current
  1280.   data handlers, this is an alias).
  1281.  
  1282. An Introduction to Samples
  1283.  
  1284. One way to describe a sample (that is, a single element of a sequence
  1285. of time-ordered data) is to include it in a sample table atom. Samples
  1286. are stored sequentially in the media, and they may have varying
  1287. durations. This approach enforces an ordering of the samples--it does
  1288. not mean the sample data must be stored sequentially with respect to
  1289. movie time in the actual data stream. Figure 4-22 shows the way that
  1290. samples are stored in a series of chunks in a media. Chunks are a
  1291. collection of data samples in a media that allow optimized data
  1292. access. A chunk may contain one or more samples. Chunks in a media may
  1293. have different sizes, and the samples within a chunk may have
  1294. different sizes.
  1295.  
  1296. Figure 4-22 Samples in a media
  1297.  
  1298.  
  1299. Sample Table Atoms
  1300.  
  1301. The sample table atom contains information for converting from media
  1302. time to sample number to sample location. This atom also indicates how
  1303. to interpret the sample (for example, whether to decompress the video
  1304. sample and, if so, how). This section describes the format and content
  1305. of the sample table atom.
  1306.  
  1307. The sample table has an atom type of 'stbl'. It contains the sample
  1308. description atom, the time-to-sample atom, the sample-to-chunk atom,
  1309. the sync sample atom, the sample size atom, the chunk offset atom, and
  1310. the shadow sync atom.
  1311.  
  1312. Figure 4-23 shows the layout of the sample table atom. 
  1313.  
  1314. Figure 4-23 The layout of a sample table atom
  1315.  
  1316.  
  1317. You define a sample table atom by specifying these elements:
  1318.  
  1319. * Size. A long integer that specifies the number of bytes in the sample
  1320. table atom.
  1321.  
  1322. * Type. A long integer that specifies the type of the data (defined by
  1323. the 'stbl' atom type) in the sample table atom.
  1324.  
  1325. * Sample description. The sample description atom, described in the
  1326. next section.
  1327.  
  1328. * Time-to-sample. The time-to-sample atom, described in Time-to-Sample
  1329. Atoms, which begins on page 4-36.
  1330.  
  1331. * Sync sample. The sync sample atom, described in Sync Sample Atoms,
  1332. which begins on page 4-38.
  1333.  
  1334. * Sample-to-chunk. The sample-to-chunk atom, described in
  1335. Sample-to-Chunk Atoms, which begins on page 4-39.
  1336.  
  1337. * Sample size. The sample size atom, described in Sample Size Atoms,
  1338. which begins on page 4-41.
  1339.  
  1340. * Chunk offset. A chunk offset atom, described in Chunk Offset Atoms,
  1341. which begins on page 4-42.
  1342.  
  1343. * Shadow sync. The shadow sync atom, described in Shadow Sync Atoms,
  1344. which begins on page 4-44.
  1345.  
  1346. The following sections discuss each of the atoms that may be contained in a sample table.
  1347.  
  1348. Sample Description Atoms
  1349.  
  1350. The sample description atom stores information for the decoding of
  1351. samples in the media. In the case of video media, the sample
  1352. descriptions are image description structures (see the chapter Image
  1353. Compression Manager earlier in this book for more information about
  1354. image descriptions). Figure 4-24 shows the layout of the sample
  1355. description atom.
  1356.  
  1357. The sample description atom has an atom type of 'stsd'. The sample
  1358. description atom contains a table of sample descriptions, each of
  1359. which contains a single sample description. A media may have one or
  1360. more sample descriptions, depending upon the number of different
  1361. compression types used in the media. The sample-to-chunk atom
  1362. identifies the sample description for each sample in the media by
  1363. specifying the index into this table for the appropriate description
  1364. (see Sample-to-Chunk Atoms, which begins on page 4-39).
  1365.  
  1366. Figure 4-24 The layout of a sample description atom
  1367.  
  1368.  
  1369. You define a sample description atom by specifying these elements:
  1370.  
  1371. * Size. A long integer that specifies the number of bytes in this
  1372. sample description atom.
  1373.  
  1374. * Type. A long integer that specifies the type (defined by the atom
  1375. type 'stsd') of the data in this sample description atom.
  1376.  
  1377. * Version. A 1-byte specification of the version number of this sample
  1378. description atom.
  1379.  
  1380. * Flags. Three bytes of space for future flags associated with it.
  1381.  
  1382. * Number of entries. A long integer that specifies how many entries in
  1383. the sample description table are listed in the sample description
  1384. table field of this atom.
  1385.  
  1386. * Sample description table. The sample description table, which
  1387. contains a list of sample descriptions.
  1388.  
  1389. Time-to-Sample Atoms
  1390.  
  1391. Time-to-sample atoms store duration information for the samples in a
  1392. media, providing a mapping from a time in a media to the corresponding
  1393. data sample. The time-to-sample atom has an atom type of 'stts'.
  1394.  
  1395. You can determine the appropriate sample for any given time in a media
  1396. by examining the time-to-sample atom (shown in Figure 4-25), which
  1397. contains the time-to-sample atom table.
  1398.  
  1399. Figure 4-25 The layout of a time-to-sample atom
  1400.  
  1401.  
  1402. You define a time-to-sample atom by specifying these elements:
  1403.  
  1404. * Size. A long integer that specifies the number of bytes in this
  1405. time-to-sample atom.
  1406.  
  1407. * Type. A long integer that specifies the type (defined by the 'stts'
  1408. atom type) of the data contained in the time-to-sample atom.
  1409.  
  1410. * Version. A 1-byte specification of the version number of this
  1411. time-to-sample atom.
  1412.  
  1413. * Flags. Three bytes of space for any future flags associated with this
  1414. time-to-sample atom.
  1415.  
  1416. * Number of entries. A long integer that specifies the number of
  1417. entries in the time-to-sample table.
  1418.  
  1419. * Time-to-sample table. The time-to-sample atom contains a table that
  1420. defines the duration of each sample in the media. Each table entry
  1421. contains a count field and a duration field. The structure of the
  1422. time-to-sample table is shown in Figure 4-26.
  1423.  
  1424. Figure 4-26 The layout of a time-to-sample table
  1425.  
  1426.  
  1427. You define a time-to-sample table by specifying these entries:
  1428.  
  1429. * Sample count. A long integer that specifies the number of consecutive
  1430. samples that have the same duration.
  1431.  
  1432. * Sample duration. A long integer that specifies the duration of each
  1433. sample.
  1434.  
  1435. Entries in the table collect samples according to their order in the
  1436. media and their duration. If consecutive samples have the same
  1437. duration, a single table entry may be used to define more than one
  1438. sample. In these cases, the count field indicates the number of
  1439. consecutive samples that have the same duration. For example, if a
  1440. video media has a constant frame rate, this table would have one entry.
  1441.  
  1442. Figure 4-27 shows an example of a time-to-sample table that is based
  1443. on the data stream shown in Figure 4-22 on page 4-33. Figure 4-22
  1444. shows a total of nine samples that correspond in count and duration to
  1445. the entries of the table shown in Figure 4-27. Even though samples 4,
  1446. 5, and 6 are in the same chunk, sample 4 has a duration of 3, and
  1447. samples 5 and 6 have a duration of 2.
  1448.  
  1449. Figure 4-27 An example of a time-to-sample table 
  1450.  
  1451.  
  1452. Sync Sample Atoms
  1453.  
  1454. The sync sample atom identifies the key frames in the media. In a
  1455. media that contains compressed data, key frames define starting points
  1456. for portions of a temporally compressed sequence (see the chapter
  1457. Image Compression Manager in this book for more information about key
  1458. frames and temporal compression in video data). The key frame is
  1459. self-contained--that is, it is independent of preceding frames.
  1460. Subsequent frames may depend on the key frame.
  1461.  
  1462. Sync sample atoms have an atom type of 'stss'. The sync sample atom
  1463. contains a table of sample numbers. Each entry in the table identifies
  1464. a sample that is a key frame for the media. Figure 4-28 shows the
  1465. layout of a sync sample atom.
  1466.  
  1467. If no sync sample atom exists, then all the samples are key frames. 
  1468.  
  1469. Figure 4-28 The layout of a sync sample atom
  1470.  
  1471.  
  1472. You define a sync sample atom by specifying these elements:
  1473.  
  1474. * Size. A long integer that specifies the number of bytes in this sync
  1475. sample atom.
  1476.  
  1477. * Type. A long integer that specifies the type of the data of this sync
  1478. sample atom (defined by the 'stss' atom type).
  1479.  
  1480. * Version. A 1-byte specification of the version of this sync sample
  1481. atom.
  1482.  
  1483. * Flags. Three bytes of space for future flags.
  1484.  
  1485. * Number of entries. A long integer that specifies how many sample
  1486. numbers are in the sync sample table contained in the sync sample
  1487. table field.
  1488.  
  1489. * Sync sample table. The sync sample table (shown in Figure 4-29)
  1490. consists of an array of sample numbers. Each entry in the table
  1491. identifies a sample that is a key frame for the media.
  1492.  
  1493. Figure 4-29 The layout of a sync sample table
  1494.  
  1495.  
  1496. Sample-to-Chunk Atoms
  1497.  
  1498. As samples are added to a media, they are collected into chunks that
  1499. allow optimized data access. A chunk may contain one or more samples.
  1500. Chunks in a media may have different sizes, and the samples within a
  1501. chunk may have different sizes. The sample-to-chunk atom stores chunk
  1502. information for the samples in a media. Figure 4-30 shows the layout
  1503. of the sample-to-chunk atom. By examining the sample-to-chunk atom,
  1504. you can determine the chunk that contains a specific sample.
  1505.  
  1506. Figure 4-30 The layout of a sample-to-chunk atom
  1507.  
  1508.  
  1509. You define a sample-to-chunk atom by specifying these elements:
  1510.  
  1511. * Size. A long integer that specifies the number of bytes in this
  1512. sample-to-chunk atom.
  1513.  
  1514. * Type. A long integer that specifies the type of the data in this
  1515. sample-to-chunk atom (defined by the 'stsc' atom type).
  1516.  
  1517. * Version. A 1-byte specification of the version of this
  1518. sample-to-chunk atom.
  1519.  
  1520. * Flags. Three bytes of space for future flags associated with this
  1521. sample-to-chunk atom.
  1522.  
  1523. * Number of entries. The number of entries in the sample-to-chunk
  1524. table.
  1525.  
  1526. * Sample-to-chunk table. Figure 4-31 shows the structure of a
  1527. sample-to-chunk table. Each sample-to-chunk atom contains such a
  1528. table, which identifies the chunk for each sample in a media. Each
  1529. entry in the table contains a first chunk field, a samples per chunk
  1530. field, and a sample description ID field. From this information, you
  1531. can ascertain where samples reside in the media data.
  1532.  
  1533. Figure 4-31 The layout of a sample-to-chunk table
  1534.  
  1535.  
  1536. You define a sample-to-chunk table by specifying these elements:
  1537.  
  1538. * First chunk. The first chunk number using this table entry.
  1539.  
  1540. * Samples per chunk. The number of samples in each chunk.
  1541.  
  1542. * Sample description ID. The identification number associated with the
  1543. sample description containing the sample. For details on sample
  1544. description atoms, see Sample Description Atoms, which begins on page
  1545. 4-35.
  1546.  
  1547. Figure 4-32 shows an example of a sample-to-chunk table that is based
  1548. on the data stream shown in Figure 4-22.
  1549.  
  1550. Figure 4-32 An example of a sample-to-chunk table
  1551.  
  1552.  
  1553. Each table entry corresponds to a set of consecutive chunks, each of
  1554. which contains the same number of samples. Furthermore, each of the
  1555. samples in these chunks must use the same sample description (see
  1556. Sample Description Atoms, which begins on page 4-35). Whenever the
  1557. number of samples per chunk or the sample description changes, you
  1558. must create a new table entry. If all the chunks have the same number
  1559. of samples per chunk and use the same sample description, this table
  1560. has one entry.
  1561.  
  1562. Sample Size Atoms
  1563.  
  1564. You use sample size atoms to identify the size of each sample in the media. 
  1565.  
  1566. Sample size atoms have an atom type of 'stsz'. The sample size atom
  1567. (shown in Figure 4-33) contains sample size information.
  1568.  
  1569. Figure 4-33 The layout of a sample size atom
  1570.  
  1571.  
  1572. You define a sample size atom by specifying these elements:
  1573.  
  1574. * Size. A long integer that specifies the number of bytes in this
  1575. sample size atom.
  1576.  
  1577. * Type. A long integer that specifies the type (of atom type 'stsz') of
  1578. the data in this sample size atom.
  1579.  
  1580. * Version. A 1-byte specification of the version number of this sample
  1581. size atom.
  1582.  
  1583. * Flags. Three bytes of space for future flags associated with the data
  1584. in this sample size atom.
  1585.  
  1586. * Sample size. The number of bytes in the samples in the sample size
  1587. table field. If all the samples are the same size, the sample size
  1588. field of this atom indicates the size of all the samples. If this
  1589. field is set to 0, then the samples have different sizes, and those
  1590. sizes are stored in the sample size table.
  1591.  
  1592. * Number of entries. The number of entries in the sample size table
  1593. contained in the sample size table field of this atom.
  1594.  
  1595. * Sample size table. The sample size table, which contains the sample
  1596. size information. A sample size table contains an entry for every
  1597. sample.
  1598.  
  1599. Figure 4-34 shows the sample size table for the data stream
  1600. represented in Figure 4-22 on page 4-33.
  1601.  
  1602. Figure 4-34 An example of a sample size table
  1603.  
  1604.  
  1605. Chunk Offset Atoms
  1606.  
  1607. Chunk offset atoms identify the location of each chunk of data in the 
  1608. mediaUs data stream. 
  1609.  
  1610. Chunk offset atoms have an atom type of 'stco'. The chunk offset atom 
  1611. (shown in Figure 4-35) contains a table of offset information. 
  1612.  
  1613. Figure 4-35 The layout of a chunk offset atom
  1614.  
  1615.  
  1616. You define a chunk offset atom by specifying these elements:
  1617.  
  1618. * Size. A long integer that specifies the number of bytes in this chunk
  1619. offset atom.
  1620.  
  1621. * Type. A long integer that specifies the type of the data in this
  1622. chunk offset atom (defined by the atom type 'stco').
  1623.  
  1624. * Version. A 1-byte specification of the version of this chunk offset
  1625. atom.
  1626.  
  1627. * Flags. A 3-byte space for future flags associated with this chunk
  1628. offset atom.
  1629.  
  1630. * Number of entries. A long integer that specifies the number of
  1631. entries in the chunk offset table.
  1632.  
  1633. Chunk offset table. The chunk offset table, which consists of a
  1634. number of offset fields. Each entry in the chunk offset table 
  1635. contains an offset field. There is one table entry for each 
  1636. chunk in the media. The table is indexed by chunk number--
  1637. the first table entry corresponds to the first chunk, the
  1638. second table entry is for the second chunk, and so on. The offset
  1639. field contains the byte offset from the beginning of the data stream
  1640. to the chunk.
  1641.  
  1642. Figure 4-36 shows an example of the chunk offset table for the data
  1643. stream represented by Figure 4-22 on page 4-33.
  1644.  
  1645. Figure 4-36 An example of a chunk offset table
  1646.  
  1647.  
  1648. Shadow Sync Atoms
  1649.  
  1650. Shadow sync atoms contain self-contained samples that are alternates for
  1651. existing frame difference samples. Shadow sync atoms are used to
  1652. optimize random access operations on a movie. Scrubbing is an example
  1653. of such a random access operation. These atoms are used to enhance
  1654. playback performance. See the chapter Movie Toolbox in this book for
  1655. details on the SetMediaShadowSync and GetMediaShadowSync functions,
  1656. which allow you to create an association between a frame difference
  1657. sample and a sync sample.
  1658.  
  1659. Figure 4-37 shows the layout of a shadow sync atom. Shadow sync atoms
  1660. have an atom type of 'stsh'. Each shadow sync atom contains a table
  1661. with a frame difference number and a sync sample number.
  1662.  
  1663. Figure 4-37 The layout of a shadow sync atom
  1664.  
  1665.  
  1666. You define a shadow sync atom by specifying these elements:
  1667.  
  1668. * Size. A long integer that specifies the number of bytes in this
  1669. shadow sync atom.
  1670.  
  1671. * Type. A long integer that specifies the type (defined by the atom
  1672. type 'stsh') of the data in this shadow sync atom.
  1673.  
  1674. * Version. A 1-byte specification of the version number of this shadow
  1675. sync atom.
  1676.  
  1677. * Flags. Three bytes of space for future flags.
  1678.  
  1679. * Number of entries. A long integer that specifies how many entries in
  1680. the shadow sync table are listed in the shadow sync table field of
  1681. this atom.
  1682.  
  1683. * Shadow sync table. The shadow sync table, which contains the shadow
  1684. sync information. The shadow sync table is shown in Figure 4-38.
  1685.  
  1686. Figure 4-38 The layout of a shadow sync table 
  1687.  
  1688.  
  1689. A shadow sync table contains a frame difference sample number and a
  1690. sync sample number.
  1691.  
  1692. Using Media Information Atoms 
  1693.  
  1694. This section presents examples using the atoms just described. These
  1695. examples are intended to help you understand the relationships between
  1696. these atoms. The first example, Finding a Sample, describes the steps
  1697. that the video media handler uses to find the sample that contains the
  1698. media data for a particular time in a media. The second example,
  1699. Finding a Key Frame, describes the steps that the video media handler
  1700. uses to find an appropriate key frame for a specific time in a movie.
  1701.  
  1702. Finding a Sample
  1703.  
  1704. When it displays a movie or track, QuickTime tells the appropriate
  1705. media handler to access the media data for a particular time. The
  1706. media handler must correctly interpret the data stream to retrieve the
  1707. requested data. In the case of video media, the media handler
  1708. traverses several atoms to find the location and size of a sample for
  1709. a given media time. The media handler does the following:
  1710.  
  1711. 1. Determines the time in the media time coordinate system.
  1712.  
  1713. 2. Examines the time-to-sample atom to determine the sample number
  1714. that contains the data for the specified time.
  1715.  
  1716. 3. Scans the sample-to-chunk atom to discover which chunk contains the
  1717. sample in question.
  1718.  
  1719. 4. Extracts the offset to the chunk from the chunk offset atom.
  1720.  
  1721. 5. Finds the offset within the chunk by using the sample size atom.
  1722.  
  1723. Finding a Key Frame 
  1724.  
  1725. Finding a key frame for a specified time in a movie is slightly more
  1726. complicated than finding a sample for a specified time. The media
  1727. handler must use the sync sample atom and the time-to-sample atom
  1728. together in order to find a key frame. The media handler does the
  1729. following:
  1730.  
  1731. 1. Examines the time-to-sample atom to determine the sample number
  1732. that contains the data for the specified time.
  1733.  
  1734. 2. Scans the sync sample atom to find the key frame that precedes the
  1735. sample number chosen in step 1.
  1736.  
  1737. 3. Scans the sample-to-chunk atom to discover which chunk contains the
  1738. key frame.
  1739.  
  1740. 4. Extracts the offset to the chunk from the chunk offset atom.
  1741.  
  1742. 5. Finds the offset within the chunk by using the sample size atom.
  1743.  
  1744. This chapter has described the format of QuickTime movie resources for
  1745. those developers who need to know about the content of movie
  1746. resources. The knowledge you have gained about movie resources should
  1747. help you in the creation of movies on other computers and in the
  1748. process of importing them to the Macintosh environment, or in the
  1749. interpretation of QuickTime movies on other types of computers.
  1750.