static int rm_read_index(AVFormatContext *s)

{

    AVIOContext *pb = s->pb;

    unsigned int size, n_pkts, str_id, next_off, n, pos, pts;

    AVStream *st;



    do {

        if (avio_rl32(pb) != MKTAG('I','N','D','X'))

            return -1;

        size     = avio_rb32(pb);

        if (size < 20)

            return -1;

        avio_skip(pb, 2);

        n_pkts   = avio_rb32(pb);

        str_id   = avio_rb16(pb);

        next_off = avio_rb32(pb);

        for (n = 0; n < s->nb_streams; n++)

            if (s->streams[n]->id == str_id) {

                st = s->streams[n];

                break;

            }

        if (n == s->nb_streams)

            goto skip;



        for (n = 0; n < n_pkts; n++) {

            avio_skip(pb, 2);

            pts = avio_rb32(pb);

            pos = avio_rb32(pb);

            avio_skip(pb, 4); /* packet no. */



            av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);

        }



skip:

        if (next_off && avio_tell(pb) != next_off &&

            avio_seek(pb, next_off, SEEK_SET) < 0)

            return -1;

    } while (next_off);



    return 0;

}

static int rm_read_index(AVFormatContext *s)

{

    AVIOContext *pb = s->pb;

    unsigned int size, n_pkts, str_id, next_off, n, pos, pts;

    AVStream *st;



    do {

        if (avio_rl32(pb) != MKTAG('I','N','D','X'))

            return -1;

        size     = avio_rb32(pb);

        if (size < 20)

            return -1;

        avio_skip(pb, 2);

        n_pkts   = avio_rb32(pb);

        str_id   = avio_rb16(pb);

        next_off = avio_rb32(pb);

        for (n = 0; n < s->nb_streams; n++)

            if (s->streams[n]->id == str_id) {

                st = s->streams[n];

                break;

            }

        if (n == s->nb_streams)

            goto skip;



        for (n = 0; n < n_pkts; n++) {

            avio_skip(pb, 2);

            pts = avio_rb32(pb);

            pos = avio_rb32(pb);

            avio_skip(pb, 4); 



            av_add_index_entry(st, pos, pts, 0, 0, AVINDEX_KEYFRAME);

        }



skip:

        if (next_off && avio_tell(pb) != next_off &&

            avio_seek(pb, next_off, SEEK_SET) < 0)

            return -1;

    } while (next_off);



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)

{

    AVIOContext *pb = VAR_0->pb;

    unsigned int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;

    AVStream *st;



    do {

        if (avio_rl32(pb) != MKTAG('I','N','D','X'))

            return -1;

        VAR_1     = avio_rb32(pb);

        if (VAR_1 < 20)

            return -1;

        avio_skip(pb, 2);

        VAR_2   = avio_rb32(pb);

        VAR_3   = avio_rb16(pb);

        VAR_4 = avio_rb32(pb);

        for (VAR_5 = 0; VAR_5 < VAR_0->nb_streams; VAR_5++)

            if (VAR_0->streams[VAR_5]->id == VAR_3) {

                st = VAR_0->streams[VAR_5];

                break;

            }

        if (VAR_5 == VAR_0->nb_streams)

            goto skip;



        for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {

            avio_skip(pb, 2);

            VAR_7 = avio_rb32(pb);

            VAR_6 = avio_rb32(pb);

            avio_skip(pb, 4); 



            av_add_index_entry(st, VAR_6, VAR_7, 0, 0, AVINDEX_KEYFRAME);

        }



skip:

        if (VAR_4 && avio_tell(pb) != VAR_4 &&

            avio_seek(pb, VAR_4, SEEK_SET) < 0)

            return -1;

    } while (VAR_4);



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ AVIOContext *pb = VAR_0->pb; unsigned int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; AVStream *st; do { if (avio_rl32(pb) != MKTAG('I','N','D','X'))
return -1; VAR_1     = avio_rb32(pb); if (VAR_1 < 20)
return -1; avio_skip(pb, 2); VAR_2   = avio_rb32(pb); VAR_3   = avio_rb16(pb); VAR_4 = avio_rb32(pb); for (VAR_5 = 0; VAR_5 < VAR_0->nb_streams; VAR_5++) if (VAR_0->streams[VAR_5]->id == VAR_3) { st = VAR_0->streams[VAR_5]; break; } if (VAR_5 == VAR_0->nb_streams)
goto skip; for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { avio_skip(pb, 2); VAR_7 = avio_rb32(pb); VAR_6 = avio_rb32(pb); avio_skip(pb, 4); av_add_index_entry(st, VAR_6, VAR_7, 0, 0, AVINDEX_KEYFRAME); } skip:
if (VAR_4 && avio_tell(pb) != VAR_4 &&
avio_seek(pb, VAR_4, SEEK_SET) < 0)
return -1; } while (VAR_4); return 0; }