diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-10-06 07:01:17 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2019-10-07 22:53:19 +0200 |
commit | a1701e7591e5fcbe9111218cb583a8ea0fb0b1da (patch) | |
tree | 9dfd8d250ffaee0dc6fe4ab23cbe5525812f7b74 /libavcodec/flac_parser.c | |
parent | 047a6d396f6919c469e35d6ef75bd9cae5a87523 (diff) | |
download | ffmpeg-a1701e7591e5fcbe9111218cb583a8ea0fb0b1da.tar.gz |
avcodec/flac_parser: Remove superfluous checks
For a parser, the input buffer is always != NULL: In case of flushing,
the indicated size of the input buffer will be zero and the input buffer
will point to a zeroed buffer of size 0 + AV_INPUT_BUFFER_PADDING.
Therefore one does not need to check for whether said buffer is NULL or
not.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/flac_parser.c')
-rw-r--r-- | libavcodec/flac_parser.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 8c61f3a88c..1dcb3ef2db 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -584,17 +584,16 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, } /* Find and score new headers. */ - /* buf_size is to zero when padding, so check for this since we do */ + /* buf_size is zero when flushing, 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 && + /* Also note that buf can't be NULL. */ + while ((buf_size && read_end < buf + buf_size && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) - || ((!buf || !buf_size) && !fpc->end_padded)) { + || (!buf_size && !fpc->end_padded)) { int start_offset; /* Pad the end once if EOF, to check the final region for headers. */ - if (!buf || !buf_size) { + if (!buf_size) { fpc->end_padded = 1; buf_size = MAX_FRAME_HEADER_SIZE; read_end = read_start + MAX_FRAME_HEADER_SIZE; @@ -624,7 +623,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, goto handle_error; } - if (buf && buf_size) { + if (buf_size) { av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { @@ -647,7 +646,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, fpc->nb_headers_buffered = nb_headers; /* Wait till FLAC_MIN_HEADERS to output a valid frame. */ if (!fpc->end_padded && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) { - if (buf && read_end < buf + buf_size) { + if (read_end < buf + buf_size) { read_start = read_end; continue; } else { @@ -682,7 +681,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, if (fpc->best_header && fpc->best_header->max_score <= 0) { // Only accept a bad header if there is no other option to continue - if (!buf_size || !buf || read_end != buf || fpc->nb_headers_buffered < FLAC_MIN_HEADERS) + if (!buf_size || read_end != buf || fpc->nb_headers_buffered < FLAC_MIN_HEADERS) fpc->best_header = NULL; } |