annotate osx/include/FLAC/format.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents cc5d363db385
children
rev   line source
Chris@2 1 /* libFLAC - Free Lossless Audio Codec library
Chris@2 2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Chris@2 3 *
Chris@2 4 * Redistribution and use in source and binary forms, with or without
Chris@2 5 * modification, are permitted provided that the following conditions
Chris@2 6 * are met:
Chris@2 7 *
Chris@2 8 * - Redistributions of source code must retain the above copyright
Chris@2 9 * notice, this list of conditions and the following disclaimer.
Chris@2 10 *
Chris@2 11 * - Redistributions in binary form must reproduce the above copyright
Chris@2 12 * notice, this list of conditions and the following disclaimer in the
Chris@2 13 * documentation and/or other materials provided with the distribution.
Chris@2 14 *
Chris@2 15 * - Neither the name of the Xiph.org Foundation nor the names of its
Chris@2 16 * contributors may be used to endorse or promote products derived from
Chris@2 17 * this software without specific prior written permission.
Chris@2 18 *
Chris@2 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@2 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@2 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@2 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
Chris@2 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@2 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@2 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@2 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@2 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@2 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@2 30 */
Chris@2 31
Chris@2 32 #ifndef FLAC__FORMAT_H
Chris@2 33 #define FLAC__FORMAT_H
Chris@2 34
Chris@2 35 #include "export.h"
Chris@2 36 #include "ordinals.h"
Chris@2 37
Chris@2 38 #ifdef __cplusplus
Chris@2 39 extern "C" {
Chris@2 40 #endif
Chris@2 41
Chris@2 42 /** \file include/FLAC/format.h
Chris@2 43 *
Chris@2 44 * \brief
Chris@2 45 * This module contains structure definitions for the representation
Chris@2 46 * of FLAC format components in memory. These are the basic
Chris@2 47 * structures used by the rest of the interfaces.
Chris@2 48 *
Chris@2 49 * See the detailed documentation in the
Chris@2 50 * \link flac_format format \endlink module.
Chris@2 51 */
Chris@2 52
Chris@2 53 /** \defgroup flac_format FLAC/format.h: format components
Chris@2 54 * \ingroup flac
Chris@2 55 *
Chris@2 56 * \brief
Chris@2 57 * This module contains structure definitions for the representation
Chris@2 58 * of FLAC format components in memory. These are the basic
Chris@2 59 * structures used by the rest of the interfaces.
Chris@2 60 *
Chris@2 61 * First, you should be familiar with the
Chris@2 62 * <A HREF="../format.html">FLAC format</A>. Many of the values here
Chris@2 63 * follow directly from the specification. As a user of libFLAC, the
Chris@2 64 * interesting parts really are the structures that describe the frame
Chris@2 65 * header and metadata blocks.
Chris@2 66 *
Chris@2 67 * The format structures here are very primitive, designed to store
Chris@2 68 * information in an efficient way. Reading information from the
Chris@2 69 * structures is easy but creating or modifying them directly is
Chris@2 70 * more complex. For the most part, as a user of a library, editing
Chris@2 71 * is not necessary; however, for metadata blocks it is, so there are
Chris@2 72 * convenience functions provided in the \link flac_metadata metadata
Chris@2 73 * module \endlink to simplify the manipulation of metadata blocks.
Chris@2 74 *
Chris@2 75 * \note
Chris@2 76 * It's not the best convention, but symbols ending in _LEN are in bits
Chris@2 77 * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of
Chris@2 78 * global variables because they are usually used when declaring byte
Chris@2 79 * arrays and some compilers require compile-time knowledge of array
Chris@2 80 * sizes when declared on the stack.
Chris@2 81 *
Chris@2 82 * \{
Chris@2 83 */
Chris@2 84
Chris@2 85
Chris@2 86 /*
Chris@2 87 Most of the values described in this file are defined by the FLAC
Chris@2 88 format specification. There is nothing to tune here.
Chris@2 89 */
Chris@2 90
Chris@2 91 /** The largest legal metadata type code. */
Chris@2 92 #define FLAC__MAX_METADATA_TYPE_CODE (126u)
Chris@2 93
Chris@2 94 /** The minimum block size, in samples, permitted by the format. */
Chris@2 95 #define FLAC__MIN_BLOCK_SIZE (16u)
Chris@2 96
Chris@2 97 /** The maximum block size, in samples, permitted by the format. */
Chris@2 98 #define FLAC__MAX_BLOCK_SIZE (65535u)
Chris@2 99
Chris@2 100 /** The maximum block size, in samples, permitted by the FLAC subset for
Chris@2 101 * sample rates up to 48kHz. */
Chris@2 102 #define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u)
Chris@2 103
Chris@2 104 /** The maximum number of channels permitted by the format. */
Chris@2 105 #define FLAC__MAX_CHANNELS (8u)
Chris@2 106
Chris@2 107 /** The minimum sample resolution permitted by the format. */
Chris@2 108 #define FLAC__MIN_BITS_PER_SAMPLE (4u)
Chris@2 109
Chris@2 110 /** The maximum sample resolution permitted by the format. */
Chris@2 111 #define FLAC__MAX_BITS_PER_SAMPLE (32u)
Chris@2 112
Chris@2 113 /** The maximum sample resolution permitted by libFLAC.
Chris@2 114 *
Chris@2 115 * \warning
Chris@2 116 * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However,
Chris@2 117 * the reference encoder/decoder is currently limited to 24 bits because
Chris@2 118 * of prevalent 32-bit math, so make sure and use this value when
Chris@2 119 * appropriate.
Chris@2 120 */
Chris@2 121 #define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
Chris@2 122
Chris@2 123 /** The maximum sample rate permitted by the format. The value is
Chris@2 124 * ((2 ^ 16) - 1) * 10; see <A HREF="../format.html">FLAC format</A>
Chris@2 125 * as to why.
Chris@2 126 */
Chris@2 127 #define FLAC__MAX_SAMPLE_RATE (655350u)
Chris@2 128
Chris@2 129 /** The maximum LPC order permitted by the format. */
Chris@2 130 #define FLAC__MAX_LPC_ORDER (32u)
Chris@2 131
Chris@2 132 /** The maximum LPC order permitted by the FLAC subset for sample rates
Chris@2 133 * up to 48kHz. */
Chris@2 134 #define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u)
Chris@2 135
Chris@2 136 /** The minimum quantized linear predictor coefficient precision
Chris@2 137 * permitted by the format.
Chris@2 138 */
Chris@2 139 #define FLAC__MIN_QLP_COEFF_PRECISION (5u)
Chris@2 140
Chris@2 141 /** The maximum quantized linear predictor coefficient precision
Chris@2 142 * permitted by the format.
Chris@2 143 */
Chris@2 144 #define FLAC__MAX_QLP_COEFF_PRECISION (15u)
Chris@2 145
Chris@2 146 /** The maximum order of the fixed predictors permitted by the format. */
Chris@2 147 #define FLAC__MAX_FIXED_ORDER (4u)
Chris@2 148
Chris@2 149 /** The maximum Rice partition order permitted by the format. */
Chris@2 150 #define FLAC__MAX_RICE_PARTITION_ORDER (15u)
Chris@2 151
Chris@2 152 /** The maximum Rice partition order permitted by the FLAC Subset. */
Chris@2 153 #define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
Chris@2 154
Chris@2 155 /** The version string of the release, stamped onto the libraries and binaries.
Chris@2 156 *
Chris@2 157 * \note
Chris@2 158 * This does not correspond to the shared library version number, which
Chris@2 159 * is used to determine binary compatibility.
Chris@2 160 */
Chris@2 161 extern FLAC_API const char *FLAC__VERSION_STRING;
Chris@2 162
Chris@2 163 /** The vendor string inserted by the encoder into the VORBIS_COMMENT block.
Chris@2 164 * This is a NUL-terminated ASCII string; when inserted into the
Chris@2 165 * VORBIS_COMMENT the trailing null is stripped.
Chris@2 166 */
Chris@2 167 extern FLAC_API const char *FLAC__VENDOR_STRING;
Chris@2 168
Chris@2 169 /** The byte string representation of the beginning of a FLAC stream. */
Chris@2 170 extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */
Chris@2 171
Chris@2 172 /** The 32-bit integer big-endian representation of the beginning of
Chris@2 173 * a FLAC stream.
Chris@2 174 */
Chris@2 175 extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */
Chris@2 176
Chris@2 177 /** The length of the FLAC signature in bits. */
Chris@2 178 extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */
Chris@2 179
Chris@2 180 /** The length of the FLAC signature in bytes. */
Chris@2 181 #define FLAC__STREAM_SYNC_LENGTH (4u)
Chris@2 182
Chris@2 183
Chris@2 184 /*****************************************************************************
Chris@2 185 *
Chris@2 186 * Subframe structures
Chris@2 187 *
Chris@2 188 *****************************************************************************/
Chris@2 189
Chris@2 190 /*****************************************************************************/
Chris@2 191
Chris@2 192 /** An enumeration of the available entropy coding methods. */
Chris@2 193 typedef enum {
Chris@2 194 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0,
Chris@2 195 /**< Residual is coded by partitioning into contexts, each with it's own
Chris@2 196 * 4-bit Rice parameter. */
Chris@2 197
Chris@2 198 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1
Chris@2 199 /**< Residual is coded by partitioning into contexts, each with it's own
Chris@2 200 * 5-bit Rice parameter. */
Chris@2 201 } FLAC__EntropyCodingMethodType;
Chris@2 202
Chris@2 203 /** Maps a FLAC__EntropyCodingMethodType to a C string.
Chris@2 204 *
Chris@2 205 * Using a FLAC__EntropyCodingMethodType as the index to this array will
Chris@2 206 * give the string equivalent. The contents should not be modified.
Chris@2 207 */
Chris@2 208 extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
Chris@2 209
Chris@2 210
Chris@2 211 /** Contents of a Rice partitioned residual
Chris@2 212 */
Chris@2 213 typedef struct {
Chris@2 214
Chris@2 215 unsigned *parameters;
Chris@2 216 /**< The Rice parameters for each context. */
Chris@2 217
Chris@2 218 unsigned *raw_bits;
Chris@2 219 /**< Widths for escape-coded partitions. Will be non-zero for escaped
Chris@2 220 * partitions and zero for unescaped partitions.
Chris@2 221 */
Chris@2 222
Chris@2 223 unsigned capacity_by_order;
Chris@2 224 /**< The capacity of the \a parameters and \a raw_bits arrays
Chris@2 225 * specified as an order, i.e. the number of array elements
Chris@2 226 * allocated is 2 ^ \a capacity_by_order.
Chris@2 227 */
Chris@2 228 } FLAC__EntropyCodingMethod_PartitionedRiceContents;
Chris@2 229
Chris@2 230 /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
Chris@2 231 */
Chris@2 232 typedef struct {
Chris@2 233
Chris@2 234 unsigned order;
Chris@2 235 /**< The partition order, i.e. # of contexts = 2 ^ \a order. */
Chris@2 236
Chris@2 237 const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
Chris@2 238 /**< The context's Rice parameters and/or raw bits. */
Chris@2 239
Chris@2 240 } FLAC__EntropyCodingMethod_PartitionedRice;
Chris@2 241
Chris@2 242 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
Chris@2 243 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
Chris@2 244 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */
Chris@2 245 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
Chris@2 246
Chris@2 247 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
Chris@2 248 /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
Chris@2 249 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;
Chris@2 250 /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
Chris@2 251
Chris@2 252 /** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>)
Chris@2 253 */
Chris@2 254 typedef struct {
Chris@2 255 FLAC__EntropyCodingMethodType type;
Chris@2 256 union {
Chris@2 257 FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
Chris@2 258 } data;
Chris@2 259 } FLAC__EntropyCodingMethod;
Chris@2 260
Chris@2 261 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
Chris@2 262
Chris@2 263 /*****************************************************************************/
Chris@2 264
Chris@2 265 /** An enumeration of the available subframe types. */
Chris@2 266 typedef enum {
Chris@2 267 FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */
Chris@2 268 FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */
Chris@2 269 FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */
Chris@2 270 FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */
Chris@2 271 } FLAC__SubframeType;
Chris@2 272
Chris@2 273 /** Maps a FLAC__SubframeType to a C string.
Chris@2 274 *
Chris@2 275 * Using a FLAC__SubframeType as the index to this array will
Chris@2 276 * give the string equivalent. The contents should not be modified.
Chris@2 277 */
Chris@2 278 extern FLAC_API const char * const FLAC__SubframeTypeString[];
Chris@2 279
Chris@2 280
Chris@2 281 /** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>)
Chris@2 282 */
Chris@2 283 typedef struct {
Chris@2 284 FLAC__int32 value; /**< The constant signal value. */
Chris@2 285 } FLAC__Subframe_Constant;
Chris@2 286
Chris@2 287
Chris@2 288 /** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>)
Chris@2 289 */
Chris@2 290 typedef struct {
Chris@2 291 const FLAC__int32 *data; /**< A pointer to verbatim signal. */
Chris@2 292 } FLAC__Subframe_Verbatim;
Chris@2 293
Chris@2 294
Chris@2 295 /** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>)
Chris@2 296 */
Chris@2 297 typedef struct {
Chris@2 298 FLAC__EntropyCodingMethod entropy_coding_method;
Chris@2 299 /**< The residual coding method. */
Chris@2 300
Chris@2 301 unsigned order;
Chris@2 302 /**< The polynomial order. */
Chris@2 303
Chris@2 304 FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
Chris@2 305 /**< Warmup samples to prime the predictor, length == order. */
Chris@2 306
Chris@2 307 const FLAC__int32 *residual;
Chris@2 308 /**< The residual signal, length == (blocksize minus order) samples. */
Chris@2 309 } FLAC__Subframe_Fixed;
Chris@2 310
Chris@2 311
Chris@2 312 /** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>)
Chris@2 313 */
Chris@2 314 typedef struct {
Chris@2 315 FLAC__EntropyCodingMethod entropy_coding_method;
Chris@2 316 /**< The residual coding method. */
Chris@2 317
Chris@2 318 unsigned order;
Chris@2 319 /**< The FIR order. */
Chris@2 320
Chris@2 321 unsigned qlp_coeff_precision;
Chris@2 322 /**< Quantized FIR filter coefficient precision in bits. */
Chris@2 323
Chris@2 324 int quantization_level;
Chris@2 325 /**< The qlp coeff shift needed. */
Chris@2 326
Chris@2 327 FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
Chris@2 328 /**< FIR filter coefficients. */
Chris@2 329
Chris@2 330 FLAC__int32 warmup[FLAC__MAX_LPC_ORDER];
Chris@2 331 /**< Warmup samples to prime the predictor, length == order. */
Chris@2 332
Chris@2 333 const FLAC__int32 *residual;
Chris@2 334 /**< The residual signal, length == (blocksize minus order) samples. */
Chris@2 335 } FLAC__Subframe_LPC;
Chris@2 336
Chris@2 337 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */
Chris@2 338 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */
Chris@2 339
Chris@2 340
Chris@2 341 /** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>)
Chris@2 342 */
Chris@2 343 typedef struct {
Chris@2 344 FLAC__SubframeType type;
Chris@2 345 union {
Chris@2 346 FLAC__Subframe_Constant constant;
Chris@2 347 FLAC__Subframe_Fixed fixed;
Chris@2 348 FLAC__Subframe_LPC lpc;
Chris@2 349 FLAC__Subframe_Verbatim verbatim;
Chris@2 350 } data;
Chris@2 351 unsigned wasted_bits;
Chris@2 352 } FLAC__Subframe;
Chris@2 353
Chris@2 354 /** == 1 (bit)
Chris@2 355 *
Chris@2 356 * This used to be a zero-padding bit (hence the name
Chris@2 357 * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a
Chris@2 358 * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1
Chris@2 359 * to mean something else.
Chris@2 360 */
Chris@2 361 extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN;
Chris@2 362 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */
Chris@2 363 extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */
Chris@2 364
Chris@2 365 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */
Chris@2 366 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */
Chris@2 367 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */
Chris@2 368 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */
Chris@2 369
Chris@2 370 /*****************************************************************************/
Chris@2 371
Chris@2 372
Chris@2 373 /*****************************************************************************
Chris@2 374 *
Chris@2 375 * Frame structures
Chris@2 376 *
Chris@2 377 *****************************************************************************/
Chris@2 378
Chris@2 379 /** An enumeration of the available channel assignments. */
Chris@2 380 typedef enum {
Chris@2 381 FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */
Chris@2 382 FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */
Chris@2 383 FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */
Chris@2 384 FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */
Chris@2 385 } FLAC__ChannelAssignment;
Chris@2 386
Chris@2 387 /** Maps a FLAC__ChannelAssignment to a C string.
Chris@2 388 *
Chris@2 389 * Using a FLAC__ChannelAssignment as the index to this array will
Chris@2 390 * give the string equivalent. The contents should not be modified.
Chris@2 391 */
Chris@2 392 extern FLAC_API const char * const FLAC__ChannelAssignmentString[];
Chris@2 393
Chris@2 394 /** An enumeration of the possible frame numbering methods. */
Chris@2 395 typedef enum {
Chris@2 396 FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */
Chris@2 397 FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */
Chris@2 398 } FLAC__FrameNumberType;
Chris@2 399
Chris@2 400 /** Maps a FLAC__FrameNumberType to a C string.
Chris@2 401 *
Chris@2 402 * Using a FLAC__FrameNumberType as the index to this array will
Chris@2 403 * give the string equivalent. The contents should not be modified.
Chris@2 404 */
Chris@2 405 extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
Chris@2 406
Chris@2 407
Chris@2 408 /** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>)
Chris@2 409 */
Chris@2 410 typedef struct {
Chris@2 411 unsigned blocksize;
Chris@2 412 /**< The number of samples per subframe. */
Chris@2 413
Chris@2 414 unsigned sample_rate;
Chris@2 415 /**< The sample rate in Hz. */
Chris@2 416
Chris@2 417 unsigned channels;
Chris@2 418 /**< The number of channels (== number of subframes). */
Chris@2 419
Chris@2 420 FLAC__ChannelAssignment channel_assignment;
Chris@2 421 /**< The channel assignment for the frame. */
Chris@2 422
Chris@2 423 unsigned bits_per_sample;
Chris@2 424 /**< The sample resolution. */
Chris@2 425
Chris@2 426 FLAC__FrameNumberType number_type;
Chris@2 427 /**< The numbering scheme used for the frame. As a convenience, the
Chris@2 428 * decoder will always convert a frame number to a sample number because
Chris@2 429 * the rules are complex. */
Chris@2 430
Chris@2 431 union {
Chris@2 432 FLAC__uint32 frame_number;
Chris@2 433 FLAC__uint64 sample_number;
Chris@2 434 } number;
Chris@2 435 /**< The frame number or sample number of first sample in frame;
Chris@2 436 * use the \a number_type value to determine which to use. */
Chris@2 437
Chris@2 438 FLAC__uint8 crc;
Chris@2 439 /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0)
Chris@2 440 * of the raw frame header bytes, meaning everything before the CRC byte
Chris@2 441 * including the sync code.
Chris@2 442 */
Chris@2 443 } FLAC__FrameHeader;
Chris@2 444
Chris@2 445 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
Chris@2 446 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */
Chris@2 447 extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */
Chris@2 448 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */
Chris@2 449 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */
Chris@2 450 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */
Chris@2 451 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */
Chris@2 452 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */
Chris@2 453 extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */
Chris@2 454 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */
Chris@2 455
Chris@2 456
Chris@2 457 /** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>)
Chris@2 458 */
Chris@2 459 typedef struct {
Chris@2 460 FLAC__uint16 crc;
Chris@2 461 /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with
Chris@2 462 * 0) of the bytes before the crc, back to and including the frame header
Chris@2 463 * sync code.
Chris@2 464 */
Chris@2 465 } FLAC__FrameFooter;
Chris@2 466
Chris@2 467 extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
Chris@2 468
Chris@2 469
Chris@2 470 /** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>)
Chris@2 471 */
Chris@2 472 typedef struct {
Chris@2 473 FLAC__FrameHeader header;
Chris@2 474 FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
Chris@2 475 FLAC__FrameFooter footer;
Chris@2 476 } FLAC__Frame;
Chris@2 477
Chris@2 478 /*****************************************************************************/
Chris@2 479
Chris@2 480
Chris@2 481 /*****************************************************************************
Chris@2 482 *
Chris@2 483 * Meta-data structures
Chris@2 484 *
Chris@2 485 *****************************************************************************/
Chris@2 486
Chris@2 487 /** An enumeration of the available metadata block types. */
Chris@2 488 typedef enum {
Chris@2 489
Chris@2 490 FLAC__METADATA_TYPE_STREAMINFO = 0,
Chris@2 491 /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */
Chris@2 492
Chris@2 493 FLAC__METADATA_TYPE_PADDING = 1,
Chris@2 494 /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */
Chris@2 495
Chris@2 496 FLAC__METADATA_TYPE_APPLICATION = 2,
Chris@2 497 /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */
Chris@2 498
Chris@2 499 FLAC__METADATA_TYPE_SEEKTABLE = 3,
Chris@2 500 /**< <A HREF="../format.html#metadata_block_seektable">SEEKTABLE</A> block */
Chris@2 501
Chris@2 502 FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
Chris@2 503 /**< <A HREF="../format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block (a.k.a. FLAC tags) */
Chris@2 504
Chris@2 505 FLAC__METADATA_TYPE_CUESHEET = 5,
Chris@2 506 /**< <A HREF="../format.html#metadata_block_cuesheet">CUESHEET</A> block */
Chris@2 507
Chris@2 508 FLAC__METADATA_TYPE_PICTURE = 6,
Chris@2 509 /**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */
Chris@2 510
Chris@2 511 FLAC__METADATA_TYPE_UNDEFINED = 7
Chris@2 512 /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
Chris@2 513
Chris@2 514 } FLAC__MetadataType;
Chris@2 515
Chris@2 516 /** Maps a FLAC__MetadataType to a C string.
Chris@2 517 *
Chris@2 518 * Using a FLAC__MetadataType as the index to this array will
Chris@2 519 * give the string equivalent. The contents should not be modified.
Chris@2 520 */
Chris@2 521 extern FLAC_API const char * const FLAC__MetadataTypeString[];
Chris@2 522
Chris@2 523
Chris@2 524 /** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>)
Chris@2 525 */
Chris@2 526 typedef struct {
Chris@2 527 unsigned min_blocksize, max_blocksize;
Chris@2 528 unsigned min_framesize, max_framesize;
Chris@2 529 unsigned sample_rate;
Chris@2 530 unsigned channels;
Chris@2 531 unsigned bits_per_sample;
Chris@2 532 FLAC__uint64 total_samples;
Chris@2 533 FLAC__byte md5sum[16];
Chris@2 534 } FLAC__StreamMetadata_StreamInfo;
Chris@2 535
Chris@2 536 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */
Chris@2 537 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */
Chris@2 538 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */
Chris@2 539 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */
Chris@2 540 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */
Chris@2 541 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */
Chris@2 542 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */
Chris@2 543 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */
Chris@2 544 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */
Chris@2 545
Chris@2 546 /** The total stream length of the STREAMINFO block in bytes. */
Chris@2 547 #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
Chris@2 548
Chris@2 549 /** FLAC PADDING structure. (c.f. <A HREF="../format.html#metadata_block_padding">format specification</A>)
Chris@2 550 */
Chris@2 551 typedef struct {
Chris@2 552 int dummy;
Chris@2 553 /**< Conceptually this is an empty struct since we don't store the
Chris@2 554 * padding bytes. Empty structs are not allowed by some C compilers,
Chris@2 555 * hence the dummy.
Chris@2 556 */
Chris@2 557 } FLAC__StreamMetadata_Padding;
Chris@2 558
Chris@2 559
Chris@2 560 /** FLAC APPLICATION structure. (c.f. <A HREF="../format.html#metadata_block_application">format specification</A>)
Chris@2 561 */
Chris@2 562 typedef struct {
Chris@2 563 FLAC__byte id[4];
Chris@2 564 FLAC__byte *data;
Chris@2 565 } FLAC__StreamMetadata_Application;
Chris@2 566
Chris@2 567 extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */
Chris@2 568
Chris@2 569 /** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="../format.html#seekpoint">format specification</A>)
Chris@2 570 */
Chris@2 571 typedef struct {
Chris@2 572 FLAC__uint64 sample_number;
Chris@2 573 /**< The sample number of the target frame. */
Chris@2 574
Chris@2 575 FLAC__uint64 stream_offset;
Chris@2 576 /**< The offset, in bytes, of the target frame with respect to
Chris@2 577 * beginning of the first frame. */
Chris@2 578
Chris@2 579 unsigned frame_samples;
Chris@2 580 /**< The number of samples in the target frame. */
Chris@2 581 } FLAC__StreamMetadata_SeekPoint;
Chris@2 582
Chris@2 583 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */
Chris@2 584 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */
Chris@2 585 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */
Chris@2 586
Chris@2 587 /** The total stream length of a seek point in bytes. */
Chris@2 588 #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
Chris@2 589
Chris@2 590 /** The value used in the \a sample_number field of
Chris@2 591 * FLAC__StreamMetadataSeekPoint used to indicate a placeholder
Chris@2 592 * point (== 0xffffffffffffffff).
Chris@2 593 */
Chris@2 594 extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
Chris@2 595
Chris@2 596
Chris@2 597 /** FLAC SEEKTABLE structure. (c.f. <A HREF="../format.html#metadata_block_seektable">format specification</A>)
Chris@2 598 *
Chris@2 599 * \note From the format specification:
Chris@2 600 * - The seek points must be sorted by ascending sample number.
Chris@2 601 * - Each seek point's sample number must be the first sample of the
Chris@2 602 * target frame.
Chris@2 603 * - Each seek point's sample number must be unique within the table.
Chris@2 604 * - Existence of a SEEKTABLE block implies a correct setting of
Chris@2 605 * total_samples in the stream_info block.
Chris@2 606 * - Behavior is undefined when more than one SEEKTABLE block is
Chris@2 607 * present in a stream.
Chris@2 608 */
Chris@2 609 typedef struct {
Chris@2 610 unsigned num_points;
Chris@2 611 FLAC__StreamMetadata_SeekPoint *points;
Chris@2 612 } FLAC__StreamMetadata_SeekTable;
Chris@2 613
Chris@2 614
Chris@2 615 /** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
Chris@2 616 *
Chris@2 617 * For convenience, the APIs maintain a trailing NUL character at the end of
Chris@2 618 * \a entry which is not counted toward \a length, i.e.
Chris@2 619 * \code strlen(entry) == length \endcode
Chris@2 620 */
Chris@2 621 typedef struct {
Chris@2 622 FLAC__uint32 length;
Chris@2 623 FLAC__byte *entry;
Chris@2 624 } FLAC__StreamMetadata_VorbisComment_Entry;
Chris@2 625
Chris@2 626 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */
Chris@2 627
Chris@2 628
Chris@2 629 /** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
Chris@2 630 */
Chris@2 631 typedef struct {
Chris@2 632 FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
Chris@2 633 FLAC__uint32 num_comments;
Chris@2 634 FLAC__StreamMetadata_VorbisComment_Entry *comments;
Chris@2 635 } FLAC__StreamMetadata_VorbisComment;
Chris@2 636
Chris@2 637 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */
Chris@2 638
Chris@2 639
Chris@2 640 /** FLAC CUESHEET track index structure. (See the
Chris@2 641 * <A HREF="../format.html#cuesheet_track_index">format specification</A> for
Chris@2 642 * the full description of each field.)
Chris@2 643 */
Chris@2 644 typedef struct {
Chris@2 645 FLAC__uint64 offset;
Chris@2 646 /**< Offset in samples, relative to the track offset, of the index
Chris@2 647 * point.
Chris@2 648 */
Chris@2 649
Chris@2 650 FLAC__byte number;
Chris@2 651 /**< The index point number. */
Chris@2 652 } FLAC__StreamMetadata_CueSheet_Index;
Chris@2 653
Chris@2 654 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */
Chris@2 655 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */
Chris@2 656 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */
Chris@2 657
Chris@2 658
Chris@2 659 /** FLAC CUESHEET track structure. (See the
Chris@2 660 * <A HREF="../format.html#cuesheet_track">format specification</A> for
Chris@2 661 * the full description of each field.)
Chris@2 662 */
Chris@2 663 typedef struct {
Chris@2 664 FLAC__uint64 offset;
Chris@2 665 /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */
Chris@2 666
Chris@2 667 FLAC__byte number;
Chris@2 668 /**< The track number. */
Chris@2 669
Chris@2 670 char isrc[13];
Chris@2 671 /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */
Chris@2 672
Chris@2 673 unsigned type:1;
Chris@2 674 /**< The track type: 0 for audio, 1 for non-audio. */
Chris@2 675
Chris@2 676 unsigned pre_emphasis:1;
Chris@2 677 /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */
Chris@2 678
Chris@2 679 FLAC__byte num_indices;
Chris@2 680 /**< The number of track index points. */
Chris@2 681
Chris@2 682 FLAC__StreamMetadata_CueSheet_Index *indices;
Chris@2 683 /**< NULL if num_indices == 0, else pointer to array of index points. */
Chris@2 684
Chris@2 685 } FLAC__StreamMetadata_CueSheet_Track;
Chris@2 686
Chris@2 687 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */
Chris@2 688 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */
Chris@2 689 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */
Chris@2 690 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */
Chris@2 691 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */
Chris@2 692 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */
Chris@2 693 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */
Chris@2 694
Chris@2 695
Chris@2 696 /** FLAC CUESHEET structure. (See the
Chris@2 697 * <A HREF="../format.html#metadata_block_cuesheet">format specification</A>
Chris@2 698 * for the full description of each field.)
Chris@2 699 */
Chris@2 700 typedef struct {
Chris@2 701 char media_catalog_number[129];
Chris@2 702 /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In
Chris@2 703 * general, the media catalog number may be 0 to 128 bytes long; any
Chris@2 704 * unused characters should be right-padded with NUL characters.
Chris@2 705 */
Chris@2 706
Chris@2 707 FLAC__uint64 lead_in;
Chris@2 708 /**< The number of lead-in samples. */
Chris@2 709
Chris@2 710 FLAC__bool is_cd;
Chris@2 711 /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */
Chris@2 712
Chris@2 713 unsigned num_tracks;
Chris@2 714 /**< The number of tracks. */
Chris@2 715
Chris@2 716 FLAC__StreamMetadata_CueSheet_Track *tracks;
Chris@2 717 /**< NULL if num_tracks == 0, else pointer to array of tracks. */
Chris@2 718
Chris@2 719 } FLAC__StreamMetadata_CueSheet;
Chris@2 720
Chris@2 721 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
Chris@2 722 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
Chris@2 723 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */
Chris@2 724 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */
Chris@2 725 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */
Chris@2 726
Chris@2 727
Chris@2 728 /** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */
Chris@2 729 typedef enum {
Chris@2 730 FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */
Chris@2 731 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */
Chris@2 732 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */
Chris@2 733 FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */
Chris@2 734 FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */
Chris@2 735 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */
Chris@2 736 FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */
Chris@2 737 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */
Chris@2 738 FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */
Chris@2 739 FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */
Chris@2 740 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */
Chris@2 741 FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */
Chris@2 742 FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */
Chris@2 743 FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */
Chris@2 744 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */
Chris@2 745 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */
Chris@2 746 FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */
Chris@2 747 FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */
Chris@2 748 FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */
Chris@2 749 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */
Chris@2 750 FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */
Chris@2 751 FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED
Chris@2 752 } FLAC__StreamMetadata_Picture_Type;
Chris@2 753
Chris@2 754 /** Maps a FLAC__StreamMetadata_Picture_Type to a C string.
Chris@2 755 *
Chris@2 756 * Using a FLAC__StreamMetadata_Picture_Type as the index to this array
Chris@2 757 * will give the string equivalent. The contents should not be
Chris@2 758 * modified.
Chris@2 759 */
Chris@2 760 extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[];
Chris@2 761
Chris@2 762 /** FLAC PICTURE structure. (See the
Chris@2 763 * <A HREF="../format.html#metadata_block_picture">format specification</A>
Chris@2 764 * for the full description of each field.)
Chris@2 765 */
Chris@2 766 typedef struct {
Chris@2 767 FLAC__StreamMetadata_Picture_Type type;
Chris@2 768 /**< The kind of picture stored. */
Chris@2 769
Chris@2 770 char *mime_type;
Chris@2 771 /**< Picture data's MIME type, in ASCII printable characters
Chris@2 772 * 0x20-0x7e, NUL terminated. For best compatibility with players,
Chris@2 773 * use picture data of MIME type \c image/jpeg or \c image/png. A
Chris@2 774 * MIME type of '-->' is also allowed, in which case the picture
Chris@2 775 * data should be a complete URL. In file storage, the MIME type is
Chris@2 776 * stored as a 32-bit length followed by the ASCII string with no NUL
Chris@2 777 * terminator, but is converted to a plain C string in this structure
Chris@2 778 * for convenience.
Chris@2 779 */
Chris@2 780
Chris@2 781 FLAC__byte *description;
Chris@2 782 /**< Picture's description in UTF-8, NUL terminated. In file storage,
Chris@2 783 * the description is stored as a 32-bit length followed by the UTF-8
Chris@2 784 * string with no NUL terminator, but is converted to a plain C string
Chris@2 785 * in this structure for convenience.
Chris@2 786 */
Chris@2 787
Chris@2 788 FLAC__uint32 width;
Chris@2 789 /**< Picture's width in pixels. */
Chris@2 790
Chris@2 791 FLAC__uint32 height;
Chris@2 792 /**< Picture's height in pixels. */
Chris@2 793
Chris@2 794 FLAC__uint32 depth;
Chris@2 795 /**< Picture's color depth in bits-per-pixel. */
Chris@2 796
Chris@2 797 FLAC__uint32 colors;
Chris@2 798 /**< For indexed palettes (like GIF), picture's number of colors (the
Chris@2 799 * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth).
Chris@2 800 */
Chris@2 801
Chris@2 802 FLAC__uint32 data_length;
Chris@2 803 /**< Length of binary picture data in bytes. */
Chris@2 804
Chris@2 805 FLAC__byte *data;
Chris@2 806 /**< Binary picture data. */
Chris@2 807
Chris@2 808 } FLAC__StreamMetadata_Picture;
Chris@2 809
Chris@2 810 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */
Chris@2 811 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */
Chris@2 812 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */
Chris@2 813 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */
Chris@2 814 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */
Chris@2 815 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */
Chris@2 816 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */
Chris@2 817 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */
Chris@2 818
Chris@2 819
Chris@2 820 /** Structure that is used when a metadata block of unknown type is loaded.
Chris@2 821 * The contents are opaque. The structure is used only internally to
Chris@2 822 * correctly handle unknown metadata.
Chris@2 823 */
Chris@2 824 typedef struct {
Chris@2 825 FLAC__byte *data;
Chris@2 826 } FLAC__StreamMetadata_Unknown;
Chris@2 827
Chris@2 828
Chris@2 829 /** FLAC metadata block structure. (c.f. <A HREF="../format.html#metadata_block">format specification</A>)
Chris@2 830 */
Chris@2 831 typedef struct {
Chris@2 832 FLAC__MetadataType type;
Chris@2 833 /**< The type of the metadata block; used determine which member of the
Chris@2 834 * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED
Chris@2 835 * then \a data.unknown must be used. */
Chris@2 836
Chris@2 837 FLAC__bool is_last;
Chris@2 838 /**< \c true if this metadata block is the last, else \a false */
Chris@2 839
Chris@2 840 unsigned length;
Chris@2 841 /**< Length, in bytes, of the block data as it appears in the stream. */
Chris@2 842
Chris@2 843 union {
Chris@2 844 FLAC__StreamMetadata_StreamInfo stream_info;
Chris@2 845 FLAC__StreamMetadata_Padding padding;
Chris@2 846 FLAC__StreamMetadata_Application application;
Chris@2 847 FLAC__StreamMetadata_SeekTable seek_table;
Chris@2 848 FLAC__StreamMetadata_VorbisComment vorbis_comment;
Chris@2 849 FLAC__StreamMetadata_CueSheet cue_sheet;
Chris@2 850 FLAC__StreamMetadata_Picture picture;
Chris@2 851 FLAC__StreamMetadata_Unknown unknown;
Chris@2 852 } data;
Chris@2 853 /**< Polymorphic block data; use the \a type value to determine which
Chris@2 854 * to use. */
Chris@2 855 } FLAC__StreamMetadata;
Chris@2 856
Chris@2 857 extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
Chris@2 858 extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */
Chris@2 859 extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */
Chris@2 860
Chris@2 861 /** The total stream length of a metadata block header in bytes. */
Chris@2 862 #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
Chris@2 863
Chris@2 864 /*****************************************************************************/
Chris@2 865
Chris@2 866
Chris@2 867 /*****************************************************************************
Chris@2 868 *
Chris@2 869 * Utility functions
Chris@2 870 *
Chris@2 871 *****************************************************************************/
Chris@2 872
Chris@2 873 /** Tests that a sample rate is valid for FLAC.
Chris@2 874 *
Chris@2 875 * \param sample_rate The sample rate to test for compliance.
Chris@2 876 * \retval FLAC__bool
Chris@2 877 * \c true if the given sample rate conforms to the specification, else
Chris@2 878 * \c false.
Chris@2 879 */
Chris@2 880 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
Chris@2 881
Chris@2 882 /** Tests that a sample rate is valid for the FLAC subset. The subset rules
Chris@2 883 * for valid sample rates are slightly more complex since the rate has to
Chris@2 884 * be expressible completely in the frame header.
Chris@2 885 *
Chris@2 886 * \param sample_rate The sample rate to test for compliance.
Chris@2 887 * \retval FLAC__bool
Chris@2 888 * \c true if the given sample rate conforms to the specification for the
Chris@2 889 * subset, else \c false.
Chris@2 890 */
Chris@2 891 FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate);
Chris@2 892
Chris@2 893 /** Check a Vorbis comment entry name to see if it conforms to the Vorbis
Chris@2 894 * comment specification.
Chris@2 895 *
Chris@2 896 * Vorbis comment names must be composed only of characters from
Chris@2 897 * [0x20-0x3C,0x3E-0x7D].
Chris@2 898 *
Chris@2 899 * \param name A NUL-terminated string to be checked.
Chris@2 900 * \assert
Chris@2 901 * \code name != NULL \endcode
Chris@2 902 * \retval FLAC__bool
Chris@2 903 * \c false if entry name is illegal, else \c true.
Chris@2 904 */
Chris@2 905 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name);
Chris@2 906
Chris@2 907 /** Check a Vorbis comment entry value to see if it conforms to the Vorbis
Chris@2 908 * comment specification.
Chris@2 909 *
Chris@2 910 * Vorbis comment values must be valid UTF-8 sequences.
Chris@2 911 *
Chris@2 912 * \param value A string to be checked.
Chris@2 913 * \param length A the length of \a value in bytes. May be
Chris@2 914 * \c (unsigned)(-1) to indicate that \a value is a plain
Chris@2 915 * UTF-8 NUL-terminated string.
Chris@2 916 * \assert
Chris@2 917 * \code value != NULL \endcode
Chris@2 918 * \retval FLAC__bool
Chris@2 919 * \c false if entry name is illegal, else \c true.
Chris@2 920 */
Chris@2 921 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length);
Chris@2 922
Chris@2 923 /** Check a Vorbis comment entry to see if it conforms to the Vorbis
Chris@2 924 * comment specification.
Chris@2 925 *
Chris@2 926 * Vorbis comment entries must be of the form 'name=value', and 'name' and
Chris@2 927 * 'value' must be legal according to
Chris@2 928 * FLAC__format_vorbiscomment_entry_name_is_legal() and
Chris@2 929 * FLAC__format_vorbiscomment_entry_value_is_legal() respectively.
Chris@2 930 *
Chris@2 931 * \param entry An entry to be checked.
Chris@2 932 * \param length The length of \a entry in bytes.
Chris@2 933 * \assert
Chris@2 934 * \code value != NULL \endcode
Chris@2 935 * \retval FLAC__bool
Chris@2 936 * \c false if entry name is illegal, else \c true.
Chris@2 937 */
Chris@2 938 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length);
Chris@2 939
Chris@2 940 /** Check a seek table to see if it conforms to the FLAC specification.
Chris@2 941 * See the format specification for limits on the contents of the
Chris@2 942 * seek table.
Chris@2 943 *
Chris@2 944 * \param seek_table A pointer to a seek table to be checked.
Chris@2 945 * \assert
Chris@2 946 * \code seek_table != NULL \endcode
Chris@2 947 * \retval FLAC__bool
Chris@2 948 * \c false if seek table is illegal, else \c true.
Chris@2 949 */
Chris@2 950 FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table);
Chris@2 951
Chris@2 952 /** Sort a seek table's seek points according to the format specification.
Chris@2 953 * This includes a "unique-ification" step to remove duplicates, i.e.
Chris@2 954 * seek points with identical \a sample_number values. Duplicate seek
Chris@2 955 * points are converted into placeholder points and sorted to the end of
Chris@2 956 * the table.
Chris@2 957 *
Chris@2 958 * \param seek_table A pointer to a seek table to be sorted.
Chris@2 959 * \assert
Chris@2 960 * \code seek_table != NULL \endcode
Chris@2 961 * \retval unsigned
Chris@2 962 * The number of duplicate seek points converted into placeholders.
Chris@2 963 */
Chris@2 964 FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
Chris@2 965
Chris@2 966 /** Check a cue sheet to see if it conforms to the FLAC specification.
Chris@2 967 * See the format specification for limits on the contents of the
Chris@2 968 * cue sheet.
Chris@2 969 *
Chris@2 970 * \param cue_sheet A pointer to an existing cue sheet to be checked.
Chris@2 971 * \param check_cd_da_subset If \c true, check CUESHEET against more
Chris@2 972 * stringent requirements for a CD-DA (audio) disc.
Chris@2 973 * \param violation Address of a pointer to a string. If there is a
Chris@2 974 * violation, a pointer to a string explanation of the
Chris@2 975 * violation will be returned here. \a violation may be
Chris@2 976 * \c NULL if you don't need the returned string. Do not
Chris@2 977 * free the returned string; it will always point to static
Chris@2 978 * data.
Chris@2 979 * \assert
Chris@2 980 * \code cue_sheet != NULL \endcode
Chris@2 981 * \retval FLAC__bool
Chris@2 982 * \c false if cue sheet is illegal, else \c true.
Chris@2 983 */
Chris@2 984 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@2 985
Chris@2 986 /** Check picture data to see if it conforms to the FLAC specification.
Chris@2 987 * See the format specification for limits on the contents of the
Chris@2 988 * PICTURE block.
Chris@2 989 *
Chris@2 990 * \param picture A pointer to existing picture data to be checked.
Chris@2 991 * \param violation Address of a pointer to a string. If there is a
Chris@2 992 * violation, a pointer to a string explanation of the
Chris@2 993 * violation will be returned here. \a violation may be
Chris@2 994 * \c NULL if you don't need the returned string. Do not
Chris@2 995 * free the returned string; it will always point to static
Chris@2 996 * data.
Chris@2 997 * \assert
Chris@2 998 * \code picture != NULL \endcode
Chris@2 999 * \retval FLAC__bool
Chris@2 1000 * \c false if picture data is illegal, else \c true.
Chris@2 1001 */
Chris@2 1002 FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation);
Chris@2 1003
Chris@2 1004 /* \} */
Chris@2 1005
Chris@2 1006 #ifdef __cplusplus
Chris@2 1007 }
Chris@2 1008 #endif
Chris@2 1009
Chris@2 1010 #endif