summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authormichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-07 19:52:47 +0000
committermichael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-07 19:52:47 +0000
commit3c49701490aecb7c854bc6be048b16c24ce5c4d7 (patch)
tree81bcde8f8c6a1bc1897a6dd34d0f447cae87412c /libmpcodecs
parent1052ab502a54d3e40ed6b2f44ca68dd822f4c9e1 (diff)
downloadmpv-3c49701490aecb7c854bc6be048b16c24ce5c4d7.tar.bz2
mpv-3c49701490aecb7c854bc6be048b16c24ce5c4d7.tar.xz
feed av_log() through mp_msg()
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20757 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/vd_ffmpeg.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 2ea90a0454..19192f8669 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -167,6 +167,54 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){
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 @@ static int init(sh_video_t *sh){
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));