minor additions
[flac.git] / doc / format.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4         <TITLE>FLAC - format</TITLE>
5 </HEAD>
6
7 <BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#99CC99" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
8
9 <TABLE BORDER=0 WIDTH="100%" CELLPADDING=1 CELLSPACING=0>
10         <TR>
11                 <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>
12         </TR>
13 </TABLE>
14
15 <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>
16
17 <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>
18
19 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
20         <TR>
21                 <TD ALIGN="CENTER" BGCOLOR="#D3D4C5">
22                         <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
23                                 <TR>
24                                         <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>
25                                         <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>
26                                         <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>
27                                         <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>
28                                         <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>
29                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;format&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
30                                         <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>
31                                         <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>
32                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="developers.html">developers</A>&nbsp;&nbsp;</TD>
33                                 </TR>
34                         </TABLE>
35                 </TD>
36         </TR>
37 </TABLE>
38
39 <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>
40
41 <CENTER>
42
43 <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>
44
45
46 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
47 <TR><TD>
48         <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>
49         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
50                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
51                 <B><FONT SIZE="+2">format</FONT></B>
52                 </FONT></TD></TR>
53         </TABLE>
54         <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>
55         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
56         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
57         <P>
58                 This is a detailed description of the FLAC format.  The format is currently in the beta stage, which means it will not change in a way that will break backward compatibility unless a bug related to the format is found.  Until the first official release you should probably not use FLAC for archiving unless you keep your beta binaries.
59         </P>
60         <P>
61                 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:
62         </P>
63         <P>
64         <UL>
65                 <LI>
66                         <A HREF="http://svr-www.eng.cam.ac.uk/~ajr/">A. J. Robinson</A> for his work on <A HREF="http://svr-www.eng.cam.ac.uk/~ajr/GroupPubs/Robinson94-tr156/index.html">Shorten</A>; his code and paper are a good starting point on some of the basic methods used by FLAC.  FLAC expands on the fixed predictors used in shorten.
67                 </LI>
68                 <LI>
69                         <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.
70                 </LI>
71                 <LI>
72                         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.
73                 </LI>
74                 <LI>
75                         And of course, the main guy, <A HREF="http://www.digitalcentury.com/encyclo/update/shannon.html">Claude Shannon</A>
76                 </LI>
77         </UL>
78         </P>
79         <P>
80                 <A NAME="scope"><FONT SIZE="+1"><B><U>Scope</U></B></FONT></A>
81         </P>
82         <P>
83                 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 code 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.
84         </P>
85         <P>
86                 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.
87         </P>
88         <P>
89                 <A NAME="architecture"><FONT SIZE="+1"><B><U>Architecture</U></B></FONT></A>
90         </P>
91         <P>
92                 Similar to many audio coders, a FLAC encoder has the following stages:
93         </P>
94         <UL>
95                 <P><LI>
96                         <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.
97                 </LI></P>
98                 <P><LI>
99                         <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.
100                 </LI></P>
101                 <P><LI>
102                         <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.
103                 </LI></P>
104                 <LI><P>
105                         <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.
106                 </LI></P>
107         </UL>
108         <P>
109                 In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.
110         </P>
111         <P>
112                 <A NAME="definitions"><FONT SIZE="+1"><B><U>Definitions</U></B></FONT></A>
113         </P>
114         <P>
115                 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.
116         </P>
117         <UL>
118                 <P><LI>
119                         <B>Block</B>: One or more audio samples that span several channels.
120                 </LI></P>
121                 <P><LI>
122                         <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.
123                 </LI></P>
124                 <P><LI>
125                         <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.
126                 </LI></P>
127                 <P><LI>
128                         <B>Frame</B>: A frame header plus one or more subframes.
129                 </LI></P>
130                 <P><LI>
131                         <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.
132                 </LI></P>
133         </UL>
134         <P>
135                 <A NAME="blocking"><FONT SIZE="+1"><B><U>Blocking</U></B></FONT></A>
136         </P>
137         <P>
138                 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.
139         </P>
140         <P>
141                 Currently the reference encoder uses a fixed block size, optimized on the sample rate of the input.  Future version may vary the block size depending on the characteristics of the signal.
142         </P>
143         <P>
144                 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.
145         </P>
146         <P>
147                 <A NAME="interchannel"><FONT SIZE="+1"><B><U>Interchannel Decorrelation</U></B></FONT></A>
148         </P>
149         <P>
150                 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.
151         </P>
152         <UL>
153                 <P><LI>
154                         <B>Independent</B>.  The left and right channels are coded independently.
155                 </LI></P>
156                 <P><LI>
157                         <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).
158                 </LI></P>
159                 <P><LI>
160                         <B>Left-side</B>.  The left channel and side channel are coded.
161                 </LI></P>
162                 <P><LI>
163                         <B>Right-side</B>.  The right channel and side channel are coded
164                 </LI></P>
165         </UL>
166         <P>
167                 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.
168         </P>
169         <P>
170                 <A NAME="prediction"><FONT SIZE="+1"><B><U>Prediction</U></B></FONT></A>
171         </P>
172         <P>
173                 FLAC uses four methods for modeling the input signal:
174         </P>
175         <UL>
176                 <P><LI>
177                         <B>Verbatim</B>.  This is essentially a zero-order predictor of the signal.  The predictor of the signal is the signal itself, so 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.
178                 </LI></P>
179                 <P><LI>
180                         <B>Constant</B>.  This predictor is used whenever the subblock contains digital silence, i.e. a constant value throughout.  The signal is run-length encoded and added to the stream.
181                 </LI></P>
182                 <P><LI>
183                         <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.
184                 </LI></P>
185                 <P><LI>
186                         <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.
187                 </LI></P>
188         </UL>
189         <P>
190                 <A NAME="residualcoding"><FONT SIZE="+1"><B><U>Residual Coding</U></B></FONT></A>
191         </P>
192         <P>
193                 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.)
194         </P>
195         <P>
196                 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.
197         </P>
198         <P>
199                 <FONT SIZE="+1"><B><U>Format</U></B></FONT>
200         </P>
201         <P>
202                 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.
203         </P>
204         <P>
205                 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.
206         </P>
207         <P>
208                 <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.  The input plugins support ID3V1 tags</A>
209         </P>
210         <P>
211                 Before the formal description of the stream, an overview might be helpful.
212         </P>
213         <UL>
214                 <P><LI>
215                         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.
216                 </LI></P>
217                 <P><LI>
218                         FLAC supports up to 128 kinds of metadata blocks, but currently only one is defined.  This is the STREAMINFO block, which has info about the whole stream like sample rate, number of channels, total number of samples, etc.  This block 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.
219                 </LI></P>
220                 <P><LI>
221                         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.
222                 </LI></P>
223                 <P><LI>
224                         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 9-bit sync code begins every 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.
225                 </LI></P>
226                 <P><LI>
227                         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.
228                 </LI></P>
229                 <P><LI>
230                         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.
231                 </LI></P>
232                 <P><LI>
233                         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 blocking such that decoder buffer sizes 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:
234                         <UL>
235                         <LI>
236                                 The blocksize bits in the <A HREF="#frame_header">frame header</A> must be 001-101, specifying a fixed-blocksize stream (the exception being the last block as described in the table).  This also means that the STREAMINFO metadata block must specify equal mininum and maximum blocksizes.
237                         </LI>
238                         <LI>
239                                 The bits-per-sample bits in the <A HREF="#frame_header">frame header</A> must be 001-110.
240                         </LI>
241                         <LI>
242                                 The sample rate bits in the <A HREF="#frame_header">frame header</A> must be 0001-1011.
243                         </LI>
244                         </UL>
245                 </LI></P>
246         </UL>
247
248         <P>
249                 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.
250         </P>
251
252         </FONT>
253         </TD></TR>
254         </TABLE>
255         <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>
256
257         <P>
258         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
259         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
260                 <TR>
261                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
262                                 <A NAME="stream"><FONT SIZE="+1"><B>STREAM</B></FONT></A>
263                         </TD>
264                 </TR>
265                 <TR>
266                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
267                                 &lt;32&gt;
268                         </TD>
269                         <TD>
270                                 "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
271                         </TD>
272                 </TR>
273                 <TR>
274                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
275                                 <A HREF="#metadata_streaminfo_block"><I>METADATA_BLOCK</I></A>
276                         </TD>
277                         <TD>
278                                 This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
279                         </TD>
280                 </TR>
281                 <TR>
282                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
283                                 <A HREF="#metadata_block"><I>METADATA_BLOCK</I></A>*
284                         </TD>
285                         <TD>
286                                 Zero or more metadata blocks
287                         </TD>
288                 </TR>
289                 <TR>
290                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
291                                 <A HREF="#frame"><I>FRAME</I></A>+
292                         </TD>
293                         <TD>
294                                 One or more audio frames
295                         </TD>
296                 </TR>
297         </TABLE>
298         </TD></TR></TABLE>
299         </P>
300
301         <P>
302         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
303         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
304                 <TR>
305                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
306                                 <A NAME="metadata_block"><FONT SIZE="+1"><B>METADATA_BLOCK</B></FONT></A>
307                         </TD>
308                 </TR>
309                 <TR>
310                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
311                                 <A HREF="#metadata_block_header"><I>METADATA_BLOCK_HEADER</I></A>
312                         </TD>
313                         <TD>
314                                 A block header that specifies the type and size of the metadata block data.
315                         </TD>
316                 </TR>
317                 <TR>
318                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
319                                 <A HREF="#metadata_block_data"><I>METADATA_BLOCK_DATA</I></A>
320                         </TD>
321                         <TD>
322                                 &nbsp;
323                         </TD>
324                 </TR>
325         </TABLE>
326         </TD></TR></TABLE>
327         </P>
328
329         <P>
330         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
331         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
332                 <TR>
333                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
334                                 <A NAME="metadata_block_header"><FONT SIZE="+1"><B>METADATA_BLOCK_HEADER</B></FONT></A>
335                         </TD>
336                 </TR>
337                 <TR>
338                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
339                                 &lt;1&gt;
340                         </TD>
341                         <TD>
342                                 Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
343                         </TD>
344                 </TR>
345                 <TR>
346                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
347                                 &lt;7&gt;
348                         </TD>
349                         <TD>
350                                 BLOCK_TYPE<BR>
351                                 <UL>
352                                 <LI>
353                                         <TT>0</TT> : STREAMINFO
354                                 </LI>
355                                 <LI>
356                                         <TT>1</TT> : PADDING
357                                 </LI>
358                                 <LI>
359                                         <TT>2</TT> : APPLICATION
360                                 </LI>
361                                 <LI>
362                                         <TT>3-127</TT> : reserved
363                                 </LI>
364                                 </UL>
365                         </TD>
366                 </TR>
367                 <TR>
368                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
369                                 &lt;24&gt;
370                         </TD>
371                         <TD>
372                                 Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
373                         </TD>
374                 </TR>
375         </TABLE>
376         </TD></TR></TABLE>
377         </P>
378
379         <P>
380         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
381         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
382                 <TR>
383                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
384                                 <A NAME="metadata_block_data"><FONT SIZE="+1"><B>METADATA_BLOCK_DATA</B></FONT></A>
385                         </TD>
386                 </TR>
387                 <TR>
388                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
389                                 <A HREF="#metadata_block_streaminfo"><I>METADATA_BLOCK_STREAMINFO</I></A><BR>|| <A HREF="#metadata_block_padding"><I>METADATA_BLOCK_PADDING</I></A><BR>|| <A HREF="#metadata_block_application"><I>METADATA_BLOCK_APPLICATION</I></A>
390                         </TD>
391                         <TD>
392                                 The block data must match the block type in the block header.
393                         </TD>
394                 </TR>
395         </TABLE>
396         </TD></TR></TABLE>
397         </P>
398
399         <P>
400         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
401         <TABLE WIDTH="100%" BORDER="1">
402                 <TR>
403                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
404                                 <A NAME="metadata_block_streaminfo"><FONT SIZE="+1"><B>METADATA_BLOCK_STREAMINFO</B></FONT></A>
405                         </TD>
406                 </TR>
407                 <TR>
408                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
409                                 &lt;16&gt;
410                         </TD>
411                         <TD>
412                                 The minimum block size (in samples) used in the stream.
413                         </TD>
414                 </TR>
415                 <TR>
416                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
417                                 &lt;16&gt;
418                         </TD>
419                         <TD>
420                                 The maximum block size (in samples) used in the stream.  (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
421                         </TD>
422                 </TR>
423                 <TR>
424                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
425                                 &lt;24&gt;
426                         </TD>
427                         <TD>
428                                 The minimum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
429                         </TD>
430                 </TR>
431                 <TR>
432                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
433                                 &lt;24&gt;
434                         </TD>
435                         <TD>
436                                 The maximum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
437                         </TD>
438                 </TR>
439                 <TR>
440                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
441                                 &lt;20&gt;
442                         </TD>
443                         <TD>
444                                 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.
445                         </TD>
446                 </TR>
447                 <TR>
448                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
449                                 &lt;3&gt;
450                         </TD>
451                         <TD>
452                                 (number of channels)-1.  FLAC supports from 1 to 8 channels
453                         </TD>
454                 </TR>
455                 <TR>
456                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
457                                 &lt;5&gt;
458                         </TD>
459                         <TD>
460                                 (bits per sample)-1.  FLAC supports from 1 to 32 bits per sample.  Currently the reference encoder and decoders only support up to 24 bits per sample.
461                         </TD>
462                 </TR>
463                 <TR>
464                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
465                                 &lt;36&gt;
466                         </TD>
467                         <TD>
468                                 Total samples in stream.  'Samples' means channel-wide 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.
469                         </TD>
470                 </TR>
471                 <TR>
472                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
473                                 &lt;128&gt;
474                         </TD>
475                         <TD>
476                                 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.
477                         </TD>
478                 </TR>
479                 <TR>
480                         <TD>
481                         </TD>
482                         <TD BGCOLOR="#F4F4CC">
483                                 <FONT SIZE="+1">NOTES</FONT><BR>
484                                 <UL>
485                                 <LI>
486                                         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.
487                                 </LI>
488                                 </UL>
489                         </TD>
490                 </TR>
491         </TABLE>
492         </TD></TR></TABLE>
493         </P>
494
495         <P>
496         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
497         <TABLE WIDTH="100%" BORDER="1">
498                 <TR>
499                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
500                                 <A NAME="metadata_block_padding"><FONT SIZE="+1"><B>METADATA_BLOCK_PADDING</B></FONT></A>
501                         </TD>
502                 </TR>
503                 <TR>
504                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
505                                 &lt;n&gt;
506                         </TD>
507                         <TD>
508                                 n '0' bits (n must be a multiple of 8)
509                         </TD>
510                 </TR>
511         </TABLE>
512         </TD></TR></TABLE>
513         </P>
514
515         <P>
516         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
517         <TABLE WIDTH="100%" BORDER="1">
518                 <TR>
519                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
520                                 <A NAME="metadata_block_application"><FONT SIZE="+1"><B>METADATA_BLOCK_APPLICATION</B></FONT></A>
521                         </TD>
522                 </TR>
523                 <TR>
524                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
525                                 &lt;32&gt;
526                         </TD>
527                         <TD>
528                                 Registered application ID
529                         </TD>
530                 </TR>
531                 <TR>
532                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
533                                 &lt;n&gt;
534                         </TD>
535                         <TD>
536                                 Application data (n must be a multiple of 8)
537                         </TD>
538                 </TR>
539         </TABLE>
540         </TD></TR></TABLE>
541         </P>
542
543         <P>
544         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
545         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
546                 <TR>
547                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
548                                 <A NAME="frame"><FONT SIZE="+1"><B>FRAME</B></FONT></A>
549                         </TD>
550                 </TR>
551                 <TR>
552                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
553                                 <A HREF="#frame_header"><I>FRAME_HEADER</I></A>
554                         </TD>
555                         <TD>
556                                 &nbsp;
557                         </TD>
558                 </TR>
559                 <TR>
560                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
561                                 <A HREF="#subframe"><I>SUBFRAME</I></A>+
562                         </TD>
563                         <TD>
564                                 One SUBFRAME per channel.
565                         </TD>
566                 </TR>
567                 <TR>
568                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
569                                 &lt;?&gt;
570                         </TD>
571                         <TD>
572                                 Zero-padding to byte alignment.
573                         </TD>
574                 </TR>
575         </TABLE>
576         </TD></TR></TABLE>
577         </P>
578
579         <P>
580         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
581         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
582                 <TR>
583                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
584                                 <A NAME="frame_header"><FONT SIZE="+1"><B>FRAME_HEADER</B></FONT></A>
585                         </TD>
586                 </TR>
587                 <TR>
588                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
589                                 &lt;9&gt;
590                         </TD>
591                         <TD>
592                                 sync code '<TT>111111110</TT>'
593                         </TD>
594                 </TR>
595                 <TR>
596                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
597                                 &lt;3&gt;
598                         </TD>
599                         <TD>
600                                 block size in channel-wide samples:<BR>
601                                 <UL>
602                                 <LI>
603                                         <TT>000</TT> : get from STREAMINFO metadata block
604                                 </LI>
605                                 <LI>
606                                         <TT>001</TT> : 192 samples
607                                 </LI>
608                                 <LI>
609                                         <TT>010-101</TT> : 576 * (2^(2-n)) samples, i.e. 576/1152/2304/4608
610                                 </LI>
611                                 <LI>
612                                         <TT>110</TT> : get 8 bit (blocksize-1) from end of header
613                                 </LI>
614                                 <LI>
615                                         <TT>111</TT> : get 16 bit (blocksize-1) from end of header
616                                 </LI>
617                                 </UL>
618                         </TD>
619                 </TR>
620                 <TR>
621                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
622                                 &lt;4&gt;
623                         </TD>
624                         <TD>
625                                 sample rate:<BR>
626                                 <UL>
627                                 <LI>
628                                         <TT>0000</TT> : get from STREAMINFO metadata block
629                                 </LI>
630                                 <LI>
631                                         <TT>0001-0011</TT> : reserved
632                                 </LI>
633                                 <LI>
634                                         <TT>0100</TT> : 8kHz
635                                 </LI>
636                                 <LI>
637                                         <TT>0101</TT> : 16kHz
638                                 </LI>
639                                 <LI>
640                                         <TT>0110</TT> : 22.05kHz
641                                 </LI>
642                                 <LI>
643                                         <TT>0111</TT> : 24kHz
644                                 </LI>
645                                 <LI>
646                                         <TT>1000</TT> : 32kHz
647                                 </LI>
648                                 <LI>
649                                         <TT>1001</TT> : 44.1kHz
650                                 </LI>
651                                 <LI>
652                                         <TT>1010</TT> : 48kHz
653                                 </LI>
654                                 <LI>
655                                         <TT>1011</TT> : 96kHz
656                                 </LI>
657                                 <LI>
658                                         <TT>1100</TT> : get 8 bit sample rate (in kHz) from end of header
659                                 </LI>
660                                 <LI>
661                                         <TT>1101</TT> : get 16 bit sample rate (in Hz) from end of header
662                                 </LI>
663                                 <LI>
664                                         <TT>1110</TT> : get 16 bit sample rate (in tens of Hz) from end of header
665                                 </LI>
666                                 <LI>
667                                         <TT>1111</TT> : invalid, to prevent sync-fooling string of 1s
668                                 </LI>
669                                 </UL>
670                         </TD>
671                 </TR>
672                 <TR>
673                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
674                                 &lt;4&gt;
675                         </TD>
676                         <TD>
677                                 channel assignment
678                                 <UL>
679                                 <LI>
680                                         <TT>0000-0111</TT> : (number of independent channels)-1.  when == 0001, channel 0 is the left channel and channel 1 is the right
681                                 </LI>
682                                 <LI>
683                                         <TT>1000</TT> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
684                                 </LI>
685                                 <LI>
686                                         <TT>1001</TT> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
687                                 </LI>
688                                 <LI>
689                                         <TT>1010</TT> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
690                                 </LI>
691                                 <LI>
692                                         <TT>1011-1111</TT> : reserved
693                                 </LI>
694                                 </UL>
695                         </TD>
696                 </TR>
697                 <TR>
698                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
699                                 &lt;3&gt;
700                         </TD>
701                         <TD>
702                                 sample size in bits:<BR>
703                                 <UL>
704                                 <LI>
705                                         <TT>000</TT> : get from STREAMINFO metadata block
706                                 </LI>
707                                 <LI>
708                                         <TT>001</TT> : 8 bits per sample
709                                 </LI>
710                                 <LI>
711                                         <TT>010</TT> : 12 bits per sample
712                                 </LI>
713                                 <LI>
714                                         <TT>011</TT> : reserved
715                                 </LI>
716                                 <LI>
717                                         <TT>100</TT> : 16 bits per sample
718                                 </LI>
719                                 <LI>
720                                         <TT>101</TT> : 20 bits per sample
721                                 </LI>
722                                 <LI>
723                                         <TT>110</TT> : 24 bits per sample
724                                 </LI>
725                                 <LI>
726                                         <TT>111</TT> : reserved
727                                 </LI>
728                                 </UL>
729                         </TD>
730                 </TR>
731                 <TR>
732                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
733                                 &lt;1&gt;
734                         </TD>
735                         <TD>
736                                 zero bit padding, to prevent sync-fooling string of 1s
737                         </TD>
738                 </TR>
739                 <TR>
740                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
741                                 &lt;?&gt;
742                         </TD>
743                         <TD>
744                                 if(variable blocksize)<BR>
745                                 &nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits)<BR>
746                                 else<BR>
747                                 &nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits)
748                         </TD>
749                 </TR>
750                 <TR>
751                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
752                                 &lt;?&gt;
753                         </TD>
754                         <TD>
755                                 if(blocksize bits == 11x)<BR>
756                                 &nbsp;&nbsp;&nbsp;8/16 bit (blocksize-1)
757                         </TD>
758                 </TR>
759                 <TR>
760                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
761                                 &lt;?&gt;
762                         </TD>
763                         <TD>
764                                 if(sample rate bits == 11xx)<BR>
765                                 &nbsp;&nbsp;&nbsp;8/16 bit sample rate
766                         </TD>
767                 </TR>
768                 <TR>
769                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
770                                 &lt;8&gt;
771                         </TD>
772                         <TD>
773                                 CRC-8 (polynomial = x^8 + x^2 + x + 1) of everything before the crc, including the sync code
774                         </TD>
775                 </TR>
776                 <TR>
777                         <TD>
778                         </TD>
779                         <TD BGCOLOR="#F4F4CC">
780                                 <FONT SIZE="+1">NOTES</FONT><BR>
781                                 <UL>
782                                 <LI>
783                                         The blocksize bits 000-101 may only be used if the blocksize is fixed throughout the entire stream.  Blocksize bits 110-111 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 110-111 on the last frame of a fixed-blocksize stream, as long as the blocksize is not greater than the stream blocksize.
784                                 </LI>
785                                 <LI>
786                                         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.
787                                 </LI>
788                                 </UL>
789                         </TD>
790                 </TR>
791         </TABLE>
792         </TD></TR></TABLE>
793         </P>
794
795         <P>
796         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
797         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
798                 <TR>
799                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
800                                 <A NAME="subframe"><FONT SIZE="+1"><B>SUBFRAME</B></FONT></A>
801                         </TD>
802                 </TR>
803                 <TR>
804                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
805                                 <A HREF="#subframe_header"><I>SUBFRAME_HEADER</I></A>
806                         </TD>
807                         <TD>
808                                 &nbsp;
809                         </TD>
810                 </TR>
811                 <TR>
812                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
813                                 <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>
814                         </TD>
815                         <TD VALIGN="TOP">
816                                 The SUBFRAME_HEADER specifies which one.
817                         </TD>
818                 </TR>
819         </TABLE>
820         </TD></TR></TABLE>
821         </P>
822
823         <P>
824         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
825         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
826                 <TR>
827                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
828                                 <A NAME="subframe_header"><FONT SIZE="+1"><B>SUBFRAME_HEADER</B></FONT></A>
829                         </TD>
830                 </TR>
831                 <TR>
832                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
833                                 &lt;8&gt;
834                         </TD>
835                         <TD>
836                                 Subframe type:
837                                 <UL>
838                                 <LI>
839                                         <TT>xxxxxxx1</TT> : invalid, to prevent sync-fooling string of 1s
840                                 </LI>
841                                 <LI>
842                                         <TT>00000000</TT> : <A HREF="#subframe_constant">SUBFRAME_CONSTANT</A>
843                                 </LI>
844                                 <LI>
845                                         <TT>00000010</TT> : <A HREF="#subframe_verbatim">SUBFRAME_VERBATIM</A>
846                                 </LI>
847                                 <LI>
848                                         <TT>000001x0</TT> : reserved
849                                 </LI>
850                                 <LI>
851                                         <TT>00001xx0</TT> : reserved
852                                 </LI>
853                                 <LI>
854                                         <TT>0001xxx0</TT> : if(xxx <= 4) <A HREF="#subframe_fixed">SUBFRAME_FIXED</A>, xxx=order ; else reserved
855                                 </LI>
856                                 <LI>
857                                         <TT>001xxxx0</TT> : reserved
858                                 </LI>
859                                 <LI>
860                                         <TT>01xxxxx0</TT> : <A HREF="#subframe_lpc">SUBFRAME_LPC</A>, xxxxx=order-1
861                                 </LI>
862                                 <LI>
863                                         <TT>1xxxxxxx</TT> : invalid, to prevent sync-fooling string of 1s
864                                 </LI>
865                                 </UL>
866                         </TD>
867                 </TR>
868         </TABLE>
869         </TD></TR></TABLE>
870         </P>
871
872         <P>
873         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
874         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
875                 <TR>
876                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
877                                 <A NAME="subframe_constant"><FONT SIZE="+1"><B>SUBFRAME_CONSTANT</B></FONT></A>
878                         </TD>
879                 </TR>
880                 <TR>
881                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
882                                 &lt;n&gt;
883                         </TD>
884                         <TD>
885                                 Unencoded constant value of the subblock, n = frame's bits-per-sample.
886                         </TD>
887                 </TR>
888         </TABLE>
889         </TD></TR></TABLE>
890         </P>
891
892         <P>
893         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
894         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
895                 <TR>
896                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
897                                 <A NAME="subframe_fixed"><FONT SIZE="+1"><B>SUBFRAME_FIXED</B></FONT></A>
898                         </TD>
899                 </TR>
900                 <TR>
901                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
902                                 &lt;n&gt;
903                         </TD>
904                         <TD>
905                                 Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
906                         </TD>
907                 </TR>
908                 <TR>
909                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
910                                 <A HREF="#residual"><I>RESIDUAL</I></A>
911                         </TD>
912                         <TD>
913                                 Encoded residual
914                         </TD>
915                 </TR>
916         </TABLE>
917         </TD></TR></TABLE>
918         </P>
919
920         <P>
921         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
922         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
923                 <TR>
924                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
925                                 <A NAME="subframe_lpc"><FONT SIZE="+1"><B>SUBFRAME_LPC</B></FONT></A>
926                         </TD>
927                 </TR>
928                 <TR>
929                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
930                                 &lt;n&gt;
931                         </TD>
932                         <TD>
933                                 Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
934                         </TD>
935                 </TR>
936                 <TR>
937                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
938                                 &lt;4&gt;
939                         </TD>
940                         <TD>
941                                 (quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
942                         </TD>
943                 </TR>
944                 <TR>
945                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
946                                 &lt;5&gt;
947                         </TD>
948                         <TD>
949                                 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement).
950                         </TD>
951                 </TR>
952                 <TR>
953                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
954                                 &lt;n&gt;
955                         </TD>
956                         <TD>
957                                 Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
958                         </TD>
959                 </TR>
960                 <TR>
961                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
962                                 <A HREF="#residual"><I>RESIDUAL</I></A>
963                         </TD>
964                         <TD>
965                                 Encoded residual
966                         </TD>
967                 </TR>
968         </TABLE>
969         </TD></TR></TABLE>
970         </P>
971
972         <P>
973         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
974         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
975                 <TR>
976                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
977                                 <A NAME="subframe_verbatim"><FONT SIZE="+1"><B>SUBFRAME_VERBATIM</B></FONT></A>
978                         </TD>
979                 </TR>
980                 <TR>
981                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
982                                 &lt;n*i&gt;
983                         </TD>
984                         <TD>
985                                 Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
986                         </TD>
987                 </TR>
988         </TABLE>
989         </TD></TR></TABLE>
990         </P>
991
992         <P>
993         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
994         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
995                 <TR>
996                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
997                                 <A NAME="residual"><FONT SIZE="+1"><B>RESIDUAL</B></FONT></A>
998                         </TD>
999                 </TR>
1000                 <TR>
1001                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1002                                 &lt;2&gt;
1003                         </TD>
1004                         <TD>
1005                                 Residual coding method:<BR>
1006                                 <UL>
1007                                 <LI>
1008                                         <TT>00</TT> : partitioned rice coding
1009                                 </LI>
1010                                 <LI>
1011                                         <TT>01-11</TT> : reserved
1012                                 </LI>
1013                                 </UL>
1014                         </TD>
1015                 </TR>
1016                 <TR>
1017                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1018                                 <A HREF="#partitioned_rice"><I>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</I></A>
1019                         </TD>
1020                         <TD>
1021                                 &nbsp;
1022                         </TD>
1023                 </TR>
1024                 <TR>
1025                         <TD>
1026                         </TD>
1027                         <TD BGCOLOR="#F4F4CC">
1028                                 <FONT SIZE="+1">NOTES</FONT><BR>
1029                                 <UL>
1030                                 <LI>
1031                                         Currently, FLAC specifies only one entropy coding method.
1032                                 </LI>
1033                                 </UL>
1034                         </TD>
1035                 </TR>
1036         </TABLE>
1037         </TD></TR></TABLE>
1038         </P>
1039
1040         <P>
1041         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1042         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1043                 <TR>
1044                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1045                                 <A NAME="partitioned_rice"><FONT SIZE="+1"><B>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</B></FONT></A>
1046                         </TD>
1047                 </TR>
1048                 <TR>
1049                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1050                                 &lt;4&gt;
1051                         </TD>
1052                         <TD>
1053                                 Partition order.
1054                         </TD>
1055                 </TR>
1056                 <TR>
1057                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1058                                 <A HREF="#rice_partition"><I>RICE_PARTITION</I></A>+
1059                         </TD>
1060                         <TD>
1061                                 There will be 2^order partitions.
1062                         </TD>
1063                 </TR>
1064         </TABLE>
1065         </TD></TR></TABLE>
1066         </P>
1067
1068         <P>
1069         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1070         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1071                 <TR>
1072                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1073                                 <A NAME="rice_partition"><FONT SIZE="+1"><B>RICE_PARTITION</B></FONT></A>
1074                         </TD>
1075                 </TR>
1076                 <TR>
1077                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1078                                 &lt;4&gt;
1079                         </TD>
1080                         <TD>
1081                                 Rice parameter
1082                         </TD>
1083                 </TR>
1084                 <TR>
1085                         <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1086                                 &lt;?&gt;
1087                         </TD>
1088                         <TD>
1089                                 Encoded residual.  The number of samples (n) in the partition is determined as follows:<BR>
1090                                 <UL>
1091                                 <LI>
1092                                         if the partition order is zero, n = frame's blocksize
1093                                 </LI>
1094                                 <LI>
1095                                         else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1096                                 </LI>
1097                                 <LI>
1098                                         else n = (frame's blocksize / (2^partition order)) - predictor order
1099                                 </LI>
1100                                 </UL>
1101                         </TD>
1102                 </TR>
1103         </TABLE>
1104         </TD></TR></TABLE>
1105         </P>
1106
1107 </TD></TR>
1108 </TABLE>
1109
1110
1111 </CENTER>
1112
1113 </BODY>
1114 </HTML>