From patchwork Sun May 28 09:13:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41852 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp987074pzb; Sun, 28 May 2023 02:15:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5k9jjR12GUkaQcM6J4dmH3jMenTl3H10LNNRjPobd3I+XKCwwMeSQkFUm/+tzw4rbTPPr4 X-Received: by 2002:a17:907:26c3:b0:969:e9ec:9a0 with SMTP id bp3-20020a17090726c300b00969e9ec09a0mr6802606ejc.77.1685265324311; Sun, 28 May 2023 02:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685265324; cv=none; d=google.com; s=arc-20160816; b=BOparcvHm/Z4/5RGui6QEx91UOZPFwQ4fSUHMkslbVW31fVACncP0COmZB6lzWqJKY dyI+bAIQFvTRZE2cr2J7QgOWct4snnLnQkBVtDsw5I4iqNCbMIWWTB9I3x2vbAxh7tPu df5YG5nAY8YFB9xPjNcjxgwOQjOnYC9OuHegvk8wbAsbktXz2DKLsfM+wNxBnXtS69DU IeBZorJM9l8ppStSm2GXALvmumHNIV7Vdo6aMHt7I8M74hsT5LuROIfIeipH9QOKzM4K YBgyf0cwIxXEVN21datmOptvMIgXUqEWuusoJahna6FRq+ndeojPO/FeiLqz4fu2vZcL mRGQ== 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=PuPZzwKXi6vFzIOI/43mV/yoyWmIDfhXQbigz6Wp64k=; b=t1CVPUG9g3gwP1pEJanW6+h+oDslpFpiz17paB/Tq+ubODYFAANzpHAqfnOfjMXEy/ koR+rHOukm0w9545zp/ZieaXo2cf01pbzHztVlpgTvRLRQ3lo95aikLNmrlZD5Iu5qBD V92HH/h8bypvnnlrQW4CYrGnz6kl4JUvUgBdWA9i+8xX1PUWCMwZLbwJdpBwmWU+FLUI 6jZBjRtp4BKsf1zWtBZrpvOfcA9yLayBb7Hvm3V67Acw0vcBlYjwVcgGSpjNIkFe0j64 YsGhfnnmFdBqh0Ij+mcyE7CwzewN0cKPzGjQlmOCgMbZ8Da2FN31JBczfJRnhab2TLte 1MXw== 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 w18-20020a170906131200b009537f63f002si3813093ejb.779.2023.05.28.02.15.23; Sun, 28 May 2023 02:15:24 -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 5F32168C212; Sun, 28 May 2023 12:14:58 +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 9279868C1DE for ; Sun, 28 May 2023 12:14:49 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5B4EE240591 for ; Sun, 28 May 2023 11:14:49 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id OhJQYJhwyMUl for ; Sun, 28 May 2023 11:14:48 +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 7CECE2404F5 for ; Sun, 28 May 2023 11:14:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 34C123A0570 for ; Sun, 28 May 2023 11:14:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 May 2023 11:13:56 +0200 Message-Id: <20230528091416.17927-4-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528091416.17927-1-anton@khirnov.net> References: <20230528091416.17927-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/24] fftools/ffmpeg_filter: always pass graph description to fg_create() 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: /pn1aTlpifYU Currently NULL would be passed for simple filtergraphs, which would make the filter code extract the graph description from the output stream when needed. This is unnecessarily convoluted. --- fftools/ffmpeg.h | 4 ++-- fftools/ffmpeg_filter.c | 8 ++++---- fftools/ffmpeg_mux.c | 1 - fftools/ffmpeg_mux_init.c | 16 ++++++++-------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 95334825ef..1bb9125bf2 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -590,7 +590,6 @@ typedef struct OutputStream { FILE *logfile; OutputFilter *filter; - char *avfilter; AVDictionary *encoder_opts; AVDictionary *sws_dict; @@ -737,7 +736,8 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id int configure_filtergraph(FilterGraph *fg); void check_filter_outputs(void); int filtergraph_is_simple(FilterGraph *fg); -int init_simple_filtergraph(InputStream *ist, OutputStream *ost); +int init_simple_filtergraph(InputStream *ist, OutputStream *ost, + char *graph_desc); int init_complex_filtergraph(FilterGraph *fg); void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index e11ae2e9bf..75317139ba 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -352,7 +352,8 @@ FilterGraph *fg_create(char *graph_desc) return fg; } -int init_simple_filtergraph(InputStream *ist, OutputStream *ost) +int init_simple_filtergraph(InputStream *ist, OutputStream *ost, + char *graph_desc) { FilterGraph *fg; FilterGraphPriv *fgp; @@ -360,7 +361,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) InputFilter *ifilter; int ret; - fg = fg_create(NULL); + fg = fg_create(graph_desc); if (!fg) report_and_exit(AVERROR(ENOMEM)); fgp = fgp_from_fg(fg); @@ -1263,8 +1264,7 @@ int configure_filtergraph(FilterGraph *fg) AVBufferRef *hw_device; AVFilterInOut *inputs, *outputs, *cur; int ret, i, simple = filtergraph_is_simple(fg); - const char *graph_desc = simple ? fg->outputs[0]->ost->avfilter : - fgp->graph_desc; + const char *graph_desc = fgp->graph_desc; cleanup_filtergraph(fg); if (!(fg->graph = avfilter_graph_alloc())) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 36ed482072..3da3c04d7f 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -853,7 +853,6 @@ static void ost_free(OutputStream **post) av_freep(&ost->kf.pts); av_expr_free(ost->kf.pexpr); - av_freep(&ost->avfilter); av_freep(&ost->logfile_prefix); av_freep(&ost->apad); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 033e55d76e..1c97804ec8 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -432,7 +432,7 @@ static MuxStream *mux_stream_alloc(Muxer *mux, enum AVMediaType type) } static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, - OutputStream *ost) + OutputStream *ost, char **dst) { const char *filters = NULL, *filters_script = NULL; @@ -470,12 +470,12 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc, } if (filters_script) - ost->avfilter = file_read(filters_script); + *dst = file_read(filters_script); else if (filters) - ost->avfilter = av_strdup(filters); + *dst = av_strdup(filters); else - ost->avfilter = av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); - return ost->avfilter ? 0 : AVERROR(ENOMEM); + *dst = av_strdup(ost->type == AVMEDIA_TYPE_VIDEO ? "null" : "anull"); + return *dst ? 0 : AVERROR(ENOMEM); } static void parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str) @@ -995,7 +995,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, AVStream *st = avformat_new_stream(oc, NULL); int ret = 0; const char *bsfs = NULL, *time_base = NULL; - char *next, *codec_tag = NULL; + char *filters = NULL, *next, *codec_tag = NULL; double qscale = -1; int i; @@ -1250,7 +1250,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, } if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) { - ret = ost_get_filters(o, oc, ost); + ret = ost_get_filters(o, oc, ost, &filters); if (ret < 0) exit_program(1); } @@ -1262,7 +1262,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o, ofilter->ost = ost; avfilter_inout_free(&ofilter->out_tmp); } else { - ret = init_simple_filtergraph(ost->ist, ost); + ret = init_simple_filtergraph(ost->ist, ost, filters); if (ret < 0) { av_log(ost, AV_LOG_ERROR, "Error initializing a simple filtergraph\n");