ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)

{

    const uint8_t *p = buf;

    const uint8_t *end = buf + size;

    unsigned n, j;

    int s;



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

        return -1;



    s = bytestream_get_le32(&p);



    if (end - p - 4 < s || s < 0)

        return -1;



    p += s;



    n = bytestream_get_le32(&p);



    while (end - p >= 4 && n > 0) {

        const char *t, *v;

        int tl, vl;



        s = bytestream_get_le32(&p);



        if (end - p < s || s < 0)

            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_log(as, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\n");

                continue;

            }



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

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

            tt[tl] = 0;



            memcpy(ct, v, vl);

            ct[vl] = 0;



            if (!strcmp(tt, "METADATA_BLOCK_PICTURE")) {

                int ret;

                char *pict = av_malloc(vl);



                if (!pict) {

                    av_log(as, AV_LOG_WARNING, "out-of-memory error. Skipping cover art block.\n");


                    continue;

                }

                if ((ret = av_base64_decode(pict, ct, vl)) > 0)

                    ret = ff_flac_parse_picture(as, pict, ret);

                av_freep(&pict);


                if (ret < 0) {

                    av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");

                    continue;

                }

            } else if (!ogm_chapter(as, tt, ct))

                av_dict_set(m, tt, ct,

                                   AV_DICT_DONT_STRDUP_KEY |

                                   AV_DICT_DONT_STRDUP_VAL);

        }

    }



    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);



    ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);



    return 0;

}
ff_vorbis_comment(AVFormatContext * as, AVDictionary **m, const uint8_t *buf, int size)

{

    const uint8_t *p = buf;

    const uint8_t *end = buf + size;

    unsigned n, j;

    int s;



    if (size < 8) 

        return -1;



    s = bytestream_get_le32(&p);



    if (end - p - 4 < s || s < 0)

        return -1;



    p += s;



    n = bytestream_get_le32(&p);



    while (end - p >= 4 && n > 0) {

        const char *t, *v;

        int tl, vl;



        s = bytestream_get_le32(&p);



        if (end - p < s || s < 0)

            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_log(as, AV_LOG_WARNING, "out-of-memory error. skipping VorbisComment tag.\n");

                continue;

            }



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

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

            tt[tl] = 0;



            memcpy(ct, v, vl);

            ct[vl] = 0;



            if (!strcmp(tt, "METADATA_BLOCK_PICTURE")) {

                int ret;

                char *pict = av_malloc(vl);



                if (!pict) {

                    av_log(as, AV_LOG_WARNING, "out-of-memory error. Skipping cover art block.\n");


                    continue;

                }

                if ((ret = av_base64_decode(pict, ct, vl)) > 0)

                    ret = ff_flac_parse_picture(as, pict, ret);

                av_freep(&pict);


                if (ret < 0) {

                    av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");

                    continue;

                }

            } else if (!ogm_chapter(as, tt, ct))

                av_dict_set(m, tt, ct,

                                   AV_DICT_DONT_STRDUP_KEY |

                                   AV_DICT_DONT_STRDUP_VAL);

        }

    }



    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);



    ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);



    return 0;

}
FUNC_0(AVFormatContext * VAR_0, AVDictionary **VAR_1, const uint8_t *VAR_2, int VAR_3)

{

    const uint8_t *VAR_4 = VAR_2;

    const uint8_t *VAR_5 = VAR_2 + VAR_3;

    unsigned VAR_6, VAR_7;

    int VAR_8;



    if (VAR_3 < 8) 

        return -1;



    VAR_8 = bytestream_get_le32(&VAR_4);



    if (VAR_5 - VAR_4 - 4 < VAR_8 || VAR_8 < 0)

        return -1;



    VAR_4 += VAR_8;



    VAR_6 = bytestream_get_le32(&VAR_4);



    while (VAR_5 - VAR_4 >= 4 && VAR_6 > 0) {

        const char *VAR_9, *VAR_10;

        int VAR_11, VAR_12;



        VAR_8 = bytestream_get_le32(&VAR_4);



        if (VAR_5 - VAR_4 < VAR_8 || VAR_8 < 0)

            break;



        VAR_9 = VAR_4;

        VAR_4 += VAR_8;

        VAR_6--;



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

        if (!VAR_10)

            continue;



        VAR_11 = VAR_10 - VAR_9;

        VAR_12 = VAR_8 - VAR_11 - 1;

        VAR_10++;



        if (VAR_11 && VAR_12) {

            char *VAR_13, *VAR_14;



            VAR_13 = av_malloc(VAR_11 + 1);

            VAR_14 = av_malloc(VAR_12 + 1);

            if (!VAR_13 || !VAR_14) {

                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_11; VAR_7++)

                VAR_13[VAR_7] = av_toupper(VAR_9[VAR_7]);

            VAR_13[VAR_11] = 0;



            memcpy(VAR_14, VAR_10, VAR_12);

            VAR_14[VAR_12] = 0;



            if (!strcmp(VAR_13, "METADATA_BLOCK_PICTURE")) {

                int VAR_15;

                char *VAR_16 = av_malloc(VAR_12);



                if (!VAR_16) {

                    av_log(VAR_0, AV_LOG_WARNING, "out-of-memory error. Skipping cover art block.\VAR_6");


                    continue;

                }

                if ((VAR_15 = av_base64_decode(VAR_16, VAR_14, VAR_12)) > 0)

                    VAR_15 = ff_flac_parse_picture(VAR_0, VAR_16, VAR_15);

                av_freep(&VAR_16);


                if (VAR_15 < 0) {

                    av_log(VAR_0, AV_LOG_WARNING, "Failed to parse cover art block.\VAR_6");

                    continue;

                }

            } else if (!ogm_chapter(VAR_0, VAR_13, VAR_14))

                av_dict_set(VAR_1, VAR_13, VAR_14,

                                   AV_DICT_DONT_STRDUP_KEY |

                                   AV_DICT_DONT_STRDUP_VAL);

        }

    }



    if (VAR_4 != VAR_5)

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

    if (VAR_6 > 0)

        av_log(VAR_0, AV_LOG_INFO,

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



    ff_metadata_conv(VAR_1, NULL, ff_vorbiscomment_metadata_conv);



    return 0;

}
FUNC_0(AVFormatContext * VAR_0, AVDictionary **VAR_1, const uint8_t *VAR_2, int VAR_3)
{ const uint8_t *VAR_4 = VAR_2; const uint8_t *VAR_5 = VAR_2 + VAR_3; unsigned VAR_6, VAR_7; int VAR_8; if (VAR_3 < 8)
return -1; VAR_8 = bytestream_get_le32(&VAR_4); if (VAR_5 - VAR_4 - 4 < VAR_8 || VAR_8 < 0)
return -1; VAR_4 += VAR_8; VAR_6 = bytestream_get_le32(&VAR_4); while (VAR_5 - VAR_4 >= 4 && VAR_6 > 0) { const char *VAR_9, *VAR_10; int VAR_11, VAR_12; VAR_8 = bytestream_get_le32(&VAR_4); if (VAR_5 - VAR_4 < VAR_8 || VAR_8 < 0)
break; VAR_9 = VAR_4; VAR_4 += VAR_8; VAR_6--; VAR_10 = memchr(VAR_9, '=', VAR_8); if (!VAR_10)
continue; VAR_11 = VAR_10 - VAR_9; VAR_12 = VAR_8 - VAR_11 - 1; VAR_10++; if (VAR_11 && VAR_12) { char *VAR_13, *VAR_14; VAR_13 = av_malloc(VAR_11 + 1); VAR_14 = av_malloc(VAR_12 + 1); if (!VAR_13 || !VAR_14) { 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_11; VAR_7++) VAR_13[VAR_7] = av_toupper(VAR_9[VAR_7]); VAR_13[VAR_11] = 0; memcpy(VAR_14, VAR_10, VAR_12); VAR_14[VAR_12] = 0; if (!strcmp(VAR_13, "METADATA_BLOCK_PICTURE")) { int VAR_15; char *VAR_16 = av_malloc(VAR_12); if (!VAR_16) { av_log(VAR_0, AV_LOG_WARNING, "out-of-memory error. Skipping cover art block.\VAR_6"); continue; } if ((VAR_15 = av_base64_decode(VAR_16, VAR_14, VAR_12)) > 0)
VAR_15 = ff_flac_parse_picture(VAR_0, VAR_16, VAR_15); av_freep(&VAR_16); if (VAR_15 < 0) { av_log(VAR_0, AV_LOG_WARNING, "Failed to parse cover art block.\VAR_6"); continue; } } else if (!ogm_chapter(VAR_0, VAR_13, VAR_14)) av_dict_set(VAR_1, VAR_13, VAR_14,
AV_DICT_DONT_STRDUP_KEY |
AV_DICT_DONT_STRDUP_VAL); } } if (VAR_4 != VAR_5)
av_log(VAR_0, AV_LOG_INFO, "%ti bytes of comment header remain\VAR_6", VAR_5-VAR_4); if (VAR_6 > 0)
av_log(VAR_0, AV_LOG_INFO,
"truncated comment header, %i comments not found\VAR_6", VAR_6); ff_metadata_conv(VAR_1, NULL, ff_vorbiscomment_metadata_conv); return 0; }