From patchwork Mon Nov 11 01:05:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 16199 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 BB021447CBF for ; Mon, 11 Nov 2019 03:12:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0CA268AB33; Mon, 11 Nov 2019 03:12:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6078E6883D3 for ; Mon, 11 Nov 2019 03:12:28 +0200 (EET) Received: by mail-pf1-f195.google.com with SMTP id s5so9479865pfh.9 for ; Sun, 10 Nov 2019 17:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AL8H1JbWZre3REht8PXkJW5OPgbK4cEvrKbqau81SZg=; b=aSogSbCFtuZC7K0YAdFtDiITZLUZNey/2nN+bJ5P2nQBha3zOsUm838TRPb3e0lmS+ 4p35dtno619WbYxCKfeu5LozSf5BTetzsCpopsCwvE49QW+2LKEdW8u8k5+xo6tEWbBi y0kSqseOvGEZo/X6rBnmgth++n+4BqfkG/SDzePfQimTOgGotZ6gDo9VIHZZm8GUsvkp J0bTkwL2/JfEElfRLbhP+rLxf+HagRp3d8mhj2kDDQesvfxTpKva47dN68h5kKkeJuL1 tJF5F9REHK7sTOMx6bu8aIqxcq64tgijpJMNSlUYht5pF/6dFjtL+8lqGdB8FqPl6t3i fYtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AL8H1JbWZre3REht8PXkJW5OPgbK4cEvrKbqau81SZg=; b=CFoDwVfy2DXPhs6vRDsUBhF4515pPo+SVl3IiRuhDEmVhXYcY7iPxqmgHdtMV/x+18 +1iW+UlLUTzvbVwP3NU2P20npLZ2Md8qfsAVbi5Gg7B0LgJnmjqEN+Hj+em93G+e01Ee tzrPFOBuUJy2ibKe7ORY3t2PJRcQbTQavVKMg2E9tjOOIbHs99wz5MGYBIzm63Y6mA+T s/+Wj5iH39LlXfreKvBJ7jn5FA58Yh+SD/2sxS0m2IkbVvb09cIAyYEMHTSTUJKlmrje ue87t7YnFhgpnw0IRJgTodW34dMuwVR14q/IEUBn/5umYKVinkc7NCOOfYfUELmDcp2D H98w== X-Gm-Message-State: APjAAAWR6kPObMBGXSCi0d1J/d9HT7MaWJeQ/GFXYqN1WvyrdpwFqrtK n7S58bKFfWQuolTKL7swgL52gy8g X-Google-Smtp-Source: APXvYqz5VQdFltIMzgIoWBxidsWgAK5qiNxt1L6B/rVZaNAhfXkcC0kX4uXzKl0C9fNZimnRTkxkmA== X-Received: by 2002:a17:90a:aa96:: with SMTP id l22mr29304186pjq.112.1573434308354; Sun, 10 Nov 2019 17:05:08 -0800 (PST) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id p3sm15238287pfb.163.2019.11.10.17.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Nov 2019 17:05:07 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Nov 2019 09:05:01 +0800 Message-Id: <20191111010502.1894-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [FFmpeg-devel] [PATCH v1 1/2] avformat/mp3dec: cosmetics 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- Note, the patchset are changed after applied mp3 probe fix patchset: https://patchwork.ffmpeg.org/patch/16158/ libavformat/mp3dec.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index eb40362..a047878 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -77,16 +77,16 @@ static int mp3_read_probe(const AVProbeData *p) buf0 = p->buf; end = p->buf + p->buf_size - sizeof(uint32_t); - while(buf0 < end && !*buf0) + while (buf0 < end && !*buf0) buf0++; max_frames = 0; max_framesizes = 0; buf = buf0; - for(; buf < end; buf= buf2+1) { + for (; buf < end; buf = buf2+1) { buf2 = buf; - for(framesizes = frames = 0; buf2 < end; frames++) { + for (framesizes = frames = 0; buf2 < end; frames++) { MPADecodeHeader h; int header_emu = 0; @@ -106,7 +106,7 @@ static int mp3_read_probe(const AVProbeData *p) } max_frames = FFMAX(max_frames, frames); max_framesizes = FFMAX(max_framesizes, framesizes); - if(buf == buf0) { + if (buf == buf0) { first_frames= frames; if (buf2 == end + sizeof(uint32_t)) whole_used = 1; @@ -115,14 +115,14 @@ static int mp3_read_probe(const AVProbeData *p) // keep this in sync with ac3 probe, both need to avoid // issues with MPEG-files! if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1; - else if(max_frames>200 && p->buf_size < 2*max_framesizes)return AVPROBE_SCORE_EXTENSION; - else if(max_frames>=4 && p->buf_size < 2*max_framesizes) return AVPROBE_SCORE_EXTENSION / 2; - else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size) + else if (max_frames>200 && p->buf_size < 2*max_framesizes)return AVPROBE_SCORE_EXTENSION; + else if (max_frames>=4 && p->buf_size < 2*max_framesizes) return AVPROBE_SCORE_EXTENSION / 2; + else if (ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size) return p->buf_size < PROBE_BUF_MAX ? AVPROBE_SCORE_EXTENSION / 4 : AVPROBE_SCORE_EXTENSION - 2; - else if(first_frames > 1 && whole_used) return 5; - else if(max_frames>=1 && p->buf_size < 10*max_framesizes) return 1; + else if (first_frames > 1 && whole_used) return 5; + else if (max_frames>=1 && p->buf_size < 10*max_framesizes) return 1; else return 0; -//mpegps_mp3_unrecognized_format.mpg has max_frames=3 + //mpegps_mp3_unrecognized_format.mpg has max_frames=3 } static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration) @@ -243,8 +243,8 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, avio_r8(s->pb); /* Encoder delays */ - v= avio_rb24(s->pb); - if(AV_RB32(version) == MKBETAG('L', 'A', 'M', 'E') + v = avio_rb24(s->pb); + if (AV_RB32(version) == MKBETAG('L', 'A', 'M', 'E') || AV_RB32(version) == MKBETAG('L', 'a', 'v', 'f') || AV_RB32(version) == MKBETAG('L', 'a', 'v', 'c') ) { @@ -327,7 +327,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) return ret; else if (ret == 0) vbrtag_size = c.frame_size; - if(c.layer != 3) + if (c.layer != 3) return -1; spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */ @@ -382,7 +382,7 @@ static int mp3_read_header(AVFormatContext *s) if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) ff_id3v1_read(s); - if(s->pb->seekable & AVIO_SEEKABLE_NORMAL) + if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) mp3->filesize = avio_size(s->pb); if (mp3_parse_vbr_tags(s, st, off) < 0) @@ -442,12 +442,12 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt) int ret, size; int64_t pos; - size= MP3_PACKET_SIZE; + size = MP3_PACKET_SIZE; pos = avio_tell(s->pb); - if(mp3->filesize > ID3v1_TAG_SIZE && pos < mp3->filesize) + if (mp3->filesize > ID3v1_TAG_SIZE && pos < mp3->filesize) size= FFMIN(size, mp3->filesize - pos); - ret= av_get_packet(s->pb, pkt, size); + ret = av_get_packet(s->pb, pkt, size); if (ret <= 0) { if(ret<0) return ret; @@ -502,7 +502,7 @@ static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags) #define MIN_VALID 3 best_pos = target_pos; best_score = 999; - for(i=0; i 0 ? i - SEEK_WINDOW/4 : -i); int64_t candidate = -1; int score = 999; @@ -510,9 +510,9 @@ static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags) if (pos < 0) continue; - for(j=0; jpb, pos, NULL); - if(ret < 0) { + if (ret < 0) { if (ret == CHECK_WRONG_HEADER) { break; } else if (ret == CHECK_SEEK_FAILED) {