[FFmpeg-cvslog] avfilter/framesync: Separate framesync AVClass and auxiliary functions

Andreas Rheinhardt git at videolan.org
Thu Sep 23 22:26:32 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Sep 11 17:34:39 2021 +0200| [b368a774ddac8dc3e97d1206f6ee8c01a81edcab] | committer: Andreas Rheinhardt

avfilter/framesync: Separate framesync AVClass and auxiliary functions

Will be useful for deduplication.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavfilter/framesync.h | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h
index fb85e8aec7..a1db87187e 100644
--- a/libavfilter/framesync.h
+++ b/libavfilter/framesync.h
@@ -299,25 +299,36 @@ int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame *
 
 const AVClass *ff_framesync_child_class_iterate(void **iter);
 
-#define FRAMESYNC_DEFINE_CLASS(name, context, field) \
-static int name##_framesync_preinit(AVFilterContext *ctx) { \
+#define FRAMESYNC_DEFINE_PURE_CLASS(name, desc, func_prefix, options) \
+static const AVClass name##_class = {                                 \
+    .class_name          = desc,                                      \
+    .item_name           = av_default_item_name,                      \
+    .option              = options,                                   \
+    .version             = LIBAVUTIL_VERSION_INT,                     \
+    .category            = AV_CLASS_CATEGORY_FILTER,                  \
+    .child_class_iterate = ff_framesync_child_class_iterate,          \
+    .child_next          = func_prefix##_child_next,                  \
+}
+
+#define FRAMESYNC_AUXILIARY_FUNCS(func_prefix, context, field)        \
+static int func_prefix##_framesync_preinit(AVFilterContext *ctx)      \
+{                                                                     \
     context *s = ctx->priv; \
     ff_framesync_preinit(&s->field); \
     return 0; \
 } \
-static void *name##_child_next(void *obj, void *prev) { \
+static void *func_prefix##_child_next(void *obj, void *prev)          \
+{                                                                     \
     context *s = obj; \
     s->fs.class = ff_framesync_get_class(); /* FIXME */ \
     return prev ? NULL : &s->field; \
-} \
-static const AVClass name##_class = { \
-    .class_name       = #name, \
-    .item_name        = av_default_item_name, \
-    .option           = name##_options, \
-    .version          = LIBAVUTIL_VERSION_INT, \
-    .category         = AV_CLASS_CATEGORY_FILTER, \
-    .child_class_iterate = ff_framesync_child_class_iterate, \
-    .child_next       = name##_child_next, \
 }
 
+#define FRAMESYNC_DEFINE_CLASS_EXT(name, context, field, options)     \
+FRAMESYNC_AUXILIARY_FUNCS(name, context, field)                       \
+FRAMESYNC_DEFINE_PURE_CLASS(name, #name, name, options)
+
+#define FRAMESYNC_DEFINE_CLASS(name, context, field)                  \
+FRAMESYNC_DEFINE_CLASS_EXT(name, context, field, name##_options)
+
 #endif /* AVFILTER_FRAMESYNC_H */



More information about the ffmpeg-cvslog mailing list