diff options
Diffstat (limited to 'libavcodec/flac_parser.c')
-rw-r--r-- | libavcodec/flac_parser.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 6c8c046..e37ca64 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -2,20 +2,20 @@ * FLAC parser * Copyright (c) 2010 Michael Chinen * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -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)); @@ -606,10 +606,11 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, /* restore the state pre-padding */ if (fpc->end_padded) { + int warp = fpc->fifo_buf->wptr - fpc->fifo_buf->buffer < MAX_FRAME_HEADER_SIZE; /* HACK: drain the tail of the fifo */ fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE; fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE; - if (fpc->fifo_buf->wptr < 0) { + if (warp) { fpc->fifo_buf->wptr += fpc->fifo_buf->end - fpc->fifo_buf->buffer; } |