From patchwork Thu Apr 13 14:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41159 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1289814pzb; Thu, 13 Apr 2023 07:19:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZEWT/06uLx09/i4a3GaNuWOpqb622kWlpTasV7Oh6IHbdSXnG1RGsHFz45R4nI323uI7XT X-Received: by 2002:a17:906:49d9:b0:94a:4c55:e714 with SMTP id w25-20020a17090649d900b0094a4c55e714mr2495655ejv.76.1681395584302; Thu, 13 Apr 2023 07:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681395584; cv=none; d=google.com; s=arc-20160816; b=DXE14UOgVsdHW+dDNAcZ59feTb4qqpQOKTIe02XUGxtj1+Z8ISQ+5Uomuc9VLs0Ko5 N3sRdyWsKt7HgG26/60HP3kdmj1R/CC9IV6L+XT8skeV2ka+330WxTuNeklN8pz/nEwK FpdWfWxyM5ygK3HHCNpva51Bp4A4LKW1/3Z5SmlIHwnGX+Gwn4dZTc0uJkIwCqUJqSUJ t1DeLGa4nOWXtkhWlvBworyaBx4vHd5zkRFTzh0N4loH8D0gbicgqu5Wrz+p0jvGjPT4 jijEScX/Mu8KmaRZ6MKfPvO0qW3qpQOispeP3lnn8S3YDc66JJAFDqRxwapK+c+BsDXy +bIg== 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=4kikUTkZpkl0Rs6ISoW/JdEQy/76E+xeHH2Z7Ph+AFI=; b=wyUtsrN82MftNXbK9GTYenL4YpGJyixzb3XBrD0i44pAoc5bPOL0ZzOOS3klx9qSJT CTQ/v2WCRRSgKvm1ajgqyZQEG+Wr0/vjzWOoFPEotd6Ydhb7mWTrUb0obNG56xwKT+V8 VC/C1laqMQgkVOV4g6IBeNoQRpTv3G2U2GJi6o27f6+FR9InlKgxeCZMuNilIoqDeeID BgiZbjhGAoRUDhGF0BxN3AifWIp+L5SeNZrYJCBmYkqHr1qlNJvpw4Yy1JM93G1kNVXg FhtjVHuPvaC7w3jP+Lj86+7DV90ArJGWp1x313LLviaLh8ymlST+V0PDuS4sg5c7P+27 rvVQ== 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 wl24-20020a170907311800b0094e987b24b1si1701944ejb.1008.2023.04.13.07.19.43; Thu, 13 Apr 2023 07:19:44 -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 ED13668BEE6; Thu, 13 Apr 2023 17:16:16 +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 47E5868BE34 for ; Thu, 13 Apr 2023 17:16:00 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A979C2405F9 for ; Thu, 13 Apr 2023 16:15:58 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pqzQ1cz7meHK for ; Thu, 13 Apr 2023 16:15:57 +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 4A61A2406CA for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3BAAA3A03E5 for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:08 +0200 Message-Id: <20230413141223.17245-10-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/25] fftools/ffmpeg: stop setting InputStream fields from muxing/filtering code 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: vlIThfZOWQ5v Set InputStream.decoding_needed/discard/etc. only from ist_{filter,output},add() functions. Reduces the knowledge of InputStream internals in muxing/filtering code. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_demux.c | 13 ++++++++++++- fftools/ffmpeg_filter.c | 8 ++------ fftools/ffmpeg_mux_init.c | 6 ------ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d25377514e..c73fc8a459 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -880,7 +880,7 @@ void ifile_close(InputFile **f); int ifile_get_packet(InputFile *f, AVPacket **pkt); void ist_output_add(InputStream *ist, OutputStream *ost); -void ist_filter_add(InputStream *ist, InputFilter *ifilter); +void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple); /* iterate over all input streams in all input files; * pass NULL to start iteration */ diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 2d46dbf876..d15a714e90 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -561,14 +561,25 @@ void ifile_close(InputFile **pf) av_freep(pf); } +static void ist_use(InputStream *ist, int decoding_needed) +{ + ist->discard = 0; + ist->st->discard = ist->user_set_discard; + ist->decoding_needed |= decoding_needed; +} + void ist_output_add(InputStream *ist, OutputStream *ost) { + ist_use(ist, ost->enc ? DECODING_FOR_OST : 0); + GROW_ARRAY(ist->outputs, ist->nb_outputs); ist->outputs[ist->nb_outputs - 1] = ost; } -void ist_filter_add(InputStream *ist, InputFilter *ifilter) +void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple) { + ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER); + GROW_ARRAY(ist->filters, ist->nb_filters); ist->filters[ist->nb_filters - 1] = ifilter; } diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d2a185cf98..1d88d2e3b1 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -215,7 +215,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) GROW_ARRAY(filtergraphs, nb_filtergraphs); filtergraphs[nb_filtergraphs - 1] = fg; - ist_filter_add(ist, ifilter); + ist_filter_add(ist, ifilter, 1); return 0; } @@ -303,10 +303,6 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) } av_assert0(ist); - ist->discard = 0; - ist->decoding_needed |= DECODING_FOR_FILTER; - ist->st->discard = AVDISCARD_NONE; - ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); ifilter->ist = ist; ifilter->graph = fg; @@ -318,7 +314,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) if (!ifilter->frame_queue) report_and_exit(AVERROR(ENOMEM)); - ist_filter_add(ist, ifilter); + ist_filter_add(ist, ifilter, 0); } static int read_binary(const char *path, uint8_t **data, int *len) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index dc1dd834e0..e3d8f5e386 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1215,12 +1215,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, } if (ost->ist) { - ost->ist->discard = 0; - ost->ist->st->discard = ost->ist->user_set_discard; - - if (ost->enc) - ost->ist->decoding_needed |= DECODING_FOR_OST; - if (ost->enc && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { ret = init_simple_filtergraph(ost->ist, ost);