[FFmpeg-devel] [PATCH] Add --avlog-limit configure option.
Alexander Strasser
eclipse7 at gmx.net
Sun Sep 22 22:00:01 CEST 2013
Hi Reimar!
On 2013-09-22 17:03 +0200, Reimar Döffinger wrote:
> 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
IIUC with your latest changes to this patch you compile out the log
calls in the libs only. If I am not mistaken this should be reflected
more explicitly in the option description and in the commit message.
> @@ -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
> + ;;
This is too flexible for my taste. I would just do (un-tested):
--avlog-limit=*)
avloglimit="$optval"
case "$avloglimit" in
AV_LOG_DEBUG) ;;
AV_LOG_VERBOSE) ;;
AV_LOG_INFO) ;;
AV_LOG_WARNING) ;;
AV_LOG_ERROR) ;;
AV_LOG_FATAL) ;;
AV_LOG_PANIC) ;;
AV_LOG_QUIET) ;;
'') ;; # empty string to unset
*) die "Invalid value '$avloglimit' for --avlog-limit"
esac
;;
Usage errors will be caught immediately. If future extension
will be needed it will be easy to do. Just a suggestion, maybe
it is just me.
> --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"
This looks ugly :(
Alexander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130922/3278d484/attachment.asc>
More information about the ffmpeg-devel
mailing list