annotate win32-mingw/include/FLAC/format.h @ 169:223a55898ab9 tip default

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