vorbis_comment(AVFormatContext * as, uint8_t *buf, int size)

{

    const uint8_t *p = buf;

    const uint8_t *end = buf + size;

    unsigned s, n, j;



    if (size < 8) /* must have vendor_length and user_comment_list_length */

        return -1;



    s = bytestream_get_le32(&p);



    if (end - p < s)

        return -1;



    p += s;



    n = bytestream_get_le32(&p);



    while (p < end && n > 0) {

        const char *t, *v;

        int tl, vl;



        s = bytestream_get_le32(&p);



        if (end - p < s)

            break;



        t = p;

        p += s;

        n--;



        v = memchr(t, '=', s);

        if (!v)

            continue;



        tl = v - t;

        vl = s - tl - 1;

        v++;



        if (tl && vl) {

            char *tt, *ct;



            tt = av_malloc(tl + 1);

            ct = av_malloc(vl + 1);

            if (!tt || !ct) {

                av_freep(&tt);

                av_freep(&ct);

                av_log(as, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\n");

                continue;

            }



            for (j = 0; j < tl; j++)

                tt[j] = toupper(t[j]);

            tt[tl] = 0;



            memcpy(ct, v, vl);

            ct[vl] = 0;



            av_metadata_set(&as->metadata, tt, ct);



            av_freep(&tt);

            av_freep(&ct);

        }

    }



    if (p != end)

        av_log(as, AV_LOG_INFO, "%ti bytes of comment header remain\n", end-p);

    if (n > 0)

        av_log(as, AV_LOG_INFO,

               "truncated comment header, %i comments not found\n", n);



    return 0;

}

vorbis_comment(AVFormatContext * as, uint8_t *buf, int size)

{

    const uint8_t *p = buf;

    const uint8_t *end = buf + size;

    unsigned s, n, j;



    if (size < 8) 

        return -1;



    s = bytestream_get_le32(&p);



    if (end - p < s)

        return -1;



    p += s;



    n = bytestream_get_le32(&p);



    while (p < end && n > 0) {

        const char *t, *v;

        int tl, vl;



        s = bytestream_get_le32(&p);



        if (end - p < s)

            break;



        t = p;

        p += s;

        n--;



        v = memchr(t, '=', s);

        if (!v)

            continue;



        tl = v - t;

        vl = s - tl - 1;

        v++;



        if (tl && vl) {

            char *tt, *ct;



            tt = av_malloc(tl + 1);

            ct = av_malloc(vl + 1);

            if (!tt || !ct) {

                av_freep(&tt);

                av_freep(&ct);

                av_log(as, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\n");

                continue;

            }



            for (j = 0; j < tl; j++)

                tt[j] = toupper(t[j]);

            tt[tl] = 0;



            memcpy(ct, v, vl);

            ct[vl] = 0;



            av_metadata_set(&as->metadata, tt, ct);



            av_freep(&tt);

            av_freep(&ct);

        }

    }



    if (p != end)

        av_log(as, AV_LOG_INFO, "%ti bytes of comment header remain\n", end-p);

    if (n > 0)

        av_log(as, AV_LOG_INFO,

               "truncated comment header, %i comments not found\n", n);



    return 0;

}

    unsigned s, n, j;     if (end - p < s)     while (p < end && n > 0) {         if (end - p < s)
FUNC_0(AVFormatContext * VAR_0, uint8_t *VAR_1, int VAR_2)

{

    const uint8_t *VAR_3 = VAR_1;

    const uint8_t *VAR_4 = VAR_1 + VAR_2;

    unsigned VAR_5, VAR_6, VAR_7;



    if (VAR_2 < 8) 

        return -1;



    VAR_5 = bytestream_get_le32(&VAR_3);



    if (VAR_4 - VAR_3 < VAR_5)

        return -1;



    VAR_3 += VAR_5;



    VAR_6 = bytestream_get_le32(&VAR_3);



    while (VAR_3 < VAR_4 && VAR_6 > 0) {

        const char *VAR_8, *VAR_9;

        int VAR_10, VAR_11;



        VAR_5 = bytestream_get_le32(&VAR_3);



        if (VAR_4 - VAR_3 < VAR_5)

            break;



        VAR_8 = VAR_3;

        VAR_3 += VAR_5;

        VAR_6--;



        VAR_9 = memchr(VAR_8, '=', VAR_5);

        if (!VAR_9)

            continue;



        VAR_10 = VAR_9 - VAR_8;

        VAR_11 = VAR_5 - VAR_10 - 1;

        VAR_9++;



        if (VAR_10 && VAR_11) {

            char *VAR_12, *VAR_13;



            VAR_12 = av_malloc(VAR_10 + 1);

            VAR_13 = av_malloc(VAR_11 + 1);

            if (!VAR_12 || !VAR_13) {

                av_freep(&VAR_12);

                av_freep(&VAR_13);

                av_log(VAR_0, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\VAR_6");

                continue;

            }



            for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++)

                VAR_12[VAR_7] = toupper(VAR_8[VAR_7]);

            VAR_12[VAR_10] = 0;



            memcpy(VAR_13, VAR_9, VAR_11);

            VAR_13[VAR_11] = 0;



            av_metadata_set(&VAR_0->metadata, VAR_12, VAR_13);



            av_freep(&VAR_12);

            av_freep(&VAR_13);

        }

    }



    if (VAR_3 != VAR_4)

        av_log(VAR_0, AV_LOG_INFO, "%ti bytes of comment header remain\VAR_6", VAR_4-VAR_3);

    if (VAR_6 > 0)

        av_log(VAR_0, AV_LOG_INFO,

               "truncated comment header, %i comments not found\VAR_6", VAR_6);



    return 0;

}

FUNC_0(AVFormatContext * VAR_0, uint8_t *VAR_1, int VAR_2)
{ const uint8_t *VAR_3 = VAR_1; const uint8_t *VAR_4 = VAR_1 + VAR_2; unsigned VAR_5, VAR_6, VAR_7; if (VAR_2 < 8)
return -1; VAR_5 = bytestream_get_le32(&VAR_3); if (VAR_4 - VAR_3 < VAR_5)
return -1; VAR_3 += VAR_5; VAR_6 = bytestream_get_le32(&VAR_3); while (VAR_3 < VAR_4 && VAR_6 > 0) { const char *VAR_8, *VAR_9; int VAR_10, VAR_11; VAR_5 = bytestream_get_le32(&VAR_3); if (VAR_4 - VAR_3 < VAR_5)
break; VAR_8 = VAR_3; VAR_3 += VAR_5; VAR_6--; VAR_9 = memchr(VAR_8, '=', VAR_5); if (!VAR_9)
continue; VAR_10 = VAR_9 - VAR_8; VAR_11 = VAR_5 - VAR_10 - 1; VAR_9++; if (VAR_10 && VAR_11) { char *VAR_12, *VAR_13; VAR_12 = av_malloc(VAR_10 + 1); VAR_13 = av_malloc(VAR_11 + 1); if (!VAR_12 || !VAR_13) { av_freep(&VAR_12); av_freep(&VAR_13); av_log(VAR_0, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\VAR_6"); continue; } for (VAR_7 = 0; VAR_7 < VAR_10; VAR_7++) VAR_12[VAR_7] = toupper(VAR_8[VAR_7]); VAR_12[VAR_10] = 0; memcpy(VAR_13, VAR_9, VAR_11); VAR_13[VAR_11] = 0; av_metadata_set(&VAR_0->metadata, VAR_12, VAR_13); av_freep(&VAR_12); av_freep(&VAR_13); } } if (VAR_3 != VAR_4)
av_log(VAR_0, AV_LOG_INFO, "%ti bytes of comment header remain\VAR_6", VAR_4-VAR_3); if (VAR_6 > 0)
av_log(VAR_0, AV_LOG_INFO,
"truncated comment header, %i comments not found\VAR_6", VAR_6); return 0; }