[FFmpeg-cvslog] lavfi: add avfilter_default_filter_name()

Stefano Sabatini git at videolan.org
Mon Jun 4 00:56:55 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Fri Jun  1 14:46:54 2012 +0200| [4d6a8a2bdb19c4380cc458759b7bd221942a028f] | committer: Stefano Sabatini

lavfi: add avfilter_default_filter_name()

The function is modelled after av_default_item_name(), and will print the
name of the instance filter if defined, otherwise the name of the filter.

This allows to show the instance name in the log, which is useful when
debugging complex filter graphs.

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

 doc/APIchanges                 |    3 +++
 libavfilter/af_aformat.c       |    2 +-
 libavfilter/af_amix.c          |    2 +-
 libavfilter/af_asyncts.c       |    2 +-
 libavfilter/af_silencedetect.c |    7 +------
 libavfilter/asrc_aevalsrc.c    |    7 +------
 libavfilter/asrc_anullsrc.c    |    7 +------
 libavfilter/avfilter.c         |    8 ++++----
 libavfilter/avfilter.h         |    6 ++++++
 libavfilter/avfiltergraph.c    |    2 +-
 libavfilter/buffersrc.c        |    2 +-
 libavfilter/src_movie.c        |    7 +------
 libavfilter/version.h          |    2 +-
 libavfilter/vf_ass.c           |    7 +------
 libavfilter/vf_blackdetect.c   |    7 +------
 libavfilter/vf_delogo.c        |    7 +------
 libavfilter/vf_drawtext.c      |    7 +------
 libavfilter/vf_fade.c          |    7 +------
 libavfilter/vf_fps.c           |    2 +-
 libavfilter/vf_lut.c           |    7 +------
 libavfilter/vf_overlay.c       |    7 +------
 libavfilter/vsrc_cellauto.c    |    7 +------
 libavfilter/vsrc_life.c        |    7 +------
 libavfilter/vsrc_mandelbrot.c  |    7 +------
 libavfilter/vsrc_mptestsrc.c   |    7 +------
 libavfilter/vsrc_testsrc.c     |   21 +++------------------
 26 files changed, 38 insertions(+), 119 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index b14204a..0b70c21 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-06-04 - xxxxxxx - lafi 2.78.100
+  Add avfilter_default_filter_name() function in avfilter.h.
+
 2012-05-24 - xxxxxxx - lavu 51.54.100
   Move AVPALETTE_SIZE and AVPALETTE_COUNT macros from
   libavcodec/avcodec.h to libavutil/pixfmt.h.
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index 35e7db8..1fcaee7 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -55,7 +55,7 @@ static const AVOption options[] = {
 
 static const AVClass aformat_class = {
     .class_name = "aformat filter",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = options,
     .version    = LIBAVUTIL_VERSION_INT,
     .category = AV_CLASS_CATEGORY_FILTER,
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index d4af9a4..03e643a 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -186,7 +186,7 @@ static const AVOption options[] = {
 
 static const AVClass amix_class = {
     .class_name = "amix filter",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c
index adb5347..1d97f1a 100644
--- a/libavfilter/af_asyncts.c
+++ b/libavfilter/af_asyncts.c
@@ -50,7 +50,7 @@ static const AVOption options[] = {
 
 static const AVClass async_class = {
     .class_name = "asyncts filter",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c
index 76001ce..b8057e4 100644
--- a/libavfilter/af_silencedetect.c
+++ b/libavfilter/af_silencedetect.c
@@ -48,14 +48,9 @@ static const AVOption silencedetect_options[] = {
     { NULL },
 };
 
-static const char *silencedetect_get_name(void *ctx)
-{
-    return "silencedetect";
-}
-
 static const AVClass silencedetect_class = {
     .class_name = "SilenceDetectContext",
-    .item_name  = silencedetect_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = silencedetect_options,
 };
 
diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c
index f259d14..b336b57 100644
--- a/libavfilter/asrc_aevalsrc.c
+++ b/libavfilter/asrc_aevalsrc.c
@@ -78,14 +78,9 @@ static const AVOption eval_options[]= {
 {NULL},
 };
 
-static const char *eval_get_name(void *ctx)
-{
-    return "aevalsrc";
-}
-
 static const AVClass eval_class = {
     "AEvalSrcContext",
-    eval_get_name,
+    avfilter_default_filter_name,
     eval_options
 };
 
diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c
index 61fdc32..6cd49e6 100644
--- a/libavfilter/asrc_anullsrc.c
+++ b/libavfilter/asrc_anullsrc.c
@@ -53,14 +53,9 @@ static const AVOption anullsrc_options[]= {
     { NULL },
 };
 
-static const char *anullsrc_get_name(void *ctx)
-{
-    return "anullsrc";
-}
-
 static const AVClass anullsrc_class = {
     "ANullSrcContext",
-    anullsrc_get_name,
+    avfilter_default_filter_name,
     anullsrc_options
 };
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 0c3e7ed..b56106a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -366,15 +366,15 @@ static int pad_count(const AVFilterPad *pads)
     return count;
 }
 
-static const char *filter_name(void *p)
+const char *avfilter_default_filter_name(void *filter_ctx)
 {
-    AVFilterContext *filter = p;
-    return filter->filter->name;
+    AVFilterContext *ctx = filter_ctx;
+    return ctx->name ? ctx->name : ctx->filter->name;
 }
 
 static const AVClass avfilter_class = {
     .class_name = "AVFilter",
-    .item_name  = filter_name,
+    .item_name  = avfilter_default_filter_name,
     .version    = LIBAVUTIL_VERSION_INT,
     .category = AV_CLASS_CATEGORY_FILTER,
 };
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index c9d63d6..10803c5 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -634,6 +634,12 @@ struct AVFilterContext {
     struct AVFilterCommand *command_queue;
 };
 
+/**
+ * Print the name of the filter given a filter context.
+ */
+const char *avfilter_default_filter_name(void *filter_ctx);
+
+
 #if FF_API_PACKING
 enum AVFilterPacking {
     AVFILTER_PACKED = 0,
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 8d2312e..3918a0f 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -36,7 +36,7 @@
 
 static const AVClass filtergraph_class = {
     .class_name = "AVFilterGraph",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 0c60caf..6536542 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -255,7 +255,7 @@ static const AVOption audio_options[] = {
 
 static const AVClass abuffer_class = {
     .class_name = "abuffer source",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = audio_options,
     .version    = LIBAVUTIL_VERSION_INT,
     .category   = AV_CLASS_CATEGORY_FILTER,
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 21e4e3f..8262e00 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -78,14 +78,9 @@ static const AVOption movie_options[]= {
 {NULL},
 };
 
-static const char *movie_get_name(void *ctx)
-{
-    return "movie";
-}
-
 static const AVClass movie_class = {
     "MovieContext",
-    movie_get_name,
+    avfilter_default_filter_name,
     movie_options
 };
 
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c44c45e..76f649e 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  2
-#define LIBAVFILTER_VERSION_MINOR 77
+#define LIBAVFILTER_VERSION_MINOR 78
 #define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_ass.c b/libavfilter/vf_ass.c
index c828699..3503b26 100644
--- a/libavfilter/vf_ass.c
+++ b/libavfilter/vf_ass.c
@@ -54,14 +54,9 @@ static const AVOption ass_options[] = {
     {NULL},
 };
 
-static const char *ass_get_name(void *ctx)
-{
-    return "ass";
-}
-
 static const AVClass ass_class = {
     "AssContext",
-    ass_get_name,
+    avfilter_default_filter_name,
     ass_options
 };
 
diff --git a/libavfilter/vf_blackdetect.c b/libavfilter/vf_blackdetect.c
index ea45f05..909cb37 100644
--- a/libavfilter/vf_blackdetect.c
+++ b/libavfilter/vf_blackdetect.c
@@ -57,14 +57,9 @@ static const AVOption blackdetect_options[] = {
     { NULL },
 };
 
-static const char *blackdetect_get_name(void *ctx)
-{
-    return "blackdetect";
-}
-
 static const AVClass blackdetect_class = {
     .class_name = "BlackDetectContext",
-    .item_name  = blackdetect_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = blackdetect_options,
 };
 
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index ffef1c7..e0dc9a2 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -149,14 +149,9 @@ static const AVOption delogo_options[]= {
     {NULL},
 };
 
-static const char *delogo_get_name(void *ctx)
-{
-    return "delogo";
-}
-
 static const AVClass delogo_class = {
     .class_name = "DelogoContext",
-    .item_name  = delogo_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = delogo_options,
 };
 
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 898bbd4..c51341b 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -205,14 +205,9 @@ static const AVOption drawtext_options[]= {
 {NULL},
 };
 
-static const char *drawtext_get_name(void *ctx)
-{
-    return "drawtext";
-}
-
 static const AVClass drawtext_class = {
     "DrawTextContext",
-    drawtext_get_name,
+    avfilter_default_filter_name,
     drawtext_options
 };
 
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index a38387f..6c795b0 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -69,14 +69,9 @@ static const AVOption fade_options[] = {
     {NULL},
 };
 
-static const char *fade_get_name(void *ctx)
-{
-    return "fade";
-}
-
 static const AVClass fade_class = {
     "FadeContext",
-    fade_get_name,
+    avfilter_default_filter_name,
     fade_options
 };
 
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index d12070c..cd66e3f 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -60,7 +60,7 @@ static const AVOption options[] = {
 
 static const AVClass class = {
     .class_name = "FPS filter",
-    .item_name  = av_default_item_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index c0b8607..831a8bf 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -89,14 +89,9 @@ static const AVOption lut_options[] = {
     {NULL},
 };
 
-static const char *lut_get_name(void *ctx)
-{
-    return "lut";
-}
-
 static const AVClass lut_class = {
     "LutContext",
-    lut_get_name,
+    avfilter_default_filter_name,
     lut_options
 };
 
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 65712a8..8217f6d 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -101,14 +101,9 @@ static const AVOption overlay_options[] = {
     {NULL},
 };
 
-static const char *overlay_get_name(void *ctx)
-{
-    return "overlay";
-}
-
 static const AVClass overlay_class = {
     "OverlayContext",
-    overlay_get_name,
+    avfilter_default_filter_name,
     overlay_options
 };
 
diff --git a/libavfilter/vsrc_cellauto.c b/libavfilter/vsrc_cellauto.c
index d17b5e4..93bdded 100644
--- a/libavfilter/vsrc_cellauto.c
+++ b/libavfilter/vsrc_cellauto.c
@@ -76,14 +76,9 @@ static const AVOption cellauto_options[] = {
     { NULL },
 };
 
-static const char *cellauto_get_name(void *ctx)
-{
-    return "cellauto";
-}
-
 static const AVClass cellauto_class = {
     "CellAutoContext",
-    cellauto_get_name,
+    avfilter_default_filter_name,
     cellauto_options
 };
 
diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c
index 028c90b..9b6305d 100644
--- a/libavfilter/vsrc_life.c
+++ b/libavfilter/vsrc_life.c
@@ -95,14 +95,9 @@ static const AVOption life_options[] = {
     { NULL },
 };
 
-static const char *life_get_name(void *ctx)
-{
-    return "life";
-}
-
 static const AVClass life_class = {
     "LifeContext",
-    life_get_name,
+    avfilter_default_filter_name,
     life_options
 };
 
diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
index 9d44200..92b4b38 100644
--- a/libavfilter/vsrc_mandelbrot.c
+++ b/libavfilter/vsrc_mandelbrot.c
@@ -103,14 +103,9 @@ static const AVOption mandelbrot_options[] = {
     {NULL},
 };
 
-static const char *mandelbrot_get_name(void *ctx)
-{
-    return "mandelbrot";
-}
-
 static const AVClass mandelbrot_class = {
     "MBContext",
-    mandelbrot_get_name,
+    avfilter_default_filter_name,
     mandelbrot_options
 };
 
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 3043204..c7521df 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -82,14 +82,9 @@ static const AVOption mptestsrc_options[]= {
     { NULL },
 };
 
-static const char *mptestsrc_get_name(void *ctx)
-{
-    return "mptestsrc";
-}
-
 static const AVClass mptestsrc_class = {
     "MPTestContext",
-    mptestsrc_get_name,
+    avfilter_default_filter_name,
     mptestsrc_options
 };
 
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 7cf29ee..95bf168 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -156,14 +156,9 @@ static int request_frame(AVFilterLink *outlink)
 
 #if CONFIG_NULLSRC_FILTER
 
-static const char *nullsrc_get_name(void *ctx)
-{
-    return "nullsrc";
-}
-
 static const AVClass nullsrc_class = {
     .class_name = "NullSourceContext",
-    .item_name  = nullsrc_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = testsrc_options,
 };
 
@@ -196,14 +191,9 @@ AVFilter avfilter_vsrc_nullsrc = {
 
 #if CONFIG_TESTSRC_FILTER
 
-static const char *testsrc_get_name(void *ctx)
-{
-    return "testsrc";
-}
-
 static const AVClass testsrc_class = {
     .class_name = "TestSourceContext",
-    .item_name  = testsrc_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = testsrc_options,
 };
 
@@ -423,14 +413,9 @@ AVFilter avfilter_vsrc_testsrc = {
 
 #if CONFIG_RGBTESTSRC_FILTER
 
-static const char *rgbtestsrc_get_name(void *ctx)
-{
-    return "rgbtestsrc";
-}
-
 static const AVClass rgbtestsrc_class = {
     .class_name = "RGBTestSourceContext",
-    .item_name  = rgbtestsrc_get_name,
+    .item_name  = avfilter_default_filter_name,
     .option     = testsrc_options,
 };
 



More information about the ffmpeg-cvslog mailing list