From patchwork Wed Dec 13 19:29:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: FFmpeg Technical Committee X-Patchwork-Id: 45116 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp4501176pzf; Wed, 13 Dec 2023 11:30:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEC1YSqiAHOu0iENePJ8dkzebqqg3YYKcR3Y0OSXOFJeKStmOmkCAeRXhdIkTao4mHXUYp4 X-Received: by 2002:a17:906:f5a3:b0:a1f:5c21:a577 with SMTP id cm35-20020a170906f5a300b00a1f5c21a577mr5244145ejd.152.1702495850655; Wed, 13 Dec 2023 11:30:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702495850; cv=none; d=google.com; s=arc-20160816; b=BS2rVYc22MBbbm+aE++Di8cTvxe9H+37FmOFHNKmmN24eaV3QBmILJ/yxoIpoUyS2g HerC3z74QrsTGpQDaQQW9kTxFO3MvLfLqPQJ57RPwuky9PGwHEnfQxS5Dyb5nLjuQuMo x94pJhUo1B43EL8lHyRH7IwMcv069Tax2++1kBTeit1KmSqR3O7YHmpySXTFvHdyfciz W9hHAZY/uG7LSDWLP6PmmPBfaQcY7xnqjOL5hrQdlY/bqzYPAEW8t8FNpMG6clj3lI8z Wc+BLhRmWXdwfktNtGt5iRuteS5PCg8SwzOF1aVI3GXcEH9Wwdth8lyPo3X2MCzyuFsX ttrQ== 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=83N+u9NV/n+lSUa20mBte7inA1/ot1QeVqBxBmJB3cg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=QEaS/l/xwFq2DojU25ITboWB1p+CIM7sTGRgEYb8uOCsyv4lMqr1IErszT5SSrWj6z FtSawsU9FFVP8JCa9CyriD912K7udFSnp97OudinHU7ceRSDZlJnDRdOkTLpogh4yzIA PMXk++mS31QZOcQaC1+UvW5uizHnjIWIYBbl9lYnVeb2Bz5EicZ410gCCm01lXNZkvab WUBuzdOMLUs+evfJpByt2jxak9eRIN8lhBOcjcbjbBpyQydgpsQJJNOsVO04vqWo8Jsq dIYyrxvigNMy5Li6rDO1AN9e1+bpcxG93WeWzsdp58GtZL59XyBohJT8vD7AkvevMTqF SpZw== 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 bj4-20020a170906b04400b00a1f6129b0c4si5506412ejb.410.2023.12.13.11.30.46; Wed, 13 Dec 2023 11:30:50 -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 C4BE768D01B; Wed, 13 Dec 2023 21:30:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF60268CF9B for ; Wed, 13 Dec 2023 21:30:22 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 0F1141CCB for ; Wed, 13 Dec 2023 20:30:22 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 4euX1nmOq3fi for ; Wed, 13 Dec 2023 20:30:21 +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 mail1.khirnov.net (Postfix) with ESMTPS id 4F430163E for ; Wed, 13 Dec 2023 20:30:21 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 334803A0613 for ; Wed, 13 Dec 2023 20:30:14 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Dec 2023 20:29:59 +0100 Message-ID: <20231213193007.17471-4-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231213193007.17471-1-anton@khirnov.net> References: <20231213193007.17471-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg: move InputStream.discard to private data 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: pdGpzJtNe4qK It is not used outside of ffmpeg_demux. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_demux.c | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 63e72e4fbc..0bab44cefc 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -339,7 +339,6 @@ typedef struct InputStream { int index; AVStream *st; - int discard; /* true if stream data should be discarded */ int user_set_discard; int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ #define DECODING_FOR_OST 1 diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 61fb856106..9779580819 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -63,6 +63,9 @@ typedef struct DemuxStream { double ts_scale; + /* true if stream data should be discarded */ + int discard; + // scheduler returned EOF for this stream int finished; @@ -136,7 +139,8 @@ static Demuxer *demuxer_from_ifile(InputFile *f) InputStream *ist_find_unused(enum AVMediaType type) { for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { - if (ist->par->codec_type == type && ist->discard && + DemuxStream *ds = ds_from_ist(ist); + if (ist->par->codec_type == type && ds->discard && ist->user_set_discard != AVDISCARD_ALL) return ist; } @@ -556,11 +560,14 @@ static void discard_unused_programs(InputFile *ifile) 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) { + for (int k = 0; k < p->nb_stream_indexes; k++) { + DemuxStream *ds = ds_from_ist(ifile->streams[p->stream_index[k]]); + + if (!ds->discard) { discard = AVDISCARD_DEFAULT; break; } + } p->discard = discard; } } @@ -637,7 +644,7 @@ static void *input_thread(void *arg) dynamically in stream : we ignore them */ ds = pkt->stream_index < f->nb_streams ? ds_from_ist(f->streams[pkt->stream_index]) : NULL; - if (!ds || ds->ist.discard || ds->finished) { + if (!ds || ds->discard || ds->finished) { report_new_stream(d, pkt); av_packet_unref(pkt); continue; @@ -689,7 +696,7 @@ static void demux_final_stats(Demuxer *d) DemuxStream *ds = ds_from_ist(ist); enum AVMediaType type = ist->par->codec_type; - if (ist->discard || type == AVMEDIA_TYPE_ATTACHMENT) + if (ds->discard || type == AVMEDIA_TYPE_ATTACHMENT) continue; total_size += ds->data_size; @@ -777,8 +784,8 @@ static int ist_use(InputStream *ist, int decoding_needed) ds->sch_idx_stream = ret; } - if (ist->discard) { - ist->discard = 0; + if (ds->discard) { + ds->discard = 0; d->nb_streams_used++; } @@ -1024,7 +1031,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ist = &ds->ist; - ist->discard = 1; + ds->discard = 1; st->discard = AVDISCARD_ALL; ds->first_dts = AV_NOPTS_VALUE; ds->next_dts = AV_NOPTS_VALUE;