static int calculate_bitrate(AVFormatContext *s)

{

    AVIContext *avi = s->priv_data;

    int i, j;

    int64_t lensum = 0;

    int64_t maxpos = 0;



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

        int64_t len = 0;

        AVStream *st = s->streams[i];



        if (!st->nb_index_entries)

            continue;



        for (j = 0; j < st->nb_index_entries; j++)

            len += st->index_entries[j].size;

        maxpos = FFMAX(maxpos, st->index_entries[j-1].pos);

        lensum += len;

    }

    if (maxpos < avi->io_fsize*9/10) // index does not cover the whole file

        return 0;

    if (lensum*9/10 > maxpos || lensum < maxpos*9/10) // frame sum and filesize mismatch

        return 0;



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

        int64_t len = 0;

        AVStream *st = s->streams[i];

        int64_t duration;



        for (j = 0; j < st->nb_index_entries; j++)

            len += st->index_entries[j].size;



        if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)

            continue;

        duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;

        st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);

    }

    return 1;

}

static int calculate_bitrate(AVFormatContext *s)

{

    AVIContext *avi = s->priv_data;

    int i, j;

    int64_t lensum = 0;

    int64_t maxpos = 0;



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

        int64_t len = 0;

        AVStream *st = s->streams[i];



        if (!st->nb_index_entries)

            continue;



        for (j = 0; j < st->nb_index_entries; j++)

            len += st->index_entries[j].size;

        maxpos = FFMAX(maxpos, st->index_entries[j-1].pos);

        lensum += len;

    }

    if (maxpos < avi->io_fsize*9/10) 

        return 0;

    if (lensum*9/10 > maxpos || lensum < maxpos*9/10) 

        return 0;



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

        int64_t len = 0;

        AVStream *st = s->streams[i];

        int64_t duration;



        for (j = 0; j < st->nb_index_entries; j++)

            len += st->index_entries[j].size;



        if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)

            continue;

        duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;

        st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);

    }

    return 1;

}

        st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
static int FUNC_0(AVFormatContext *VAR_0)

{

    AVIContext *avi = VAR_0->priv_data;

    int VAR_1, VAR_2;

    int64_t lensum = 0;

    int64_t maxpos = 0;



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

        int64_t len = 0;

        AVStream *st = VAR_0->streams[VAR_1];



        if (!st->nb_index_entries)

            continue;



        for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++)

            len += st->index_entries[VAR_2].size;

        maxpos = FFMAX(maxpos, st->index_entries[VAR_2-1].pos);

        lensum += len;

    }

    if (maxpos < avi->io_fsize*9/10) 

        return 0;

    if (lensum*9/10 > maxpos || lensum < maxpos*9/10) 

        return 0;



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

        int64_t len = 0;

        AVStream *st = VAR_0->streams[VAR_1];

        int64_t duration;



        for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++)

            len += st->index_entries[VAR_2].size;



        if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)

            continue;

        duration = st->index_entries[VAR_2-1].timestamp - st->index_entries[0].timestamp;

        st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);

    }

    return 1;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ AVIContext *avi = VAR_0->priv_data; int VAR_1, VAR_2; int64_t lensum = 0; int64_t maxpos = 0; for (VAR_1 = 0; VAR_1<VAR_0->nb_streams; VAR_1++) { int64_t len = 0; AVStream *st = VAR_0->streams[VAR_1]; if (!st->nb_index_entries)
continue; for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++) len += st->index_entries[VAR_2].size; maxpos = FFMAX(maxpos, st->index_entries[VAR_2-1].pos); lensum += len; } if (maxpos < avi->io_fsize*9/10)
return 0; if (lensum*9/10 > maxpos || lensum < maxpos*9/10)
return 0; for (VAR_1 = 0; VAR_1<VAR_0->nb_streams; VAR_1++) { int64_t len = 0; AVStream *st = VAR_0->streams[VAR_1]; int64_t duration; for (VAR_2 = 0; VAR_2 < st->nb_index_entries; VAR_2++) len += st->index_entries[VAR_2].size; if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
continue; duration = st->index_entries[VAR_2-1].timestamp - st->index_entries[0].timestamp; st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num); } return 1; }