/* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson * Copyright (C) 2011-2016 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Xiph.org Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FLAC__FORMAT_H#define FLAC__FORMAT_H #include "export.h"#include "ordinals.h" #ifdef __cplusplusextern "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 * <A HREF="../format.html">FLAC format</A>. 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 \link flac_metadata metadata * module \endlink 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 largest legal metadata type code. */#define FLAC__MAX_METADATA_TYPE_CODE (126u) /** 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 block size, in samples, permitted by the FLAC subset for * sample rates up to 48kHz. */#define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u) /** 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 <A HREF="../format.html">FLAC format</A> * as to why. */#define FLAC__MAX_SAMPLE_RATE (655350u) /** The maximum LPC order permitted by the format. */#define FLAC__MAX_LPC_ORDER (32u) /** The maximum LPC order permitted by the FLAC subset for sample rates * up to 48kHz. */#define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u) /** The minimum quantized linear predictor coefficient precision * permitted by the format. */#define FLAC__MIN_QLP_COEFF_PRECISION (5u) /** The maximum quantized linear predictor coefficient precision * permitted by the format. */#define FLAC__MAX_QLP_COEFF_PRECISION (15u) /** 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) /** The maximum Rice partition order permitted by the FLAC Subset. */#define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u) /** The version string of the release, stamped onto the libraries and binaries. * * \note * This does not correspond to the shared library version number, which * is used to determine binary compatibility. */extern FLAC_API const char *FLAC__VERSION_STRING; /** The vendor string inserted by the encoder into the VORBIS_COMMENT block. * This is a NUL-terminated ASCII string; when inserted into the * VORBIS_COMMENT the trailing null is stripped. */extern FLAC_API const char *FLAC__VENDOR_STRING; /** The byte string representation of the beginning of a FLAC stream. */extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ /** The 32-bit integer big-endian representation of the beginning of * a FLAC stream. */extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */ /** The length of the FLAC signature in bits. */extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */ /** The length of the FLAC signature in bytes. */#define FLAC__STREAM_SYNC_LENGTH (4u) /***************************************************************************** * * 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 * 4-bit Rice parameter. */ FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 /**< Residual is coded by partitioning into contexts, each with it's own * 5-bit 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 FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; /** Contents of a Rice partitioned residual */typedef struct { uint32_t *parameters; /**< The Rice parameters for each context. */ uint32_t *raw_bits; /**< Widths for escape-coded partitions. Will be non-zero for escaped * partitions and zero for unescaped partitions. */ uint32_t capacity_by_order; /**< The capacity of the \a parameters and \a raw_bits arrays * specified as an order, i.e. the number of array elements * allocated is 2 ^ \a capacity_by_order. */} FLAC__EntropyCodingMethod_PartitionedRiceContents; /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>) */typedef struct { uint32_t order; /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; /**< The context's Rice parameters and/or raw bits. */ } FLAC__EntropyCodingMethod_PartitionedRice; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ /** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>) */typedef struct { FLAC__EntropyCodingMethodType type; union { FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; } data;} FLAC__EntropyCodingMethod; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ /*****************************************************************************/ /** An enumeration of the available subframe types. */typedef enum { FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */} FLAC__SubframeType; /** Maps a FLAC__SubframeType to a C string. * * Using a FLAC__SubframeType as the index to this array will * give the string equivalent. The contents should not be modified. */extern FLAC_API const char * const FLAC__SubframeTypeString[]; /** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>) */typedef struct { FLAC__int32 value; /**< The constant signal value. */} FLAC__Subframe_Constant; /** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>) */typedef struct { const FLAC__int32 *data; /**< A pointer to verbatim signal. */} FLAC__Subframe_Verbatim; /** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>) */typedef struct { FLAC__EntropyCodingMethod entropy_coding_method; /**< The residual coding method. */ uint32_t order; /**< The polynomial order. */ FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER]; /**< Warmup samples to prime the predictor, length == order. */ const FLAC__int32 *residual; /**< The residual signal, length == (blocksize minus order) samples. */} FLAC__Subframe_Fixed; /** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>) */typedef struct { FLAC__EntropyCodingMethod entropy_coding_method; /**< The residual coding method. */ uint32_t order; /**< The FIR order. */ uint32_t qlp_coeff_precision; /**< Quantized FIR filter coefficient precision in bits. */ int quantization_level; /**< The qlp coeff shift needed. */ FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; /**< FIR filter coefficients. */ FLAC__int32 warmup[FLAC__MAX_LPC_ORDER]; /**< Warmup samples to prime the predictor, length == order. */ const FLAC__int32 *residual; /**< The residual signal, length == (blocksize minus order) samples. */} FLAC__Subframe_LPC; extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ /** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>) */typedef struct { FLAC__SubframeType type; union { FLAC__Subframe_Constant constant; FLAC__Subframe_Fixed fixed; FLAC__Subframe_LPC lpc; FLAC__Subframe_Verbatim verbatim; } data; uint32_t wasted_bits;} FLAC__Subframe; /** == 1 (bit) * * This used to be a zero-padding bit (hence the name * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 * to mean something else. */extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN;extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ /*****************************************************************************/ /***************************************************************************** * * Frame structures * *****************************************************************************/ /** An enumeration of the available channel assignments. */typedef enum { FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */} FLAC__ChannelAssignment; /** Maps a FLAC__ChannelAssignment to a C string. * * Using a FLAC__ChannelAssignment as the index to this array will * give the string equivalent. The contents should not be modified. */extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; /** An enumeration of the possible frame numbering methods. */typedef enum { FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */} FLAC__FrameNumberType; /** Maps a FLAC__FrameNumberType to a C string. * * Using a FLAC__FrameNumberType as the index to this array will * give the string equivalent. The contents should not be modified. */extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; /** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>) */typedef struct { uint32_t blocksize; /**< The number of samples per subframe. */ uint32_t sample_rate; /**< The sample rate in Hz. */ uint32_t channels; /**< The number of channels (== number of subframes). */ FLAC__ChannelAssignment channel_assignment; /**< The channel assignment for the frame. */ uint32_t bits_per_sample; /**< The sample resolution. */ FLAC__FrameNumberType number_type; /**< The numbering scheme used for the frame. As a convenience, the * decoder will always convert a frame number to a sample number because * the rules are complex. */ union { FLAC__uint32 frame_number; FLAC__uint64 sample_number; } number; /**< The frame number or sample number of first sample in frame; * use the \a number_type value to determine which to use. */ FLAC__uint8 crc; /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) * of the raw frame header bytes, meaning everything before the CRC byte * including the sync code. */} FLAC__FrameHeader; extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ /** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>) */typedef struct { FLAC__uint16 crc; /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with * 0) of the bytes before the crc, back to and including the frame header * sync code. */} FLAC__FrameFooter; extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ /** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>) */typedef struct { FLAC__FrameHeader header; FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; FLAC__FrameFooter footer;} FLAC__Frame; /*****************************************************************************/ /***************************************************************************** * * Meta-data structures * *****************************************************************************/ /** An enumeration of the available metadata block types. */typedef enum { FLAC__METADATA_TYPE_STREAMINFO = 0, /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */ FLAC__METADATA_TYPE_PADDING = 1, /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */ FLAC__METADATA_TYPE_APPLICATION = 2, /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */ FLAC__METADATA_TYPE_SEEKTABLE = 3,Lines 1–500 of 1025. Load more
/* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson * Copyright (C) 2011-2016 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Xiph.org Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FLAC__FORMAT_H #define FLAC__FORMAT_H #include "export.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 * <A HREF="../format.html">FLAC format</A>. 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 \link flac_metadata metadata * module \endlink 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 largest legal metadata type code. */ #define FLAC__MAX_METADATA_TYPE_CODE (126u) /** 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 block size, in samples, permitted by the FLAC subset for * sample rates up to 48kHz. */ #define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u) /** 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 <A HREF="../format.html">FLAC format</A> * as to why. */ #define FLAC__MAX_SAMPLE_RATE (655350u) /** The maximum LPC order permitted by the format. */ #define FLAC__MAX_LPC_ORDER (32u) /** The maximum LPC order permitted by the FLAC subset for sample rates * up to 48kHz. */ #define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u) /** The minimum quantized linear predictor coefficient precision * permitted by the format. */ #define FLAC__MIN_QLP_COEFF_PRECISION (5u) /** The maximum quantized linear predictor coefficient precision * permitted by the format. */ #define FLAC__MAX_QLP_COEFF_PRECISION (15u) /** 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) /** The maximum Rice partition order permitted by the FLAC Subset. */ #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u) /** The version string of the release, stamped onto the libraries and binaries. * * \note * This does not correspond to the shared library version number, which * is used to determine binary compatibility. */ extern FLAC_API const char *FLAC__VERSION_STRING; /** The vendor string inserted by the encoder into the VORBIS_COMMENT block. * This is a NUL-terminated ASCII string; when inserted into the * VORBIS_COMMENT the trailing null is stripped. */ extern FLAC_API const char *FLAC__VENDOR_STRING; /** The byte string representation of the beginning of a FLAC stream. */ extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ /** The 32-bit integer big-endian representation of the beginning of * a FLAC stream. */ extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */ /** The length of the FLAC signature in bits. */ extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */ /** The length of the FLAC signature in bytes. */ #define FLAC__STREAM_SYNC_LENGTH (4u) /***************************************************************************** * * 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 * 4-bit Rice parameter. */ FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 /**< Residual is coded by partitioning into contexts, each with it's own * 5-bit 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 FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; /** Contents of a Rice partitioned residual */ typedef struct { uint32_t *parameters; /**< The Rice parameters for each context. */ uint32_t *raw_bits; /**< Widths for escape-coded partitions. Will be non-zero for escaped * partitions and zero for unescaped partitions. */ uint32_t capacity_by_order; /**< The capacity of the \a parameters and \a raw_bits arrays * specified as an order, i.e. the number of array elements * allocated is 2 ^ \a capacity_by_order. */ } FLAC__EntropyCodingMethod_PartitionedRiceContents; /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>) */ typedef struct { uint32_t order; /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; /**< The context's Rice parameters and/or raw bits. */ } FLAC__EntropyCodingMethod_PartitionedRice; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER; /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ /** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>) */ typedef struct { FLAC__EntropyCodingMethodType type; union { FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; } data; } FLAC__EntropyCodingMethod; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ /*****************************************************************************/ /** An enumeration of the available subframe types. */ typedef enum { FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */ } FLAC__SubframeType; /** Maps a FLAC__SubframeType to a C string. * * Using a FLAC__SubframeType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__SubframeTypeString[]; /** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>) */ typedef struct { FLAC__int32 value; /**< The constant signal value. */ } FLAC__Subframe_Constant; /** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>) */ typedef struct { const FLAC__int32 *data; /**< A pointer to verbatim signal. */ } FLAC__Subframe_Verbatim; /** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>) */ typedef struct { FLAC__EntropyCodingMethod entropy_coding_method; /**< The residual coding method. */ uint32_t order; /**< The polynomial order. */ FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER]; /**< Warmup samples to prime the predictor, length == order. */ const FLAC__int32 *residual; /**< The residual signal, length == (blocksize minus order) samples. */ } FLAC__Subframe_Fixed; /** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>) */ typedef struct { FLAC__EntropyCodingMethod entropy_coding_method; /**< The residual coding method. */ uint32_t order; /**< The FIR order. */ uint32_t qlp_coeff_precision; /**< Quantized FIR filter coefficient precision in bits. */ int quantization_level; /**< The qlp coeff shift needed. */ FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; /**< FIR filter coefficients. */ FLAC__int32 warmup[FLAC__MAX_LPC_ORDER]; /**< Warmup samples to prime the predictor, length == order. */ const FLAC__int32 *residual; /**< The residual signal, length == (blocksize minus order) samples. */ } FLAC__Subframe_LPC; extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ /** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>) */ typedef struct { FLAC__SubframeType type; union { FLAC__Subframe_Constant constant; FLAC__Subframe_Fixed fixed; FLAC__Subframe_LPC lpc; FLAC__Subframe_Verbatim verbatim; } data; uint32_t wasted_bits; } FLAC__Subframe; /** == 1 (bit) * * This used to be a zero-padding bit (hence the name * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 * to mean something else. */ extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN; extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ /*****************************************************************************/ /***************************************************************************** * * Frame structures * *****************************************************************************/ /** An enumeration of the available channel assignments. */ typedef enum { FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */ } FLAC__ChannelAssignment; /** Maps a FLAC__ChannelAssignment to a C string. * * Using a FLAC__ChannelAssignment as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; /** An enumeration of the possible frame numbering methods. */ typedef enum { FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */ } FLAC__FrameNumberType; /** Maps a FLAC__FrameNumberType to a C string. * * Using a FLAC__FrameNumberType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; /** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>) */ typedef struct { uint32_t blocksize; /**< The number of samples per subframe. */ uint32_t sample_rate; /**< The sample rate in Hz. */ uint32_t channels; /**< The number of channels (== number of subframes). */ FLAC__ChannelAssignment channel_assignment; /**< The channel assignment for the frame. */ uint32_t bits_per_sample; /**< The sample resolution. */ FLAC__FrameNumberType number_type; /**< The numbering scheme used for the frame. As a convenience, the * decoder will always convert a frame number to a sample number because * the rules are complex. */ union { FLAC__uint32 frame_number; FLAC__uint64 sample_number; } number; /**< The frame number or sample number of first sample in frame; * use the \a number_type value to determine which to use. */ FLAC__uint8 crc; /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) * of the raw frame header bytes, meaning everything before the CRC byte * including the sync code. */ } FLAC__FrameHeader; extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ /** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>) */ typedef struct { FLAC__uint16 crc; /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with * 0) of the bytes before the crc, back to and including the frame header * sync code. */ } FLAC__FrameFooter; extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ /** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>) */ typedef struct { FLAC__FrameHeader header; FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; FLAC__FrameFooter footer; } FLAC__Frame; /*****************************************************************************/ /***************************************************************************** * * Meta-data structures * *****************************************************************************/ /** An enumeration of the available metadata block types. */ typedef enum { FLAC__METADATA_TYPE_STREAMINFO = 0, /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */ FLAC__METADATA_TYPE_PADDING = 1, /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */ FLAC__METADATA_TYPE_APPLICATION = 2, /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */ FLAC__METADATA_TYPE_SEEKTABLE = 3,