]> git.sesse.net Git - ffmpeg/commitdiff
bfi: Avoid divisions by zero
authorMartin Storsjö <martin@martin.st>
Sat, 28 Sep 2013 20:42:40 +0000 (23:42 +0300)
committerMartin Storsjö <martin@martin.st>
Sun, 29 Sep 2013 16:58:56 +0000 (19:58 +0300)
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@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/bfi.c

index e60bbf4cab5384279bb536af50fbdf6d86780a67..5d7ccb85e632ec76d4f718668bc933ad4092e779 100644 (file)
@@ -140,9 +140,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);
@@ -154,6 +152,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;