[FFmpeg-cvslog] bfi: Avoid divisions by zero

Martin Storsjö git at videolan.org
Thu Jan 16 22:29:50 CET 2014


ffmpeg | branch: release/0.10 | Martin Storsjö <martin at martin.st> | Sat Sep 28 23:42:40 2013 +0300| [5e8243e843be8f71da7dde199a71d095726533eb] | committer: Luca Barbato

bfi: Avoid divisions by zero

If a zero-length video packet is to be returned, just return
AVERROR(EAGAIN) and switch back to the audio stream.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>
(cherry picked from commit 9fc7184d1a9af8d97b3fc5c2ef9d0a647d6617ea)
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
(cherry picked from commit ad1223d6bcc69e1639951aedcdae40822bf41042)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e8243e843be8f71da7dde199a71d095726533eb
---

 libavformat/bfi.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index bb02e85..c0b5681 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -138,9 +138,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
 
         pkt->pts          = bfi->audio_frame;
         bfi->audio_frame += ret;
-    }
-
-    else {
+    } else if (bfi->video_size > 0) {
 
         //Tossing a video packet at the video decoder.
         ret = av_get_packet(pb, pkt, bfi->video_size);
@@ -152,6 +150,9 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
 
         /* One less frame to read. A cursory decrement. */
         bfi->nframes--;
+    } else {
+        /* Empty video packet */
+        ret = AVERROR(EAGAIN);
     }
 
     bfi->avflag       = !bfi->avflag;



More information about the ffmpeg-cvslog mailing list