/* libFLAC - Free Lossless Audio Codec library * Copyright (C) 2000-2009 Josh Coalson * Copyright (C) 2011-2022 Xiph.Org Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Xiph.org Foundation nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FLAC__FORMAT_H #define FLAC__FORMAT_H #include "export.h" #include "ordinals.h" #ifdef __cplusplus extern "C" { #endif /** \file include/FLAC/format.h * * \brief * This module contains structure definitions for the representation * of FLAC format components in memory. These are the basic * structures used by the rest of the interfaces. * * See the detailed documentation in the * \link flac_format format \endlink module. */ /** \defgroup flac_format FLAC/format.h: format components * \ingroup flac * * \brief * This module contains structure definitions for the representation * of FLAC format components in memory. These are the basic * structures used by the rest of the interfaces. * * First, you should be familiar with the * <A HREF="https://xiph.org/flac/format.html">FLAC format</A>. Many of the * values here follow directly from the specification. As a user of libFLAC, * the interesting parts really are the structures that describe the frame * header and metadata blocks. * * The format structures here are very primitive, designed to store * information in an efficient way. Reading information from the * structures is easy but creating or modifying them directly is * more complex. For the most part, as a user of a library, editing * is not necessary; however, for metadata blocks it is, so there are * convenience functions provided in the \link flac_metadata metadata * module \endlink to simplify the manipulation of metadata blocks. * * \note * It's not the best convention, but symbols ending in _LEN are in bits * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of * global variables because they are usually used when declaring byte * arrays and some compilers require compile-time knowledge of array * sizes when declared on the stack. * * \{ */ /* Most of the values described in this file are defined by the FLAC format specification. There is nothing to tune here. */ /** The largest legal metadata type code. */ #define FLAC__MAX_METADATA_TYPE_CODE … /** The minimum block size, in samples, permitted by the format. */ #define FLAC__MIN_BLOCK_SIZE … /** The maximum block size, in samples, permitted by the format. */ #define FLAC__MAX_BLOCK_SIZE … /** The maximum block size, in samples, permitted by the FLAC subset for * sample rates up to 48kHz. */ #define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ … /** The maximum number of channels permitted by the format. */ #define FLAC__MAX_CHANNELS … /** The minimum sample resolution permitted by the format. */ #define FLAC__MIN_BITS_PER_SAMPLE … /** The maximum sample resolution permitted by the format. */ #define FLAC__MAX_BITS_PER_SAMPLE … /** The maximum sample resolution permitted by libFLAC. * * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However, * the reference encoder/decoder used to be limited to 24 bits. This * value was used to signal that limit. */ #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE … /** The maximum sample rate permitted by the format. The value is * ((2 ^ 20) - 1) */ #define FLAC__MAX_SAMPLE_RATE … /** The maximum LPC order permitted by the format. */ #define FLAC__MAX_LPC_ORDER … /** The maximum LPC order permitted by the FLAC subset for sample rates * up to 48kHz. */ #define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ … /** The minimum quantized linear predictor coefficient precision * permitted by the format. */ #define FLAC__MIN_QLP_COEFF_PRECISION … /** The maximum quantized linear predictor coefficient precision * permitted by the format. */ #define FLAC__MAX_QLP_COEFF_PRECISION … /** The maximum order of the fixed predictors permitted by the format. */ #define FLAC__MAX_FIXED_ORDER … /** The maximum Rice partition order permitted by the format. */ #define FLAC__MAX_RICE_PARTITION_ORDER … /** The maximum Rice partition order permitted by the FLAC Subset. */ #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER … /** The version string of the release, stamped onto the libraries and binaries. * * \note * This does not correspond to the shared library version number, which * is used to determine binary compatibility. */ extern FLAC_API const char *FLAC__VERSION_STRING; /** The vendor string inserted by the encoder into the VORBIS_COMMENT block. * This is a NUL-terminated ASCII string; when inserted into the * VORBIS_COMMENT the trailing null is stripped. */ extern FLAC_API const char *FLAC__VENDOR_STRING; /** The byte string representation of the beginning of a FLAC stream. */ extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */ /** The 32-bit integer big-endian representation of the beginning of * a FLAC stream. */ extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */ /** The length of the FLAC signature in bits. */ extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */ /** The length of the FLAC signature in bytes. */ #define FLAC__STREAM_SYNC_LENGTH … /***************************************************************************** * * Subframe structures * *****************************************************************************/ /*****************************************************************************/ /** An enumeration of the available entropy coding methods. */ FLAC__EntropyCodingMethodType; /** Maps a FLAC__EntropyCodingMethodType to a C string. * * Using a FLAC__EntropyCodingMethodType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; /** Contents of a Rice partitioned residual */ FLAC__EntropyCodingMethod_PartitionedRiceContents; /** Header for a Rice partitioned residual. (c.f. <A * HREF="https://xiph.org/flac/format.html#partitioned_rice">format * specification</A>) */ FLAC__EntropyCodingMethod_PartitionedRice; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */ extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER; /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ /** Header for the entropy coding method. (c.f. <A * HREF="https://xiph.org/flac/format.html#residual">format specification</A>) */ FLAC__EntropyCodingMethod; extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ /*****************************************************************************/ /** An enumeration of the available subframe types. */ FLAC__SubframeType; /** Maps a FLAC__SubframeType to a C string. * * Using a FLAC__SubframeType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__SubframeTypeString[]; /** CONSTANT subframe. (c.f. <A * HREF="https://xiph.org/flac/format.html#subframe_constant">format * specification</A>) */ FLAC__Subframe_Constant; /** An enumeration of the possible verbatim subframe data types. */ FLAC__VerbatimSubframeDataType; /** VERBATIM subframe. (c.f. <A * HREF="https://xiph.org/flac/format.html#subframe_verbatim">format * specification</A>) */ FLAC__Subframe_Verbatim; /** FIXED subframe. (c.f. <A * HREF="https://xiph.org/flac/format.html#subframe_fixed">format * specification</A>) */ FLAC__Subframe_Fixed; /** LPC subframe. (c.f. <A * HREF="https://xiph.org/flac/format.html#subframe_lpc">format * specification</A>) */ FLAC__Subframe_LPC; extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ /** FLAC subframe structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#subframe">format specification</A>) */ FLAC__Subframe; /** == 1 (bit) * * This used to be a zero-padding bit (hence the name * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 * to mean something else. */ extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN; extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ /*****************************************************************************/ /***************************************************************************** * * Frame structures * *****************************************************************************/ /** An enumeration of the available channel assignments. */ FLAC__ChannelAssignment; /** Maps a FLAC__ChannelAssignment to a C string. * * Using a FLAC__ChannelAssignment as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; /** An enumeration of the possible frame numbering methods. */ FLAC__FrameNumberType; /** Maps a FLAC__FrameNumberType to a C string. * * Using a FLAC__FrameNumberType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; /** FLAC frame header structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#frame_header">format * specification</A>) */ FLAC__FrameHeader; extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ /** FLAC frame footer structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#frame_footer">format * specification</A>) */ FLAC__FrameFooter; extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ /** FLAC frame structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#frame">format specification</A>) */ FLAC__Frame; /*****************************************************************************/ /***************************************************************************** * * Meta-data structures * *****************************************************************************/ /** An enumeration of the available metadata block types. */ FLAC__MetadataType; /** Maps a FLAC__MetadataType to a C string. * * Using a FLAC__MetadataType as the index to this array will * give the string equivalent. The contents should not be modified. */ extern FLAC_API const char * const FLAC__MetadataTypeString[]; /** FLAC STREAMINFO structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_streaminfo">format * specification</A>) */ FLAC__StreamMetadata_StreamInfo; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */ /** The total stream length of the STREAMINFO block in bytes. */ #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH … /** FLAC PADDING structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_padding">format * specification</A>) */ FLAC__StreamMetadata_Padding; /** FLAC APPLICATION structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_application">format * specification</A>) */ FLAC__StreamMetadata_Application; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */ /** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A * HREF="https://xiph.org/flac/format.html#seekpoint">format specification</A>) */ FLAC__StreamMetadata_SeekPoint; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */ /** The total stream length of a seek point in bytes. */ #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH … /** The value used in the \a sample_number field of * FLAC__StreamMetadataSeekPoint used to indicate a placeholder * point (== 0xffffffffffffffff). */ extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; /** FLAC SEEKTABLE structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_seektable">format * specification</A>) * * \note From the format specification: * - The seek points must be sorted by ascending sample number. * - Each seek point's sample number must be the first sample of the * target frame. * - Each seek point's sample number must be unique within the table. * - Existence of a SEEKTABLE block implies a correct setting of * total_samples in the stream_info block. * - Behavior is undefined when more than one SEEKTABLE block is * present in a stream. */ FLAC__StreamMetadata_SeekTable; /** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">format * specification</A>) * * For convenience, the APIs maintain a trailing NUL character at the end of * \a entry which is not counted toward \a length, i.e. * \code strlen(entry) == length \endcode */ FLAC__StreamMetadata_VorbisComment_Entry; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */ /** FLAC VORBIS_COMMENT structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">format * specification</A>) */ FLAC__StreamMetadata_VorbisComment; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */ /** FLAC CUESHEET track index structure. (See the * <A HREF="https://xiph.org/flac/format.html#cuesheet_track_index">format * specification</A> for the full description of each field.) */ FLAC__StreamMetadata_CueSheet_Index; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */ /** FLAC CUESHEET track structure. (See the * <A HREF="https://xiph.org/flac/format.html#cuesheet_track">format * specification</A> for the full description of each field.) */ FLAC__StreamMetadata_CueSheet_Track; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */ /** FLAC CUESHEET structure. (See the * <A HREF="https://xiph.org/flac/format.html#metadata_block_cuesheet">format * specification</A> for the full description of each field.) */ FLAC__StreamMetadata_CueSheet; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */ /** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */ FLAC__StreamMetadata_Picture_Type; /** Maps a FLAC__StreamMetadata_Picture_Type to a C string. * * Using a FLAC__StreamMetadata_Picture_Type as the index to this array * will give the string equivalent. The contents should not be * modified. */ extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[]; /** FLAC PICTURE structure. (See the * <A HREF="https://xiph.org/flac/format.html#metadata_block_picture">format * specification</A> for the full description of each field.) */ FLAC__StreamMetadata_Picture; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */ /** Structure that is used when a metadata block of unknown type is loaded. * The contents are opaque. The structure is used only internally to * correctly handle unknown metadata. */ FLAC__StreamMetadata_Unknown; /** FLAC metadata block structure. (c.f. <A * HREF="https://xiph.org/flac/format.html#metadata_block">format * specification</A>) */ FLAC__StreamMetadata; extern FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */ extern FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */ /** The total stream length of a metadata block header in bytes. */ #define FLAC__STREAM_METADATA_HEADER_LENGTH … /*****************************************************************************/ /***************************************************************************** * * Utility functions * *****************************************************************************/ /** Tests that a sample rate is valid for FLAC. * * \param sample_rate The sample rate to test for compliance. * \retval FLAC__bool * \c true if the given sample rate conforms to the specification, else * \c false. */ FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate); /** Tests that a blocksize at the given sample rate is valid for the FLAC * subset. * * \param blocksize The blocksize to test for compliance. * \param sample_rate The sample rate is needed, since the valid subset * blocksize depends on the sample rate. * \retval FLAC__bool * \c true if the given blocksize conforms to the specification for the * subset at the given sample rate, else \c false. */ FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate); /** Tests that a sample rate is valid for the FLAC subset. The subset rules * for valid sample rates are slightly more complex since the rate has to * be expressible completely in the frame header. * * \param sample_rate The sample rate to test for compliance. * \retval FLAC__bool * \c true if the given sample rate conforms to the specification for the * subset, else \c false. */ FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate); /** Check a Vorbis comment entry name to see if it conforms to the Vorbis * comment specification. * * Vorbis comment names must be composed only of characters from * [0x20-0x3C,0x3E-0x7D]. * * \param name A NUL-terminated string to be checked. * \assert * \code name != NULL \endcode * \retval FLAC__bool * \c false if entry name is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name); /** Check a Vorbis comment entry value to see if it conforms to the Vorbis * comment specification. * * Vorbis comment values must be valid UTF-8 sequences. * * \param value A string to be checked. * \param length A the length of \a value in bytes. May be * \c (uint32_t)(-1) to indicate that \a value is a plain * UTF-8 NUL-terminated string. * \assert * \code value != NULL \endcode * \retval FLAC__bool * \c false if entry name is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte* value, uint32_t length); /** Check a Vorbis comment entry to see if it conforms to the Vorbis * comment specification. * * Vorbis comment entries must be of the form 'name=value', and 'name' and * 'value' must be legal according to * FLAC__format_vorbiscomment_entry_name_is_legal() and * FLAC__format_vorbiscomment_entry_value_is_legal() respectively. * * \param entry An entry to be checked. * \param length The length of \a entry in bytes. * \assert * \code value != NULL \endcode * \retval FLAC__bool * \c false if entry name is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte* entry, uint32_t length); /** Check a seek table to see if it conforms to the FLAC specification. * See the format specification for limits on the contents of the * seek table. * * \param seek_table A pointer to a seek table to be checked. * \assert * \code seek_table != NULL \endcode * \retval FLAC__bool * \c false if seek table is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table); /** Sort a seek table's seek points according to the format specification. * This includes a "unique-ification" step to remove duplicates, i.e. * seek points with identical \a sample_number values. Duplicate seek * points are converted into placeholder points and sorted to the end of * the table. * * \param seek_table A pointer to a seek table to be sorted. * \assert * \code seek_table != NULL \endcode * \retval uint32_t * The number of duplicate seek points converted into placeholders. */ FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable* seek_table); /** Check a cue sheet to see if it conforms to the FLAC specification. * See the format specification for limits on the contents of the * cue sheet. * * \param cue_sheet A pointer to an existing cue sheet to be checked. * \param check_cd_da_subset If \c true, check CUESHEET against more * stringent requirements for a CD-DA (audio) disc. * \param violation Address of a pointer to a string. If there is a * violation, a pointer to a string explanation of the * violation will be returned here. \a violation may be * \c NULL if you don't need the returned string. Do not * free the returned string; it will always point to static * data. * \assert * \code cue_sheet != NULL \endcode * \retval FLAC__bool * \c false if cue sheet is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation); /** Check picture data to see if it conforms to the FLAC specification. * See the format specification for limits on the contents of the * PICTURE block. * * \param picture A pointer to existing picture data to be checked. * \param violation Address of a pointer to a string. If there is a * violation, a pointer to a string explanation of the * violation will be returned here. \a violation may be * \c NULL if you don't need the returned string. Do not * free the returned string; it will always point to static * data. * \assert * \code picture != NULL \endcode * \retval FLAC__bool * \c false if picture data is illegal, else \c true. */ FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation); /* \} */ #ifdef __cplusplus } #endif #endif