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