fftools/ffmpeg_filter: accept a name from its upstream input
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.
This commit is contained in:
@@ -253,6 +253,8 @@ typedef struct OptionsContext {
|
|||||||
typedef struct InputFilterOptions {
|
typedef struct InputFilterOptions {
|
||||||
int64_t trim_start_us;
|
int64_t trim_start_us;
|
||||||
int64_t trim_end_us;
|
int64_t trim_end_us;
|
||||||
|
|
||||||
|
uint8_t *name;
|
||||||
} InputFilterOptions;
|
} InputFilterOptions;
|
||||||
|
|
||||||
typedef struct InputFilter {
|
typedef struct InputFilter {
|
||||||
|
|||||||
@@ -1009,6 +1009,10 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
|
|||||||
AV_NOPTS_VALUE : tsoffset;
|
AV_NOPTS_VALUE : tsoffset;
|
||||||
opts->trim_end_us = d->recording_time;
|
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;
|
return ds->sch_idx_dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -889,6 +889,7 @@ void fg_free(FilterGraph **pfg)
|
|||||||
|
|
||||||
av_buffer_unref(&ifp->hw_frames_ctx);
|
av_buffer_unref(&ifp->hw_frames_ctx);
|
||||||
av_freep(&ifp->linklabel);
|
av_freep(&ifp->linklabel);
|
||||||
|
av_freep(&ifp->opts.name);
|
||||||
av_freep(&ifilter->name);
|
av_freep(&ifilter->name);
|
||||||
av_freep(&fg->inputs[j]);
|
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 AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||||
const AVPixFmtDescriptor *desc;
|
const AVPixFmtDescriptor *desc;
|
||||||
InputStream *ist = ifp->ist;
|
InputStream *ist = ifp->ist;
|
||||||
InputFile *f = ist->file;
|
|
||||||
AVRational fr = ist->framerate;
|
AVRational fr = ist->framerate;
|
||||||
AVRational sar;
|
AVRational sar;
|
||||||
AVBPrint args;
|
AVBPrint args;
|
||||||
@@ -1506,8 +1506,8 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
|
|||||||
ifp->color_space, ifp->color_range);
|
ifp->color_space, ifp->color_range);
|
||||||
if (fr.num && fr.den)
|
if (fr.num && fr.den)
|
||||||
av_bprintf(&args, ":frame_rate=%d/%d", 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,
|
snprintf(name, sizeof(name), "graph %d input from stream %s", fg->index,
|
||||||
f->index, ist->index);
|
ifp->opts.name);
|
||||||
|
|
||||||
|
|
||||||
if ((ret = avfilter_graph_create_filter(&ifp->filter, buffer_filt, 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name);
|
||||||
f->index, ist->index);
|
|
||||||
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
|
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
|
||||||
&last_filter, &pad_idx, name);
|
&last_filter, &pad_idx, name);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -1580,8 +1579,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
|
|||||||
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
|
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
|
||||||
AVFilterContext *last_filter;
|
AVFilterContext *last_filter;
|
||||||
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
|
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
|
||||||
InputStream *ist = ifp->ist;
|
|
||||||
InputFile *f = ist->file;
|
|
||||||
AVBPrint args;
|
AVBPrint args;
|
||||||
char name[255];
|
char name[255];
|
||||||
int ret, pad_idx = 0;
|
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);
|
av_channel_layout_describe_bprint(&ifp->ch_layout, &args);
|
||||||
} else
|
} else
|
||||||
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
|
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
|
||||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
snprintf(name, sizeof(name), "graph_%d_in_%s", fg->index, ifp->opts.name);
|
||||||
f->index, ist->index);
|
|
||||||
|
|
||||||
if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt,
|
if ((ret = avfilter_graph_create_filter(&ifp->filter, abuffer_filt,
|
||||||
name, args.str, NULL,
|
name, args.str, NULL,
|
||||||
@@ -1608,8 +1604,7 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
|
|||||||
return ret;
|
return ret;
|
||||||
last_filter = ifp->filter;
|
last_filter = ifp->filter;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "trim for input stream %d:%d",
|
snprintf(name, sizeof(name), "trim for input stream %s", ifp->opts.name);
|
||||||
f->index, ist->index);
|
|
||||||
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
|
ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
|
||||||
&last_filter, &pad_idx, name);
|
&last_filter, &pad_idx, name);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -2566,8 +2561,8 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
|
|||||||
|
|
||||||
if (ifp->format < 0) {
|
if (ifp->format < 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR,
|
av_log(NULL, AV_LOG_ERROR,
|
||||||
"Cannot determine format of input stream %d:%d after EOF\n",
|
"Cannot determine format of input %s after EOF\n",
|
||||||
ifp->ist->file->index, ifp->ist->index);
|
ifp->opts.name);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user