From patchwork Sat Jul 23 14:09:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36917 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp1047770pzb; Sat, 23 Jul 2022 07:13:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8UuNjHmSBedeQdUUKGO7rP4hmN7f7lIo9e1t0ncySyt9RYVlRmWihHZr/g38o82QYpIXK X-Received: by 2002:a05:6402:3685:b0:43b:dfd3:9487 with SMTP id ej5-20020a056402368500b0043bdfd39487mr2709917edb.32.1658585583684; Sat, 23 Jul 2022 07:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585583; cv=none; d=google.com; s=arc-20160816; b=AWIreAsL/UCyfVmbSkCCxLg64QWoCmsaqP2iZMW/cH0ATSqNnJOAgatVpZG5HsWQ/3 FFkxRo1qo4LB/30xI6tlrHxNFDBPke0hX35pqxI/aFneE0bkmh1+3xKpk535V4U/VG6i or4Jpsb+E8Ltb5ZBC9oFx5H2AkhBpZnGGgHtCV5gJfG1zZvrvcLo/tdB0cmAl3+sF2wf CeEyz9RoFjV19F3f9X7Ay+F/1LHq9se7DKoTbD6OHmWkCe1FlbFg8ENs1Q5Qi8V1tlHd +oXv+6b6e0vEMPZBFiJ+6sVsCY7Ktu+xpNA2QIHLv3wFmzNCsp9FNWHK68aitYage0// kJkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=1kr+ebT9aatdPg+7lECLFYH7npNSfpNzkmlXeWp/RBw=; b=PrxFFSBNHFm008Suz7r2fc1lPPWoRo67n2DAwVMTjLUFJ10ABtkCYp5eIBeuDPqJlg aZCbNZlQRKRUr6eLMWekyGT/hmirGE2ceUQGw56Nz1O5/WRdJmx0ySLsWZfrdHmQA9xG LrcL5z+piXjsAx27rek6luTdnPnO5nZLQkqqTv5514x5Gtcvmw98me2ki+tcFtkQeuuU noB4kVchn4Qrs6Ytw4H3R1h7Ml9hr8L57eZNTS7QIlAHRjUw2VkhCYz9Xwyi0hIXNSCU AkMj+iFpYP0/1VjN8bNhKYy64Qju5OGxnW1WG2WXK3kGpxySx3Oq/iikrJBOTlg8Ug3w KaYw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y37-20020a50bb28000000b0043bbe1d01e2si9852683ede.410.2022.07.23.07.13.03; Sat, 23 Jul 2022 07:13:03 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6709168B7DF; Sat, 23 Jul 2022 17:10:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0FF068B72C for ; Sat, 23 Jul 2022 17:10:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2BAB6240590 for ; Sat, 23 Jul 2022 16:10:28 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id cmS6qViKysam for ; Sat, 23 Jul 2022 16:10:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id CA49B24068F for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id ADEAB3A0232; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:46 +0200 Message-Id: <20220723140952.31814-21-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220723140952.31814-1-anton@khirnov.net> References: <20220723140952.31814-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/27] fftools/ffmpeg_opt: reduce indentation in map_auto_audio() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: ltQEsHVvI8KU Fix indentation after the previous commit. Also use an early return to save one extra indentation level. --- fftools/ffmpeg_opt.c | 57 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index e426768f7c..174b1dd0eb 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2545,38 +2545,39 @@ static void map_auto_audio(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { InputStream *ist; + int best_score = 0, idx = -1; /* audio: most channels */ - if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - for (int j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (int i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->ch_layout.nb_channels - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && - score > file_best_score) { - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) == AV_CODEC_ID_NONE) + return; + + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->ch_layout.nb_channels + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + score > file_best_score) { + file_best_score = score; + file_best_idx = ifile->ist_index + i; } - if (idx >= 0) - new_audio_stream(o, oc, idx); } + if (file_best_idx >= 0) { + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_audio_stream(o, oc, idx); } static int open_output_file(OptionsContext *o, const char *filename)