Whoops, that version spams on every flush; changed to only print when buf_size > 0.
- dale On Fri, Feb 23, 2018 at 10:37 AM, Dale Curtis <dalecur...@chromium.org> wrote: > After some deeper testing it looks like this mechanism can actually fully > replace the existing ID3 and APE tag skips; so I've simplified the patch to > do so. > > - dale > > > On Thu, Feb 22, 2018 at 4:46 PM, Dale Curtis <dalecur...@chromium.org> > wrote: > >> The parser should only return valid mpeg audio packets; it generally >> does so, but in the case of flush, it returns whatever happens to >> be in the buffer instead of ensuring its first a valid mpeg packet. >> >> The fix is to check whether a valid frame size has been parsed and >> if not discard the packet when flushing. >> >> This should fix all sorts of mp3 files with trailing garbage. >> >> Signed-off-by: Dale Curtis <dalecur...@chromium.org> >> >> >
From b81ec4a9a3907e21cc4c4abcf5502778be94076a Mon Sep 17 00:00:00 2001 From: Dale Curtis <dalecur...@chromium.org> Date: Thu, 22 Feb 2018 16:43:37 -0800 Subject: [PATCH] [mpegaudio_parser] Skip trailing junk data when flushing parser. The parser should only return valid mpeg audio packets; it generally does so, but in the case of flush, it returns whatever happens to be in the buffer instead of ensuring its first a valid mpeg packet. The fix is to check whether a valid frame size has been parsed and if not discard the packet when flushing. This should fix all sorts of mp3 files with trailing garbage. Signed-off-by: Dale Curtis <dalecur...@chromium.org> --- libavcodec/mpegaudio_parser.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 244281b56f..87365a2c75 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -23,8 +23,6 @@ #include "parser.h" #include "mpegaudiodecheader.h" #include "libavutil/common.h" -#include "libavformat/apetag.h" // for APE tag. -#include "libavformat/id3v1.h" // for ID3v1_TAG_SIZE typedef struct MpegAudioParseContext { ParseContext pc; @@ -115,13 +113,8 @@ static int mpegaudio_parse(AVCodecParserContext *s1, return buf_size; } - if (flush && buf_size >= ID3v1_TAG_SIZE && memcmp(buf, "TAG", 3) == 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return next; - } - - if (flush && buf_size >= APE_TAG_FOOTER_BYTES && memcmp(buf, APE_TAG_PREAMBLE, 8) == 0) { + if (flush && buf_size && !s->frame_size) { + av_log(avctx, AV_LOG_WARNING, "Discarding invalid trailing data from mpeg audio stream.\n"); *poutbuf = NULL; *poutbuf_size = 0; return next; -- 2.16.1.291.g4437f3f132-goog
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel