Mercurial > mplayer.hg
changeset 20741:b3ef93332896
feed av_log() through mp_msg()
author | michael |
---|---|
date | Tue, 07 Nov 2006 19:52:47 +0000 |
parents | a2a3094c5c09 |
children | 172fed37b456 |
files | libmpcodecs/vd_ffmpeg.c |
diffstat | 1 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c Tue Nov 07 19:05:38 2006 +0000 +++ b/libmpcodecs/vd_ffmpeg.c Tue Nov 07 19:52:47 2006 +0000 @@ -167,6 +167,54 @@ return CONTROL_UNKNOWN; } +void mp_msp_av_log_callback(void* ptr, int level, const char* fmt, va_list vl) +{ + static int print_prefix=1; + AVClass* avc= ptr ? *(AVClass**)ptr : NULL; + int type= MSGT_FIXME; + int mp_level; + char buf[256]; + + if(ptr){ + if(!strcmp(avc->class_name, "AVCodecContext")){ + AVCodecContext * s= ptr; + if(s->codec){ + if(s->codec->type == CODEC_TYPE_AUDIO){ + if(s->codec->decode) + type= MSGT_DECAUDIO; + }else if(s->codec->type == CODEC_TYPE_VIDEO){ + if(s->codec->decode) + type= MSGT_DECVIDEO; + } + //FIXME subtitles, encoders (what msgt for them? there is no appropiate ...) + } + }else if(!strcmp(avc->class_name, "AVFormatContext")){ +#if 0 //needs libavformat include FIXME iam too lazy to do this cleanly,probably the whole should be moved out of this file ... + AVFormatContext * s= ptr; + if(s->iformat) + type= MSGT_DEMUXER; + else if(s->oformat) + type= MSGT_MUXER; +#endif + } + } + + switch(level){ + case AV_LOG_DEBUG: mp_level= MSGL_V ; break; + case AV_LOG_INFO : mp_level= MSGL_INFO; break; + case AV_LOG_ERROR: mp_level= MSGL_ERR ; break; + default : mp_level= MSGL_ERR ; break; + } + + if(print_prefix && avc) { + mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc); + } + + print_prefix= strstr(fmt, "\n") != NULL; + vsnprintf(buf, sizeof(buf), fmt, vl); + mp_msg(type, mp_level, buf); +} + // init driver static int init(sh_video_t *sh){ AVCodecContext *avctx; @@ -179,6 +227,7 @@ avcodec_init(); avcodec_register_all(); avcodec_inited=1; + av_log_set_callback(mp_msp_av_log_callback); } ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx));