[FFmpeg-devel] [PATCH] Add --avlog-limit configure option.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Sep 22 17:03:53 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 | 26 ++++++++++++++++++++++++++
libavutil/log.c | 1 +
libavutil/log.h | 12 ++++++++++++
libavutil/opt.c | 3 +++
4 files changed, 42 insertions(+)
diff --git a/configure b/configure
index a219c26..759b225 100755
--- a/configure
+++ b/configure
@@ -99,6 +99,9 @@ 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,
+ reducing binary size. 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
@@ -2486,6 +2489,23 @@ 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 ;;
+ AV_LOG_*) ;; # looks like a predefined constant, assume it is valid
+ -[0-9]*|[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
;;
@@ -4849,6 +4869,12 @@ cat > $TMPH <<EOF
#define HAVE_MMX2 HAVE_MMXEXT
EOF
+# ifdef since ffmpeg.c etc. should not be affected
+echo "#ifdef HAVE_AV_CONFIG_H" >> $TMPH
+test -n "$avloglimit" &&
+ echo "#define AV_LOG_MIN_LEVEL $avloglimit" >> $TMPH
+echo "#endif" >> $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));
diff --git a/libavutil/opt.c b/libavutil/opt.c
index c035307..d2d116c 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -25,6 +25,9 @@
* @author Michael Niedermayer <michaelni at gmx.at>
*/
+#include "config.h"
+// to keep av_opt_show2 working
+#undef AV_LOG_MIN_LEVEL
#include "avutil.h"
#include "avstring.h"
#include "common.h"
--
1.8.4.rc3
More information about the ffmpeg-devel
mailing list