aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Chinen <m@roughsoft.com>2012-10-14 16:08:43 +0900
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2012-12-11 00:50:19 +0100
commit59d765e30cdabbba174f3d764eecda39ebfc63c2 (patch)
treef4ac5abab01d2a9c7c6f2090a810591e2e165205
parentdad5b9560a5cf3f34ddbc1df1a8a18b07b0d24ac (diff)
downloadffmpeg-59d765e30cdabbba174f3d764eecda39ebfc63c2.tar.gz
flac_parser.c: fix issue with looping output for small files.
see trac 1345 https://ffmpeg.org/trac/ffmpeg/ticket/1345 Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit c73b1a1d8010dac29653b41d39af9c18247179c3)
-rw-r--r--libavcodec/flac_parser.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index e37ca64be8..f38d7aae67 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -541,14 +541,18 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
av_freep(&fpc->best_header);
}
- /* Find and score new headers. */
- while ((buf && read_end < buf + buf_size &&
+ /* Find and score new headers. */
+ /* buf_size is to zero when padding, so check for this since we do */
+ /* not want to try to read more input once we have found the end. */
+ /* Note that as (non-modified) parameters, buf can be non-NULL, */
+ /* while buf_size is 0. */
+ while ((buf && buf_size && read_end < buf + buf_size &&
fpc->nb_headers_buffered < FLAC_MIN_HEADERS)
- || (!buf && !fpc->end_padded)) {
+ || ((!buf || !buf_size) && !fpc->end_padded)) {
int start_offset;
/* Pad the end once if EOF, to check the final region for headers. */
- if (!buf) {
+ if (!buf || !buf_size) {
fpc->end_padded = 1;
buf_size = MAX_FRAME_HEADER_SIZE;
read_end = read_start + MAX_FRAME_HEADER_SIZE;
@@ -569,7 +573,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
goto handle_error;
}
- if (buf) {
+ if (buf && buf_size) {
av_fifo_generic_write(fpc->fifo_buf, (void*) read_start,
read_end - read_start, NULL);
} else {