]> git.sesse.net Git - ffmpeg/commitdiff
id3v2: use an enum for encodings instead of magic numbers.
authorAnton Khirnov <anton@khirnov.net>
Wed, 19 Jan 2011 09:13:25 +0000 (10:13 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 21 Jan 2011 19:36:01 +0000 (20:36 +0100)
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit d66eff36852975129ae499c56de4340e48b9b7b4)

libavformat/id3v2.c
libavformat/id3v2.h

index 95ec0b05cb0c0a6b0b4109f05dfb1e824c0b07d0..62eee15591d7962c2fc258f79d81606a37602149 100644 (file)
@@ -74,7 +74,7 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
 
     switch (get_byte(pb)) { /* encoding type */
 
-    case 0:  /* ISO-8859-1 (0 - 255 maps directly into unicode) */
+    case ID3v2_ENCODING_ISO8859:
         q = dst;
         while (taglen-- && q - dst < dstlen - 7) {
             uint8_t tmp;
@@ -83,7 +83,7 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
         *q = 0;
         break;
 
-    case 1:  /* UTF-16 with BOM */
+    case ID3v2_ENCODING_UTF16BOM:
         taglen -= 2;
         switch (get_be16(pb)) {
         case 0xfffe:
@@ -96,7 +96,7 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
         }
         // fall-through
 
-    case 2:  /* UTF-16BE without BOM */
+    case ID3v2_ENCODING_UTF16BE:
         q = dst;
         while (taglen > 1 && q - dst < dstlen - 7) {
             uint32_t ch;
@@ -108,7 +108,7 @@ static void read_ttag(AVFormatContext *s, ByteIOContext *pb, int taglen, const c
         *q = 0;
         break;
 
-    case 3:  /* UTF-8 */
+    case ID3v2_ENCODING_UTF8:
         len = FFMIN(taglen, dstlen);
         get_buffer(pb, dst, len);
         dst[len] = 0;
index 25ee53e9b87596cf7ef0161487219f3eba296c1b..c2e1add8495bfc1e617e80911a623868967de746 100644 (file)
 #define ID3v2_FLAG_ENCRYPTION  0x0004
 #define ID3v2_FLAG_COMPRESSION 0x0008
 
+enum ID3v2Encoding {
+    ID3v2_ENCODING_ISO8859  = 0,
+    ID3v2_ENCODING_UTF16BOM = 1,
+    ID3v2_ENCODING_UTF16BE  = 2,
+    ID3v2_ENCODING_UTF8     = 3,
+};
+
 /**
  * Detect ID3v2 Header.
  * @param buf   must be ID3v2_HEADER_SIZE byte long