From patchwork Fri Feb 23 19:15:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dale Curtis X-Patchwork-Id: 7724 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.33 with SMTP id c30csp1027269jai; Fri, 23 Feb 2018 11:15:42 -0800 (PST) X-Google-Smtp-Source: AG47ELvVnLt4VKPPoPNLT4u6iimP+Em6aNjFWpgg2TER356AwrjgTIncXUF8GjOTxyuatnNgj54e X-Received: by 10.28.207.201 with SMTP id f192mr2465685wmg.81.1519413342675; Fri, 23 Feb 2018 11:15:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519413342; cv=none; d=google.com; s=arc-20160816; b=W9rjrY4160G6u/qS+8zXf6WRIIT+MrvggPOiaGkxL187Df9I8CJ5npRFwWi87eQgFP 5ekpwynXXABhOpO0yqI8Rgr6nUo1Biz+RVR6GKaHtGhUFcLnMvAjF+LuQDamvjF/v1ff a3Xi5kmGYXJeUcb2lRvMFt4SeKaQMuKCtlH1J2nJcuFuUMnwCS6Ojpg5cAKUeyBm+hmt W5C4EDly8a77RFjAWu1qgWv/1bVk3cCYKm4brqZTfpDYeq5rRLG1TMubKyq5+RbmSO+h B02dk2aMAbgUNsjHSW5/5E5lrWC/q6+19QVxczws07Zyx3NexuSig2JVxg5gbNgvDDRf GJJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:dkim-signature:delivered-to :arc-authentication-results; bh=OECpCxDuQ1LLPOlHlhknJE1iz6063ACydbhyGcQtRTo=; b=xRiiXTCk5DsfSNYF3bZVD/6OF9jdo4j8kyuuJ6a0xI4l9LFI+krlubLSXfSV0Y18lU acBxNaPcl4LjVX0XprfVvhvg1ME4QWRRMV0BucKxaaLn74F4JW6C6kRl4Gu/XKTJYz/+ WkV/fmNXAfz6zitruI2aBR57nSfsVyy2tp2LcW9KWqda/lwCPJ5dfDPfSN/y4w5T1UDY Tf9cBKpO4fShRPJP0bAd2neJq409ErQl2Qu1x/hdnwpDVrqEhhx2JaM0cT39mMT+VNDc vhxqYhBYgcwK+2BE62HDYw7ATEEGtaCK3GhByD8fqZyPkrmsXwLPZjjkSFKE54nGKTmY RTAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=AvX5I6fO; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=fb4T3hKL; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i11si1208502wmb.263.2018.02.23.11.15.41; Fri, 23 Feb 2018 11:15:42 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=AvX5I6fO; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=fb4T3hKL; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C612668A68B; Fri, 23 Feb 2018 21:15:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw0-f174.google.com (mail-yw0-f174.google.com [209.85.161.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92BC568A678 for ; Fri, 23 Feb 2018 21:15:29 +0200 (EET) Received: by mail-yw0-f174.google.com with SMTP id q69so3143142ywh.13 for ; Fri, 23 Feb 2018 11:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=gFm/rQQfOwlzDdWnzPqTYIPUJMl3bagn+SA5cmyv5lY=; b=AvX5I6fOHq82JtgWyMdUYwNf5u4vUeJ2NOGMF7Bw74JFbDLlXHu3YF8B1RWXx93IDW VZnB/nGiHqYmIxjZ9f2TRCJED9xjj0WtuS6QCbQyKO1oqoQy68x7ITYggmlD/vY9nxrj OW6DWkjiOJJqjrA6sq4d0eW89HFMdYrOkvAIXHTWCZefBoeKtPZX6rB8mNsBqg4IVIvP w4Om6mVJg/L3IG0gg8IExMd18aKEtwn/NeBJ9elvpeYGJbA+Pa2N7td+WqpYx3cobFSf TcDCgF9lQOhkl29nOubWERDYLO2Rm2VighJRB9gujsMCAfL+e8TnhqcOHTphmaaX1Nsb QVcA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=gFm/rQQfOwlzDdWnzPqTYIPUJMl3bagn+SA5cmyv5lY=; b=fb4T3hKLIUVC2JNXfefxRjIb7YQYBfnwfqZwgRAcJJGECEvU6J9lx3IKIg7CWqRR16 Sbs213ro8Cp9Jngsu7prQ9BAw34Syq+TsoqLH5w/1ZkKFwrw9KEh8I8HskaLMBJgntHr KdHAqbCYH0j4/bi3c1HVWzuTJPG6uQ7EBayIw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=gFm/rQQfOwlzDdWnzPqTYIPUJMl3bagn+SA5cmyv5lY=; b=KpYaZZD/3bb/nCVlwimq8mVX9PszPq1Ld7wcii4aMI725CV4UEG8r/e4ztps1C/KO1 jHEC+bTrKusvnWfDn65dAqtQDQ7ufnPTzuVXpc+Upm/qANKtp6mw3zv48lq0dPOYSCF+ vpNsv9PISn9SzoHm+nbsqqACtXyu/PvClJ2lTFIgd561F691mfBf14v7pDXP+MOYbfQY SAwWHD5cf9hep5Ld2AsIL8EwU+D3EuW97mi4MQBL58m8keP1J5qTqzu60B4UjzOTjcko G57f0NOn6GpZzunr5ECETqNTgN4aJzAHPMS7BEKM/8+y3yz6XSWC3i8++Frr6hIxQhls PYAQ== X-Gm-Message-State: APf1xPB5iASFpGyb+vMj4rMf3A12PSj3AiwmDSGOEhNAtkoXSbsbLjel 9CYOQOrhLSLqtlaWr+XeGAkcYaHCMia+sND0F4Oot3iu X-Received: by 10.129.84.69 with SMTP id i66mr1895243ywb.264.1519413330580; Fri, 23 Feb 2018 11:15:30 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:5f52:0:0:0:0:0 with HTTP; Fri, 23 Feb 2018 11:15:09 -0800 (PST) In-Reply-To: References: From: Dale Curtis Date: Fri, 23 Feb 2018 11:15:09 -0800 X-Google-Sender-Auth: Rt3pyyyw_q5-gQmancWDFswgyTI Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [mpegaudio_parser] Skip trailing junk data when flushing parser. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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 > 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 >> >> > From b81ec4a9a3907e21cc4c4abcf5502778be94076a Mon Sep 17 00:00:00 2001 From: Dale Curtis 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 --- 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