1
1
/* libFLAC - Free Lossless Audio Codec library
2
* Copyright (C) 2000,2001,2002,2003,2004,2005 Josh Coalson
2
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
4
4
* Redistribution and use in source and binary forms, with or without
5
5
* modification, are permitted provided that the following conditions
54
54
/* VERSION should come from configure */
55
55
FLAC_API const char *FLAC__VERSION_STRING = VERSION;
57
#if defined _MSC_VER || defined __MINW32__
57
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINW32__
58
58
/* yet one more hack because of MSVC6: */
59
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.1.2 20050205";
59
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.1.4 20070213";
61
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20050205";
61
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20070213";
64
64
FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
65
65
FLAC_API const unsigned FLAC__STREAM_SYNC = 0x664C6143;
66
FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */;
66
FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */
68
68
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
69
69
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
104
104
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
105
105
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
107
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
108
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
109
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
110
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
111
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
112
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
113
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
114
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
107
116
FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
108
117
FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
109
118
FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
170
179
"VORBIS_COMMENT",
184
FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
186
"32x32 pixels 'file icon' (PNG only)",
191
"Media (e.g. label side of CD)",
192
"Lead artist/lead performer/soloist",
197
"Lyricist/text writer",
198
"Recording Location",
200
"During performance",
201
"Movie/video screen capture",
202
"A bright coloured fish",
204
"Band/artist logotype",
205
"Publisher/Studio logotype"
174
208
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
292
* also disallows non-shortest-form encodings, c.f.
293
* http://www.unicode.org/versions/corrigendum1.html
294
* and a more clear explanation at the end of this section:
295
* http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
257
297
static __inline unsigned utf8len_(const FLAC__byte *utf8)
259
299
FLAC__ASSERT(0 != utf8);
260
if ((utf8[0] & 0x80) == 0)
300
if ((utf8[0] & 0x80) == 0) {
262
else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80)
303
else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) {
304
if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */
264
else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80)
308
else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) {
309
if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */
311
/* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */
312
if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */
314
if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */
318
else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) {
319
if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */
323
else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) {
324
if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */
328
else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) {
329
if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */
270
338
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name)
366
434
if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) {
367
if(violation) *violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples";
436
if(i == cue_sheet->num_tracks-1) /* the lead-out track... */
437
*violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples";
439
*violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples";
474
FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
479
for(p = picture->mime_type; *p; p++) {
480
if(*p < 0x20 || *p > 0x7e) {
481
if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)";
486
for(b = picture->description; *b; ) {
487
unsigned n = utf8len_(b);
489
if(violation) *violation = "description string must be valid UTF-8";
402
499
* These routines are private to libFLAC