From patchwork Wed Oct 2 20:18:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 15466 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4E531447B42 for ; Wed, 2 Oct 2019 23:19:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A2C0687F5A; Wed, 2 Oct 2019 23:19:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E5AF4687F2B for ; Wed, 2 Oct 2019 23:18:56 +0300 (EEST) Received: by mail-io1-f66.google.com with SMTP id a1so297945ioc.6 for ; Wed, 02 Oct 2019 13:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=6EHx/ZuGZYk8e5AqdMFwkxlh23vB3fEg1Mvt/KnifOc=; b=gu4g35wKYcNaTeJuBbqzOf05i46HDmBryklQxqtrx/5fw8PmORaQtIxS3GQ8s4jUfL IqrE41cFDH7MW3o3P4+XApVDViU6ybHR2AN8f1DlrL2nK4/xazrJ2xQoZDJ1yl2ICrUc SjMpkw8MeGEdGufSniuntxqPkuq5OaYTS+9XinRd4yAPCDzd8L67T9sG7wJY63U0qM3D 712TbwVNwHuRZPsAzSZD07o/8eAHR32UACt25+MYkH5vkt3NBH0DTRoyrZNV7oz9xAGe 2nqGrAjL0WHb+0b36ZZ1gW4Jr6eF9yCWFxFPSHmhj1r89InsASR4QyejoMkJ1AsCsQLo 1pSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=6EHx/ZuGZYk8e5AqdMFwkxlh23vB3fEg1Mvt/KnifOc=; b=K9WtekTZfwXe1hXIk6jskHZu7tJyJLkl2XXRz+6/7V6WAFuM1ZMJwSmTB4fe+jU4OK OVL+aF2dKgMW5cg1muA12YydXi6zu3nyNQ7BugQdC8hsA0jMDUgIDKIjedUbRMak+H4J S1E4S3+GnN9qlFi5TFqnlEA1QdkgaCE9mTJXbPoM696K68zZ8UO6HlkR0izM/cB2hyO4 Q50mmjM3/8vkEeirc0OOlMRVCWeI3Hpie92AKD8KIqUiCmyDJx0HjojR0lCsUOBgMZBC bvLnoMu06YwEHyL9sqMdZpFZjB6/L3kJukBQSoaxOvTRVKlK9Zscr0b0Gp5c/CIYtl0D 3RSQ== X-Gm-Message-State: APjAAAUZueyWGBGnlHzLbjnU0damkr+l/S56BHfTH2aMvMBSzJ2KzExT fjQd3tIh0ydCRCUoAiG4thmh0l6DgBy8OMzKNGU32bQn X-Google-Smtp-Source: APXvYqw7SWy2oTfnTOgbPSkVtZAijH1diMXtl7KPWyiVZtlM271pZ5jBom7CnXAl2tS0z1tXbNzxSZ2RyVvyJae6WIY= X-Received: by 2002:a02:5205:: with SMTP id d5mr5902116jab.31.1570047534832; Wed, 02 Oct 2019 13:18:54 -0700 (PDT) MIME-Version: 1.0 References: <20191002181107.27360-1-onemda@gmail.com> In-Reply-To: <20191002181107.27360-1-onemda@gmail.com> From: Carl Eugen Hoyos Date: Wed, 2 Oct 2019 22:18:43 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] avformat/amr: reduce raw amr false positive detection 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" Am Mi., 2. Okt. 2019 um 20:19 Uhr schrieb Paul B Mahol : > > Signed-off-by: Paul B Mahol > --- > libavformat/amr.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/libavformat/amr.c b/libavformat/amr.c > index 42840a50a3..600cb1b0f0 100644 > --- a/libavformat/amr.c > +++ b/libavformat/amr.c > @@ -190,9 +190,12 @@ static int amrnb_probe(const AVProbeData *p) > if (b[++i] != last) > break; > } > - if (size > 0) { > - valid++; > - i += size; > + while (size--) { > + if (b[i]) > + valid++; > + else > + invalid++; > + i++; > } > } else { > valid = 0; > @@ -246,9 +249,12 @@ static int amrwb_probe(const AVProbeData *p) > if (b[++i] != last) > break; > } > - if (size > 0) { > - valid++; > - i += size; > + while (size--) { > + if (b[i]) > + valid++; > + else > + invalid++; > + i++; > } > } else { > valid = 0; The changes to amrwb are unneeded for the file you provided. (A "PGP Secret Sub-key" according to file.) I encoded a few amr files and "00 00" seems common and not invalid. The following works here but I believe the main issue is that our amr decoder happily decodes the "PGP Secret Sub-key" without any error messages so I wonder if the detection is wrong at all. Carl Eugen diff --git a/libavformat/amr.c b/libavformat/amr.c index 42840a50a3..2645af95c2 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -186,8 +186,18 @@ static int amrnb_probe(const AVProbeData *p) if (mode < 9 && (b[i] & 0x4) == 0x4) { int last = b[i]; int size = amrnb_packed_size[mode]; + int changes = 0, repeats = 0; while (size--) { if (b[++i] != last) + changes++; + else + repeats++; + last = b[i]; + if (repeats >= 2) { + i += size; + size = 0; + break; + } else if (changes > 4) break; } if (size > 0) { @@ -200,7 +210,7 @@ static int amrnb_probe(const AVProbeData *p) i++; } } - if (valid > 100 && valid >> 4 > invalid) + if (valid > 120 && valid >> 4 > invalid) return AVPROBE_SCORE_EXTENSION / 2 + 1; return 0; }