static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)

{

    char *value;

    int64_t off = avio_tell(s->pb);



    if ((unsigned)len >= (UINT_MAX - 1) / 2)

        return;



    value = av_malloc(2 * len + 1);

    if (!value)

        goto finish;



    if (type == 0) {         // UTF16-LE

        avio_get_str16le(s->pb, len, value, 2 * len + 1);

    } else if (type == -1) { // ASCII

        avio_read(s->pb, value, len);

        value[len]=0;

    } else if (type == 1) {  // byte array

        if (!strcmp(key, "WM/Picture")) { // handle cover art

            asf_read_picture(s, len);

        } else if (!strcmp(key, "ID3")) { // handle ID3 tag

            get_id3_tag(s, len);

        } else {

            av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);

        }

        goto finish;

    } else if (type > 1 && type <= 5) {  // boolean or DWORD or QWORD or WORD

        uint64_t num = get_value(s->pb, type, type2_size);

        snprintf(value, len, "%"PRIu64, num);

    } else if (type == 6) { // (don't) handle GUID

        av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);

        goto finish;

    } else {

        av_log(s, AV_LOG_DEBUG,

               "Unsupported value type %d in tag %s.\n", type, key);

        goto finish;

    }

    if (*value)

        av_dict_set(&s->metadata, key, value, 0);



finish:

    av_freep(&value);

    avio_seek(s->pb, off + len, SEEK_SET);

}

static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)

{

    char *value;

    int64_t off = avio_tell(s->pb);



    if ((unsigned)len >= (UINT_MAX - 1) / 2)

        return;



    value = av_malloc(2 * len + 1);

    if (!value)

        goto finish;



    if (type == 0) {         

        avio_get_str16le(s->pb, len, value, 2 * len + 1);

    } else if (type == -1) { 

        avio_read(s->pb, value, len);

        value[len]=0;

    } else if (type == 1) {  

        if (!strcmp(key, "WM/Picture")) { 

            asf_read_picture(s, len);

        } else if (!strcmp(key, "ID3")) { 

            get_id3_tag(s, len);

        } else {

            av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);

        }

        goto finish;

    } else if (type > 1 && type <= 5) {  

        uint64_t num = get_value(s->pb, type, type2_size);

        snprintf(value, len, "%"PRIu64, num);

    } else if (type == 6) { 

        av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);

        goto finish;

    } else {

        av_log(s, AV_LOG_DEBUG,

               "Unsupported value type %d in tag %s.\n", type, key);

        goto finish;

    }

    if (*value)

        av_dict_set(&s->metadata, key, value, 0);



finish:

    av_freep(&value);

    avio_seek(s->pb, off + len, SEEK_SET);

}

    if ((unsigned)len >= (UINT_MAX - 1) / 2)     value = av_malloc(2 * len + 1);         snprintf(value, len, "%"PRIu64, num);
static void FUNC_0(AVFormatContext *VAR_0, const char *VAR_1, int VAR_2, int VAR_3, int VAR_4)

{

    char *VAR_5;

    int64_t off = avio_tell(VAR_0->pb);



    if ((unsigned)VAR_3 >= (UINT_MAX - 1) / 2)

        return;



    VAR_5 = av_malloc(2 * VAR_3 + 1);

    if (!VAR_5)

        goto finish;



    if (VAR_2 == 0) {         

        avio_get_str16le(VAR_0->pb, VAR_3, VAR_5, 2 * VAR_3 + 1);

    } else if (VAR_2 == -1) { 

        avio_read(VAR_0->pb, VAR_5, VAR_3);

        VAR_5[VAR_3]=0;

    } else if (VAR_2 == 1) {  

        if (!strcmp(VAR_1, "WM/Picture")) { 

            asf_read_picture(VAR_0, VAR_3);

        } else if (!strcmp(VAR_1, "ID3")) { 

            get_id3_tag(VAR_0, VAR_3);

        } else {

            av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported byte array in tag %VAR_0.\n", VAR_1);

        }

        goto finish;

    } else if (VAR_2 > 1 && VAR_2 <= 5) {  

        uint64_t num = get_value(VAR_0->pb, VAR_2, VAR_4);

        snprintf(VAR_5, VAR_3, "%"PRIu64, num);

    } else if (VAR_2 == 6) { 

        av_log(VAR_0, AV_LOG_DEBUG, "Unsupported GUID VAR_5 in tag %VAR_0.\n", VAR_1);

        goto finish;

    } else {

        av_log(VAR_0, AV_LOG_DEBUG,

               "Unsupported VAR_5 VAR_2 %d in tag %VAR_0.\n", VAR_2, VAR_1);

        goto finish;

    }

    if (*VAR_5)

        av_dict_set(&VAR_0->metadata, VAR_1, VAR_5, 0);



finish:

    av_freep(&VAR_5);

    avio_seek(VAR_0->pb, off + VAR_3, SEEK_SET);

}

static void FUNC_0(AVFormatContext *VAR_0, const char *VAR_1, int VAR_2, int VAR_3, int VAR_4)
{ char *VAR_5; int64_t off = avio_tell(VAR_0->pb); if ((unsigned)VAR_3 >= (UINT_MAX - 1) / 2)
return; VAR_5 = av_malloc(2 * VAR_3 + 1); if (!VAR_5)
goto finish; if (VAR_2 == 0) { avio_get_str16le(VAR_0->pb, VAR_3, VAR_5, 2 * VAR_3 + 1); } else if (VAR_2 == -1) { avio_read(VAR_0->pb, VAR_5, VAR_3); VAR_5[VAR_3]=0; } else if (VAR_2 == 1) { if (!strcmp(VAR_1, "WM/Picture")) { asf_read_picture(VAR_0, VAR_3); } else if (!strcmp(VAR_1, "ID3")) { get_id3_tag(VAR_0, VAR_3); } else { av_log(VAR_0, AV_LOG_VERBOSE, "Unsupported byte array in tag %VAR_0.\n", VAR_1); } goto finish; } else if (VAR_2 > 1 && VAR_2 <= 5) { uint64_t num = get_value(VAR_0->pb, VAR_2, VAR_4); snprintf(VAR_5, VAR_3, "%"PRIu64, num); } else if (VAR_2 == 6) { av_log(VAR_0, AV_LOG_DEBUG, "Unsupported GUID VAR_5 in tag %VAR_0.\n", VAR_1); goto finish; } else { av_log(VAR_0, AV_LOG_DEBUG,
"Unsupported VAR_5 VAR_2 %d in tag %VAR_0.\n", VAR_2, VAR_1); goto finish; } if (*VAR_5)
av_dict_set(&VAR_0->metadata, VAR_1, VAR_5, 0); finish:
av_freep(&VAR_5); avio_seek(VAR_0->pb, off + VAR_3, SEEK_SET); }