annotate win32-mingw/include/FLAC/format.h @ 30:553a5f65ef64

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