From patchwork Wed May 17 10:20:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41686 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1080128pzb; Wed, 17 May 2023 03:25:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RKosg8PzSNn3Ef1zQ2PcmJSbL70brOhVHnK8CySNQxYfOcoEIEUfXO5nEltyDiYLWww0y X-Received: by 2002:a05:6402:704:b0:50a:276f:a3ba with SMTP id w4-20020a056402070400b0050a276fa3bamr1339739edx.34.1684319136929; Wed, 17 May 2023 03:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684319136; cv=none; d=google.com; s=arc-20160816; b=KdEzSy5Vd0BPxlFTWimU7t0F1prbhJ5PowgH+HwuLY1o40gxSeSRgR5fjNZj235QGj HEZRYI1lknMa8pGeR9YECzryx9egHr1NleeUVo9JU4rfK1vYqn5JE3GGeKsJIvxZz538 jJ4Ra7FEsdKgj/xCJ20AE2L18xUT1T+13DPXdqIRvaohCo/LQSZRjqZOZh7c65U+Ibvs NII3pn1IrM+kJKSWs4orP8ov2OQY6OweuQjmleRQnhUXWTzw85FsmXPPqcmX97dRLg3a aYyRdPfg8KJ+YThxderCZHvy3uxzZsFEmccsPGLJRh0bdEo1/RzGLCupz3H7ht4Exepp LbYg== 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=nxVljDjj4+/BRNBudKqp9/5ItxupjfpVLLlOT7MiqIA=; b=F8vlPFfJwIWdkMWkRKtFhwY7OEk6RwXmu7w+2ZfbGHgwquj5IdXyzHMnagaoOhH+1h 0Vczw1713XFJMMTle1mvOVKFiA7CQJHresltv2E/y5wb8TNx7Er6S/lGakrOEyohKfBq +wJMH/IM1E9PEm/OGaG5J0hsGyQJ/jzWdlUQ6Jm8oTjjqZvcDm7OyQH37K4bXDtl8s1D g8l0uJj6Bo3kuQjVARerL9ltX/zekZC8IbMhrWbrCq8ss5DxXuxt7RYBZoUTRnYGmQnA zZjKVT1UWPQYqtTO1pedhQqF/h035eefvcTXrAgiYPPTVip4KagIdbHfBC+5DqgD0piD tOOg== 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 h2-20020aa7c602000000b0050c0e683b3bsi14420294edq.98.2023.05.17.03.25.36; Wed, 17 May 2023 03:25:36 -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 E0F4068C1FE; Wed, 17 May 2023 13:21:24 +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 8FA1668C189 for ; Wed, 17 May 2023 13:21:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 494AC240177 for ; Wed, 17 May 2023 12:21:01 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id f2QSanyryfH8 for ; Wed, 17 May 2023 12:20:59 +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 6131B240D22 for ; Wed, 17 May 2023 12:20:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 265D23A1858 for ; Wed, 17 May 2023 12:20:40 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:20:10 +0200 Message-Id: <20230517102029.541-17-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/36] fftools/ffmpeg_filter: move InputFilter.ist 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: mJoLXX0Yxm4W It is not accessed outside of ffmpeg_filter. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 34 +++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9cb9f35bc2..c33e537faa 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -279,7 +279,6 @@ typedef struct OptionsContext { typedef struct InputFilter { AVFilterContext *filter; - struct InputStream *ist; struct FilterGraph *graph; uint8_t *name; enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 16f29a313f..e6e9e00985 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -55,6 +55,8 @@ static FilterGraphPriv *fgp_from_fg(FilterGraph *fg) typedef struct InputFilterPriv { InputFilter ifilter; + InputStream *ist; + // used to hold submitted input AVFrame *frame; @@ -247,7 +249,7 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return ofilter; } -static InputFilter *ifilter_alloc(FilterGraph *fg) +static InputFilter *ifilter_alloc(FilterGraph *fg, InputStream *ist) { InputFilterPriv *ifp = allocate_array_elem(&fg->inputs, sizeof(*ifp), &fg->nb_inputs); @@ -261,6 +263,7 @@ static InputFilter *ifilter_alloc(FilterGraph *fg) ifp->format = -1; ifp->fallback.format = -1; + ifp->ist = ist; ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifp->frame_queue) @@ -282,7 +285,7 @@ void fg_free(FilterGraph **pfg) for (int j = 0; j < fg->nb_inputs; j++) { InputFilter *ifilter = fg->inputs[j]; InputFilterPriv *ifp = ifp_from_ifilter(ifilter); - struct InputStream *ist = ifilter->ist; + InputStream *ist = ifp->ist; if (ifp->frame_queue) { AVFrame *frame; @@ -354,8 +357,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) ost->filter = ofilter; - ifilter = ifilter_alloc(fg); - ifilter->ist = ist; + ifilter = ifilter_alloc(fg, ist); ret = ist_filter_add(ist, ifilter, 1); if (ret < 0) @@ -437,8 +439,8 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) } av_assert0(ist); - ifilter = ifilter_alloc(fg); - ifilter->ist = ist; + ifilter = ifilter_alloc(fg, ist); + ifilter->type = ist->st->codecpar->codec_type; ifilter->name = describe_filter_link(fg, in, 1); @@ -1019,7 +1021,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterContext *last_filter; const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); const AVPixFmtDescriptor *desc; - InputStream *ist = ifilter->ist; + InputStream *ist = ifp->ist; InputFile *f = input_files[ist->file_index]; AVRational fr = ist->framerate; AVRational sar; @@ -1145,7 +1147,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, InputFilterPriv *ifp = ifp_from_ifilter(ifilter); AVFilterContext *last_filter; const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer"); - InputStream *ist = ifilter->ist; + InputStream *ist = ifp->ist; InputFile *f = input_files[ist->file_index]; AVBPrint args; char name[255]; @@ -1380,7 +1382,7 @@ int configure_filtergraph(FilterGraph *fg) /* process queued up subtitle packets */ for (i = 0; i < fg->nb_inputs; i++) { - InputStream *ist = fg->inputs[i]->ist; + InputStream *ist = ifp_from_ifilter(fg->inputs[i])->ist; if (ist->sub2video.sub_queue && ist->sub2video.frame) { AVSubtitle tmp; while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) { @@ -1561,7 +1563,9 @@ int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb) } if (ifp->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) { - av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index); + av_log(NULL, AV_LOG_ERROR, + "Cannot determine format of input stream %d:%d after EOF\n", + ifp->ist->file_index, ifp->ist->st->index); return AVERROR_INVALIDDATA; } } @@ -1579,7 +1583,7 @@ int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) /* determine if the parameters for this input changed */ need_reinit = ifp->format != frame->format; - switch (ifilter->ist->par->codec_type) { + switch (ifp->ist->par->codec_type) { case AVMEDIA_TYPE_AUDIO: need_reinit |= ifp->sample_rate != frame->sample_rate || av_channel_layout_compare(&ifp->ch_layout, &frame->ch_layout); @@ -1590,7 +1594,7 @@ int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) break; } - if (!ifilter->ist->reinit_filters && fg->graph) + if (!ifp->ist->reinit_filters && fg->graph) need_reinit = 0; if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx || @@ -1686,8 +1690,8 @@ int fg_transcode_step(FilterGraph *graph, InputStream **best_ist) for (int i = 0; i < graph->nb_inputs; i++) { InputFilter *ifilter = graph->inputs[i]; InputFilterPriv *ifp = ifp_from_ifilter(ifilter); - if (!ifilter->ist->got_output && !ifp->eof) { - *best_ist = ifilter->ist; + if (!ifp->ist->got_output && !ifp->eof) { + *best_ist = ifp->ist; return 0; } } @@ -1717,7 +1721,7 @@ int fg_transcode_step(FilterGraph *graph, InputStream **best_ist) InputFilter *ifilter = graph->inputs[i]; InputFilterPriv *ifp = ifp_from_ifilter(ifilter); - ist = ifilter->ist; + ist = ifp->ist; if (input_files[ist->file_index]->eagain || ifp->eof) continue; nb_requests = av_buffersrc_get_nb_failed_requests(ifilter->filter);