format.h 40 KB

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