quick fix for SF#1601812 where an error of exactly 0 (very rare) in FLAC__lpc_compute...
[platform/upstream/flac.git] / src / libFLAC / format.c
index 8052b0f..af384ea 100644 (file)
@@ -1,5 +1,5 @@
 /* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005  Josh Coalson
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2006  Josh Coalson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h> /* for qsort() */
 #include "FLAC/assert.h"
 #include "FLAC/format.h"
 #include "private/format.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #ifdef min
 #undef min
 #endif
 /* VERSION should come from configure */
 FLAC_API const char *FLAC__VERSION_STRING = VERSION;
 
-#if defined _MSC_VER || defined __MINW32__
+#if defined _MSC_VER || defined __BORLANDC__ || defined __MINW32__
 /* yet one more hack because of MSVC6: */
-FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.1.2 20050205";
+FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.1.3 20061120";
 #else
-FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20050205";
+FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20061120";
 #endif
 
 FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
@@ -104,6 +104,15 @@ FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
 FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
 FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
 
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
+FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
+
 FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
 FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
 FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
@@ -168,7 +177,32 @@ FLAC_API const char * const FLAC__MetadataTypeString[] = {
        "APPLICATION",
        "SEEKTABLE",
        "VORBIS_COMMENT",
-       "CUESHEET"
+       "CUESHEET",
+       "PICTURE"
+};
+
+FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
+       "Other",
+       "32x32 pixels 'file icon' (PNG only)",
+       "Other file icon",
+       "Cover (front)",
+       "Cover (back)",
+       "Leaflet page",
+       "Media (e.g. label side of CD)",
+       "Lead artist/lead performer/soloist",
+       "Artist/performer",
+       "Conductor",
+       "Band/Orchestra",
+       "Composer",
+       "Lyricist/text writer",
+       "Recording Location",
+       "During recording",
+       "During performance",
+       "Movie/video screen capture",
+       "A bright coloured fish",
+       "Illustration",
+       "Band/artist logotype",
+       "Publisher/Studio logotype"
 };
 
 FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
@@ -437,6 +471,30 @@ FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_Cu
        return true;
 }
 
+FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
+{
+       char *p;
+       FLAC__byte *b;
+
+       for(p = picture->mime_type; *p; p++) {
+               if(*p < 0x20 || *p > 0x7e) {
+                       if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)";
+                       return false;
+               }
+       }
+
+       for(b = picture->description; *b; ) {
+               unsigned n = utf8len_(b);
+               if(n == 0) {
+                       if(violation) *violation = "description string must be valid UTF-8";
+                       return false;
+               }
+               b += n;
+       }
+
+       return true;
+}
+
 /*
  * These routines are private to libFLAC
  */