From patchwork Sat Jul 23 14:09:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36931 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a9d:f07:0:b0:61c:acf1:bf6b with SMTP id 7csp644890ott; Sat, 23 Jul 2022 07:14:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s8xxx18fNnqXq15EenypOp4WnjxD34nHuNra3IXucyA+GhMn0jDfLLYjrhd/pQejQ+h77k X-Received: by 2002:a17:906:3f51:b0:712:3945:8c0d with SMTP id f17-20020a1709063f5100b0071239458c0dmr3547865ejj.302.1658585661796; Sat, 23 Jul 2022 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658585661; cv=none; d=google.com; s=arc-20160816; b=NkrDky6zTl7+Tp+bNeCCTuSsoZNRuQBqgY4iQ01v2zbLIafpKYKOvAzfRq6557S3dJ ucNykB9jX03TdR1kK9wfkyvjYtQI0EmD+gytRsZA+QAqNUCGE/9+gVyb2CqJwMMnTEfc 1l+qMtjq+rMBD/DWs7iLP9aCBZttb1ki1I33bjsm0uNXnRd47o46a2bm4jFgKDXuB6Tf OWqYStrrl1p/QFOKDoJcIgcM9If5+It4xHfbC6taOiwOrks2S/OWAIifkFsDty4wEg9w KJhTylaJ58bfDux1TfjIYVPTdTDmmJ28Q6nVsWQzqWTErRbNtJN1i8BcbMixkHitmYLl Fd8w== 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=tTqJt57s8HQK+d7O9ATUxfEXh5XTVmqg3T1/efYICAQ=; b=Sd541ceX/HJUMKV83fxAkTHBJzEUKbUBM233Tm1NP1UIrUPbJGA/tUShf1ySYSCzAl gv3oOQ3vzj8GlSAaM0HAW48VfM8hbnyVsH9LmttaFuWfKmXCW+E7pDKV7TXvtPegMOOT u7wm5PVno7AZON6IBdOXT9goQ9BY3mqw0yZlLCpMKGdIi2WstPOGvUU1m8GSNIuLf2Y6 MTfl13NPb8UUECVSkmiNCGr9Us+/9xi1Cnz62/9kt7ieCRTwG3T3IHkZYMNgfBxQ+RWg bOxvTQikKsE1YZ4+Fhgrnw9ZXsu71HOp3Iz7UL7ZdPn5tBZReR2fqJpUULVCLjyUxHOs 0YYA== 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 ev7-20020a17090729c700b00726d6cb0258si7346161ejc.263.2022.07.23.07.14.21; Sat, 23 Jul 2022 07:14:21 -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 C719F68B90A; Sat, 23 Jul 2022 17:10:52 +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 941E468B852 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6EA3B24055A for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wAa-dNCpCASO for ; Sat, 23 Jul 2022 16:10:23 +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 8DC8224052D for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id A48123A04EA; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:44 +0200 Message-Id: <20220723140952.31814-19-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 19/27] fftools/ffmpeg_opt: reduce indentation in map_auto_video() 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: Pvca2ilc/rQ+ Content-Length: 4925 Fix indentation after the previous commit. Also use an early return to save one extra indentation level. --- fftools/ffmpeg_opt.c | 72 +++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 4d2cd13107..9b08c68ec5 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2499,44 +2499,46 @@ static void map_auto_video(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { InputStream *ist; + int best_score = 0, idx = -1; + int qcr; - /* video: highest resolution */ - if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_VIDEO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - int qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); - 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->width * ist->st->codecpar->height - + 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((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - score = 1; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - score > file_best_score) { - if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - continue; - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - 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; - } - } + /* video: highest resolution */ + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_VIDEO) == AV_CODEC_ID_NONE) + return; + + qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0); + 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->width * ist->st->codecpar->height + + 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((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + score = 1; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && + score > file_best_score) { + if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + continue; + file_best_score = score; + file_best_idx = ifile->ist_index + i; } - if (idx >= 0) - new_video_stream(o, oc, idx); } + if (file_best_idx >= 0) { + if((qcr == MKTAG('A', 'P', 'I', 'C')) || !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + 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_video_stream(o, oc, idx); } static int open_output_file(OptionsContext *o, const char *filename)