avformat/utils: Fix bitrate overflow check
The check added indf33a58e53
does not work at all, rather it broke the summing of bitrates completely. The comparission was wrong way around. This commit replaces it by a simpler and hopefully clearer check Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commita5d67bc796
) Conflicts: libavformat/utils.c Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -2253,23 +2253,20 @@ static void fill_all_stream_timings(AVFormatContext *ic)
|
||||
static void estimate_timings_from_bit_rate(AVFormatContext *ic)
|
||||
{
|
||||
int64_t filesize, duration;
|
||||
int bit_rate, i;
|
||||
int i;
|
||||
AVStream *st;
|
||||
|
||||
/* if bit_rate is already set, we believe it */
|
||||
if (ic->bit_rate <= 0) {
|
||||
bit_rate = 0;
|
||||
int64_t bit_rate = 0;
|
||||
for(i=0;i<ic->nb_streams;i++) {
|
||||
st = ic->streams[i];
|
||||
if (st->codec->bit_rate > 0) {
|
||||
if (INT_MAX - st->codec->bit_rate > bit_rate) {
|
||||
bit_rate = 0;
|
||||
break;
|
||||
}
|
||||
bit_rate += st->codec->bit_rate;
|
||||
}
|
||||
}
|
||||
ic->bit_rate = bit_rate;
|
||||
if (bit_rate <= INT_MAX)
|
||||
ic->bit_rate = bit_rate;
|
||||
}
|
||||
|
||||
/* if duration is already set, we believe it */
|
||||
|
Reference in New Issue
Block a user