Mercurial > hg > sv-dependency-builds
comparison osx/include/FLAC/format.h @ 87:dde06ec3df43
Add OS/X 64-bit builds
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 19 Mar 2013 20:33:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:98c1576536ae | 87:dde06ec3df43 |
---|---|
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 * 4-bit Rice parameter. */ | |
197 | |
198 FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 | |
199 /**< Residual is coded by partitioning into contexts, each with it's own | |
200 * 5-bit Rice parameter. */ | |
201 } FLAC__EntropyCodingMethodType; | |
202 | |
203 /** Maps a FLAC__EntropyCodingMethodType to a C string. | |
204 * | |
205 * Using a FLAC__EntropyCodingMethodType as the index to this array will | |
206 * give the string equivalent. The contents should not be modified. | |
207 */ | |
208 extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[]; | |
209 | |
210 | |
211 /** Contents of a Rice partitioned residual | |
212 */ | |
213 typedef struct { | |
214 | |
215 unsigned *parameters; | |
216 /**< The Rice parameters for each context. */ | |
217 | |
218 unsigned *raw_bits; | |
219 /**< Widths for escape-coded partitions. Will be non-zero for escaped | |
220 * partitions and zero for unescaped partitions. | |
221 */ | |
222 | |
223 unsigned capacity_by_order; | |
224 /**< The capacity of the \a parameters and \a raw_bits arrays | |
225 * specified as an order, i.e. the number of array elements | |
226 * allocated is 2 ^ \a capacity_by_order. | |
227 */ | |
228 } FLAC__EntropyCodingMethod_PartitionedRiceContents; | |
229 | |
230 /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>) | |
231 */ | |
232 typedef struct { | |
233 | |
234 unsigned order; | |
235 /**< The partition order, i.e. # of contexts = 2 ^ \a order. */ | |
236 | |
237 const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents; | |
238 /**< The context's Rice parameters and/or raw bits. */ | |
239 | |
240 } FLAC__EntropyCodingMethod_PartitionedRice; | |
241 | |
242 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */ | |
243 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */ | |
244 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */ | |
245 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */ | |
246 | |
247 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; | |
248 /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */ | |
249 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER; | |
250 /**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ | |
251 | |
252 /** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>) | |
253 */ | |
254 typedef struct { | |
255 FLAC__EntropyCodingMethodType type; | |
256 union { | |
257 FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice; | |
258 } data; | |
259 } FLAC__EntropyCodingMethod; | |
260 | |
261 extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */ | |
262 | |
263 /*****************************************************************************/ | |
264 | |
265 /** An enumeration of the available subframe types. */ | |
266 typedef enum { | |
267 FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */ | |
268 FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */ | |
269 FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */ | |
270 FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */ | |
271 } FLAC__SubframeType; | |
272 | |
273 /** Maps a FLAC__SubframeType to a C string. | |
274 * | |
275 * Using a FLAC__SubframeType as the index to this array will | |
276 * give the string equivalent. The contents should not be modified. | |
277 */ | |
278 extern FLAC_API const char * const FLAC__SubframeTypeString[]; | |
279 | |
280 | |
281 /** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>) | |
282 */ | |
283 typedef struct { | |
284 FLAC__int32 value; /**< The constant signal value. */ | |
285 } FLAC__Subframe_Constant; | |
286 | |
287 | |
288 /** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>) | |
289 */ | |
290 typedef struct { | |
291 const FLAC__int32 *data; /**< A pointer to verbatim signal. */ | |
292 } FLAC__Subframe_Verbatim; | |
293 | |
294 | |
295 /** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>) | |
296 */ | |
297 typedef struct { | |
298 FLAC__EntropyCodingMethod entropy_coding_method; | |
299 /**< The residual coding method. */ | |
300 | |
301 unsigned order; | |
302 /**< The polynomial order. */ | |
303 | |
304 FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER]; | |
305 /**< Warmup samples to prime the predictor, length == order. */ | |
306 | |
307 const FLAC__int32 *residual; | |
308 /**< The residual signal, length == (blocksize minus order) samples. */ | |
309 } FLAC__Subframe_Fixed; | |
310 | |
311 | |
312 /** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>) | |
313 */ | |
314 typedef struct { | |
315 FLAC__EntropyCodingMethod entropy_coding_method; | |
316 /**< The residual coding method. */ | |
317 | |
318 unsigned order; | |
319 /**< The FIR order. */ | |
320 | |
321 unsigned qlp_coeff_precision; | |
322 /**< Quantized FIR filter coefficient precision in bits. */ | |
323 | |
324 int quantization_level; | |
325 /**< The qlp coeff shift needed. */ | |
326 | |
327 FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; | |
328 /**< FIR filter coefficients. */ | |
329 | |
330 FLAC__int32 warmup[FLAC__MAX_LPC_ORDER]; | |
331 /**< Warmup samples to prime the predictor, length == order. */ | |
332 | |
333 const FLAC__int32 *residual; | |
334 /**< The residual signal, length == (blocksize minus order) samples. */ | |
335 } FLAC__Subframe_LPC; | |
336 | |
337 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */ | |
338 extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */ | |
339 | |
340 | |
341 /** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>) | |
342 */ | |
343 typedef struct { | |
344 FLAC__SubframeType type; | |
345 union { | |
346 FLAC__Subframe_Constant constant; | |
347 FLAC__Subframe_Fixed fixed; | |
348 FLAC__Subframe_LPC lpc; | |
349 FLAC__Subframe_Verbatim verbatim; | |
350 } data; | |
351 unsigned wasted_bits; | |
352 } FLAC__Subframe; | |
353 | |
354 /** == 1 (bit) | |
355 * | |
356 * This used to be a zero-padding bit (hence the name | |
357 * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a | |
358 * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1 | |
359 * to mean something else. | |
360 */ | |
361 extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN; | |
362 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */ | |
363 extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */ | |
364 | |
365 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */ | |
366 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */ | |
367 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */ | |
368 extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */ | |
369 | |
370 /*****************************************************************************/ | |
371 | |
372 | |
373 /***************************************************************************** | |
374 * | |
375 * Frame structures | |
376 * | |
377 *****************************************************************************/ | |
378 | |
379 /** An enumeration of the available channel assignments. */ | |
380 typedef enum { | |
381 FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */ | |
382 FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */ | |
383 FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */ | |
384 FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */ | |
385 } FLAC__ChannelAssignment; | |
386 | |
387 /** Maps a FLAC__ChannelAssignment to a C string. | |
388 * | |
389 * Using a FLAC__ChannelAssignment as the index to this array will | |
390 * give the string equivalent. The contents should not be modified. | |
391 */ | |
392 extern FLAC_API const char * const FLAC__ChannelAssignmentString[]; | |
393 | |
394 /** An enumeration of the possible frame numbering methods. */ | |
395 typedef enum { | |
396 FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */ | |
397 FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */ | |
398 } FLAC__FrameNumberType; | |
399 | |
400 /** Maps a FLAC__FrameNumberType to a C string. | |
401 * | |
402 * Using a FLAC__FrameNumberType as the index to this array will | |
403 * give the string equivalent. The contents should not be modified. | |
404 */ | |
405 extern FLAC_API const char * const FLAC__FrameNumberTypeString[]; | |
406 | |
407 | |
408 /** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>) | |
409 */ | |
410 typedef struct { | |
411 unsigned blocksize; | |
412 /**< The number of samples per subframe. */ | |
413 | |
414 unsigned sample_rate; | |
415 /**< The sample rate in Hz. */ | |
416 | |
417 unsigned channels; | |
418 /**< The number of channels (== number of subframes). */ | |
419 | |
420 FLAC__ChannelAssignment channel_assignment; | |
421 /**< The channel assignment for the frame. */ | |
422 | |
423 unsigned bits_per_sample; | |
424 /**< The sample resolution. */ | |
425 | |
426 FLAC__FrameNumberType number_type; | |
427 /**< The numbering scheme used for the frame. As a convenience, the | |
428 * decoder will always convert a frame number to a sample number because | |
429 * the rules are complex. */ | |
430 | |
431 union { | |
432 FLAC__uint32 frame_number; | |
433 FLAC__uint64 sample_number; | |
434 } number; | |
435 /**< The frame number or sample number of first sample in frame; | |
436 * use the \a number_type value to determine which to use. */ | |
437 | |
438 FLAC__uint8 crc; | |
439 /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) | |
440 * of the raw frame header bytes, meaning everything before the CRC byte | |
441 * including the sync code. | |
442 */ | |
443 } FLAC__FrameHeader; | |
444 | |
445 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ | |
446 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */ | |
447 extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */ | |
448 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */ | |
449 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */ | |
450 extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */ | |
451 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */ | |
452 extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */ | |
453 extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */ | |
454 extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */ | |
455 | |
456 | |
457 /** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>) | |
458 */ | |
459 typedef struct { | |
460 FLAC__uint16 crc; | |
461 /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with | |
462 * 0) of the bytes before the crc, back to and including the frame header | |
463 * sync code. | |
464 */ | |
465 } FLAC__FrameFooter; | |
466 | |
467 extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ | |
468 | |
469 | |
470 /** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>) | |
471 */ | |
472 typedef struct { | |
473 FLAC__FrameHeader header; | |
474 FLAC__Subframe subframes[FLAC__MAX_CHANNELS]; | |
475 FLAC__FrameFooter footer; | |
476 } FLAC__Frame; | |
477 | |
478 /*****************************************************************************/ | |
479 | |
480 | |
481 /***************************************************************************** | |
482 * | |
483 * Meta-data structures | |
484 * | |
485 *****************************************************************************/ | |
486 | |
487 /** An enumeration of the available metadata block types. */ | |
488 typedef enum { | |
489 | |
490 FLAC__METADATA_TYPE_STREAMINFO = 0, | |
491 /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */ | |
492 | |
493 FLAC__METADATA_TYPE_PADDING = 1, | |
494 /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */ | |
495 | |
496 FLAC__METADATA_TYPE_APPLICATION = 2, | |
497 /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */ | |
498 | |
499 FLAC__METADATA_TYPE_SEEKTABLE = 3, | |
500 /**< <A HREF="../format.html#metadata_block_seektable">SEEKTABLE</A> block */ | |
501 | |
502 FLAC__METADATA_TYPE_VORBIS_COMMENT = 4, | |
503 /**< <A HREF="../format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block (a.k.a. FLAC tags) */ | |
504 | |
505 FLAC__METADATA_TYPE_CUESHEET = 5, | |
506 /**< <A HREF="../format.html#metadata_block_cuesheet">CUESHEET</A> block */ | |
507 | |
508 FLAC__METADATA_TYPE_PICTURE = 6, | |
509 /**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */ | |
510 | |
511 FLAC__METADATA_TYPE_UNDEFINED = 7 | |
512 /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */ | |
513 | |
514 } FLAC__MetadataType; | |
515 | |
516 /** Maps a FLAC__MetadataType to a C string. | |
517 * | |
518 * Using a FLAC__MetadataType as the index to this array will | |
519 * give the string equivalent. The contents should not be modified. | |
520 */ | |
521 extern FLAC_API const char * const FLAC__MetadataTypeString[]; | |
522 | |
523 | |
524 /** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>) | |
525 */ | |
526 typedef struct { | |
527 unsigned min_blocksize, max_blocksize; | |
528 unsigned min_framesize, max_framesize; | |
529 unsigned sample_rate; | |
530 unsigned channels; | |
531 unsigned bits_per_sample; | |
532 FLAC__uint64 total_samples; | |
533 FLAC__byte md5sum[16]; | |
534 } FLAC__StreamMetadata_StreamInfo; | |
535 | |
536 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */ | |
537 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */ | |
538 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */ | |
539 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */ | |
540 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */ | |
541 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */ | |
542 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */ | |
543 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */ | |
544 extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */ | |
545 | |
546 /** The total stream length of the STREAMINFO block in bytes. */ | |
547 #define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u) | |
548 | |
549 /** FLAC PADDING structure. (c.f. <A HREF="../format.html#metadata_block_padding">format specification</A>) | |
550 */ | |
551 typedef struct { | |
552 int dummy; | |
553 /**< Conceptually this is an empty struct since we don't store the | |
554 * padding bytes. Empty structs are not allowed by some C compilers, | |
555 * hence the dummy. | |
556 */ | |
557 } FLAC__StreamMetadata_Padding; | |
558 | |
559 | |
560 /** FLAC APPLICATION structure. (c.f. <A HREF="../format.html#metadata_block_application">format specification</A>) | |
561 */ | |
562 typedef struct { | |
563 FLAC__byte id[4]; | |
564 FLAC__byte *data; | |
565 } FLAC__StreamMetadata_Application; | |
566 | |
567 extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */ | |
568 | |
569 /** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="../format.html#seekpoint">format specification</A>) | |
570 */ | |
571 typedef struct { | |
572 FLAC__uint64 sample_number; | |
573 /**< The sample number of the target frame. */ | |
574 | |
575 FLAC__uint64 stream_offset; | |
576 /**< The offset, in bytes, of the target frame with respect to | |
577 * beginning of the first frame. */ | |
578 | |
579 unsigned frame_samples; | |
580 /**< The number of samples in the target frame. */ | |
581 } FLAC__StreamMetadata_SeekPoint; | |
582 | |
583 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */ | |
584 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */ | |
585 extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */ | |
586 | |
587 /** The total stream length of a seek point in bytes. */ | |
588 #define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u) | |
589 | |
590 /** The value used in the \a sample_number field of | |
591 * FLAC__StreamMetadataSeekPoint used to indicate a placeholder | |
592 * point (== 0xffffffffffffffff). | |
593 */ | |
594 extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; | |
595 | |
596 | |
597 /** FLAC SEEKTABLE structure. (c.f. <A HREF="../format.html#metadata_block_seektable">format specification</A>) | |
598 * | |
599 * \note From the format specification: | |
600 * - The seek points must be sorted by ascending sample number. | |
601 * - Each seek point's sample number must be the first sample of the | |
602 * target frame. | |
603 * - Each seek point's sample number must be unique within the table. | |
604 * - Existence of a SEEKTABLE block implies a correct setting of | |
605 * total_samples in the stream_info block. | |
606 * - Behavior is undefined when more than one SEEKTABLE block is | |
607 * present in a stream. | |
608 */ | |
609 typedef struct { | |
610 unsigned num_points; | |
611 FLAC__StreamMetadata_SeekPoint *points; | |
612 } FLAC__StreamMetadata_SeekTable; | |
613 | |
614 | |
615 /** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>) | |
616 * | |
617 * For convenience, the APIs maintain a trailing NUL character at the end of | |
618 * \a entry which is not counted toward \a length, i.e. | |
619 * \code strlen(entry) == length \endcode | |
620 */ | |
621 typedef struct { | |
622 FLAC__uint32 length; | |
623 FLAC__byte *entry; | |
624 } FLAC__StreamMetadata_VorbisComment_Entry; | |
625 | |
626 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */ | |
627 | |
628 | |
629 /** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>) | |
630 */ | |
631 typedef struct { | |
632 FLAC__StreamMetadata_VorbisComment_Entry vendor_string; | |
633 FLAC__uint32 num_comments; | |
634 FLAC__StreamMetadata_VorbisComment_Entry *comments; | |
635 } FLAC__StreamMetadata_VorbisComment; | |
636 | |
637 extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */ | |
638 | |
639 | |
640 /** FLAC CUESHEET track index structure. (See the | |
641 * <A HREF="../format.html#cuesheet_track_index">format specification</A> for | |
642 * the full description of each field.) | |
643 */ | |
644 typedef struct { | |
645 FLAC__uint64 offset; | |
646 /**< Offset in samples, relative to the track offset, of the index | |
647 * point. | |
648 */ | |
649 | |
650 FLAC__byte number; | |
651 /**< The index point number. */ | |
652 } FLAC__StreamMetadata_CueSheet_Index; | |
653 | |
654 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */ | |
655 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */ | |
656 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */ | |
657 | |
658 | |
659 /** FLAC CUESHEET track structure. (See the | |
660 * <A HREF="../format.html#cuesheet_track">format specification</A> for | |
661 * the full description of each field.) | |
662 */ | |
663 typedef struct { | |
664 FLAC__uint64 offset; | |
665 /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */ | |
666 | |
667 FLAC__byte number; | |
668 /**< The track number. */ | |
669 | |
670 char isrc[13]; | |
671 /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */ | |
672 | |
673 unsigned type:1; | |
674 /**< The track type: 0 for audio, 1 for non-audio. */ | |
675 | |
676 unsigned pre_emphasis:1; | |
677 /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */ | |
678 | |
679 FLAC__byte num_indices; | |
680 /**< The number of track index points. */ | |
681 | |
682 FLAC__StreamMetadata_CueSheet_Index *indices; | |
683 /**< NULL if num_indices == 0, else pointer to array of index points. */ | |
684 | |
685 } FLAC__StreamMetadata_CueSheet_Track; | |
686 | |
687 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */ | |
688 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */ | |
689 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */ | |
690 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */ | |
691 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */ | |
692 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */ | |
693 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */ | |
694 | |
695 | |
696 /** FLAC CUESHEET structure. (See the | |
697 * <A HREF="../format.html#metadata_block_cuesheet">format specification</A> | |
698 * for the full description of each field.) | |
699 */ | |
700 typedef struct { | |
701 char media_catalog_number[129]; | |
702 /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In | |
703 * general, the media catalog number may be 0 to 128 bytes long; any | |
704 * unused characters should be right-padded with NUL characters. | |
705 */ | |
706 | |
707 FLAC__uint64 lead_in; | |
708 /**< The number of lead-in samples. */ | |
709 | |
710 FLAC__bool is_cd; | |
711 /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */ | |
712 | |
713 unsigned num_tracks; | |
714 /**< The number of tracks. */ | |
715 | |
716 FLAC__StreamMetadata_CueSheet_Track *tracks; | |
717 /**< NULL if num_tracks == 0, else pointer to array of tracks. */ | |
718 | |
719 } FLAC__StreamMetadata_CueSheet; | |
720 | |
721 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */ | |
722 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */ | |
723 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */ | |
724 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */ | |
725 extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */ | |
726 | |
727 | |
728 /** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */ | |
729 typedef enum { | |
730 FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */ | |
731 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */ | |
732 FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */ | |
733 FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */ | |
734 FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */ | |
735 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */ | |
736 FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */ | |
737 FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */ | |
738 FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */ | |
739 FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */ | |
740 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */ | |
741 FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */ | |
742 FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */ | |
743 FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */ | |
744 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */ | |
745 FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */ | |
746 FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */ | |
747 FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */ | |
748 FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */ | |
749 FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */ | |
750 FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */ | |
751 FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED | |
752 } FLAC__StreamMetadata_Picture_Type; | |
753 | |
754 /** Maps a FLAC__StreamMetadata_Picture_Type to a C string. | |
755 * | |
756 * Using a FLAC__StreamMetadata_Picture_Type as the index to this array | |
757 * will give the string equivalent. The contents should not be | |
758 * modified. | |
759 */ | |
760 extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[]; | |
761 | |
762 /** FLAC PICTURE structure. (See the | |
763 * <A HREF="../format.html#metadata_block_picture">format specification</A> | |
764 * for the full description of each field.) | |
765 */ | |
766 typedef struct { | |
767 FLAC__StreamMetadata_Picture_Type type; | |
768 /**< The kind of picture stored. */ | |
769 | |
770 char *mime_type; | |
771 /**< Picture data's MIME type, in ASCII printable characters | |
772 * 0x20-0x7e, NUL terminated. For best compatibility with players, | |
773 * use picture data of MIME type \c image/jpeg or \c image/png. A | |
774 * MIME type of '-->' is also allowed, in which case the picture | |
775 * data should be a complete URL. In file storage, the MIME type is | |
776 * stored as a 32-bit length followed by the ASCII string with no NUL | |
777 * terminator, but is converted to a plain C string in this structure | |
778 * for convenience. | |
779 */ | |
780 | |
781 FLAC__byte *description; | |
782 /**< Picture's description in UTF-8, NUL terminated. In file storage, | |
783 * the description is stored as a 32-bit length followed by the UTF-8 | |
784 * string with no NUL terminator, but is converted to a plain C string | |
785 * in this structure for convenience. | |
786 */ | |
787 | |
788 FLAC__uint32 width; | |
789 /**< Picture's width in pixels. */ | |
790 | |
791 FLAC__uint32 height; | |
792 /**< Picture's height in pixels. */ | |
793 | |
794 FLAC__uint32 depth; | |
795 /**< Picture's color depth in bits-per-pixel. */ | |
796 | |
797 FLAC__uint32 colors; | |
798 /**< For indexed palettes (like GIF), picture's number of colors (the | |
799 * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). | |
800 */ | |
801 | |
802 FLAC__uint32 data_length; | |
803 /**< Length of binary picture data in bytes. */ | |
804 | |
805 FLAC__byte *data; | |
806 /**< Binary picture data. */ | |
807 | |
808 } FLAC__StreamMetadata_Picture; | |
809 | |
810 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */ | |
811 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */ | |
812 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */ | |
813 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */ | |
814 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */ | |
815 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */ | |
816 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */ | |
817 extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */ | |
818 | |
819 | |
820 /** Structure that is used when a metadata block of unknown type is loaded. | |
821 * The contents are opaque. The structure is used only internally to | |
822 * correctly handle unknown metadata. | |
823 */ | |
824 typedef struct { | |
825 FLAC__byte *data; | |
826 } FLAC__StreamMetadata_Unknown; | |
827 | |
828 | |
829 /** FLAC metadata block structure. (c.f. <A HREF="../format.html#metadata_block">format specification</A>) | |
830 */ | |
831 typedef struct { | |
832 FLAC__MetadataType type; | |
833 /**< The type of the metadata block; used determine which member of the | |
834 * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED | |
835 * then \a data.unknown must be used. */ | |
836 | |
837 FLAC__bool is_last; | |
838 /**< \c true if this metadata block is the last, else \a false */ | |
839 | |
840 unsigned length; | |
841 /**< Length, in bytes, of the block data as it appears in the stream. */ | |
842 | |
843 union { | |
844 FLAC__StreamMetadata_StreamInfo stream_info; | |
845 FLAC__StreamMetadata_Padding padding; | |
846 FLAC__StreamMetadata_Application application; | |
847 FLAC__StreamMetadata_SeekTable seek_table; | |
848 FLAC__StreamMetadata_VorbisComment vorbis_comment; | |
849 FLAC__StreamMetadata_CueSheet cue_sheet; | |
850 FLAC__StreamMetadata_Picture picture; | |
851 FLAC__StreamMetadata_Unknown unknown; | |
852 } data; | |
853 /**< Polymorphic block data; use the \a type value to determine which | |
854 * to use. */ | |
855 } FLAC__StreamMetadata; | |
856 | |
857 extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ | |
858 extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */ | |
859 extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */ | |
860 | |
861 /** The total stream length of a metadata block header in bytes. */ | |
862 #define FLAC__STREAM_METADATA_HEADER_LENGTH (4u) | |
863 | |
864 /*****************************************************************************/ | |
865 | |
866 | |
867 /***************************************************************************** | |
868 * | |
869 * Utility functions | |
870 * | |
871 *****************************************************************************/ | |
872 | |
873 /** Tests that a sample rate is valid for FLAC. | |
874 * | |
875 * \param sample_rate The sample rate to test for compliance. | |
876 * \retval FLAC__bool | |
877 * \c true if the given sample rate conforms to the specification, else | |
878 * \c false. | |
879 */ | |
880 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate); | |
881 | |
882 /** Tests that a sample rate is valid for the FLAC subset. The subset rules | |
883 * for valid sample rates are slightly more complex since the rate has to | |
884 * be expressible completely in the frame header. | |
885 * | |
886 * \param sample_rate The sample rate to test for compliance. | |
887 * \retval FLAC__bool | |
888 * \c true if the given sample rate conforms to the specification for the | |
889 * subset, else \c false. | |
890 */ | |
891 FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate); | |
892 | |
893 /** Check a Vorbis comment entry name to see if it conforms to the Vorbis | |
894 * comment specification. | |
895 * | |
896 * Vorbis comment names must be composed only of characters from | |
897 * [0x20-0x3C,0x3E-0x7D]. | |
898 * | |
899 * \param name A NUL-terminated string to be checked. | |
900 * \assert | |
901 * \code name != NULL \endcode | |
902 * \retval FLAC__bool | |
903 * \c false if entry name is illegal, else \c true. | |
904 */ | |
905 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name); | |
906 | |
907 /** Check a Vorbis comment entry value to see if it conforms to the Vorbis | |
908 * comment specification. | |
909 * | |
910 * Vorbis comment values must be valid UTF-8 sequences. | |
911 * | |
912 * \param value A string to be checked. | |
913 * \param length A the length of \a value in bytes. May be | |
914 * \c (unsigned)(-1) to indicate that \a value is a plain | |
915 * UTF-8 NUL-terminated string. | |
916 * \assert | |
917 * \code value != NULL \endcode | |
918 * \retval FLAC__bool | |
919 * \c false if entry name is illegal, else \c true. | |
920 */ | |
921 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length); | |
922 | |
923 /** Check a Vorbis comment entry to see if it conforms to the Vorbis | |
924 * comment specification. | |
925 * | |
926 * Vorbis comment entries must be of the form 'name=value', and 'name' and | |
927 * 'value' must be legal according to | |
928 * FLAC__format_vorbiscomment_entry_name_is_legal() and | |
929 * FLAC__format_vorbiscomment_entry_value_is_legal() respectively. | |
930 * | |
931 * \param entry An entry to be checked. | |
932 * \param length The length of \a entry in bytes. | |
933 * \assert | |
934 * \code value != NULL \endcode | |
935 * \retval FLAC__bool | |
936 * \c false if entry name is illegal, else \c true. | |
937 */ | |
938 FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length); | |
939 | |
940 /** Check a seek table to see if it conforms to the FLAC specification. | |
941 * See the format specification for limits on the contents of the | |
942 * seek table. | |
943 * | |
944 * \param seek_table A pointer to a seek table to be checked. | |
945 * \assert | |
946 * \code seek_table != NULL \endcode | |
947 * \retval FLAC__bool | |
948 * \c false if seek table is illegal, else \c true. | |
949 */ | |
950 FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table); | |
951 | |
952 /** Sort a seek table's seek points according to the format specification. | |
953 * This includes a "unique-ification" step to remove duplicates, i.e. | |
954 * seek points with identical \a sample_number values. Duplicate seek | |
955 * points are converted into placeholder points and sorted to the end of | |
956 * the table. | |
957 * | |
958 * \param seek_table A pointer to a seek table to be sorted. | |
959 * \assert | |
960 * \code seek_table != NULL \endcode | |
961 * \retval unsigned | |
962 * The number of duplicate seek points converted into placeholders. | |
963 */ | |
964 FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table); | |
965 | |
966 /** Check a cue sheet to see if it conforms to the FLAC specification. | |
967 * See the format specification for limits on the contents of the | |
968 * cue sheet. | |
969 * | |
970 * \param cue_sheet A pointer to an existing cue sheet to be checked. | |
971 * \param check_cd_da_subset If \c true, check CUESHEET against more | |
972 * stringent requirements for a CD-DA (audio) disc. | |
973 * \param violation Address of a pointer to a string. If there is a | |
974 * violation, a pointer to a string explanation of the | |
975 * violation will be returned here. \a violation may be | |
976 * \c NULL if you don't need the returned string. Do not | |
977 * free the returned string; it will always point to static | |
978 * data. | |
979 * \assert | |
980 * \code cue_sheet != NULL \endcode | |
981 * \retval FLAC__bool | |
982 * \c false if cue sheet is illegal, else \c true. | |
983 */ | |
984 FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation); | |
985 | |
986 /** Check picture data to see if it conforms to the FLAC specification. | |
987 * See the format specification for limits on the contents of the | |
988 * PICTURE block. | |
989 * | |
990 * \param picture A pointer to existing picture data to be checked. | |
991 * \param violation Address of a pointer to a string. If there is a | |
992 * violation, a pointer to a string explanation of the | |
993 * violation will be returned here. \a violation may be | |
994 * \c NULL if you don't need the returned string. Do not | |
995 * free the returned string; it will always point to static | |
996 * data. | |
997 * \assert | |
998 * \code picture != NULL \endcode | |
999 * \retval FLAC__bool | |
1000 * \c false if picture data is illegal, else \c true. | |
1001 */ | |
1002 FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation); | |
1003 | |
1004 /* \} */ | |
1005 | |
1006 #ifdef __cplusplus | |
1007 } | |
1008 #endif | |
1009 | |
1010 #endif |