annotate win64-mingw/include/FLAC/format.h @ 42:2cd0e3b3e1fd

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