[FFmpeg-devel] [PATCH 2/3] lavfi/buffersink: loop until the sink fifo get filled.

Clément Bœsch ubitux at gmail.com
Sat Mar 16 16:50:12 CET 2013


In some situations, notably when there is a filter using the min/max
samples (where some buffering is done), the ff_request_frame() present
in that chunk could succeed without having filled the buffer sink fifo.

This fixes -f lavfi -i amovie=in.mp3,ebur128=metadata=1 where the first
av_buffersink_get_frame_flags() led to a EINVAL.
---
 libavfilter/buffersink.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 8236f22..087f845 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -125,16 +125,13 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag
     AVFrame *cur_frame;
 
     /* no picref available, fetch it from the filterchain */
-    if (!av_fifo_size(buf->fifo)) {
+    while (!av_fifo_size(buf->fifo)) {
         if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
             return AVERROR(EAGAIN);
         if ((ret = ff_request_frame(inlink)) < 0)
             return ret;
     }
 
-    if (!av_fifo_size(buf->fifo))
-        return AVERROR(EINVAL);
-
     if (flags & AV_BUFFERSINK_FLAG_PEEK) {
         cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
         av_frame_ref(frame, cur_frame); /* TODO check failure */
-- 
1.8.2



More information about the ffmpeg-devel mailing list