static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length)

{

    int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;

    char *buf = av_malloc(buf_size);

    if (!buf)

        return;



    if (type == 0 && length == 4) {

        snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));

    } else if (type == 1) {

        avio_get_str16le(pb, length, buf, buf_size);

        if (!strlen(buf)) {

           av_free(buf);

           return;

        }

    } else if (type == 3 && length == 4) {

        strcpy(buf, avio_rl32(pb) ? "true" : "false");

    } else if (type == 4 && length == 8) {

        int64_t num = avio_rl64(pb);

        if (!strcmp(key, "WM/EncodingTime") ||

            !strcmp(key, "WM/MediaOriginalBroadcastDateTime"))

            filetime_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVEncodeTime") ||

                 !strcmp(key, "WM/WMRVEndTime"))

            crazytime_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVExpirationDate"))

            oledate_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVBitrate"))

            snprintf(buf, buf_size, "%f", av_int2dbl(num));

        else

            snprintf(buf, buf_size, "%"PRIi64, num);

    } else if (type == 5 && length == 2) {

        snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));

    } else if (type == 6 && length == 16) {

        ff_asf_guid guid;

        avio_read(pb, guid, 16);

        snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));

    } else if (type == 2 && !strcmp(key, "WM/Picture")) {

        get_attachment(s, pb, length);

        av_freep(&buf);

        return;

    } else {

        av_freep(&buf);

        av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length);

        avio_skip(pb, length);

        return;

    }



    av_metadata_set2(&s->metadata, key, buf, 0);

    av_freep(&buf);

}

static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int type, int length)

{

    int buf_size = FFMAX(2*length, LEN_PRETTY_GUID) + 1;

    char *buf = av_malloc(buf_size);

    if (!buf)

        return;



    if (type == 0 && length == 4) {

        snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));

    } else if (type == 1) {

        avio_get_str16le(pb, length, buf, buf_size);

        if (!strlen(buf)) {

           av_free(buf);

           return;

        }

    } else if (type == 3 && length == 4) {

        strcpy(buf, avio_rl32(pb) ? "true" : "false");

    } else if (type == 4 && length == 8) {

        int64_t num = avio_rl64(pb);

        if (!strcmp(key, "WM/EncodingTime") ||

            !strcmp(key, "WM/MediaOriginalBroadcastDateTime"))

            filetime_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVEncodeTime") ||

                 !strcmp(key, "WM/WMRVEndTime"))

            crazytime_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVExpirationDate"))

            oledate_to_iso8601(buf, buf_size, num);

        else if (!strcmp(key, "WM/WMRVBitrate"))

            snprintf(buf, buf_size, "%f", av_int2dbl(num));

        else

            snprintf(buf, buf_size, "%"PRIi64, num);

    } else if (type == 5 && length == 2) {

        snprintf(buf, buf_size, "%"PRIi16, avio_rl16(pb));

    } else if (type == 6 && length == 16) {

        ff_asf_guid guid;

        avio_read(pb, guid, 16);

        snprintf(buf, buf_size, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));

    } else if (type == 2 && !strcmp(key, "WM/Picture")) {

        get_attachment(s, pb, length);

        av_freep(&buf);

        return;

    } else {

        av_freep(&buf);

        av_log(s, AV_LOG_WARNING, "unsupported metadata entry; key:%s, type:%d, length:0x%x\n", key, type, length);

        avio_skip(pb, length);

        return;

    }



    av_metadata_set2(&s->metadata, key, buf, 0);

    av_freep(&buf);

}

        else if (!strcmp(key, "WM/WMRVExpirationDate"))             oledate_to_iso8601(buf, buf_size, num);         else if (!strcmp(key, "WM/WMRVBitrate"))
static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, const char *VAR_2, int VAR_3, int VAR_4)

{

    int VAR_5 = FFMAX(2*VAR_4, LEN_PRETTY_GUID) + 1;

    char *VAR_6 = av_malloc(VAR_5);

    if (!VAR_6)

        return;



    if (VAR_3 == 0 && VAR_4 == 4) {

        snprintf(VAR_6, VAR_5, "%"PRIi32, avio_rl32(VAR_1));

    } else if (VAR_3 == 1) {

        avio_get_str16le(VAR_1, VAR_4, VAR_6, VAR_5);

        if (!strlen(VAR_6)) {

           av_free(VAR_6);

           return;

        }

    } else if (VAR_3 == 3 && VAR_4 == 4) {

        strcpy(VAR_6, avio_rl32(VAR_1) ? "true" : "false");

    } else if (VAR_3 == 4 && VAR_4 == 8) {

        int64_t num = avio_rl64(VAR_1);

        if (!strcmp(VAR_2, "WM/EncodingTime") ||

            !strcmp(VAR_2, "WM/MediaOriginalBroadcastDateTime"))

            filetime_to_iso8601(VAR_6, VAR_5, num);

        else if (!strcmp(VAR_2, "WM/WMRVEncodeTime") ||

                 !strcmp(VAR_2, "WM/WMRVEndTime"))

            crazytime_to_iso8601(VAR_6, VAR_5, num);

        else if (!strcmp(VAR_2, "WM/WMRVExpirationDate"))

            oledate_to_iso8601(VAR_6, VAR_5, num);

        else if (!strcmp(VAR_2, "WM/WMRVBitrate"))

            snprintf(VAR_6, VAR_5, "%f", av_int2dbl(num));

        else

            snprintf(VAR_6, VAR_5, "%"PRIi64, num);

    } else if (VAR_3 == 5 && VAR_4 == 2) {

        snprintf(VAR_6, VAR_5, "%"PRIi16, avio_rl16(VAR_1));

    } else if (VAR_3 == 6 && VAR_4 == 16) {

        ff_asf_guid guid;

        avio_read(VAR_1, guid, 16);

        snprintf(VAR_6, VAR_5, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid));

    } else if (VAR_3 == 2 && !strcmp(VAR_2, "WM/Picture")) {

        get_attachment(VAR_0, VAR_1, VAR_4);

        av_freep(&VAR_6);

        return;

    } else {

        av_freep(&VAR_6);

        av_log(VAR_0, AV_LOG_WARNING, "unsupported metadata entry; VAR_2:%VAR_0, VAR_3:%d, VAR_4:0x%x\n", VAR_2, VAR_3, VAR_4);

        avio_skip(VAR_1, VAR_4);

        return;

    }



    av_metadata_set2(&VAR_0->metadata, VAR_2, VAR_6, 0);

    av_freep(&VAR_6);

}

static void FUNC_0(AVFormatContext *VAR_0, AVIOContext *VAR_1, const char *VAR_2, int VAR_3, int VAR_4)
{ int VAR_5 = FFMAX(2*VAR_4, LEN_PRETTY_GUID) + 1; char *VAR_6 = av_malloc(VAR_5); if (!VAR_6)
return; if (VAR_3 == 0 && VAR_4 == 4) { snprintf(VAR_6, VAR_5, "%"PRIi32, avio_rl32(VAR_1)); } else if (VAR_3 == 1) { avio_get_str16le(VAR_1, VAR_4, VAR_6, VAR_5); if (!strlen(VAR_6)) { av_free(VAR_6); return; } } else if (VAR_3 == 3 && VAR_4 == 4) { strcpy(VAR_6, avio_rl32(VAR_1) ? "true" : "false"); } else if (VAR_3 == 4 && VAR_4 == 8) { int64_t num = avio_rl64(VAR_1); if (!strcmp(VAR_2, "WM/EncodingTime") ||
!strcmp(VAR_2, "WM/MediaOriginalBroadcastDateTime"))
filetime_to_iso8601(VAR_6, VAR_5, num); else if (!strcmp(VAR_2, "WM/WMRVEncodeTime") ||
!strcmp(VAR_2, "WM/WMRVEndTime"))
crazytime_to_iso8601(VAR_6, VAR_5, num); else if (!strcmp(VAR_2, "WM/WMRVExpirationDate"))
oledate_to_iso8601(VAR_6, VAR_5, num); else if (!strcmp(VAR_2, "WM/WMRVBitrate"))
snprintf(VAR_6, VAR_5, "%f", av_int2dbl(num)); else
snprintf(VAR_6, VAR_5, "%"PRIi64, num); } else if (VAR_3 == 5 && VAR_4 == 2) { snprintf(VAR_6, VAR_5, "%"PRIi16, avio_rl16(VAR_1)); } else if (VAR_3 == 6 && VAR_4 == 16) { ff_asf_guid guid; avio_read(VAR_1, guid, 16); snprintf(VAR_6, VAR_5, PRI_PRETTY_GUID, ARG_PRETTY_GUID(guid)); } else if (VAR_3 == 2 && !strcmp(VAR_2, "WM/Picture")) { get_attachment(VAR_0, VAR_1, VAR_4); av_freep(&VAR_6); return; } else { av_freep(&VAR_6); av_log(VAR_0, AV_LOG_WARNING, "unsupported metadata entry; VAR_2:%VAR_0, VAR_3:%d, VAR_4:0x%x\n", VAR_2, VAR_3, VAR_4); avio_skip(VAR_1, VAR_4); return; } av_metadata_set2(&VAR_0->metadata, VAR_2, VAR_6, 0); av_freep(&VAR_6); }