[FFmpeg-cvslog] fftools/ffmpeg_filter: factor out binding an output stream to OutputFilter

Anton Khirnov git at videolan.org
Wed May 31 17:25:54 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 21 22:33:13 2023 +0200| [87b576135e4b647ed5e434dd0d6acd09538f915e] | committer: Anton Khirnov

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=87b576135e4b647ed5e434dd0d6acd09538f915e
---

 fftools/ffmpeg.h          |  2 ++
 fftools/ffmpeg_filter.c   | 10 ++++++++--
 fftools/ffmpeg_mux_init.c |  3 +--
 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) {



More information about the ffmpeg-cvslog mailing list