diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-21 21:11:09 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-31 16:15:47 +0200 |
commit | 00183880aa065e97a3ec37524c802b562f83876d (patch) | |
tree | 65e6c50c8a5df81a4009bb23d945c9b317f11f1c /fftools/ffmpeg_filter.c | |
parent | 7ea10bfef3ac103854d975553bc1d43a5e3979d3 (diff) | |
download | ffmpeg-00183880aa065e97a3ec37524c802b562f83876d.tar.gz |
fftools/ffmpeg_filter: decouple allocating InputFilter and binding it to InputStream
Will be useful in future commits.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 323e63b829..a8c4ef321f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -258,7 +258,24 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) return ofilter; } -static InputFilter *ifilter_alloc(FilterGraph *fg, InputStream *ist) +static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) +{ + InputFilterPriv *ifp = ifp_from_ifilter(ifilter); + int ret; + + ret = ist_filter_add(ist, ifilter, filtergraph_is_simple(ifilter->graph)); + if (ret < 0) + return ret; + + ifp->ist = ist; + ifp->type_src = ist->st->codecpar->codec_type; + ifp->type = ifp->type_src == AVMEDIA_TYPE_SUBTITLE ? + AVMEDIA_TYPE_VIDEO : ifp->type_src; + + return 0; +} + +static InputFilter *ifilter_alloc(FilterGraph *fg) { InputFilterPriv *ifp = allocate_array_elem(&fg->inputs, sizeof(*ifp), &fg->nb_inputs); @@ -272,10 +289,6 @@ static InputFilter *ifilter_alloc(FilterGraph *fg, InputStream *ist) ifp->format = -1; ifp->fallback.format = -1; - ifp->ist = ist; - ifp->type_src = ist->st->codecpar->codec_type; - ifp->type = ifp->type_src == AVMEDIA_TYPE_SUBTITLE ? - AVMEDIA_TYPE_VIDEO : ifp->type_src; ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifp->frame_queue) @@ -373,9 +386,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, ost->filter = ofilter; - ifilter = ifilter_alloc(fg, ist); + ifilter = ifilter_alloc(fg); - ret = ist_filter_add(ist, ifilter, 1); + ret = ifilter_bind_ist(ifilter, ist); if (ret < 0) return ret; @@ -455,10 +468,10 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) } av_assert0(ist); - ifilter = ifilter_alloc(fg, ist); + ifilter = ifilter_alloc(fg); ifilter->name = describe_filter_link(fg, in, 1); - ret = ist_filter_add(ist, ifilter, 0); + ret = ifilter_bind_ist(ifilter, ist); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error binding an input stream to complex filtergraph input %s.\n", |