From patchwork Thu Nov 17 10:16:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39313 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp997320pzb; Thu, 17 Nov 2022 02:17:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YpEev7kpD5/w1a2aKQN61V6Z5osJJRM7mKgXU+KFe2cFpjWcL+iUM8/OuTMRTaFWCi49C X-Received: by 2002:a17:906:398b:b0:7ad:b868:f096 with SMTP id h11-20020a170906398b00b007adb868f096mr1567071eje.295.1668680241044; Thu, 17 Nov 2022 02:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668680241; cv=none; d=google.com; s=arc-20160816; b=BpGmmQbFFCcSdT9v8Yn4vbL1kMlaS5mFyY8jxEKheRCX0LGpGU7394/KbXwEzTZZd2 TKKDlce0ClLcusS0qjt/H2AIFu5Bwv/LyadXy1ZVFRRuPV5CFGQQVOHwHEUFtkfxKXKY uBt8B3Q5nyhyw3gzXsrbGL9HY1jTsDEz1/HBgVuiSdtJliks1dQKFdsANQyzwVs4upe5 3HVqujy/HJv0aEE/dzmOIKuOWW8eqAxe/O4u2spVvUccCVmX507xV5/R8ZCuhadtZyRT mFcrCmpwk2dHC9kQpQz2hq+o28RAxx4IY+ReCPNGjo6WvfqiVDuh5lh/bQ0byU5wtItA FuqA== 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=P229JHkDMWJ620qaNqsgg6KpdxIglJF3+snHP25nKqA=; b=Gl2QjCNGsxypMrLgQkaFRnISRl3JCPI4OSwJ2i7lbcqZCSFea2g8QHdARHI8fb3w5X N2PcLn648GLPfLswAHTtyAQy3crHqvqBUX3QD54IBnaqQZse3Mo3y/TDTbSWvLlfHA4d fQmFUz6tX9WTx39OU9gjnCNLI0z8r8rrOjdUfl1+5oak7IdODYvwROvOzzBHcmdsEoV7 W4CKbazhcWg5vBz2n8LgDhpHtBNMhXe+oLWoFUu1sV5S6VvtNMzuIW1wwQor1O+4Nugs 4egjuWU8CQRwi7eORR1N7OEItfankj3S8ALP0w+EFfgMm95nXLY3aaWyAzhr612MvW/8 zkKQ== 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 o3-20020a170906974300b007811ace1701si276743ejy.445.2022.11.17.02.17.20; Thu, 17 Nov 2022 02:17:21 -0800 (PST) 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 7B85D68BD36; Thu, 17 Nov 2022 12:16:54 +0200 (EET) 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 D271968BCBB for ; Thu, 17 Nov 2022 12:16:45 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 95BDC2400F5 for ; Thu, 17 Nov 2022 11:16:45 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1NTzJxT-xsm9 for ; Thu, 17 Nov 2022 11:16:45 +0100 (CET) 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 587A42405F9 for ; Thu, 17 Nov 2022 11:16:43 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 242BD3A058F for ; Thu, 17 Nov 2022 11:16:43 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:16:35 +0100 Message-Id: <20221117101640.6789-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117101640.6789-1-anton@khirnov.net> References: <20221117101640.6789-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_mux_init: simplify inner loop in map_auto_{video, 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: 7/8aThZLPMSp Skip unusable streams early and do not compute any scores for them. --- fftools/ffmpeg_mux_init.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index e460e7603f..6db70cc852 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -869,15 +869,18 @@ static void map_auto_video(Muxer *mux, const OptionsContext *o) for (int i = 0; i < ifile->nb_streams; i++) { int score; ist = input_streams[ifile->ist_index + i]; + + if (ist->user_set_discard == AVDISCARD_ALL || + ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) + continue; + 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 (score > file_best_score) { if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) continue; file_best_score = score; @@ -913,13 +916,15 @@ static void map_auto_audio(Muxer *mux, const OptionsContext *o) for (int i = 0; i < ifile->nb_streams; i++) { int score; ist = input_streams[ifile->ist_index + i]; + + if (ist->user_set_discard == AVDISCARD_ALL || + ist->st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) + continue; + 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) { + if (score > file_best_score) { file_best_score = score; file_best_idx = ifile->ist_index + i; }