Revision 20c68378 libavformat/id3v2.c

View differences:

libavformat/id3v2.c
81 81
    char *q, dst[512];
82 82
    int len, dstlen = sizeof(dst) - 1;
83 83
    unsigned genre;
84
    unsigned int (*get)(ByteIOContext*) = get_be16;
84 85

  
85 86
    dst[0] = 0;
86 87
    if (taglen < 1)
......
99 100
        *q = 0;
100 101
        break;
101 102

  
103
    case 1:  /* UTF-16 with BOM */
104
        taglen -= 2;
105
        switch (get_be16(s->pb)) {
106
        case 0xfffe:
107
            get = get_le16;
108
        case 0xfeff:
109
            break;
110
        default:
111
            av_log(s, AV_LOG_ERROR, "Incorrect BOM value in tag %s.\n", key);
112
            return;
113
        }
114
        // fall-through
115

  
116
    case 2:  /* UTF-16BE without BOM */
117
        q = dst;
118
        while (taglen > 1 && q - dst < dstlen - 7) {
119
            uint32_t ch;
120
            uint8_t tmp;
121

  
122
            GET_UTF16(ch, ((taglen -= 2) >= 0 ? get(s->pb) : 0), break;)
123
            PUT_UTF8(ch, tmp, *q++ = tmp;)
124
        }
125
        *q = 0;
126
        break;
127

  
102 128
    case 3:  /* UTF-8 */
103 129
        len = FFMIN(taglen, dstlen - 1);
104 130
        get_buffer(s->pb, dst, len);
105 131
        dst[len] = 0;
106 132
        break;
133
    default:
134
        av_log(s, AV_LOG_WARNING, "Unknown encoding in tag %s\n.", key);
107 135
    }
108 136

  
109 137
    if (!strcmp(key, "genre")

Also available in: Unified diff