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