[FFmpeg-cvslog] mpegts: prevent division by zero
Andreas Cadhalpun
git at videolan.org
Sun Nov 27 01:41:09 EET 2016
ffmpeg | branch: release/3.0 | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Mon Nov 7 23:37:59 2016 +0100| [3d82cebdd2bd5424b0eb37b0e39284da19fa0e5b] | committer: Andreas Cadhalpun
mpegts: prevent division by zero
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
(cherry picked from commit 1bbb18fe82fc77a10d45fa53bd2738d2c54de6c6)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3d82cebdd2bd5424b0eb37b0e39284da19fa0e5b
---
libavformat/mpegts.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index e8f3889..c85c30d 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2585,8 +2585,17 @@ static int mpegts_read_header(AVFormatContext *s)
packet_count[nb_pcrs] = nb_packets;
pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
nb_pcrs++;
- if (nb_pcrs >= 2)
- break;
+ if (nb_pcrs >= 2) {
+ if (pcrs[1] - pcrs[0] > 0) {
+ /* the difference needs to be positive to make sense for bitrate computation */
+ break;
+ } else {
+ av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= %"PRId64"\n", pcrs[0], pcrs[1]);
+ pcrs[0] = pcrs[1];
+ packet_count[0] = packet_count[1];
+ nb_pcrs--;
+ }
+ }
} else {
finished_reading_packet(s, ts->raw_packet_size);
}
More information about the ffmpeg-cvslog
mailing list