/* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000,2001,2002 Josh Coalson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef FLAC__FORMAT_H #define FLAC__FORMAT_H #include "ordinals.h" #ifdef __cplusplus extern "C" { #endif /** \file include/FLAC/format.h * * \brief * This module contains structure definitions for the representation * of FLAC format components in memory. These are the basic * structures used by the rest of the interfaces. * * See the detailed documentation in the * \link flac_format format \endlink module. */ /** \defgroup flac_format FLAC/format.h: format components * \ingroup flac * * \brief * This module contains structure definitions for the representation * of FLAC format components in memory. These are the basic * structures used by the rest of the interfaces. * * First, you should be familiar with the XXX FLAC format XXX. Many * of the values here follow directly from the specification. As a * user of libFLAC, the interesting parts really are the structures * that describe the frame header and metadata blocks. * * The format structures here are very primitive, designed to store * information in an efficient way. Reading information from the * structures is easy but creating or modifying them directly is * more complex. For the most part, as a user of a library, editing * is not necessary; however, for metadata blocks it is, so there are * convenience functions provided in the XXX metadata XXX module * to simplify the manipulation of metadata blocks. * * \note * It's not the best convention, but symbols ending in _LEN are in bits * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of * global variables because they are usually used when declaring byte * arrays and some compilers require compile-time knowledge of array * sizes when declared on the stack. * * \{ */ /* Most of the values described in this file are defined by the FLAC format specification. There is nothing to tune here. */ /** The minimum block size, in samples, permitted by the format. */ #define FLAC__MIN_BLOCK_SIZE (16u) /** The maximum block size, in samples, permitted by the format. */ #define FLAC__MAX_BLOCK_SIZE (65535u) /** The maximum number of channels permitted by the format. */ #define FLAC__MAX_CHANNELS (8u) /** The minimum sample resolution permitted by the format. */ #define FLAC__MIN_BITS_PER_SAMPLE (4u) /** The maximum sample resolution permitted by the format. */ #define FLAC__MAX_BITS_PER_SAMPLE (32u) /** The maximum sample resolution permitted by libFLAC. * * \warning * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, * the reference encoder/decoder is currently limited to 24 bits because * of prevalent 32-bit math, so make sure and use this value when * appropriate. */ #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u) /** The maximum sample rate permitted by the format. The value is * ((2 ** 16) - 1) * 10; see XXX format.html XXX as to why. */ #define FLAC__MAX_SAMPLE_RATE (655350u) /** The maximum LPC order permitted by the format. */ #define FLAC__MAX_LPC_ORDER (32u) /** The minimum quantized linear predictor coefficient precision * permitted by the format. */ #define FLAC__MIN_QLP_COEFF_PRECISION (5u) /** The maximum order of the fixed predictors permitted by the format. */ #define FLAC__MAX_FIXED_ORDER (4u) /** The maximum Rice partition order permitted by the format. */ #define FLAC__MAX_RICE_PARTITION_ORDER (15u) /* VERSION should come from configure */ #ifdef VERSION /** The version string of the current library. * * \note * This does not correspond to the shared library version number, which * is used to determine binary compatibility. */ #define FLAC__VERSION_STRING VERSION #endif /** The byte string representation of the beginning of a FLAC stream. */ extern const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */; /** The 32-bit integer big-endian representation of the beginning of * a FLAC stream. */ extern const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */; /** The length of the FLAC signature in bits. */ extern const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */; /** The length of the FLAC signature in bytes. */ #define FLAC__STREAM_SYNC_LENGTH (4u) /***************************************************************************** * @@@ REMOVE? * NOTE: Within the bitstream, all fixed-width numbers are big-endian coded. * All numbers are unsigned unless otherwise noted. * *****************************************************************************/ /***************************************************************************** * * Subframe structures * *****************************************************************************/ /*****************************************************************************/ /** An enumeration of the available entropy coding methods. */ typedef enum { FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0 /**< Residual is coded by partitioning into contexts, each with it's own * Rice parameter. */ } FLAC__EntropyCodingMethodType; /** Maps a FLAC__EntropyCodingMethodType to a C string. * * Using a FLAC__EntropyCodingMethodType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern const char * const FLAC__EntropyCodingMethodTypeString[]; /** Header for a Rice partition. (XXX format XXX) */ typedef struct { unsigned order; /**< The partition order, i.e. # of contexts = 2 ** order. */ unsigned parameters[1 << FLAC__MAX_RICE_PARTITION_ORDER]; /**< The Rice parameters for each context. */ unsigned raw_bits[1 << FLAC__MAX_RICE_PARTITION_ORDER]; /**< Widths for escape-coded partitions. */ } FLAC__EntropyCodingMethod_PartitionedRice; extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ extern const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; /**< == (1<