From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input Date: Wed, 14 Feb 2024 19:24:28 +0100 Message-ID: <20240214182435.31380-3-anton@khirnov.net> (raw) In-Reply-To: <20240214182435.31380-1-anton@khirnov.net> 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".
next prev parent reply other threads:[~2024-02-14 18:24 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-14 18:24 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer Anton Khirnov 2024-02-14 18:24 ` Anton Khirnov [this message] 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags " Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate " Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase Anton Khirnov 2024-02-15 1:58 ` Michael Niedermayer 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user Anton Khirnov 2024-02-14 18:24 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240214182435.31380-3-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git