flac_FLAC_format.h 39 KB

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