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