add link to faq.html in navbar
[platform/upstream/flac.git] / doc / html / format.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <!-- Copyright (c)  2000,2001,2002,2003  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         <TITLE>FLAC - format</TITLE>
11 </HEAD>
12
13 <BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#99CC99" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
14
15 <TABLE BORDER=0 WIDTH="100%" CELLPADDING=1 CELLSPACING=0>
16         <TR>
17                 <TD ALIGN="CENTER" BGCOLOR="#000000"><A HREF="http://flac.sourceforge.net/"><IMG SRC="images/logo.jpg" ALIGN=CENTER ALT="FLAC Logo" BORDER=0 HSPACE=0></a></TD>
18         </TR>
19 </TABLE>
20
21 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#99CC99"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="25" ALT=""></TD></TR></TABLE>
22
23 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
24
25 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
26         <TR>
27                 <TD ALIGN="CENTER" BGCOLOR="#D3D4C5">
28                         <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
29                                 <TR>
30                                         <TD HEIGHT=22 BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="index.html">home</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
31                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="faq.html">faq</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
32                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="news.html">news</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
33                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="download.html">download</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
34                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="features.html">features</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
35                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="goals.html">goals</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
36                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;format&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
37                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="id.html">id</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
38                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="comparison.html">comparison</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
39                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="documentation.html">documentation</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
40                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="developers.html">developers</A>&nbsp;&nbsp;</TD>
41                                 </TR>
42                         </TABLE>
43                 </TD>
44         </TR>
45 </TABLE>
46
47 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
48
49 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
50         <TR>
51                 <TD ALIGN="CENTER" BGCOLOR="#EEEED4">
52                         <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
53                                 <TR>
54                                         <TD HEIGHT=22 BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;english&nbsp;&nbsp;</TD><TD BGCOLOR="#EEEED4" ALIGN=CENTER>|</TD>
55                                         <TD           BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="ru/format.html">russian</A>&nbsp;&nbsp;</TD>
56                                 </TR>
57                         </TABLE>
58                 </TD>
59         </TR>
60 </TABLE>
61
62 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
63
64 <CENTER>
65
66 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#99CC99"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="15" ALT=""></TD></TR></TABLE>
67
68
69 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
70 <TR><TD>
71         <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
72         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
73                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
74                 <B><FONT SIZE="+2">format</FONT></B>
75                 </FONT></TD></TR>
76         </TABLE>
77         <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
78         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
79         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
80         <P>
81                 This is a detailed description of the FLAC format.
82         </P>
83         <P>
84                 First, as the original developer I have to say that I am not a compression expert and I feel obligated to give credit where it is due.  FLAC owes a lot to the many people who have advanced the audio compression field so freely.  For instance:
85         </P>
86         <P>
87         <UL>
88                 <LI>
89                         <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 expands on the fixed predictors used in shorten.
90                 </LI>
91                 <LI>
92                         <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.
93                 </LI>
94                 <LI>
95                         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.
96                 </LI>
97                 <LI>
98                         And of course, the main guy, <A HREF="http://www.digitalcentury.com/encyclo/update/shannon.html">Claude Shannon</A>
99                 </LI>
100         </UL>
101         </P>
102         <P>
103                 <A NAME="scope"><FONT SIZE="+1"><B><U>Scope</U></B></FONT></A>
104         </P>
105         <P>
106                 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.
107         </P>
108         <P>
109                 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.
110         </P>
111         <P>
112                 <A NAME="architecture"><FONT SIZE="+1"><B><U>Architecture</U></B></FONT></A>
113         </P>
114         <P>
115                 Similar to many audio coders, a FLAC encoder has the following stages:
116         </P>
117         <UL>
118                 <P><LI>
119                         <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.
120                 </LI></P>
121                 <P><LI>
122                         <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.
123                 </LI></P>
124                 <P><LI>
125                         <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.
126                 </LI></P>
127                 <LI><P>
128                         <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.
129                 </LI></P>
130         </UL>
131         <P>
132                 In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.
133         </P>
134         <P>
135                 <A NAME="definitions"><FONT SIZE="+1"><B><U>Definitions</U></B></FONT></A>
136         </P>
137         <P>
138                 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.
139         </P>
140         <UL>
141                 <P><LI>
142                         <B>Block</B>: One or more audio samples that span several channels.
143                 </LI></P>
144                 <P><LI>
145                         <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.
146                 </LI></P>
147                 <P><LI>
148                         <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.
149                 </LI></P>
150                 <P><LI>
151                         <B>Frame</B>: A frame header plus one or more subframes.
152                 </LI></P>
153                 <P><LI>
154                         <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.
155                 </LI></P>
156         </UL>
157         <P>
158                 <A NAME="blocking"><FONT SIZE="+1"><B><U>Blocking</U></B></FONT></A>
159         </P>
160         <P>
161                 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.
162         </P>
163         <P>
164                 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.
165         </P>
166         <P>
167                 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.
168         </P>
169         <P>
170                 <A NAME="interchannel"><FONT SIZE="+1"><B><U>Interchannel Decorrelation</U></B></FONT></A>
171         </P>
172         <P>
173                 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.
174         </P>
175         <UL>
176                 <P><LI>
177                         <B>Independent</B>.  The left and right channels are coded independently.
178                 </LI></P>
179                 <P><LI>
180                         <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).
181                 </LI></P>
182                 <P><LI>
183                         <B>Left-side</B>.  The left channel and side channel are coded.
184                 </LI></P>
185                 <P><LI>
186                         <B>Right-side</B>.  The right channel and side channel are coded
187                 </LI></P>
188         </UL>
189         <P>
190                 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.
191         </P>
192         <P>
193                 <A NAME="prediction"><FONT SIZE="+1"><B><U>Prediction</U></B></FONT></A>
194         </P>
195         <P>
196                 FLAC uses four methods for modeling the input signal:
197         </P>
198         <UL>
199                 <P><LI>
200                         <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.
201                 </LI></P>
202                 <P><LI>
203                         <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.
204                 </LI></P>
205                 <P><LI>
206                         <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.
207                 </LI></P>
208                 <P><LI>
209                         <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.
210                 </LI></P>
211         </UL>
212         <P>
213                 <A NAME="residualcoding"><FONT SIZE="+1"><B><U>Residual Coding</U></B></FONT></A>
214         </P>
215         <P>
216                 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.)
217         </P>
218         <P>
219                 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.
220         </P>
221         <P>
222                 <FONT SIZE="+1"><B><U>Format</U></B></FONT>
223         </P>
224         <P>
225                 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.
226         </P>
227         <P>
228                 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.
229         </P>
230         <P>
231                 <A NAME="overview">A FLAC bitstream may be appended with ID3V1 data or prepended with ID3V2 data.  FLAC has no knowledge of such data, but the reference decoder knows how to skip an ID3 tag.</A>
232         </P>
233         <P>
234                 Before the formal description of the stream, an overview might be helpful.
235         </P>
236         <UL>
237                 <P><LI>
238                         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.
239                 </LI></P>
240                 <P><LI>
241                         FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
242                         <UL>
243                                 <LI><A NAME="def_STREAMINFO"><B>STREAMINFO</B>: 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>
244                                 <LI><A NAME="def_APPLICATION"><B>APPLICATION</B>: 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>
245                                 <LI><A NAME="def_PADDING"><B>PADDING</B>: 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 an APPLICATION block will be added after encoding; the user can instruct the encoder to reserve a PADDING block of the proper size so that the application may directly write over it later (which is relatively quick) instead of having to insert the APPLICATION block (which would normally require rewriting the entire file).</LI>
246                                 <LI><A NAME="def_SEEKTABLE"><B>SEEKTABLE</B>: 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>
247                                 <LI><A NAME="def_VORBIS_COMMENT"><B>VORBIS_COMMENT</B>: 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/ogg/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.</LI>
248                                 <LI><A NAME="def_CUESHEET"><B>CUESHEET</B>: 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>
249                         </UL>
250                 </LI></P>
251                 <P><LI>
252                         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.
253                 </LI></P>
254                 <P><LI>
255                         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.
256                 </LI></P>
257                 <P><LI>
258                         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.
259                 </LI></P>
260                 <P><LI>
261                         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.
262                 </LI></P>
263                 <P><LI>
264                         <A NAME="subset">FLAC 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:
265                         <UL>
266                         <LI>
267                                 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.
268                         </LI>
269                         <LI>
270                                 The sample rate bits in the <A HREF="#frame_header">frame header</A> must be 0001-1011.
271                         </LI>
272                         <LI>
273                                 The bits-per-sample bits in the <A HREF="#frame_header">frame header</A> must be 001-111.
274                         </LI>
275                         </UL>
276                 </LI></P>
277         </UL>
278
279         <P>
280                 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.
281         </P>
282
283         </FONT>
284         </TD></TR>
285         </TABLE>
286         <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
287
288         <P>
289         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
290         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
291                 <TR>
292                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
293                                 <A NAME="stream"><FONT SIZE="+1"><B>STREAM</B></FONT></A>
294                         </TD>
295                 </TR>
296                 <TR>
297                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
298                                 &lt;32&gt;
299                         </TD>
300                         <TD>
301                                 "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
302                         </TD>
303                 </TR>
304                 <TR>
305                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
306                                 <A HREF="#metadata_block_streaminfo"><I>METADATA_BLOCK</I></A>
307                         </TD>
308                         <TD>
309                                 This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
310                         </TD>
311                 </TR>
312                 <TR>
313                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
314                                 <A HREF="#metadata_block"><I>METADATA_BLOCK</I></A>*
315                         </TD>
316                         <TD>
317                                 Zero or more metadata blocks
318                         </TD>
319                 </TR>
320                 <TR>
321                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
322                                 <A HREF="#frame"><I>FRAME</I></A>+
323                         </TD>
324                         <TD>
325                                 One or more audio frames
326                         </TD>
327                 </TR>
328         </TABLE>
329         </TD></TR></TABLE>
330         </P>
331
332         <P>
333         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
334         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
335                 <TR>
336                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
337                                 <A NAME="metadata_block"><FONT SIZE="+1"><B>METADATA_BLOCK</B></FONT></A>
338                         </TD>
339                 </TR>
340                 <TR>
341                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
342                                 <A HREF="#metadata_block_header"><I>METADATA_BLOCK_HEADER</I></A>
343                         </TD>
344                         <TD>
345                                 A block header that specifies the type and size of the metadata block data.
346                         </TD>
347                 </TR>
348                 <TR>
349                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
350                                 <A HREF="#metadata_block_data"><I>METADATA_BLOCK_DATA</I></A>
351                         </TD>
352                         <TD>
353                                 &nbsp;
354                         </TD>
355                 </TR>
356         </TABLE>
357         </TD></TR></TABLE>
358         </P>
359
360         <P>
361         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
362         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
363                 <TR>
364                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
365                                 <A NAME="metadata_block_header"><FONT SIZE="+1"><B>METADATA_BLOCK_HEADER</B></FONT></A>
366                         </TD>
367                 </TR>
368                 <TR>
369                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
370                                 &lt;1&gt;
371                         </TD>
372                         <TD>
373                                 Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
374                         </TD>
375                 </TR>
376                 <TR>
377                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
378                                 &lt;7&gt;
379                         </TD>
380                         <TD>
381                                 BLOCK_TYPE<BR>
382                                 <UL>
383                                 <LI>
384                                         <TT>0</TT> : STREAMINFO
385                                 </LI>
386                                 <LI>
387                                         <TT>1</TT> : PADDING
388                                 </LI>
389                                 <LI>
390                                         <TT>2</TT> : APPLICATION
391                                 </LI>
392                                 <LI>
393                                         <TT>3</TT> : SEEKTABLE
394                                 </LI>
395                                 <LI>
396                                         <TT>4</TT> : VORBIS_COMMENT
397                                 </LI>
398                                 <LI>
399                                         <TT>5</TT> : CUESHEET
400                                 </LI>
401                                 <LI>
402                                         <TT>6-127</TT> : reserved
403                                 </LI>
404                                 </UL>
405                         </TD>
406                 </TR>
407                 <TR>
408                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
409                                 &lt;24&gt;
410                         </TD>
411                         <TD>
412                                 Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
413                         </TD>
414                 </TR>
415         </TABLE>
416         </TD></TR></TABLE>
417         </P>
418
419         <P>
420         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
421         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
422                 <TR>
423                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
424                                 <A NAME="metadata_block_data"><FONT SIZE="+1"><B>METADATA_BLOCK_DATA</B></FONT></A>
425                         </TD>
426                 </TR>
427                 <TR>
428                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
429                                 <A HREF="#metadata_block_streaminfo"><I>METADATA_BLOCK_STREAMINFO</I></A><BR>
430                                 || <A HREF="#metadata_block_padding"><I>METADATA_BLOCK_PADDING</I></A><BR>
431                                 || <A HREF="#metadata_block_application"><I>METADATA_BLOCK_APPLICATION</I></A><BR>
432                                 || <A HREF="#metadata_block_seektable"><I>METADATA_BLOCK_SEEKTABLE</I></A><BR>
433                                 || <A HREF="#metadata_block_vorbis_comment"><I>METADATA_BLOCK_VORBIS_COMMENT</I></A><BR>
434                                 || <A HREF="#metadata_block_cuesheet"><I>METADATA_BLOCK_CUESHEET</I></A>
435                         </TD>
436                         <TD>
437                                 The block data must match the block type in the block header.
438                         </TD>
439                 </TR>
440         </TABLE>
441         </TD></TR></TABLE>
442         </P>
443
444         <P>
445         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
446         <TABLE WIDTH="100%" BORDER="1">
447                 <TR>
448                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
449                                 <A NAME="metadata_block_streaminfo"><FONT SIZE="+1"><B>METADATA_BLOCK_STREAMINFO</B></FONT></A>
450                         </TD>
451                 </TR>
452                 <TR>
453                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
454                                 &lt;16&gt;
455                         </TD>
456                         <TD>
457                                 The minimum block size (in samples) used in the stream.
458                         </TD>
459                 </TR>
460                 <TR>
461                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
462                                 &lt;16&gt;
463                         </TD>
464                         <TD>
465                                 The maximum block size (in samples) used in the stream.  (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
466                         </TD>
467                 </TR>
468                 <TR>
469                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
470                                 &lt;24&gt;
471                         </TD>
472                         <TD>
473                                 The minimum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
474                         </TD>
475                 </TR>
476                 <TR>
477                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
478                                 &lt;24&gt;
479                         </TD>
480                         <TD>
481                                 The maximum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
482                         </TD>
483                 </TR>
484                 <TR>
485                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
486                                 &lt;20&gt;
487                         </TD>
488                         <TD>
489                                 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.
490                         </TD>
491                 </TR>
492                 <TR>
493                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
494                                 &lt;3&gt;
495                         </TD>
496                         <TD>
497                                 (number of channels)-1.  FLAC supports from 1 to 8 channels
498                         </TD>
499                 </TR>
500                 <TR>
501                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
502                                 &lt;5&gt;
503                         </TD>
504                         <TD>
505                                 (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.
506                         </TD>
507                 </TR>
508                 <TR>
509                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
510                                 &lt;36&gt;
511                         </TD>
512                         <TD>
513                                 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.
514                         </TD>
515                 </TR>
516                 <TR>
517                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
518                                 &lt;128&gt;
519                         </TD>
520                         <TD>
521                                 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.
522                         </TD>
523                 </TR>
524                 <TR>
525                         <TD>
526                         </TD>
527                         <TD BGCOLOR="#F4F4CC">
528                                 <FONT SIZE="+1">NOTES</FONT><BR>
529                                 <UL>
530                                 <LI>
531                                         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.
532                                 </LI>
533                                 </UL>
534                         </TD>
535                 </TR>
536         </TABLE>
537         </TD></TR></TABLE>
538         </P>
539
540         <P>
541         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
542         <TABLE WIDTH="100%" BORDER="1">
543                 <TR>
544                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
545                                 <A NAME="metadata_block_padding"><FONT SIZE="+1"><B>METADATA_BLOCK_PADDING</B></FONT></A>
546                         </TD>
547                 </TR>
548                 <TR>
549                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
550                                 &lt;n&gt;
551                         </TD>
552                         <TD>
553                                 n '0' bits (n must be a multiple of 8)
554                         </TD>
555                 </TR>
556         </TABLE>
557         </TD></TR></TABLE>
558         </P>
559
560         <P>
561         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
562         <TABLE WIDTH="100%" BORDER="1">
563                 <TR>
564                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
565                                 <A NAME="metadata_block_application"><FONT SIZE="+1"><B>METADATA_BLOCK_APPLICATION</B></FONT></A>
566                         </TD>
567                 </TR>
568                 <TR>
569                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
570                                 &lt;32&gt;
571                         </TD>
572                         <TD>
573                                 Registered application ID.  (Visit the <A HREF="id.html">registration page</A> to register an ID with FLAC.)
574                         </TD>
575                 </TR>
576                 <TR>
577                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
578                                 &lt;n&gt;
579                         </TD>
580                         <TD>
581                                 Application data (n must be a multiple of 8)
582                         </TD>
583                 </TR>
584         </TABLE>
585         </TD></TR></TABLE>
586         </P>
587
588         <P>
589         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
590         <TABLE WIDTH="100%" BORDER="1">
591                 <TR>
592                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
593                                 <A NAME="metadata_block_seektable"><FONT SIZE="+1"><B>METADATA_BLOCK_SEEKTABLE</B></FONT></A>
594                         </TD>
595                 </TR>
596                 <TR>
597                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
598                                 <A HREF="#seekpoint"><I>SEEKPOINT</I></A>+
599                         </TD>
600                         <TD>
601                                 One or more seek points.
602                         </TD>
603                 </TR>
604                 <TR>
605                         <TD>
606                         </TD>
607                         <TD BGCOLOR="#F4F4CC">
608                                 <FONT SIZE="+1">NOTE</FONT><BR>
609                                 <UL>
610                                 <LI>
611                                         The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
612                                 </LI>
613                                 </UL>
614                         </TD>
615                 </TR>
616         </TABLE>
617         </TD></TR></TABLE>
618         </P>
619
620         <P>
621         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
622         <TABLE WIDTH="100%" BORDER="1">
623                 <TR>
624                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
625                                 <A NAME="seekpoint"><FONT SIZE="+1"><B>SEEKPOINT</B></FONT></A>
626                         </TD>
627                 </TR>
628                 <TR>
629                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
630                                 &lt;64&gt;
631                         </TD>
632                         <TD>
633                                 Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
634                         </TD>
635                 </TR>
636                 <TR>
637                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
638                                 &lt;64&gt;
639                         </TD>
640                         <TD>
641                                 Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
642                         </TD>
643                 </TR>
644                 <TR>
645                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
646                                 &lt;16&gt;
647                         </TD>
648                         <TD>
649                                 Number of samples in the target frame.
650                         </TD>
651                 </TR>
652                 <TR>
653                         <TD>
654                         </TD>
655                         <TD BGCOLOR="#F4F4CC">
656                                 <FONT SIZE="+1">NOTES</FONT><BR>
657                                 <UL>
658                                 <LI>
659                                         For placeholder points, the second and third field values are undefined.
660                                 </LI>
661                                 <LI>
662                                         Seek points within a table must be sorted in ascending order by sample number.
663                                 </LI>
664                                 <LI>
665                                         Seek points within a table must be unique by sample number, with the exception of placeholder points.
666                                 </LI>
667                                 <LI>
668                                         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.
669                                 </LI>
670                                 </UL>
671                         </TD>
672                 </TR>
673         </TABLE>
674         </TD></TR></TABLE>
675         </P>
676
677         <P>
678         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
679         <TABLE WIDTH="100%" BORDER="1">
680                 <TR>
681                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
682                                 <A NAME="metadata_block_vorbis_comment"><FONT SIZE="+1"><B>METADATA_BLOCK_VORBIS_COMMENT</B></FONT></A>
683                         </TD>
684                 </TR>
685                 <TR>
686                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
687                                 &lt;n&gt;
688                         </TD>
689                         <TD>
690                                 The contents of a vorbis comment packet as specified <A HREF="http://www.xiph.org/ogg/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.
691                         </TD>
692                 </TR>
693         </TABLE>
694         </TD></TR></TABLE>
695         </P>
696
697         <P>
698         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
699         <TABLE WIDTH="100%" BORDER="1">
700                 <TR>
701                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
702                                 <A NAME="metadata_block_cuesheet"><FONT SIZE="+1"><B>METADATA_BLOCK_CUESHEET</B></FONT></A>
703                         </TD>
704                 </TR>
705                 <TR>
706                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
707                                 &lt;128*8&gt;
708                         </TD>
709                         <TD>
710                                 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.
711                         </TD>
712                 </TR>
713                 <TR>
714                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
715                                 &lt;64&gt;
716                         </TD>
717                         <TD>
718                                 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.
719                         </TD>
720                 </TR>
721                 <TR>
722                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
723                                 &lt;1&gt;
724                         </TD>
725                         <TD>
726                                 <TT>1</TT> if the CUESHEET corresponds to a Compact Disc, else <TT>0</TT>.
727                         </TD>
728                 </TR>
729                 <TR>
730                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
731                                 &lt;7+258*8&gt;
732                         </TD>
733                         <TD>
734                                 Reserved.  All bits must be set to zero.
735                         </TD>
736                 </TR>
737                 <TR>
738                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
739                                 &lt;8&gt;
740                         </TD>
741                         <TD>
742                                 The number of tracks.  For CD-DA, this number must be no more than 100 (99 regular tracks and one leadout track).
743                         </TD>
744                 </TR>
745                 <TR>
746                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
747                                 <A HREF="#cuesheet_track"><I>CUESHEET_TRACK</I></A>+
748                         </TD>
749                         <TD>
750                                 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.
751                         </TD>
752                 </TR>
753         </TABLE>
754         </TD></TR></TABLE>
755         </P>
756
757         <P>
758         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
759         <TABLE WIDTH="100%" BORDER="1">
760                 <TR>
761                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
762                                 <A NAME="cuesheet_track"><FONT SIZE="+1"><B>CUESHEET_TRACK</B></FONT></A>
763                         </TD>
764                 </TR>
765                 <TR>
766                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
767                                 &lt;64&gt;
768                         </TD>
769                         <TD>
770                                 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).
771                         </TD>
772                 </TR>
773                 <TR>
774                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
775                                 &lt;8&gt;
776                         </TD>
777                         <TD>
778                                 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.
779                         </TD>
780                 </TR>
781                 <TR>
782                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
783                                 &lt;12*8&gt;
784                         </TD>
785                         <TD>
786                                 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.
787                         </TD>
788                 </TR>
789                 <TR>
790                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
791                                 &lt;1&gt;
792                         </TD>
793                         <TD>
794                                 The track type: 0 for audio, 1 for non-audio.  This corresponds to the CD-DA Q-channel control bit 3.
795                         </TD>
796                 </TR>
797                 <TR>
798                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
799                                 &lt;1&gt;
800                         </TD>
801                         <TD>
802                                 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>.
803                         </TD>
804                 </TR>
805                 <TR>
806                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
807                                 &lt;6+13*8&gt;
808                         </TD>
809                         <TD>
810                                 Reserved.  All bits must be set to zero.
811                         </TD>
812                 </TR>
813                 <TR>
814                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
815                                 &lt;8&gt;
816                         </TD>
817                         <TD>
818                                 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.
819                         </TD>
820                 </TR>
821                 <TR>
822                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
823                                 <A HREF="#cuesheet_track_index"><I>CUESHEET_TRACK_INDEX</I></A>+
824                         </TD>
825                         <TD>
826                                 For all tracks except the lead-out track, one or more track index points.
827                         </TD>
828                 </TR>
829         </TABLE>
830         </TD></TR></TABLE>
831         </P>
832
833         <P>
834         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
835         <TABLE WIDTH="100%" BORDER="1">
836                 <TR>
837                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
838                                 <A NAME="cuesheet_track_index"><FONT SIZE="+1"><B>CUESHEET_TRACK_INDEX</B></FONT></A>
839                         </TD>
840                 </TR>
841                 <TR>
842                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
843                                 &lt;64&gt;
844                         </TD>
845                         <TD>
846                                 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.
847                         </TD>
848                 </TR>
849                 <TR>
850                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
851                                 &lt;8&gt;
852                         </TD>
853                         <TD>
854                                 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.
855                         </TD>
856                 </TR>
857                 <TR>
858                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
859                                 &lt;3*8&gt;
860                         </TD>
861                         <TD>
862                                 Reserved.  All bits must be set to zero.
863                         </TD>
864                 </TR>
865         </TABLE>
866         </TD></TR></TABLE>
867         </P>
868
869         <P>
870         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
871         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
872                 <TR>
873                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
874                                 <A NAME="frame"><FONT SIZE="+1"><B>FRAME</B></FONT></A>
875                         </TD>
876                 </TR>
877                 <TR>
878                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
879                                 <A HREF="#frame_header"><I>FRAME_HEADER</I></A>
880                         </TD>
881                         <TD>
882                                 &nbsp;
883                         </TD>
884                 </TR>
885                 <TR>
886                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
887                                 <A HREF="#subframe"><I>SUBFRAME</I></A>+
888                         </TD>
889                         <TD>
890                                 One SUBFRAME per channel.
891                         </TD>
892                 </TR>
893                 <TR>
894                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
895                                 &lt;?&gt;
896                         </TD>
897                         <TD>
898                                 Zero-padding to byte alignment.
899                         </TD>
900                 </TR>
901                 <TR>
902                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
903                                 <A HREF="#frame_footer"><I>FRAME_FOOTER</I></A>
904                         </TD>
905                         <TD>
906                                 &nbsp;
907                         </TD>
908                 </TR>
909         </TABLE>
910         </TD></TR></TABLE>
911         </P>
912
913         <P>
914         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
915         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
916                 <TR>
917                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
918                                 <A NAME="frame_header"><FONT SIZE="+1"><B>FRAME_HEADER</B></FONT></A>
919                         </TD>
920                 </TR>
921                 <TR>
922                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
923                                 &lt;14&gt;
924                         </TD>
925                         <TD>
926                                 Sync code '<TT>11111111111110</TT>'
927                         </TD>
928                 </TR>
929                 <TR>
930                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
931                                 &lt;2&gt;
932                         </TD>
933                         <TD>
934                                 Reserved:<BR>
935                                 <UL>
936                                 <LI>
937                                         <TT>00</TT> : mandatory value
938                                 </LI>
939                                 <LI>
940                                         <TT>01-11</TT> : reserved for future use
941                                 </LI>
942                                 </UL>
943                         </TD>
944                 </TR>
945                 <TR>
946                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
947                                 &lt;4&gt;
948                         </TD>
949                         <TD>
950                                 Block size in inter-channel samples:<BR>
951                                 <UL>
952                                 <LI>
953                                         <TT>0000</TT> : get from STREAMINFO metadata block
954                                 </LI>
955                                 <LI>
956                                         <TT>0001</TT> : 192 samples
957                                 </LI>
958                                 <LI>
959                                         <TT>0010-0101</TT> : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
960                                 </LI>
961                                 <LI>
962                                         <TT>0110</TT> : get 8 bit (blocksize-1) from end of header
963                                 </LI>
964                                 <LI>
965                                         <TT>0111</TT> : get 16 bit (blocksize-1) from end of header
966                                 </LI>
967                                 <LI>
968                                         <TT>1000-1111</TT> : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
969                                 </LI>
970                                 </UL>
971                         </TD>
972                 </TR>
973                 <TR>
974                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
975                                 &lt;4&gt;
976                         </TD>
977                         <TD>
978                                 Sample rate:<BR>
979                                 <UL>
980                                 <LI>
981                                         <TT>0000</TT> : get from STREAMINFO metadata block
982                                 </LI>
983                                 <LI>
984                                         <TT>0001-0011</TT> : reserved
985                                 </LI>
986                                 <LI>
987                                         <TT>0100</TT> : 8kHz
988                                 </LI>
989                                 <LI>
990                                         <TT>0101</TT> : 16kHz
991                                 </LI>
992                                 <LI>
993                                         <TT>0110</TT> : 22.05kHz
994                                 </LI>
995                                 <LI>
996                                         <TT>0111</TT> : 24kHz
997                                 </LI>
998                                 <LI>
999                                         <TT>1000</TT> : 32kHz
1000                                 </LI>
1001                                 <LI>
1002                                         <TT>1001</TT> : 44.1kHz
1003                                 </LI>
1004                                 <LI>
1005                                         <TT>1010</TT> : 48kHz
1006                                 </LI>
1007                                 <LI>
1008                                         <TT>1011</TT> : 96kHz
1009                                 </LI>
1010                                 <LI>
1011                                         <TT>1100</TT> : get 8 bit sample rate (in kHz) from end of header
1012                                 </LI>
1013                                 <LI>
1014                                         <TT>1101</TT> : get 16 bit sample rate (in Hz) from end of header
1015                                 </LI>
1016                                 <LI>
1017                                         <TT>1110</TT> : get 16 bit sample rate (in tens of Hz) from end of header
1018                                 </LI>
1019                                 <LI>
1020                                         <TT>1111</TT> : invalid, to prevent sync-fooling string of 1s
1021                                 </LI>
1022                                 </UL>
1023                         </TD>
1024                 </TR>
1025                 <TR>
1026                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1027                                 &lt;4&gt;
1028                         </TD>
1029                         <TD>
1030                                 Channel assignment
1031                                 <UL>
1032                                 <LI>
1033                                         <TT>0000-0111</TT> : (number of independent channels)-1.  when == 0001, channel 0 is the left channel and channel 1 is the right
1034                                 </LI>
1035                                 <LI>
1036                                         <TT>1000</TT> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
1037                                 </LI>
1038                                 <LI>
1039                                         <TT>1001</TT> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
1040                                 </LI>
1041                                 <LI>
1042                                         <TT>1010</TT> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
1043                                 </LI>
1044                                 <LI>
1045                                         <TT>1011-1111</TT> : reserved
1046                                 </LI>
1047                                 </UL>
1048                         </TD>
1049                 </TR>
1050                 <TR>
1051                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1052                                 &lt;3&gt;
1053                         </TD>
1054                         <TD>
1055                                 Sample size in bits:<BR>
1056                                 <UL>
1057                                 <LI>
1058                                         <TT>000</TT> : get from STREAMINFO metadata block
1059                                 </LI>
1060                                 <LI>
1061                                         <TT>001</TT> : 8 bits per sample
1062                                 </LI>
1063                                 <LI>
1064                                         <TT>010</TT> : 12 bits per sample
1065                                 </LI>
1066                                 <LI>
1067                                         <TT>011</TT> : reserved
1068                                 </LI>
1069                                 <LI>
1070                                         <TT>100</TT> : 16 bits per sample
1071                                 </LI>
1072                                 <LI>
1073                                         <TT>101</TT> : 20 bits per sample
1074                                 </LI>
1075                                 <LI>
1076                                         <TT>110</TT> : 24 bits per sample
1077                                 </LI>
1078                                 <LI>
1079                                         <TT>111</TT> : reserved
1080                                 </LI>
1081                                 </UL>
1082                         </TD>
1083                 </TR>
1084                 <TR>
1085                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1086                                 &lt;1&gt;
1087                         </TD>
1088                         <TD>
1089                                 Zero bit padding, to prevent sync-fooling string of 1s
1090                         </TD>
1091                 </TR>
1092                 <TR>
1093                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1094                                 &lt;?&gt;
1095                         </TD>
1096                         <TD>
1097                                 if(variable blocksize)<BR>
1098                                 &nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits)<BR>
1099                                 else<BR>
1100                                 &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits)
1101                         </TD>
1102                 </TR>
1103                 <TR>
1104                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1105                                 &lt;?&gt;
1106                         </TD>
1107                         <TD>
1108                                 if(blocksize bits == 011x)<BR>
1109                                 &nbsp;&nbsp;&nbsp;8/16 bit (blocksize-1)
1110                         </TD>
1111                 </TR>
1112                 <TR>
1113                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1114                                 &lt;?&gt;
1115                         </TD>
1116                         <TD>
1117                                 if(sample rate bits == 11xx)<BR>
1118                                 &nbsp;&nbsp;&nbsp;8/16 bit sample rate
1119                         </TD>
1120                 </TR>
1121                 <TR>
1122                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1123                                 &lt;8&gt;
1124                         </TD>
1125                         <TD>
1126                                 CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
1127                         </TD>
1128                 </TR>
1129                 <TR>
1130                         <TD>
1131                         </TD>
1132                         <TD BGCOLOR="#F4F4CC">
1133                                 <FONT SIZE="+1">NOTES</FONT><BR>
1134                                 <UL>
1135                                 <LI>
1136                                         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.  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.
1137                                 </LI>
1138                                 <LI>
1139                                         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.
1140                                 </LI>
1141                                 </UL>
1142                         </TD>
1143                 </TR>
1144         </TABLE>
1145         </TD></TR></TABLE>
1146         </P>
1147
1148         <P>
1149         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1150         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1151                 <TR>
1152                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1153                                 <A NAME="frame_footer"><FONT SIZE="+1"><B>FRAME_FOOTER</B></FONT></A>
1154                         </TD>
1155                 </TR>
1156                 <TR>
1157                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1158                                 &lt;16&gt;
1159                         </TD>
1160                         <TD>
1161                                 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
1162                         </TD>
1163                 </TR>
1164         </TABLE>
1165         </TD></TR></TABLE>
1166         </P>
1167
1168         <P>
1169         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1170         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1171                 <TR>
1172                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1173                                 <A NAME="subframe"><FONT SIZE="+1"><B>SUBFRAME</B></FONT></A>
1174                         </TD>
1175                 </TR>
1176                 <TR>
1177                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1178                                 <A HREF="#subframe_header"><I>SUBFRAME_HEADER</I></A>
1179                         </TD>
1180                         <TD>
1181                                 &nbsp;
1182                         </TD>
1183                 </TR>
1184                 <TR>
1185                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1186                                 <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>
1187                         </TD>
1188                         <TD VALIGN="TOP">
1189                                 The SUBFRAME_HEADER specifies which one.
1190                         </TD>
1191                 </TR>
1192         </TABLE>
1193         </TD></TR></TABLE>
1194         </P>
1195
1196         <P>
1197         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1198         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1199                 <TR>
1200                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1201                                 <A NAME="subframe_header"><FONT SIZE="+1"><B>SUBFRAME_HEADER</B></FONT></A>
1202                         </TD>
1203                 </TR>
1204                 <TR>
1205                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1206                                 &lt;1&gt;
1207                         </TD>
1208                         <TD>
1209                                 Zero bit padding, to prevent sync-fooling string of 1s
1210                         </TD>
1211                 </TR>
1212                 <TR>
1213                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1214                                 &lt;6&gt;
1215                         </TD>
1216                         <TD>
1217                                 Subframe type:
1218                                 <UL>
1219                                 <LI>
1220                                         <TT>000000</TT> : <A HREF="#subframe_constant">SUBFRAME_CONSTANT</A>
1221                                 </LI>
1222                                 <LI>
1223                                         <TT>000001</TT> : <A HREF="#subframe_verbatim">SUBFRAME_VERBATIM</A>
1224                                 </LI>
1225                                 <LI>
1226                                         <TT>00001x</TT> : reserved
1227                                 </LI>
1228                                 <LI>
1229                                         <TT>0001xx</TT> : reserved
1230                                 </LI>
1231                                 <LI>
1232                                         <TT>001xxx</TT> : if(xxx <= 4) <A HREF="#subframe_fixed">SUBFRAME_FIXED</A>, xxx=order ; else reserved
1233                                 </LI>
1234                                 <LI>
1235                                         <TT>01xxxx</TT> : reserved
1236                                 </LI>
1237                                 <LI>
1238                                         <TT>1xxxxx</TT> : <A HREF="#subframe_lpc">SUBFRAME_LPC</A>, xxxxx=order-1
1239                                 </LI>
1240                                 </UL>
1241                         </TD>
1242                 </TR>
1243                 <TR>
1244                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1245                                 &lt;1+k&gt;
1246                         </TD>
1247                         <TD>
1248                                 'Wasted bits-per-sample' flag:
1249                                 <UL>
1250                                 <LI>
1251                                         <TT>0</TT> : no wasted bits-per-sample in source subblock, k=0
1252                                 </LI>
1253                                 <LI>
1254                                         <TT>1</TT> : k wasted bits-per-sample in source subblock, k-1 follows, unary coded; i.e. k=3 => 001 follows, k=7 => 0000001 follows.
1255                                 </LI>
1256                         </TD>
1257                 </TR>
1258         </TABLE>
1259         </TD></TR></TABLE>
1260         </P>
1261
1262         <P>
1263         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1264         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1265                 <TR>
1266                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1267                                 <A NAME="subframe_constant"><FONT SIZE="+1"><B>SUBFRAME_CONSTANT</B></FONT></A>
1268                         </TD>
1269                 </TR>
1270                 <TR>
1271                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1272                                 &lt;n&gt;
1273                         </TD>
1274                         <TD>
1275                                 Unencoded constant value of the subblock, n = frame's bits-per-sample.
1276                         </TD>
1277                 </TR>
1278         </TABLE>
1279         </TD></TR></TABLE>
1280         </P>
1281
1282         <P>
1283         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1284         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1285                 <TR>
1286                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1287                                 <A NAME="subframe_fixed"><FONT SIZE="+1"><B>SUBFRAME_FIXED</B></FONT></A>
1288                         </TD>
1289                 </TR>
1290                 <TR>
1291                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1292                                 &lt;n&gt;
1293                         </TD>
1294                         <TD>
1295                                 Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
1296                         </TD>
1297                 </TR>
1298                 <TR>
1299                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1300                                 <A HREF="#residual"><I>RESIDUAL</I></A>
1301                         </TD>
1302                         <TD>
1303                                 Encoded residual
1304                         </TD>
1305                 </TR>
1306         </TABLE>
1307         </TD></TR></TABLE>
1308         </P>
1309
1310         <P>
1311         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1312         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1313                 <TR>
1314                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1315                                 <A NAME="subframe_lpc"><FONT SIZE="+1"><B>SUBFRAME_LPC</B></FONT></A>
1316                         </TD>
1317                 </TR>
1318                 <TR>
1319                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1320                                 &lt;n&gt;
1321                         </TD>
1322                         <TD>
1323                                 Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
1324                         </TD>
1325                 </TR>
1326                 <TR>
1327                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1328                                 &lt;4&gt;
1329                         </TD>
1330                         <TD>
1331                                 (Quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
1332                         </TD>
1333                 </TR>
1334                 <TR>
1335                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1336                                 &lt;5&gt;
1337                         </TD>
1338                         <TD>
1339                                 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement).
1340                         </TD>
1341                 </TR>
1342                 <TR>
1343                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1344                                 &lt;n&gt;
1345                         </TD>
1346                         <TD>
1347                                 Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
1348                         </TD>
1349                 </TR>
1350                 <TR>
1351                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1352                                 <A HREF="#residual"><I>RESIDUAL</I></A>
1353                         </TD>
1354                         <TD>
1355                                 Encoded residual
1356                         </TD>
1357                 </TR>
1358         </TABLE>
1359         </TD></TR></TABLE>
1360         </P>
1361
1362         <P>
1363         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1364         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1365                 <TR>
1366                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1367                                 <A NAME="subframe_verbatim"><FONT SIZE="+1"><B>SUBFRAME_VERBATIM</B></FONT></A>
1368                         </TD>
1369                 </TR>
1370                 <TR>
1371                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1372                                 &lt;n*i&gt;
1373                         </TD>
1374                         <TD>
1375                                 Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
1376                         </TD>
1377                 </TR>
1378         </TABLE>
1379         </TD></TR></TABLE>
1380         </P>
1381
1382         <P>
1383         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1384         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1385                 <TR>
1386                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1387                                 <A NAME="residual"><FONT SIZE="+1"><B>RESIDUAL</B></FONT></A>
1388                         </TD>
1389                 </TR>
1390                 <TR>
1391                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1392                                 &lt;2&gt;
1393                         </TD>
1394                         <TD>
1395                                 Residual coding method:<BR>
1396                                 <UL>
1397                                 <LI>
1398                                         <TT>00</TT> : partitioned rice coding
1399                                 </LI>
1400                                 <LI>
1401                                         <TT>01-11</TT> : reserved
1402                                 </LI>
1403                                 </UL>
1404                         </TD>
1405                 </TR>
1406                 <TR>
1407                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1408                                 <A HREF="#partitioned_rice"><I>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</I></A>
1409                         </TD>
1410                         <TD>
1411                                 &nbsp;
1412                         </TD>
1413                 </TR>
1414                 <TR>
1415                         <TD>
1416                         </TD>
1417                         <TD BGCOLOR="#F4F4CC">
1418                                 <FONT SIZE="+1">NOTES</FONT><BR>
1419                                 <UL>
1420                                 <LI>
1421                                         Currently, FLAC specifies only one entropy coding method.
1422                                 </LI>
1423                                 </UL>
1424                         </TD>
1425                 </TR>
1426         </TABLE>
1427         </TD></TR></TABLE>
1428         </P>
1429
1430         <P>
1431         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1432         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1433                 <TR>
1434                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1435                                 <A NAME="partitioned_rice"><FONT SIZE="+1"><B>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</B></FONT></A>
1436                         </TD>
1437                 </TR>
1438                 <TR>
1439                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1440                                 &lt;4&gt;
1441                         </TD>
1442                         <TD>
1443                                 Partition order.
1444                         </TD>
1445                 </TR>
1446                 <TR>
1447                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1448                                 <A HREF="#rice_partition"><I>RICE_PARTITION</I></A>+
1449                         </TD>
1450                         <TD>
1451                                 There will be 2^order partitions.
1452                         </TD>
1453                 </TR>
1454         </TABLE>
1455         </TD></TR></TABLE>
1456         </P>
1457
1458         <P>
1459         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1460         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1461                 <TR>
1462                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1463                                 <A NAME="rice_partition"><FONT SIZE="+1"><B>RICE_PARTITION</B></FONT></A>
1464                         </TD>
1465                 </TR>
1466                 <TR>
1467                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1468                                 &lt;4(+5)&gt;
1469                         </TD>
1470                         <TD>
1471                                 Encoding parameter:<BR>
1472                                 <UL>
1473                                 <LI>
1474                                         <TT>0000-1110</TT> : Rice parameter.
1475                                 </LI>
1476                                 <LI>
1477                                         <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.
1478                                 </LI>
1479                                 </UL>
1480                         </TD>
1481                 </TR>
1482                 <TR>
1483                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1484                                 &lt;?&gt;
1485                         </TD>
1486                         <TD>
1487                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<BR>
1488                                 <UL>
1489                                 <LI>
1490                                         if the partition order is zero, n = frame's blocksize
1491                                 </LI>
1492                                 <LI>
1493                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1494                                 </LI>
1495                                 <LI>
1496                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1497                                 </LI>
1498                                 </UL>
1499                         </TD>
1500                 </TR>
1501         </TABLE>
1502         </TD></TR></TABLE>
1503         </P>
1504
1505 </TD></TR>
1506 </TABLE>
1507
1508
1509 </CENTER>
1510
1511 <P>&nbsp;Copyright (c) 2000,2001,2002,2003 Josh Coalson</P>
1512
1513 </BODY>
1514 </HTML>