[FFmpeg-devel] [PATCH 1/2] WIP lavfi/framesync2: add dualinput helper function.

Nicolas George george at nsup.org
Sun Jul 30 13:48:09 EEST 2017


Signed-off-by: Nicolas George <george at nsup.org>
---
 libavfilter/framesync2.c | 20 ++++++++++++++++++++
 libavfilter/framesync2.h | 14 ++++++++++++++
 2 files changed, 34 insertions(+)


Both patches work in progress. They work, but the code needs to be enhanced,
otherwise the other filters will require boilerplace code.


diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c
index 0e9f6f210c..ed8f913b7d 100644
--- a/libavfilter/framesync2.c
+++ b/libavfilter/framesync2.c
@@ -311,3 +311,23 @@ int ff_framesync2_activate(FFFrameSync *fs)
 
     return 0;
 }
+
+int ff_framesync2_get_dualinput(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
+{
+    AVFilterContext *ctx = fs->parent;
+    AVFrame *mainpic = NULL, *secondpic = NULL;
+    int ret = 0;
+
+    if ((ret = ff_framesync2_get_frame(fs, 0, &mainpic,   1)) < 0 ||
+        (ret = ff_framesync2_get_frame(fs, 1, &secondpic, 0)) < 0) {
+        av_frame_free(&mainpic);
+        return ret;
+    }
+    av_assert0(mainpic);
+    mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
+    if (ctx->is_disabled)
+        secondpic = NULL;
+    *f0 = mainpic;
+    *f1 = secondpic;
+    return 0;
+}
diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h
index 2b37636ebb..07e422b309 100644
--- a/libavfilter/framesync2.h
+++ b/libavfilter/framesync2.h
@@ -245,4 +245,18 @@ int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
  */
 int ff_framesync2_activate(FFFrameSync *fs);
 
+/**
+ * Get dualinput frames.
+ *
+ * Compared to generic framesync, dualinput assumes the first input is the
+ * main one and the filtering is performed on it. The first input will be
+ * the only one with sync set and generic timeline support will just pass it
+ * unchanged when disabled.
+ *
+ * @param f0  used to return the main frame
+ * @param f1  used to return the second frame, or NULL if disabled
+ * @return  >=0 for success or AVERROR code
+ */
+int ff_framesync2_get_dualinput(FFFrameSync *fs, AVFrame **f0, AVFrame **f1);
+
 #endif /* AVFILTER_FRAMESYNC2_H */
-- 
2.13.2



More information about the ffmpeg-devel mailing list