From patchwork Mon May 8 09:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41536 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp2180575pzb; Mon, 8 May 2023 02:19:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7f+VWtZEIJSthkhGcfYSLtMSlAyh0sNr7/rfmVG4kkKzUH+kauM7x8rlMsrvzPlAZ+cC7J X-Received: by 2002:a17:906:58d0:b0:961:8fcd:53bc with SMTP id e16-20020a17090658d000b009618fcd53bcmr8691735ejs.21.1683537546308; Mon, 08 May 2023 02:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683537546; cv=none; d=google.com; s=arc-20160816; b=eQ8T/YIZ2gy45HPSMgG1gGoFcYoEs6tkFBr+rULBMdAI/eeAJ80MTVJdA2KKQkr/BT 9aVWeq3c7koYR/whmOdMUYIk2BgWdJgAAVg/DP0OHjMZdPOHkoKs9sS223cBNL+N6KAe bIQJFBt8LGutSzv0qC8NdkcLRvfLQwX7Kz7+4eHF4gt+EG0NugcW7ZfvSh0HERyZnokk iV9GqfTPESKD8s9cMddE9naRNu6ql8R/c8qBHKlAOIciw3C8HuMqttjERro6EYwtdnvN IzOh2d4+65X2C0o6YaHYbg70neguQkaiifJd8A59Q+TxI4dBzNIuT/P7Rt/J+EqfPfRJ U2UQ== 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=HZf62voTnOPpZlzfmZ/PBCkp27M8SKph5DTMmicgMi0=; b=AGZmvre6RajYFM1jqQ/35gOqGqFx+b97oux+WCTyoKMibGo/IT3EOHDb+6+asYZ31W tpb6hBxmFS9iQmp813ZPzGmPFs6jqoxZPXxiiV5XGF9p7q1F6g+hh8L5nNiFX9plG+rD VEEAy1gsBS+LxHpDpHl1AfRDAlROHdAdgPSt23c0Jao8QcqDNlOgQ3O8Ti9pYnxMy4CT MojG7GueXcZ8uPnW1Q4ejsrmavC3nku0DXuiwWDt3EqR91LxBeVGjYqvMJ8liDWCVZj0 oQpJxfn3c+J+8IEKpjwsVq67PMxVKmcc3FT6mfAHmAJm81vLDkirss1UAiZHeBEmbTH1 nfyA== 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 c18-20020aa7c992000000b0050b8cfeecbasi626090edt.517.2023.05.08.02.19.05; Mon, 08 May 2023 02:19:06 -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 798F368C194; Mon, 8 May 2023 12:18:11 +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 ACF2268C136 for ; Mon, 8 May 2023 12:18:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id CD6432406CC for ; Mon, 8 May 2023 11:18:03 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MKpVWlxRU9Wg for ; Mon, 8 May 2023 11:18:03 +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 80FCF2406CF for ; Mon, 8 May 2023 11:17:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6E6393A048F for ; Mon, 8 May 2023 11:17:57 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 May 2023 11:17:31 +0200 Message-Id: <20230508091738.20813-15-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230508091738.20813-1-anton@khirnov.net> References: <20230508091738.20813-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/22] fftools/ffmpeg: move discarding unused programs to ffmpeg_demux 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: pRxzVU38XZCo This is a more appropriate place for this code. --- fftools/ffmpeg.c | 16 ---------------- fftools/ffmpeg_demux.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 40e97ad486..725ffca631 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1498,22 +1498,6 @@ static int transcode_init(void) { int ret = 0; - /* discard unused programs */ - for (int i = 0; i < nb_input_files; i++) { - InputFile *ifile = input_files[i]; - for (int j = 0; j < ifile->ctx->nb_programs; j++) { - AVProgram *p = ifile->ctx->programs[j]; - int discard = AVDISCARD_ALL; - - for (int k = 0; k < p->nb_stream_indexes; k++) - if (!ifile->streams[p->stream_index[k]]->discard) { - discard = AVDISCARD_DEFAULT; - break; - } - p->discard = discard; - } - } - /* dump the stream mapping */ av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1f8f3a73bd..1b268719aa 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -525,6 +525,21 @@ static void readrate_sleep(Demuxer *d) } } +static void discard_unused_programs(InputFile *ifile) +{ + for (int j = 0; j < ifile->ctx->nb_programs; j++) { + AVProgram *p = ifile->ctx->programs[j]; + int discard = AVDISCARD_ALL; + + for (int k = 0; k < p->nb_stream_indexes; k++) + if (!ifile->streams[p->stream_index[k]]->discard) { + discard = AVDISCARD_DEFAULT; + break; + } + p->discard = discard; + } +} + static void thread_set_name(InputFile *f) { char name[16]; @@ -548,6 +563,8 @@ static void *input_thread(void *arg) thread_set_name(f); + discard_unused_programs(f); + d->wallclock_start = av_gettime_relative(); while (1) {