1%Copyright (C) 2007-2014 Brian Langenberger 2%This work is licensed under the 3%Creative Commons Attribution-Share Alike 3.0 United States License. 4%To view a copy of this license, visit 5%http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to 6%Creative Commons, 7%171 Second Street, Suite 300, 8%San Francisco, California, 94105, USA. 9 10\chapter{M4A} 11\label{m4a} 12M4A is typically AAC audio in a QuickTime container stream, though 13it may also contain other formats such as MPEG-1 audio. 14 15\section{the QuickTime File Stream} 16\begin{figure}[h] 17\includegraphics{figures/m4a/quicktime.pdf} 18\end{figure} 19\par 20\noindent 21Unlike other chunked formats such as RIFF WAVE, QuickTime's atom chunks 22may be containers for other atoms. All of its fields are big-endian. 23\subsection{a QuickTime Atom} 24\begin{figure}[h] 25\includegraphics{figures/m4a/atom.pdf} 26\end{figure} 27\VAR{Atom Type} is an ASCII string. 28\VAR{Atom Length} is the length of the entire atom, including the header. 29If \VAR{Atom Length} is 0, the atom continues until the end of the file. 30If \VAR{Atom Length} is 1, the atom has an extended size. This means 31there is a 64-bit length field immediately after the header which is 32the atom's actual size. 33\begin{figure}[h] 34\includegraphics{figures/m4a/atom2.pdf} 35\end{figure} 36\subsection{Container Atoms} 37There is no flag or field to tell a QuickTime parser which 38of its atoms are containers and which ones are not. 39If an atom is known to be a container, one can treat its Atom Data 40as a QuickTime stream and parse it in a recursive fashion. 41 42\clearpage 43 44\section{M4A Atoms} 45\subsection{the ftyp Atom} 46\begin{figure}[h] 47 \includegraphics{figures/m4a/ftyp.pdf} 48\end{figure} 49\par 50\noindent 51The \VAR{major brand} and \VAR{compatible brand} fields are ASCII strings, 52or NULL when compatible brand fields are exhausted. 53\VAR{major brand version} is an integer. 54 55\subsubsection{ftyp Atom Example} 56\begin{figure}[h] 57 \includegraphics{figures/m4a/ftyp-example.pdf} 58\end{figure} 59\par 60\noindent 61\begin{tabular}{rl} 62 \textsf{length} & 32 bytes \\ 63 \textsf{name} & \texttt{ftyp} \\ 64 \textsf{major brand} & \texttt{"M4A "} \\ 65 \textsf{major brand version} & 0 \\ 66 $\textsf{compatible brand}_0$ & \texttt{"M4A "} \\ 67 $\textsf{compatible brand}_1$ & \texttt{"mp42"} \\ 68 $\textsf{compatible brand}_2$ & \texttt{"isom"} \\ 69 $\textsf{compatible brand}_3$ & NULL \\ 70\end{tabular} 71 72\clearpage 73 74\subsection{the moov Atom} 75\begin{wrapfigure}[5]{r}{2in} 76 \includegraphics{figures/m4a/moov-tree.pdf} 77\end{wrapfigure} 78 79\begin{figure}[h] 80 \includegraphics{figures/m4a/moov.pdf} 81\end{figure} 82\par 83\noindent 84This is a container for \hyperref[atom:mvhd]{\ATOM{mvhd}}, 85\hyperref[atom:trak]{\ATOM{trak}} and 86\hyperref[atom:udta]{\ATOM{udta}} atoms. 87 88\clearpage 89 90\subsection{the mvhd Atom} 91\label{atom:mvhd} 92\begin{figure}[h] 93 \includegraphics{figures/m4a/mvhd.pdf} 94\end{figure} 95\par 96\noindent 97If \VAR{version} is 0, \VAR{created Mac UTC Date}, 98\VAR{modified Mac UTC Date} and 99\VAR{duration} are 32-bit fields. If it is 1, they are 64-bit fields. 100The \VAR{created MAC UTC date} and \VAR{modified MAC UTC date} are seconds 101since the Macintosh Epoch, which is 00:00:00, January 1st, 1904.\footnote{Why 1904? It's the first leap year of the 20th century.} 102To convert a Unix Epoch timestamp (seconds since January 1st, 1970) to 103a Macintosh Epoch, one needs to add 24,107 days - 104or \texttt{2082844800} seconds. 105\VAR{Time scale} is the file's sample rate 106and \VAR{duration} is the length of the file, in PCM frames. 107 108\clearpage 109 110\subsubsection{mvhd Atom Example} 111\begin{figure}[h] 112 \includegraphics{figures/m4a/mvhd-example.pdf} 113\end{figure} 114\par 115\noindent 116\begin{tabular}{rl} 117 \textsf{length} & 108 bytes \\ 118 \textsf{name} & \texttt{mvhd} \\ 119 \textsf{version} & 0 \\ 120 \textsf{flags} & 0 \\ 121 \textsf{created Mac UTC date} & 3441086831 \\ 122 \textsf{modified Mac UTC date} & 3441086831 \\ 123 \textsf{time scale} & 44100 Hz \\ 124 \textsf{duration} & 304844 PCM frames \\ 125 \textsf{playback speed} & 65536 \\ 126 \textsf{user volume} & 256 \\ 127 \textsf{reserved} & 0 \\ 128 \textsf{WGM A} & 65536 \\ 129 \textsf{WGM B} & 0 \\ 130 \textsf{WGM U} & 0 \\ 131 \textsf{WGM C} & 0 \\ 132 \textsf{WGM D} & 65536 \\ 133 \textsf{WGM V} & 0 \\ 134 \textsf{WGM X} & 0 \\ 135 \textsf{WGM Y} & 0 \\ 136 \textsf{WGM W} & 1073741824 \\ 137 \textsf{QT preview} & 0 \\ 138 \textsf{QT still poster} & 0 \\ 139 \textsf{QT selection time} & 0 \\ 140 \textsf{QT current time} & 0 \\ 141 \textsf{next track ID} & 2 \\ 142\end{tabular} 143 144\clearpage 145 146\begin{wrapfigure}[5]{r}{1in} 147 \includegraphics[width=1in,keepaspectratio]{figures/m4a/trak-tree.pdf} 148\end{wrapfigure} 149\subsection{the trak Atom} 150\label{atom:trak} 151\begin{minipage}[t]{4.75in} 152\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/trak.pdf} 153\par 154\noindent 155This is a container for \hyperref[atom:tkhd]{\ATOM{tkhd}} and 156\hyperref[atom:mdia]{\ATOM{mdia}} atoms. 157\noindent 158\subsection{the tkhd Atom} 159\label{atom:tkhd} 160\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/tkhd.pdf} 161\par 162\noindent 163As with `mvhd', if \VAR{version} is 0, \VAR{created Mac UTC Date}, 164\VAR{modified Mac UTC Date} and \VAR{duration} are 32-bit fields. 165If it is 1, they are 64-bit fields. 166\end{minipage} 167 168\clearpage 169 170\subsubsection{tkhd Atom Example} 171\begin{figure}[h] 172 \includegraphics{figures/m4a/tkhd-example.pdf} 173\end{figure} 174\par 175\noindent 176\begin{tabular}{rl} 177 \textsf{length} & 92 bytes \\ 178 \textsf{name} & \texttt{tkhd} \\ 179 \textsf{version} & 0 \\ 180 \textsf{reserved} & 0 \\ 181 \textsf{track in poster} & 0 \\ 182 \textsf{track in preview} & 1 \\ 183 \textsf{track in movie} & 1 \\ 184 \textsf{track enabled} & 1 \\ 185 \textsf{created Mac UTC date} & 3441086831 \\ 186 \textsf{modified Mac UTC date} & 3441086831 \\ 187 \textsf{track ID} & 1 \\ 188 \textsf{reserved} & 0 \\ 189 \textsf{duration} & 304844 PCM frames \\ 190 \textsf{reserved} & 0 \\ 191 \textsf{video layer} & 0 \\ 192 \textsf{QT alternate} & 0 \\ 193 \textsf{volume} & 256 \\ 194 \textsf{reserved} & 0 \\ 195 \textsf{VGM Value A} & 65536 \\ 196 \textsf{VGM Value B} & 0 \\ 197 \textsf{VGM Value U} & 0 \\ 198 \textsf{VGM Value C} & 0 \\ 199 \textsf{VGM Value D} & 65536 \\ 200 \textsf{VGM Value V} & 0 \\ 201 \textsf{VGM Value X} & 0 \\ 202 \textsf{VGM Value Y} & 0 \\ 203 \textsf{VGM Value W} & 1073741824 \\ 204 \textsf{video width} & 0 \\ 205 \textsf{video height} & 0 \\ 206\end{tabular} 207 208\clearpage 209 210\begin{wrapfigure}[5]{r}{1in} 211 \includegraphics[width=1in,keepaspectratio]{figures/m4a/mdia-tree.pdf} 212\end{wrapfigure} 213\begin{minipage}[t]{4.75in} 214\subsection{the mdia Atom} 215\label{atom:mdia} 216\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/mdia.pdf} 217\par 218\noindent 219This is a container for \hyperref[atom:mdhd]{\ATOM{mdhd}}, 220\hyperref[atom:hdlr]{\ATOM{hdlr}} and 221\hyperref[atom:minf]{\ATOM{minf}} atoms. 222 223\subsection{the mdhd Atom} 224\label{atom:mdhd} 225\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/mdhd.pdf} 226\par 227\noindent 228The \ATOM{mdhd} atom contains track information such as samples-per-second, 229track length and creation/modification times. 230As with \ATOM{mvhd}, if \VAR{version} is 0, \VAR{created Mac UTC date}, 231\VAR{modified Mac UTC date} and \VAR{track length} are 32-bit fields. 232If it is 1, they are 64-bit fields. 233\VAR{language} is a set of 3, 5-bit fields which can be converted 234back to ASCII by adding 96 to their values. 235\end{minipage} 236 237\clearpage 238 239\subsubsection{mdhd Atom Example} 240\begin{figure}[h] 241 \includegraphics{figures/m4a/mdhd-example.pdf} 242\end{figure} 243\begin{figure}[h] 244 \includegraphics{figures/m4a/mdhd-example2.pdf} 245\end{figure} 246\par 247\noindent 248\begin{tabular}{rl} 249 \textsf{length} & 32 bytes \\ 250 \textsf{name} & \texttt{mdhd} \\ 251 \textsf{version} & 0 \\ 252 \textsf{flags} & 0 \\ 253 \textsf{create MAC UTC date} & 3441086831 \\ 254 \textsf{modify MAC UTC date} & 3441086831 \\ 255 \textsf{sample rate} & 44100 Hz \\ 256 \textsf{PCM frame count} & 304844 \\ 257 $\textsf{language}_0$ & \multicolumn{1}{r}{21 + 96 = \texttt{'u'}} \\ 258 $\textsf{language}_1$ & \multicolumn{1}{r}{14 + 96 = \texttt{'n'}} \\ 259 $\textsf{language}_2$ & \multicolumn{1}{r}{4 + 96 = \texttt{'d'}} \\ 260 \textsf{quality} & 0 \\ 261\end{tabular} 262\par 263\noindent 264The three language fields combine to make \texttt{"und"} meaning 265undefined, which is typical. 266 267\clearpage 268 269\subsection{the hdlr Atom} 270\label{atom:hdlr} 271\begin{figure}[h] 272\includegraphics{figures/m4a/hdlr.pdf} 273\end{figure} 274\par 275\noindent 276\VAR{QuickTime flags}, \VAR{QuickTime flags mask} and 277\VAR{component name length} 278are integers. The rest are ASCII strings. 279 280\subsubsection{hdlr Atom Example} 281\begin{figure}[h] 282\includegraphics{figures/m4a/hdlr-example.pdf} 283\end{figure} 284\begin{tabular}{rl} 285 \textsf{length} & 34 bytes \\ 286 \textsf{name} & \texttt{hdlr} \\ 287 \textsf{version} & 0 \\ 288 \textsf{flags} & 0 \\ 289 \textsf{QuickTime type} & NULL \\ 290 \textsf{subtype/media} & \textsf{"soun"} \\ 291 \textsf{QuickTime manufacturer} & NULL \\ 292 \textsf{QuickTime flags} & 0 \\ 293 \textsf{QuickTime flags mask} & 0 \\ 294 \textsf{component name length} & 0 \\ 295 \textsf{component name} & \textsf{""} \\ 296\end{tabular} 297 298\clearpage 299 300\begin{wrapfigure}[5]{r}{1in} 301 \includegraphics[width=1in,keepaspectratio]{figures/m4a/minf-tree.pdf} 302\end{wrapfigure} 303\begin{minipage}[t]{4.75in} 304\subsection{the minf Atom} 305\label{atom:minf} 306\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/minf.pdf} 307\par 308\noindent 309This atom is a container for \hyperref[atom:smhd]{\ATOM{smhd}}, 310\hyperref[atom:dinf]{\ATOM{dinf}} and 311\hyperref[atom:stbl]{\ATOM{stbl}} atoms. 312 313\subsection{the smhd Atom} 314\label{atom:smhd} 315\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/smhd.pdf} 316 317\subsubsection{smhd Atom Example} 318\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/smhd-example.pdf} 319\begin{tabular}{rl} 320 \textsf{length} & 16 bytes \\ 321 \textsf{name} & \textsf{smhd} \\ 322 \textsf{version} & 0 \\ 323 \textsf{flags} & 0 \\ 324 \textsf{audio balance} & 0 \\ 325 \textsf{reserved} & 0 \\ 326\end{tabular} 327\end{minipage} 328 329\clearpage 330 331\subsection{the dinf Atom} 332\label{atom:dinf} 333\begin{figure}[h] 334 \includegraphics{figures/m4a/dinf.pdf} 335\end{figure} 336\par 337\noindent 338This atom is a container for the \hyperref[atom:dref]{\ATOM{dref}} atom. 339 340\subsection{the dref Atom} 341\label{atom:dref} 342\begin{figure}[h] 343\includegraphics{figures/m4a/dref.pdf} 344\end{figure} 345\par 346\noindent 347This atom is a container for a number of reference atoms. 348 349\subsubsection{dref Atom Example} 350\begin{figure}[h] 351 \includegraphics{figures/m4a/dref-example.pdf} 352\end{figure} 353\begin{tabular}{rl} 354 \textsf{length} & 28 bytes \\ 355 \textsf{name} & \textsf{dref} \\ 356 \textsf{reference atoms} & 1 \\ 357\end{tabular} 358 359\clearpage 360 361\begin{wrapfigure}[5]{r}{1in} 362 \includegraphics[width=1in,keepaspectratio]{figures/m4a/stbl-tree.pdf} 363\end{wrapfigure} 364\begin{minipage}[t]{4.75in} 365\subsection{the stbl Atom} 366\label{atom:stbl} 367\includegraphics[width=4.75in,keepaspectratio]{figures/m4a/stbl.pdf} 368\par 369\noindent 370This atom is a container for the 371\hyperref[atom:stsd]{\ATOM{stsd}}, 372\hyperref[atom:stts]{\ATOM{stts}}, 373\hyperref[atom:stsc]{\ATOM{stsc}}, 374\hyperref[atom:stsz]{\ATOM{stsz}} and 375\hyperref[atom:stco]{\ATOM{stco}} atoms. 376\end{minipage} 377 378 379\clearpage 380 381\subsection{the stsd Atom} 382\label{atom:stsd} 383\begin{figure}[h] 384\includegraphics{figures/m4a/stsd.pdf} 385\end{figure} 386\par 387\noindent 388This atom typically contains a decription atom, 389which contents will vary depending on the file format. 390AAC audio contains a \ATOM{mp4a} description, 391Apple Lossless contains an \ATOM{alac} description 392and so forth. 393 394\subsubsection{stsd Atom Example} 395\begin{figure}[h] 396 \includegraphics{figures/m4a/stsd-example.pdf} 397\end{figure} 398\begin{tabular}{rl} 399 \textsf{length} & 88 bytes \\ 400 \textsf{name} & \textsf{stsd} \\ 401 \textsf{version} & 0 \\ 402 \textsf{flags} & 0 \\ 403 \textsf{number of descriptions} & 1 \\ 404\end{tabular} 405 406\clearpage 407 408%% \subsection{the mp4a Atom} 409 410%% The \ATOM{mp4a} atom contains information such as the number of channels 411%% and bits-per-sample. It can be found in the \ATOM{stsd} atom. 412 413%% \begin{figure}[h] 414%% \includegraphics{figures/m4a/mp4a.pdf} 415%% \end{figure} 416 417%% \clearpage 418 419\subsection{the stts Atom} 420\label{atom:stts} 421\begin{figure}[h] 422 \includegraphics{figures/m4a/stts.pdf} 423\end{figure} 424\par 425\noindent 426This atom is for storing stream block sizes. 427\subsubsection{stts Atom Example} 428\begin{figure}[h] 429 \includegraphics{figures/m4a/stts-example.pdf} 430\end{figure} 431\par 432\noindent 433\begin{tabular}{rl} 434 \textsf{length} & 32 bytes \\ 435 \textsf{name} & \texttt{stts} \\ 436 \textsf{version} & 0 \\ 437 \textsf{flags} & 0 \\ 438 \textsf{number of times} & 2 \\ 439 $\textsf{frame count}_0$ & 74 \\ 440 $\textsf{duration}_0$ & 4096 PCM frames \\ 441 $\textsf{frame count}_1$ & 1 \\ 442 $\textsf{duration}_1$ & 1740 PCM frames \\ 443\end{tabular} 444\par 445\noindent 446Which indicates the stream has 74 frames with 4096 PCM frames each, 447and 1 frame with 1740 PCM frames, for a total of 304844 PCM frames 448(which matches values stored elsewhere in the stream). 449 450\clearpage 451 452\subsection{the stsc Atom} 453\label{atom:stsc} 454\begin{figure}[h] 455 \includegraphics{figures/m4a/stsc.pdf} 456\end{figure} 457\par 458\noindent 459This atom indicates how the file is split into seekable chunks. 460\VAR{first chunk} is the index of the first chunk 461which contains \VAR{frames per chunk} M4A or ALAC frames per 462chunk and continues at that interval until the next index. 463 464\subsubsection{stsc Atom Example} 465\begin{figure}[h] 466 \includegraphics{figures/m4a/stsc-example.pdf} 467\end{figure} 468\par 469\noindent 470\begin{tabular}{rl} 471 \textsf{length} & 28 bytes \\ 472 \textsf{name} & \texttt{stsc} \\ 473 \textsf{number of chunks} & 1 \\ 474 $\textsf{first chunk}_0$ & 1 \\ 475 $\textsf{frames per chunk}_0$ & 5 \\ 476 $\textsf{sample duration index}$ & 1 \\ 477\end{tabular} 478\par 479\noindent 480Which indicates that all of the file's chunks, which start from index 1, 481have 5 M4A or ALAC frames. 482 483\clearpage 484 485\subsection{the stsz Atom} 486\label{atom:stsz} 487\begin{figure}[h] 488 \includegraphics{figures/m4a/stsz.pdf} 489\end{figure} 490\par 491\noindent 492This atom contains a list of M4A or ALAC frame sizes, 493with one size value per frame. 494%% \subsubsection{stsz Atom Example} 495%% \begin{figure}[h] 496%% \includegraphics{figures/m4a/stsz-example.pdf} 497%% \end{figure} 498%% \par 499%% \noindent 500%% \begin{tabular}{rl} 501%% \textsf{length} & 320 bytes \\ 502%% \textsf{name} & \texttt{stsz} \\ 503%% \textsf{block byte size} & 0 \\ 504%% \textsf{number of frame sizes} & 75 \\ 505%% $\textsf{size}_{0}$ & 3890 bytes \\ 506%% $\textsf{size}_{1}$ & 3541 bytes \\ 507%% $\textsf{size}_{2}$ & 3607 bytes \\ 508%% $\textsf{size}_{3}$ & 3636 bytes \\ 509%% $\textsf{size}_{4}$ & 3756 bytes \\ 510%% $\textsf{size}_{5}$ & 3787 bytes \\ 511%% $\textsf{size}_{6}$ & 4538 bytes \\ 512%% $\textsf{size}_{7}$ & 5154 bytes \\ 513%% $\textsf{size}_{8}$ & 5459 bytes \\ 514%% $\textsf{size}_{9}$ & 5853 bytes \\ 515%% $\textsf{size}_{10}$ & 6310 bytes \\ 516%% $\textsf{size}_{11}$ & 6269 bytes \\ 517%% $\textsf{size}_{12}$ & 5976 bytes \\ 518%% $\textsf{size}_{13}$ & 5774 bytes \\ 519%% $\textsf{size}_{14}$ & 5665 bytes \\ 520%% $\textsf{size}_{15}$ & 5483 bytes \\ 521%% $\textsf{size}_{16}$ & 5204 bytes \\ 522%% $\textsf{size}_{17}$ & 4940 bytes \\ 523%% $\textsf{size}_{18}$ & 4876 bytes \\ 524%% $\textsf{size}_{19}$ & 4775 bytes \\ 525%% $\textsf{size}_{20}$ & 4730 bytes \\ 526%% $\textsf{size}_{21}$ & 4731 bytes \\ 527%% $\textsf{size}_{22}$ & 4750 bytes \\ 528%% $\textsf{size}_{23}$ & 4922 bytes \\ 529%% $\textsf{size}_{24}$ & 4738 bytes \\ 530%% $\textsf{size}_{25}$ & 5647 bytes \\ 531%% $\textsf{size}_{26}$ & 6984 bytes \\ 532%% $\textsf{size}_{27}$ & 7450 bytes \\ 533%% $\textsf{size}_{28}$ & 7855 bytes \\ 534%% $\textsf{size}_{29}$ & 8919 bytes \\ 535%% $\textsf{size}_{30}$ & 9049 bytes \\ 536%% $\textsf{size}_{31}$ & 8484 bytes \\ 537%% $\textsf{size}_{32}$ & 6517 bytes \\ 538%% $\textsf{size}_{33}$ & 6271 bytes \\ 539%% $\textsf{size}_{34}$ & 6066 bytes \\ 540%% $\textsf{size}_{35}$ & 5833 bytes \\ 541%% $\textsf{size}_{36}$ & 5545 bytes \\ 542%% $\textsf{size}_{37}$ & 5312 bytes \\ 543%% $\textsf{size}_{38}$ & 5139 bytes \\ 544%% $\textsf{size}_{39}$ & 5004 bytes \\ 545%% $\textsf{size}_{40}$ & 4887 bytes \\ 546%% $\textsf{size}_{41}$ & 4808 bytes \\ 547%% $\textsf{size}_{42}$ & 4822 bytes \\ 548%% $\textsf{size}_{43}$ & 7520 bytes \\ 549%% $\textsf{size}_{44}$ & 8109 bytes \\ 550%% $\textsf{size}_{45}$ & 9061 bytes \\ 551%% $\textsf{size}_{46}$ & 9113 bytes \\ 552%% $\textsf{size}_{47}$ & 9785 bytes \\ 553%% $\textsf{size}_{48}$ & 9244 bytes \\ 554%% $\textsf{size}_{49}$ & 8864 bytes \\ 555%% $\textsf{size}_{50}$ & 8428 bytes \\ 556%% $\textsf{size}_{51}$ & 8175 bytes \\ 557%% $\textsf{size}_{52}$ & 7531 bytes \\ 558%% $\textsf{size}_{53}$ & 7216 bytes \\ 559%% $\textsf{size}_{54}$ & 7039 bytes \\ 560%% $\textsf{size}_{55}$ & 6611 bytes \\ 561%% $\textsf{size}_{56}$ & 6210 bytes \\ 562%% $\textsf{size}_{57}$ & 5914 bytes \\ 563%% $\textsf{size}_{58}$ & 5757 bytes \\ 564%% $\textsf{size}_{59}$ & 5587 bytes \\ 565%% $\textsf{size}_{60}$ & 5509 bytes \\ 566%% $\textsf{size}_{61}$ & 5225 bytes \\ 567%% $\textsf{size}_{62}$ & 5107 bytes \\ 568%% $\textsf{size}_{63}$ & 4850 bytes \\ 569%% $\textsf{size}_{64}$ & 4607 bytes \\ 570%% $\textsf{size}_{65}$ & 4600 bytes \\ 571%% $\textsf{size}_{66}$ & 4566 bytes \\ 572%% $\textsf{size}_{67}$ & 4367 bytes \\ 573%% $\textsf{size}_{68}$ & 4376 bytes \\ 574%% $\textsf{size}_{69}$ & 4313 bytes \\ 575%% $\textsf{size}_{70}$ & 4116 bytes \\ 576%% $\textsf{size}_{71}$ & 4143 bytes \\ 577%% $\textsf{size}_{72}$ & 3873 bytes \\ 578%% $\textsf{size}_{73}$ & 4029 bytes \\ 579%% $\textsf{size}_{74}$ & 1636 bytes \\ 580%% \end{tabular} 581 582\clearpage 583 584\subsection{the stco Atom} 585\label{atom:stco} 586\begin{figure}[h] 587 \includegraphics{figures/m4a/stco.pdf} 588\end{figure} 589\par 590\noindent 591Offsets point to an absolute position in the file, 592which will be the start of frames in the \ATOM{mdat} atom. 593\subsubsection{stco Atom Example} 594\begin{figure}[h] 595 \includegraphics{figures/m4a/stco-example.pdf} 596\end{figure} 597\par 598\noindent 599{\relsize{-2} 600\begin{tabular}{rl} 601 \textsf{length} & 76 bytes \\ 602 \textsf{name} & \texttt{stco} \\ 603 \textsf{version} & 0 \\ 604 \textsf{flags} & 0 \\ 605 \textsf{number of offsets} & 15 \\ 606 $\textsf{offset}_{0}$ & \texttt{0x2000} \\ 607 $\textsf{offset}_{1}$ & \texttt{0x67FE} \\ 608 $\textsf{offset}_{2}$ & \texttt{0xC8D5} \\ 609 $\textsf{offset}_{3}$ & \texttt{0x13DFF} \\ 610 $\textsf{offset}_{4}$ & \texttt{0x1A0BD} \\ 611 $\textsf{offset}_{5}$ & \texttt{0x1FDFC} \\ 612 $\textsf{offset}_{6}$ & \texttt{0x28DF3} \\ 613 $\textsf{offset}_{7}$ & \texttt{0x31C16} \\ 614 $\textsf{offset}_{8}$ & \texttt{0x384E7} \\ 615 $\textsf{offset}_{9}$ & \texttt{0x3FAA9} \\ 616 $\textsf{offset}_{10}$ & \texttt{0x4AE9C} \\ 617 $\textsf{offset}_{11}$ & \texttt{0x54491} \\ 618 $\textsf{offset}_{12}$ & \texttt{0x5BA10} \\ 619 $\textsf{offset}_{13}$ & \texttt{0x61CE2} \\ 620 $\textsf{offset}_{14}$ & \texttt{0x673B0} \\ 621\end{tabular} 622} 623 624\clearpage 625 626\subsection{the utda Atom} 627\label{atom:udta} 628\begin{figure}[h] 629 \includegraphics{figures/m4a/udta.pdf} 630\end{figure} 631\par 632\noindent 633This atom is a container for the \hyperref[atom:meta]{\ATOM{meta}} atom. 634 635\subsection{the meta Atom} 636\label{atom:meta} 637\begin{figure}[h] 638 \includegraphics{figures/m4a/meta.pdf} 639\end{figure} 640\begin{wrapfigure}[3]{r}{1.5in} 641 \includegraphics{figures/m4a/meta_atoms.pdf} 642\end{wrapfigure} 643\par 644\noindent 645This atom is a container for 646\hyperref[atom:hdlr]{\ATOM{hdlr}}, 647\hyperref[atom:ilst]{\ATOM{ilst}} and 648\hyperref[atom:free]{\ATOM{free}} atoms. 649Note that unlike other containers, \ATOM{meta} has \VAR{version} 650and \VAR{flags} fields prior to its sub-atoms. 651 652\clearpage 653 654\subsection{the ilst Atom} 655\label{atom:ilst} 656\begin{figure}[h] 657 \includegraphics{figures/m4a/ilst.pdf} 658\end{figure} 659\par 660\noindent 661Text \ATOM{data} atoms have a \VAR{type} of 1 662and their names are often prefixed by the \texttt{0xA9} byte 663which indicates that the value of \VAR{metadata} is UTF-8 encoded text. 664Binary data atoms typically have a \VAR{type} of 0 665which indicates \VAR{metadata} is something else. 666\begin{table}[h] 667 \begin{tabular}{rlrl} 668 \textsf{atom name} & meaning & \textsf{atom name} & meaning \\ 669 \hline 670 \texttt{alb} & album name & \texttt{ART} & track artist \\ 671 \texttt{cmt} & comments & \texttt{covr} & cover image \\ 672 \texttt{cpil} & compilation & \texttt{cprt} & copyright \\ 673 \texttt{day} & year & \texttt{disk} & disc number \\ 674 \texttt{gnre} & genre & \texttt{grp} & grouping \\ 675 \texttt{----} & iTunes-specific & \texttt{nam} & track name \\ 676 \texttt{rtng} & rating & \texttt{tmpo} & BMP \\ 677 \texttt{too} & encoder & \texttt{trkn} & track number \\ 678 \texttt{wrt} & composer \\ 679 \end{tabular} 680\end{table} 681 682\clearpage 683 684\subsubsection{the trkn Sub-Atom} 685\begin{figure}[h] 686\includegraphics{figures/m4a/trkn.pdf} 687\end{figure} 688\par 689\noindent 690\ATOM{trkn} is a binary sub-atom of \ATOM{ilst} which contains 691the file's track number and track total. 692 693\subsubsection{the disk Sub-Atom} 694\begin{figure}[h] 695\includegraphics{figures/m4a/disk.pdf} 696\end{figure} 697\par 698\noindent 699\ATOM{disk} is a binary sub-atom of \ATOM{ilst} which contains 700the file's disc number and disc total. 701 702\clearpage 703 704\subsubsection{meta Atom Example} 705\begin{figure}[h] 706\includegraphics[height=6in]{figures/m4a/meta-example.pdf} 707\end{figure} 708 709\clearpage 710 711\subsubsection{nam Atom Example} 712\includegraphics{figures/m4a/nam-example.pdf} 713\par 714\noindent 715\begin{tabular}{rl} 716 \textsf{atom name} & \texttt{ nam} \\ 717 \textsf{type} & 1 (text) \\ 718 \textsf{metadata} & \texttt{"Track Name"} (UTF-8 encoded text) \\ 719\end{tabular} 720 721\subsubsection{alb Atom Example} 722\includegraphics{figures/m4a/alb-example.pdf} 723\par 724\noindent 725\begin{tabular}{rl} 726 \textsf{atom name} & \texttt{ alb} \\ 727 \textsf{type} & 1 (text) \\ 728 \textsf{metadata} & \texttt{"Album Name"} (UTF-8 encoded text) \\ 729\end{tabular} 730 731\subsubsection{trkn Atom Example} 732\includegraphics{figures/m4a/trkn-example.pdf} 733\par 734\noindent 735\begin{tabular}{rl} 736 \textsf{atom name} & \texttt{trkn} \\ 737 \textsf{type} & 0 (binary) \\ 738 \textsf{track number} : & \texttt{1} \\ 739 \textsf{total tracks} : & \texttt{2} \\ 740\end{tabular} 741 742\subsubsection{disk Atom Example} 743\includegraphics{figures/m4a/disk-example.pdf} 744\par 745\noindent 746\begin{tabular}{rl} 747 \textsf{atom name} & \texttt{disk} \\ 748 \textsf{type} & 0 (binary) \\ 749 \textsf{track number} : & \texttt{3} \\ 750 \textsf{total tracks} : & \texttt{4} \\ 751\end{tabular} 752 753\clearpage 754 755\subsection{the free Atom} 756\label{atom:free} 757\begin{figure}[h] 758 \includegraphics{figures/m4a/free.pdf} 759\end{figure} 760\par 761\noindent 762This atom is a collection of NULL bytes which are easy 763to resize in order to accomodate more data 764in the \ATOM{meta} atom without having to change 765its size and rewrite the whole file. 766 767\subsection{the mdat Atom} 768\begin{figure}[h] 769 \includegraphics{figures/m4a/mdat.pdf} 770\end{figure} 771\par 772\noindent 773This atom is contains the file's audio data frames. 774