1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2000,2001,2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef FLAC__FORMAT_H
21 #define FLAC__FORMAT_H
30 /** \file include/FLAC/format.h
33 * This module contains structure definitions for the representation
34 * of FLAC format components in memory. These are the basic
35 * structures used by the rest of the interfaces.
37 * See the detailed documentation in the
38 * \link flac_format format \endlink module.
41 /** \defgroup flac_format FLAC/format.h: format components
45 * This module contains structure definitions for the representation
46 * of FLAC format components in memory. These are the basic
47 * structures used by the rest of the interfaces.
49 * First, you should be familiar with the
50 * <A HREF="../format.html">FLAC format</A>. Many of the values here
51 * follow directly from the specification. As a user of libFLAC, the
52 * interesting parts really are the structures that describe the frame
53 * header and metadata blocks.
55 * The format structures here are very primitive, designed to store
56 * information in an efficient way. Reading information from the
57 * structures is easy but creating or modifying them directly is
58 * more complex. For the most part, as a user of a library, editing
59 * is not necessary; however, for metadata blocks it is, so there are
60 * convenience functions provided in the \link flac_metadata metadata
61 * module \endlink to simplify the manipulation of metadata blocks.
64 * It's not the best convention, but symbols ending in _LEN are in bits
65 * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of
66 * global variables because they are usually used when declaring byte
67 * arrays and some compilers require compile-time knowledge of array
68 * sizes when declared on the stack.
75 Most of the values described in this file are defined by the FLAC
76 format specification. There is nothing to tune here.
79 /** The minimum block size, in samples, permitted by the format. */
80 #define FLAC__MIN_BLOCK_SIZE (16u)
82 /** The maximum block size, in samples, permitted by the format. */
83 #define FLAC__MAX_BLOCK_SIZE (65535u)
85 /** The maximum number of channels permitted by the format. */
86 #define FLAC__MAX_CHANNELS (8u)
88 /** The minimum sample resolution permitted by the format. */
89 #define FLAC__MIN_BITS_PER_SAMPLE (4u)
91 /** The maximum sample resolution permitted by the format. */
92 #define FLAC__MAX_BITS_PER_SAMPLE (32u)
94 /** The maximum sample resolution permitted by libFLAC.
97 * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However,
98 * the reference encoder/decoder is currently limited to 24 bits because
99 * of prevalent 32-bit math, so make sure and use this value when
102 #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
104 /** The maximum sample rate permitted by the format. The value is
105 * ((2 ^ 16) - 1) * 10; see <A HREF="../format.html">FLAC format</A>
108 #define FLAC__MAX_SAMPLE_RATE (655350u)
110 /** The maximum LPC order permitted by the format. */
111 #define FLAC__MAX_LPC_ORDER (32u)
113 /** The minimum quantized linear predictor coefficient precision
114 * permitted by the format.
116 #define FLAC__MIN_QLP_COEFF_PRECISION (5u)
118 /** The maximum quantized linear predictor coefficient precision
119 * permitted by the format.
121 #define FLAC__MAX_QLP_COEFF_PRECISION (15u)
123 /** The maximum order of the fixed predictors permitted by the format. */
124 #define FLAC__MAX_FIXED_ORDER (4u)
126 /** The maximum Rice partition order permitted by the format. */
127 #define FLAC__MAX_RICE_PARTITION_ORDER (15u)
129 /** The maximum Rice partition order permitted by the FLAC Subset. */
130 #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
132 /** The version string of the release, stamped onto the libraries and binaries.
135 * This does not correspond to the shared library version number, which
136 * is used to determine binary compatibility.
138 extern FLAC_API const char *FLAC__VERSION_STRING;
140 /** The vendor string inserted by the encoder into the VORBIS_COMMENT block.
141 * This is a nulL-terminated ASCII string; when inserted into the
142 * VORBIS_COMMENT the trailing null is stripped.
144 extern FLAC_API const char *FLAC__VENDOR_STRING;
146 /** The byte string representation of the beginning of a FLAC stream. */
147 extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */
149 /** The 32-bit integer big-endian representation of the beginning of
152 extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */
154 /** The length of the FLAC signature in bits. */
155 extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */
157 /** The length of the FLAC signature in bytes. */
158 #define FLAC__STREAM_SYNC_LENGTH (4u)
161 /*****************************************************************************
163 * Subframe structures
165 *****************************************************************************/
167 /*****************************************************************************/
169 /** An enumeration of the available entropy coding methods. */
171 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0
172 /**< Residual is coded by partitioning into contexts, each with it's own
174 } FLAC__EntropyCodingMethodType;
176 /** Maps a FLAC__EntropyCodingMethodType to a C string.
178 * Using a FLAC__EntropyCodingMethodType as the index to this array will
179 * give the string equivalent. The contents should not be modified.
181 extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
184 /** Contents of a Rice partitioned residual
188 unsigned *parameters;
189 /**< The Rice parameters for each context. */
192 /**< Widths for escape-coded partitions. */
194 unsigned capacity_by_order;
195 /**< The capacity of the \a parameters and \a raw_bits arrays
196 * specified as an order, i.e. the number of array elements
197 * allocated is 2 ^ \a capacity_by_order.
199 } FLAC__EntropyCodingMethod_PartitionedRiceContents;
201 /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
206 /**< The partition order, i.e. # of contexts = 2 ^ \a order. */
208 const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
209 /**< The context's Rice parameters and/or raw bits. */
211 } FLAC__EntropyCodingMethod_PartitionedRice;
213 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
214 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
215 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
217 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
218 /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
220 /** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>)
223 FLAC__EntropyCodingMethodType type;
225 FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
227 } FLAC__EntropyCodingMethod;
229 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
231 /*****************************************************************************/
233 /** An enumeration of the available subframe types. */
235 FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */
236 FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */
237 FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */
238 FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */
239 } FLAC__SubframeType;
241 /** Maps a FLAC__SubframeType to a C string.
243 * Using a FLAC__SubframeType as the index to this array will
244 * give the string equivalent. The contents should not be modified.
246 extern FLAC_API const char * const FLAC__SubframeTypeString[];
249 /** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>)
252 FLAC__int32 value; /**< The constant signal value. */
253 } FLAC__Subframe_Constant;
256 /** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>)
259 const FLAC__int32 *data; /**< A pointer to verbatim signal. */
260 } FLAC__Subframe_Verbatim;
263 /** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>)
266 FLAC__EntropyCodingMethod entropy_coding_method;
267 /**< The residual coding method. */
270 /**< The polynomial order. */
272 FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
273 /**< Warmup samples to prime the predictor, length == order. */
275 const FLAC__int32 *residual;
276 /**< The residual signal, length == (blocksize minus order) samples. */
277 } FLAC__Subframe_Fixed;
280 /** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>)
283 FLAC__EntropyCodingMethod entropy_coding_method;
284 /**< The residual coding method. */
287 /**< The FIR order. */
289 unsigned qlp_coeff_precision;
290 /**< Quantized FIR filter coefficient precision in bits. */
292 int quantization_level;
293 /**< The qlp coeff shift needed. */
295 FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
296 /**< FIR filter coefficients. */
298 FLAC__int32 warmup[FLAC__MAX_LPC_ORDER];
299 /**< Warmup samples to prime the predictor, length == order. */
301 const FLAC__int32 *residual;
302 /**< The residual signal, length == (blocksize minus order) samples. */
303 } FLAC__Subframe_LPC;
305 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */
306 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */
309 /** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>)
312 FLAC__SubframeType type;
314 FLAC__Subframe_Constant constant;
315 FLAC__Subframe_Fixed fixed;
316 FLAC__Subframe_LPC lpc;
317 FLAC__Subframe_Verbatim verbatim;
319 unsigned wasted_bits;
322 extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN; /**< == 1 (bit) */
323 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */
324 extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */
326 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /* = 0x00 */
327 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /* = 0x02 */
328 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /* = 0x10 */
329 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /* = 0x40 */
331 /*****************************************************************************/
334 /*****************************************************************************
338 *****************************************************************************/
340 /** An enumeration of the available channel assignments. */
342 FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */
343 FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */
344 FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */
345 FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */
346 } FLAC__ChannelAssignment;
348 /** Maps a FLAC__ChannelAssignment to a C string.
350 * Using a FLAC__ChannelAssignment as the index to this array will
351 * give the string equivalent. The contents should not be modified.
353 extern FLAC_API const char * const FLAC__ChannelAssignmentString[];
355 /** An enumeration of the possible frame numbering methods. */
357 FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */
358 FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */
359 } FLAC__FrameNumberType;
361 /** Maps a FLAC__FrameNumberType to a C string.
363 * Using a FLAC__FrameNumberType as the index to this array will
364 * give the string equivalent. The contents should not be modified.
366 extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
369 /** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>)
373 /**< The number of samples per subframe. */
375 unsigned sample_rate;
376 /**< The sample rate in Hz. */
379 /**< The number of channels (== number of subframes). */
381 FLAC__ChannelAssignment channel_assignment;
382 /**< The channel assignment for the frame. */
384 unsigned bits_per_sample;
385 /**< The sample resolution. */
387 FLAC__FrameNumberType number_type;
388 /**< The numbering scheme used for the frame. */
391 FLAC__uint32 frame_number;
392 FLAC__uint64 sample_number;
394 /**< The frame number or sample number of first sample in frame;
395 * use the \a number_type value to determine which to use. */
398 /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0)
399 * of the raw frame header bytes, meaning everything before the CRC byte
400 * including the sync code.
404 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
405 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */
406 extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 2 (bits) */
407 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */
408 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */
409 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */
410 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */
411 extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */
412 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */
415 /** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>)
419 /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with
420 * 0) of the bytes before the crc, back to and including the frame header
425 extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
428 /** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>)
431 FLAC__FrameHeader header;
432 FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
433 FLAC__FrameFooter footer;
436 /*****************************************************************************/
439 /*****************************************************************************
441 * Meta-data structures
443 *****************************************************************************/
445 /** An enumeration of the available metadata block types. */
448 FLAC__METADATA_TYPE_STREAMINFO = 0,
449 /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */
451 FLAC__METADATA_TYPE_PADDING = 1,
452 /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */
454 FLAC__METADATA_TYPE_APPLICATION = 2,
455 /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */
457 FLAC__METADATA_TYPE_SEEKTABLE = 3,
458 /**< <A HREF="../format.html#metadata_block_seektable">SEEKTABLE</A> block */
460 FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
461 /**< <A HREF="../format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block */
463 FLAC__METADATA_TYPE_CUESHEET = 5,
464 /**< <A HREF="../format.html#metadata_block_cuesheet">CUESHEET</A> block */
466 FLAC__METADATA_TYPE_UNDEFINED = 6
467 /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
469 } FLAC__MetadataType;
471 /** Maps a FLAC__MetadataType to a C string.
473 * Using a FLAC__MetadataType as the index to this array will
474 * give the string equivalent. The contents should not be modified.
476 extern FLAC_API const char * const FLAC__MetadataTypeString[];
479 /** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>)
482 unsigned min_blocksize, max_blocksize;
483 unsigned min_framesize, max_framesize;
484 unsigned sample_rate;
486 unsigned bits_per_sample;
487 FLAC__uint64 total_samples;
488 FLAC__byte md5sum[16];
489 } FLAC__StreamMetadata_StreamInfo;
491 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */
492 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */
493 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */
494 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */
495 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */
496 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */
497 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */
498 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */
499 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */
501 /** The total stream length of the STREAMINFO block in bytes. */
502 #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
504 /** FLAC PADDING structure. (c.f. <A HREF="../format.html#metadata_block_padding">format specification</A>)
508 /**< Conceptually this is an empty struct since we don't store the
509 * padding bytes. Empty structs are not allowed by some C compilers,
512 } FLAC__StreamMetadata_Padding;
515 /** FLAC APPLICATION structure. (c.f. <A HREF="../format.html#metadata_block_application">format specification</A>)
520 } FLAC__StreamMetadata_Application;
522 extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */
524 /** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="../format.html#seekpoint">format specification</A>)
527 FLAC__uint64 sample_number;
528 /**< The sample number of the target frame. */
530 FLAC__uint64 stream_offset;
531 /**< The offset, in bytes, of the target frame with respect to
532 * beginning of the first frame. */
534 unsigned frame_samples;
535 /**< The number of samples in the target frame. */
536 } FLAC__StreamMetadata_SeekPoint;
538 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */
539 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */
540 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */
542 /** The total stream length of a seek point in bytes. */
543 #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
545 /** The value used in the \a sample_number field of
546 * FLAC__StreamMetadataSeekPoint used to indicate a placeholder
547 * point (== 0xffffffffffffffff).
549 extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
552 /** FLAC SEEKTABLE structure. (c.f. <A HREF="../format.html#metadata_block_seektable">format specification</A>)
554 * \note From the format specification:
555 * - The seek points must be sorted by ascending sample number.
556 * - Each seek point's sample number must be the first sample of the
558 * - Each seek point's sample number must be unique within the table.
559 * - Existence of a SEEKTABLE block implies a correct setting of
560 * total_samples in the stream_info block.
561 * - Behavior is undefined when more than one SEEKTABLE block is
562 * present in a stream.
566 FLAC__StreamMetadata_SeekPoint *points;
567 } FLAC__StreamMetadata_SeekTable;
570 /** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
575 } FLAC__StreamMetadata_VorbisComment_Entry;
577 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */
580 /** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
583 FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
584 FLAC__uint32 num_comments;
585 FLAC__StreamMetadata_VorbisComment_Entry *comments;
586 } FLAC__StreamMetadata_VorbisComment;
588 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */
591 /** XXX. (c.f. <A HREF="../format.html#XXX">format specification</A>)
595 /**< The index offset from the beginning of the track, in samples.
596 * For CD-DA, the offset must be evenly divisible by 588 samples (588
597 * samples = 44100 samples/sec * 1/75th of a sec). Note that the
598 * offset is from the beginning of the track, not the beginning of
603 /**< The index number. For CD-DA, an index number of 0 corresponds
604 * to the track pregap. There must be at least one index in every
605 * track except the lead-out track. The first index in a track must
606 * be 0 or 1 and subsequently index numbers must increase by 1. Index
607 * numbers must be unique within a track.
609 } FLAC__StreamMetadata_CueSheet_Index;
611 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */
612 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */
613 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == @@@@3*8 (bits) */
616 /** XXX. (c.f. <A HREF="../format.html#XXX">format specification</A>)
620 /**< The track offset from the beginning of the audio data, in samples.
621 * This track offset is the offset to the first index point of the
622 * track. Note that for CD-DA, the track's offset in the TOC is that
623 * of the track's INDEX 01 even if there is an INDEX 00.
625 * For CD-DA, the offset must be evenly divisible by 588 samples (588
626 * samples = 44100 samples/sec * 1/75th of a sec).
630 /**< The track number. A track number of 0 is not allowed to avoid
631 * conflicting with the CD-DA spec, which reserves this for the
632 * lead-in. For CD-DA the number must be 1-99, or 170 for the lead-out.
633 * It is not required but encouraged to start with track 1 and increase
634 * sequentially. A CUESHEET block is required to have a lead-out
635 * track; it is always the last track in the cuesheet and the number
636 * must be 170 for CD-DA. Track numbers must be unique within a
640 char isrc[13]; /*@@@@ 12 ascii characters plus trailing '\0' */
641 unsigned type:1; /*@@@@q-channel control bit 3: 0=>audio, 1=>data (undefined for CD-DA, defined for CDROM) */
642 unsigned pre_emphasis:1; /*@@@@q-channel control bit 5: 0=>no pre-em, 1=>pre-em */
643 FLAC__byte num_indices;
644 FLAC__StreamMetadata_CueSheet_Index *indices;
645 } FLAC__StreamMetadata_CueSheet_Track;
647 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */
648 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */
649 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */
650 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */
651 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */
652 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+@@@@13*8 (bits) */
653 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */
656 /** FLAC CUESHEET structure. (c.f. <A HREF="../format.html#metadata_block_cuesheet">format specification</A>)
659 char media_catalog_number[129]; /*@@@@ in the stream, the media_catalog_number will be 128 alphanumeric ascii characters; unused digits are padded out to the right with NUL characters. in memory, the 129th character will be guaranteed to be a null character so that the whole string is always a valid C string. CD-DA: 13 ascii digits ('0'-'9') plus 116 trailing '\0' characters */
660 FLAC__uint64 lead_in; /*@@@@ length of lead-in in samples; required to compute some versions of CD TOC hashes; CD-DA says the lead-in must be digital silence and rippers don't save it by convention, so TRACK 00 is disallowed and instead we store only the length. The lead-in is the number of samples up to the first index point of the first track, \b not INDEX 01 of the first track. This is so applications can correctly compute a CD-DA TOC equivalent even when there is TRACK 01 INDEX 00 data. */
662 FLAC__StreamMetadata_CueSheet_Track *tracks;
663 } FLAC__StreamMetadata_CueSheet;
665 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
666 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
667 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == @@@@259*8 (bits) */
668 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */
671 /** FLAC metadata block structure. (c.f. <A HREF="../format.html#metadata_block">format specification</A>)
674 FLAC__MetadataType type;
675 /**< The type of the metadata block; used determine which member of the
676 * \a data union to dereference. */
679 /**< \c true if this metadata block is the last, else \a false */
682 /**< Length, in bytes, of the block data as it appears in the stream. */
685 FLAC__StreamMetadata_StreamInfo stream_info;
686 FLAC__StreamMetadata_Padding padding;
687 FLAC__StreamMetadata_Application application;
688 FLAC__StreamMetadata_SeekTable seek_table;
689 FLAC__StreamMetadata_VorbisComment vorbis_comment;
690 FLAC__StreamMetadata_CueSheet cue_sheet;
692 /**< Polymorphic block data; use the \a type value to determine which
694 } FLAC__StreamMetadata;
696 extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
697 extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */
698 extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */
700 /** The total stream length of a metadata block header in bytes. */
701 #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
703 /*****************************************************************************/
706 /*****************************************************************************
710 *****************************************************************************/
712 /** Tests that a sample rate is valid for FLAC. Since the rules for valid
713 * sample rates are slightly complex, they are encapsulated in this function.
715 * \param sample_rate The sample rate to test for compliance.
717 * \c true if the given sample rate conforms to the specification, else
720 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
722 /** Check a seek table to see if it conforms to the FLAC specification.
723 * See the format specification for limits on the contents of the
726 * \param seek_table A pointer to a seek table to be checked.
728 * \code seek_table != NULL \endcode
730 * \c false if seek table is illegal, else \c true.
732 FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table);
734 /** Sort a seek table's seek points according to the format specification.
735 * This includes a "unique-ification" step to remove duplicates, i.e.
736 * seek points with identical \a sample_number values. Duplicate seek
737 * points are converted into placeholder points and sorted to the end of
740 * \param seek_table A pointer to a seek table to be sorted.
742 * \code seek_table != NULL \endcode
744 * The number of duplicate seek points converted into placeholders.
746 FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
748 /*@@@@ add to unit tests */
749 /** Check a cue sheet to see if it conforms to the FLAC specification.
750 * See the format specification for limits on the contents of the
753 * \param cue_sheet A pointer to an existing cue sheet to be checked.
754 * \param check_cd_da_subset If \c true, check CUESHEET against more
755 * stringent requirements for a CD-DA (audio) disc.
756 * \param violation Address of a pointer to a string. If there is a
757 * violation, a pointer to a string explanation of the
758 * violation will be returned here. \a violation may be
759 * \c NULL if you don't need the returned string. Do not
760 * free the returned string; it will always point to static
763 * \code cue_sheet != NULL \endcode
765 * \c false if cue sheet is illegal, else \c true.
767 FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation);