[FFmpeg-cvslog] avformat/utils: Fix bitrate overflow check
Michael Niedermayer
git at videolan.org
Tue Sep 3 14:50:48 CEST 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Sep 3 14:36:12 2013 +0200| [a5d67bc796e1f9a2b99b43ea807166b655e4bdbc] | committer: Michael Niedermayer
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 <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5d67bc796e1f9a2b99b43ea807166b655e4bdbc
---
libavformat/utils.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c99df71..277b559 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2219,18 +2219,15 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
/* if bit_rate is already set, we believe it */
if (ic->bit_rate <= 0) {
- int 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 */
More information about the ffmpeg-cvslog
mailing list