From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2C83148663 for ; Wed, 14 Feb 2024 18:24:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8A9F368D219; Wed, 14 Feb 2024 20:24:48 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D098668C92E for ; Wed, 14 Feb 2024 20:24:41 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=C3Ts5Uc0; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id F3F084D38 for ; Wed, 14 Feb 2024 19:24:40 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Yegy8Q93sf-W for ; Wed, 14 Feb 2024 19:24:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1707935078; bh=M9nvJVVY+I19UcbZ7lWrftwYTbrpAijkdqLOW5qtN3g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=C3Ts5Uc0AvFd1c+kAO7vOD5NF8elQnKZuBeHMFUVQWSmMrmx8fGdLXrDGCAO/mQHE wZq6K9J/vKLQzD6NC2jWSJqnZ4ScKecNc3ohreltKjNOPdHbhq9tknXQOQ0y5hpH8P +0DkTdy9jZqZ3u627la8ZUVli5L6oW8D5WAYg3vqrFKgG2j97iAeArGAhB7CgliOp5 BB6ADQsF8De5s2wR0R6aEo4oXnxKPnqn15wEEhN3ebKJapT5uClYw3cdegNyFzInZa OuHt/1pyOwr6/HNpAtlmr24tI5PKWB8XzuJY2FaptUjPF0mio7UFyw7PUE4itXY0vv 0cqWcsShVOlgA== 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 7E45F448E for ; Wed, 14 Feb 2024 19:24:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 69C433A218D for ; Wed, 14 Feb 2024 19:24:38 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Feb 2024 19:24:28 +0100 Message-ID: <20240214182435.31380-3-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240214182435.31380-1-anton@khirnov.net> References: <20240214182435.31380-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Do not construct the name manually from input file/stream indices. This is a step towards avoiding the assumption that filtergraph inputs are always fed by demuxers. --- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_demux.c | 4 ++++ fftools/ffmpeg_filter.c | 21 ++++++++------------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index cbc5413238..2c1ad714b6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -253,6 +253,8 @@ typedef struct OptionsContext { typedef struct InputFilterOptions { int64_t trim_start_us; int64_t trim_end_us; + + uint8_t *name; } InputFilterOptions; typedef struct InputFilter { diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index abda4ad0d9..4cbad80e17 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1009,6 +1009,10 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, AV_NOPTS_VALUE : tsoffset; opts->trim_end_us = d->recording_time; + opts->name = av_strdup(ds->dec_name); + if (!opts->name) + return AVERROR(ENOMEM); + return ds->sch_idx_dec; } diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c411b882de..0f57035104 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -889,6 +889,7 @@ void fg_free(FilterGraph **pfg) av_buffer_unref(&ifp->hw_frames_ctx); av_freep(&ifp->linklabel); + av_freep(&ifp->opts.name); av_freep(&ifilter->name); av_freep(&fg->inputs[j]); } @@ -1475,7 +1476,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, const AVFilter *buffer_filt = avfilter_get_by_name("buffer"); const AVPixFmtDescriptor *desc; InputStream *ist = ifp->ist; - InputFile *f = ist->file; AVRational fr = ist->framerate; AVRational sar; AVBPrint args; @@ -1506,8 +1506,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, ifp->color_space, ifp->color_range); if (fr.num && fr.den) av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den); - snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, - f->index, ist->index); + snprintf(name, sizeof(name), "graph %d input from stream %s", fg->index, + ifp->opts.name); if ((ret = avfilter_graph_create_filter(&ifp->filter, buffer_filt, name, @@ -1558,8 +1558,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, return ret; } - snprintf(name, sizeof(name), "trim_in_%d_%d", - f->index, ist->index); + snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name); ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us, &last_filter, &pad_idx, name); if (ret < 0) @@ -1580,8 +1579,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilterPriv *ifp = ifp_from_ifilter(ifilter); AVFilterContext *last_filter; const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer"); - InputStream *ist = ifp->ist; - InputFile *f = ist->file; AVBPrint args; char name[255]; int ret, pad_idx = 0; @@ -1599,8 +1596,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, av_channel_layout_describe_bprint(&ifp->ch_layout, &args); } else av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels); - snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index, - f->index, ist->index); + snprintf(name, sizeof(name), "graph_%d_in_%s", fg->index, ifp->opts.name); if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt, name, args.str, NULL, @@ -1608,8 +1604,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, return ret; last_filter = ifp->filter; - snprintf(name, sizeof(name), "trim for input stream %d:%d", - f->index, ist->index); + snprintf(name, sizeof(name), "trim for input stream %s", ifp->opts.name); ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us, &last_filter, &pad_idx, name); if (ret < 0) @@ -2566,8 +2561,8 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, if (ifp->format < 0) { av_log(NULL, AV_LOG_ERROR, - "Cannot determine format of input stream %d:%d after EOF\n", - ifp->ist->file->index, ifp->ist->index); + "Cannot determine format of input %s after EOF\n", + ifp->opts.name); return AVERROR_INVALIDDATA; } } -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".