aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-21 22:33:13 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-31 16:15:47 +0200
commit87b576135e4b647ed5e434dd0d6acd09538f915e (patch)
tree8c6edf09736a0fe91835d5309abba8313af502ef
parentdc5864a00c7a7ebab3cc478e6abcadc231a68433 (diff)
downloadffmpeg-87b576135e4b647ed5e434dd0d6acd09538f915e.tar.gz
fftools/ffmpeg_filter: factor out binding an output stream to OutputFilter
While the new function is trivial for now, it will become more useful in future commits.
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_filter.c10
-rw-r--r--fftools/ffmpeg_mux_init.c3
3 files changed, 11 insertions, 4 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3aa19c7f5f..8c149f1f95 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -756,6 +756,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec)
int ifilter_has_all_input_formats(FilterGraph *fg);
+void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost);
+
/**
* Create a new filtergraph in the global filtergraph list.
*
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d74eeef52a..5f77f1e00f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -464,6 +464,12 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
return 0;
}
+void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
+{
+ ofilter->ost = ost;
+ av_freep(&ofilter->linklabel);
+}
+
static InputFilter *ifilter_alloc(FilterGraph *fg)
{
InputFilterPriv *ifp = allocate_array_elem(&fg->inputs, sizeof(*ifp),
@@ -624,14 +630,14 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
return AVERROR(EINVAL);
}
- fg->outputs[0]->ost = ost;
-
ost->filter = fg->outputs[0];
ret = ifilter_bind_ist(fg->inputs[0], ist);
if (ret < 0)
return ret;
+ ofilter_bind_ost(fg->outputs[0], ost);
+
return 0;
}
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index f7a24feec7..99708b9621 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1259,8 +1259,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
if (ofilter) {
ost->filter = ofilter;
- ofilter->ost = ost;
- av_freep(&ofilter->linklabel);
+ ofilter_bind_ost(ofilter, ost);
} else {
ret = init_simple_filtergraph(ost->ist, ost, filters);
if (ret < 0) {