ec8107afbc14b20d48fa4dcd2429d8843ea8020e
[platform/upstream/flac.git] / doc / documentation.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <!-- Copyright (c)  2000,2001  Josh Coalson -->
3 <!-- Permission is granted to copy, distribute and/or modify this document -->
4 <!-- under the terms of the GNU Free Documentation License, Version 1.1 -->
5 <!-- or any later version published by the Free Software Foundation; -->
6 <!-- with no invariant sections. -->
7 <!-- A copy of the license can be found at http://www.gnu.org/copyleft/fdl.html -->
8 <HTML>
9 <HEAD>
10         <TITLE>FLAC - documentation</TITLE>
11 </HEAD>
12
13 <BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#99CC99" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
14
15 <TABLE BORDER=0 WIDTH="100%" CELLPADDING=1 CELLSPACING=0>
16         <TR>
17                 <TD ALIGN="CENTER" BGCOLOR="#000000"><A HREF="http://flac.sourceforge.net/"><IMG SRC="images/logo.jpg" ALIGN=CENTER ALT="FLAC Logo" BORDER=0 HSPACE=0></a></TD>
18         </TR>
19 </TABLE>
20
21 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#99CC99"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="25" ALT=""></TD></TR></TABLE>
22
23 <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
24
25 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
26         <TR>
27                 <TD ALIGN="CENTER" BGCOLOR="#D3D4C5">
28                         <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
29                                 <TR>
30                                         <TD HEIGHT=22 BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="index.html">home</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
31                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="news.html">news</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
32                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="download.html">download</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
33                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="features.html">features</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
34                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="goals.html">goals</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
35                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="format.html">format</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
36                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="id.html">id</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
37                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="comparison.html">comparison</A>&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
38                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;documentation&nbsp;&nbsp;</TD><TD BGCOLOR="#D3D4C5" ALIGN=CENTER>|</TD>
39                                         <TD           BGCOLOR="#D3D4C5" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="developers.html">developers</A>&nbsp;&nbsp;</TD>
40                                 </TR>
41                         </TABLE>
42                 </TD>
43         </TR>
44 </TABLE>
45
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>
47
48 <TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>
49         <TR>
50                 <TD ALIGN="CENTER" BGCOLOR="#EEEED4">
51                         <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
52                                 <TR>
53                                         <TD HEIGHT=22 BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;english&nbsp;&nbsp;</TD><TD BGCOLOR="#EEEED4" ALIGN=CENTER>|</TD>
54                                         <TD           BGCOLOR="#EEEED4" ALIGN=CENTER NOWRAP>&nbsp;&nbsp;<A CLASS="topnav" HREF="ru/documentation.html">russian</A>&nbsp;&nbsp;</TD>
55                                 </TR>
56                         </TABLE>
57                 </TD>
58         </TR>
59 </TABLE>
60
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>
62
63 <CENTER>
64
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>
66
67
68 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
69 <TR><TD>
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">documentation</FONT></B>
74                 </FONT></TD></TR>
75         </TABLE>
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">
79         <P>
80                 This page is broken up into the following sections:
81                 <UL>
82                         <LI><A HREF="#format">format</A> - the user-level view of the FLAC format (for a more detailed explanation see the <A HREF="format.html">format page</A>).</LI>
83                         <LI><A HREF="#flac">flac</A> - the usage of the command-line file encoder/decoder <B><TT>flac</TT></B>.</LI>
84                         <LI><A HREF="#metaflac">metaflac</A> - the usage of the command-line FLAC metadata editor <B><TT>metaflac</TT></B>.</LI>
85                         <LI><A HREF="#plugins">plugins</A> - documentation for the various input plugins.</LI>
86                         <LI><A HREF="#libflac">libFLAC API</A> - for developers who want to add FLAC support to their programs.</LI>
87                         <LI><A HREF="#bugs">bugs</A> - known bugs.</LI>
88                 </UL>
89         </P>
90         <P>
91                 Keep in mind that the online version of this document will always apply to the latest release.  For older releases, check the documentation included with the release package.
92         </P>
93         </FONT>
94         </TD></TR>
95         </TABLE>
96         <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>
97 </TD></TR>
98 </TABLE>
99
100
101 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
102 <TR><TD>
103         <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>
104         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
105                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
106                 <A NAME="format"><B><FONT SIZE="+2">format</FONT></B>
107                 </FONT></TD></TR>
108         </TABLE>
109         <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>
110         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
111         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
112         <P>
113                 <B><TT>flac</TT></B> has been tuned so that the default options yield a good speed vs. compression tradeoff for many kinds of input.  However, if you are looking to maximize the compression rate or speed, or want to use the full power of FLAC's metadata system, this section is for you.  If not, just skip to the <A HREF="#flac">next section</A>.
114         </P>
115         <P>
116                 The basic structure of a FLAC stream is:
117                 <UL>
118                         <LI>The four byte string "fLaC"</LI>
119                         <LI>The <A HREF="format.html#def_STREAMINFO">STREAMINFO</A> metadata block</LI>
120                         <LI>Zero or more other metadata blocks</LI>
121                         <LI>One or more audio frames</LI>
122                 </UL>
123         </P>
124         <P>
125                 The first four bytes are to identify the FLAC stream.  The metadata that follows contains all the information about the stream except for the audio data itself.  After the metadata comes the encoded audio data.
126         </P>
127         <P>
128                 <B>METADATA</B>
129         </P>
130         <P>
131                 FLAC defines several types of metadata blocks (see the <A HREF="format.html">format</A> page for the complete list.  Metadata blocks can be any length and new ones can be defined.  A decoder is allowed to skip any metadata types it does not understand.  Only one is mandatory: the STREAMINFO block.  This block has information like the sample rate, number of channels, etc., and data that can help the decoder manage its buffers, like the minimum and maximum data rate and minimum and maximum block size.  Also included in the STREAMINFO block is the MD5 signature of the <I>unencoded</I> audio data.  This is useful for checking an entire stream for transmission errors.
132         </P>
133         <P>
134                 Other blocks allow for padding, seek tables, and application-specific data.  You can see <B><TT>flac</TT></B> options below for adding PADDING blocks or specifying seek points.  FLAC does not require seek points for seeking but they can speed up seeks, or be used for cueing in editing applications.
135         <P>
136         </P>
137                 Also, if you have a need of a custom metadata block, you can define your own and request an ID <A HREF="id.html">here</A>.  Then you can reserve a PADDING block of the correct size when encoding, and overwrite the padding block with your APPLICATION block after encoding.  The resulting stream will be FLAC compatible; decoders that are aware of your metadata can use it and the rest will safely ignore it.
138         </P>
139         <P>
140                 <B>AUDIO DATA</B>
141         </P>
142         <P>
143                 After the metadata comes the encoded audio data.  Audio data and metadata are not interleaved.  Like most audio codecs, FLAC splits the unencoded audio data into blocks, and encodes each block separately.  The encoded block is packed into a frame and appended to the stream.  The reference encoder uses a single block size for the whole stream but the FLAC format does not require it.
144         </P>
145         <P>
146                 <B>BLOCKING</B>
147         </P>
148         <P>
149                 The block size is an important parameter to encoding.  If it is too small, the frame overhead will lower the compression.  If it is too large, the modeling stage of the compressor will not be able to generate an efficient model.  Understanding FLAC's modeling will help you to improve compression for some kinds of input by varying the block size.  In the most general case, using linear prediction on 44.1kHz audio, the optimal block size will be between 2-6 ksamples.  <B><TT>flac</TT></B> defaults to a block size of 4608 in this case.  Using the fast fixed predictors, a smaller block size is usually preferable because of the smaller frame header.
150         </P>
151         <P>
152                 <B>INTER-CHANNEL DECORRELATION</B>
153         </P>
154         <P>
155                 In the case of stereo input, once the data is blocked it is optionally passed through an inter-channel decorrelation stage.  The left and right channels are converted to center and side channels through the following transformation: mid = (left + right) / 2, side = left - right.  This is a lossless process, unlike joint stereo.  For normal CD audio this can result in significant extra compression.  <B><TT>flac</TT></B> has two options for this: <TT>-m</TT> always compresses both the left-right and mid-side versions of the block and takes the smallest frame, and <TT>-M</TT>, which adaptively switches between left-right and mid-side.
156         </P>
157         <P>
158                 <B>MODELING</B>
159         </P>
160         <P>
161                 In the next stage, the encoder tries to approximate the signal with a function in such a way that when the approximation is subracted, the result (called the <I>residual</I>, <I>residue</I>, or <I>error</I>) requires fewer bits-per-sample to encode.  The function's parameters also have to be transmitted so they should not be so complex as to eat up the savings.  FLAC has two methods of forming approximations: 1) fitting a simple polynomial to the signal; and 2) general linear predictive coding (LPC).  I will not go into the details here, only some generalities that involve the encoding options.
162         </P>
163         <P>
164                 First, fixed polynomial prediction (specified with <TT>-l 0</TT>) is much faster, but less accurate than LPC.  The higher the maximum LPC order, the slower, but more accurate, the model will be.  However, there are diminishing returns with increasing orders.  Also, at some point (usually around order 9) the part of the encoder that guesses what is the best order to use will start to get it wrong and the compression will actually decrease slightly; at that point you will have to you will have to use the exhaustive search option <TT>-e</TT> to overcome this, which is significantly slower.
165         </P>
166         <P>
167                 Second, the parameters for the fixed predictors can be transmitted in 3 bits whereas the parameters for the LPC model depend on the bits-per-sample and LPC order.  This means the frame header length varies depending on the method and order you choose and can affect the optimal block size.
168         </P>
169         <P>
170                 <B>RESIDUAL CODING</B>
171         </P>
172         <P>
173                 Once the model is generated, the encoder subracts the approximation from the original signal to get the residual (error) signal.  The error signal is then losslessly coded.  To do this, FLAC takes advantage of the fact that the error signal generally has a Laplacian (two-sided geometric) distribution, and that there are a set of special Huffman codes called Rice codes that can be used to efficiently encode these kind of signals quickly and without needing a dictionary.
174         </P>
175         <P>
176                 Rice coding involves finding a single parameter that matches a signal's distribution, then using that parameter to generate the codes.  As the distribution changes, the optimal parameter changes, so FLAC supports a method that allows the parameter to change as needed.  The residual can be broken into several <I>contexts</I> or <I>partitions</I>, each with it's own Rice parameter.  <B><TT>flac</TT></B> allows you to specify how the partitioning is done with the <TT>-r</TT> option.  The residual can be broken into 2^<I>n</I> partitions, by using the option <TT>-r n,n</TT>.  The parameter <I>n</I> is called the <I>partition order</I>.  Furthermore, the encoder can be made to search through <I>m</I> to <I>n</I> partition orders, taking the best one, by specifying <TT>-r m,n</TT>.  Generally, the choice of n does not affect encoding speed but m,n does.  The larger the difference between m and n, the more time it will take the encoder to search for the best order.  The block size will also affect the optimal order.
177         </P>
178         <P>
179                 <B>FRAMING</B>
180         </P>
181         <P>
182                 An audio frame is preceded by a frame header and trailed by a frame footer.  The header starts with a sync code, and contains the minimum information necessary for a decoder to play the stream, like sample rate, bits per sample, etc.  It also contains the block or sample number and an 8-bit CRC of the frame header.  The sync code, frame header CRC, and block/sample number allow resynchronization and seeking even in the absence of seek points.  The frame footer contains a 16-bit CRC of the entire encoded frame for error detection.  If the reference decoder detects a CRC error it will generate a silent block.
183         </P>
184         <P>
185                 <B>MISCELLANEOUS</B>
186         </P>
187         <P>
188                 In order to support come common types of metadata, the reference decoder knows how to skip ID3V1 and ID3V2 tags so it is safe to tag FLAC files in this way.  ID3V2 tags must come at the beginning of the file (before the "fLaC" marker) and ID3V1 tags must come at the end of the file.
189         </P>
190         <P>
191                 <B><TT>flac</TT></B> has a verify option <TT>-V</TT> that verifies the output while encoding.  With this option, a decoder is run in parallel to the encoder and its output is compared against the original input.  If a difference is found <B><TT>flac</TT></B> will stop with an error.
192         </P>
193         </FONT>
194         </TD></TR>
195         </TABLE>
196         <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>
197 </TD></TR>
198 </TABLE>
199
200
201 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
202 <TR><TD>
203         <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>
204         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
205                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
206                 <A NAME="flac"><B><FONT SIZE="+2">flac</FONT></B>
207                 </FONT></TD></TR>
208         </TABLE>
209         <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>
210         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
211         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
212         <P>
213                 <B><TT>flac</TT></B> is the command-line file encoder/decoder.  The input to the encoder and the output to the decoder must either be RIFF WAVE format, or raw interleaved sample data.  <B><TT>flac</TT></B> only supports linear PCM samples (in other words, no A-LAW, uLAW, etc.).  Another restriction (hopefully short-term) is that the input must be 8, 16, or 24 bits per sample.  This is not a limitation of the FLAC format, just the reference encoder/decoder.
214         </P>
215         <P>
216                 <B><TT>flac</TT></B> assumes that RIFF WAVE files will have the extension ".wav"; this may be overridden with a command-line option.  For piped-in data, <B><TT>flac</TT></B> tries to determine the type by looking at the beginning of the file.  Other than this, <B><TT>flac</TT></B> makes no assumptions about file extensions, though the convention is that FLAC files have the extension ".flac" (or ".fla" on ancient file systems like FAT-16).
217         </P>
218         <P>
219                 Before going into the full command-line description, a few other things help to sort it out: 1) <B><TT>flac</TT></B> encodes by default, so you must use <B>-d</B> to decode; 2) the options <B><TT>-0</TT></B> .. <B><TT>-9</TT></B> that control the compression level actually are just synonyms for different groups of specific encoding options (described later) and you can get the same effect by using the same options; 3) <B><TT>flac</TT></B> behaves similarly to gzip in the way it handles input and output files.
220         </P>
221         <P>
222                 <B><TT>flac</TT></B> will be invoked one of four ways, depending on whether you are encoding, decoding, testing, or analyzing:
223                 <UL>
224                 <LI>
225                         Encoding: flac [-s] [--skip #] [-V] [<I><A HREF="#format_options">&lt;format-options&gt;</A></I>] [<I><A HREF="#encoding_options">&lt;encoding options&gt;</A></I>] [inputfile [...]]
226                 </LI>
227                 <LI>
228                         Decoding: flac -d [-s] [--skip #] [<I><A HREF="#format_options">&lt;format-options&gt;</A></I>] [inputfile [...]]
229                 </LI>
230                 <LI>
231                         Testing: flac -t [-s] [inputfile [...]]
232                 </LI>
233                 <LI>
234                         Analyzing: flac -a [-s] [--skip #] [<I><A HREF="#analysis_options">&lt;analysis-options&gt;</A></I>] [inputfile [...]]
235                 </LI>
236                 </UL>
237         </P>
238         <P>
239                 In any case, if no <TT>inputfile</TT> is specified, stdin is assumed.  If only one inputfile is specified, it may be "-" for stdin.  When stdin is used as input, <B><TT>flac</TT></B> will write to stdout.  Otherwise <B><TT>flac</TT></B> will perform the desired operation on each input file to similarly named output files (meaning for encoding, the extension will be replaced with ".flac", or appended with ".flac" if the input file has no extension, and for decoding, the extension will be ".wav" for WAVE output and ".raw" for raw output).  The original file is not deleted unless --delete-input-file is specified.
240         </P>
241         <P>
242                 If you are encoding/decoding from stdin to a file, you should use the -o option like so:
243                 <UL>
244                 <LI>
245                         flac [options] -o outputfile
246                 </LI>
247                 <LI>
248                         flac -d [options] -o outputfile
249                 </LI>
250                 </UL>
251                 which are better than:
252                 <UL>
253                 <LI>
254                         flac [options] &gt; outputfile
255                 </LI>
256                 <LI>
257                         flac -d [options] &gt; outputfile
258                 </LI>
259                 </UL>
260                 since the former allows flac to seek backwards to write the STREAMINFO or RIFF WAVE header contents when necessary.
261         </P>
262         <P>
263                 Also, you can force output data to go to stdout using <TT>-c</TT>.
264         </P>
265         <P>The encoding options affect the compression ratio and encoding speed.  The format options are used to tell <B><TT>flac</TT></B> the arrangement of samples if the input file (or output file when decoding) is a raw file.  If it is a RIFF WAVE file the format options are not needed since they are read from the WAVE header.
266         </P>
267         <P>
268                 In test mode, <B><TT>flac</TT></B> acts just like in decode mode, except no output file is written.  Both decode and test modes detect errors in the stream, but they also detect when the MD5 signature of the decoded audio does not match the stored MD5 signature, even when the bitstream is valid.
269         </P>
270         <P>
271         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
272         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
273                 <TR>
274                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
275                                 <A NAME="general_options"><FONT SIZE="+1"><B>General Options</B></FONT></A>
276                         </TD>
277                 </TR>
278                 <TR>
279                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
280                                 <TT>-d</TT>
281                         </TD>
282                         <TD>
283                                 Decode (<B><TT>flac</TT></B> encodes by default).  <B><TT>flac</TT></B> will exit with an exit code of <TT>1</TT> (and print a message, even in silent mode) if there were any errors during decoding, including when the MD5 checksum does not match the decoded output.  Otherwise the exit code will be <TT>0</TT>.
284                         </TD>
285                 </TR>
286                 <TR>
287                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
288                                 <TT>-t</TT>
289                         </TD>
290                         <TD>
291                                 Test (same as <B><TT>-d</TT></B> except no decoded file is written).  The exit codes are the same as in decode mode.
292                         </TD>
293                 </TR>
294                 <TR>
295                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
296                                 <TT>-a</TT>
297                         </TD>
298                         <TD>
299                                 Analyze (same as <B><TT>-d</TT></B> except an analysis file is written).  The exit codes are the same as in decode mode.  This option is mainly for developers; the output will be a text file that has data about each frame and subframe.
300                         </TD>
301                 </TR>
302                 <TR>
303                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
304                                 <TT>-c</TT>
305                         </TD>
306                         <TD>
307                                 Write output to stdout
308                         </TD>
309                 </TR>
310                 <TR>
311                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
312                                 <TT>-s</TT>
313                         </TD>
314                         <TD>
315                                 Silent: do not show encoding/decoding statistics.
316                         </TD>
317                 </TR>
318                 <TR>
319                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
320                                 <TT>-o filename</TT>
321                         </TD>
322                         <TD>
323                                 Force the output file name (usually <TT><B>flac</B></TT> just changes the extension).  May only be used when encoding a single file.  May not be used in conjunction with <TT>--output-prefix</T>.
324                         </TD>
325                 </TR>
326                 <TR>
327                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
328                                 <TT>--output-prefix string</TT>
329                         </TD>
330                         <TD>
331                                 Prefix each output file name with the given string.  This can be useful for encoding/decoding files to a different directory.  Make sure if your string is a path name that it ends with a trailing '<TT>/</TT>' slash.
332                         </TD>
333                 </TR>
334                 <TR>
335                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
336                                 <TT>--delete-input-file</TT>
337                         </TD>
338                         <TD>
339                                 Automatically delete the input file after a successful encode or decode.  If there was an error (including a verify error) the input file is left intact.
340                         </TD>
341                 </TR>
342                 <TR>
343                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
344                                 <TT>--skip #</TT>
345                         </TD>
346                         <TD>
347                                 Skip over the first # of samples of the input.  This works for both encoding and decoding, but not testing.
348                         </TD>
349                 </TR>
350         </TABLE>
351         </TD></TR></TABLE>
352         </P>
353         <P>
354         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
355         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
356                 <TR>
357                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
358                                 <A NAME="analysis_options"><FONT SIZE="+1"><B>Analysis Options</B></FONT></A>
359                         </TD>
360                 </TR>
361                 <TR>
362                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
363                                 <TT>--a-rtext</TT>
364                         </TD>
365                         <TD>
366                                 Includes the residual signal in the analysis file.  This will make the file <B>very</B> big, much larger than even the decoded file.
367                         </TD>
368                 </TR>
369                 <TR>
370                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
371                                 <TT>--a-rgp</TT>
372                         </TD>
373                         <TD>
374                                 Generates a gnuplot file for every subframe; each file will contain the residual distribution of the subframe.  This will create a <B>lot</B> of files.
375                         </TD>
376                 </TR>
377         </TABLE>
378         </TD></TR></TABLE>
379         </P>
380         <P>
381         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
382         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
383                 <TR>
384                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
385                                 <A NAME="encoding_options"><FONT SIZE="+1"><B>Encoding Options</B></FONT></A>
386                         </TD>
387                 </TR>
388                 <TR>
389                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
390                                 <TT>--lax</TT>
391                         </TD>
392                         <TD>
393                                 Allow encoder to generate non-Subset files.  The resulting FLAC file may not be streamable, so you should only use this option in combination with custom encoding options meant for archival.  File decoders will still be able play (and seek in) such files.
394                         </TD>
395                 </TR>
396                 <TR>
397                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
398                                 <TT>--sector-align</TT>
399                         </TD>
400                         <TD>
401                                 Align encoding of multiple CD format WAVE files on sector boundaries.  This option is only allowed when encoding WAVE files, all of which have a 44.1kHz sample rate and 2 channels.  With <TT>--sector-align</TT>, the encoder will align the resulting .flac streams so that their lengths are even multiples of a CD sector (1/75th of a second, or 588 samples).  It does this by carrying over any partial sector at the end of each WAVE file to the next stream.  The last stream will be padded to alignment with zeroes.<P>
402                                 This option will have no effect if the files are already aligned (as is the normally the case with WAVE files ripped from a CD).  <TT><B>flac</B></TT> can only align a set of files given in one invocation of <TT><B>flac</B></TT>.<P>
403                                 <B>WARNING:</B> The ordering of files is important!  If you give a command like '<TT>flac --sector-align *.wav</TT>' the shell may not expand the wildcard to the order you expect.  To be safe you should '<TT>echo *.wav</TT>' first to confirm the order, or be explicit like '<TT>flac --sector-align 8.wav 9.wav 10.wav</TT>'.
404                         </TD>
405                 </TR>
406                 <TR>
407                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
408                                 <TT>-S { # | X | #x }</TT>
409                         </TD>
410                         <TD>
411                                 Include a point or points in a SEEKTABLE:<BR>
412                                 <UL>
413                                 <LI>
414                                         <TT>#&nbsp;</TT> : a specific sample number for a seek point
415                                 </LI>
416                                 <LI>
417                                         <TT>X&nbsp;</TT> : a placeholder point (always goes at the end of the SEEKTABLE)
418                                 </LI>
419                                 <LI>
420                                         <TT>#x</TT> : # evenly spaced seekpoints, the first being at sample 0
421                                 </LI>
422                                 </UL>
423                                 You may use many -S options; the resulting SEEKTABLE will be the unique-ified union of all such values.<BR>
424                                 With no -S options, flac defaults to '-S 100x'.  Use -S- for no SEEKTABLE.<BR>
425                                 <B>NOTE:</B> -S #x will not work if the encoder can't determine the input size before starting.<BR>
426                                 <B>NOTE:</B> if you use -S # and # is >= samples in the input, there will be either no seek point entered (if the input size is determinable before encoding starts) or a placeholder point (if input size is not determinable).<BR>
427                         </TD>
428                 </TR>
429                 <TR>
430                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
431                                 <TT>-P #</TT>
432                         </TD>
433                         <TD>
434                                   Tell the encoder to write a <TT>PADDING</TT> metadata block of the given length (in bytes) after the <TT>STREAMINFO</TT> block.  <TT>-P 0</TT> implies no <TT>PADDING</TT> block, which is the default.  This is useful if you plan to tag the file later with an <TT>APPLICATION</TT> block; instead of having to rewrite the entire file later just to insert your block, you can write directly over the <TT>PADDING</TT> block.
435                         </TD>
436                 </TR>
437                 <TR>
438                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
439                                 <TT>-b #</TT>
440                         </TD>
441                         <TD>
442                                 Specify the block size in samples.  The default is 1152 for -l 0, otherwise 4608.  Subset streams must use one of 192/576/1152/2304/4608/256/512/1024/2048/4096/8192/16384/32768.  The reference encoder uses the same block size for the entire stream.
443                         </TD>
444                 </TR>
445                 <TR>
446                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
447                                 <TT>-m</TT>
448                         </TD>
449                         <TD>
450                                 Enable mid-side coding (only for stereo streams).  Tends to increase compression by a few percent on average.  For each block both the stereo pair and mid-side versions of the block will be encoded, and smallest resulting frame will be stored.  Currently mid-side encoding is only available when bits-per-sample <= 16.
451                         </TD>
452                 </TR>
453                 <TR>
454                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
455                                 <TT>-M</TT>
456                         </TD>
457                         <TD>
458                                 Enable loose mid-side coding (only for stereo streams).  Like <TT>-m</TT> but the encoder adaptively switches between independent and mid-side coding, which is faster but yields less compression than <TT>-m</TT> (which does an exhaustive search).
459                         </TD>
460                 </TR>
461                 <TR>
462                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
463                                 <TT>-0 .. -9</TT>
464                         </TD>
465                         <TD>
466                                 Fastest compression .. highest compression.  The default is <TT>-5</TT>.
467                         </TD>
468                 </TR>
469                 <TR>
470                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
471                                 <TT>-0</TT>
472                         </TD>
473                         <TD>
474                                 Synonymous with <TT>-l 0 -b 1152 -r 2,2</TT>
475                         </TD>
476                 </TR>
477                 <TR>
478                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
479                                 <TT>-1</TT>
480                         </TD>
481                         <TD>
482                                 Synonymous with <TT>-l 0 -b 1152 -M -r 2,2</TT>
483                         </TD>
484                 </TR>
485                 <TR>
486                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
487                                 <TT>-2</TT>
488                         </TD>
489                         <TD>
490                                 Synonymous with <TT>-l 0 -b 1152 -m -r 3</TT>
491                         </TD>
492                 </TR>
493                 <TR>
494                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
495                                 <TT>-3</TT>
496                         </TD>
497                         <TD>
498                                 Synonymous with <TT>-l 6 -b 4608 -r 3,3</TT>
499                         </TD>
500                 </TR>
501                 <TR>
502                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
503                                 <TT>-4</TT>
504                         </TD>
505                         <TD>
506                                 Synonymous with <TT>-l 8 -b 4608 -M -r 3,3</TT>
507                         </TD>
508                 </TR>
509                 <TR>
510                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
511                                 <TT>-5</TT>
512                         </TD>
513                         <TD>
514                                 Synonymous with <TT>-l 8 -b 4608 -m -r 3,3</TT>
515                         </TD>
516                 </TR>
517                 <TR>
518                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
519                                 <TT>-6</TT>
520                         </TD>
521                         <TD>
522                                 Synonymous with <TT>-l 8 -b 4608 -m -r 4</TT>
523                         </TD>
524                 </TR>
525                 <TR>
526                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
527                                 <TT>-7</TT>
528                         </TD>
529                         <TD>
530                                 Synonymous with <TT>-l 8 -b 4608 -m -e -r 6</TT>
531                         </TD>
532                 </TR>
533                 <TR>
534                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
535                                 <TT>-8</TT>
536                         </TD>
537                         <TD>
538                                 Synonymous with <TT>-l 12 -b 4608 -m -e -r 6</TT>
539                         </TD>
540                 </TR>
541                 <TR>
542                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
543                                 <TT>-9</TT>
544                         </TD>
545                         <TD>
546                                 Synonymous with <TT>-l 32 -b 4608 -m -e -E -r 16 -p</TT>.  This is painfully slow but gives you the maximum compression <B><TT>flac</TT></B> can do for the given block size.  It is more of a theoretical option without much practical use, since <TT>-8</TT> will get you within tiny fractions of a percent of <TT>-9</TT> and much faster.
547                         </TD>
548                 </TR>
549                 <TR>
550                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
551                                 <TT>-e</TT>
552                         </TD>
553                         <TD>
554                                 Exhaustive model search (expensive!).  Normally the encoder estimates the best model to use and encodes once based on the estimate.  With an exhaustive model search, the encoder will generate subframes for every order and use the smallest.  If the max LPC order is high this can significantly increase the encode time but can shave off another 0.5%.
555                         </TD>
556                 </TR>
557                 <TR>
558                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
559                                 <TT>-E</TT>
560                         </TD>
561                         <TD>
562                                 Do escape coding in the entropy coder.  This causes the encoder to use an unencoded representation of the residual in a partition if it is smaller.  It increases the runtime and usually results in an improvement of less than 1%.
563                         </TD>
564                 </TR>
565                 <TR>
566                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
567                                 <TT>-l #</TT>
568                         </TD>
569                         <TD>
570                                 Specifies the maximum LPC order.  This number must be <= 32.  If 0, the encoder will not attempt generic linear prediction, and use only fixed predictors.  Using fixed predictors is faster but usually results in files being 5-10% larger.
571                         </TD>
572                 </TR>
573                 <TR>
574                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
575                                 <TT>-q #</TT>
576                         </TD>
577                         <TD>
578                                 Specifies the precision of the quantized LP coefficients, in bits.  The default is <B><TT>-q 0</TT></B>, which means let the encoder decide based on the signal.  Unless you really know your input file it's best to leave this up to the encoder.
579                         </TD>
580                 </TR>
581                 <TR>
582                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
583                                 <TT>-p</TT>
584                         </TD>
585                         <TD>
586                                 Do exhaustive LP coefficient quantization optimization.  This option overrides any <B><TT>-q</TT></B> option.  It is expensive and typically will only improve the compression a tiny fraction of a percent.  <B><TT>-q</TT></B> has no effect when <B><TT>-l 0</TT></B> is used.
587                         </TD>
588                 </TR>
589                 <TR>
590                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
591                                 <TT>-r [#,]#</TT>
592                         </TD>
593                         <TD>
594                                 Set the [min,]max residual partition order.  The min value defaults to 0 if unspecified.<P>
595                                 By default the encoder uses a single Rice parameter for the subframe's entire residual.  With this option, the residual is iteratively partitioned into 2^min# .. 2^max# pieces, each with its own Rice parameter.  Higher values of max# yield diminishing returns.  The most bang for the buck is usually with <B><TT>-r 2,2</TT></B> (more for higher block sizes).  This usually shaves off about 1.5%.  The technique tends to peak out about when blocksize/(2^n)=128.  Use <B><TT>-r 0,16</TT></B> to force the highest degree of optimization.
596                         </TD>
597                 </TR>
598                 <TR>
599                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
600                                 <TT>-R #</TT>
601                         </TD>
602                         <TD>
603                                 Set the Rice parameter search distance.  Defaults to 0.  The residual coder will search for the best Rice parameter +/- this number for each residual partition.  This option is expensive (run time for -R n will typically be (2n)*30% over that of -R 0) and doesn't give much of a gain.  As a matter of fact, none of the -0..-9 options currently use it since -R > 1 is not consistently better like it should be.
604                         </TD>
605                 </TR>
606                 <TR>
607                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
608                                 <TT>-V</TT>
609                         </TD>
610                         <TD>
611                                 Verify the encoding process.  With this option, <B><TT>flac</TT></B> will create a parallel decoder that decodes the output of the encoder and compares the result against the original.  It will abort immediately with an error if a mismatch occurs.  <B><TT>-V</TT></B> increases the total encoding time but is guaranteed to catch any unforseen bug in the encoding process.
612                         </TD>
613                 </TR>
614                 <TR>
615                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
616                         </TD>
617                         <TD>
618                                 <TT>-S-</TT>, <TT>-m-</TT>, <TT>-e-</TT>, <TT>-E-</TT>, <TT>-p-</TT>, <TT>-V-</TT>, <TT>--delete-input-file-</TT>, <TT>--lax-</TT>, <TT>--sector-align-</TT> can all be used to turn off a particular option.
619                         </TD>
620                 </TR>
621         </TABLE>
622         </TD></TR></TABLE>
623         </P>
624         <P>
625         <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#EEEED4"><TR><TD>
626         <TABLE WIDTH="100%" BORDER="1" BGCOLOR="#EEEED4">
627                 <TR>
628                         <TD COLSPAN="2" BGCOLOR="#D3D4C5">
629                                 <A NAME="format_options"><FONT SIZE="+1"><B>Format Options</B></FONT></A>
630                         </TD>
631                 </TR>
632                 <TR>
633                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
634                                 <TT>-fb | -fl</TT>
635                         </TD>
636                         <TD>
637                                 Specify big-endian | little-endian byte order in the raw file.
638                         </TD>
639                 </TR>
640                 <TR>
641                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
642                                 <TT>-fc #</TT>
643                         </TD>
644                         <TD>
645                                 Specify the number of channels in the raw file.
646                         </TD>
647                 </TR>
648                 <TR>
649                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
650                                 <TT>-fp #</TT>
651                         </TD>
652                         <TD>
653                                 Specify the number of bits per sample in the raw file.
654                         </TD>
655                 </TR>
656                 <TR>
657                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
658                                 <TT>-fs #</TT>
659                         </TD>
660                         <TD>
661                                 Specify the sample rate of the raw file.
662                         </TD>
663                 </TR>
664                 <TR>
665                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
666                                 <TT>-fu</TT>
667                         </TD>
668                         <TD>
669                                 Specify that the samples in the raw file are unsigned (the default is signed).
670                         </TD>
671                 </TR>
672                 <TR>
673                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
674                                 <TT>-fr</TT>
675                         </TD>
676                         <TD>
677                                 Treat the input file (or output file if decoding) as a raw file, regardless of the extension.
678                         </TD>
679                 </TR>
680                 <TR>
681                         <TD NOWRAP ALIGN="RIGHT" VALIGN="TOP" BGCOLOR="#F4F4CC">
682                                 <TT>-fw</TT>
683                         </TD>
684                         <TD>
685                                 Treat the input file (or output file if decoding) as a RIFF WAVE file, regardless of the extension.
686                         </TD>
687                 </TR>
688         </TABLE>
689         </TD></TR></TABLE>
690         </P>
691         </FONT>
692         </TD></TR>
693         </TABLE>
694         <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>
695 </TD></TR>
696 </TABLE>
697
698
699 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
700 <TR><TD>
701         <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>
702         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
703                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
704                 <A NAME="metaflac"><B><FONT SIZE="+2">metaflac</FONT></B>
705                 </FONT></TD></TR>
706         </TABLE>
707         <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>
708         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
709         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
710         <P>
711                 <B><TT>metaflac</TT></B> is the command-line <TT>.flac</TT> file metadata editor.  Right now it just lists the contents of all metadata blocks in a .flac file, but soon it will allow you to insert, delete, and edit blocks.
712         </P>
713         <P>
714                 Currently <B><TT>metaflac</TT></B> can be invoked only one way:
715                 <UL>
716                 <LI>
717                         Listing: metaflac [-v] inputfile
718                 </LI>
719                 </UL>
720         </P>
721         <P>
722                 <TT>inputfile</TT> may be "-" for stdin.  If <TT>-v</TT> is used, you will get verbose output.
723         </P>
724         </FONT>
725         </TD></TR>
726         </TABLE>
727         <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>
728 </TD></TR>
729 </TABLE>
730
731
732 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
733 <TR><TD>
734         <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>
735         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
736                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
737                 <A NAME="plugins"><A NAME="xmms_plugin"><B><FONT SIZE="+2">xmms plugin</FONT></B></A>
738                 </FONT></TD></TR>
739         </TABLE>
740         <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>
741         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
742         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
743         <P>
744                 All that is necessary is to copy <B><TT>libxmms-flac.so</TT></B> to the directory where XMMS looks for input plugins (usually <B><TT>/usr/lib/xmms/Input</TT></B>).  There is nothing else to configure.  Make sure to restart XMMS before trying to play any <TT>.flac</TT> files.
745         </P>
746         </FONT>
747         </TD></TR>
748         </TABLE>
749         <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>
750 </TD></TR>
751 </TABLE>
752
753
754 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
755 <TR><TD>
756         <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>
757         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
758                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
759                 <A NAME="winamp_plugin"><B><FONT SIZE="+2">winamp plugin</FONT></B>
760                 </FONT></TD></TR>
761         </TABLE>
762         <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>
763         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
764         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
765         <P>
766                 All that is necessary is to copy <B><TT>in_flac.dll</TT></B> to the <B><TT>Plugins/</TT></B> directory of your Winamp installation.  There is nothing else to configure.  Make sure to restart Winamp before trying to play any <TT>.flac</TT> files.
767         </P>
768         </FONT>
769         </TD></TR>
770         </TABLE>
771         <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>
772 </TD></TR>
773 </TABLE>
774
775
776 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
777 <TR><TD>
778         <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>
779         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
780                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
781                 <A NAME="libflac"><B><FONT SIZE="+2">libFLAC</FONT></B>
782                 </FONT></TD></TR>
783         </TABLE>
784         <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>
785         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
786         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
787         <P>
788                 The FLAC library <B><TT>libFLAC</TT></B> is a C implementation of reference encoders and decoders.  By linking against <B><TT>libFLAC</TT></B> and writing a little code, it is relatively easy to add FLAC support to another program.  The library is licensed under the <A HREF="http://www.gnu.org/copyleft/lesser.html">LGPL</A>.  Complete source code of <B><TT>libFLAC</TT></B> as well as the command-line encoder and plugins is available and is a useful source of examples.
789         </P>
790         <P>
791                 <B><TT>libFLAC</TT></B> usually only requires the standard C library and C math library.  In particular, threading is not used so there is no dependency on a thread library.  However, <B><TT>libFLAC</TT></B> does not use global variables and should be thread-safe.
792         </P>
793         <P>
794                 The <B><TT>libFLAC</TT></B> interface is described in the public header files in the include/FLAC directory.  The public headers and the compiled library are all that is needed to compile and link against the library.  Note that none of the code in src/libFLAC/, including the private header files in src/libFLAC/include/ is required.
795         </P>
796         <P>
797                 The basic usage of <B><TT>libFLAC</TT></B> is as follows:
798                 <OL>
799                         <LI>The program creates an instance of a decoder or encoder using <TT>*_new()</TT>.</LI>
800                         <LI>The program sets the parameters of the instance and callbacks for reading, writing, error reporting, and metadata reporting using <TT>*_set_*()</TT> functions.</LI>
801                         <LI>The program initializes the instance to validate the parameters and prepare for decoding/encoding using <TT>*_init()</TT>.</LI>
802                         <LI>The program calls <TT>*_process_*()</TT> functions to encode or decode data, which subsequently calls the callbacks.</LI>
803                         <LI>The program finishes the instance with <TT>*_finish()</TT>, which flushes the input and output.</LI>
804                         <LI>The instance may be used again or deleted with <TT>*_delete()</TT>.</LI>
805                 </OL>
806         </P>
807         <P>
808                 For decoding, <B><TT>libFLAC</TT></B> provides two layers of access.  The lowest layer is stream-level decoding, and the highest level is file-level decoding, which is a wrapper around the stream decoder.  The interfaces are described in <TT>stream_decoder.h</TT> and <TT>file_decoder.h</TT> respectively.  The file decoder supplies the read callback internally and provides seek functions.  Currently there is only one level of encoder implementation which is at the stream level (<TT>stream_encoder.h</TT>).  There is no currently no file encoder because seeking within a file while encoding seemed like too obscure a feature.
809         </P>
810         <P>
811                 Structures and constants related to the format are defined in <TT>format.h</TT>.
812         </P>
813         <P>
814                 <B>STREAM DECODER</B>
815         </P>
816         <P>
817                 First we discuss the stream decoder.  The instance type is <TT>FLAC__StreamDecoder</TT>.  Typically the program will create a new instance by calling <TT>FLAC__stream_decoder_new()</TT>, then call <TT>FLAC__stream_decoder_set_*()</TT> functions to set the callbacks and client data, and call <TT>FLAC__stream_decoder_init()</TT>.  The required callbacks are:
818                 <UL>
819                         <LI>Read callback - This function will be called when the decoder needs more input data.  The address of the buffer to be filled is supplied, along with the number of bytes the buffer can hold.  The callback may choose to supply less data and modify the byte count but must be careful not to overflow the buffer.  The callback then returns a status code chosen from FLAC__StreamDecoderReadStatus.</LI>
820                         <LI>Write callback - This function will be called when the decoder has decoded a single frame of data.  The decoder will pass the frame metadata as well as an array of pointers (one for each channel) pointing to the decoded audio.</LI>
821                         <LI>Metadata callback - This function will be called when the decoder has decoded a metadata block.  There will always be one STREAMINFO block per stream, followed by zero or more other metadata blocks.  These will be supplied by the decoder in the same order as they appear in the stream and always before the first audio frame.</LI>
822                         <LI>Error callback - This function will be called whenever an error occurs during decoding.</LI>
823                 </UL>
824         </P>
825         <P>
826                 Once the decoder is initialized, the program will call one of several functions to stimulate the decoding process:
827                 <UL>
828                         <LI><B><TT>FLAC__stream_decoder_process_whole_stream()</TT></B> - Tells the decoder to start and continue processing the stream until the read callback says <TT>FLAC__STREAM_DECODER_READ_END_OF_STREAM</TT> or <TT>FLAC__STREAM_DECODER_READ_ABORT</TT>.</LI>
829                         <LI><B><TT>FLAC__stream_decoder_process_metadata()</TT></B> - Tells the decoder to start processing the stream and stop upon reaching the first audio frame.</LI>
830                         <LI><B><TT>FLAC__stream_decoder_process_one_frame()</TT></B> - Tells the decoder to process one audio frame and return.  The decoder must have processed all metadata first before calling this function.</LI>
831                         <LI><B><TT>FLAC__stream_decoder_process_remaining_frames()</TT></B> - Tells the decoder to process all remaining frames.  The decoder must have processed all metadata first but may also have processed frames with <TT>FLAC__stream_decoder_process_one_frame()</TT>.</LI>
832                 </UL>
833         </P>
834         <P>
835                 When the decoder has finished decoding (normally or through an abort), the instance is finished by calling <TT>FLAC__stream_decoder_finish()</TT>, which ensures the decoder is in the correct state and frees memory.  Then the instance may be deleted with <TT>FLAC__stream_decoder_delete()</TT> or initialized again to decode another stream.
836         </P>
837         <P>
838                 Note that the stream decoder has no real concept of stream position, it just converts data.  To seek within a stream the callbacks have only to flush the decoder using <TT>FLAC__stream_decoder_flush()</TT> and start feeding data from the new position through the read callback.  The file decoder does just this.
839         </P>
840         <P>
841                 <B>FILE DECODER</B>
842         </P>
843         <P>
844                 The file decoder is a wrapper around the stream decoder meant to simplfy the process of decoding from a file.  The instance type is <TT>FLAC__FileDecoder</TT>.  The flow and callbacks are similar to that of the stream decoder.  However, a file path replaces the read callback argument during initialization.  The program needs only to provide the path to the file and the file decoder handles the read callbacks.  The remaining callbacks and process functions are analogous to their stream decoder counterparts.
845         </P>
846         <P>
847                 Since the file decoder manages the input automatically, it also can provide seeking.  This is exposed through the <TT>FLAC__file_decoder_seek_absolute()</TT> method.  At any point after the file decoder has been initialized, the program can call this function to seek to an exact sample within the file.  Subsequently, the first time the write callback is called it will contain a (possibly partial) block starting at that sample.
848         </P>
849         <P>
850                 The file decoder also provides MD5 signature checking.  If this is turned on before initialization, <TT>FLAC__file_decoder_finish()</TT> will report when the decoded MD5 signature does not match the one stored in the STREAMINFO block.  MD5 checking is automatically turned off if the is no signature in the STREAMINFO block or when a seek is attempted.
851         </P>
852         <P>
853                 <B>STREAM ENCODER</B>
854         </P>
855         <P>
856                 The stream encoder functions similarly to the stream decoder, but has fewer callbacks and more options.  The instance type is <TT>FLAC__StreamEncoder</TT>.  Typically the program will create a new instance by calling <TT>FLAC__stream_encoder_new()</TT>, then set the necessary parameters with <TT>FLAC__stream_encoder_set_*()</TT>, and initialize it by calling <TT>FLAC__stream_encoder_init()</TT>.
857         </P>
858         <P>
859                 Unlike the decoding process, FLAC encoding has many options that can affect the speed and compression ratio.  When the program calls <TT>FLAC__stream_encoder_init()</TT> the encoder will validate the values, so you should make sure to check the returned state to see that it is FLAC__STREAM_ENCODER_OK.  When setting these parameters you should have some basic knowledge of the format (see the <A HREF="#format">user-level documentation</A> or the <A HREF="format.html">formal description</A>) but the required parameters are summarized here:
860                 <UL>
861                         <LI><B><TT>streamable_subset</TT></B> - true to force the encoder to generate a <A HREF="format.html#subset">Subset stream</A>, else false.</LI>
862                         <LI><B><TT>do_mid_side_stereo</TT></B> - true to try mid-side encoding on stereo input, else false.  <TT>channels</TT> must be 2.</LI>
863                         <LI><B><TT>loose_mid_side_stereo</TT></B> - true to do adaptive mid-side switching, else false.  <TT>do_mid_side_stereo</TT> must be true.</LI>
864                         <LI><B><TT>channels</TT></B> - must be &lt;= <TT>FLAC__MAX_CHANNELS</TT>.</LI>
865                         <LI><B><TT>bits_per_sample</TT></B> - do not give the encoder wider data than what you specify here or bad things will happen.</LI>
866                         <LI><B><TT>sample_rate</TT></B> - must be &lt;= <TT>FLAC__MAX_SAMPLE_RATE</TT>.</LI>
867                         <LI><B><TT>blocksize</TT></B> - must be between <TT>FLAC__MIN_BLOCKSIZE</TT> and <TT>FLAC__MAX_BLOCKSIZE</TT>.</LI>
868                         <LI><B><TT>max_lpc_order</TT></B> - 0 implies encoder will not try general LPC, only fixed predictors; must be &lt;= <TT>FLAC__MAX_LPC_ORDER</TT>.</LI>
869                         <LI><B><TT>qlp_coeff_precision</TT></B> - must be &gt;= <TT>FLAC__MIN_QLP_COEFF_PRECISION</TT>, or 0 to let encoder select based on blocksize.  In the current imlementation <TT>qlp_coeff_precision</TT>+<TT>bits_per_sample</TT> must be &lt; 32.</LI>
870                         <LI><B><TT>do_qlp_coeff_prec_search</TT></B> - false to use <TT>qlp_coeff_precision</TT>; true to search around <TT>qlp_coeff_precision</TT> and take best.</LI>
871                         <LI><B><TT>do_escape_coding</TT></B> - true => search for escape codes in the entropy coding stage for slightly better compression.</LI>
872                         <LI><B><TT>do_exhaustive_model_search</TT></B> - false to use estimated bits per residual for scoring; true to generate all and take shortest.</LI>
873                         <LI><B><TT>min_residual_partition_order</TT></B>, <B><TT>max_residual_partition_order</TT></B> - 0 to estimate Rice parameter based on residual variance; &gt; 0 to partition the residual and use parameter for each based on mean; <TT>min_residual_partition_order</TT> and <TT>max_residual_partition_order</TT> specify the min and max Rice partition order.</LI>
874                         <LI><B><TT>rice_parameter_search_dist</TT></B> - 0 to try only calculated parameter k; else try all [k-<TT>rice_parameter_search_dist</TT>..k+<TT>rice_parameter_search_dist</TT>] parameters and use the best.</LI>
875                         <LI><B><TT>total_samples_estimate</TT></B> - May be set to 0 if unknown.  Otherwise, set this to the number of samples to be encoded.  This will allow the STREAMINFO block to be more accurate during the first pass in the event that the encoder can't seek back to the beginning of the output file to write the updated STREAMINFO block.</LI>
876                         <LI><B><TT>seek_table</TT></B> - Optional seek table to prepend; NULL implies no seek table.</LI>
877                         <LI><B><TT>padding</TT></B> - Size of PADDING block to add (goes after seek table); 0 implies do not add a PADDING block.</LI>
878                         <LI><B><TT>last_metadata_is_last</TT></B> - The value the encoder will use for the 'is_last' flag of the last metadata block it writes.  In normal usage you would set this to true, but if you will be manually inserting more metadata blocks between the time of the first write callback (when the encoder sends the <TT>fLaC</TT> header and metadata) and the time actual audio encoding starts then set this to false.</LI>
879                 </UL>
880         </P>
881         <P>
882                 The program provide addresses for the following callbacks:
883                 <UL>
884                         <LI>Write callback - This function is called anytime there is raw encoded data to write.  It may include metadata mixed with encoded audio frames and the data is not guaranteed to be aligned on frame or metadata block boundaries.</LI>
885                         <LI>Metadata callback - This function is called once at the end of encoding with the populated STREAMINFO structure.  This is so file encoders can seek back to the beginning of the file and write the STREAMINFO block with the correct statistics after encoding (like minimum/maximum frame size).</LI>
886                 </UL>
887                 The call to <TT>FLAC__stream_encoder_init()</TT> currently will also immediately call the write callback with the "fLaC" signature and all the encoded metadata.
888         </P>
889         <P>
890                 After initializing the instance, the program may feed audio data to the encoder in one of two ways:
891                 <UL>
892                         <LI>Channel separate, through <B><TT>FLAC__stream_encoder_process()</TT></B> - The program will pass an array of pointers to buffers, one for each channel, to the encoder, each of the same length.  The samples need not be block-aligned.</LI>
893                         <LI>Channel interleaved, through <B><TT>FLAC__stream_encoder_process_interleaved()</TT></B> - The program will pass a single pointer to data that is channel-interleaved (i.e. <TT>channel0_sample0, channel1_sample0, ... , channelN_sample0, channel0_sample1, ...</TT>).  Again, the samples need not be block-aligned but they must be sample-aligned, i.e. the first value should be channel0_sampleX and the last value channelN_sampleY.</LI>
894                 </UL>
895         </P>
896         <P>
897                 When the program is finished encoding data, it calls <TT>FLAC__stream_encoder_finish()</TT>, which causes the encoder to encode any data still in its input pipe, and call the metadata callback with the final encoding statistics.  Then the instance may be deleted with <TT>FLAC__stream_encoder_delete()</TT> or initialized again to encode another stream.
898         </P>
899         <P>
900                 <B>MISCELLANEOUS</B>
901         </P>
902         <P>
903                 It should be noted that any time an array of pointers to audio data is passed, the channel order currently only has meaning for stereo streams.  Channel 0 corresponds to the left channel and channel 1 corresponds to the right channel.
904         </P>
905         <P>
906                 <B>METADATA</B>
907         </P>
908         <P>
909                 For programs that write their own APPLICATION metadata, it is advantageous to instruct the encoder to write a PADDING block of the correct size, so that instead of rewriting the whole stream after encoding, the program can just overwrite the PADDING block.  If only the maximum size of the APPLICATION block is known, the program can write a slightly larger padding block, then split it after encoding into an APPLICATION block and a PADDING block.
910         </P>
911         <P>
912                 In the case where the size of the APPLICATION block data is known ahead of time, the required size of the padding block can be easily calculated.  If the APPLICATION block data length in bytes (not including the APPLICATION metadata block header) is N bytes, the size given to the FLAC__StreamEncoder instance before initialization is simply N+4.  This accounts for the extra space needed to store the APPLICATION ID.
913         </P>
914         <P>
915                 In the case where only the maximum size is known, say, to be N bytes, the required padding size would be N+8.  Four for the APPLICATION ID as before, and four for the extra PADDING block that will fill up the remainder.  At the end of the encoding, when the APPLICATION block data length is known, say, to be M bytes, the original PADDING block would be overwritten with the APPLICATION block and a PADDING block of size N-M.
916         </P>
917         </FONT>
918         </TD></TR>
919         </TABLE>
920         <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>
921 </TD></TR>
922 </TABLE>
923
924
925 <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
926 <TR><TD>
927         <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>
928         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
929                 <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
930                 <A NAME="bugs"><B><FONT SIZE="+2">known bugs</FONT></B>
931                 </FONT></TD></TR>
932         </TABLE>
933         <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>
934         <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
935         <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
936         <P>
937                 Bug tracking is done on the Sourceforge project page <A HREF="http://sourceforge.net/bugs/?group_id=13478">here</A>.  If you submit a bug, please provide an email contact and/or use the Monitor feature.
938         </P>
939         </FONT>
940         </TD></TR>
941         </TABLE>
942         <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>
943 </TD></TR>
944 </TABLE>
945
946
947 </CENTER>
948
949 <P>&nbsp;Copyright (c) 2000,2001 Josh Coalson</P>
950
951 </BODY>
952 </HTML>