[FFmpeg-devel] [PATCH] libavutil/fifo: Fix fifo grow step

sebechlebskyjan at gmail.com sebechlebskyjan at gmail.com
Fri Jun 3 14:04:00 CEST 2016


From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>

Fifo was reallocating always to twice of the requested size.
This fixes it to reallocate to requested size, or twice of the
original size - whichever is greater.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
 I believe the intended behaviour was as described in commit message
 and FFMAX(size,2*size) is a mistake.

 libavutil/fifo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 986729a..1060aed 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -113,7 +113,7 @@ int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
     size += av_fifo_size(f);
 
     if (old_size < size)
-        return av_fifo_realloc2(f, FFMAX(size, 2*size));
+        return av_fifo_realloc2(f, FFMAX(size, 2*old_size));
     return 0;
 }
 
-- 
1.9.1



More information about the ffmpeg-devel mailing list