From 4880cfd9522fcb0234aacc4e40f0f27729ccee40 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 19 May 2010 22:51:38 +0000 Subject: [PATCH] Print parent log context too, if available. Originally committed as revision 23200 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavutil/log.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavutil/log.c b/libavutil/log.c index 87a1edaffb..ce0dc4aa52 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -68,11 +68,17 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) AVClass* avc= ptr ? *(AVClass**)ptr : NULL; if(level>av_log_level) return; + line[0]=0; #undef fprintf if(print_prefix && avc) { - snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr); - }else - line[0]=0; + if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ + AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); + if(parent && *parent){ + snprintf(line, sizeof(line), "[%s @ %p]", (*parent)->item_name(parent), parent); + } + } + snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p]", avc->item_name(ptr), ptr); + } vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);