diff mbox series

[FFmpeg-devel,1/4] avfilter/framesync: Separate framesync AVClass and auxiliary functions

Message ID AM7PR03MB66605E1793FAEC59B605F04E8FDF9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avfilter/framesync: Separate framesync AVClass and auxiliary functions
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 19, 2021, 4:44 a.m. UTC
Will be useful for deduplication.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/framesync.h | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h
index fb85e8aec7..8436aba23b 100644
--- a/libavfilter/framesync.h
+++ b/libavfilter/framesync.h
@@ -299,25 +299,34 @@  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 */