[FFmpeg-devel] [PATCH] Add --avlog-limit configure option.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Sep 10 19:24:23 CEST 2013


This allows compiling out messages below a certain level.
Note that it might cause some strange behaviour with the
help printout of the command-line tools.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 configure       | 22 ++++++++++++++++++++++
 libavutil/log.c |  1 +
 libavutil/log.h | 12 ++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/configure b/configure
index 4ff97b4..57ca190 100755
--- a/configure
+++ b/configure
@@ -99,6 +99,8 @@ Configuration options:
   --disable-static         do not build static libraries [no]
   --enable-shared          build shared libraries [no]
   --enable-small           optimize for size instead of speed
+  --avlog-limit=value      do not compile in messages below this limit can be a number or
+                           one of: debug verbose info warning error fatal panic quiet
   --disable-runtime-cpudetect disable detecting cpu capabilities at runtime (smaller binary)
   --enable-gray            enable full grayscale support (slower color)
   --disable-swscale-alpha  disable alpha channel support in swscale
@@ -2482,6 +2484,22 @@ for opt do
         --enable-debug=*)
             debuglevel="$optval"
         ;;
+        --avlog-limit=*)
+            avloglimit="$optval"
+            case "$avloglimit" in
+            debug)   avloglimit=AV_LOG_DEBUG ;;
+            verbose) avloglimit=AV_LOG_VERBOSE ;;
+            info)    avloglimit=AV_LOG_INFO ;;
+            warning) avloglimit=AV_LOG_WARNING ;;
+            error)   avloglimit=AV_LOG_ERROR ;;
+            fatal)   avloglimit=AV_LOG_FATAL ;;
+            panic)   avloglimit=AV_LOG_PANIC ;;
+            quiet)   avloglimit=AV_LOG_QUIET ;;
+            [-0-9]*) ;; # looks like a number, assume it is valid
+            '') ;; # empty string to unset
+            *) die "Invalid value '$avloglimit' for --avlog-limit"
+            esac
+        ;;
         --disable-programs)
             disable $PROGRAM_LIST
         ;;
@@ -4821,6 +4839,10 @@ cat > $TMPH <<EOF
 #define HAVE_MMX2 HAVE_MMXEXT
 EOF
 
+
+test -n "$avloglimit" &&
+    echo "#define AV_LOG_MIN_LEVEL $avloglimit" >> $TMPH
+
 test -n "$assert_level" &&
     echo "#define ASSERT_LEVEL $assert_level" >>$TMPH
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 53be3ea..eec851b 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -39,6 +39,7 @@
 #include "common.h"
 #include "internal.h"
 #include "log.h"
+#undef av_log
 
 #define LINE_SZ 1024
 
diff --git a/libavutil/log.h b/libavutil/log.h
index 7ea95fa..41d21a6 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -180,6 +180,18 @@ typedef struct AVClass {
 void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
 
 void av_vlog(void *avcl, int level, const char *fmt, va_list);
+#ifdef AV_LOG_MIN_LEVEL
+static inline void av_log_internal(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
+static inline void av_log_internal(void *avcl, int level, const char *fmt, ...) {
+    if (level <= AV_LOG_MIN_LEVEL) {
+        va_list va;
+        va_start(va, fmt);
+        av_vlog(avcl, level, fmt, va);
+        va_end(va);
+    }
+}
+#define av_log(avcl, ...) av_log_internal(avcl, __VA_ARGS__)
+#endif
 int av_log_get_level(void);
 void av_log_set_level(int);
 void av_log_set_callback(void (*)(void*, int, const char*, va_list));
-- 
1.8.4.rc3



More information about the ffmpeg-devel mailing list