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