Mercurial > mplayer.hg
comparison libmpcodecs/vd_ffmpeg.c @ 20741:b3ef93332896
feed av_log() through mp_msg()
author | michael |
---|---|
date | Tue, 07 Nov 2006 19:52:47 +0000 |
parents | c41d4672c675 |
children | 94b1a797661f |
comparison
equal
deleted
inserted
replaced
20740:a2a3094c5c09 | 20741:b3ef93332896 |
---|---|
165 return avctx->has_b_frames + 10; | 165 return avctx->has_b_frames + 10; |
166 } | 166 } |
167 return CONTROL_UNKNOWN; | 167 return CONTROL_UNKNOWN; |
168 } | 168 } |
169 | 169 |
170 void mp_msp_av_log_callback(void* ptr, int level, const char* fmt, va_list vl) | |
171 { | |
172 static int print_prefix=1; | |
173 AVClass* avc= ptr ? *(AVClass**)ptr : NULL; | |
174 int type= MSGT_FIXME; | |
175 int mp_level; | |
176 char buf[256]; | |
177 | |
178 if(ptr){ | |
179 if(!strcmp(avc->class_name, "AVCodecContext")){ | |
180 AVCodecContext * s= ptr; | |
181 if(s->codec){ | |
182 if(s->codec->type == CODEC_TYPE_AUDIO){ | |
183 if(s->codec->decode) | |
184 type= MSGT_DECAUDIO; | |
185 }else if(s->codec->type == CODEC_TYPE_VIDEO){ | |
186 if(s->codec->decode) | |
187 type= MSGT_DECVIDEO; | |
188 } | |
189 //FIXME subtitles, encoders (what msgt for them? there is no appropiate ...) | |
190 } | |
191 }else if(!strcmp(avc->class_name, "AVFormatContext")){ | |
192 #if 0 //needs libavformat include FIXME iam too lazy to do this cleanly,probably the whole should be moved out of this file ... | |
193 AVFormatContext * s= ptr; | |
194 if(s->iformat) | |
195 type= MSGT_DEMUXER; | |
196 else if(s->oformat) | |
197 type= MSGT_MUXER; | |
198 #endif | |
199 } | |
200 } | |
201 | |
202 switch(level){ | |
203 case AV_LOG_DEBUG: mp_level= MSGL_V ; break; | |
204 case AV_LOG_INFO : mp_level= MSGL_INFO; break; | |
205 case AV_LOG_ERROR: mp_level= MSGL_ERR ; break; | |
206 default : mp_level= MSGL_ERR ; break; | |
207 } | |
208 | |
209 if(print_prefix && avc) { | |
210 mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc); | |
211 } | |
212 | |
213 print_prefix= strstr(fmt, "\n") != NULL; | |
214 vsnprintf(buf, sizeof(buf), fmt, vl); | |
215 mp_msg(type, mp_level, buf); | |
216 } | |
217 | |
170 // init driver | 218 // init driver |
171 static int init(sh_video_t *sh){ | 219 static int init(sh_video_t *sh){ |
172 AVCodecContext *avctx; | 220 AVCodecContext *avctx; |
173 vd_ffmpeg_ctx *ctx; | 221 vd_ffmpeg_ctx *ctx; |
174 AVCodec *lavc_codec; | 222 AVCodec *lavc_codec; |
177 | 225 |
178 if(!avcodec_inited){ | 226 if(!avcodec_inited){ |
179 avcodec_init(); | 227 avcodec_init(); |
180 avcodec_register_all(); | 228 avcodec_register_all(); |
181 avcodec_inited=1; | 229 avcodec_inited=1; |
230 av_log_set_callback(mp_msp_av_log_callback); | |
182 } | 231 } |
183 | 232 |
184 ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); | 233 ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); |
185 if (!ctx) | 234 if (!ctx) |
186 return(0); | 235 return(0); |