flac_parser: speedup fifo realloc
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 13 May 2012 23:36:40 +0000 (01:36 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 13 May 2012 23:42:51 +0000 (01:42 +0200)
Fixes Ticket1121

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/flac_parser.c

index 217461f..3d2b882 100644 (file)
@@ -561,8 +561,8 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
         }
 
         /* Fill the buffer. */
-        if (av_fifo_realloc2(fpc->fifo_buf,
-                             (read_end - read_start) + av_fifo_size(fpc->fifo_buf)) < 0) {
+        if (   av_fifo_space(fpc->fifo_buf) < read_end - read_start
+            && av_fifo_realloc2(fpc->fifo_buf, (read_end - read_start) + 2*av_fifo_size(fpc->fifo_buf)) < 0) {
             av_log(avctx, AV_LOG_ERROR,
                    "couldn't reallocate buffer of size %td\n",
                    (read_end - read_start) + av_fifo_size(fpc->fifo_buf));