From: Rémi Bernon <rbernon@codeweavers.com> --- libs/ffmpeg/libavutil/log.c | 3 +++ libs/ffmpeg/libavutil/log.h | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/libs/ffmpeg/libavutil/log.c b/libs/ffmpeg/libavutil/log.c index b5d3e46d6c5..8b14bb12b6f 100644 --- a/libs/ffmpeg/libavutil/log.c +++ b/libs/ffmpeg/libavutil/log.c @@ -440,6 +440,7 @@ end: static atomic_uintptr_t av_log_callback = (uintptr_t)av_log_default_callback; +#undef av_log void av_log(void* avcl, int level, const char *fmt, ...) { va_list vl; @@ -448,6 +449,7 @@ void av_log(void* avcl, int level, const char *fmt, ...) va_end(vl); } +#undef av_log_once void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) { va_list vl; @@ -457,6 +459,7 @@ void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state *state = 1; } +#undef av_vlog void av_vlog(void* avcl, int level, const char *fmt, va_list vl) { AVClass* avc = avcl ? *(AVClass **) avcl : NULL; diff --git a/libs/ffmpeg/libavutil/log.h b/libs/ffmpeg/libavutil/log.h index 4a111ca9a5b..3b832fc5e51 100644 --- a/libs/ffmpeg/libavutil/log.h +++ b/libs/ffmpeg/libavutil/log.h @@ -424,4 +424,55 @@ int av_log_get_flags(void); * @} */ +#include "wine/debug.h" +#undef OUT + +WINE_DECLARE_DEBUG_CHANNEL(ffmpeg); + +static enum __wine_debug_class wine_dbglog_from_level( int level ) +{ + if (level >= 0) level &= 0xff; + if (level < 0) return __WINE_DBCL_TRACE; + if (level <= AV_LOG_ERROR) return __WINE_DBCL_ERR; + if (level <= AV_LOG_WARNING) return __WINE_DBCL_WARN; + return __WINE_DBCL_TRACE; +} + +#define av_log( a, b, c, ... ) wine_av_log( __func__, a, b, c, ##__VA_ARGS__ ) +static inline void wine_av_log( const char *func, void *avcl, int level, const char *fmt, ... ) +{ + enum __wine_debug_class dbcl = wine_dbglog_from_level( level ); + va_list args; + + if (!(__wine_dbch_ffmpeg.flags & (1 << dbcl))) return; + va_start( args, fmt ); + wine_dbg_vlog( dbcl, &__wine_dbch_ffmpeg, func, fmt, args ); + va_end( args ); +} + +#define av_log_once( a, b, c, d, e, ... ) wine_av_log_once( __func__, a, b, c, d, e, ##__VA_ARGS__ ) +static inline void wine_av_log_once( const char *func, void *avcl, int initial_level, int subsequent_level, + int *state, const char *fmt, ... ) +{ + enum __wine_debug_class dbcl; + va_list args; + int level; + + level = InterlockedExchange( (LONG *)state, 1 ) ? subsequent_level : initial_level; + dbcl = wine_dbglog_from_level( level ); + + if (!(__wine_dbch_ffmpeg.flags & (1 << dbcl))) return; + va_start( args, fmt ); + wine_dbg_vlog( dbcl, &__wine_dbch_ffmpeg, func, fmt, args ); + va_end( args ); +} + +#define av_vlog( a, b, c, d ) wine_av_vlog( __func__, a, b, c, d ) +static inline void wine_av_vlog( const char *func, void *avcl, int level, const char *fmt, va_list args ) +{ + enum __wine_debug_class dbcl = wine_dbglog_from_level( level ); + if (!(__wine_dbch_ffmpeg.flags & (1 << dbcl))) return; + wine_dbg_vlog( dbcl, &__wine_dbch_ffmpeg, func, fmt, args ); +} + #endif /* AVUTIL_LOG_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11111