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