[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[616] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-12-28 08:16:23
|
Revision: 616 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=616&view=rev Author: nickols_k Date: 2012-12-28 08:16:10 +0000 (Fri, 28 Dec 2012) Log Message: ----------- cleanups and fixes Modified Paths: -------------- mplayerxp/libmpcodecs/dec_audio.cpp mplayerxp/libmpcodecs/dec_audio.h mplayerxp/libmpcodecs/dec_video.cpp mplayerxp/libmpcodecs/dec_video.h mplayerxp/mplayerxp.cpp Modified: mplayerxp/libmpcodecs/dec_audio.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_audio.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_audio.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -196,7 +196,7 @@ /* Init audio filters */ MPXP_Rc mpca_preinit_filters(audio_decoder_t& opaque, unsigned in_samplerate, unsigned in_channels, unsigned in_format, - unsigned* out_samplerate, unsigned* out_channels, unsigned* out_format){ + unsigned& out_samplerate, unsigned& out_channels, unsigned& out_format){ decaudio_priv_t* priv = reinterpret_cast<decaudio_priv_t*>(opaque.ad_private); sh_audio_t* sh_audio = priv->parent; char strbuf[200]; @@ -208,9 +208,9 @@ afs->input.format = afmt2mpaf(in_format); // output format: same as ao driver's input format (if missing, fallback to input) - afs->output.rate = *out_samplerate ? *out_samplerate : afs->input.rate; - afs->output.nch = *out_channels ? *out_channels : afs->input.nch; - if(*out_format) afs->output.format = afmt2mpaf(*out_format); + afs->output.rate = out_samplerate ? out_samplerate : afs->input.rate; + afs->output.nch = out_channels ? out_channels : afs->input.nch; + if(out_format) afs->output.format = afmt2mpaf(out_format); else afs->output.format = afs->input.format; // filter config: @@ -225,9 +225,9 @@ return MPXP_False; // failed :( } - *out_samplerate=afs->output.rate; - *out_channels=afs->output.nch; - *out_format=mpaf2afmt(afs->output.format); + out_samplerate=afs->output.rate; + out_channels=afs->output.nch; + out_format=mpaf2afmt(afs->output.format); sh_audio->af_bps = afs->output.rate*afs->output.nch*(afs->output.format&MPAF_BPS_MASK); Modified: mplayerxp/libmpcodecs/dec_audio.h =================================================================== --- mplayerxp/libmpcodecs/dec_audio.h 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_audio.h 2012-12-28 08:16:10 UTC (rev 616) @@ -24,7 +24,7 @@ unsigned out_minsize, unsigned out_maxsize); extern MPXP_Rc mpca_preinit_filters(audio_decoder_t& sh_audio, unsigned in_samplerate, unsigned in_channels, unsigned in_format, - unsigned* out_samplerate, unsigned* out_channels, unsigned* out_format); + unsigned& out_samplerate, unsigned& out_channels, unsigned& out_format); extern MPXP_Rc mpca_reinit_filters(audio_decoder_t& sh_audio, unsigned in_samplerate, unsigned in_channels, mpaf_format_e in_format, unsigned out_samplerate, unsigned out_channels, mpaf_format_e out_format, Modified: mplayerxp/libmpcodecs/dec_video.cpp =================================================================== --- mplayerxp/libmpcodecs/dec_video.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_video.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -83,15 +83,15 @@ return MPXP_False; } -MPXP_Rc mpcv_set_colors(video_decoder_t& opaque,const char *item,int value) +MPXP_Rc mpcv_set_colors(video_decoder_t& opaque,const std::string& item,int value) { decvideo_priv_t* priv=reinterpret_cast<decvideo_priv_t*>(opaque.vd_private); vf_stream_t* vs=priv->vfilter; vf_equalizer_t eq; - eq.item=item; + eq.item=item.c_str(); eq.value=value*10; if(vf_control(vs,VFCTRL_SET_EQUALIZER,&eq)!=MPXP_True) { - if(priv->mpvdec) return priv->mpvdec->control_vd(*priv->ctx,VDCTRL_SET_EQUALIZER,(any_t*)item,(int)value); + if(priv->mpvdec) return priv->mpvdec->control_vd(*priv->ctx,VDCTRL_SET_EQUALIZER,(any_t*)item.c_str(),(int)value); } return MPXP_False; } @@ -169,7 +169,7 @@ return handle; } -video_decoder_t* mpcv_init(sh_video_t *sh_video,const char* codecname,const char * vfm,int status,libinput_t&libinput){ +video_decoder_t* mpcv_init(sh_video_t *sh_video,const std::string& codecname,const std::string& family,int status,libinput_t&libinput){ UNUSED(codecname); UNUSED(status); int done=0; @@ -179,6 +179,7 @@ decvideo_priv_t* priv = new(zeromem) decvideo_priv_t(libinput); priv->parent=sh_video; handle->vd_private=priv; + std::string vfm=family; MP_UNIT("init_video_filters"); if(priv->vfilter_inited<=0) { @@ -190,7 +191,7 @@ priv->vfilter_inited=1; } - if(vfm) { + if(!vfm.empty()) { priv->mpvdec=vfm_find_driver(vfm); if(priv->mpvdec) vprobe=priv->mpvdec->probe(sh_video->fourcc); } Modified: mplayerxp/libmpcodecs/dec_video.h =================================================================== --- mplayerxp/libmpcodecs/dec_video.h 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/libmpcodecs/dec_video.h 2012-12-28 08:16:10 UTC (rev 616) @@ -12,14 +12,14 @@ }; // dec_video.c: -extern video_decoder_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const char *codec_name,const char *family,int status,libinput_t&libinput); +extern video_decoder_t* __FASTCALL__ mpcv_init(sh_video_t *sh_video, const std::string& codec_name,const std::string& family,int status,libinput_t&libinput); extern void __FASTCALL__ mpcv_uninit(video_decoder_t& handle); extern video_decoder_t* __FASTCALL__ mpcv_lavc_init(sh_video_t*,libinput_t& libinput); extern int __FASTCALL__ mpcv_decode(video_decoder_t& handle,const enc_frame_t& frame); extern MPXP_Rc __FASTCALL__ mpcv_get_quality_max(video_decoder_t& handle,unsigned& quality); extern MPXP_Rc __FASTCALL__ mpcv_set_quality(video_decoder_t& handle,int quality); -extern MPXP_Rc __FASTCALL__ mpcv_set_colors(video_decoder_t& handle,const char *item,int value); +extern MPXP_Rc __FASTCALL__ mpcv_set_colors(video_decoder_t& handle,const std::string& item,int value); extern void __FASTCALL__ mpcv_resync_stream(video_decoder_t& handle); extern void vfm_help(void); Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-28 07:33:30 UTC (rev 615) +++ mplayerxp/mplayerxp.cpp 2012-12-28 08:16:10 UTC (rev 616) @@ -243,22 +243,6 @@ /**************************************************************************/ MPXPContext& mpxp_context() { return *MPXPCtx; } -static int mpxp_init_antiviral_protection(int verbose) -{ - int rc; - rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole2,sizeof(antiviral_hole2),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole3,sizeof(antiviral_hole3),MP_DENY_ALL); - rc|=mp_mprotect((any_t*)antiviral_hole4,sizeof(antiviral_hole4),MP_DENY_ALL); - if(verbose) { - if(rc) - mpxp_err<<"*** Error! Cannot initialize antiviral protection: '"<<strerror(errno)<<"' ***!"<<std::endl; - else - mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; - } - return rc; -} - static MPXP_Rc mpxp_test_antiviral_protection(int* verbose) { if(*verbose) mpxp_info<<"Your've specified test-av option!\nRight now MPlayerXP should make coredump!"<<std::endl; @@ -282,12 +266,6 @@ #endif } -static void mpxp_init_structs(void) { -#if defined( ARCH_X86 ) || defined(ARCH_X86_64) - memset(&mp_conf.x86,-1,sizeof(x86_features_t)); -#endif -} - static void mpxp_uninit_structs(void) { #ifdef ENABLE_WIN32LOADER free_codec_cfg(); @@ -1159,7 +1137,7 @@ if(vo_conf.softzoom) mpxp_context().video().output->ZOOM_SET(); if(vo_conf.flip>0) mpxp_context().video().output->FLIP_SET(); if(vo_conf.vidmode) mpxp_context().video().output->VM_SET(); - if((mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec,mp_conf.video_family,-1,_libinput))) sh_video->inited=1; + if((mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec?mp_conf.video_codec:"",mp_conf.video_family?mp_conf.video_family:"",-1,_libinput))) sh_video->inited=1; #ifdef ENABLE_WIN32LOADER if(!sh_video->inited) { /* Go through the codec.conf and find the best codec...*/ @@ -1167,15 +1145,15 @@ if(mp_conf.video_codec) { /* forced codec by name: */ mpxp_info<<"Forced video codec: "<<mp_conf.video_codec<<std::endl; - mpxp_context().video().decoder=mpcv_init(sh_video,mp_conf.video_codec,NULL,-1,_libinput); + mpxp_context().video().decoder=mpcv_init(sh_video,video_codec?mp_conf.video_codec:"","",-1,_libinput); } else { int status; /* try in stability order: UNTESTED, WORKING, BUGGY, BROKEN */ if(mp_conf.video_family) mpxp_info<<MSGTR_TryForceVideoFmt<<": "<<mp_conf.video_family<<std::endl; for(status=CODECS_STATUS__MAX;status>=CODECS_STATUS__MIN;--status){ if(mp_conf.video_family) /* try first the preferred codec family:*/ - if((mpxp_context().video().decoder=mpcv_init(sh_video,NULL,mp_conf.video_family,status,_libinput))) break; - if((mpxp_context().video().decoder=mpcv_init(sh_video,NULL,NULL,status,_libinput))) break; + if((mpxp_context().video().decoder=mpcv_init(sh_video,"",mp_conf.video_family?mp_conf.video_family:"",status,_libinput))) break; + if((mpxp_context().video().decoder=mpcv_init(sh_video,"","",status,_libinput))) break; } } } @@ -1232,7 +1210,7 @@ (int)(sh_audio->rate), sh_audio->nch, sh_audio->afmt, // output: - &samplerate, &channels, &format)!=MPXP_Ok){ + samplerate, channels, format)!=MPXP_Ok){ mpxp_err<<"Audio filter chain preinit failed"<<std::endl; } else { mpxp_v<<"AF_pre: "<<samplerate<<"Hz "<<channels<<"ch (" @@ -1614,37 +1592,11 @@ return eof; } -static void mpxp_config_malloc(const std::vector<std::string>& argv) -{ - size_t i,sz=argv.size(); - mp_conf.malloc_debug=0; - mp_malloc_e flg=MPA_FLG_RANDOMIZER; - for(i=0;i<sz;i++) { - std::string s=argv[i]; - if(s.substr(0,18)=="-core.malloc-debug") { - size_t pos; - if((pos=s.find('='))!=std::string::npos) { - mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); - } - switch(mp_conf.malloc_debug) { - default: - case 0: flg=MPA_FLG_RANDOMIZER; break; - case 1: flg=MPA_FLG_BOUNDS_CHECK; break; - case 2: flg=MPA_FLG_BEFORE_CHECK; break; - case 3: flg=MPA_FLG_BACKTRACE; break; - } - break; - } - } - mp_init_malloc(argv[0],1000,10,flg); -} - _PlayTree_Iter* mpxp_get_playtree_iter() { return mpxp_context().engine().MPXPSys->playtree_iter; } /******************************************\ * MAIN MPLAYERXP FUNCTION !!! * \******************************************/ int MPlayerXP(const std::vector<std::string>& argv, const std::map<std::string,std::string>& envm){ - mpxp_init_antiviral_protection(1); // mpxp_test_backtrace(); Stream* stream=NULL; int stream_dump_type=0; @@ -1659,14 +1611,10 @@ int forced_subs_only=0; seek_args_t seek_args = { 0, DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS }; - mpxp_config_malloc(argv); - // Yes, it really must be placed in stack or in very secret place PointerProtector<MPXPSecureKeys> ptr_protector; secure_keys=ptr_protector.protect(new(zeromem) MPXPSecureKeys(10)); - mpxp_init_structs(); - mpxp_context().video().output=new(zeromem) Video_Output; init_signal_handling(); @@ -2012,7 +1960,6 @@ while(!eof){ int in_pause=0; - eof |= mpxp_context().engine().xp_core->audio->eof; /*========================== UPDATE TIMERS ============================*/ MP_UNIT("Update timers"); if(sh_audio) eof = mpxp_context().engine().xp_core->audio->eof; @@ -2030,7 +1977,7 @@ //================= Keyboard events, SEEKing ==================== memset(&input_state,0,sizeof(input_state_t)); - eof=MPXPSys.handle_input(&seek_args,&osd,&input_state); + eof|=MPXPSys.handle_input(&seek_args,&osd,&input_state); if(input_state.next_file) goto goto_next_file; if (mp_conf.seek_to_sec) { @@ -2169,11 +2116,46 @@ str=str.substr(0,pos); envm[str]=stmp; } + /* init antiviral protection */ + int rc; + rc=mp_mprotect((any_t*)antiviral_hole1,sizeof(antiviral_hole1),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole2,sizeof(antiviral_hole2),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole3,sizeof(antiviral_hole3),MP_DENY_ALL); + rc|=mp_mprotect((any_t*)antiviral_hole4,sizeof(antiviral_hole4),MP_DENY_ALL); + if(rc) { + mpxp_err<<"*** Error! Cannot initialize antiviral protection: '"<<strerror(errno)<<"' ***!"<<std::endl; + return EXIT_FAILURE; + } + mpxp_ok<<"*** Antiviral protection was inited ***!!!"<<std::endl; + /* init malloc */ + size_t i,sz=argv.size(); + mp_conf.malloc_debug=0; + mp_malloc_e flg=MPA_FLG_RANDOMIZER; + for(i=0;i<sz;i++) { + std::string s=argv[i]; + if(s.substr(0,18)=="-core.malloc-debug") { + if((pos=s.find('='))!=std::string::npos) { + mp_conf.malloc_debug=::atoi(s.substr(pos+1).c_str()); + } + switch(mp_conf.malloc_debug) { + default: + case 0: flg=MPA_FLG_RANDOMIZER; break; + case 1: flg=MPA_FLG_BOUNDS_CHECK; break; + case 2: flg=MPA_FLG_BEFORE_CHECK; break; + case 3: flg=MPA_FLG_BACKTRACE; break; + } + break; + } + } + mp_init_malloc(argv[0],1000,10,flg); + /* init structs */ +#if defined( ARCH_X86 ) || defined(ARCH_X86_64) + memset(&mp_conf.x86,-1,sizeof(x86_features_t)); +#endif + /* call player */ return MPlayerXP(argv,envm); } catch(const std::string& what) { std::cout<<"[main_module] Exception '"<<what<<"'caught in module: MPlayerXP"<<std::endl; -// } catch(...) { -// std::cout<<"[main_module] Exception caught in module: MPlayerXP"<<std::endl; } return EXIT_FAILURE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |