annotate win32-mingw/include/FLAC/all.h @ 33:879bdc878826

Ah, we've already done this. Merge, taking everything from the branch with the older commits.
author Chris Cannam
date Fri, 04 Jul 2014 10:37:37 +0100
parents e582a1ccd5fe
children
rev   line source
Chris@5 1 /* libFLAC - Free Lossless Audio Codec library
Chris@5 2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Chris@5 3 *
Chris@5 4 * Redistribution and use in source and binary forms, with or without
Chris@5 5 * modification, are permitted provided that the following conditions
Chris@5 6 * are met:
Chris@5 7 *
Chris@5 8 * - Redistributions of source code must retain the above copyright
Chris@5 9 * notice, this list of conditions and the following disclaimer.
Chris@5 10 *
Chris@5 11 * - Redistributions in binary form must reproduce the above copyright
Chris@5 12 * notice, this list of conditions and the following disclaimer in the
Chris@5 13 * documentation and/or other materials provided with the distribution.
Chris@5 14 *
Chris@5 15 * - Neither the name of the Xiph.org Foundation nor the names of its
Chris@5 16 * contributors may be used to endorse or promote products derived from
Chris@5 17 * this software without specific prior written permission.
Chris@5 18 *
Chris@5 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@5 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@5 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@5 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
Chris@5 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@5 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@5 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@5 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@5 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@5 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@5 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@5 30 */
Chris@5 31
Chris@5 32 #ifndef FLAC__ALL_H
Chris@5 33 #define FLAC__ALL_H
Chris@5 34
Chris@5 35 #include "export.h"
Chris@5 36
Chris@5 37 #include "assert.h"
Chris@5 38 #include "callback.h"
Chris@5 39 #include "format.h"
Chris@5 40 #include "metadata.h"
Chris@5 41 #include "ordinals.h"
Chris@5 42 #include "stream_decoder.h"
Chris@5 43 #include "stream_encoder.h"
Chris@5 44
Chris@5 45 /** \mainpage
Chris@5 46 *
Chris@5 47 * \section intro Introduction
Chris@5 48 *
Chris@5 49 * This is the documentation for the FLAC C and C++ APIs. It is
Chris@5 50 * highly interconnected; this introduction should give you a top
Chris@5 51 * level idea of the structure and how to find the information you
Chris@5 52 * need. As a prerequisite you should have at least a basic
Chris@5 53 * knowledge of the FLAC format, documented
Chris@5 54 * <A HREF="../format.html">here</A>.
Chris@5 55 *
Chris@5 56 * \section c_api FLAC C API
Chris@5 57 *
Chris@5 58 * The FLAC C API is the interface to libFLAC, a set of structures
Chris@5 59 * describing the components of FLAC streams, and functions for
Chris@5 60 * encoding and decoding streams, as well as manipulating FLAC
Chris@5 61 * metadata in files. The public include files will be installed
Chris@5 62 * in your include area (for example /usr/include/FLAC/...).
Chris@5 63 *
Chris@5 64 * By writing a little code and linking against libFLAC, it is
Chris@5 65 * relatively easy to add FLAC support to another program. The
Chris@5 66 * library is licensed under <A HREF="../license.html">Xiph's BSD license</A>.
Chris@5 67 * Complete source code of libFLAC as well as the command-line
Chris@5 68 * encoder and plugins is available and is a useful source of
Chris@5 69 * examples.
Chris@5 70 *
Chris@5 71 * Aside from encoders and decoders, libFLAC provides a powerful
Chris@5 72 * metadata interface for manipulating metadata in FLAC files. It
Chris@5 73 * allows the user to add, delete, and modify FLAC metadata blocks
Chris@5 74 * and it can automatically take advantage of PADDING blocks to avoid
Chris@5 75 * rewriting the entire FLAC file when changing the size of the
Chris@5 76 * metadata.
Chris@5 77 *
Chris@5 78 * libFLAC usually only requires the standard C library and C math
Chris@5 79 * library. In particular, threading is not used so there is no
Chris@5 80 * dependency on a thread library. However, libFLAC does not use
Chris@5 81 * global variables and should be thread-safe.
Chris@5 82 *
Chris@5 83 * libFLAC also supports encoding to and decoding from Ogg FLAC.
Chris@5 84 * However the metadata editing interfaces currently have limited
Chris@5 85 * read-only support for Ogg FLAC files.
Chris@5 86 *
Chris@5 87 * \section cpp_api FLAC C++ API
Chris@5 88 *
Chris@5 89 * The FLAC C++ API is a set of classes that encapsulate the
Chris@5 90 * structures and functions in libFLAC. They provide slightly more
Chris@5 91 * functionality with respect to metadata but are otherwise
Chris@5 92 * equivalent. For the most part, they share the same usage as
Chris@5 93 * their counterparts in libFLAC, and the FLAC C API documentation
Chris@5 94 * can be used as a supplement. The public include files
Chris@5 95 * for the C++ API will be installed in your include area (for
Chris@5 96 * example /usr/include/FLAC++/...).
Chris@5 97 *
Chris@5 98 * libFLAC++ is also licensed under
Chris@5 99 * <A HREF="../license.html">Xiph's BSD license</A>.
Chris@5 100 *
Chris@5 101 * \section getting_started Getting Started
Chris@5 102 *
Chris@5 103 * A good starting point for learning the API is to browse through
Chris@5 104 * the <A HREF="modules.html">modules</A>. Modules are logical
Chris@5 105 * groupings of related functions or classes, which correspond roughly
Chris@5 106 * to header files or sections of header files. Each module includes a
Chris@5 107 * detailed description of the general usage of its functions or
Chris@5 108 * classes.
Chris@5 109 *
Chris@5 110 * From there you can go on to look at the documentation of
Chris@5 111 * individual functions. You can see different views of the individual
Chris@5 112 * functions through the links in top bar across this page.
Chris@5 113 *
Chris@5 114 * If you prefer a more hands-on approach, you can jump right to some
Chris@5 115 * <A HREF="../documentation_example_code.html">example code</A>.
Chris@5 116 *
Chris@5 117 * \section porting_guide Porting Guide
Chris@5 118 *
Chris@5 119 * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink
Chris@5 120 * has been introduced which gives detailed instructions on how to
Chris@5 121 * port your code to newer versions of FLAC.
Chris@5 122 *
Chris@5 123 * \section embedded_developers Embedded Developers
Chris@5 124 *
Chris@5 125 * libFLAC has grown larger over time as more functionality has been
Chris@5 126 * included, but much of it may be unnecessary for a particular embedded
Chris@5 127 * implementation. Unused parts may be pruned by some simple editing of
Chris@5 128 * src/libFLAC/Makefile.am. In general, the decoders, encoders, and
Chris@5 129 * metadata interface are all independent from each other.
Chris@5 130 *
Chris@5 131 * It is easiest to just describe the dependencies:
Chris@5 132 *
Chris@5 133 * - All modules depend on the \link flac_format Format \endlink module.
Chris@5 134 * - The decoders and encoders depend on the bitbuffer.
Chris@5 135 * - The decoder is independent of the encoder. The encoder uses the
Chris@5 136 * decoder because of the verify feature, but this can be removed if
Chris@5 137 * not needed.
Chris@5 138 * - Parts of the metadata interface require the stream decoder (but not
Chris@5 139 * the encoder).
Chris@5 140 * - Ogg support is selectable through the compile time macro
Chris@5 141 * \c FLAC__HAS_OGG.
Chris@5 142 *
Chris@5 143 * For example, if your application only requires the stream decoder, no
Chris@5 144 * encoder, and no metadata interface, you can remove the stream encoder
Chris@5 145 * and the metadata interface, which will greatly reduce the size of the
Chris@5 146 * library.
Chris@5 147 *
Chris@5 148 * Also, there are several places in the libFLAC code with comments marked
Chris@5 149 * with "OPT:" where a #define can be changed to enable code that might be
Chris@5 150 * faster on a specific platform. Experimenting with these can yield faster
Chris@5 151 * binaries.
Chris@5 152 */
Chris@5 153
Chris@5 154 /** \defgroup porting Porting Guide for New Versions
Chris@5 155 *
Chris@5 156 * This module describes differences in the library interfaces from
Chris@5 157 * version to version. It assists in the porting of code that uses
Chris@5 158 * the libraries to newer versions of FLAC.
Chris@5 159 *
Chris@5 160 * One simple facility for making porting easier that has been added
Chris@5 161 * in FLAC 1.1.3 is a set of \c #defines in \c export.h of each
Chris@5 162 * library's includes (e.g. \c include/FLAC/export.h). The
Chris@5 163 * \c #defines mirror the libraries'
Chris@5 164 * <A HREF="http://www.gnu.org/software/libtool/manual.html#Libtool-versioning">libtool version numbers</A>,
Chris@5 165 * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT,
Chris@5 166 * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE.
Chris@5 167 * These can be used to support multiple versions of an API during the
Chris@5 168 * transition phase, e.g.
Chris@5 169 *
Chris@5 170 * \code
Chris@5 171 * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
Chris@5 172 * legacy code
Chris@5 173 * #else
Chris@5 174 * new code
Chris@5 175 * #endif
Chris@5 176 * \endcode
Chris@5 177 *
Chris@5 178 * The the source will work for multiple versions and the legacy code can
Chris@5 179 * easily be removed when the transition is complete.
Chris@5 180 *
Chris@5 181 * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
Chris@5 182 * include/FLAC/export.h), which can be used to determine whether or not
Chris@5 183 * the library has been compiled with support for Ogg FLAC. This is
Chris@5 184 * simpler than trying to call an Ogg init function and catching the
Chris@5 185 * error.
Chris@5 186 */
Chris@5 187
Chris@5 188 /** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3
Chris@5 189 * \ingroup porting
Chris@5 190 *
Chris@5 191 * \brief
Chris@5 192 * This module describes porting from FLAC 1.1.2 to FLAC 1.1.3.
Chris@5 193 *
Chris@5 194 * The main change between the APIs in 1.1.2 and 1.1.3 is that they have
Chris@5 195 * been simplified. First, libOggFLAC has been merged into libFLAC and
Chris@5 196 * libOggFLAC++ has been merged into libFLAC++. Second, both the three
Chris@5 197 * decoding layers and three encoding layers have been merged into a
Chris@5 198 * single stream decoder and stream encoder. That is, the functionality
Chris@5 199 * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged
Chris@5 200 * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and
Chris@5 201 * FLAC__FileEncoder into FLAC__StreamEncoder. Only the
Chris@5 202 * FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means
Chris@5 203 * is there is now a single API that can be used to encode or decode
Chris@5 204 * streams to/from native FLAC or Ogg FLAC and the single API can work
Chris@5 205 * on both seekable and non-seekable streams.
Chris@5 206 *
Chris@5 207 * Instead of creating an encoder or decoder of a certain layer, now the
Chris@5 208 * client will always create a FLAC__StreamEncoder or
Chris@5 209 * FLAC__StreamDecoder. The old layers are now differentiated by the
Chris@5 210 * initialization function. For example, for the decoder,
Chris@5 211 * FLAC__stream_decoder_init() has been replaced by
Chris@5 212 * FLAC__stream_decoder_init_stream(). This init function takes
Chris@5 213 * callbacks for the I/O, and the seeking callbacks are optional. This
Chris@5 214 * allows the client to use the same object for seekable and
Chris@5 215 * non-seekable streams. For decoding a FLAC file directly, the client
Chris@5 216 * can use FLAC__stream_decoder_init_file() and pass just a filename
Chris@5 217 * and fewer callbacks; most of the other callbacks are supplied
Chris@5 218 * internally. For situations where fopen()ing by filename is not
Chris@5 219 * possible (e.g. Unicode filenames on Windows) the client can instead
Chris@5 220 * open the file itself and supply the FILE* to
Chris@5 221 * FLAC__stream_decoder_init_FILE(). The init functions now returns a
Chris@5 222 * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState.
Chris@5 223 * Since the callbacks and client data are now passed to the init
Chris@5 224 * function, the FLAC__stream_decoder_set_*_callback() functions and
Chris@5 225 * FLAC__stream_decoder_set_client_data() are no longer needed. The
Chris@5 226 * rest of the calls to the decoder are the same as before.
Chris@5 227 *
Chris@5 228 * There are counterpart init functions for Ogg FLAC, e.g.
Chris@5 229 * FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls
Chris@5 230 * and callbacks are the same as for native FLAC.
Chris@5 231 *
Chris@5 232 * As an example, in FLAC 1.1.2 a seekable stream decoder would have
Chris@5 233 * been set up like so:
Chris@5 234 *
Chris@5 235 * \code
Chris@5 236 * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new();
Chris@5 237 * if(decoder == NULL) do_something;
Chris@5 238 * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true);
Chris@5 239 * [... other settings ...]
Chris@5 240 * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback);
Chris@5 241 * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback);
Chris@5 242 * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback);
Chris@5 243 * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback);
Chris@5 244 * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback);
Chris@5 245 * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback);
Chris@5 246 * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback);
Chris@5 247 * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback);
Chris@5 248 * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data);
Chris@5 249 * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something;
Chris@5 250 * \endcode
Chris@5 251 *
Chris@5 252 * In FLAC 1.1.3 it is like this:
Chris@5 253 *
Chris@5 254 * \code
Chris@5 255 * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
Chris@5 256 * if(decoder == NULL) do_something;
Chris@5 257 * FLAC__stream_decoder_set_md5_checking(decoder, true);
Chris@5 258 * [... other settings ...]
Chris@5 259 * if(FLAC__stream_decoder_init_stream(
Chris@5 260 * decoder,
Chris@5 261 * my_read_callback,
Chris@5 262 * my_seek_callback, // or NULL
Chris@5 263 * my_tell_callback, // or NULL
Chris@5 264 * my_length_callback, // or NULL
Chris@5 265 * my_eof_callback, // or NULL
Chris@5 266 * my_write_callback,
Chris@5 267 * my_metadata_callback, // or NULL
Chris@5 268 * my_error_callback,
Chris@5 269 * my_client_data
Chris@5 270 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Chris@5 271 * \endcode
Chris@5 272 *
Chris@5 273 * or you could do;
Chris@5 274 *
Chris@5 275 * \code
Chris@5 276 * [...]
Chris@5 277 * FILE *file = fopen("somefile.flac","rb");
Chris@5 278 * if(file == NULL) do_somthing;
Chris@5 279 * if(FLAC__stream_decoder_init_FILE(
Chris@5 280 * decoder,
Chris@5 281 * file,
Chris@5 282 * my_write_callback,
Chris@5 283 * my_metadata_callback, // or NULL
Chris@5 284 * my_error_callback,
Chris@5 285 * my_client_data
Chris@5 286 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Chris@5 287 * \endcode
Chris@5 288 *
Chris@5 289 * or just:
Chris@5 290 *
Chris@5 291 * \code
Chris@5 292 * [...]
Chris@5 293 * if(FLAC__stream_decoder_init_file(
Chris@5 294 * decoder,
Chris@5 295 * "somefile.flac",
Chris@5 296 * my_write_callback,
Chris@5 297 * my_metadata_callback, // or NULL
Chris@5 298 * my_error_callback,
Chris@5 299 * my_client_data
Chris@5 300 * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
Chris@5 301 * \endcode
Chris@5 302 *
Chris@5 303 * Another small change to the decoder is in how it handles unparseable
Chris@5 304 * streams. Before, when the decoder found an unparseable stream
Chris@5 305 * (reserved for when the decoder encounters a stream from a future
Chris@5 306 * encoder that it can't parse), it changed the state to
Chris@5 307 * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM. Now the decoder instead
Chris@5 308 * drops sync and calls the error callback with a new error code
Chris@5 309 * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM. This is
Chris@5 310 * more robust. If your error callback does not discriminate on the the
Chris@5 311 * error state, your code does not need to be changed.
Chris@5 312 *
Chris@5 313 * The encoder now has a new setting:
Chris@5 314 * FLAC__stream_encoder_set_apodization(). This is for setting the
Chris@5 315 * method used to window the data before LPC analysis. You only need to
Chris@5 316 * add a call to this function if the default is not suitable. There
Chris@5 317 * are also two new convenience functions that may be useful:
Chris@5 318 * FLAC__metadata_object_cuesheet_calculate_cddb_id() and
Chris@5 319 * FLAC__metadata_get_cuesheet().
Chris@5 320 *
Chris@5 321 * The \a bytes parameter to FLAC__StreamDecoderReadCallback,
Chris@5 322 * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
Chris@5 323 * is now \c size_t instead of \c unsigned.
Chris@5 324 */
Chris@5 325
Chris@5 326 /** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
Chris@5 327 * \ingroup porting
Chris@5 328 *
Chris@5 329 * \brief
Chris@5 330 * This module describes porting from FLAC 1.1.3 to FLAC 1.1.4.
Chris@5 331 *
Chris@5 332 * There were no changes to any of the interfaces from 1.1.3 to 1.1.4.
Chris@5 333 * There was a slight change in the implementation of
Chris@5 334 * FLAC__stream_encoder_set_metadata(); the function now makes a copy
Chris@5 335 * of the \a metadata array of pointers so the client no longer needs
Chris@5 336 * to maintain it after the call. The objects themselves that are
Chris@5 337 * pointed to by the array are still not copied though and must be
Chris@5 338 * maintained until the call to FLAC__stream_encoder_finish().
Chris@5 339 */
Chris@5 340
Chris@5 341 /** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0
Chris@5 342 * \ingroup porting
Chris@5 343 *
Chris@5 344 * \brief
Chris@5 345 * This module describes porting from FLAC 1.1.4 to FLAC 1.2.0.
Chris@5 346 *
Chris@5 347 * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0.
Chris@5 348 * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added.
Chris@5 349 * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added.
Chris@5 350 *
Chris@5 351 * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN
Chris@5 352 * has changed to reflect the conversion of one of the reserved bits
Chris@5 353 * into active use. It used to be \c 2 and now is \c 1. However the
Chris@5 354 * FLAC frame header length has not changed, so to skip the proper
Chris@5 355 * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN +
Chris@5 356 * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN
Chris@5 357 */
Chris@5 358
Chris@5 359 /** \defgroup flac FLAC C API
Chris@5 360 *
Chris@5 361 * The FLAC C API is the interface to libFLAC, a set of structures
Chris@5 362 * describing the components of FLAC streams, and functions for
Chris@5 363 * encoding and decoding streams, as well as manipulating FLAC
Chris@5 364 * metadata in files.
Chris@5 365 *
Chris@5 366 * You should start with the format components as all other modules
Chris@5 367 * are dependent on it.
Chris@5 368 */
Chris@5 369
Chris@5 370 #endif