cannam@87: /* libFLAC - Free Lossless Audio Codec library cannam@87: * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson cannam@87: * cannam@87: * Redistribution and use in source and binary forms, with or without cannam@87: * modification, are permitted provided that the following conditions cannam@87: * are met: cannam@87: * cannam@87: * - Redistributions of source code must retain the above copyright cannam@87: * notice, this list of conditions and the following disclaimer. cannam@87: * cannam@87: * - Redistributions in binary form must reproduce the above copyright cannam@87: * notice, this list of conditions and the following disclaimer in the cannam@87: * documentation and/or other materials provided with the distribution. cannam@87: * cannam@87: * - Neither the name of the Xiph.org Foundation nor the names of its cannam@87: * contributors may be used to endorse or promote products derived from cannam@87: * this software without specific prior written permission. cannam@87: * cannam@87: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS cannam@87: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT cannam@87: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR cannam@87: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR cannam@87: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, cannam@87: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, cannam@87: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR cannam@87: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF cannam@87: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING cannam@87: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS cannam@87: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cannam@87: */ cannam@87: cannam@87: #ifndef FLAC__FORMAT_H cannam@87: #define FLAC__FORMAT_H cannam@87: cannam@87: #include "export.h" cannam@87: #include "ordinals.h" cannam@87: cannam@87: #ifdef __cplusplus cannam@87: extern "C" { cannam@87: #endif cannam@87: cannam@87: /** \file include/FLAC/format.h cannam@87: * cannam@87: * \brief cannam@87: * This module contains structure definitions for the representation cannam@87: * of FLAC format components in memory. These are the basic cannam@87: * structures used by the rest of the interfaces. cannam@87: * cannam@87: * See the detailed documentation in the cannam@87: * \link flac_format format \endlink module. cannam@87: */ cannam@87: cannam@87: /** \defgroup flac_format FLAC/format.h: format components cannam@87: * \ingroup flac cannam@87: * cannam@87: * \brief cannam@87: * This module contains structure definitions for the representation cannam@87: * of FLAC format components in memory. These are the basic cannam@87: * structures used by the rest of the interfaces. cannam@87: * cannam@87: * First, you should be familiar with the cannam@87: * FLAC format. Many of the values here cannam@87: * follow directly from the specification. As a user of libFLAC, the cannam@87: * interesting parts really are the structures that describe the frame cannam@87: * header and metadata blocks. cannam@87: * cannam@87: * The format structures here are very primitive, designed to store cannam@87: * information in an efficient way. Reading information from the cannam@87: * structures is easy but creating or modifying them directly is cannam@87: * more complex. For the most part, as a user of a library, editing cannam@87: * is not necessary; however, for metadata blocks it is, so there are cannam@87: * convenience functions provided in the \link flac_metadata metadata cannam@87: * module \endlink to simplify the manipulation of metadata blocks. cannam@87: * cannam@87: * \note cannam@87: * It's not the best convention, but symbols ending in _LEN are in bits cannam@87: * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of cannam@87: * global variables because they are usually used when declaring byte cannam@87: * arrays and some compilers require compile-time knowledge of array cannam@87: * sizes when declared on the stack. cannam@87: * cannam@87: * \{ cannam@87: */ cannam@87: cannam@87: cannam@87: /* cannam@87: Most of the values described in this file are defined by the FLAC cannam@87: format specification. There is nothing to tune here. cannam@87: */ cannam@87: cannam@87: /** The largest legal metadata type code. */ cannam@87: #define FLAC__MAX_METADATA_TYPE_CODE (126u) cannam@87: cannam@87: /** The minimum block size, in samples, permitted by the format. */ cannam@87: #define FLAC__MIN_BLOCK_SIZE (16u) cannam@87: cannam@87: /** The maximum block size, in samples, permitted by the format. */ cannam@87: #define FLAC__MAX_BLOCK_SIZE (65535u) cannam@87: cannam@87: /** The maximum block size, in samples, permitted by the FLAC subset for cannam@87: * sample rates up to 48kHz. */ cannam@87: #define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u) cannam@87: cannam@87: /** The maximum number of channels permitted by the format. */ cannam@87: #define FLAC__MAX_CHANNELS (8u) cannam@87: cannam@87: /** The minimum sample resolution permitted by the format. */ cannam@87: #define FLAC__MIN_BITS_PER_SAMPLE (4u) cannam@87: cannam@87: /** The maximum sample resolution permitted by the format. */ cannam@87: #define FLAC__MAX_BITS_PER_SAMPLE (32u) cannam@87: cannam@87: /** The maximum sample resolution permitted by libFLAC. cannam@87: * cannam@87: * \warning cannam@87: * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, cannam@87: * the reference encoder/decoder is currently limited to 24 bits because cannam@87: * of prevalent 32-bit math, so make sure and use this value when cannam@87: * appropriate. cannam@87: */ cannam@87: #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u) cannam@87: cannam@87: /** The maximum sample rate permitted by the format. The value is cannam@87: * ((2 ^ 16) - 1) * 10; see FLAC format cannam@87: * as to why. cannam@87: */ cannam@87: #define FLAC__MAX_SAMPLE_RATE (655350u) cannam@87: cannam@87: /** The maximum LPC order permitted by the format. */ cannam@87: #define FLAC__MAX_LPC_ORDER (32u) cannam@87: cannam@87: /** The maximum LPC order permitted by the FLAC subset for sample rates cannam@87: * up to 48kHz. */ cannam@87: #define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u) cannam@87: cannam@87: /** The minimum quantized linear predictor coefficient precision cannam@87: * permitted by the format. cannam@87: */ cannam@87: #define FLAC__MIN_QLP_COEFF_PRECISION (5u) cannam@87: cannam@87: /** The maximum quantized linear predictor coefficient precision cannam@87: * permitted by the format. cannam@87: */ cannam@87: #define FLAC__MAX_QLP_COEFF_PRECISION (15u) cannam@87: cannam@87: /** The maximum order of the fixed predictors permitted by the format. */ cannam@87: #define FLAC__MAX_FIXED_ORDER (4u) cannam@87: cannam@87: /** The maximum Rice partition order permitted by the format. */ cannam@87: #define FLAC__MAX_RICE_PARTITION_ORDER (15u) cannam@87: cannam@87: /** The maximum Rice partition order permitted by the FLAC Subset. */ cannam@87: #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u) cannam@87: cannam@87: /** The version string of the release, stamped onto the libraries and binaries. cannam@87: * cannam@87: * \note cannam@87: * This does not correspond to the shared library version number, which cannam@87: * is used to determine binary compatibility. cannam@87: */ cannam@87: extern FLAC_API const char *FLAC__VERSION_STRING; cannam@87: cannam@87: /** The vendor string inserted by the encoder into the VORBIS_COMMENT block. cannam@87: * This is a NUL-terminated ASCII string; when inserted into the cannam@87: * VORBIS_COMMENT the trailing null is stripped. cannam@87: */ cannam@87: extern FLAC_API const char *FLAC__VENDOR_STRING; cannam@87: cannam@87: /** The byte string representation of the beginning of a FLAC stream. */ cannam@87: extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ cannam@87: cannam@87: /** The 32-bit integer big-endian representation of the beginning of cannam@87: * a FLAC stream. cannam@87: */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */ cannam@87: cannam@87: /** The length of the FLAC signature in bits. */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */ cannam@87: cannam@87: /** The length of the FLAC signature in bytes. */ cannam@87: #define FLAC__STREAM_SYNC_LENGTH (4u) cannam@87: cannam@87: cannam@87: /***************************************************************************** cannam@87: * cannam@87: * Subframe structures cannam@87: * cannam@87: *****************************************************************************/ cannam@87: cannam@87: /*****************************************************************************/ cannam@87: cannam@87: /** An enumeration of the available entropy coding methods. */ cannam@87: typedef enum { cannam@87: FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0, cannam@87: /**< Residual is coded by partitioning into contexts, each with it's own cannam@87: * 4-bit Rice parameter. */ cannam@87: cannam@87: FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 cannam@87: /**< Residual is coded by partitioning into contexts, each with it's own cannam@87: * 5-bit Rice parameter. */ cannam@87: } FLAC__EntropyCodingMethodType; cannam@87: cannam@87: /** Maps a FLAC__EntropyCodingMethodType to a C string. cannam@87: * cannam@87: * Using a FLAC__EntropyCodingMethodType as the index to this array will cannam@87: * give the string equivalent. The contents should not be modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; cannam@87: cannam@87: cannam@87: /** Contents of a Rice partitioned residual cannam@87: */ cannam@87: typedef struct { cannam@87: cannam@87: unsigned *parameters; cannam@87: /**< The Rice parameters for each context. */ cannam@87: cannam@87: unsigned *raw_bits; cannam@87: /**< Widths for escape-coded partitions. Will be non-zero for escaped cannam@87: * partitions and zero for unescaped partitions. cannam@87: */ cannam@87: cannam@87: unsigned capacity_by_order; cannam@87: /**< The capacity of the \a parameters and \a raw_bits arrays cannam@87: * specified as an order, i.e. the number of array elements cannam@87: * allocated is 2 ^ \a capacity_by_order. cannam@87: */ cannam@87: } FLAC__EntropyCodingMethod_PartitionedRiceContents; cannam@87: cannam@87: /** Header for a Rice partitioned residual. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: cannam@87: unsigned order; cannam@87: /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ cannam@87: cannam@87: const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; cannam@87: /**< The context's Rice parameters and/or raw bits. */ cannam@87: cannam@87: } FLAC__EntropyCodingMethod_PartitionedRice; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; cannam@87: /**< == (1<format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__EntropyCodingMethodType type; cannam@87: union { cannam@87: FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; cannam@87: } data; cannam@87: } FLAC__EntropyCodingMethod; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ cannam@87: cannam@87: /*****************************************************************************/ cannam@87: cannam@87: /** An enumeration of the available subframe types. */ cannam@87: typedef enum { cannam@87: FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ cannam@87: FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ cannam@87: FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ cannam@87: FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */ cannam@87: } FLAC__SubframeType; cannam@87: cannam@87: /** Maps a FLAC__SubframeType to a C string. cannam@87: * cannam@87: * Using a FLAC__SubframeType as the index to this array will cannam@87: * give the string equivalent. The contents should not be modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__SubframeTypeString[]; cannam@87: cannam@87: cannam@87: /** CONSTANT subframe. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__int32 value; /**< The constant signal value. */ cannam@87: } FLAC__Subframe_Constant; cannam@87: cannam@87: cannam@87: /** VERBATIM subframe. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: const FLAC__int32 *data; /**< A pointer to verbatim signal. */ cannam@87: } FLAC__Subframe_Verbatim; cannam@87: cannam@87: cannam@87: /** FIXED subframe. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__EntropyCodingMethod entropy_coding_method; cannam@87: /**< The residual coding method. */ cannam@87: cannam@87: unsigned order; cannam@87: /**< The polynomial order. */ cannam@87: cannam@87: FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER]; cannam@87: /**< Warmup samples to prime the predictor, length == order. */ cannam@87: cannam@87: const FLAC__int32 *residual; cannam@87: /**< The residual signal, length == (blocksize minus order) samples. */ cannam@87: } FLAC__Subframe_Fixed; cannam@87: cannam@87: cannam@87: /** LPC subframe. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__EntropyCodingMethod entropy_coding_method; cannam@87: /**< The residual coding method. */ cannam@87: cannam@87: unsigned order; cannam@87: /**< The FIR order. */ cannam@87: cannam@87: unsigned qlp_coeff_precision; cannam@87: /**< Quantized FIR filter coefficient precision in bits. */ cannam@87: cannam@87: int quantization_level; cannam@87: /**< The qlp coeff shift needed. */ cannam@87: cannam@87: FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; cannam@87: /**< FIR filter coefficients. */ cannam@87: cannam@87: FLAC__int32 warmup[FLAC__MAX_LPC_ORDER]; cannam@87: /**< Warmup samples to prime the predictor, length == order. */ cannam@87: cannam@87: const FLAC__int32 *residual; cannam@87: /**< The residual signal, length == (blocksize minus order) samples. */ cannam@87: } FLAC__Subframe_LPC; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC subframe structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__SubframeType type; cannam@87: union { cannam@87: FLAC__Subframe_Constant constant; cannam@87: FLAC__Subframe_Fixed fixed; cannam@87: FLAC__Subframe_LPC lpc; cannam@87: FLAC__Subframe_Verbatim verbatim; cannam@87: } data; cannam@87: unsigned wasted_bits; cannam@87: } FLAC__Subframe; cannam@87: cannam@87: /** == 1 (bit) cannam@87: * cannam@87: * This used to be a zero-padding bit (hence the name cannam@87: * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a cannam@87: * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 cannam@87: * to mean something else. cannam@87: */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN; cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ cannam@87: extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ cannam@87: cannam@87: /*****************************************************************************/ cannam@87: cannam@87: cannam@87: /***************************************************************************** cannam@87: * cannam@87: * Frame structures cannam@87: * cannam@87: *****************************************************************************/ cannam@87: cannam@87: /** An enumeration of the available channel assignments. */ cannam@87: typedef enum { cannam@87: FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ cannam@87: FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ cannam@87: FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ cannam@87: FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */ cannam@87: } FLAC__ChannelAssignment; cannam@87: cannam@87: /** Maps a FLAC__ChannelAssignment to a C string. cannam@87: * cannam@87: * Using a FLAC__ChannelAssignment as the index to this array will cannam@87: * give the string equivalent. The contents should not be modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; cannam@87: cannam@87: /** An enumeration of the possible frame numbering methods. */ cannam@87: typedef enum { cannam@87: FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ cannam@87: FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */ cannam@87: } FLAC__FrameNumberType; cannam@87: cannam@87: /** Maps a FLAC__FrameNumberType to a C string. cannam@87: * cannam@87: * Using a FLAC__FrameNumberType as the index to this array will cannam@87: * give the string equivalent. The contents should not be modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; cannam@87: cannam@87: cannam@87: /** FLAC frame header structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: unsigned blocksize; cannam@87: /**< The number of samples per subframe. */ cannam@87: cannam@87: unsigned sample_rate; cannam@87: /**< The sample rate in Hz. */ cannam@87: cannam@87: unsigned channels; cannam@87: /**< The number of channels (== number of subframes). */ cannam@87: cannam@87: FLAC__ChannelAssignment channel_assignment; cannam@87: /**< The channel assignment for the frame. */ cannam@87: cannam@87: unsigned bits_per_sample; cannam@87: /**< The sample resolution. */ cannam@87: cannam@87: FLAC__FrameNumberType number_type; cannam@87: /**< The numbering scheme used for the frame. As a convenience, the cannam@87: * decoder will always convert a frame number to a sample number because cannam@87: * the rules are complex. */ cannam@87: cannam@87: union { cannam@87: FLAC__uint32 frame_number; cannam@87: FLAC__uint64 sample_number; cannam@87: } number; cannam@87: /**< The frame number or sample number of first sample in frame; cannam@87: * use the \a number_type value to determine which to use. */ cannam@87: cannam@87: FLAC__uint8 crc; cannam@87: /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) cannam@87: * of the raw frame header bytes, meaning everything before the CRC byte cannam@87: * including the sync code. cannam@87: */ cannam@87: } FLAC__FrameHeader; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ cannam@87: extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC frame footer structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__uint16 crc; cannam@87: /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with cannam@87: * 0) of the bytes before the crc, back to and including the frame header cannam@87: * sync code. cannam@87: */ cannam@87: } FLAC__FrameFooter; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC frame structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__FrameHeader header; cannam@87: FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; cannam@87: FLAC__FrameFooter footer; cannam@87: } FLAC__Frame; cannam@87: cannam@87: /*****************************************************************************/ cannam@87: cannam@87: cannam@87: /***************************************************************************** cannam@87: * cannam@87: * Meta-data structures cannam@87: * cannam@87: *****************************************************************************/ cannam@87: cannam@87: /** An enumeration of the available metadata block types. */ cannam@87: typedef enum { cannam@87: cannam@87: FLAC__METADATA_TYPE_STREAMINFO = 0, cannam@87: /**< STREAMINFO block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_PADDING = 1, cannam@87: /**< PADDING block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_APPLICATION = 2, cannam@87: /**< APPLICATION block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_SEEKTABLE = 3, cannam@87: /**< SEEKTABLE block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_VORBIS_COMMENT = 4, cannam@87: /**< VORBISCOMMENT block (a.k.a. FLAC tags) */ cannam@87: cannam@87: FLAC__METADATA_TYPE_CUESHEET = 5, cannam@87: /**< CUESHEET block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_PICTURE = 6, cannam@87: /**< PICTURE block */ cannam@87: cannam@87: FLAC__METADATA_TYPE_UNDEFINED = 7 cannam@87: /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */ cannam@87: cannam@87: } FLAC__MetadataType; cannam@87: cannam@87: /** Maps a FLAC__MetadataType to a C string. cannam@87: * cannam@87: * Using a FLAC__MetadataType as the index to this array will cannam@87: * give the string equivalent. The contents should not be modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__MetadataTypeString[]; cannam@87: cannam@87: cannam@87: /** FLAC STREAMINFO structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: unsigned min_blocksize, max_blocksize; cannam@87: unsigned min_framesize, max_framesize; cannam@87: unsigned sample_rate; cannam@87: unsigned channels; cannam@87: unsigned bits_per_sample; cannam@87: FLAC__uint64 total_samples; cannam@87: FLAC__byte md5sum[16]; cannam@87: } FLAC__StreamMetadata_StreamInfo; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */ cannam@87: cannam@87: /** The total stream length of the STREAMINFO block in bytes. */ cannam@87: #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u) cannam@87: cannam@87: /** FLAC PADDING structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: int dummy; cannam@87: /**< Conceptually this is an empty struct since we don't store the cannam@87: * padding bytes. Empty structs are not allowed by some C compilers, cannam@87: * hence the dummy. cannam@87: */ cannam@87: } FLAC__StreamMetadata_Padding; cannam@87: cannam@87: cannam@87: /** FLAC APPLICATION structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__byte id[4]; cannam@87: FLAC__byte *data; cannam@87: } FLAC__StreamMetadata_Application; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */ cannam@87: cannam@87: /** SeekPoint structure used in SEEKTABLE blocks. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__uint64 sample_number; cannam@87: /**< The sample number of the target frame. */ cannam@87: cannam@87: FLAC__uint64 stream_offset; cannam@87: /**< The offset, in bytes, of the target frame with respect to cannam@87: * beginning of the first frame. */ cannam@87: cannam@87: unsigned frame_samples; cannam@87: /**< The number of samples in the target frame. */ cannam@87: } FLAC__StreamMetadata_SeekPoint; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */ cannam@87: cannam@87: /** The total stream length of a seek point in bytes. */ cannam@87: #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u) cannam@87: cannam@87: /** The value used in the \a sample_number field of cannam@87: * FLAC__StreamMetadataSeekPoint used to indicate a placeholder cannam@87: * point (== 0xffffffffffffffff). cannam@87: */ cannam@87: extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; cannam@87: cannam@87: cannam@87: /** FLAC SEEKTABLE structure. (c.f. format specification) cannam@87: * cannam@87: * \note From the format specification: cannam@87: * - The seek points must be sorted by ascending sample number. cannam@87: * - Each seek point's sample number must be the first sample of the cannam@87: * target frame. cannam@87: * - Each seek point's sample number must be unique within the table. cannam@87: * - Existence of a SEEKTABLE block implies a correct setting of cannam@87: * total_samples in the stream_info block. cannam@87: * - Behavior is undefined when more than one SEEKTABLE block is cannam@87: * present in a stream. cannam@87: */ cannam@87: typedef struct { cannam@87: unsigned num_points; cannam@87: FLAC__StreamMetadata_SeekPoint *points; cannam@87: } FLAC__StreamMetadata_SeekTable; cannam@87: cannam@87: cannam@87: /** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. format specification) cannam@87: * cannam@87: * For convenience, the APIs maintain a trailing NUL character at the end of cannam@87: * \a entry which is not counted toward \a length, i.e. cannam@87: * \code strlen(entry) == length \endcode cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__uint32 length; cannam@87: FLAC__byte *entry; cannam@87: } FLAC__StreamMetadata_VorbisComment_Entry; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC VORBIS_COMMENT structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__StreamMetadata_VorbisComment_Entry vendor_string; cannam@87: FLAC__uint32 num_comments; cannam@87: FLAC__StreamMetadata_VorbisComment_Entry *comments; cannam@87: } FLAC__StreamMetadata_VorbisComment; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC CUESHEET track index structure. (See the cannam@87: * format specification for cannam@87: * the full description of each field.) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__uint64 offset; cannam@87: /**< Offset in samples, relative to the track offset, of the index cannam@87: * point. cannam@87: */ cannam@87: cannam@87: FLAC__byte number; cannam@87: /**< The index point number. */ cannam@87: } FLAC__StreamMetadata_CueSheet_Index; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC CUESHEET track structure. (See the cannam@87: * format specification for cannam@87: * the full description of each field.) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__uint64 offset; cannam@87: /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */ cannam@87: cannam@87: FLAC__byte number; cannam@87: /**< The track number. */ cannam@87: cannam@87: char isrc[13]; cannam@87: /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */ cannam@87: cannam@87: unsigned type:1; cannam@87: /**< The track type: 0 for audio, 1 for non-audio. */ cannam@87: cannam@87: unsigned pre_emphasis:1; cannam@87: /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */ cannam@87: cannam@87: FLAC__byte num_indices; cannam@87: /**< The number of track index points. */ cannam@87: cannam@87: FLAC__StreamMetadata_CueSheet_Index *indices; cannam@87: /**< NULL if num_indices == 0, else pointer to array of index points. */ cannam@87: cannam@87: } FLAC__StreamMetadata_CueSheet_Track; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */ cannam@87: cannam@87: cannam@87: /** FLAC CUESHEET structure. (See the cannam@87: * format specification cannam@87: * for the full description of each field.) cannam@87: */ cannam@87: typedef struct { cannam@87: char media_catalog_number[129]; cannam@87: /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In cannam@87: * general, the media catalog number may be 0 to 128 bytes long; any cannam@87: * unused characters should be right-padded with NUL characters. cannam@87: */ cannam@87: cannam@87: FLAC__uint64 lead_in; cannam@87: /**< The number of lead-in samples. */ cannam@87: cannam@87: FLAC__bool is_cd; cannam@87: /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */ cannam@87: cannam@87: unsigned num_tracks; cannam@87: /**< The number of tracks. */ cannam@87: cannam@87: FLAC__StreamMetadata_CueSheet_Track *tracks; cannam@87: /**< NULL if num_tracks == 0, else pointer to array of tracks. */ cannam@87: cannam@87: } FLAC__StreamMetadata_CueSheet; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */ cannam@87: cannam@87: cannam@87: /** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */ cannam@87: typedef enum { cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */ cannam@87: FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED cannam@87: } FLAC__StreamMetadata_Picture_Type; cannam@87: cannam@87: /** Maps a FLAC__StreamMetadata_Picture_Type to a C string. cannam@87: * cannam@87: * Using a FLAC__StreamMetadata_Picture_Type as the index to this array cannam@87: * will give the string equivalent. The contents should not be cannam@87: * modified. cannam@87: */ cannam@87: extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[]; cannam@87: cannam@87: /** FLAC PICTURE structure. (See the cannam@87: * format specification cannam@87: * for the full description of each field.) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__StreamMetadata_Picture_Type type; cannam@87: /**< The kind of picture stored. */ cannam@87: cannam@87: char *mime_type; cannam@87: /**< Picture data's MIME type, in ASCII printable characters cannam@87: * 0x20-0x7e, NUL terminated. For best compatibility with players, cannam@87: * use picture data of MIME type \c image/jpeg or \c image/png. A cannam@87: * MIME type of '-->' is also allowed, in which case the picture cannam@87: * data should be a complete URL. In file storage, the MIME type is cannam@87: * stored as a 32-bit length followed by the ASCII string with no NUL cannam@87: * terminator, but is converted to a plain C string in this structure cannam@87: * for convenience. cannam@87: */ cannam@87: cannam@87: FLAC__byte *description; cannam@87: /**< Picture's description in UTF-8, NUL terminated. In file storage, cannam@87: * the description is stored as a 32-bit length followed by the UTF-8 cannam@87: * string with no NUL terminator, but is converted to a plain C string cannam@87: * in this structure for convenience. cannam@87: */ cannam@87: cannam@87: FLAC__uint32 width; cannam@87: /**< Picture's width in pixels. */ cannam@87: cannam@87: FLAC__uint32 height; cannam@87: /**< Picture's height in pixels. */ cannam@87: cannam@87: FLAC__uint32 depth; cannam@87: /**< Picture's color depth in bits-per-pixel. */ cannam@87: cannam@87: FLAC__uint32 colors; cannam@87: /**< For indexed palettes (like GIF), picture's number of colors (the cannam@87: * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). cannam@87: */ cannam@87: cannam@87: FLAC__uint32 data_length; cannam@87: /**< Length of binary picture data in bytes. */ cannam@87: cannam@87: FLAC__byte *data; cannam@87: /**< Binary picture data. */ cannam@87: cannam@87: } FLAC__StreamMetadata_Picture; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */ cannam@87: cannam@87: cannam@87: /** Structure that is used when a metadata block of unknown type is loaded. cannam@87: * The contents are opaque. The structure is used only internally to cannam@87: * correctly handle unknown metadata. cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__byte *data; cannam@87: } FLAC__StreamMetadata_Unknown; cannam@87: cannam@87: cannam@87: /** FLAC metadata block structure. (c.f. format specification) cannam@87: */ cannam@87: typedef struct { cannam@87: FLAC__MetadataType type; cannam@87: /**< The type of the metadata block; used determine which member of the cannam@87: * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED cannam@87: * then \a data.unknown must be used. */ cannam@87: cannam@87: FLAC__bool is_last; cannam@87: /**< \c true if this metadata block is the last, else \a false */ cannam@87: cannam@87: unsigned length; cannam@87: /**< Length, in bytes, of the block data as it appears in the stream. */ cannam@87: cannam@87: union { cannam@87: FLAC__StreamMetadata_StreamInfo stream_info; cannam@87: FLAC__StreamMetadata_Padding padding; cannam@87: FLAC__StreamMetadata_Application application; cannam@87: FLAC__StreamMetadata_SeekTable seek_table; cannam@87: FLAC__StreamMetadata_VorbisComment vorbis_comment; cannam@87: FLAC__StreamMetadata_CueSheet cue_sheet; cannam@87: FLAC__StreamMetadata_Picture picture; cannam@87: FLAC__StreamMetadata_Unknown unknown; cannam@87: } data; cannam@87: /**< Polymorphic block data; use the \a type value to determine which cannam@87: * to use. */ cannam@87: } FLAC__StreamMetadata; cannam@87: cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */ cannam@87: extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */ cannam@87: cannam@87: /** The total stream length of a metadata block header in bytes. */ cannam@87: #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u) cannam@87: cannam@87: /*****************************************************************************/ cannam@87: cannam@87: cannam@87: /***************************************************************************** cannam@87: * cannam@87: * Utility functions cannam@87: * cannam@87: *****************************************************************************/ cannam@87: cannam@87: /** Tests that a sample rate is valid for FLAC. cannam@87: * cannam@87: * \param sample_rate The sample rate to test for compliance. cannam@87: * \retval FLAC__bool cannam@87: * \c true if the given sample rate conforms to the specification, else cannam@87: * \c false. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate); cannam@87: cannam@87: /** Tests that a sample rate is valid for the FLAC subset. The subset rules cannam@87: * for valid sample rates are slightly more complex since the rate has to cannam@87: * be expressible completely in the frame header. cannam@87: * cannam@87: * \param sample_rate The sample rate to test for compliance. cannam@87: * \retval FLAC__bool cannam@87: * \c true if the given sample rate conforms to the specification for the cannam@87: * subset, else \c false. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate); cannam@87: cannam@87: /** Check a Vorbis comment entry name to see if it conforms to the Vorbis cannam@87: * comment specification. cannam@87: * cannam@87: * Vorbis comment names must be composed only of characters from cannam@87: * [0x20-0x3C,0x3E-0x7D]. cannam@87: * cannam@87: * \param name A NUL-terminated string to be checked. cannam@87: * \assert cannam@87: * \code name != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if entry name is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name); cannam@87: cannam@87: /** Check a Vorbis comment entry value to see if it conforms to the Vorbis cannam@87: * comment specification. cannam@87: * cannam@87: * Vorbis comment values must be valid UTF-8 sequences. cannam@87: * cannam@87: * \param value A string to be checked. cannam@87: * \param length A the length of \a value in bytes. May be cannam@87: * \c (unsigned)(-1) to indicate that \a value is a plain cannam@87: * UTF-8 NUL-terminated string. cannam@87: * \assert cannam@87: * \code value != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if entry name is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length); cannam@87: cannam@87: /** Check a Vorbis comment entry to see if it conforms to the Vorbis cannam@87: * comment specification. cannam@87: * cannam@87: * Vorbis comment entries must be of the form 'name=value', and 'name' and cannam@87: * 'value' must be legal according to cannam@87: * FLAC__format_vorbiscomment_entry_name_is_legal() and cannam@87: * FLAC__format_vorbiscomment_entry_value_is_legal() respectively. cannam@87: * cannam@87: * \param entry An entry to be checked. cannam@87: * \param length The length of \a entry in bytes. cannam@87: * \assert cannam@87: * \code value != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if entry name is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length); cannam@87: cannam@87: /** Check a seek table to see if it conforms to the FLAC specification. cannam@87: * See the format specification for limits on the contents of the cannam@87: * seek table. cannam@87: * cannam@87: * \param seek_table A pointer to a seek table to be checked. cannam@87: * \assert cannam@87: * \code seek_table != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if seek table is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table); cannam@87: cannam@87: /** Sort a seek table's seek points according to the format specification. cannam@87: * This includes a "unique-ification" step to remove duplicates, i.e. cannam@87: * seek points with identical \a sample_number values. Duplicate seek cannam@87: * points are converted into placeholder points and sorted to the end of cannam@87: * the table. cannam@87: * cannam@87: * \param seek_table A pointer to a seek table to be sorted. cannam@87: * \assert cannam@87: * \code seek_table != NULL \endcode cannam@87: * \retval unsigned cannam@87: * The number of duplicate seek points converted into placeholders. cannam@87: */ cannam@87: FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table); cannam@87: cannam@87: /** Check a cue sheet to see if it conforms to the FLAC specification. cannam@87: * See the format specification for limits on the contents of the cannam@87: * cue sheet. cannam@87: * cannam@87: * \param cue_sheet A pointer to an existing cue sheet to be checked. cannam@87: * \param check_cd_da_subset If \c true, check CUESHEET against more cannam@87: * stringent requirements for a CD-DA (audio) disc. cannam@87: * \param violation Address of a pointer to a string. If there is a cannam@87: * violation, a pointer to a string explanation of the cannam@87: * violation will be returned here. \a violation may be cannam@87: * \c NULL if you don't need the returned string. Do not cannam@87: * free the returned string; it will always point to static cannam@87: * data. cannam@87: * \assert cannam@87: * \code cue_sheet != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if cue sheet is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation); cannam@87: cannam@87: /** Check picture data to see if it conforms to the FLAC specification. cannam@87: * See the format specification for limits on the contents of the cannam@87: * PICTURE block. cannam@87: * cannam@87: * \param picture A pointer to existing picture data to be checked. cannam@87: * \param violation Address of a pointer to a string. If there is a cannam@87: * violation, a pointer to a string explanation of the cannam@87: * violation will be returned here. \a violation may be cannam@87: * \c NULL if you don't need the returned string. Do not cannam@87: * free the returned string; it will always point to static cannam@87: * data. cannam@87: * \assert cannam@87: * \code picture != NULL \endcode cannam@87: * \retval FLAC__bool cannam@87: * \c false if picture data is illegal, else \c true. cannam@87: */ cannam@87: FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation); cannam@87: cannam@87: /* \} */ cannam@87: cannam@87: #ifdef __cplusplus cannam@87: } cannam@87: #endif cannam@87: cannam@87: #endif