[MPlayer-cvslog] r20757 - trunk/libmpcodecs/vd_ffmpeg.c
michael
subversion at mplayerhq.hu
Tue Nov 7 20:52:47 CET 2006
Author: michael
Date: Tue Nov 7 20:52:47 2006
New Revision: 20757
Modified:
trunk/libmpcodecs/vd_ffmpeg.c
Log:
feed av_log() through mp_msg()
Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c (original)
+++ trunk/libmpcodecs/vd_ffmpeg.c Tue Nov 7 20:52:47 2006
@@ -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));
More information about the MPlayer-cvslog
mailing list