1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <!-- Copyright (c) 2000,2001,2002 Josh Coalson -->
3 <!-- Permission is granted to copy, distribute and/or modify this document -->
4 <!-- under the terms of the GNU Free Documentation License, Version 1.1 -->
5 <!-- or any later version published by the Free Software Foundation; -->
6 <!-- with no invariant sections. -->
7 <!-- A copy of the license can be found at http://www.gnu.org/copyleft/fdl.html -->
10 <TITLE>FLAC - format</TITLE>
13 <BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#99CC99" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
15 <TABLE BORDER=0 WIDTH="100%" CELLPADDING=1 CELLSPACING=0>
17 <TD ALIGN="CENTER" BGCOLOR="#000000"><A HREF="http://flac.sourceforge.net/"><IMG SRC="images/logo.jpg" ALIGN=CENTER ALT="FLAC Logo" BORDER=0 HSPACE=0></a></TD>
21 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#99CC99"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="25" ALT=""></TD></TR></TABLE>
23 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
25 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
27 <TD ALIGN="CENTER" BGCOLOR="#D3D4C5">
28 <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
30 <TD HEIGHT=22 BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="index.html">home</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
31 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="news.html">news</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
32 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="download.html">download</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
33 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="features.html">features</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
34 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="goals.html">goals</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
35 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> format </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
36 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="id.html">id</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
37 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="comparison.html">comparison</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
38 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="documentation.html">documentation</A> </TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
39 <TD BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="developers.html">developers</A> </TD>
46 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
48 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
50 <TD ALIGN="CENTER" BGCOLOR="#EEEED4">
51 <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
53 <TD HEIGHT=22 BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP> english </TD><TD BGCOLOR="#EEEED4" ALIGN=CENTER>|</TD>
54 <TD BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP> <A CLASS="topnav" HREF="ru/format.html">russian</A> </TD>
61 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
65 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#99CC99"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="15" ALT=""></TD></TR></TABLE>
68 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
70 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
71 <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
72 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
73 <B><FONT SIZE="+2">format</FONT></B>
76 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
77 <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
78 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
80 This is a detailed description of the FLAC format.
83 First, as the original developer I have to say that I am not a compression expert and I feel obligated to give credit where it is due. FLAC owes a lot to the many people who have advanced the audio compression field so freely. For instance:
88 <A HREF="http://svr-www.eng.cam.ac.uk/~ajr/">A. J. Robinson</A> for his work on <A HREF="http://www-svr.eng.cam.ac.uk/reports/abstracts/robinson_tr156.html">Shorten</A>; his paper is a good starting point on some of the basic methods used by FLAC. FLAC expands on the fixed predictors used in shorten.
91 <A HREF="http://commsci.usc.edu/faculty/golomb.html">S. W. Golomb</A> and Robert F. Rice; their universal codes are used by FLAC's entropy coder.
94 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.
97 And of course, the main guy, <A HREF="http://www.digitalcentury.com/encyclo/update/shannon.html">Claude Shannon</A>
102 <A NAME="scope"><FONT SIZE="+1"><B><U>Scope</U></B></FONT></A>
105 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.
108 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.
111 <A NAME="architecture"><FONT SIZE="+1"><B><U>Architecture</U></B></FONT></A>
114 Similar to many audio coders, a FLAC encoder has the following stages:
118 <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.
121 <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.
124 <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.
127 <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.
131 In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.
134 <A NAME="definitions"><FONT SIZE="+1"><B><U>Definitions</U></B></FONT></A>
137 Many terms like "block" and "frame" are used to mean different things in differenct encoding schemes. For example, a frame in MP3 corresponds to many samples across several channels, whereas an S/PDIF frame represents just one sample for each channel. The definitions we use for FLAC follow. Note that when we talk about blocks and subblocks we are refering to the raw unencoded audio data that is the input to the encoder, and when we talk about frames and subframes, we are refering to the FLAC-encoded data.
141 <B>Block</B>: One or more audio samples that span several channels.
144 <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.
147 <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.
150 <B>Frame</B>: A frame header plus one or more subframes.
153 <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.
157 <A NAME="blocking"><FONT SIZE="+1"><B><U>Blocking</U></B></FONT></A>
160 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.
163 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.
166 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.
169 <A NAME="interchannel"><FONT SIZE="+1"><B><U>Interchannel Decorrelation</U></B></FONT></A>
172 In stereo streams, in many cases there is an exploitable amount of correlation between the left and right channels. FLAC allows the frames of stereo streams to have different channel assignments, and an encoder may choose to use the best representation on a frame-by-frame basis.
176 <B>Independent</B>. The left and right channels are coded independently.
179 <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).
182 <B>Left-side</B>. The left channel and side channel are coded.
185 <B>Right-side</B>. The right channel and side channel are coded
189 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.
192 <A NAME="prediction"><FONT SIZE="+1"><B><U>Prediction</U></B></FONT></A>
195 FLAC uses four methods for modeling the input signal:
199 <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.
202 <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.
205 <B>Fixed linear predictor</B>. FLAC uses a class of computationally-efficient fixed linear predictors (for a good description, see <A HREF="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</A> and <A HREF="http://svr-www.eng.cam.ac.uk/~ajr/GroupPubs/Robinson94-tr156/index.html">shorten</A>). FLAC adds a fourth-order predictor to the zero-to-third-order predictors used by Shorten. Since the predictors are fixed, the predictor order is the only parameter that needs to be stored in the compressed stream. The error signal is then passed to the residual coder.
208 <B>FIR Linear prediction</B>. For more accurate modeling (at a cost of slower encoding), FLAC supports up to 32nd order FIR linear prediction (again, for info on linear prediction, see <A HREF="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</A> and <A HREF="http://svr-www.eng.cam.ac.uk/~ajr/GroupPubs/Robinson94-tr156/index.html">shorten</A>). The reference encoder uses the Levinson-Durbin method for calculating the LPC coefficients from the autocorrelation coefficients, and the coefficients are quantized before computing the residual. Whereas encoders such as Shorten used a fixed quantization for the entire input, FLAC allows the quantized coefficient precision to vary from subframe to subframe. The FLAC reference encoder estimates the optimal precision to use based on the block size and dynamic range of the original signal.
212 <A NAME="residualcoding"><FONT SIZE="+1"><B><U>Residual Coding</U></B></FONT></A>
215 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.)
218 The FLAC format has reserved space for other coding methods. Some possiblities for volunteers would be to explore better context-modeling of the Rice parameter, or Huffman coding. See <A HREF="http://www.hpl.hp.com/techreports/98/HPL-98-193.html">LOCO-I</A> and <A HREF="http://www.cs.tut.fi/~albert/Dev/pucrunch/packing.html">pucrunch</A> for descriptions of several universal codes.
221 <FONT SIZE="+1"><B><U>Format</U></B></FONT>
224 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.
227 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.
230 <A NAME="overview">A FLAC bitstream may be appended with ID3V1 data or prepended with ID3V2 data. FLAC has no knowledge of such data, but the reference decoder knows how to skip an ID3 tag.</A>
233 Before the formal description of the stream, an overview might be helpful.
237 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.
240 FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
242 <LI><A NAME="def_STREAMINFO"><B>STREAMINFO</B>: This block has information about the whole stream, like sample rate, number of channels, total number of samples, etc. It must be present as the first metadata block in the stream. Other metadata blocks may follow, and ones that the decoder doesn't understand, it will skip.</LI>
243 <LI><A NAME="def_APPLICATION"><B>APPLICATION</B>: This block is for use by third-party applications. The only mandatory field is a 32-bit identifier. This ID is granted upon request to an application by the FLAC maintainers. The remainder is of the block is defined by the registered application. Visit the <A HREF="id.html">registration page</A> if you would like to register an ID for your application with FLAC.</LI>
244 <LI><A NAME="def_PADDING"><B>PADDING</B>: This block allows for an arbitrary amount of padding. The contents of a PADDING block have no meaning. This block is useful when it is known that an APPLICATION block will be added after encoding; the user can instruct the encoder to reserve a PADDING block of the proper size so that the application may directly write over it later (which is relatively quick) instead of having to insert the APPLICATION block (which would normally require rewriting the entire file).</LI>
245 <LI><A NAME="def_SEEKTABLE"><B>SEEKTABLE</B>: This is an optional block for storing seek points. It is possible to seek to any given sample in a FLAC stream without a seek table, but the delay can be unpredictable since the bitrate may vary widely within a stream. By adding seek points to a stream, this delay can be significantly reduced. Each seek point takes 18 bytes, so 1% resolution within a stream adds less than 2k. There can be only one SEEKTABLE in a stream, but the table can have any number of seek points. There is also a special 'placeholder' seekpoint which will be ignored by decoders but which can be used to reserve space for future seek point insertion.</LI>
249 The audio data is composed of one or more audio frames. Each frame consists of a frame header, which contains a sync code, info about the frame like the block size, sample rate, number of channels, et cetera, and an 8-bit CRC. The frame header also contains either the sample number of the first sample in the frame (for variable-blocksize streams), or the frame number (for fixed-blocksize streams). This allows for fast, sample-accurate seeking to be performed. Following the frame header are encoded subframes, one for each channel, and finally, the frame is zero-padded to a byte boundary. Each subframe has its own header that specifies how the subframe is encoded.
252 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.
255 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.
258 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.
261 <A NAME="subset">FLAC specifies a subset of itself as the Subset format. The purpose of this is to ensure that any streams encoded according to the Subset are truly "streamable", meaning that a decoder that cannot seek within the stream can still pick up in the middle of the stream and start decoding. It also makes hardware decoder implementations more practical by limiting the encoding parameters such that decoder buffer sizes and other resource requirements can be easily determined. "flac" generates Subset streams by default unless the "--lax" command-line option is used. The Subset makes the following limitations on what may be used in the stream:
264 The blocksize bits in the <A HREF="#frame_header">frame header</A> must be 0001-0101 or 1000-1110, specifying a fixed-blocksize stream (the exception being the last block as described in the table) and a few allowable blocksizes. This also means that the STREAMINFO metadata block must specify equal mininum and maximum blocksizes.
267 The sample rate bits in the <A HREF="#frame_header">frame header</A> must be 0001-1011.
270 The bits-per-sample bits in the <A HREF="#frame_header">frame header</A> must be 001-111.
277 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.
283 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
286 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
287 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
289 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
290 <A NAME="stream"><FONT SIZE="+1"><B>STREAM</B></FONT></A>
294 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
298 "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
302 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
303 <A HREF="#metadata_block_streaminfo"><I>METADATA_BLOCK</I></A>
306 This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
310 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
311 <A HREF="#metadata_block"><I>METADATA_BLOCK</I></A>*
314 Zero or more metadata blocks
318 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
319 <A HREF="#frame"><I>FRAME</I></A>+
322 One or more audio frames
330 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
331 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
333 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
334 <A NAME="metadata_block"><FONT SIZE="+1"><B>METADATA_BLOCK</B></FONT></A>
338 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
339 <A HREF="#metadata_block_header"><I>METADATA_BLOCK_HEADER</I></A>
342 A block header that specifies the type and size of the metadata block data.
346 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
347 <A HREF="#metadata_block_data"><I>METADATA_BLOCK_DATA</I></A>
358 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
359 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
361 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
362 <A NAME="metadata_block_header"><FONT SIZE="+1"><B>METADATA_BLOCK_HEADER</B></FONT></A>
366 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
370 Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
374 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
381 <TT>0</TT> : STREAMINFO
387 <TT>2</TT> : APPLICATION
390 <TT>3</TT> : SEEKTABLE
393 <TT>4</TT> : VORBIS_COMMENT
396 <TT>4</TT> : CUESHEET
399 <TT>6-127</TT> : reserved
405 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
409 Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
417 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
418 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
420 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
421 <A NAME="metadata_block_data"><FONT SIZE="+1"><B>METADATA_BLOCK_DATA</B></FONT></A>
425 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
426 <A HREF="#metadata_block_streaminfo"><I>METADATA_BLOCK_STREAMINFO</I></A><BR>|| <A HREF="#metadata_block_padding"><I>METADATA_BLOCK_PADDING</I></A><BR>|| <A HREF="#metadata_block_application"><I>METADATA_BLOCK_APPLICATION</I></A><BR>|| <A HREF="#metadata_block_seektable"><I>METADATA_BLOCK_SEEKTABLE</I></A><BR>|| <A HREF="#metadata_block_vorbis_comment"><I>METADATA_BLOCK_VORBIS_COMMENT</I></A>
429 The block data must match the block type in the block header.
437 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
438 <TABLE WIDTH="100%" BORDER="1">
440 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
441 <A NAME="metadata_block_streaminfo"><FONT SIZE="+1"><B>METADATA_BLOCK_STREAMINFO</B></FONT></A>
445 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
449 The minimum block size (in samples) used in the stream.
453 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
457 The maximum block size (in samples) used in the stream. (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
461 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
465 The minimum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
469 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
473 The maximum frame size (in bytes) used in the stream. May be 0 to imply the value is not known.
477 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
481 Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 1048570Hz. Also, a value of 0 is invalid.
485 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
489 (number of channels)-1. FLAC supports from 1 to 8 channels
493 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
497 (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.
501 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
505 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.
509 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
513 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.
519 <TD BGCOLOR="#F4F4CC">
520 <FONT SIZE="+1">NOTES</FONT><BR>
523 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.
533 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
534 <TABLE WIDTH="100%" BORDER="1">
536 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
537 <A NAME="metadata_block_padding"><FONT SIZE="+1"><B>METADATA_BLOCK_PADDING</B></FONT></A>
541 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
545 n '0' bits (n must be a multiple of 8)
553 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
554 <TABLE WIDTH="100%" BORDER="1">
556 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
557 <A NAME="metadata_block_application"><FONT SIZE="+1"><B>METADATA_BLOCK_APPLICATION</B></FONT></A>
561 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
565 Registered application ID. (Visit the <A HREF="id.html">registration page</A> to register an ID with FLAC.)
569 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
573 Application data (n must be a multiple of 8)
581 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
582 <TABLE WIDTH="100%" BORDER="1">
584 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
585 <A NAME="metadata_block_seektable"><FONT SIZE="+1"><B>METADATA_BLOCK_SEEKTABLE</B></FONT></A>
589 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
590 <A HREF="#seekpoint"><I>SEEKPOINT</I></A>+
593 One or more seek points.
599 <TD BGCOLOR="#F4F4CC">
600 <FONT SIZE="+1">NOTE</FONT><BR>
603 The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
613 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
614 <TABLE WIDTH="100%" BORDER="1">
616 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
617 <A NAME="seekpoint"><FONT SIZE="+1"><B>SEEKPOINT</B></FONT></A>
621 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
625 Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
629 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
633 Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
637 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
641 Number of samples in the target frame.
647 <TD BGCOLOR="#F4F4CC">
648 <FONT SIZE="+1">NOTES</FONT><BR>
651 For placeholder points, the second and third field values are undefined.
654 Seek points within a table must be sorted in ascending order by sample number.
657 Seek points within a table must be unique by sample number, with the exception of placeholder points.
660 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.
670 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
671 <TABLE WIDTH="100%" BORDER="1">
673 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
674 <A NAME="metadata_block_vorbis_comment"><FONT SIZE="+1"><B>METADATA_BLOCK_VORBIS_COMMENT</B></FONT></A>
678 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
682 The contents of a vorbis comment packet as specified <A HREF="http://www.xiph.org/ogg/vorbis/doc/v-comment.html">here</A>, including the vendor string. Note that the vorbis comment spec allows for on the order of 2 ^ 64 bytes of data where as the FLAC metadata block is limited to 2 ^ 24 bytes. Given the stated purpose of vorbis comments, i.e. human-readable textual information, this limit is unlikely to be restrictive. Also note that the 32-bit field lengths are little-endian coded according to the vorbis spec, as opposed to the usual big-endian coding of fixed-length integers in the rest of FLAC.
690 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
691 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
693 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
694 <A NAME="frame"><FONT SIZE="+1"><B>FRAME</B></FONT></A>
698 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
699 <A HREF="#frame_header"><I>FRAME_HEADER</I></A>
706 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
707 <A HREF="#subframe"><I>SUBFRAME</I></A>+
710 One SUBFRAME per channel.
714 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
718 Zero-padding to byte alignment.
722 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
723 <A HREF="#frame_footer"><I>FRAME_FOOTER</I></A>
734 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
735 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
737 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
738 <A NAME="frame_header"><FONT SIZE="+1"><B>FRAME_HEADER</B></FONT></A>
742 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
746 Sync code '<TT>11111111111110</TT>'
750 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
757 <TT>00</TT> : mandatory value
760 <TT>01-11</TT> : reserved for future use
766 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
770 Block size in inter-channel samples:<BR>
773 <TT>0000</TT> : get from STREAMINFO metadata block
776 <TT>0001</TT> : 192 samples
779 <TT>0010-0101</TT> : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
782 <TT>0110</TT> : get 8 bit (blocksize-1) from end of header
785 <TT>0111</TT> : get 16 bit (blocksize-1) from end of header
788 <TT>1000-1111</TT> : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
794 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
801 <TT>0000</TT> : get from STREAMINFO metadata block
804 <TT>0001-0011</TT> : reserved
810 <TT>0101</TT> : 16kHz
813 <TT>0110</TT> : 22.05kHz
816 <TT>0111</TT> : 24kHz
819 <TT>1000</TT> : 32kHz
822 <TT>1001</TT> : 44.1kHz
825 <TT>1010</TT> : 48kHz
828 <TT>1011</TT> : 96kHz
831 <TT>1100</TT> : get 8 bit sample rate (in kHz) from end of header
834 <TT>1101</TT> : get 16 bit sample rate (in Hz) from end of header
837 <TT>1110</TT> : get 16 bit sample rate (in tens of Hz) from end of header
840 <TT>1111</TT> : invalid, to prevent sync-fooling string of 1s
846 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
853 <TT>0000-0111</TT> : (number of independent channels)-1. when == 0001, channel 0 is the left channel and channel 1 is the right
856 <TT>1000</TT> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
859 <TT>1001</TT> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
862 <TT>1010</TT> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
865 <TT>1011-1111</TT> : reserved
871 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
875 Sample size in bits:<BR>
878 <TT>000</TT> : get from STREAMINFO metadata block
881 <TT>001</TT> : 8 bits per sample
884 <TT>010</TT> : 12 bits per sample
887 <TT>011</TT> : reserved
890 <TT>100</TT> : 16 bits per sample
893 <TT>101</TT> : 20 bits per sample
896 <TT>110</TT> : 24 bits per sample
899 <TT>111</TT> : reserved
905 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
909 Zero bit padding, to prevent sync-fooling string of 1s
913 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
917 if(variable blocksize)<BR>
918 <8-56>:"UTF-8" coded sample number (decoded number is 36 bits)<BR>
920 <8-48>:"UTF-8" coded frame number (decoded number is 31 bits)
924 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
928 if(blocksize bits == 011x)<BR>
929 8/16 bit (blocksize-1)
933 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
937 if(sample rate bits == 11xx)<BR>
938 8/16 bit sample rate
942 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
946 CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
952 <TD BGCOLOR="#F4F4CC">
953 <FONT SIZE="+1">NOTES</FONT><BR>
956 The blocksize bits 0000-0101 and 1000-1111 may only be used if the blocksize is fixed throughout the entire stream. Blocksize bits 0110-0111 may be used in any case but the decoder will have to pessimistically guess that it is a variable-blocksize stream. There is only one special case: the encoder may use blocksize bits 0110-0111 on the last frame of a fixed-blocksize stream, as long as the blocksize is not greater than the stream blocksize.
959 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.
969 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
970 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
972 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
973 <A NAME="frame_footer"><FONT SIZE="+1"><B>FRAME_FOOTER</B></FONT></A>
977 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
981 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
989 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
990 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
992 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
993 <A NAME="subframe"><FONT SIZE="+1"><B>SUBFRAME</B></FONT></A>
997 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
998 <A HREF="#subframe_header"><I>SUBFRAME_HEADER</I></A>
1005 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1006 <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>
1009 The SUBFRAME_HEADER specifies which one.
1017 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1018 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1020 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1021 <A NAME="subframe_header"><FONT SIZE="+1"><B>SUBFRAME_HEADER</B></FONT></A>
1025 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1029 Zero bit padding, to prevent sync-fooling string of 1s
1033 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1040 <TT>000000</TT> : <A HREF="#subframe_constant">SUBFRAME_CONSTANT</A>
1043 <TT>000001</TT> : <A HREF="#subframe_verbatim">SUBFRAME_VERBATIM</A>
1046 <TT>00001x</TT> : reserved
1049 <TT>0001xx</TT> : reserved
1052 <TT>001xxx</TT> : if(xxx <= 4) <A HREF="#subframe_fixed">SUBFRAME_FIXED</A>, xxx=order ; else reserved
1055 <TT>01xxxx</TT> : reserved
1058 <TT>1xxxxx</TT> : <A HREF="#subframe_lpc">SUBFRAME_LPC</A>, xxxxx=order-1
1064 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1068 'Wasted bits-per-sample' flag:
1071 <TT>0</TT> : no wasted bits-per-sample in source subblock, k=0
1074 <TT>1</TT> : k wasted bits-per-sample in source subblock, k-1 follows, unary coded; i.e. k=3 => 001 follows, k=7 => 0000001 follows.
1083 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1084 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1086 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1087 <A NAME="subframe_constant"><FONT SIZE="+1"><B>SUBFRAME_CONSTANT</B></FONT></A>
1091 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1095 Unencoded constant value of the subblock, n = frame's bits-per-sample.
1103 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1104 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1106 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1107 <A NAME="subframe_fixed"><FONT SIZE="+1"><B>SUBFRAME_FIXED</B></FONT></A>
1111 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1115 Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
1119 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1120 <A HREF="#residual"><I>RESIDUAL</I></A>
1131 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1132 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1134 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1135 <A NAME="subframe_lpc"><FONT SIZE="+1"><B>SUBFRAME_LPC</B></FONT></A>
1139 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1143 Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
1147 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1151 (Quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
1155 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1159 Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement).
1163 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1167 Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
1171 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1172 <A HREF="#residual"><I>RESIDUAL</I></A>
1183 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1184 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1186 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1187 <A NAME="subframe_verbatim"><FONT SIZE="+1"><B>SUBFRAME_VERBATIM</B></FONT></A>
1191 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1195 Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
1203 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1204 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1206 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1207 <A NAME="residual"><FONT SIZE="+1"><B>RESIDUAL</B></FONT></A>
1211 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1215 Residual coding method:<BR>
1218 <TT>00</TT> : partitioned rice coding
1221 <TT>01-11</TT> : reserved
1227 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1228 <A HREF="#partitioned_rice"><I>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</I></A>
1237 <TD BGCOLOR="#F4F4CC">
1238 <FONT SIZE="+1">NOTES</FONT><BR>
1241 Currently, FLAC specifies only one entropy coding method.
1251 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1252 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1254 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1255 <A NAME="partitioned_rice"><FONT SIZE="+1"><B>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</B></FONT></A>
1259 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1267 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1268 <A HREF="#rice_partition"><I>RICE_PARTITION</I></A>+
1271 There will be 2^order partitions.
1279 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
1280 <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
1282 <TD COLSPAN="2" BGCOLOR="#D3D4C5">
1283 <A NAME="rice_partition"><FONT SIZE="+1"><B>RICE_PARTITION</B></FONT></A>
1287 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1291 Encoding parameter:<BR>
1294 <TT>0000-1110</TT> : Rice parameter.
1297 <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.
1303 <TD ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
1307 Encoded residual. The number of samples (n) in the partition is determined as follows:<BR>
1310 if the partition order is zero, n = frame's blocksize
1313 else if this is not the first partition of the subframe, n = (frame's blocksize / (2^partition order))
1316 else n = (frame's blocksize / (2^partition order)) - predictor order
1331 <P> Copyright (c) 2000,2001,2002 Josh Coalson</P>