summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <[email protected]>2013-09-03 14:36:12 +0200
committerMichael Niedermayer <[email protected]>2013-09-07 13:51:58 +0200
commit5c6aea5c31bf2a2f3343a051f6b39a62b245878e (patch)
treea0083b6b75b07f969f4c8bfb7580fcc7792e8ae0
parentdfe0ba46bf484b8b64cd7584353e97ea18912c13 (diff)
avformat/utils: Fix bitrate overflow check
The check added in df33a58e5311ee9a64a573889b883a80e981af7b 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 <[email protected]> (cherry picked from commit a5d67bc796e1f9a2b99b43ea807166b655e4bdbc) Conflicts: libavformat/utils.c Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r--libavformat/utils.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5fff3e26fa..9619d95f5e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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 */