autogen.sh: replace this by a simple call to autoreconf
[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,2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson -->
3 <!-- Permission is granted to copy, distribute and/or modify this document -->
4 <!-- under the terms of the GNU Free Documentation License, Version 1.1 -->
5 <!-- or any later version published by the Free Software Foundation; -->
6 <!-- with no invariant sections. -->
7 <!-- A copy of the license can be found at http://www.gnu.org/copyleft/fdl.html -->
8 <html>
9 <head>
10         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
11         <meta name="author" content="Josh Coalson" />
12         <meta name="description" content="A free, open source codec for lossless audio compression and decompression" />
13         <meta name="keywords" content="free,lossless,audio,codec,encoder,decoder,compression,compressor,archival,archive,archiving,backup,music" />
14         <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
15         <link rel="stylesheet" type="text/css" href="flac.css" />
16         <title>FLAC - format</title>
17 </head>
18
19 <body>
20
21 <div class="logo">
22         <a href="http://flac.sourceforge.net/"><img src="images/logo130.gif" alt="FLAC Logo" align="middle" border="0" hspace="0" /></a>
23 </div>
24
25 <div class="above_nav"></div>
26
27 <div class="navbar">
28         &nbsp;<a href="index.html">home</a>&nbsp;&nbsp;|
29         &nbsp;<a href="faq.html">faq</a>&nbsp;&nbsp;|
30         &nbsp;<a href="news.html">news</a>&nbsp;&nbsp;|
31         &nbsp;<a href="download.html">download</a>&nbsp;&nbsp;|
32         &nbsp;<a href="documentation.html">documentation</a>&nbsp;&nbsp;|
33         &nbsp;<a href="comparison.html">comparison</a>&nbsp;&nbsp;|
34         &nbsp;<a href="changelog.html">changelog</a>&nbsp;&nbsp;|
35         &nbsp;<a href="links.html">links</a>&nbsp;&nbsp;|
36         &nbsp;<a href="developers.html">developers</a>&nbsp;
37 </div>
38
39 <div class="langbar">
40         &nbsp;english&nbsp;&nbsp;|
41         &nbsp;<a href="ru/format.html">russian</a>&nbsp;
42 </div>
43
44 <div class="below_nav"></div>
45
46 <div class="box">
47         <div class="box_title">
48                 format
49         </div>
50         <div class="box_header"></div>
51         <div class="box_body">
52                 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 />
53                 <br />
54                 For a user-oriented overview, see <a href="documentation_format_overview.html">About the FLAC Format</a>.<br />
55                 <br />
56                 <a name="toc"><font size="+1"><b><u>Table of Contents</u></b></font></a>
57                 <ul>
58                         <li><a href="#acknowledgments">Acknowledgments</a></li>
59                         <li><a href="#scope">Scope</a></li>
60                         <li><a href="#architecture">Architecture</a></li>
61                         <li><a href="#definitions">Definitions</a></li>
62                         <li><a href="#blocking">Blocking</a></li>
63                         <li><a href="#interchannel">Interchannel Decorrelation</a></li>
64                         <li><a href="#prediction">Prediction</a></li>
65                         <li><a href="#residualcoding">Residual Coding</a></li>
66                         <li><a href="#format_overview">Format</a></li>
67                         <li><a href="#subset">FLAC Subset</a></li>
68                         <li>Specification
69                                 <ul>
70                                         <li><a href="#stream">STREAM</a>
71                                                 <ul>
72                                                         <li><a href="#metadata_block">METADATA_BLOCK</a>
73                                                                 <ul>
74                                                                         <li><a href="#metadata_block_header">METADATA_BLOCK_HEADER</a></li>
75                                                                         <li><a href="#metadata_block_data">METADATA_BLOCK_DATA</a>
76                                                                                 <ul>
77                                                                                         <li><a href="#metadata_block_streaminfo">METADATA_BLOCK_STREAMINFO</a></li>
78                                                                                         <li><a href="#metadata_block_padding">METADATA_BLOCK_PADDING</a></li>
79                                                                                         <li><a href="#metadata_block_application">METADATA_BLOCK_APPLICATION</a></li>
80                                                                                         <li><a href="#metadata_block_seektable">METADATA_BLOCK_SEEKTABLE</a>
81                                                                                                 <ul>
82                                                                                                         <li><a href="#seekpoint">SEEKPOINT</a></li>
83                                                                                                 </ul>
84                                                                                         </li>
85                                                                                         <li><a href="#metadata_block_vorbis_comment">METADATA_BLOCK_VORBIS_COMMENT</a></li>
86                                                                                         <li><a href="#metadata_block_cuesheet">METADATA_BLOCK_CUESHEET</a>
87                                                                                                 <ul>
88                                                                                                         <li><a href="#cuesheet_track">CUESHEET_TRACK</a>
89                                                                                                                 <ul>
90                                                                                                                         <li><a href="#cuesheet_track_index">CUESHEET_TRACK_INDEX</a></li>
91                                                                                                                 </ul>
92                                                                                                         </li>
93                                                                                                 </ul>
94                                                                                         </li>
95                                                                                         <li><a href="#metadata_block_picture">METADATA_BLOCK_PICTURE</a></li>
96                                                                                 </ul>
97                                                                         </li>
98                                                                 </ul>
99                                                         </li>
100                                                 </ul>
101                                         </li>
102                                         <li>
103                                                 <ul>
104                                                         <li><a href="#frame">FRAME</a>
105                                                                 <ul>
106                                                                         <li><a href="#frame_header">FRAME_HEADER</a></li>
107                                                                         <li><a href="#frame_footer">FRAME_FOOTER</a></li>
108                                                                         <li><a href="#subframe">SUBFRAME</a>
109                                                                                 <ul>
110                                                                                         <li><a href="#subframe_header">SUBFRAME_HEADER</a></li>
111                                                                                         <li><a href="#subframe_constant">SUBFRAME_CONSTANT</a></li>
112                                                                                         <li><a href="#subframe_fixed">SUBFRAME_FIXED</a></li>
113                                                                                         <li><a href="#subframe_lpc">SUBFRAME_LPC</a></li>
114                                                                                         <li><a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
115                                                                                                 <ul>
116                                                                                                         <li><a href="#residual">RESIDUAL</a>
117                                                                                                                 <ul>
118                                                                                                                         <li><a href="#partitioned_rice">RESIDUAL_CODING_METHOD_PARTITIONED_RICE</a>
119                                                                                                                                 <ul>
120                                                                                                                                         <li><a href="#rice_partition">RICE_PARTITION</a></li>
121                                                                                                                                 </ul>
122                                                                                                                         </li>
123                                                                                                                         <li><a href="#partitioned_rice2">RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</a>
124                                                                                                                                 <ul>
125                                                                                                                                         <li><a href="#rice2_partition">RICE2_PARTITION</a></li>
126                                                                                                                                 </ul>
127                                                                                                                         </li>
128                                                                                                                 </ul>
129                                                                                                         </li>
130                                                                                                 </ul>
131                                                                                         </li>
132                                                                                 </ul>
133                                                                         </li>
134                                                                 </ul>
135                                                         </li>
136                                                 </ul>
137                                         </li>
138                                 </ul>
139                         </li>
140                 </ul>
141                 <a name="acknowledgments"><font size="+1"><b><u>Acknowledgments</u></b></font></a><br />
142                 <br />
143                 FLAC owes much to the many people who have advanced the audio compression field so freely.  For instance:
144                 <ul>
145                         <li>
146                                 <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.
147                         </li>
148                         <li>
149                                 <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.
150                         </li>
151                         <li>
152                                 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.
153                         </li>
154                         <li>
155                                 And of course, <a href="http://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a>
156                         </li>
157                 </ul>
158                 <a name="scope"><font size="+1"><b><u>Scope</u></b></font></a><br />
159                 <br />
160                 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 />
161                 <br />
162                 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 />
163                 <br />
164                 <a name="architecture"><font size="+1"><b><u>Architecture</u></b></font></a><br />
165                 <br />
166                 Similar to many audio coders, a FLAC encoder has the following stages:
167                 <ul>
168                         <li>
169                                 <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.
170                         </li>
171                         <li>
172                                 <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.
173                         </li>
174                         <li>
175                                 <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.
176                         </li>
177                         <li>
178                                 <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.
179                         </li>
180                 </ul>
181                 In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.<br />
182                 <br />
183                 <a name="definitions"><font size="+1"><b><u>Definitions</u></b></font></a><br />
184                 <br />
185                 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.
186                 <ul>
187                         <li>
188                                 <b>Block</b>: One or more audio samples that span several channels.
189                         </li>
190                         <li>
191                                 <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.
192                         </li>
193                         <li>
194                                 <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.
195                         </li>
196                         <li>
197                                 <b>Frame</b>: A frame header plus one or more subframes.
198                         </li>
199                         <li>
200                                 <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.
201                         </li>
202                 </ul>
203                 <a name="blocking"><font size="+1"><b><u>Blocking</u></b></font></a><br />
204                 <br />
205                 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 />
206                 <br />
207                 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 />
208                 <br />
209                 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 />
210                 <br />
211                 <a name="interchannel"><font size="+1"><b><u>Interchannel Decorrelation</u></b></font></a><br />
212                 <br />
213                 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.
214                 <ul>
215                         <li>
216                                 <b>Independent</b>.  The left and right channels are coded independently.
217                         </li>
218                         <li>
219                                 <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).
220                         </li>
221                         <li>
222                                 <b>Left-side</b>.  The left channel and side channel are coded.
223                         </li>
224                         <li>
225                                 <b>Right-side</b>.  The right channel and side channel are coded
226                         </li>
227                 </ul>
228                 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 />
229                 <br />
230                 <a name="prediction"><font size="+1"><b><u>Prediction</u></b></font></a><br />
231                 <br />
232                 FLAC uses four methods for modeling the input signal:
233                 <ul>
234                         <li>
235                                 <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.
236                         </li>
237                         <li>
238                                 <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.
239                         </li>
240                         <li>
241                                 <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.
242                         </li>
243                         <li>
244                                 <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.
245                         </li>
246                 </ul>
247                 <a name="residualcoding"><font size="+1"><b><u>Residual Coding</u></b></font></a><br />
248                 <br />
249                 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 />
250                 <br />
251                 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 />
252                 <br />
253                 <a name="format_overview"><font size="+1"><b><u>Format</u></b></font></a><br />
254                 <br />
255                 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 />
256                 <br />
257                 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 />
258                 <br />
259                 Before the formal description of the stream, an overview might be helpful.
260                 <ul>
261                         <li>
262                                 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.
263                         </li>
264                         <li>
265                                 FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
266                                 <ul>
267                                         <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>
268                                         <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>
269                                         <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>
270                                         <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>
271                                         <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>
272                                         <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>
273                                         <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>
274                                 </ul>
275                         </li>
276                         <li>
277                                 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.
278                         </li>
279                         <li>
280                                 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.
281                         </li>
282                         <li>
283                                 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.
284                         </li>
285                         <li>
286                                 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.
287                         </li>
288                         <li>
289                                 <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:
290                                 <ul>
291                                 <li>
292                                         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.
293                                 </li>
294                                 <li>
295                                         The sample rate bits in the <a href="#frame_header">frame header</a> must be 0001-1110.
296                                 </li>
297                                 <li>
298                                         The bits-per-sample bits in the <a href="#frame_header">frame header</a> must be 001-111.
299                                 </li>
300                                 <li>
301                                         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.
302                                 </li>
303                                 <li>
304                                         The Rice partition order in a <a href="#partitioned_rice">Rice-coded residual section</a> must be less than or equal to 8.
305                                 </li>
306                                 </ul>
307                         </li>
308                 </ul>
309
310                 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 />
311         </div>
312         <div class="box_footer"></div>
313 </div>
314
315 <br />
316
317 <div class="box">
318         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
319         <table width="100%" border="1" bgcolor="#EEEED4">
320                 <tr>
321                         <td colspan="2" bgcolor="#D3D4C5">
322                                 <a name="stream"><font size="+1"><b>STREAM</b></font></a>
323                         </td>
324                 </tr>
325                 <tr>
326                         <td align="right" valign="top" bgcolor="#F4F4CC">
327                                 &lt;32&gt;
328                         </td>
329                         <td>
330                                 "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
331                         </td>
332                 </tr>
333                 <tr>
334                         <td align="right" valign="top" bgcolor="#F4F4CC">
335                                 <a href="#metadata_block_streaminfo"><i>METADATA_BLOCK</i></a>
336                         </td>
337                         <td>
338                                 This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
339                         </td>
340                 </tr>
341                 <tr>
342                         <td align="right" valign="top" bgcolor="#F4F4CC">
343                                 <a href="#metadata_block"><i>METADATA_BLOCK</i></a>*
344                         </td>
345                         <td>
346                                 Zero or more metadata blocks
347                         </td>
348                 </tr>
349                 <tr>
350                         <td align="right" valign="top" bgcolor="#F4F4CC">
351                                 <a href="#frame"><i>FRAME</i></a>+
352                         </td>
353                         <td>
354                                 One or more audio frames
355                         </td>
356                 </tr>
357         </table>
358         </td></tr></table>
359 </div>
360
361 <br />
362
363 <div class="box">
364         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
365         <table width="100%" border="1" bgcolor="#EEEED4">
366                 <tr>
367                         <td colspan="2" bgcolor="#D3D4C5">
368                                 <a name="metadata_block"><font size="+1"><b>METADATA_BLOCK</b></font></a>
369                         </td>
370                 </tr>
371                 <tr>
372                         <td align="right" valign="top" bgcolor="#F4F4CC">
373                                 <a href="#metadata_block_header"><i>METADATA_BLOCK_HEADER</i></a>
374                         </td>
375                         <td>
376                                 A block header that specifies the type and size of the metadata block data.
377                         </td>
378                 </tr>
379                 <tr>
380                         <td align="right" valign="top" bgcolor="#F4F4CC">
381                                 <a href="#metadata_block_data"><i>METADATA_BLOCK_DATA</i></a>
382                         </td>
383                         <td>
384                                 &nbsp;
385                         </td>
386                 </tr>
387         </table>
388         </td></tr></table>
389 </div>
390
391 <br />
392
393 <div class="box">
394         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
395         <table width="100%" border="1" bgcolor="#EEEED4">
396                 <tr>
397                         <td colspan="2" bgcolor="#D3D4C5">
398                                 <a name="metadata_block_header"><font size="+1"><b>METADATA_BLOCK_HEADER</b></font></a>
399                         </td>
400                 </tr>
401                 <tr>
402                         <td align="right" valign="top" bgcolor="#F4F4CC">
403                                 &lt;1&gt;
404                         </td>
405                         <td>
406                                 Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
407                         </td>
408                 </tr>
409                 <tr>
410                         <td align="right" valign="top" bgcolor="#F4F4CC">
411                                 &lt;7&gt;
412                         </td>
413                         <td>
414                                 BLOCK_TYPE<br />
415                                 <ul>
416                                 <li>
417                                         <tt>0</tt> : STREAMINFO
418                                 </li>
419                                 <li>
420                                         <tt>1</tt> : PADDING
421                                 </li>
422                                 <li>
423                                         <tt>2</tt> : APPLICATION
424                                 </li>
425                                 <li>
426                                         <tt>3</tt> : SEEKTABLE
427                                 </li>
428                                 <li>
429                                         <tt>4</tt> : VORBIS_COMMENT
430                                 </li>
431                                 <li>
432                                         <tt>5</tt> : CUESHEET
433                                 </li>
434                                 <li>
435                                         <tt>6</tt> : PICTURE
436                                 </li>
437                                 <li>
438                                         <tt>7-126</tt> : reserved
439                                 </li>
440                                 <li>
441                                         <tt>127</tt> : invalid, to avoid confusion with a frame sync code
442                                 </li>
443                                 </ul>
444                         </td>
445                 </tr>
446                 <tr>
447                         <td align="right" valign="top" bgcolor="#F4F4CC">
448                                 &lt;24&gt;
449                         </td>
450                         <td>
451                                 Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
452                         </td>
453                 </tr>
454         </table>
455         </td></tr></table>
456 </div>
457
458 <br />
459
460 <div class="box">
461         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
462         <table width="100%" border="1" bgcolor="#EEEED4">
463                 <tr>
464                         <td colspan="2" bgcolor="#D3D4C5">
465                                 <a name="metadata_block_data"><font size="+1"><b>METADATA_BLOCK_DATA</b></font></a>
466                         </td>
467                 </tr>
468                 <tr>
469                         <td align="right" valign="top" bgcolor="#F4F4CC">
470                                 <a href="#metadata_block_streaminfo"><i>METADATA_BLOCK_STREAMINFO</i></a><br />
471                                 || <a href="#metadata_block_padding"><i>METADATA_BLOCK_PADDING</i></a><br />
472                                 || <a href="#metadata_block_application"><i>METADATA_BLOCK_APPLICATION</i></a><br />
473                                 || <a href="#metadata_block_seektable"><i>METADATA_BLOCK_SEEKTABLE</i></a><br />
474                                 || <a href="#metadata_block_vorbis_comment"><i>METADATA_BLOCK_VORBIS_COMMENT</i></a><br />
475                                 || <a href="#metadata_block_cuesheet"><i>METADATA_BLOCK_CUESHEET</i></a><br />
476                                 || <a href="#metadata_block_picture"><i>METADATA_BLOCK_PICTURE</i></a>
477                         </td>
478                         <td>
479                                 The block data must match the block type in the block header.
480                         </td>
481                 </tr>
482         </table>
483         </td></tr></table>
484 </div>
485
486 <br />
487
488 <div class="box">
489         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
490         <table width="100%" border="1">
491                 <tr>
492                         <td colspan="2" bgcolor="#D3D4C5">
493                                 <a name="metadata_block_streaminfo"><font size="+1"><b>METADATA_BLOCK_STREAMINFO</b></font></a>
494                         </td>
495                 </tr>
496                 <tr>
497                         <td align="right" valign="top" bgcolor="#F4F4CC">
498                                 &lt;16&gt;
499                         </td>
500                         <td>
501                                 The minimum block size (in samples) used in the stream.
502                         </td>
503                 </tr>
504                 <tr>
505                         <td align="right" valign="top" bgcolor="#F4F4CC">
506                                 &lt;16&gt;
507                         </td>
508                         <td>
509                                 The maximum block size (in samples) used in the stream.  (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
510                         </td>
511                 </tr>
512                 <tr>
513                         <td align="right" valign="top" bgcolor="#F4F4CC">
514                                 &lt;24&gt;
515                         </td>
516                         <td>
517                                 The minimum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
518                         </td>
519                 </tr>
520                 <tr>
521                         <td align="right" valign="top" bgcolor="#F4F4CC">
522                                 &lt;24&gt;
523                         </td>
524                         <td>
525                                 The maximum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
526                         </td>
527                 </tr>
528                 <tr>
529                         <td align="right" valign="top" bgcolor="#F4F4CC">
530                                 &lt;20&gt;
531                         </td>
532                         <td>
533                                 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.
534                         </td>
535                 </tr>
536                 <tr>
537                         <td align="right" valign="top" bgcolor="#F4F4CC">
538                                 &lt;3&gt;
539                         </td>
540                         <td>
541                                 (number of channels)-1.  FLAC supports from 1 to 8 channels
542                         </td>
543                 </tr>
544                 <tr>
545                         <td align="right" valign="top" bgcolor="#F4F4CC">
546                                 &lt;5&gt;
547                         </td>
548                         <td>
549                                 (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.
550                         </td>
551                 </tr>
552                 <tr>
553                         <td align="right" valign="top" bgcolor="#F4F4CC">
554                                 &lt;36&gt;
555                         </td>
556                         <td>
557                                 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.
558                         </td>
559                 </tr>
560                 <tr>
561                         <td align="right" valign="top" bgcolor="#F4F4CC">
562                                 &lt;128&gt;
563                         </td>
564                         <td>
565                                 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.
566                         </td>
567                 </tr>
568                 <tr>
569                         <td>
570                         </td>
571                         <td bgcolor="#F4F4CC">
572                                 <font size="+1">NOTES</font><br />
573                                 <ul>
574                                 <li>
575                                         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.
576                                 </li>
577                                 </ul>
578                         </td>
579                 </tr>
580         </table>
581         </td></tr></table>
582 </div>
583
584 <br />
585
586 <div class="box">
587         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
588         <table width="100%" border="1">
589                 <tr>
590                         <td colspan="2" bgcolor="#D3D4C5">
591                                 <a name="metadata_block_padding"><font size="+1"><b>METADATA_BLOCK_PADDING</b></font></a>
592                         </td>
593                 </tr>
594                 <tr>
595                         <td align="right" valign="top" bgcolor="#F4F4CC">
596                                 &lt;n&gt;
597                         </td>
598                         <td>
599                                 n '0' bits (n must be a multiple of 8)
600                         </td>
601                 </tr>
602         </table>
603         </td></tr></table>
604 </div>
605
606 <br />
607
608 <div class="box">
609         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
610         <table width="100%" border="1">
611                 <tr>
612                         <td colspan="2" bgcolor="#D3D4C5">
613                                 <a name="metadata_block_application"><font size="+1"><b>METADATA_BLOCK_APPLICATION</b></font></a>
614                         </td>
615                 </tr>
616                 <tr>
617                         <td align="right" valign="top" bgcolor="#F4F4CC">
618                                 &lt;32&gt;
619                         </td>
620                         <td>
621                                 Registered application ID.  (Visit the <a href="id.html">registration page</a> to register an ID with FLAC.)
622                         </td>
623                 </tr>
624                 <tr>
625                         <td align="right" valign="top" bgcolor="#F4F4CC">
626                                 &lt;n&gt;
627                         </td>
628                         <td>
629                                 Application data (n must be a multiple of 8)
630                         </td>
631                 </tr>
632         </table>
633         </td></tr></table>
634 </div>
635
636 <br />
637
638 <div class="box">
639         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
640         <table width="100%" border="1">
641                 <tr>
642                         <td colspan="2" bgcolor="#D3D4C5">
643                                 <a name="metadata_block_seektable"><font size="+1"><b>METADATA_BLOCK_SEEKTABLE</b></font></a>
644                         </td>
645                 </tr>
646                 <tr>
647                         <td align="right" valign="top" bgcolor="#F4F4CC">
648                                 <a href="#seekpoint"><i>SEEKPOINT</i></a>+
649                         </td>
650                         <td>
651                                 One or more seek points.
652                         </td>
653                 </tr>
654                 <tr>
655                         <td>
656                         </td>
657                         <td bgcolor="#F4F4CC">
658                                 <font size="+1">NOTE</font><br />
659                                 <ul>
660                                 <li>
661                                         The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
662                                 </li>
663                                 </ul>
664                         </td>
665                 </tr>
666         </table>
667         </td></tr></table>
668 </div>
669
670 <br />
671
672 <div class="box">
673         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
674         <table width="100%" border="1">
675                 <tr>
676                         <td colspan="2" bgcolor="#D3D4C5">
677                                 <a name="seekpoint"><font size="+1"><b>SEEKPOINT</b></font></a>
678                         </td>
679                 </tr>
680                 <tr>
681                         <td align="right" valign="top" bgcolor="#F4F4CC">
682                                 &lt;64&gt;
683                         </td>
684                         <td>
685                                 Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
686                         </td>
687                 </tr>
688                 <tr>
689                         <td align="right" valign="top" bgcolor="#F4F4CC">
690                                 &lt;64&gt;
691                         </td>
692                         <td>
693                                 Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
694                         </td>
695                 </tr>
696                 <tr>
697                         <td align="right" valign="top" bgcolor="#F4F4CC">
698                                 &lt;16&gt;
699                         </td>
700                         <td>
701                                 Number of samples in the target frame.
702                         </td>
703                 </tr>
704                 <tr>
705                         <td>
706                         </td>
707                         <td bgcolor="#F4F4CC">
708                                 <font size="+1">NOTES</font><br />
709                                 <ul>
710                                 <li>
711                                         For placeholder points, the second and third field values are undefined.
712                                 </li>
713                                 <li>
714                                         Seek points within a table must be sorted in ascending order by sample number.
715                                 </li>
716                                 <li>
717                                         Seek points within a table must be unique by sample number, with the exception of placeholder points.
718                                 </li>
719                                 <li>
720                                         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.
721                                 </li>
722                                 </ul>
723                         </td>
724                 </tr>
725         </table>
726         </td></tr></table>
727 </div>
728
729 <br />
730
731 <div class="box">
732         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
733         <table width="100%" border="1">
734                 <tr>
735                         <td colspan="2" bgcolor="#D3D4C5">
736                                 <a name="metadata_block_vorbis_comment"><font size="+1"><b>METADATA_BLOCK_VORBIS_COMMENT</b></font></a>
737                         </td>
738                 </tr>
739                 <tr>
740                         <td align="right" valign="top" bgcolor="#F4F4CC">
741                                 &lt;n&gt;
742                         </td>
743                         <td>
744                                 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.
745                         </td>
746                 </tr>
747         </table>
748         </td></tr></table>
749 </div>
750
751 <br />
752
753 <div class="box">
754         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
755         <table width="100%" border="1">
756                 <tr>
757                         <td colspan="2" bgcolor="#D3D4C5">
758                                 <a name="metadata_block_cuesheet"><font size="+1"><b>METADATA_BLOCK_CUESHEET</b></font></a>
759                         </td>
760                 </tr>
761                 <tr>
762                         <td align="right" valign="top" bgcolor="#F4F4CC">
763                                 &lt;128*8&gt;
764                         </td>
765                         <td>
766                                 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.
767                         </td>
768                 </tr>
769                 <tr>
770                         <td align="right" valign="top" bgcolor="#F4F4CC">
771                                 &lt;64&gt;
772                         </td>
773                         <td>
774                                 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.
775                         </td>
776                 </tr>
777                 <tr>
778                         <td align="right" valign="top" bgcolor="#F4F4CC">
779                                 &lt;1&gt;
780                         </td>
781                         <td>
782                                 <tt>1</tt> if the CUESHEET corresponds to a Compact Disc, else <tt>0</tt>.
783                         </td>
784                 </tr>
785                 <tr>
786                         <td align="right" valign="top" bgcolor="#F4F4CC">
787                                 &lt;7+258*8&gt;
788                         </td>
789                         <td>
790                                 Reserved.  All bits must be set to zero.
791                         </td>
792                 </tr>
793                 <tr>
794                         <td align="right" valign="top" bgcolor="#F4F4CC">
795                                 &lt;8&gt;
796                         </td>
797                         <td>
798                                 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).
799                         </td>
800                 </tr>
801                 <tr>
802                         <td align="right" valign="top" bgcolor="#F4F4CC">
803                                 <a href="#cuesheet_track"><i>CUESHEET_TRACK</i></a>+
804                         </td>
805                         <td>
806                                 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.
807                         </td>
808                 </tr>
809         </table>
810         </td></tr></table>
811 </div>
812
813 <br />
814
815 <div class="box">
816         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
817         <table width="100%" border="1">
818                 <tr>
819                         <td colspan="2" bgcolor="#D3D4C5">
820                                 <a name="cuesheet_track"><font size="+1"><b>CUESHEET_TRACK</b></font></a>
821                         </td>
822                 </tr>
823                 <tr>
824                         <td align="right" valign="top" bgcolor="#F4F4CC">
825                                 &lt;64&gt;
826                         </td>
827                         <td>
828                                 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).
829                         </td>
830                 </tr>
831                 <tr>
832                         <td align="right" valign="top" bgcolor="#F4F4CC">
833                                 &lt;8&gt;
834                         </td>
835                         <td>
836                                 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.
837                         </td>
838                 </tr>
839                 <tr>
840                         <td align="right" valign="top" bgcolor="#F4F4CC">
841                                 &lt;12*8&gt;
842                         </td>
843                         <td>
844                                 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.
845                         </td>
846                 </tr>
847                 <tr>
848                         <td align="right" valign="top" bgcolor="#F4F4CC">
849                                 &lt;1&gt;
850                         </td>
851                         <td>
852                                 The track type: 0 for audio, 1 for non-audio.  This corresponds to the CD-DA Q-channel control bit 3.
853                         </td>
854                 </tr>
855                 <tr>
856                         <td align="right" valign="top" bgcolor="#F4F4CC">
857                                 &lt;1&gt;
858                         </td>
859                         <td>
860                                 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>.
861                         </td>
862                 </tr>
863                 <tr>
864                         <td align="right" valign="top" bgcolor="#F4F4CC">
865                                 &lt;6+13*8&gt;
866                         </td>
867                         <td>
868                                 Reserved.  All bits must be set to zero.
869                         </td>
870                 </tr>
871                 <tr>
872                         <td align="right" valign="top" bgcolor="#F4F4CC">
873                                 &lt;8&gt;
874                         </td>
875                         <td>
876                                 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.
877                         </td>
878                 </tr>
879                 <tr>
880                         <td align="right" valign="top" bgcolor="#F4F4CC">
881                                 <a href="#cuesheet_track_index"><i>CUESHEET_TRACK_INDEX</i></a>+
882                         </td>
883                         <td>
884                                 For all tracks except the lead-out track, one or more track index points.
885                         </td>
886                 </tr>
887         </table>
888         </td></tr></table>
889 </div>
890
891 <br />
892
893 <div class="box">
894         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
895         <table width="100%" border="1">
896                 <tr>
897                         <td colspan="2" bgcolor="#D3D4C5">
898                                 <a name="cuesheet_track_index"><font size="+1"><b>CUESHEET_TRACK_INDEX</b></font></a>
899                         </td>
900                 </tr>
901                 <tr>
902                         <td align="right" valign="top" bgcolor="#F4F4CC">
903                                 &lt;64&gt;
904                         </td>
905                         <td>
906                                 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.
907                         </td>
908                 </tr>
909                 <tr>
910                         <td align="right" valign="top" bgcolor="#F4F4CC">
911                                 &lt;8&gt;
912                         </td>
913                         <td>
914                                 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.
915                         </td>
916                 </tr>
917                 <tr>
918                         <td align="right" valign="top" bgcolor="#F4F4CC">
919                                 &lt;3*8&gt;
920                         </td>
921                         <td>
922                                 Reserved.  All bits must be set to zero.
923                         </td>
924                 </tr>
925         </table>
926         </td></tr></table>
927 </div>
928
929 <br />
930
931 <div class="box">
932         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
933         <table width="100%" border="1">
934                 <tr>
935                         <td colspan="2" bgcolor="#D3D4C5">
936                                 <a name="metadata_block_picture"><font size="+1"><b>METADATA_BLOCK_PICTURE</b></font></a>
937                         </td>
938                 </tr>
939                 <tr>
940                         <td align="right" valign="top" bgcolor="#F4F4CC">
941                                 &lt;32&gt;
942                         </td>
943                         <td>
944                                 The picture type according to the ID3v2 APIC frame:<br />
945                                 <ul>
946                                         <li>0 - Other</li>
947                                         <li>1 - 32x32 pixels 'file icon' (PNG only)</li>
948                                         <li>2 - Other file icon</li>
949                                         <li>3 - Cover (front)</li>
950                                         <li>4 - Cover (back)</li>
951                                         <li>5 - Leaflet page</li>
952                                         <li>6 - Media (e.g. label side of CD)</li>
953                                         <li>7 - Lead artist/lead performer/soloist</li>
954                                         <li>8 - Artist/performer</li>
955                                         <li>9 - Conductor</li>
956                                         <li>10 - Band/Orchestra</li>
957                                         <li>11 - Composer</li>
958                                         <li>12 - Lyricist/text writer</li>
959                                         <li>13 - Recording Location</li>
960                                         <li>14 - During recording</li>
961                                         <li>15 - During performance</li>
962                                         <li>16 - Movie/video screen capture</li>
963                                         <li>17 - A bright coloured fish</li>
964                                         <li>18 - Illustration</li>
965                                         <li>19 - Band/artist logotype</li>
966                                         <li>20 - Publisher/Studio logotype</li>
967                                 </ul>
968                                 Others are reserved and should not be used.  There may only be one each of picture type 1 and 2 in a file.
969                         </td>
970                 </tr>
971                 <tr>
972                         <td align="right" valign="top" bgcolor="#F4F4CC">
973                                 &lt;32&gt;
974                         </td>
975                         <td>
976                                 The length of the MIME type string in bytes.
977                         </td>
978                 </tr>
979                 <tr>
980                         <td align="right" valign="top" bgcolor="#F4F4CC">
981                                 &lt;n*8&gt;
982                         </td>
983                         <td>
984                                 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.
985                         </td>
986                 </tr>
987                 <tr>
988                         <td align="right" valign="top" bgcolor="#F4F4CC">
989                                 &lt;32&gt;
990                         </td>
991                         <td>
992                                 The length of the description string in bytes.
993                         </td>
994                 </tr>
995                 <tr>
996                         <td align="right" valign="top" bgcolor="#F4F4CC">
997                                 &lt;n*8&gt;
998                         </td>
999                         <td>
1000                                 The description of the picture, in UTF-8.
1001                         </td>
1002                 </tr>
1003                 <tr>
1004                         <td align="right" valign="top" bgcolor="#F4F4CC">
1005                                 &lt;32&gt;
1006                         </td>
1007                         <td>
1008                                 The width of the picture in pixels.
1009                         </td>
1010                 </tr>
1011                 <tr>
1012                         <td align="right" valign="top" bgcolor="#F4F4CC">
1013                                 &lt;32&gt;
1014                         </td>
1015                         <td>
1016                                 The height of the picture in pixels.
1017                         </td>
1018                 </tr>
1019                 <tr>
1020                         <td align="right" valign="top" bgcolor="#F4F4CC">
1021                                 &lt;32&gt;
1022                         </td>
1023                         <td>
1024                                 The color depth of the picture in bits-per-pixel.
1025                         </td>
1026                 </tr>
1027                 <tr>
1028                         <td align="right" valign="top" bgcolor="#F4F4CC">
1029                                 &lt;32&gt;
1030                         </td>
1031                         <td>
1032                                 For indexed-color pictures (e.g. GIF), the number of colors used, or <tt>0</tt> for non-indexed pictures.
1033                         </td>
1034                 </tr>
1035                 <tr>
1036                         <td align="right" valign="top" bgcolor="#F4F4CC">
1037                                 &lt;32&gt;
1038                         </td>
1039                         <td>
1040                                 The length of the picture data in bytes.
1041                         </td>
1042                 </tr>
1043                 <tr>
1044                         <td align="right" valign="top" bgcolor="#F4F4CC">
1045                                 &lt;n*8&gt;
1046                         </td>
1047                         <td>
1048                                 The binary picture data.
1049                         </td>
1050                 </tr>
1051         </table>
1052         </td></tr></table>
1053 </div>
1054
1055 <br />
1056
1057 <div class="box">
1058         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1059         <table width="100%" border="1" bgcolor="#EEEED4">
1060                 <tr>
1061                         <td colspan="2" bgcolor="#D3D4C5">
1062                                 <a name="frame"><font size="+1"><b>FRAME</b></font></a>
1063                         </td>
1064                 </tr>
1065                 <tr>
1066                         <td align="right" valign="top" bgcolor="#F4F4CC">
1067                                 <a href="#frame_header"><i>FRAME_HEADER</i></a>
1068                         </td>
1069                         <td>
1070                                 &nbsp;
1071                         </td>
1072                 </tr>
1073                 <tr>
1074                         <td align="right" valign="top" bgcolor="#F4F4CC">
1075                                 <a href="#subframe"><i>SUBFRAME</i></a>+
1076                         </td>
1077                         <td>
1078                                 One SUBFRAME per channel.
1079                         </td>
1080                 </tr>
1081                 <tr>
1082                         <td align="right" valign="top" bgcolor="#F4F4CC">
1083                                 &lt;?&gt;
1084                         </td>
1085                         <td>
1086                                 Zero-padding to byte alignment.
1087                         </td>
1088                 </tr>
1089                 <tr>
1090                         <td align="right" valign="top" bgcolor="#F4F4CC">
1091                                 <a href="#frame_footer"><i>FRAME_FOOTER</i></a>
1092                         </td>
1093                         <td>
1094                                 &nbsp;
1095                         </td>
1096                 </tr>
1097         </table>
1098         </td></tr></table>
1099 </div>
1100
1101 <br />
1102
1103 <div class="box">
1104         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1105         <table width="100%" border="1" bgcolor="#EEEED4">
1106                 <tr>
1107                         <td colspan="2" bgcolor="#D3D4C5">
1108                                 <a name="frame_header"><font size="+1"><b>FRAME_HEADER</b></font></a>
1109                         </td>
1110                 </tr>
1111                 <tr>
1112                         <td align="right" valign="top" bgcolor="#F4F4CC">
1113                                 &lt;14&gt;
1114                         </td>
1115                         <td>
1116                                 Sync code '<tt>11111111111110</tt>'
1117                         </td>
1118                 </tr>
1119                 <tr>
1120                         <td align="right" valign="top" bgcolor="#F4F4CC">
1121                                 &lt;1&gt;
1122                         </td>
1123                         <td>
1124                                 Reserved: <a href="#frame_header_notes">[1]</a><br />
1125                                 <ul>
1126                                 <li>
1127                                         <tt>0</tt> : mandatory value
1128                                 </li>
1129                                 <li>
1130                                         <tt>1</tt> : reserved for future use
1131                                 </li>
1132                                 </ul>
1133                         </td>
1134                 </tr>
1135                 <tr>
1136                         <td align="right" valign="top" bgcolor="#F4F4CC">
1137                                 &lt;1&gt;
1138                         </td>
1139                         <td>
1140                                 Blocking strategy: <a href="#frame_header_notes">[2]</a> <a href="#frame_header_notes">[3]</a><br />
1141                                 <ul>
1142                                 <li>
1143                                         <tt>0</tt> : fixed-blocksize stream; frame header encodes the frame number
1144                                 </li>
1145                                 <li>
1146                                         <tt>1</tt> : variable-blocksize stream; frame header encodes the sample number
1147                                 </li>
1148                                 </ul>
1149                         </td>
1150                 </tr>
1151                 <tr>
1152                         <td align="right" valign="top" bgcolor="#F4F4CC">
1153                                 &lt;4&gt;
1154                         </td>
1155                         <td>
1156                                 Block size in inter-channel samples:<br />
1157                                 <ul>
1158                                 <li>
1159                                         <tt>0000</tt> : reserved
1160                                 </li>
1161                                 <li>
1162                                         <tt>0001</tt> : 192 samples
1163                                 </li>
1164                                 <li>
1165                                         <tt>0010-0101</tt> : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
1166                                 </li>
1167                                 <li>
1168                                         <tt>0110</tt> : get 8 bit (blocksize-1) from end of header
1169                                 </li>
1170                                 <li>
1171                                         <tt>0111</tt> : get 16 bit (blocksize-1) from end of header
1172                                 </li>
1173                                 <li>
1174                                         <tt>1000-1111</tt> : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
1175                                 </li>
1176                                 </ul>
1177                         </td>
1178                 </tr>
1179                 <tr>
1180                         <td align="right" valign="top" bgcolor="#F4F4CC">
1181                                 &lt;4&gt;
1182                         </td>
1183                         <td>
1184                                 Sample rate:<br />
1185                                 <ul>
1186                                 <li>
1187                                         <tt>0000</tt> : get from STREAMINFO metadata block
1188                                 </li>
1189                                 <li>
1190                                         <tt>0001</tt> : 88.2kHz
1191                                 </li>
1192                                 <li>
1193                                         <tt>0010</tt> : 176.4kHz
1194                                 </li>
1195                                 <li>
1196                                         <tt>0011</tt> : 192kHz
1197                                 </li>
1198                                 <li>
1199                                         <tt>0100</tt> : 8kHz
1200                                 </li>
1201                                 <li>
1202                                         <tt>0101</tt> : 16kHz
1203                                 </li>
1204                                 <li>
1205                                         <tt>0110</tt> : 22.05kHz
1206                                 </li>
1207                                 <li>
1208                                         <tt>0111</tt> : 24kHz
1209                                 </li>
1210                                 <li>
1211                                         <tt>1000</tt> : 32kHz
1212                                 </li>
1213                                 <li>
1214                                         <tt>1001</tt> : 44.1kHz
1215                                 </li>
1216                                 <li>
1217                                         <tt>1010</tt> : 48kHz
1218                                 </li>
1219                                 <li>
1220                                         <tt>1011</tt> : 96kHz
1221                                 </li>
1222                                 <li>
1223                                         <tt>1100</tt> : get 8 bit sample rate (in kHz) from end of header
1224                                 </li>
1225                                 <li>
1226                                         <tt>1101</tt> : get 16 bit sample rate (in Hz) from end of header
1227                                 </li>
1228                                 <li>
1229                                         <tt>1110</tt> : get 16 bit sample rate (in tens of Hz) from end of header
1230                                 </li>
1231                                 <li>
1232                                         <tt>1111</tt> : invalid, to prevent sync-fooling string of 1s
1233                                 </li>
1234                                 </ul>
1235                         </td>
1236                 </tr>
1237                 <tr>
1238                         <td align="right" valign="top" bgcolor="#F4F4CC">
1239                                 &lt;4&gt;
1240                         </td>
1241                         <td>
1242                                 Channel assignment
1243                                 <ul>
1244                                 <li>
1245                                         <tt>0000-0111</tt> : (number of independent channels)-1.  Where defined, the channel order follows SMPTE/ITU-R recommendations.  The assignments are as follows:
1246                                         <ul>
1247                                                 <li>1 channel: mono</li>
1248                                                 <li>2 channels: left, right</li>
1249                                                 <li>3 channels: left, right, center</li>
1250                                                 <li>4 channels: left, right, back left, back right</li>
1251                                                 <li>5 channels: left, right, center, back/surround left, back/surround right</li>
1252                                                 <li>6 channels: left, right, center, LFE, back/surround left, back/surround right</li>
1253                                                 <li>7 channels: not defined</li>
1254                                                 <li>8 channels: not defined</li>
1255                                         </ul>
1256                                 </li>
1257                                 <li>
1258                                         <tt>1000</tt> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
1259                                 </li>
1260                                 <li>
1261                                         <tt>1001</tt> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
1262                                 </li>
1263                                 <li>
1264                                         <tt>1010</tt> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
1265                                 </li>
1266                                 <li>
1267                                         <tt>1011-1111</tt> : reserved
1268                                 </li>
1269                                 </ul>
1270                         </td>
1271                 </tr>
1272                 <tr>
1273                         <td align="right" valign="top" bgcolor="#F4F4CC">
1274                                 &lt;3&gt;
1275                         </td>
1276                         <td>
1277                                 Sample size in bits:<br />
1278                                 <ul>
1279                                 <li>
1280                                         <tt>000</tt> : get from STREAMINFO metadata block
1281                                 </li>
1282                                 <li>
1283                                         <tt>001</tt> : 8 bits per sample
1284                                 </li>
1285                                 <li>
1286                                         <tt>010</tt> : 12 bits per sample
1287                                 </li>
1288                                 <li>
1289                                         <tt>011</tt> : reserved
1290                                 </li>
1291                                 <li>
1292                                         <tt>100</tt> : 16 bits per sample
1293                                 </li>
1294                                 <li>
1295                                         <tt>101</tt> : 20 bits per sample
1296                                 </li>
1297                                 <li>
1298                                         <tt>110</tt> : 24 bits per sample
1299                                 </li>
1300                                 <li>
1301                                         <tt>111</tt> : reserved
1302                                 </li>
1303                                 </ul>
1304                         </td>
1305                 </tr>
1306                 <tr>
1307                         <td align="right" valign="top" bgcolor="#F4F4CC">
1308                                 &lt;1&gt;
1309                         </td>
1310                         <td>
1311                                 Reserved:<br />
1312                                 <ul>
1313                                 <li>
1314                                         <tt>0</tt> : mandatory value
1315                                 </li>
1316                                 <li>
1317                                         <tt>1</tt> : reserved for future use
1318                                 </li>
1319                                 </ul>
1320                         </td>
1321                 </tr>
1322                 <tr>
1323                         <td align="right" valign="top" bgcolor="#F4F4CC">
1324                                 &lt;?&gt;
1325                         </td>
1326                         <td>
1327                                 if(variable blocksize)<br />
1328                                 &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 />
1329                                 else<br />
1330                                 &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits) <a href="#frame_header_notes">[4]</a>
1331                         </td>
1332                 </tr>
1333                 <tr>
1334                         <td align="right" valign="top" bgcolor="#F4F4CC">
1335                                 &lt;?&gt;
1336                         </td>
1337                         <td>
1338                                 if(blocksize bits == 011x)<br />
1339                                 &nbsp;&nbsp;&nbsp;8/16 bit (blocksize-1)
1340                         </td>
1341                 </tr>
1342                 <tr>
1343                         <td align="right" valign="top" bgcolor="#F4F4CC">
1344                                 &lt;?&gt;
1345                         </td>
1346                         <td>
1347                                 if(sample rate bits == 11xx)<br />
1348                                 &nbsp;&nbsp;&nbsp;8/16 bit sample rate
1349                         </td>
1350                 </tr>
1351                 <tr>
1352                         <td align="right" valign="top" bgcolor="#F4F4CC">
1353                                 &lt;8&gt;
1354                         </td>
1355                         <td>
1356                                 CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
1357                         </td>
1358                 </tr>
1359                 <tr>
1360                         <td>
1361                         </td>
1362                         <td bgcolor="#F4F4CC">
1363                                 <a name="frame_header_notes"><font size="+1">NOTES</font></a><br />
1364                                 <ol>
1365                                 <li>
1366                                         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>).
1367                                 </li>
1368                                 <li>
1369                                         The "blocking strategy" bit must be the same throughout the entire stream.
1370                                 </li>
1371                                 <li>
1372                                         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).
1373                                 </li>
1374                                 <li>
1375                                         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.
1376                                 </li>
1377                                 </ol>
1378                         </td>
1379                 </tr>
1380         </table>
1381         </td></tr></table>
1382 </div>
1383
1384 <br />
1385
1386 <div class="box">
1387         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1388         <table width="100%" border="1" bgcolor="#EEEED4">
1389                 <tr>
1390                         <td colspan="2" bgcolor="#D3D4C5">
1391                                 <a name="frame_footer"><font size="+1"><b>FRAME_FOOTER</b></font></a>
1392                         </td>
1393                 </tr>
1394                 <tr>
1395                         <td align="right" valign="top" bgcolor="#F4F4CC">
1396                                 &lt;16&gt;
1397                         </td>
1398                         <td>
1399                                 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
1400                         </td>
1401                 </tr>
1402         </table>
1403         </td></tr></table>
1404 </div>
1405
1406 <br />
1407
1408 <div class="box">
1409         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1410         <table width="100%" border="1" bgcolor="#EEEED4">
1411                 <tr>
1412                         <td colspan="2" bgcolor="#D3D4C5">
1413                                 <a name="subframe"><font size="+1"><b>SUBFRAME</b></font></a>
1414                         </td>
1415                 </tr>
1416                 <tr>
1417                         <td align="right" valign="top" bgcolor="#F4F4CC">
1418                                 <a href="#subframe_header"><i>SUBFRAME_HEADER</i></a>
1419                         </td>
1420                         <td>
1421                                 &nbsp;
1422                         </td>
1423                 </tr>
1424                 <tr>
1425                         <td align="right" valign="top" bgcolor="#F4F4CC">
1426                                 <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>
1427                         </td>
1428                         <td valign="top">
1429                                 The SUBFRAME_HEADER specifies which one.
1430                         </td>
1431                 </tr>
1432         </table>
1433         </td></tr></table>
1434 </div>
1435
1436 <br />
1437
1438 <div class="box">
1439         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1440         <table width="100%" border="1" bgcolor="#EEEED4">
1441                 <tr>
1442                         <td colspan="2" bgcolor="#D3D4C5">
1443                                 <a name="subframe_header"><font size="+1"><b>SUBFRAME_HEADER</b></font></a>
1444                         </td>
1445                 </tr>
1446                 <tr>
1447                         <td align="right" valign="top" bgcolor="#F4F4CC">
1448                                 &lt;1&gt;
1449                         </td>
1450                         <td>
1451                                 Zero bit padding, to prevent sync-fooling string of 1s
1452                         </td>
1453                 </tr>
1454                 <tr>
1455                         <td align="right" valign="top" bgcolor="#F4F4CC">
1456                                 &lt;6&gt;
1457                         </td>
1458                         <td>
1459                                 Subframe type:
1460                                 <ul>
1461                                 <li>
1462                                         <tt>000000</tt> : <a href="#subframe_constant">SUBFRAME_CONSTANT</a>
1463                                 </li>
1464                                 <li>
1465                                         <tt>000001</tt> : <a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
1466                                 </li>
1467                                 <li>
1468                                         <tt>00001x</tt> : reserved
1469                                 </li>
1470                                 <li>
1471                                         <tt>0001xx</tt> : reserved
1472                                 </li>
1473                                 <li>
1474                                         <tt>001xxx</tt> : if(xxx &lt;= 4) <a href="#subframe_fixed">SUBFRAME_FIXED</a>, xxx=order ; else reserved
1475                                 </li>
1476                                 <li>
1477                                         <tt>01xxxx</tt> : reserved
1478                                 </li>
1479                                 <li>
1480                                         <tt>1xxxxx</tt> : <a href="#subframe_lpc">SUBFRAME_LPC</a>, xxxxx=order-1
1481                                 </li>
1482                                 </ul>
1483                         </td>
1484                 </tr>
1485                 <tr>
1486                         <td align="right" valign="top" bgcolor="#F4F4CC">
1487                                 &lt;1+k&gt;
1488                         </td>
1489                         <td>
1490                                 'Wasted bits-per-sample' flag:
1491                                 <ul>
1492                                 <li>
1493                                         <tt>0</tt> : no wasted bits-per-sample in source subblock, k=0
1494                                 </li>
1495                                 <li>
1496                                         <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.
1497                                 </li>
1498                                 </ul>
1499                         </td>
1500                 </tr>
1501         </table>
1502         </td></tr></table>
1503 </div>
1504
1505 <br />
1506
1507 <div class="box">
1508         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1509         <table width="100%" border="1" bgcolor="#EEEED4">
1510                 <tr>
1511                         <td colspan="2" bgcolor="#D3D4C5">
1512                                 <a name="subframe_constant"><font size="+1"><b>SUBFRAME_CONSTANT</b></font></a>
1513                         </td>
1514                 </tr>
1515                 <tr>
1516                         <td align="right" valign="top" bgcolor="#F4F4CC">
1517                                 &lt;n&gt;
1518                         </td>
1519                         <td>
1520                                 Unencoded constant value of the subblock, n = frame's bits-per-sample.
1521                         </td>
1522                 </tr>
1523         </table>
1524         </td></tr></table>
1525 </div>
1526
1527 <br />
1528
1529 <div class="box">
1530         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1531         <table width="100%" border="1" bgcolor="#EEEED4">
1532                 <tr>
1533                         <td colspan="2" bgcolor="#D3D4C5">
1534                                 <a name="subframe_fixed"><font size="+1"><b>SUBFRAME_FIXED</b></font></a>
1535                         </td>
1536                 </tr>
1537                 <tr>
1538                         <td align="right" valign="top" bgcolor="#F4F4CC">
1539                                 &lt;n&gt;
1540                         </td>
1541                         <td>
1542                                 Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
1543                         </td>
1544                 </tr>
1545                 <tr>
1546                         <td align="right" valign="top" bgcolor="#F4F4CC">
1547                                 <a href="#residual"><i>RESIDUAL</i></a>
1548                         </td>
1549                         <td>
1550                                 Encoded residual
1551                         </td>
1552                 </tr>
1553         </table>
1554         </td></tr></table>
1555 </div>
1556
1557 <br />
1558
1559 <div class="box">
1560         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1561         <table width="100%" border="1" bgcolor="#EEEED4">
1562                 <tr>
1563                         <td colspan="2" bgcolor="#D3D4C5">
1564                                 <a name="subframe_lpc"><font size="+1"><b>SUBFRAME_LPC</b></font></a>
1565                         </td>
1566                 </tr>
1567                 <tr>
1568                         <td align="right" valign="top" bgcolor="#F4F4CC">
1569                                 &lt;n&gt;
1570                         </td>
1571                         <td>
1572                                 Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
1573                         </td>
1574                 </tr>
1575                 <tr>
1576                         <td align="right" valign="top" bgcolor="#F4F4CC">
1577                                 &lt;4&gt;
1578                         </td>
1579                         <td>
1580                                 (Quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
1581                         </td>
1582                 </tr>
1583                 <tr>
1584                         <td align="right" valign="top" bgcolor="#F4F4CC">
1585                                 &lt;5&gt;
1586                         </td>
1587                         <td>
1588                                 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement).
1589                         </td>
1590                 </tr>
1591                 <tr>
1592                         <td align="right" valign="top" bgcolor="#F4F4CC">
1593                                 &lt;n&gt;
1594                         </td>
1595                         <td>
1596                                 Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
1597                         </td>
1598                 </tr>
1599                 <tr>
1600                         <td align="right" valign="top" bgcolor="#F4F4CC">
1601                                 <a href="#residual"><i>RESIDUAL</i></a>
1602                         </td>
1603                         <td>
1604                                 Encoded residual
1605                         </td>
1606                 </tr>
1607         </table>
1608         </td></tr></table>
1609 </div>
1610
1611 <br />
1612
1613 <div class="box">
1614         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1615         <table width="100%" border="1" bgcolor="#EEEED4">
1616                 <tr>
1617                         <td colspan="2" bgcolor="#D3D4C5">
1618                                 <a name="subframe_verbatim"><font size="+1"><b>SUBFRAME_VERBATIM</b></font></a>
1619                         </td>
1620                 </tr>
1621                 <tr>
1622                         <td align="right" valign="top" bgcolor="#F4F4CC">
1623                                 &lt;n*i&gt;
1624                         </td>
1625                         <td>
1626                                 Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
1627                         </td>
1628                 </tr>
1629         </table>
1630         </td></tr></table>
1631 </div>
1632
1633 <br />
1634
1635 <div class="box">
1636         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1637         <table width="100%" border="1" bgcolor="#EEEED4">
1638                 <tr>
1639                         <td colspan="2" bgcolor="#D3D4C5">
1640                                 <a name="residual"><font size="+1"><b>RESIDUAL</b></font></a>
1641                         </td>
1642                 </tr>
1643                 <tr>
1644                         <td align="right" valign="top" bgcolor="#F4F4CC">
1645                                 &lt;2&gt;
1646                         </td>
1647                         <td>
1648                                 Residual coding method:<br />
1649                                 <ul>
1650                                 <li>
1651                                         <tt>00</tt> : partitioned Rice coding with 4-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE follows
1652                                 </li>
1653                                 <li>
1654                                         <tt>01</tt> : partitioned Rice coding with 5-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 follows
1655                                 </li>
1656                                 <li>
1657                                         <tt>10-11</tt> : reserved
1658                                 </li>
1659                                 </ul>
1660                         </td>
1661                 </tr>
1662                 <tr>
1663                         <td align="right" valign="top" bgcolor="#F4F4CC">
1664                                 <a href="#partitioned_rice"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</i></a>&nbsp;||<br />
1665                                 <a href="#partitioned_rice2"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</i></a>
1666                         </td>
1667                         <td>
1668                                 &nbsp;
1669                         </td>
1670                 </tr>
1671         </table>
1672         </td></tr></table>
1673 </div>
1674
1675 <br />
1676
1677 <div class="box">
1678         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1679         <table width="100%" border="1" bgcolor="#EEEED4">
1680                 <tr>
1681                         <td colspan="2" bgcolor="#D3D4C5">
1682                                 <a name="partitioned_rice"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</b></font></a>
1683                         </td>
1684                 </tr>
1685                 <tr>
1686                         <td align="right" valign="top" bgcolor="#F4F4CC">
1687                                 &lt;4&gt;
1688                         </td>
1689                         <td>
1690                                 Partition order.
1691                         </td>
1692                 </tr>
1693                 <tr>
1694                         <td align="right" valign="top" bgcolor="#F4F4CC">
1695                                 <a href="#rice_partition"><i>RICE_PARTITION</i></a>+
1696                         </td>
1697                         <td>
1698                                 There will be 2^order partitions.
1699                         </td>
1700                 </tr>
1701         </table>
1702         </td></tr></table>
1703 </div>
1704
1705 <br />
1706
1707 <div class="box">
1708         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1709         <table width="100%" border="1" bgcolor="#EEEED4">
1710                 <tr>
1711                         <td colspan="2" bgcolor="#D3D4C5">
1712                                 <a name="rice_partition"><font size="+1"><b>RICE_PARTITION</b></font></a>
1713                         </td>
1714                 </tr>
1715                 <tr>
1716                         <td align="right" valign="top" bgcolor="#F4F4CC">
1717                                 &lt;4(+5)&gt;
1718                         </td>
1719                         <td>
1720                                 Encoding parameter:<br />
1721                                 <ul>
1722                                 <li>
1723                                         <tt>0000-1110</tt> : Rice parameter.
1724                                 </li>
1725                                 <li>
1726                                         <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.
1727                                 </li>
1728                                 </ul>
1729                         </td>
1730                 </tr>
1731                 <tr>
1732                         <td align="right" valign="top" bgcolor="#F4F4CC">
1733                                 &lt;?&gt;
1734                         </td>
1735                         <td>
1736                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
1737                                 <ul>
1738                                 <li>
1739                                         if the partition order is zero, n = frame's blocksize - predictor order
1740                                 </li>
1741                                 <li>
1742                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1743                                 </li>
1744                                 <li>
1745                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1746                                 </li>
1747                                 </ul>
1748                         </td>
1749                 </tr>
1750         </table>
1751         </td></tr></table>
1752 </div>
1753
1754 <br />
1755
1756 <div class="box">
1757         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1758         <table width="100%" border="1" bgcolor="#EEEED4">
1759                 <tr>
1760                         <td colspan="2" bgcolor="#D3D4C5">
1761                                 <a name="partitioned_rice2"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</b></font></a>
1762                         </td>
1763                 </tr>
1764                 <tr>
1765                         <td align="right" valign="top" bgcolor="#F4F4CC">
1766                                 &lt;4&gt;
1767                         </td>
1768                         <td>
1769                                 Partition order.
1770                         </td>
1771                 </tr>
1772                 <tr>
1773                         <td align="right" valign="top" bgcolor="#F4F4CC">
1774                                 <a href="#rice2_partition"><i>RICE2_PARTITION</i></a>+
1775                         </td>
1776                         <td>
1777                                 There will be 2^order partitions.
1778                         </td>
1779                 </tr>
1780         </table>
1781         </td></tr></table>
1782 </div>
1783
1784 <br />
1785
1786 <div class="box">
1787         <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
1788         <table width="100%" border="1" bgcolor="#EEEED4">
1789                 <tr>
1790                         <td colspan="2" bgcolor="#D3D4C5">
1791                                 <a name="rice2_partition"><font size="+1"><b>RICE2_PARTITION</b></font></a>
1792                         </td>
1793                 </tr>
1794                 <tr>
1795                         <td align="right" valign="top" bgcolor="#F4F4CC">
1796                                 &lt;5(+5)&gt;
1797                         </td>
1798                         <td>
1799                                 Encoding parameter:<br />
1800                                 <ul>
1801                                 <li>
1802                                         <tt>0000-11110</tt> : Rice parameter.
1803                                 </li>
1804                                 <li>
1805                                         <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.
1806                                 </li>
1807                                 </ul>
1808                         </td>
1809                 </tr>
1810                 <tr>
1811                         <td align="right" valign="top" bgcolor="#F4F4CC">
1812                                 &lt;?&gt;
1813                         </td>
1814                         <td>
1815                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
1816                                 <ul>
1817                                 <li>
1818                                         if the partition order is zero, n = frame's blocksize - predictor order
1819                                 </li>
1820                                 <li>
1821                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1822                                 </li>
1823                                 <li>
1824                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1825                                 </li>
1826                                 </ul>
1827                         </td>
1828                 </tr>
1829         </table>
1830         </td></tr></table>
1831 </div>
1832
1833
1834 <div class="copyright">
1835         <!-- @@@ oh so hacky -->
1836         <table>
1837                 <tr>
1838                         <td align="left">
1839                                 Copyright (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
1840                         </td>
1841                         <td width="1%" align="right">
1842                                 <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>
1843                         </td>
1844                         <td width="1%" align="right">
1845                                 <a href="http://www.eff.org/cafe/"><img src="images/cafebug.gif" alt="CAFE Logo" border="0" /></a><br />
1846                         </td>
1847                         <td width="1%" align="right">
1848                                 <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>
1849                         </td>
1850                 </tr>
1851         </table>
1852 </div>
1853
1854 </body>
1855 </html>