1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

fftools/ffmpeg_filter: remove remaining OutputStream usage in init_simple_filtergraph()

With this, nothing in ffmpeg_filter acesses OutputStream anymore, thus
there are no more direct ties between filtering and muxing.

Rename init_simple_filtergraph() to fg_create_simple() for consistency.
This commit is contained in:
Anton Khirnov 2024-09-12 18:49:27 +02:00
parent 72cd0c20da
commit d103b61cd8
3 changed files with 21 additions and 17 deletions

View File

@ -755,10 +755,11 @@ int find_codec(void *logctx, const char *name,
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
int filtergraph_is_simple(const FilterGraph *fg); int filtergraph_is_simple(const FilterGraph *fg);
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, int fg_create_simple(FilterGraph **pfg,
char *graph_desc, InputStream *ist,
Scheduler *sch, unsigned sch_idx_enc, char *graph_desc,
const OutputFilterOptions *opts); Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts);
int fg_finalise_bindings(void); int fg_finalise_bindings(void);
/** /**

View File

@ -1180,25 +1180,27 @@ fail:
return 0; return 0;
} }
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, int fg_create_simple(FilterGraph **pfg,
char *graph_desc, InputStream *ist,
Scheduler *sch, unsigned sched_idx_enc, char *graph_desc,
const OutputFilterOptions *opts) Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts)
{ {
const enum AVMediaType type = ist->par->codec_type;
FilterGraph *fg; FilterGraph *fg;
FilterGraphPriv *fgp; FilterGraphPriv *fgp;
int ret; int ret;
ret = fg_create(&ost->fg_simple, graph_desc, sch); ret = fg_create(pfg, graph_desc, sch);
if (ret < 0) if (ret < 0)
return ret; return ret;
fg = ost->fg_simple; fg = *pfg;
fgp = fgp_from_fg(fg); fgp = fgp_from_fg(fg);
fgp->is_simple = 1; fgp->is_simple = 1;
snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf%s", snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf%s",
av_get_media_type_string(ost->type)[0], opts->name); av_get_media_type_string(type)[0], opts->name);
if (fg->nb_inputs != 1 || fg->nb_outputs != 1) { if (fg->nb_inputs != 1 || fg->nb_outputs != 1) {
av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected " av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
@ -1208,16 +1210,14 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
graph_desc, fg->nb_inputs, fg->nb_outputs); graph_desc, fg->nb_inputs, fg->nb_outputs);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (fg->outputs[0]->type != ost->type) { if (fg->outputs[0]->type != type) {
av_log(fg, AV_LOG_ERROR, "Filtergraph has a %s output, cannot connect " av_log(fg, AV_LOG_ERROR, "Filtergraph has a %s output, cannot connect "
"it to %s output stream\n", "it to %s output stream\n",
av_get_media_type_string(fg->outputs[0]->type), av_get_media_type_string(fg->outputs[0]->type),
av_get_media_type_string(ost->type)); av_get_media_type_string(type));
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
ost->filter = fg->outputs[0];
ret = ifilter_bind_ist(fg->inputs[0], ist, opts->vs); ret = ifilter_bind_ist(fg->inputs[0], ist, opts->vs);
if (ret < 0) if (ret < 0)
return ret; return ret;

View File

@ -1010,8 +1010,11 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
ost->filter = ofilter; ost->filter = ofilter;
ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts); ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts);
} else { } else {
ret = init_simple_filtergraph(ost->ist, ost, filters, ret = fg_create_simple(&ost->fg_simple, ost->ist, filters,
mux->sch, ms->sch_idx_enc, &opts); mux->sch, ms->sch_idx_enc, &opts);
if (ret >= 0)
ost->filter = ost->fg_simple->outputs[0];
} }
av_freep(&opts.nb_threads); av_freep(&opts.nb_threads);
if (ret < 0) if (ret < 0)