Set version to 1.3.0 and update coyprights throughout.
[platform/upstream/flac.git] / doc / html / format.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <!-- Copyright (c) 2000-2009  Josh Coalson
3 <!-- Copyright (c) 2011-2013  Xiph.Org Foundation -->
4 <!-- Permission is granted to copy, distribute and/or modify this document -->
5 <!-- under the terms of the GNU Free Documentation License, Version 1.1 -->
6 <!-- or any later version published by the Free Software Foundation; -->
7 <!-- with no invariant sections. -->
8 <!-- A copy of the license can be found at http://www.gnu.org/copyleft/fdl.html -->
9 <html>
10 <head>
11         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
12         <meta name="author" content="Josh Coalson" />
13         <meta name="description" content="A free, open source codec for lossless audio compression and decompression" />
14         <meta name="keywords" content="free,lossless,audio,codec,encoder,decoder,compression,compressor,archival,archive,archiving,backup,music" />
15         <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
16         <link rel="stylesheet" type="text/css" href="flac.css" />
17         <title>FLAC - format</title>
18 </head>
19
20 <body>
21
22 <div class="logo">
23         <a href="http://flac.sourceforge.net/"><img src="images/logo130.gif" alt="FLAC Logo" align="middle" border="0" hspace="0" /></a>
24 </div>
25
26 <div class="above_nav"></div>
27
28 <div class="navbar">
29         &nbsp;<a href="index.html">home</a>&nbsp;&nbsp;|
30         &nbsp;<a href="faq.html">faq</a>&nbsp;&nbsp;|
31         &nbsp;<a href="news.html">news</a>&nbsp;&nbsp;|
32         &nbsp;<a href="download.html">download</a>&nbsp;&nbsp;|
33         &nbsp;<a href="documentation.html">documentation</a>&nbsp;&nbsp;|
34         &nbsp;<a href="comparison.html">comparison</a>&nbsp;&nbsp;|
35         &nbsp;<a href="changelog.html">changelog</a>&nbsp;&nbsp;|
36         &nbsp;<a href="links.html">links</a>&nbsp;&nbsp;|
37         &nbsp;<a href="developers.html">developers</a>&nbsp;
38 </div>
39
40 <div class="langbar">
41         &nbsp;english&nbsp;&nbsp;|
42         &nbsp;<a href="ru/format.html">russian</a>&nbsp;
43 </div>
44
45 <div class="below_nav"></div>
46
47 <div class="box">
48         <div class="box_title">
49                 format
50         </div>
51         <div class="box_header"></div>
52         <div class="box_body">
53                 This is a detailed description of the FLAC format.  There is also a companion document that describes <a href="ogg_mapping.html">FLAC-to-Ogg mapping</a>.<br />
54                 <br />
55                 For a user-oriented overview, see <a href="documentation_format_overview.html">About the FLAC Format</a>.<br />
56                 <br />
57                 <a name="toc"><font size="+1"><b><u>Table of Contents</u></b></font></a>
58                 <ul>
59                         <li><a href="#acknowledgments">Acknowledgments</a></li>
60                         <li><a href="#scope">Scope</a></li>
61                         <li><a href="#architecture">Architecture</a></li>
62                         <li><a href="#definitions">Definitions</a></li>
63                         <li><a href="#blocking">Blocking</a></li>
64                         <li><a href="#interchannel">Interchannel Decorrelation</a></li>
65                         <li><a href="#prediction">Prediction</a></li>
66                         <li><a href="#residualcoding">Residual Coding</a></li>
67                         <li><a href="#format_overview">Format</a></li>
68                         <li><a href="#subset">FLAC Subset</a></li>
69                         <li>Specification
70                                 <ul>
71                                         <li><a href="#stream">STREAM</a>
72                                                 <ul>
73                                                         <li><a href="#metadata_block">METADATA_BLOCK</a>
74                                                                 <ul>
75                                                                         <li><a href="#metadata_block_header">METADATA_BLOCK_HEADER</a></li>
76                                                                         <li><a href="#metadata_block_data">METADATA_BLOCK_DATA</a>
77                                                                                 <ul>
78                                                                                         <li><a href="#metadata_block_streaminfo">METADATA_BLOCK_STREAMINFO</a></li>
79                                                                                         <li><a href="#metadata_block_padding">METADATA_BLOCK_PADDING</a></li>
80                                                                                         <li><a href="#metadata_block_application">METADATA_BLOCK_APPLICATION</a></li>
81                                                                                         <li><a href="#metadata_block_seektable">METADATA_BLOCK_SEEKTABLE</a>
82                                                                                                 <ul>
83                                                                                                         <li><a href="#seekpoint">SEEKPOINT</a></li>
84                                                                                                 </ul>
85                                                                                         </li>
86                                                                                         <li><a href="#metadata_block_vorbis_comment">METADATA_BLOCK_VORBIS_COMMENT</a></li>
87                                                                                         <li><a href="#metadata_block_cuesheet">METADATA_BLOCK_CUESHEET</a>
88                                                                                                 <ul>
89                                                                                                         <li><a href="#cuesheet_track">CUESHEET_TRACK</a>
90                                                                                                                 <ul>
91                                                                                                                         <li><a href="#cuesheet_track_index">CUESHEET_TRACK_INDEX</a></li>
92                                                                                                                 </ul>
93                                                                                                         </li>
94                                                                                                 </ul>
95                                                                                         </li>
96                                                                                         <li><a href="#metadata_block_picture">METADATA_BLOCK_PICTURE</a></li>
97                                                                                 </ul>
98                                                                         </li>
99                                                                 </ul>
100                                                         </li>
101                                                 </ul>
102                                         </li>
103                                         <li>
104                                                 <ul>
105                                                         <li><a href="#frame">FRAME</a>
106                                                                 <ul>
107                                                                         <li><a href="#frame_header">FRAME_HEADER</a></li>
108                                                                         <li><a href="#frame_footer">FRAME_FOOTER</a></li>
109                                                                         <li><a href="#subframe">SUBFRAME</a>
110                                                                                 <ul>
111                                                                                         <li><a href="#subframe_header">SUBFRAME_HEADER</a></li>
112                                                                                         <li><a href="#subframe_constant">SUBFRAME_CONSTANT</a></li>
113                                                                                         <li><a href="#subframe_fixed">SUBFRAME_FIXED</a></li>
114                                                                                         <li><a href="#subframe_lpc">SUBFRAME_LPC</a></li>
115                                                                                         <li><a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
116                                                                                                 <ul>
117                                                                                                         <li><a href="#residual">RESIDUAL</a>
118                                                                                                                 <ul>
119                                                                                                                         <li><a href="#partitioned_rice">RESIDUAL_CODING_METHOD_PARTITIONED_RICE</a>
120                                                                                                                                 <ul>
121                                                                                                                                         <li><a href="#rice_partition">RICE_PARTITION</a></li>
122                                                                                                                                 </ul>
123                                                                                                                         </li>
124                                                                                                                         <li><a href="#partitioned_rice2">RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</a>
125                                                                                                                                 <ul>
126                                                                                                                                         <li><a href="#rice2_partition">RICE2_PARTITION</a></li>
127                                                                                                                                 </ul>
128                                                                                                                         </li>
129                                                                                                                 </ul>
130                                                                                                         </li>
131                                                                                                 </ul>
132                                                                                         </li>
133                                                                                 </ul>
134                                                                         </li>
135                                                                 </ul>
136                                                         </li>
137                                                 </ul>
138                                         </li>
139                                 </ul>
140                         </li>
141                 </ul>
142                 <a name="acknowledgments"><font size="+1"><b><u>Acknowledgments</u></b></font></a><br />
143                 <br />
144                 FLAC owes much to the many people who have advanced the audio compression field so freely.  For instance:
145                 <ul>
146                         <li>
147                                 <a href="http://svr-www.eng.cam.ac.uk/~ajr/">A. J. Robinson</a> for his work on <a href="http://www-svr.eng.cam.ac.uk/reports/abstracts/robinson_tr156.html">Shorten</a>; his paper is a good starting point on some of the basic methods used by FLAC.  FLAC trivially extends and improves the fixed predictors, LPC coefficient quantization, and Rice coding used in Shorten.
148                         </li>
149                         <li>
150                                 <a href="http://commsci.usc.edu/faculty/golomb.html">S. W. Golomb</a> and Robert F. Rice; their universal codes are used by FLAC's entropy coder.
151                         </li>
152                         <li>
153                                 N. Levinson and J. Durbin; the reference encoder uses an algorithm developed and refined by them for determining the LPC coefficients from the autocorrelation coefficients.
154                         </li>
155                         <li>
156                                 And of course, <a href="http://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a>
157                         </li>
158                 </ul>
159                 <a name="scope"><font size="+1"><b><u>Scope</u></b></font></a><br />
160                 <br />
161                 It is a known fact that no algorithm can losslessly compress all possible input, so most compressors restrict themselves to a useful domain and try to work as well as possible within that domain.  FLAC's domain is audio data.  Though it can losslessly <b>code</b> any input, only certain kinds of input will get smaller.  FLAC exploits the fact that audio data typically has a high degree of sample-to-sample correlation.<br />
162                 <br />
163                 Within the audio domain, there are many possible subdomains.  For example: low bitrate speech, high-bitrate multi-channel music, etc.  FLAC itself does not target a specific subdomain but many of the default parameters of the reference encoder are tuned to CD-quality music data (i.e. 44.1kHz, 2 channel, 16 bits per sample).  The effect of the encoding parameters on different kinds of audio data will be examined later.<br />
164                 <br />
165                 <a name="architecture"><font size="+1"><b><u>Architecture</u></b></font></a><br />
166                 <br />
167                 Similar to many audio coders, a FLAC encoder has the following stages:
168                 <ul>
169                         <li>
170                                 <a href="#blocking">Blocking</a>.  The input is broken up into many contiguous blocks.  With FLAC, the blocks may vary in size.  The optimal size of the block is usually affected by many factors, including the sample rate, spectral characteristics over time, etc.  Though FLAC allows the block size to vary within a stream, the reference encoder uses a fixed block size.
171                         </li>
172                         <li>
173                                 <a href="#interchannel">Interchannel Decorrelation</a>.  In the case of stereo streams, the encoder will create mid and side signals based on the average and difference (respectively) of the left and right channels.  The encoder will then pass the best form of the signal to the next stage.
174                         </li>
175                         <li>
176                                 <a href="#prediction">Prediction</a>.  The block is passed through a prediction stage where the encoder tries to find a mathematical description (usually an approximate one) of the signal.  This description is typically much smaller than the raw signal itself.  Since the methods of prediction are known to both the encoder and decoder, only the parameters of the predictor need be included in the compressed stream.  FLAC currently uses four different classes of predictors (described in the <a href="#prediction">prediction</a> section), but the format has reserved space for additional methods.  FLAC allows the class of predictor to change from block to block, or even within the channels of a block.
177                         </li>
178                         <li>
179                                 <a href="#residualcoding">Residual coding</a>.  If the predictor does not describe the signal exactly, the difference between the original signal and the predicted signal (called the error or residual signal) must be coded losslessy.  If the predictor is effective, the residual signal will require fewer bits per sample than the original signal.  FLAC currently uses only one method for encoding the residual (see the <a href="#residualcoding">Residual coding</a> section), but the format has reserved space for additional methods.  FLAC allows the residual coding method to change from block to block, or even within the channels of a block.
180                         </li>
181                 </ul>
182                 In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.<br />
183                 <br />
184                 <a name="definitions"><font size="+1"><b><u>Definitions</u></b></font></a><br />
185                 <br />
186                 Many terms like "block" and "frame" are used to mean different things in differenct encoding schemes.  For example, a frame in MP3 corresponds to many samples across several channels, whereas an S/PDIF frame represents just one sample for each channel.  The definitions we use for FLAC follow.  Note that when we talk about blocks and subblocks we are referring to the raw unencoded audio data that is the input to the encoder, and when we talk about frames and subframes, we are referring to the FLAC-encoded data.
187                 <ul>
188                         <li>
189                                 <b>Block</b>: One or more audio samples that span several channels.
190                         </li>
191                         <li>
192                                 <b>Subblock</b>: One or more audio samples within a channel.  So a block contains one subblock for each channel, and all subblocks contain the same number of samples.
193                         </li>
194                         <li>
195                                 <b>Blocksize</b>: The number of samples in any of a block's subblocks.  For example, a one second block sampled at 44.1KHz has a blocksize of 44100, regardless of the number of channels.
196                         </li>
197                         <li>
198                                 <b>Frame</b>: A frame header plus one or more subframes.
199                         </li>
200                         <li>
201                                 <b>Subframe</b>: A subframe header plus one or more encoded samples from a given channel.  All subframes within a frame will contain the same number of samples.
202                         </li>
203                 </ul>
204                 <a name="blocking"><font size="+1"><b><u>Blocking</u></b></font></a><br />
205                 <br />
206                 The size used for blocking the audio data has a direct effect on the compression ratio.  If the block size is too small, the resulting large number of frames mean that excess bits will be wasted on frame headers.  If the block size is too large, the characteristics of the signal may vary so much that the encoder will be unable to find a good predictor.  In order to simplify encoder/decoder design, FLAC imposes a minimum block size of 16 samples, and a maximum block size of 65535 samples.  This range covers the optimal size for all of the audio data FLAC supports.<br />
207                 <br />
208                 Currently the reference encoder uses a fixed block size, optimized on the sample rate of the input.  Future versions may vary the block size depending on the characteristics of the signal.<br />
209                 <br />
210                 Blocked data is passed to the predictor stage one subblock (channel) at a time.  Each subblock is independently coded into a subframe, and the subframes are concatenated into a frame.  Because each channel is coded separately, it means that one channel of a stereo frame may be encoded as a constant subframe, and the other an LPC subframe.<br />
211                 <br />
212                 <a name="interchannel"><font size="+1"><b><u>Interchannel Decorrelation</u></b></font></a><br />
213                 <br />
214                 In stereo streams, many times there is an exploitable amount of correlation between the left and right channels.  FLAC allows the frames of stereo streams to have different channel assignments, and an encoder may choose to use the best representation on a frame-by-frame basis.
215                 <ul>
216                         <li>
217                                 <b>Independent</b>.  The left and right channels are coded independently.
218                         </li>
219                         <li>
220                                 <b>Mid-side</b>.  The left and right channels are transformed into mid and side channels.  The mid channel is the midpoint (average) of the left and right signals, and the side is the difference signal (left minus right).
221                         </li>
222                         <li>
223                                 <b>Left-side</b>.  The left channel and side channel are coded.
224                         </li>
225                         <li>
226                                 <b>Right-side</b>.  The right channel and side channel are coded
227                         </li>
228                 </ul>
229                 Surprisingly, the left-side and right-side forms can be the most efficient in many frames, even though the raw number of bits per sample needed for the original signal is slightly more than that needed for independent or mid-side coding.<br />
230                 <br />
231                 <a name="prediction"><font size="+1"><b><u>Prediction</u></b></font></a><br />
232                 <br />
233                 FLAC uses four methods for modeling the input signal:
234                 <ul>
235                         <li>
236                                 <b>Verbatim</b>.  This is essentially a zero-order predictor of the signal.  The predicted signal is zero, meaning the residual is the signal itself, and the compression is zero.  This is the baseline against which the other predictors are measured.  If you feed random data to the encoder, the verbatim predictor will probably be used for every subblock.  Since the raw signal is not actually passed through the residual coding stage (it is added to the stream 'verbatim'), the encoding results will not be the same as a zero-order linear predictor.
237                         </li>
238                         <li>
239                                 <b>Constant</b>.  This predictor is used whenever the subblock is pure DC ("digital silence"), i.e. a constant value throughout.  The signal is run-length encoded and added to the stream.
240                         </li>
241                         <li>
242                                 <b>Fixed linear predictor</b>.  FLAC uses a class of computationally-efficient fixed linear predictors (for a good description, see <a href="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</a> and <a href="http://svr-www.eng.cam.ac.uk/~ajr/GroupPubs/Robinson94-tr156/index.html">shorten</a>).  FLAC adds a fourth-order predictor to the zero-to-third-order predictors used by Shorten.  Since the predictors are fixed, the predictor order is the only parameter that needs to be stored in the compressed stream.  The error signal is then passed to the residual coder.
243                         </li>
244                         <li>
245                                 <b>FIR Linear prediction</b>.  For more accurate modeling (at a cost of slower encoding), FLAC supports up to 32nd order FIR linear prediction (again, for information on linear prediction, see <a href="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</a> and <a href="http://svr-www.eng.cam.ac.uk/~ajr/GroupPubs/Robinson94-tr156/index.html">shorten</a>).  The reference encoder uses the Levinson-Durbin method for calculating the LPC coefficients from the autocorrelation coefficients, and the coefficients are quantized before computing the residual.  Whereas encoders such as Shorten used a fixed quantization for the entire input, FLAC allows the quantized coefficient precision to vary from subframe to subframe.  The FLAC reference encoder estimates the optimal precision to use based on the block size and dynamic range of the original signal.
246                         </li>
247                 </ul>
248                 <a name="residualcoding"><font size="+1"><b><u>Residual Coding</u></b></font></a><br />
249                 <br />
250                 FLAC currently defines two similar methods for the coding of the error signal from the prediction stage.  The error signal is coded using Rice codes in one of two ways: 1) the encoder estimates a single Rice parameter based on the variance of the residual and Rice codes the entire residual using this parameter; 2) the residual is partitioned into several equal-length regions of contiguous samples, and each region is coded with its own Rice parameter based on the region's mean.  (Note that the first method is a special case of the second method with one partition, except the Rice parameter is based on the residual variance instead of the mean.)<br />
251                 <br />
252                 The FLAC format has reserved space for other coding methods.  Some possiblities for volunteers would be to explore better context-modeling of the Rice parameter, or Huffman coding.  See <a href="http://www.hpl.hp.com/techreports/98/HPL-98-193.html">LOCO-I</a> and <a href="http://www.cs.tut.fi/~albert/Dev/pucrunch/packing.html">pucrunch</a> for descriptions of several universal codes.<br />
253                 <br />
254                 <a name="format_overview"><font size="+1"><b><u>Format</u></b></font></a><br />
255                 <br />
256                 This section specifies the FLAC bitstream format.  FLAC has no format version information, but it does contain reserved space in several places.  Future versions of the format may use this reserved space safely without breaking the format of older streams.  Older decoders may choose to abort decoding or skip data encoded with newer methods.  Apart from reserved patterns, in places the format specifies invalid patterns, meaning that the patterns may never appear in any valid bitstream, in any prior, present, or future versions of the format.  These invalid patterns are usually used to make the synchronization mechanism more robust.<br />
257                 <br />
258                 All numbers used in a FLAC bitstream are integers; there are no floating-point representations.  All numbers are big-endian coded.  All numbers are unsigned unless otherwise specified.<br />
259                 <br />
260                 Before the formal description of the stream, an overview might be helpful.
261                 <ul>
262                         <li>
263                                 A FLAC bitstream consists of the "fLaC" marker at the beginning of the stream, followed by a mandatory metadata block (called the STREAMINFO block), any number of other metadata blocks, then the audio frames.
264                         </li>
265                         <li>
266                                 FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
267                                 <ul>
268                                         <li><a name="def_STREAMINFO"><b>STREAMINFO</b></a>: This block has information about the whole stream, like sample rate, number of channels, total number of samples, etc.  It must be present as the first metadata block in the stream.  Other metadata blocks may follow, and ones that the decoder doesn't understand, it will skip.</li>
269                                         <li><a name="def_APPLICATION"><b>APPLICATION</b></a>: This block is for use by third-party applications.  The only mandatory field is a 32-bit identifier.  This ID is granted upon request to an application by the FLAC maintainers.  The remainder is of the block is defined by the registered application.  Visit the <a href="id.html">registration page</a> if you would like to register an ID for your application with FLAC.</li>
270                                         <li><a name="def_PADDING"><b>PADDING</b></a>: This block allows for an arbitrary amount of padding.  The contents of a PADDING block have no meaning.  This block is useful when it is known that metadata will be edited after encoding; the user can instruct the encoder to reserve a PADDING block of sufficient size so that when metadata is added, it will simply overwrite the padding (which is relatively quick) instead of having to insert it into the right place in the existing file (which would normally require rewriting the entire file).</li>
271                                         <li><a name="def_SEEKTABLE"><b>SEEKTABLE</b></a>: This is an optional block for storing seek points.  It is possible to seek to any given sample in a FLAC stream without a seek table, but the delay can be unpredictable since the bitrate may vary widely within a stream.  By adding seek points to a stream, this delay can be significantly reduced.  Each seek point takes 18 bytes, so 1% resolution within a stream adds less than 2k.  There can be only one SEEKTABLE in a stream, but the table can have any number of seek points.  There is also a special 'placeholder' seekpoint which will be ignored by decoders but which can be used to reserve space for future seek point insertion.</li>
272                                         <li><a name="def_VORBIS_COMMENT"><b>VORBIS_COMMENT</b></a>: This block is for storing a list of human-readable name/value pairs.  Values are encoded using UTF-8.  It is an implementation of the <a href="http://xiph.org/vorbis/doc/v-comment.html">Vorbis comment specification</a> (without the framing bit).  This is the only officially supported tagging mechanism in FLAC.  There may be only one VORBIS_COMMENT block in a stream.  In some external documentation, Vorbis comments are called FLAC tags to lessen confusion.</li>
273                                         <li><a name="def_CUESHEET"><b>CUESHEET</b></a>: This block is for storing various information that can be used in a cue sheet.  It supports track and index points, compatible with Red Book CD digital audio discs, as well as other CD-DA metadata such as media catalog number and track ISRCs.  The CUESHEET block is especially useful for backing up CD-DA discs, but it can be used as a general purpose cueing mechanism for playback.</li>
274                                         <li><a name="def_PICTURE"><b>PICTURE</b></a>: This block is for storing pictures associated with the file, most commonly cover art from CDs.  There may be more than one PICTURE block in a file.  The picture format is similar to the <a href="http://www.id3.org/id3v2.4.0-frames.txt">APIC frame in ID3v2</a>.  The PICTURE block has a type, MIME type, and UTF-8 description like ID3v2, and supports external linking via URL (though this is discouraged).  The differences are that there is no uniqueness constraint on the description field, and the MIME type is mandatory.  The FLAC PICTURE block also includes the resolution, color depth, and palette size so that the client can search for a suitable picture without having to scan them all.</li>
275                                 </ul>
276                         </li>
277                         <li>
278                                 The audio data is composed of one or more audio frames.  Each frame consists of a frame header, which contains a sync code, information about the frame like the block size, sample rate, number of channels, et cetera, and an 8-bit CRC.  The frame header also contains either the sample number of the first sample in the frame (for variable-blocksize streams), or the frame number (for fixed-blocksize streams).  This allows for fast, sample-accurate seeking to be performed.  Following the frame header are encoded subframes, one for each channel, and finally, the frame is zero-padded to a byte boundary.  Each subframe has its own header that specifies how the subframe is encoded.
279                         </li>
280                         <li>
281                                 Since a decoder may start decoding in the middle of a stream, there must be a method to determine the start of a frame.  A 14-bit sync code begins each frame.  The sync code will not appear anywhere else in the frame header.  However, since it may appear in the subframes, the decoder has two other ways of ensuring a correct sync.  The first is to check that the rest of the frame header contains no invalid data.  Even this is not foolproof since valid header patterns can still occur within the subframes.  The decoder's final check is to generate an 8-bit CRC of the frame header and compare this to the CRC stored at the end of the frame header.
282                         </li>
283                         <li>
284                                 Again, since a decoder may start decoding at an arbitrary frame in the stream, each frame header must contain some basic information about the stream because the decoder may not have access to the STREAMINFO metadata block at the start of the stream.  This information includes sample rate, bits per sample, number of channels, etc.  Since the frame header is pure overhead, it has a direct effect on the compression ratio.  To keep the frame header as small as possible, FLAC uses lookup tables for the most commonly used values for frame parameters.  For instance, the sample rate part of the frame header is specified using 4 bits.  Eight of the bit patterns correspond to the commonly used sample rates of 8/16/22.05/24/32/44.1/48/96 kHz.  However, odd sample rates can be specified by using one of the 'hint' bit patterns, directing the decoder to find the exact sample rate at the end of the frame header.  The same method is used for specifying the block size and bits per sample.  In this way, the frame header size stays small for all of the most common forms of audio data.
285                         </li>
286                         <li>
287                                 Individual subframes (one for each channel) are coded separately within a frame, and appear serially in the stream.  In other words, the encoded audio data is NOT channel-interleaved.  This reduces decoder complexity at the cost of requiring larger decode buffers.  Each subframe has its own header specifying the attributes of the subframe, like prediction method and order, residual coding parameters, etc.  The header is followed by the encoded audio data for that channel.
288                         </li>
289                         <li>
290                                 <a name="subset">FLAC</a> specifies a subset of itself as the Subset format.  The purpose of this is to ensure that any streams encoded according to the Subset are truly "streamable", meaning that a decoder that cannot seek within the stream can still pick up in the middle of the stream and start decoding.  It also makes hardware decoder implementations more practical by limiting the encoding parameters such that decoder buffer sizes and other resource requirements can be easily determined.  <span class="commandname">flac</span> generates Subset streams by default unless the "--lax" command-line option is used.  The Subset makes the following limitations on what may be used in the stream:
291                                 <ul>
292                                 <li>
293                                         The blocksize bits in the <a href="#frame_header">frame header</a> must be 0001-1110.  The blocksize must be &lt;=16384; if the sample rate is &lt;= 48000Hz, the blocksize must be &lt;=4608.
294                                 </li>
295                                 <li>
296                                         The sample rate bits in the <a href="#frame_header">frame header</a> must be 0001-1110.
297                                 </li>
298                                 <li>
299                                         The bits-per-sample bits in the <a href="#frame_header">frame header</a> must be 001-111.
300                                 </li>
301                                 <li>
302                                         If the sample rate is &lt;= 48000Hz, the filter order in <a href="#subframe_lpc">LPC subframes</a> must be less than or equal to 12, i.e. the subframe type bits in the <a href="#subframe_header">subframe header</a> may not be 101100-111111.
303                                 </li>
304                                 <li>
305                                         The Rice partition order in a <a href="#partitioned_rice">Rice-coded residual section</a> must be less than or equal to 8.
306                                 </li>
307                                 </ul>
308                         </li>
309                 </ul>
310
311                 The following tables constitute a formal description of the FLAC format.  Numbers in angle brackets indicate how many bits are used for a given field.<br />
312         </div>
313         <div class="box_footer"></div>
314 </div>
315
316 <br />
317
318 <div class="box">
319         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
320         <table width="100%" border="1" bgcolor="#EEEED4">
321                 <tr>
322                         <td colspan="2" bgcolor="#D3D4C5">
323                                 <a name="stream"><font size="+1"><b>STREAM</b></font></a>
324                         </td>
325                 </tr>
326                 <tr>
327                         <td align="right" valign="top" bgcolor="#F4F4CC">
328                                 &lt;32&gt;
329                         </td>
330                         <td>
331                                 "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
332                         </td>
333                 </tr>
334                 <tr>
335                         <td align="right" valign="top" bgcolor="#F4F4CC">
336                                 <a href="#metadata_block_streaminfo"><i>METADATA_BLOCK</i></a>
337                         </td>
338                         <td>
339                                 This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
340                         </td>
341                 </tr>
342                 <tr>
343                         <td align="right" valign="top" bgcolor="#F4F4CC">
344                                 <a href="#metadata_block"><i>METADATA_BLOCK</i></a>*
345                         </td>
346                         <td>
347                                 Zero or more metadata blocks
348                         </td>
349                 </tr>
350                 <tr>
351                         <td align="right" valign="top" bgcolor="#F4F4CC">
352                                 <a href="#frame"><i>FRAME</i></a>+
353                         </td>
354                         <td>
355                                 One or more audio frames
356                         </td>
357                 </tr>
358         </table>
359         </td></tr></table>
360 </div>
361
362 <br />
363
364 <div class="box">
365         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
366         <table width="100%" border="1" bgcolor="#EEEED4">
367                 <tr>
368                         <td colspan="2" bgcolor="#D3D4C5">
369                                 <a name="metadata_block"><font size="+1"><b>METADATA_BLOCK</b></font></a>
370                         </td>
371                 </tr>
372                 <tr>
373                         <td align="right" valign="top" bgcolor="#F4F4CC">
374                                 <a href="#metadata_block_header"><i>METADATA_BLOCK_HEADER</i></a>
375                         </td>
376                         <td>
377                                 A block header that specifies the type and size of the metadata block data.
378                         </td>
379                 </tr>
380                 <tr>
381                         <td align="right" valign="top" bgcolor="#F4F4CC">
382                                 <a href="#metadata_block_data"><i>METADATA_BLOCK_DATA</i></a>
383                         </td>
384                         <td>
385                                 &nbsp;
386                         </td>
387                 </tr>
388         </table>
389         </td></tr></table>
390 </div>
391
392 <br />
393
394 <div class="box">
395         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
396         <table width="100%" border="1" bgcolor="#EEEED4">
397                 <tr>
398                         <td colspan="2" bgcolor="#D3D4C5">
399                                 <a name="metadata_block_header"><font size="+1"><b>METADATA_BLOCK_HEADER</b></font></a>
400                         </td>
401                 </tr>
402                 <tr>
403                         <td align="right" valign="top" bgcolor="#F4F4CC">
404                                 &lt;1&gt;
405                         </td>
406                         <td>
407                                 Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
408                         </td>
409                 </tr>
410                 <tr>
411                         <td align="right" valign="top" bgcolor="#F4F4CC">
412                                 &lt;7&gt;
413                         </td>
414                         <td>
415                                 BLOCK_TYPE<br />
416                                 <ul>
417                                 <li>
418                                         <tt>0</tt> : STREAMINFO
419                                 </li>
420                                 <li>
421                                         <tt>1</tt> : PADDING
422                                 </li>
423                                 <li>
424                                         <tt>2</tt> : APPLICATION
425                                 </li>
426                                 <li>
427                                         <tt>3</tt> : SEEKTABLE
428                                 </li>
429                                 <li>
430                                         <tt>4</tt> : VORBIS_COMMENT
431                                 </li>
432                                 <li>
433                                         <tt>5</tt> : CUESHEET
434                                 </li>
435                                 <li>
436                                         <tt>6</tt> : PICTURE
437                                 </li>
438                                 <li>
439                                         <tt>7-126</tt> : reserved
440                                 </li>
441                                 <li>
442                                         <tt>127</tt> : invalid, to avoid confusion with a frame sync code
443                                 </li>
444                                 </ul>
445                         </td>
446                 </tr>
447                 <tr>
448                         <td align="right" valign="top" bgcolor="#F4F4CC">
449                                 &lt;24&gt;
450                         </td>
451                         <td>
452                                 Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
453                         </td>
454                 </tr>
455         </table>
456         </td></tr></table>
457 </div>
458
459 <br />
460
461 <div class="box">
462         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
463         <table width="100%" border="1" bgcolor="#EEEED4">
464                 <tr>
465                         <td colspan="2" bgcolor="#D3D4C5">
466                                 <a name="metadata_block_data"><font size="+1"><b>METADATA_BLOCK_DATA</b></font></a>
467                         </td>
468                 </tr>
469                 <tr>
470                         <td align="right" valign="top" bgcolor="#F4F4CC">
471                                 <a href="#metadata_block_streaminfo"><i>METADATA_BLOCK_STREAMINFO</i></a><br />
472                                 || <a href="#metadata_block_padding"><i>METADATA_BLOCK_PADDING</i></a><br />
473                                 || <a href="#metadata_block_application"><i>METADATA_BLOCK_APPLICATION</i></a><br />
474                                 || <a href="#metadata_block_seektable"><i>METADATA_BLOCK_SEEKTABLE</i></a><br />
475                                 || <a href="#metadata_block_vorbis_comment"><i>METADATA_BLOCK_VORBIS_COMMENT</i></a><br />
476                                 || <a href="#metadata_block_cuesheet"><i>METADATA_BLOCK_CUESHEET</i></a><br />
477                                 || <a href="#metadata_block_picture"><i>METADATA_BLOCK_PICTURE</i></a>
478                         </td>
479                         <td>
480                                 The block data must match the block type in the block header.
481                         </td>
482                 </tr>
483         </table>
484         </td></tr></table>
485 </div>
486
487 <br />
488
489 <div class="box">
490         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
491         <table width="100%" border="1">
492                 <tr>
493                         <td colspan="2" bgcolor="#D3D4C5">
494                                 <a name="metadata_block_streaminfo"><font size="+1"><b>METADATA_BLOCK_STREAMINFO</b></font></a>
495                         </td>
496                 </tr>
497                 <tr>
498                         <td align="right" valign="top" bgcolor="#F4F4CC">
499                                 &lt;16&gt;
500                         </td>
501                         <td>
502                                 The minimum block size (in samples) used in the stream.
503                         </td>
504                 </tr>
505                 <tr>
506                         <td align="right" valign="top" bgcolor="#F4F4CC">
507                                 &lt;16&gt;
508                         </td>
509                         <td>
510                                 The maximum block size (in samples) used in the stream.  (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
511                         </td>
512                 </tr>
513                 <tr>
514                         <td align="right" valign="top" bgcolor="#F4F4CC">
515                                 &lt;24&gt;
516                         </td>
517                         <td>
518                                 The minimum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
519                         </td>
520                 </tr>
521                 <tr>
522                         <td align="right" valign="top" bgcolor="#F4F4CC">
523                                 &lt;24&gt;
524                         </td>
525                         <td>
526                                 The maximum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
527                         </td>
528                 </tr>
529                 <tr>
530                         <td align="right" valign="top" bgcolor="#F4F4CC">
531                                 &lt;20&gt;
532                         </td>
533                         <td>
534                                 Sample rate in Hz.  Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350Hz.  Also, a value of 0 is invalid.
535                         </td>
536                 </tr>
537                 <tr>
538                         <td align="right" valign="top" bgcolor="#F4F4CC">
539                                 &lt;3&gt;
540                         </td>
541                         <td>
542                                 (number of channels)-1.  FLAC supports from 1 to 8 channels
543                         </td>
544                 </tr>
545                 <tr>
546                         <td align="right" valign="top" bgcolor="#F4F4CC">
547                                 &lt;5&gt;
548                         </td>
549                         <td>
550                                 (bits per sample)-1.  FLAC supports from 4 to 32 bits per sample.  Currently the reference encoder and decoders only support up to 24 bits per sample.
551                         </td>
552                 </tr>
553                 <tr>
554                         <td align="right" valign="top" bgcolor="#F4F4CC">
555                                 &lt;36&gt;
556                         </td>
557                         <td>
558                                 Total samples in stream.  'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels.  A value of zero here means the number of total samples is unknown.
559                         </td>
560                 </tr>
561                 <tr>
562                         <td align="right" valign="top" bgcolor="#F4F4CC">
563                                 &lt;128&gt;
564                         </td>
565                         <td>
566                                 MD5 signature of the unencoded audio data.  This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream.
567                         </td>
568                 </tr>
569                 <tr>
570                         <td>
571                         </td>
572                         <td bgcolor="#F4F4CC">
573                                 <font size="+1">NOTES</font><br />
574                                 <ul>
575                                 <li>
576                                         FLAC specifies a minimum block size of 16 and a maximum block size of 65535, meaning the bit patterns corresponding to the numbers 0-15 in the minimum blocksize and maximum blocksize fields are invalid.
577                                 </li>
578                                 </ul>
579                         </td>
580                 </tr>
581         </table>
582         </td></tr></table>
583 </div>
584
585 <br />
586
587 <div class="box">
588         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
589         <table width="100%" border="1">
590                 <tr>
591                         <td colspan="2" bgcolor="#D3D4C5">
592                                 <a name="metadata_block_padding"><font size="+1"><b>METADATA_BLOCK_PADDING</b></font></a>
593                         </td>
594                 </tr>
595                 <tr>
596                         <td align="right" valign="top" bgcolor="#F4F4CC">
597                                 &lt;n&gt;
598                         </td>
599                         <td>
600                                 n '0' bits (n must be a multiple of 8)
601                         </td>
602                 </tr>
603         </table>
604         </td></tr></table>
605 </div>
606
607 <br />
608
609 <div class="box">
610         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
611         <table width="100%" border="1">
612                 <tr>
613                         <td colspan="2" bgcolor="#D3D4C5">
614                                 <a name="metadata_block_application"><font size="+1"><b>METADATA_BLOCK_APPLICATION</b></font></a>
615                         </td>
616                 </tr>
617                 <tr>
618                         <td align="right" valign="top" bgcolor="#F4F4CC">
619                                 &lt;32&gt;
620                         </td>
621                         <td>
622                                 Registered application ID.  (Visit the <a href="id.html">registration page</a> to register an ID with FLAC.)
623                         </td>
624                 </tr>
625                 <tr>
626                         <td align="right" valign="top" bgcolor="#F4F4CC">
627                                 &lt;n&gt;
628                         </td>
629                         <td>
630                                 Application data (n must be a multiple of 8)
631                         </td>
632                 </tr>
633         </table>
634         </td></tr></table>
635 </div>
636
637 <br />
638
639 <div class="box">
640         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
641         <table width="100%" border="1">
642                 <tr>
643                         <td colspan="2" bgcolor="#D3D4C5">
644                                 <a name="metadata_block_seektable"><font size="+1"><b>METADATA_BLOCK_SEEKTABLE</b></font></a>
645                         </td>
646                 </tr>
647                 <tr>
648                         <td align="right" valign="top" bgcolor="#F4F4CC">
649                                 <a href="#seekpoint"><i>SEEKPOINT</i></a>+
650                         </td>
651                         <td>
652                                 One or more seek points.
653                         </td>
654                 </tr>
655                 <tr>
656                         <td>
657                         </td>
658                         <td bgcolor="#F4F4CC">
659                                 <font size="+1">NOTE</font><br />
660                                 <ul>
661                                 <li>
662                                         The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
663                                 </li>
664                                 </ul>
665                         </td>
666                 </tr>
667         </table>
668         </td></tr></table>
669 </div>
670
671 <br />
672
673 <div class="box">
674         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
675         <table width="100%" border="1">
676                 <tr>
677                         <td colspan="2" bgcolor="#D3D4C5">
678                                 <a name="seekpoint"><font size="+1"><b>SEEKPOINT</b></font></a>
679                         </td>
680                 </tr>
681                 <tr>
682                         <td align="right" valign="top" bgcolor="#F4F4CC">
683                                 &lt;64&gt;
684                         </td>
685                         <td>
686                                 Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
687                         </td>
688                 </tr>
689                 <tr>
690                         <td align="right" valign="top" bgcolor="#F4F4CC">
691                                 &lt;64&gt;
692                         </td>
693                         <td>
694                                 Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
695                         </td>
696                 </tr>
697                 <tr>
698                         <td align="right" valign="top" bgcolor="#F4F4CC">
699                                 &lt;16&gt;
700                         </td>
701                         <td>
702                                 Number of samples in the target frame.
703                         </td>
704                 </tr>
705                 <tr>
706                         <td>
707                         </td>
708                         <td bgcolor="#F4F4CC">
709                                 <font size="+1">NOTES</font><br />
710                                 <ul>
711                                 <li>
712                                         For placeholder points, the second and third field values are undefined.
713                                 </li>
714                                 <li>
715                                         Seek points within a table must be sorted in ascending order by sample number.
716                                 </li>
717                                 <li>
718                                         Seek points within a table must be unique by sample number, with the exception of placeholder points.
719                                 </li>
720                                 <li>
721                                         The previous two notes imply that there may be any number of placeholder points, but they must all occur at the end of the table.
722                                 </li>
723                                 </ul>
724                         </td>
725                 </tr>
726         </table>
727         </td></tr></table>
728 </div>
729
730 <br />
731
732 <div class="box">
733         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
734         <table width="100%" border="1">
735                 <tr>
736                         <td colspan="2" bgcolor="#D3D4C5">
737                                 <a name="metadata_block_vorbis_comment"><font size="+1"><b>METADATA_BLOCK_VORBIS_COMMENT</b></font></a>
738                         </td>
739                 </tr>
740                 <tr>
741                         <td align="right" valign="top" bgcolor="#F4F4CC">
742                                 &lt;n&gt;
743                         </td>
744                         <td>
745                                 Also known as FLAC tags, the contents of a vorbis comment packet as specified <a href="http://www.xiph.org/vorbis/doc/v-comment.html">here</a> (without the framing bit).  Note that the vorbis comment spec allows for on the order of 2 ^ 64 bytes of data where as the FLAC metadata block is limited to 2 ^ 24 bytes.  Given the stated purpose of vorbis comments, i.e. human-readable textual information, this limit is unlikely to be restrictive.  Also note that the 32-bit field lengths are little-endian coded according to the vorbis spec, as opposed to the usual big-endian coding of fixed-length integers in the rest of FLAC.
746                         </td>
747                 </tr>
748         </table>
749         </td></tr></table>
750 </div>
751
752 <br />
753
754 <div class="box">
755         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
756         <table width="100%" border="1">
757                 <tr>
758                         <td colspan="2" bgcolor="#D3D4C5">
759                                 <a name="metadata_block_cuesheet"><font size="+1"><b>METADATA_BLOCK_CUESHEET</b></font></a>
760                         </td>
761                 </tr>
762                 <tr>
763                         <td align="right" valign="top" bgcolor="#F4F4CC">
764                                 &lt;128*8&gt;
765                         </td>
766                         <td>
767                                 Media catalog number, in ASCII printable characters 0x20-0x7e.  In general, the media catalog number may be 0 to 128 bytes long; any unused characters should be right-padded with NUL characters.  For CD-DA, this is a thirteen digit number, followed by 115 NUL bytes.
768                         </td>
769                 </tr>
770                 <tr>
771                         <td align="right" valign="top" bgcolor="#F4F4CC">
772                                 &lt;64&gt;
773                         </td>
774                         <td>
775                                 The number of lead-in samples.  This field has meaning only for CD-DA cuesheets; for other uses it should be 0.  For CD-DA, the lead-in is the TRACK 00 area where the table of contents is stored; more precisely, it is the number of samples from the first sample of the media to the first sample of the first index point of the first track.  According to the Red Book, the lead-in must be silence and CD grabbing software does not usually store it; additionally, the lead-in must be at least two seconds but may be longer.  For these reasons the lead-in length is stored here so that the absolute position of the first track can be computed.  Note that the lead-in stored here is the number of samples up to the first index point of the first track, not necessarily to INDEX 01 of the first track; even the first track may have INDEX 00 data.
776                         </td>
777                 </tr>
778                 <tr>
779                         <td align="right" valign="top" bgcolor="#F4F4CC">
780                                 &lt;1&gt;
781                         </td>
782                         <td>
783                                 <tt>1</tt> if the CUESHEET corresponds to a Compact Disc, else <tt>0</tt>.
784                         </td>
785                 </tr>
786                 <tr>
787                         <td align="right" valign="top" bgcolor="#F4F4CC">
788                                 &lt;7+258*8&gt;
789                         </td>
790                         <td>
791                                 Reserved.  All bits must be set to zero.
792                         </td>
793                 </tr>
794                 <tr>
795                         <td align="right" valign="top" bgcolor="#F4F4CC">
796                                 &lt;8&gt;
797                         </td>
798                         <td>
799                                 The number of tracks.  Must be at least 1 (because of the requisite lead-out track).  For CD-DA, this number must be no more than 100 (99 regular tracks and one lead-out track).
800                         </td>
801                 </tr>
802                 <tr>
803                         <td align="right" valign="top" bgcolor="#F4F4CC">
804                                 <a href="#cuesheet_track"><i>CUESHEET_TRACK</i></a>+
805                         </td>
806                         <td>
807                                 One or more tracks.  A CUESHEET block is required to have a lead-out track; it is always the last track in the CUESHEET.  For CD-DA, the lead-out track number must be 170 as specified by the Red Book, otherwise is must be 255.
808                         </td>
809                 </tr>
810         </table>
811         </td></tr></table>
812 </div>
813
814 <br />
815
816 <div class="box">
817         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
818         <table width="100%" border="1">
819                 <tr>
820                         <td colspan="2" bgcolor="#D3D4C5">
821                                 <a name="cuesheet_track"><font size="+1"><b>CUESHEET_TRACK</b></font></a>
822                         </td>
823                 </tr>
824                 <tr>
825                         <td align="right" valign="top" bgcolor="#F4F4CC">
826                                 &lt;64&gt;
827                         </td>
828                         <td>
829                                 Track offset in samples, relative to the beginning of the FLAC audio stream.  It is the offset to the first index point of the track.  (Note how this differs from CD-DA, where the track's offset in the TOC is that of the track's INDEX 01 even if there is an INDEX 00.)  For CD-DA, the offset must be evenly divisible by 588 samples (588 samples = 44100 samples/sec * 1/75th of a sec).
830                         </td>
831                 </tr>
832                 <tr>
833                         <td align="right" valign="top" bgcolor="#F4F4CC">
834                                 &lt;8&gt;
835                         </td>
836                         <td>
837                                 Track number.  A track number of 0 is not allowed to avoid conflicting with the CD-DA spec, which reserves this for the lead-in.  For CD-DA the number must be 1-99, or 170 for the lead-out; for non-CD-DA, the track number must for 255 for the lead-out.  It is not required but encouraged to start with track 1 and increase sequentially.  Track numbers must be unique within a CUESHEET.
838                         </td>
839                 </tr>
840                 <tr>
841                         <td align="right" valign="top" bgcolor="#F4F4CC">
842                                 &lt;12*8&gt;
843                         </td>
844                         <td>
845                                 Track ISRC.  This is a 12-digit alphanumeric code; see <a href="http://www.ifpi.org/isrc/isrc_handbook.html">here</a> and <a href="http://www.disctronics.co.uk/technology/cdaudio/cdaud_isrc.htm">here</a>.  A value of 12 ASCII NUL characters may be used to denote absence of an ISRC.
846                         </td>
847                 </tr>
848                 <tr>
849                         <td align="right" valign="top" bgcolor="#F4F4CC">
850                                 &lt;1&gt;
851                         </td>
852                         <td>
853                                 The track type: 0 for audio, 1 for non-audio.  This corresponds to the CD-DA Q-channel control bit 3.
854                         </td>
855                 </tr>
856                 <tr>
857                         <td align="right" valign="top" bgcolor="#F4F4CC">
858                                 &lt;1&gt;
859                         </td>
860                         <td>
861                                 The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis.  This corresponds to the CD-DA Q-channel control bit 5; see <a href="http://www.chipchapin.com/CDMedia/cdda9.php3">here</a>.
862                         </td>
863                 </tr>
864                 <tr>
865                         <td align="right" valign="top" bgcolor="#F4F4CC">
866                                 &lt;6+13*8&gt;
867                         </td>
868                         <td>
869                                 Reserved.  All bits must be set to zero.
870                         </td>
871                 </tr>
872                 <tr>
873                         <td align="right" valign="top" bgcolor="#F4F4CC">
874                                 &lt;8&gt;
875                         </td>
876                         <td>
877                                 The number of track index points.  There must be at least one index in every track in a CUESHEET except for the lead-out track, which must have zero.  For CD-DA, this number may be no more than 100.
878                         </td>
879                 </tr>
880                 <tr>
881                         <td align="right" valign="top" bgcolor="#F4F4CC">
882                                 <a href="#cuesheet_track_index"><i>CUESHEET_TRACK_INDEX</i></a>+
883                         </td>
884                         <td>
885                                 For all tracks except the lead-out track, one or more track index points.
886                         </td>
887                 </tr>
888         </table>
889         </td></tr></table>
890 </div>
891
892 <br />
893
894 <div class="box">
895         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
896         <table width="100%" border="1">
897                 <tr>
898                         <td colspan="2" bgcolor="#D3D4C5">
899                                 <a name="cuesheet_track_index"><font size="+1"><b>CUESHEET_TRACK_INDEX</b></font></a>
900                         </td>
901                 </tr>
902                 <tr>
903                         <td align="right" valign="top" bgcolor="#F4F4CC">
904                                 &lt;64&gt;
905                         </td>
906                         <td>
907                                 Offset in samples, relative to the track offset, of the index point.  For CD-DA, the offset must be evenly divisible by 588 samples (588 samples = 44100 samples/sec * 1/75th of a sec).  Note that the offset is from the beginning of the track, not the beginning of the audio data.
908                         </td>
909                 </tr>
910                 <tr>
911                         <td align="right" valign="top" bgcolor="#F4F4CC">
912                                 &lt;8&gt;
913                         </td>
914                         <td>
915                                 The index point number.  For CD-DA, an index number of 0 corresponds to the track pre-gap.  The first index in a track must have a number of 0 or 1, and subsequently, index numbers must increase by 1.  Index numbers must be unique within a track.
916                         </td>
917                 </tr>
918                 <tr>
919                         <td align="right" valign="top" bgcolor="#F4F4CC">
920                                 &lt;3*8&gt;
921                         </td>
922                         <td>
923                                 Reserved.  All bits must be set to zero.
924                         </td>
925                 </tr>
926         </table>
927         </td></tr></table>
928 </div>
929
930 <br />
931
932 <div class="box">
933         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
934         <table width="100%" border="1">
935                 <tr>
936                         <td colspan="2" bgcolor="#D3D4C5">
937                                 <a name="metadata_block_picture"><font size="+1"><b>METADATA_BLOCK_PICTURE</b></font></a>
938                         </td>
939                 </tr>
940                 <tr>
941                         <td align="right" valign="top" bgcolor="#F4F4CC">
942                                 &lt;32&gt;
943                         </td>
944                         <td>
945                                 The picture type according to the ID3v2 APIC frame:<br />
946                                 <ul>
947                                         <li>0 - Other</li>
948                                         <li>1 - 32x32 pixels 'file icon' (PNG only)</li>
949                                         <li>2 - Other file icon</li>
950                                         <li>3 - Cover (front)</li>
951                                         <li>4 - Cover (back)</li>
952                                         <li>5 - Leaflet page</li>
953                                         <li>6 - Media (e.g. label side of CD)</li>
954                                         <li>7 - Lead artist/lead performer/soloist</li>
955                                         <li>8 - Artist/performer</li>
956                                         <li>9 - Conductor</li>
957                                         <li>10 - Band/Orchestra</li>
958                                         <li>11 - Composer</li>
959                                         <li>12 - Lyricist/text writer</li>
960                                         <li>13 - Recording Location</li>
961                                         <li>14 - During recording</li>
962                                         <li>15 - During performance</li>
963                                         <li>16 - Movie/video screen capture</li>
964                                         <li>17 - A bright coloured fish</li>
965                                         <li>18 - Illustration</li>
966                                         <li>19 - Band/artist logotype</li>
967                                         <li>20 - Publisher/Studio logotype</li>
968                                 </ul>
969                                 Others are reserved and should not be used.  There may only be one each of picture type 1 and 2 in a file.
970                         </td>
971                 </tr>
972                 <tr>
973                         <td align="right" valign="top" bgcolor="#F4F4CC">
974                                 &lt;32&gt;
975                         </td>
976                         <td>
977                                 The length of the MIME type string in bytes.
978                         </td>
979                 </tr>
980                 <tr>
981                         <td align="right" valign="top" bgcolor="#F4F4CC">
982                                 &lt;n*8&gt;
983                         </td>
984                         <td>
985                                 The MIME type string, in printable ASCII characters 0x20-0x7e.  The MIME type may also be <tt>--&gt;</tt> to signify that the data part is a URL of the picture instead of the picture data itself.
986                         </td>
987                 </tr>
988                 <tr>
989                         <td align="right" valign="top" bgcolor="#F4F4CC">
990                                 &lt;32&gt;
991                         </td>
992                         <td>
993                                 The length of the description string in bytes.
994                         </td>
995                 </tr>
996                 <tr>
997                         <td align="right" valign="top" bgcolor="#F4F4CC">
998                                 &lt;n*8&gt;
999                         </td>
1000                         <td>
1001                                 The description of the picture, in UTF-8.
1002                         </td>
1003                 </tr>
1004                 <tr>
1005                         <td align="right" valign="top" bgcolor="#F4F4CC">
1006                                 &lt;32&gt;
1007                         </td>
1008                         <td>
1009                                 The width of the picture in pixels.
1010                         </td>
1011                 </tr>
1012                 <tr>
1013                         <td align="right" valign="top" bgcolor="#F4F4CC">
1014                                 &lt;32&gt;
1015                         </td>
1016                         <td>
1017                                 The height of the picture in pixels.
1018                         </td>
1019                 </tr>
1020                 <tr>
1021                         <td align="right" valign="top" bgcolor="#F4F4CC">
1022                                 &lt;32&gt;
1023                         </td>
1024                         <td>
1025                                 The color depth of the picture in bits-per-pixel.
1026                         </td>
1027                 </tr>
1028                 <tr>
1029                         <td align="right" valign="top" bgcolor="#F4F4CC">
1030                                 &lt;32&gt;
1031                         </td>
1032                         <td>
1033                                 For indexed-color pictures (e.g. GIF), the number of colors used, or <tt>0</tt> for non-indexed pictures.
1034                         </td>
1035                 </tr>
1036                 <tr>
1037                         <td align="right" valign="top" bgcolor="#F4F4CC">
1038                                 &lt;32&gt;
1039                         </td>
1040                         <td>
1041                                 The length of the picture data in bytes.
1042                         </td>
1043                 </tr>
1044                 <tr>
1045                         <td align="right" valign="top" bgcolor="#F4F4CC">
1046                                 &lt;n*8&gt;
1047                         </td>
1048                         <td>
1049                                 The binary picture data.
1050                         </td>
1051                 </tr>
1052         </table>
1053         </td></tr></table>
1054 </div>
1055
1056 <br />
1057
1058 <div class="box">
1059         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1060         <table width="100%" border="1" bgcolor="#EEEED4">
1061                 <tr>
1062                         <td colspan="2" bgcolor="#D3D4C5">
1063                                 <a name="frame"><font size="+1"><b>FRAME</b></font></a>
1064                         </td>
1065                 </tr>
1066                 <tr>
1067                         <td align="right" valign="top" bgcolor="#F4F4CC">
1068                                 <a href="#frame_header"><i>FRAME_HEADER</i></a>
1069                         </td>
1070                         <td>
1071                                 &nbsp;
1072                         </td>
1073                 </tr>
1074                 <tr>
1075                         <td align="right" valign="top" bgcolor="#F4F4CC">
1076                                 <a href="#subframe"><i>SUBFRAME</i></a>+
1077                         </td>
1078                         <td>
1079                                 One SUBFRAME per channel.
1080                         </td>
1081                 </tr>
1082                 <tr>
1083                         <td align="right" valign="top" bgcolor="#F4F4CC">
1084                                 &lt;?&gt;
1085                         </td>
1086                         <td>
1087                                 Zero-padding to byte alignment.
1088                         </td>
1089                 </tr>
1090                 <tr>
1091                         <td align="right" valign="top" bgcolor="#F4F4CC">
1092                                 <a href="#frame_footer"><i>FRAME_FOOTER</i></a>
1093                         </td>
1094                         <td>
1095                                 &nbsp;
1096                         </td>
1097                 </tr>
1098         </table>
1099         </td></tr></table>
1100 </div>
1101
1102 <br />
1103
1104 <div class="box">
1105         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1106         <table width="100%" border="1" bgcolor="#EEEED4">
1107                 <tr>
1108                         <td colspan="2" bgcolor="#D3D4C5">
1109                                 <a name="frame_header"><font size="+1"><b>FRAME_HEADER</b></font></a>
1110                         </td>
1111                 </tr>
1112                 <tr>
1113                         <td align="right" valign="top" bgcolor="#F4F4CC">
1114                                 &lt;14&gt;
1115                         </td>
1116                         <td>
1117                                 Sync code '<tt>11111111111110</tt>'
1118                         </td>
1119                 </tr>
1120                 <tr>
1121                         <td align="right" valign="top" bgcolor="#F4F4CC">
1122                                 &lt;1&gt;
1123                         </td>
1124                         <td>
1125                                 Reserved: <a href="#frame_header_notes">[1]</a><br />
1126                                 <ul>
1127                                 <li>
1128                                         <tt>0</tt> : mandatory value
1129                                 </li>
1130                                 <li>
1131                                         <tt>1</tt> : reserved for future use
1132                                 </li>
1133                                 </ul>
1134                         </td>
1135                 </tr>
1136                 <tr>
1137                         <td align="right" valign="top" bgcolor="#F4F4CC">
1138                                 &lt;1&gt;
1139                         </td>
1140                         <td>
1141                                 Blocking strategy: <a href="#frame_header_notes">[2]</a> <a href="#frame_header_notes">[3]</a><br />
1142                                 <ul>
1143                                 <li>
1144                                         <tt>0</tt> : fixed-blocksize stream; frame header encodes the frame number
1145                                 </li>
1146                                 <li>
1147                                         <tt>1</tt> : variable-blocksize stream; frame header encodes the sample number
1148                                 </li>
1149                                 </ul>
1150                         </td>
1151                 </tr>
1152                 <tr>
1153                         <td align="right" valign="top" bgcolor="#F4F4CC">
1154                                 &lt;4&gt;
1155                         </td>
1156                         <td>
1157                                 Block size in inter-channel samples:<br />
1158                                 <ul>
1159                                 <li>
1160                                         <tt>0000</tt> : reserved
1161                                 </li>
1162                                 <li>
1163                                         <tt>0001</tt> : 192 samples
1164                                 </li>
1165                                 <li>
1166                                         <tt>0010-0101</tt> : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
1167                                 </li>
1168                                 <li>
1169                                         <tt>0110</tt> : get 8 bit (blocksize-1) from end of header
1170                                 </li>
1171                                 <li>
1172                                         <tt>0111</tt> : get 16 bit (blocksize-1) from end of header
1173                                 </li>
1174                                 <li>
1175                                         <tt>1000-1111</tt> : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
1176                                 </li>
1177                                 </ul>
1178                         </td>
1179                 </tr>
1180                 <tr>
1181                         <td align="right" valign="top" bgcolor="#F4F4CC">
1182                                 &lt;4&gt;
1183                         </td>
1184                         <td>
1185                                 Sample rate:<br />
1186                                 <ul>
1187                                 <li>
1188                                         <tt>0000</tt> : get from STREAMINFO metadata block
1189                                 </li>
1190                                 <li>
1191                                         <tt>0001</tt> : 88.2kHz
1192                                 </li>
1193                                 <li>
1194                                         <tt>0010</tt> : 176.4kHz
1195                                 </li>
1196                                 <li>
1197                                         <tt>0011</tt> : 192kHz
1198                                 </li>
1199                                 <li>
1200                                         <tt>0100</tt> : 8kHz
1201                                 </li>
1202                                 <li>
1203                                         <tt>0101</tt> : 16kHz
1204                                 </li>
1205                                 <li>
1206                                         <tt>0110</tt> : 22.05kHz
1207                                 </li>
1208                                 <li>
1209                                         <tt>0111</tt> : 24kHz
1210                                 </li>
1211                                 <li>
1212                                         <tt>1000</tt> : 32kHz
1213                                 </li>
1214                                 <li>
1215                                         <tt>1001</tt> : 44.1kHz
1216                                 </li>
1217                                 <li>
1218                                         <tt>1010</tt> : 48kHz
1219                                 </li>
1220                                 <li>
1221                                         <tt>1011</tt> : 96kHz
1222                                 </li>
1223                                 <li>
1224                                         <tt>1100</tt> : get 8 bit sample rate (in kHz) from end of header
1225                                 </li>
1226                                 <li>
1227                                         <tt>1101</tt> : get 16 bit sample rate (in Hz) from end of header
1228                                 </li>
1229                                 <li>
1230                                         <tt>1110</tt> : get 16 bit sample rate (in tens of Hz) from end of header
1231                                 </li>
1232                                 <li>
1233                                         <tt>1111</tt> : invalid, to prevent sync-fooling string of 1s
1234                                 </li>
1235                                 </ul>
1236                         </td>
1237                 </tr>
1238                 <tr>
1239                         <td align="right" valign="top" bgcolor="#F4F4CC">
1240                                 &lt;4&gt;
1241                         </td>
1242                         <td>
1243                                 Channel assignment
1244                                 <ul>
1245                                 <li>
1246                                         <tt>0000-0111</tt> : (number of independent channels)-1.  Where defined, the channel order follows SMPTE/ITU-R recommendations.  The assignments are as follows:
1247                                         <ul>
1248                                                 <li>1 channel: mono</li>
1249                                                 <li>2 channels: left, right</li>
1250                                                 <li>3 channels: left, right, center</li>
1251                                                 <li>4 channels: front left, front right, back left, back right</li>
1252                                                 <li>5 channels: front left, front right, front center, back/surround left, back/surround right</li>
1253                                                 <li>6 channels: front left, front right, front center, LFE, back/surround left, back/surround right</li>
1254                                                 <li>7 channels: front left, front right, front center, LFE, back center, side left, side right</li>
1255                                                 <li>8 channels: front left, front right, front center, LFE, back left, back right, side left, side right</li>
1256                                         </ul>
1257                                 </li>
1258                                 <li>
1259                                         <tt>1000</tt> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
1260                                 </li>
1261                                 <li>
1262                                         <tt>1001</tt> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
1263                                 </li>
1264                                 <li>
1265                                         <tt>1010</tt> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
1266                                 </li>
1267                                 <li>
1268                                         <tt>1011-1111</tt> : reserved
1269                                 </li>
1270                                 </ul>
1271                         </td>
1272                 </tr>
1273                 <tr>
1274                         <td align="right" valign="top" bgcolor="#F4F4CC">
1275                                 &lt;3&gt;
1276                         </td>
1277                         <td>
1278                                 Sample size in bits:<br />
1279                                 <ul>
1280                                 <li>
1281                                         <tt>000</tt> : get from STREAMINFO metadata block
1282                                 </li>
1283                                 <li>
1284                                         <tt>001</tt> : 8 bits per sample
1285                                 </li>
1286                                 <li>
1287                                         <tt>010</tt> : 12 bits per sample
1288                                 </li>
1289                                 <li>
1290                                         <tt>011</tt> : reserved
1291                                 </li>
1292                                 <li>
1293                                         <tt>100</tt> : 16 bits per sample
1294                                 </li>
1295                                 <li>
1296                                         <tt>101</tt> : 20 bits per sample
1297                                 </li>
1298                                 <li>
1299                                         <tt>110</tt> : 24 bits per sample
1300                                 </li>
1301                                 <li>
1302                                         <tt>111</tt> : reserved
1303                                 </li>
1304                                 </ul>
1305                         </td>
1306                 </tr>
1307                 <tr>
1308                         <td align="right" valign="top" bgcolor="#F4F4CC">
1309                                 &lt;1&gt;
1310                         </td>
1311                         <td>
1312                                 Reserved:<br />
1313                                 <ul>
1314                                 <li>
1315                                         <tt>0</tt> : mandatory value
1316                                 </li>
1317                                 <li>
1318                                         <tt>1</tt> : reserved for future use
1319                                 </li>
1320                                 </ul>
1321                         </td>
1322                 </tr>
1323                 <tr>
1324                         <td align="right" valign="top" bgcolor="#F4F4CC">
1325                                 &lt;?&gt;
1326                         </td>
1327                         <td>
1328                                 if(variable blocksize)<br />
1329                                 &nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits) <a href="#frame_header_notes">[4]</a><br />
1330                                 else<br />
1331                                 &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits) <a href="#frame_header_notes">[4]</a>
1332                         </td>
1333                 </tr>
1334                 <tr>
1335                         <td align="right" valign="top" bgcolor="#F4F4CC">
1336                                 &lt;?&gt;
1337                         </td>
1338                         <td>
1339                                 if(blocksize bits == 011x)<br />
1340                                 &nbsp;&nbsp;&nbsp;8/16 bit (blocksize-1)
1341                         </td>
1342                 </tr>
1343                 <tr>
1344                         <td align="right" valign="top" bgcolor="#F4F4CC">
1345                                 &lt;?&gt;
1346                         </td>
1347                         <td>
1348                                 if(sample rate bits == 11xx)<br />
1349                                 &nbsp;&nbsp;&nbsp;8/16 bit sample rate
1350                         </td>
1351                 </tr>
1352                 <tr>
1353                         <td align="right" valign="top" bgcolor="#F4F4CC">
1354                                 &lt;8&gt;
1355                         </td>
1356                         <td>
1357                                 CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
1358                         </td>
1359                 </tr>
1360                 <tr>
1361                         <td>
1362                         </td>
1363                         <td bgcolor="#F4F4CC">
1364                                 <a name="frame_header_notes"><font size="+1">NOTES</font></a><br />
1365                                 <ol>
1366                                 <li>
1367                                         This bit must remain reserved for <tt>0</tt> in order for a FLAC frame's initial 15 bits to be distinguishable from the start of an MPEG audio frame (<a href="http://lists.xiph.org/pipermail/flac-dev/2008-December/002607.html">see also</a>).
1368                                 </li>
1369                                 <li>
1370                                         The "blocking strategy" bit must be the same throughout the entire stream.
1371                                 </li>
1372                                 <li>
1373                                         The "blocking strategy" bit determines how to calculate the sample number of the first sample in the frame.  If the bit is <tt>0</tt> (fixed-blocksize), the frame header encodes the frame number as above, and the frame's starting sample number will be the frame number times the blocksize.  If it is <tt>1</tt> (variable-blocksize), the frame header encodes the frame's starting sample number itself.  (In the case of a fixed-blocksize stream, only the last block may be shorter than the stream blocksize; its starting sample number will be calculated as the frame number times the previous frame's blocksize, or zero if it is the first frame).
1374                                 </li>
1375                                 <li>
1376                                         The "UTF-8" coding used for the sample/frame number is the same variable length code used to store compressed UCS-2, extended to handle larger input.
1377                                 </li>
1378                                 </ol>
1379                         </td>
1380                 </tr>
1381         </table>
1382         </td></tr></table>
1383 </div>
1384
1385 <br />
1386
1387 <div class="box">
1388         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1389         <table width="100%" border="1" bgcolor="#EEEED4">
1390                 <tr>
1391                         <td colspan="2" bgcolor="#D3D4C5">
1392                                 <a name="frame_footer"><font size="+1"><b>FRAME_FOOTER</b></font></a>
1393                         </td>
1394                 </tr>
1395                 <tr>
1396                         <td align="right" valign="top" bgcolor="#F4F4CC">
1397                                 &lt;16&gt;
1398                         </td>
1399                         <td>
1400                                 CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with 0) of everything before the crc, back to and including the frame header sync code
1401                         </td>
1402                 </tr>
1403         </table>
1404         </td></tr></table>
1405 </div>
1406
1407 <br />
1408
1409 <div class="box">
1410         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1411         <table width="100%" border="1" bgcolor="#EEEED4">
1412                 <tr>
1413                         <td colspan="2" bgcolor="#D3D4C5">
1414                                 <a name="subframe"><font size="+1"><b>SUBFRAME</b></font></a>
1415                         </td>
1416                 </tr>
1417                 <tr>
1418                         <td align="right" valign="top" bgcolor="#F4F4CC">
1419                                 <a href="#subframe_header"><i>SUBFRAME_HEADER</i></a>
1420                         </td>
1421                         <td>
1422                                 &nbsp;
1423                         </td>
1424                 </tr>
1425                 <tr>
1426                         <td align="right" valign="top" bgcolor="#F4F4CC">
1427                                 <a href="#subframe_constant"><i>SUBFRAME_CONSTANT</i></a><br />|| <a href="#subframe_fixed"><i>SUBFRAME_FIXED</i></a><br />|| <a href="#subframe_lpc"><i>SUBFRAME_LPC</i></a><br />|| <a href="#subframe_verbatim"><i>SUBFRAME_VERBATIM</i></a>
1428                         </td>
1429                         <td valign="top">
1430                                 The SUBFRAME_HEADER specifies which one.
1431                         </td>
1432                 </tr>
1433         </table>
1434         </td></tr></table>
1435 </div>
1436
1437 <br />
1438
1439 <div class="box">
1440         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1441         <table width="100%" border="1" bgcolor="#EEEED4">
1442                 <tr>
1443                         <td colspan="2" bgcolor="#D3D4C5">
1444                                 <a name="subframe_header"><font size="+1"><b>SUBFRAME_HEADER</b></font></a>
1445                         </td>
1446                 </tr>
1447                 <tr>
1448                         <td align="right" valign="top" bgcolor="#F4F4CC">
1449                                 &lt;1&gt;
1450                         </td>
1451                         <td>
1452                                 Zero bit padding, to prevent sync-fooling string of 1s
1453                         </td>
1454                 </tr>
1455                 <tr>
1456                         <td align="right" valign="top" bgcolor="#F4F4CC">
1457                                 &lt;6&gt;
1458                         </td>
1459                         <td>
1460                                 Subframe type:
1461                                 <ul>
1462                                 <li>
1463                                         <tt>000000</tt> : <a href="#subframe_constant">SUBFRAME_CONSTANT</a>
1464                                 </li>
1465                                 <li>
1466                                         <tt>000001</tt> : <a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
1467                                 </li>
1468                                 <li>
1469                                         <tt>00001x</tt> : reserved
1470                                 </li>
1471                                 <li>
1472                                         <tt>0001xx</tt> : reserved
1473                                 </li>
1474                                 <li>
1475                                         <tt>001xxx</tt> : if(xxx &lt;= 4) <a href="#subframe_fixed">SUBFRAME_FIXED</a>, xxx=order ; else reserved
1476                                 </li>
1477                                 <li>
1478                                         <tt>01xxxx</tt> : reserved
1479                                 </li>
1480                                 <li>
1481                                         <tt>1xxxxx</tt> : <a href="#subframe_lpc">SUBFRAME_LPC</a>, xxxxx=order-1
1482                                 </li>
1483                                 </ul>
1484                         </td>
1485                 </tr>
1486                 <tr>
1487                         <td align="right" valign="top" bgcolor="#F4F4CC">
1488                                 &lt;1+k&gt;
1489                         </td>
1490                         <td>
1491                                 'Wasted bits-per-sample' flag:
1492                                 <ul>
1493                                 <li>
1494                                         <tt>0</tt> : no wasted bits-per-sample in source subblock, k=0
1495                                 </li>
1496                                 <li>
1497                                         <tt>1</tt> : k wasted bits-per-sample in source subblock, k-1 follows, unary coded; e.g. k=3 =&gt; 001 follows, k=7 =&gt; 0000001 follows.
1498                                 </li>
1499                                 </ul>
1500                         </td>
1501                 </tr>
1502         </table>
1503         </td></tr></table>
1504 </div>
1505
1506 <br />
1507
1508 <div class="box">
1509         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1510         <table width="100%" border="1" bgcolor="#EEEED4">
1511                 <tr>
1512                         <td colspan="2" bgcolor="#D3D4C5">
1513                                 <a name="subframe_constant"><font size="+1"><b>SUBFRAME_CONSTANT</b></font></a>
1514                         </td>
1515                 </tr>
1516                 <tr>
1517                         <td align="right" valign="top" bgcolor="#F4F4CC">
1518                                 &lt;n&gt;
1519                         </td>
1520                         <td>
1521                                 Unencoded constant value of the subblock, n = frame's bits-per-sample.
1522                         </td>
1523                 </tr>
1524         </table>
1525         </td></tr></table>
1526 </div>
1527
1528 <br />
1529
1530 <div class="box">
1531         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1532         <table width="100%" border="1" bgcolor="#EEEED4">
1533                 <tr>
1534                         <td colspan="2" bgcolor="#D3D4C5">
1535                                 <a name="subframe_fixed"><font size="+1"><b>SUBFRAME_FIXED</b></font></a>
1536                         </td>
1537                 </tr>
1538                 <tr>
1539                         <td align="right" valign="top" bgcolor="#F4F4CC">
1540                                 &lt;n&gt;
1541                         </td>
1542                         <td>
1543                                 Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
1544                         </td>
1545                 </tr>
1546                 <tr>
1547                         <td align="right" valign="top" bgcolor="#F4F4CC">
1548                                 <a href="#residual"><i>RESIDUAL</i></a>
1549                         </td>
1550                         <td>
1551                                 Encoded residual
1552                         </td>
1553                 </tr>
1554         </table>
1555         </td></tr></table>
1556 </div>
1557
1558 <br />
1559
1560 <div class="box">
1561         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1562         <table width="100%" border="1" bgcolor="#EEEED4">
1563                 <tr>
1564                         <td colspan="2" bgcolor="#D3D4C5">
1565                                 <a name="subframe_lpc"><font size="+1"><b>SUBFRAME_LPC</b></font></a>
1566                         </td>
1567                 </tr>
1568                 <tr>
1569                         <td align="right" valign="top" bgcolor="#F4F4CC">
1570                                 &lt;n&gt;
1571                         </td>
1572                         <td>
1573                                 Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
1574                         </td>
1575                 </tr>
1576                 <tr>
1577                         <td align="right" valign="top" bgcolor="#F4F4CC">
1578                                 &lt;4&gt;
1579                         </td>
1580                         <td>
1581                                 (Quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
1582                         </td>
1583                 </tr>
1584                 <tr>
1585                         <td align="right" valign="top" bgcolor="#F4F4CC">
1586                                 &lt;5&gt;
1587                         </td>
1588                         <td>
1589                                 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement).
1590                         </td>
1591                 </tr>
1592                 <tr>
1593                         <td align="right" valign="top" bgcolor="#F4F4CC">
1594                                 &lt;n&gt;
1595                         </td>
1596                         <td>
1597                                 Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
1598                         </td>
1599                 </tr>
1600                 <tr>
1601                         <td align="right" valign="top" bgcolor="#F4F4CC">
1602                                 <a href="#residual"><i>RESIDUAL</i></a>
1603                         </td>
1604                         <td>
1605                                 Encoded residual
1606                         </td>
1607                 </tr>
1608         </table>
1609         </td></tr></table>
1610 </div>
1611
1612 <br />
1613
1614 <div class="box">
1615         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1616         <table width="100%" border="1" bgcolor="#EEEED4">
1617                 <tr>
1618                         <td colspan="2" bgcolor="#D3D4C5">
1619                                 <a name="subframe_verbatim"><font size="+1"><b>SUBFRAME_VERBATIM</b></font></a>
1620                         </td>
1621                 </tr>
1622                 <tr>
1623                         <td align="right" valign="top" bgcolor="#F4F4CC">
1624                                 &lt;n*i&gt;
1625                         </td>
1626                         <td>
1627                                 Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
1628                         </td>
1629                 </tr>
1630         </table>
1631         </td></tr></table>
1632 </div>
1633
1634 <br />
1635
1636 <div class="box">
1637         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1638         <table width="100%" border="1" bgcolor="#EEEED4">
1639                 <tr>
1640                         <td colspan="2" bgcolor="#D3D4C5">
1641                                 <a name="residual"><font size="+1"><b>RESIDUAL</b></font></a>
1642                         </td>
1643                 </tr>
1644                 <tr>
1645                         <td align="right" valign="top" bgcolor="#F4F4CC">
1646                                 &lt;2&gt;
1647                         </td>
1648                         <td>
1649                                 Residual coding method:<br />
1650                                 <ul>
1651                                 <li>
1652                                         <tt>00</tt> : partitioned Rice coding with 4-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE follows
1653                                 </li>
1654                                 <li>
1655                                         <tt>01</tt> : partitioned Rice coding with 5-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 follows
1656                                 </li>
1657                                 <li>
1658                                         <tt>10-11</tt> : reserved
1659                                 </li>
1660                                 </ul>
1661                         </td>
1662                 </tr>
1663                 <tr>
1664                         <td align="right" valign="top" bgcolor="#F4F4CC">
1665                                 <a href="#partitioned_rice"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</i></a>&nbsp;||<br />
1666                                 <a href="#partitioned_rice2"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</i></a>
1667                         </td>
1668                         <td>
1669                                 &nbsp;
1670                         </td>
1671                 </tr>
1672         </table>
1673         </td></tr></table>
1674 </div>
1675
1676 <br />
1677
1678 <div class="box">
1679         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1680         <table width="100%" border="1" bgcolor="#EEEED4">
1681                 <tr>
1682                         <td colspan="2" bgcolor="#D3D4C5">
1683                                 <a name="partitioned_rice"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</b></font></a>
1684                         </td>
1685                 </tr>
1686                 <tr>
1687                         <td align="right" valign="top" bgcolor="#F4F4CC">
1688                                 &lt;4&gt;
1689                         </td>
1690                         <td>
1691                                 Partition order.
1692                         </td>
1693                 </tr>
1694                 <tr>
1695                         <td align="right" valign="top" bgcolor="#F4F4CC">
1696                                 <a href="#rice_partition"><i>RICE_PARTITION</i></a>+
1697                         </td>
1698                         <td>
1699                                 There will be 2^order partitions.
1700                         </td>
1701                 </tr>
1702         </table>
1703         </td></tr></table>
1704 </div>
1705
1706 <br />
1707
1708 <div class="box">
1709         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1710         <table width="100%" border="1" bgcolor="#EEEED4">
1711                 <tr>
1712                         <td colspan="2" bgcolor="#D3D4C5">
1713                                 <a name="rice_partition"><font size="+1"><b>RICE_PARTITION</b></font></a>
1714                         </td>
1715                 </tr>
1716                 <tr>
1717                         <td align="right" valign="top" bgcolor="#F4F4CC">
1718                                 &lt;4(+5)&gt;
1719                         </td>
1720                         <td>
1721                                 Encoding parameter:<br />
1722                                 <ul>
1723                                 <li>
1724                                         <tt>0000-1110</tt> : Rice parameter.
1725                                 </li>
1726                                 <li>
1727                                         <tt>1111</tt> : Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number.
1728                                 </li>
1729                                 </ul>
1730                         </td>
1731                 </tr>
1732                 <tr>
1733                         <td align="right" valign="top" bgcolor="#F4F4CC">
1734                                 &lt;?&gt;
1735                         </td>
1736                         <td>
1737                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
1738                                 <ul>
1739                                 <li>
1740                                         if the partition order is zero, n = frame's blocksize - predictor order
1741                                 </li>
1742                                 <li>
1743                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1744                                 </li>
1745                                 <li>
1746                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1747                                 </li>
1748                                 </ul>
1749                         </td>
1750                 </tr>
1751         </table>
1752         </td></tr></table>
1753 </div>
1754
1755 <br />
1756
1757 <div class="box">
1758         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1759         <table width="100%" border="1" bgcolor="#EEEED4">
1760                 <tr>
1761                         <td colspan="2" bgcolor="#D3D4C5">
1762                                 <a name="partitioned_rice2"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</b></font></a>
1763                         </td>
1764                 </tr>
1765                 <tr>
1766                         <td align="right" valign="top" bgcolor="#F4F4CC">
1767                                 &lt;4&gt;
1768                         </td>
1769                         <td>
1770                                 Partition order.
1771                         </td>
1772                 </tr>
1773                 <tr>
1774                         <td align="right" valign="top" bgcolor="#F4F4CC">
1775                                 <a href="#rice2_partition"><i>RICE2_PARTITION</i></a>+
1776                         </td>
1777                         <td>
1778                                 There will be 2^order partitions.
1779                         </td>
1780                 </tr>
1781         </table>
1782         </td></tr></table>
1783 </div>
1784
1785 <br />
1786
1787 <div class="box">
1788         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1789         <table width="100%" border="1" bgcolor="#EEEED4">
1790                 <tr>
1791                         <td colspan="2" bgcolor="#D3D4C5">
1792                                 <a name="rice2_partition"><font size="+1"><b>RICE2_PARTITION</b></font></a>
1793                         </td>
1794                 </tr>
1795                 <tr>
1796                         <td align="right" valign="top" bgcolor="#F4F4CC">
1797                                 &lt;5(+5)&gt;
1798                         </td>
1799                         <td>
1800                                 Encoding parameter:<br />
1801                                 <ul>
1802                                 <li>
1803                                         <tt>0000-11110</tt> : Rice parameter.
1804                                 </li>
1805                                 <li>
1806                                         <tt>11111</tt> : Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number.
1807                                 </li>
1808                                 </ul>
1809                         </td>
1810                 </tr>
1811                 <tr>
1812                         <td align="right" valign="top" bgcolor="#F4F4CC">
1813                                 &lt;?&gt;
1814                         </td>
1815                         <td>
1816                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
1817                                 <ul>
1818                                 <li>
1819                                         if the partition order is zero, n = frame's blocksize - predictor order
1820                                 </li>
1821                                 <li>
1822                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1823                                 </li>
1824                                 <li>
1825                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1826                                 </li>
1827                                 </ul>
1828                         </td>
1829                 </tr>
1830         </table>
1831         </td></tr></table>
1832 </div>
1833
1834
1835 <div class="copyright">
1836         <!-- @@@ oh so hacky -->
1837         <table>
1838                 <tr>
1839                         <td align="left">
1840                                 Copyright (c) 2000-2009  Josh Coalson
1841                                 <br/>
1842                                 Copyright (c) 2011-2013  Xiph.Org Foundation
1843                         </td>
1844                         <td width="1%" align="right">
1845                                 <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=13478&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
1846                         </td>
1847                         <td width="1%" align="right">
1848                                 <a href="http://www.eff.org/cafe/"><img src="images/cafebug.gif" alt="CAFE Logo" border="0" /></a><br />
1849                         </td>
1850                         <td width="1%" align="right">
1851                                 <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" border="0" hspace="0" /></a>
1852                         </td>
1853                 </tr>
1854         </table>
1855 </div>
1856
1857 </body>
1858 </html>