diff options
-rw-r--r-- | asfheader.c | 34 | ||||
-rw-r--r-- | aviheader.c | 21 | ||||
-rw-r--r-- | dec_audio.c | 27 | ||||
-rw-r--r-- | dec_video.c | 79 | ||||
-rw-r--r-- | demux_asf.c | 39 | ||||
-rw-r--r-- | demux_avi.c | 65 | ||||
-rw-r--r-- | demux_mov.c | 45 | ||||
-rw-r--r-- | demux_mpg.c | 55 | ||||
-rw-r--r-- | demuxer.c | 64 | ||||
-rw-r--r-- | dll_init.c | 49 | ||||
-rw-r--r-- | mplayer.c | 191 | ||||
-rw-r--r-- | open.c | 24 |
12 files changed, 340 insertions, 353 deletions
diff --git a/asfheader.c b/asfheader.c index a2a51115b9..8d22109352 100644 --- a/asfheader.c +++ b/asfheader.c @@ -7,6 +7,9 @@ extern int verbose; // defined in mplayer.c +#include "config.h" +#include "mp_msg.h" + #include "stream.h" #include "demuxer.h" @@ -66,7 +69,7 @@ void pack_asf_string(char* string, int length) { // the variable string is modify in this function void print_asf_string(const char* name, char* string, int length) { pack_asf_string(string, length); - printf("%s%s\n", name, string); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", name, string); } static char* asf_chunk_type(unsigned char* guid) { @@ -116,11 +119,11 @@ int asf_check_header(demuxer_t *demuxer){ // for(i=0;i<16;i++) printf(" %02X",temp[i]);printf("\n"); // for(i=0;i<16;i++) printf(" %02X",asfhdrguid[i]);printf("\n"); if(memcmp(asfhdrguid,asfh.objh.guid,16)){ - if(verbose) printf("ASF_check: not ASF guid!\n"); + mp_msg(MSGT_HEADER,MSGL_V,"ASF_check: not ASF guid!\n"); return 0; // not ASF guid } if(asfh.cno>256){ - if(verbose) printf("ASF_check: invalid subchunks_no %d\n",(int) asfh.cno); + mp_msg(MSGT_HEADER,MSGL_V,"ASF_check: invalid subchunks_no %d\n",(int) asfh.cno); return 0; // invalid header??? } return 1; @@ -148,15 +151,15 @@ while(!stream_eof(demuxer->stream)){ stream_read(demuxer->stream,(char*) &streamh,sizeof(streamh)); le2me_ASF_stream_header_t(&streamh); if(verbose){ - printf("stream type: %s\n",asf_chunk_type(streamh.type)); - printf("stream concealment: %s\n",asf_chunk_type(streamh.concealment)); - printf("type: %d bytes, stream: %d bytes ID: %d\n",(int)streamh.type_size,(int)streamh.stream_size,(int)streamh.stream_no); - printf("unk1: %lX unk2: %X\n",(unsigned long)streamh.unk1,(unsigned int)streamh.unk2); - printf("FILEPOS=0x%X\n",stream_tell(demuxer->stream)); + mp_msg(MSGT_HEADER,MSGL_V,"stream type: %s\n",asf_chunk_type(streamh.type)); + mp_msg(MSGT_HEADER,MSGL_V,"stream concealment: %s\n",asf_chunk_type(streamh.concealment)); + mp_msg(MSGT_HEADER,MSGL_V,"type: %d bytes, stream: %d bytes ID: %d\n",(int)streamh.type_size,(int)streamh.stream_size,(int)streamh.stream_no); + mp_msg(MSGT_HEADER,MSGL_V,"unk1: %lX unk2: %X\n",(unsigned long)streamh.unk1,(unsigned int)streamh.unk2); + mp_msg(MSGT_HEADER,MSGL_V,"FILEPOS=0x%X\n",stream_tell(demuxer->stream)); } if(streamh.type_size>1024 || streamh.stream_size>1024){ - printf("FATAL: header size bigger than 1024 bytes!\n"); - printf("Please contact mplayer authors, and upload/send this file.\n"); + mp_msg(MSGT_HEADER,MSGL_FATAL,"FATAL: header size bigger than 1024 bytes!\n" + "Please contact mplayer authors, and upload/send this file.\n"); exit(1); } // type-specific data: @@ -177,7 +180,7 @@ while(!stream_eof(demuxer->stream)){ } else { asf_scrambling_b=asf_scrambling_h=asf_scrambling_w=1; } - printf("ASF: audio scrambling: %d x %d x %d\n",asf_scrambling_h,asf_scrambling_w,asf_scrambling_b); + mp_msg(MSGT_HEADER,MSGL_V,"ASF: audio scrambling: %d x %d x %d\n",asf_scrambling_h,asf_scrambling_w,asf_scrambling_b); //if(demuxer->audio->id==-1) demuxer->audio->id=streamh.stream_no & 0x7F; break; } @@ -203,14 +206,14 @@ while(!stream_eof(demuxer->stream)){ case ASF_GUID_PREFIX_file_header: // guid_file_header stream_read(demuxer->stream,(char*) &fileh,sizeof(fileh)); le2me_ASF_file_header_t(&fileh); - if(verbose) printf("ASF: packets: %d flags: %d pack_size: %d frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size); + mp_msg(MSGT_HEADER,MSGL_V,"ASF: packets: %d flags: %d pack_size: %d frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size); asf_packetsize=fileh.packetsize; asf_packet=malloc(asf_packetsize); // !!! break; case ASF_GUID_PREFIX_data_chunk: // guid_data_chunk demuxer->movi_start=stream_tell(demuxer->stream)+26; demuxer->movi_end=endpos; - if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); + mp_msg(MSGT_HEADER,MSGL_V,"Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); break; // case ASF_GUID_PREFIX_index_chunk: return "guid_index_chunk"; @@ -220,11 +223,12 @@ while(!stream_eof(demuxer->stream)){ char *string=NULL; stream_read(demuxer->stream,(char*) &contenth,sizeof(contenth)); le2me_ASF_content_description_t(&contenth); + mp_msg(MSGT_HEADER,MSGL_V,"\n"); // extract the title if( contenth.title_size!=0 ) { string=(char*)malloc(contenth.title_size); stream_read(demuxer->stream, string, contenth.title_size); - print_asf_string("\n Title: ", string, contenth.title_size); + print_asf_string(" Title: ", string, contenth.title_size); } // extract the author if( contenth.author_size!=0 ) { @@ -250,7 +254,7 @@ while(!stream_eof(demuxer->stream)){ stream_read(demuxer->stream, string, contenth.rating_size); print_asf_string(" Rating: ", string, contenth.rating_size); } - printf("\n"); + mp_msg(MSGT_HEADER,MSGL_V,"\n"); free(string); } break; diff --git a/aviheader.c b/aviheader.c index 7eaa69a035..05338ccdb8 100644 --- a/aviheader.c +++ b/aviheader.c @@ -4,8 +4,7 @@ #include <unistd.h> #include "config.h" - -extern int verbose; // defined in mplayer.c +#include "mp_msg.h" #include "stream.h" #include "demuxer.h" @@ -51,12 +50,12 @@ while(1){ if(id==mmioFOURCC('L','I','S','T')){ int len=stream_read_dword_le(demuxer->stream)-4; // list size id=stream_read_dword_le(demuxer->stream); // list type - if(verbose>=2) printf("LIST %.4s len=%d\n",(char *) &id,len); + mp_dbg(MSGT_HEADER,MSGL_DBG2,"LIST %.4s len=%d\n",(char *) &id,len); if(id==listtypeAVIMOVIE){ // found MOVI header demuxer->movi_start=stream_tell(demuxer->stream); demuxer->movi_end=demuxer->movi_start+len; - if(verbose>=1) printf("Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); + mp_msg(MSGT_HEADER,MSGL_V,"Found movie at 0x%X - 0x%X\n",demuxer->movi_start,demuxer->movi_end); if(index_mode==-2) break; // reading from non-seekable source (stdin) len=(len+1)&(~1); stream_skip(demuxer->stream,len); @@ -64,7 +63,7 @@ while(1){ continue; } size2=stream_read_dword_le(demuxer->stream); - if(verbose>=2) printf("CHUNK %.4s len=%d\n",(char *) &id,size2); + mp_dbg(MSGT_HEADER,MSGL_DBG2,"CHUNK %.4s len=%d\n",(char *) &id,size2); chunksize=(size2+1)&(~1); switch(id){ case ckidAVIMAINHDR: // read 'avih' @@ -94,7 +93,7 @@ while(1){ if(last_fccType==streamtypeVIDEO){ sh_video->bih=calloc((chunksize<sizeof(BITMAPINFOHEADER))?sizeof(BITMAPINFOHEADER):chunksize,1); // sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize); - if(verbose>=1) printf("found 'bih', %d bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER)); + mp_msg(MSGT_HEADER,MSGL_V,"found 'bih', %d bytes of %d\n",chunksize,sizeof(BITMAPINFOHEADER)); stream_read(demuxer->stream,(char*) sh_video->bih,chunksize); le2me_BITMAPINFOHEADER(sh_video->bih); // swap to machine endian if(verbose>=1) print_video_header(sh_video->bih); @@ -126,7 +125,7 @@ while(1){ int wf_size = chunksize<sizeof(WAVEFORMATEX)?sizeof(WAVEFORMATEX):chunksize; sh_audio->wf=calloc(wf_size,1); // sh_audio->wf=malloc(chunksize); memset(sh_audio->wf,0,chunksize); - if(verbose>=1) printf("found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX)); + mp_msg(MSGT_HEADER,MSGL_V,"found 'wf', %d bytes of %d\n",chunksize,sizeof(WAVEFORMATEX)); stream_read(demuxer->stream,(char*) sh_audio->wf,chunksize); le2me_WAVEFORMATEX(sh_audio->wf); if (sh_audio->wf->cbSize != 0 && @@ -142,7 +141,7 @@ while(1){ case ckidAVINEWINDEX: if(index_mode){ int i; priv->idx_size=size2>>4; - if(verbose>=1) printf("Reading INDEX block, %d chunks for %ld frames\n", + mp_msg(MSGT_HEADER,MSGL_V,"Reading INDEX block, %d chunks for %ld frames\n", priv->idx_size,avih.dwTotalFrames); priv->idx=malloc(priv->idx_size<<4); stream_read(demuxer->stream,(char*)priv->idx,priv->idx_size<<4); @@ -154,7 +153,7 @@ while(1){ } } if(chunksize>0) stream_skip(demuxer->stream,chunksize); else - if(chunksize<0) printf("WARNING!!! chunksize=%d (id=%.4s)\n",chunksize,(char *) &id); + if(chunksize<0) mp_msg(MSGT_HEADER,MSGL_WARN,"chunksize=%d (id=%.4s)\n",chunksize,(char *) &id); } @@ -202,7 +201,7 @@ if(index_mode>=2 || (priv->idx_size==0 && index_mode==1)){ if(c&0x40) idx->dwFlags=0; } - if(verbose>=2) printf("%08X %08X %.4s %02X %X\n",demuxer->filepos,id,(char *) &id,c,(unsigned int) idx->dwFlags); + mp_dbg(MSGT_HEADER,MSGL_DBG2,"%08X %08X %.4s %02X %X\n",demuxer->filepos,id,(char *) &id,c,(unsigned int) idx->dwFlags); #if 0 { unsigned char tmp[64]; int i; @@ -217,7 +216,7 @@ skip_chunk: stream_seek(demuxer->stream,8+demuxer->filepos+skip); } priv->idx_size=priv->idx_pos; - printf("AVI: Generated index table for %d chunks!\n",priv->idx_size); + mp_msg(MSGT_HEADER,MSGL_INFO,"AVI: Generated index table for %d chunks!\n",priv->idx_size); } } diff --git a/dec_audio.c b/dec_audio.c index 4032656bff..7a2242ba44 100644 --- a/dec_audio.c +++ b/dec_audio.c @@ -4,6 +4,8 @@ #include <unistd.h> #include "config.h" +#include "mp_msg.h" + #include "libao2/afmt.h" extern int verbose; // defined in mplayer.c @@ -82,7 +84,7 @@ sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM switch(driver){ case AFM_ACM: #ifndef USE_WIN32DLL - printf("Win32/ACM audio codec disabled, or unavailable on non-x86 CPU -> force nosound :(\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Win32/ACM audio codec disabled, or unavailable on non-x86 CPU -> force nosound :(\n"); driver=0; #else // Win32 ACM audio codec: @@ -95,20 +97,20 @@ case AFM_ACM: // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST) // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; } else { - printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n"); driver=0; } #endif break; case AFM_DSHOW: #ifndef USE_DIRECTSHOW - printf("Compiled without DirectShow support -> force nosound :(\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Compiled without DirectShow support -> force nosound :(\n"); driver=0; #else // Win32 DShow audio codec: // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate); if(DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)){ - printf("ERROR: Could not load/initialize Win32/DirctShow AUDIO codec: %s\n",sh_audio->codec->dll); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not load/initialize Win32/DirctShow AUDIO codec: %s\n",sh_audio->codec->dll); driver=0; } else { sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; @@ -153,12 +155,12 @@ if(!driver) return 0; // allocate audio out buffer: sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc. -if(verbose) printf("dec_audio: Allocating %d + %d = %d bytes for output buffer\n", +mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d + %d = %d bytes for output buffer\n", sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); if(!sh_audio->a_buffer){ - fprintf(stderr,"Cannot allocate audio out buffer\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Cannot allocate audio out buffer\n"); return 0; } memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); @@ -169,7 +171,7 @@ switch(driver){ case AFM_ACM: { int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); if(ret<0){ - printf("ACM decoding error: %d\n",ret); + mp_msg(MSGT_DECAUDIO,MSGL_WARN,"ACM decoding error: %d\n",ret); driver=0; } sh_audio->a_buffer_len=ret; @@ -234,12 +236,12 @@ case AFM_HWAC3: { len = ds_get_packet(sh_audio->ds, &buffer); // maybe 1 packet is not enough, // at least for mpeg, PS packets contain about max. 2000 bytes of data. if(ac3_iec958_parse_syncinfo(buffer, len, &ai, &skipped) < 0) { - fprintf(stderr, "AC3 stream not valid.\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR, "AC3 stream not valid.\n"); driver = 0; break; } if(ai.samplerate != 48000) { - fprintf(stderr, "Only 48000 Hz streams supported.\n"); + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Only 48000 Hz streams supported.\n"); driver = 0; break; } @@ -289,7 +291,7 @@ case AFM_MPEG: { } if(!sh_audio->channels || !sh_audio->samplerate){ - printf("Unknown/missing audio format, using nosound\n"); + mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Unknown/missing audio format, using nosound\n"); driver=0; } @@ -385,7 +387,7 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ { int size_in=0; int size_out=0; int srcsize=DS_AudioDecoder_GetSrcSize(maxlen); - if(verbose>2)printf("DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); + mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! if(sh_audio->a_in_buffer_len<srcsize){ sh_audio->a_in_buffer_len+= @@ -394,8 +396,7 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ } DS_AudioDecoder_Convert(sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, buf,maxlen, &size_in,&size_out); - if(verbose) - printf("DShow: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds)); + mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DShow: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds)); if(size_in>=sh_audio->a_in_buffer_len){ sh_audio->a_in_buffer_len=0; } else { diff --git a/dec_video.c b/dec_video.c index e906591c06..1888ef146c 100644 --- a/dec_video.c +++ b/dec_video.c @@ -4,6 +4,7 @@ #include <unistd.h> #include "config.h" +#include "mp_msg.h" extern int verbose; // defined in mplayer.c extern int divx_quality; @@ -152,7 +153,7 @@ switch(sh_video->codec->driver){ // exit(1); return 0; } - if(verbose) printf("INFO: Win32 video codec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); break; } case VFM_VFWEX: { @@ -161,12 +162,12 @@ switch(sh_video->codec->driver){ // exit(1); return 0; } - if(verbose) printf("INFO: Win32Ex video codec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n"); break; } case VFM_DSHOW: { // Win32/DirectShow #ifndef USE_DIRECTSHOW - fprintf(stderr,"MPlayer was compiled WITHOUT directshow support!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT directshow support!\n"); return 0; // GUI_MSG( mplCompileWithoutDSSupport ) // exit(1); @@ -174,10 +175,10 @@ switch(sh_video->codec->driver){ int bpp; if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ - printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); - printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); - printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); - printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); + mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); + mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); +// mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); return 0; // #ifdef HAVE_GUI // if ( !nogui ) @@ -213,7 +214,7 @@ switch(sh_video->codec->driver){ // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); - if(verbose) printf("INFO: Win32/DShow video codec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n"); break; #endif } @@ -221,11 +222,11 @@ switch(sh_video->codec->driver){ case VFM_VFW: case VFM_DSHOW: case VFM_VFWEX: - fprintf(stderr,"Support for win32 codecs disabled, or unavailable on non-x86 platforms!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Support for win32 codecs disabled, or unavailable on non-x86 platforms!\n"); return 0; #endif /* !USE_WIN32DLL */ case VFM_ODIVX: { // OpenDivX - if(verbose) printf("OpenDivX video codec\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n"); { DEC_PARAM dec_param; DEC_SET dec_set; memset(&dec_param,0,sizeof(dec_param)); @@ -240,15 +241,15 @@ switch(sh_video->codec->driver){ dec_set.postproc_level = divx_quality; decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); } - if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); break; } case VFM_DIVX4: { // DivX4Linux #ifndef NEW_DECORE - fprintf(stderr,"MPlayer was compiled WITHOUT DivX4Linux (libdivxdecore.so) support!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT DivX4Linux (libdivxdecore.so) support!\n"); return 0; //exit(1); #else - if(verbose) printf("DivX4Linux video codec\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n"); { DEC_PARAM dec_param; DEC_SET dec_set; int bits=16; @@ -263,7 +264,7 @@ switch(sh_video->codec->driver){ case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; default: - fprintf(stderr,"Unsupported out_fmt: 0x%X\n",out_fmt); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",out_fmt); return 0; } dec_param.x_dim = sh_video->bih->biWidth; @@ -274,35 +275,35 @@ switch(sh_video->codec->driver){ sh_video->our_out_buffer = shmem_alloc(((bits*dec_param.x_dim+7)/8)*dec_param.y_dim); // sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5); } - if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); break; #endif } case VFM_FFMPEG: { // FFmpeg's libavcodec #ifndef USE_LIBAVCODEC - fprintf(stderr,"MPlayer was compiled WITHOUT libavcodec support!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT libavcodec support!\n"); return 0; //exit(1); #else - if(verbose) printf("FFmpeg's libavcodec video codec\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n"); avcodec_init(); avcodec_register_all(); lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll); if(!lavc_codec){ - fprintf(stderr,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll); return 0; //exit(1); } memset(&lavc_context, 0, sizeof(lavc_context)); // sh_video->disp_h/=2; // !! lavc_context.width=sh_video->disp_w; lavc_context.height=sh_video->disp_h; - printf("libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); /* open it */ if (avcodec_open(&lavc_context, lavc_codec) < 0) { - fprintf(stderr, "could not open codec\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR, "could not open codec\n"); return 0; //exit(1); } - if(verbose) printf("INFO: libavcodec init OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); break; #endif } @@ -313,9 +314,9 @@ switch(sh_video->codec->driver){ picture->pp_options=divx_quality; #else if(divx_quality){ - printf("WARNING! You requested image postprocessing for an MPEG 1/2 video,\n"); - printf(" but compiled MPlayer without MPEG 1/2 postprocessing support!\n"); - printf(" #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_HINT,"WARNING! You requested image postprocessing for an MPEG 1/2 video,\n"); + mp_msg(MSGT_DECVIDEO,MSGL_HINT," but compiled MPlayer without MPEG 1/2 postprocessing support!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_HINT," #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n"); } #endif mpeg2_allocate_image_buffers (picture); @@ -415,7 +416,7 @@ switch(sh_video->codec->driver){ #ifdef USE_LIBAVCODEC case VFM_FFMPEG: { // libavcodec int got_picture=0; -if(verbose>1) printf("Calling ffmpeg...\n"); + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"Calling ffmpeg...\n"); if(drop_frame<2 && in_size>0){ int ret = avcodec_decode_video(&lavc_context, &lavc_picture, &got_picture, start, in_size); @@ -431,10 +432,10 @@ if(verbose>1){ case PIX_FMT_YUV444P: x="YUV444P";break; #endif } - printf("DONE -> got_picture=%d format=0x%X (%s) \n",got_picture, + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"DONE -> got_picture=%d format=0x%X (%s) \n",got_picture, lavc_context.pix_fmt,x); } - if(ret<0) fprintf(stderr, "Error while decoding frame!\n"); + if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n"); if(!drop_frame && got_picture){ // if(!drop_frame){ if(planar){ @@ -498,7 +499,7 @@ else &sh_video->o_bih, drop_frame ? 0 : sh_video->our_out_buffer); - if(ret){ printf("Error decompressing frame, err=%d\n",(int)ret);break; } + if(ret){ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",(int)ret);break; } if(!drop_frame) blit_frame=3; break; @@ -570,38 +571,38 @@ switch(d_video->demuxer->file_format){ case DEMUXER_TYPE_MPEG_ES: case DEMUXER_TYPE_MPEG_PS: { // Find sequence_header first: - if(verbose) printf("Searching for sequence header... ");fflush(stdout); + mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for sequence header... ");fflush(stdout); while(1){ int i=sync_video_packet(d_video); if(i==0x1B3) break; // found it! if(!i || !skip_video_packet(d_video)){ - if(verbose) printf("NONE :(\n"); - fprintf(stderr,"MPEG: FATAL: EOF while searching for sequence header\n"); + if(verbose) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: FATAL: EOF while searching for sequence header\n"); return 0; // GUI_MSG( mplMPEGErrorSeqHeaderSearch ) // exit(1); } } - if(verbose) printf("OK!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); // sh_video=d_video->sh;sh_video->ds=d_video; mpeg2_init(); // ========= Read & process sequence header & extension ============ videobuffer=shmem_alloc(VIDEOBUFFER_SIZE); if(!videobuffer){ - fprintf(stderr,"Cannot allocate shared memory\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory\n"); return 0; // GUI_MSG( mplErrorShMemAlloc ) // exit(0); } videobuf_len=0; if(!read_video_packet(d_video)){ - fprintf(stderr,"FATAL: Cannot read sequence header!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header!\n"); return 0; // GUI_MSG( mplMPEGErrorCannotReadSeqHeader ) // exit(1); } if(header_process_sequence_header (picture, &videobuffer[4])) { - printf ("bad sequence header!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header!\n"); return 0; // GUI_MSG( mplMPEGErrorBadSeqHeader ) // exit(1); @@ -610,13 +611,13 @@ switch(d_video->demuxer->file_format){ // videobuf_len=0; int pos=videobuf_len; if(!read_video_packet(d_video)){ - fprintf(stderr,"FATAL: Cannot read sequence header extension!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header extension!\n"); return 0; // GUI_MSG( mplMPEGErrorCannotReadSeqHeaderExt ) // exit(1); } if(header_process_extension (picture, &videobuffer[pos+4])) { - printf ("bad sequence header extension!\n"); + mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header extension!\n"); return 0; // GUI_MSG( mplMPEGErrorBadSeqHeaderExt ) // exit(1); @@ -640,8 +641,8 @@ switch(d_video->demuxer->file_format){ if(picture->bitrate!=0x3FFFF) // unspecified/VBR ? sh_video->i_bps=1000*picture->bitrate/16; // info: - if(verbose) printf("mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); - printf("VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); + mp_msg(MSGT_DECVIDEO,MSGL_INFO,"VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", picture->mpeg1?"MPEG1":"MPEG2", sh_video->disp_w,sh_video->disp_h, picture->aspect_ratio_information, diff --git a/demux_asf.c b/demux_asf.c index e7d4ac3f3e..c159c7c154 100644 --- a/demux_asf.c +++ b/demux_asf.c @@ -4,7 +4,8 @@ #include <stdlib.h> #include <unistd.h> -extern int verbose; // defined in mplayer.c +#include "config.h" +#include "mp_msg.h" #include "stream.h" #include "asf.h" @@ -42,7 +43,7 @@ static void asf_descrambling(unsigned char *src,int len){ unsigned char *s2=src; int i=0,x,y; while(len-i>=asf_scrambling_h*asf_scrambling_w*asf_scrambling_b){ -// printf("descrambling! (w=%d b=%d)\n",w,asf_scrambling_b); +// mp_msg(MSGT_DEMUX,MSGL_DBG4,"descrambling! (w=%d b=%d)\n",w,asf_scrambling_b); //i+=asf_scrambling_h*asf_scrambling_w; for(x=0;x<asf_scrambling_w;x++) for(y=0;y<asf_scrambling_h;y++){ @@ -60,7 +61,7 @@ static void asf_descrambling(unsigned char *src,int len){ static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,int id,int seq,unsigned long time,unsigned short dur,int offs,int keyframe){ demux_stream_t *ds=NULL; - if(verbose>=4) printf("demux_asf.read_packet: id=%d seq=%d len=%d\n",id,seq,len); + mp_dbg(MSGT_DEMUX,MSGL_DBG4,"demux_asf.read_packet: id=%d seq=%d len=%d\n",id,seq,len); if(demux->video->id==-1) if(demux->v_streams[id]) @@ -75,7 +76,7 @@ static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,in ds=demux->audio; if(!ds->sh){ ds->sh=demux->a_streams[id]; - if(verbose) printf("Auto-selected ASF audio ID = %d\n",ds->id); + mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected ASF audio ID = %d\n",ds->id); } } else if(id==demux->video->id){ @@ -83,7 +84,7 @@ static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,in ds=demux->video; if(!ds->sh){ ds->sh=demux->v_streams[id]; - if(verbose) printf("Auto-selected ASF video ID = %d\n",ds->id); + mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected ASF video ID = %d\n",ds->id); } } @@ -99,10 +100,10 @@ static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,in } else { // append data to it! demux_packet_t* dp=ds->asf_packet; - if(dp->len!=offs && offs!=-1) printf("warning! fragment.len=%d BUT next fragment offset=%d \n",dp->len,offs); + if(dp->len!=offs && offs!=-1) mp_msg(MSGT_DEMUX,MSGL_V,"warning! fragment.len=%d BUT next fragment offset=%d \n",dp->len,offs); dp->buffer=realloc(dp->buffer,dp->len+len); memcpy(dp->buffer+dp->len,data,len); - if(verbose>=4) printf("data appended! %d+%d\n",dp->len,len); + mp_dbg(MSGT_DEMUX,MSGL_DBG4,"data appended! %d+%d\n",dp->len,len); dp->len+=len; // we are ready now. return 1; @@ -111,7 +112,7 @@ static int demux_asf_read_packet(demuxer_t *demux,unsigned char *data,int len,in // create new packet: { demux_packet_t* dp; if(offs>0){ - if(verbose) printf("warning! broken fragment, %d bytes missing \n",offs); + mp_msg(MSGT_DEMUX,MSGL_V,"warning! broken fragment, %d bytes missing \n",offs); return 0; } dp=new_demux_packet(len); @@ -172,12 +173,12 @@ int demux_asf_fill_buffer(demuxer_t *demux){ if(flags&0x40){ // Explicit (absoulte) packet size plen=LOAD_LE16(p); p+=2; - if(verbose>1)printf("Explicit packet size specified: %d \n",plen); - if(plen>asf_packetsize) printf("Warning! plen>packetsize! (%d>%d) \n",plen,asf_packetsize); + mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Explicit packet size specified: %d \n",plen); + if(plen>asf_packetsize) mp_msg(MSGT_DEMUX,MSGL_V,"Warning! plen>packetsize! (%d>%d) \n",plen,asf_packetsize); if(flags&(8|16)){ padding=p[0];p++; if(flags&16){ padding|=p[0]<<8; p++;} - if(verbose)printf("Warning! explicit=%d padding=%d \n",plen,asf_packetsize-padding); + mp_msg(MSGT_DEMUX,MSGL_V,"Warning! explicit=%d padding=%d \n",plen,asf_packetsize-padding); } } else { // Padding (relative) size @@ -197,7 +198,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ segs=p[0] & 0x3F; ++p; } - if(verbose>=4) printf("%08X: flag=%02X segs=%d pad=%d time=%ld dur=%d\n", + mp_dbg(MSGT_DEMUX,MSGL_DBG4,"%08X: flag=%02X segs=%d pad=%d time=%ld dur=%d\n", demux->filepos,flags,segs,padding,time,duration); for(seg=0;seg<segs;seg++){ //ASF_segmhdr_t* sh; @@ -209,7 +210,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ unsigned long time2; int keyframe=0; - if(p>=p_end) printf("Warning! invalid packet 1, sig11 coming soon...\n"); + if(p>=p_end) mp_msg(MSGT_DEMUX,MSGL_V,"Warning! invalid packet 1, sig11 coming soon...\n"); if(verbose>1){ int i; @@ -237,7 +238,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ p+=4; break; default: - printf("Warning! unknown segtype == 0x%2X \n",segtype); + mp_msg(MSGT_DEMUX,MSGL_V,"Warning! unknown segtype == 0x%2X \n",segtype); x=0; } @@ -254,7 +255,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ time2=LOAD_LE32(p);p+=4; break; default: - printf("unknown segment type: 0x%02X \n",type); + mp_msg(MSGT_DEMUX,MSGL_V,"unknown segment type: 0x%02X \n",type); } if(flags&1){ @@ -269,9 +270,9 @@ int demux_asf_fill_buffer(demuxer_t *demux){ len=plen-(p-asf_packet); } if(len<0 || (p+len)>=p_end){ - printf("ASF_parser: warning! segment len=%d\n",len); + mp_msg(MSGT_DEMUX,MSGL_V,"ASF_parser: warning! segment len=%d\n",len); } - if(verbose>=4) printf(" seg #%d: streamno=%d seq=%d type=%02X len=%d\n",seg,streamno,seq,type,len); + mp_dbg(MSGT_DEMUX,MSGL_DBG4," seg #%d: streamno=%d seq=%d type=%02X len=%d\n",seg,streamno,seq,type,len); switch(type){ case 0x01: @@ -287,7 +288,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ len-=len2+1; } if(len!=0){ - printf("ASF_parser: warning! groups total != len\n"); + mp_msg(MSGT_DEMUX,MSGL_V,"ASF_parser: warning! groups total != len\n"); } break; case 0x08: @@ -302,7 +303,7 @@ int demux_asf_fill_buffer(demuxer_t *demux){ return 1; // success } - printf("%08X: UNKNOWN TYPE %02X %02X %02X %02X %02X...\n",demux->filepos,asf_packet[0],asf_packet[1],asf_packet[2],asf_packet[3],asf_packet[4]); + mp_msg(MSGT_DEMUX,MSGL_V,"%08X: UNKNOWN TYPE %02X %02X %02X %02X %02X...\n",demux->filepos,asf_packet[0],asf_packet[1],asf_packet[2],asf_packet[3],asf_packet[4]); return 0; } diff --git a/demux_avi.c b/demux_avi.c index 0ccd4c444f..f7bc09d966 100644 --- a/demux_avi.c +++ b/demux_avi.c @@ -4,7 +4,8 @@ #include <stdlib.h> #include <unistd.h> -extern int verbose; // defined in mplayer.c +#include "config.h" +#include "mp_msg.h" #include "stream.h" #include "demuxer.h" @@ -36,20 +37,20 @@ demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id){ if(stream_id==demux->audio->id){ if(!demux->audio->sh){ demux->audio->sh=demux->a_streams[stream_id]; - if(verbose) printf("Auto-selected AVI audio ID = %d\n",demux->audio->id); + mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI audio ID = %d\n",demux->audio->id); } return demux->audio; } if(stream_id==demux->video->id){ if(!demux->video->sh){ demux->video->sh=demux->v_streams[stream_id]; - if(verbose) printf("Auto-selected AVI video ID = %d\n",demux->video->id); + mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI video ID = %d\n",demux->video->id); } return demux->video; } if(id!=mmioFOURCC('J','U','N','K')){ // unknown - if(verbose>=2) printf("Unknown chunk: %.4s (%X)\n",(char *) &id,id); + mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Unknown chunk: %.4s (%X)\n",(ch |