From patchwork Thu Nov 7 21:25:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 16157 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 93DF244A5E3 for ; Thu, 7 Nov 2019 23:34:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E1EE68AD52; Thu, 7 Nov 2019 23:34:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7833868ACC7 for ; Thu, 7 Nov 2019 23:34:30 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1iSpJq-0008zp-0C for ffmpeg-devel@ffmpeg.org; Thu, 07 Nov 2019 22:27:54 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id SpIsiHS5TwlysSpIsi9fT7; Thu, 07 Nov 2019 22:26:54 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=E5OzWpVl c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=pGLkceISAAAA:8 a=LybwiCErvUR2Nm07cpIA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 7 Nov 2019 22:25:32 +0100 Message-Id: <20191107212532.22861-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191107212532.22861-1-michael@niedermayer.cc> References: <20191107212532.22861-1-michael@niedermayer.cc> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfAZlhTQMPIvwidBUsST5MXQn4/p4LFBLHCeNssiTeO++9yxRW3g4vQ3J1urDJXJ0mvbd7bTwQL+tmacX+u6CchpCUAUB3i1dIPFYi/PrKX9sCzjJu5kp kjqzngdHKjTtCXNLQ2STBIXWxV1nn/tyreXURXjZtJkxmfH9oeDJwtXpUrbzxkon68P2wBqVSSZe59zJP8ZQjSSsSSBsfHwIO7A= Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mp3dec: Check for occurances of headers within frames during probing 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 Cc: Limin Wang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Fixes misdetection of zYLx.wav Co-Author: Michael Niedermayer Signed-off-by: Michael Niedermayer --- libavformat/mp3dec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 6848415657..eb40362548 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -73,7 +73,7 @@ static int mp3_read_probe(const AVProbeData *p) int frames, ret; int framesizes, max_framesizes; uint32_t header; - const uint8_t *buf, *buf0, *buf2, *end; + const uint8_t *buf, *buf0, *buf2, *buf3, *end; buf0 = p->buf; end = p->buf + p->buf_size - sizeof(uint32_t); @@ -88,11 +88,19 @@ static int mp3_read_probe(const AVProbeData *p) buf2 = buf; for(framesizes = frames = 0; buf2 < end; frames++) { MPADecodeHeader h; + int header_emu = 0; header = AV_RB32(buf2); ret = avpriv_mpegaudio_decode_header(&h, header); if (ret != 0 || end - buf2 < h.frame_size) break; + + for (buf3 = buf2 + 4; buf3 < buf2 + h.frame_size; buf3++) { + uint32_t next_sync = AV_RB32(buf3); + header_emu += (next_sync & MP3_MASK) == (header & MP3_MASK); + } + if (header_emu > 2) + break; buf2 += h.frame_size; framesizes += h.frame_size; }