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

Alexander Strasser eclipse7 at gmx.net
Tue Sep 10 23:29:31 CEST 2013


On 2013-09-10 19:24 +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       | 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

  Seems some inter punctuation is missing (at the indicated position?)

  Also I would like to see it tucked avay under "Advanced options", I
know categories are never perfect, especially these broad ones. But I
do not favor every average user to play around with this option
and build probably strange behaving ffmpeg tools. If it is under a
"(experts only)" category at has some warning. Also a warning could
be seen as invitation... nothing is ever perfect ;)

>    --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

  LGTM otherwise after it has undergone some more testing. (Probably from
people that want this feature.)

  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/20130910/1ecc96fb/attachment.asc>


More information about the ffmpeg-devel mailing list