[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[272] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-01 08:38:20
|
Revision: 272 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=272&view=rev Author: nickols_k Date: 2012-11-01 08:38:09 +0000 (Thu, 01 Nov 2012) Log Message: ----------- remove useless fields + cleanups + segfaults-- Modified Paths: -------------- mplayerxp/libao2/ao_wav.c mplayerxp/libmpcodecs/dec_audio.c mplayerxp/libmpcodecs/dec_video.c mplayerxp/libmpcodecs/vd.c mplayerxp/libmpdemux/cache2.c mplayerxp/libmpdemux/demuxer_r.c mplayerxp/libmpsub/spudec.c mplayerxp/libvo/sub.c mplayerxp/libvo/video_out.c mplayerxp/mplayer.c mplayerxp/postproc/vf.c mplayerxp/sig_hand.c mplayerxp/sig_hand.h mplayerxp/xmp_core.c mplayerxp/xmp_core.h Modified: mplayerxp/libao2/ao_wav.c =================================================================== --- mplayerxp/libao2/ao_wav.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libao2/ao_wav.c 2012-11-01 08:38:09 UTC (rev 272) @@ -222,7 +222,7 @@ extern vo_data_t* vo_data; static unsigned get_space(ao_data_t* ao){ priv_t* priv=ao->priv; - float pts=dae_played_fra(xp_core.video).v_pts; + float pts=dae_played_fra(xp_core->video).v_pts; if(pts) return ao->pts < pts + priv->fast * 30000 ? ao->outburst : 0; return ao->outburst; Modified: mplayerxp/libmpcodecs/dec_audio.c =================================================================== --- mplayerxp/libmpcodecs/dec_audio.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpcodecs/dec_audio.c 2012-11-01 08:38:09 UTC (rev 272) @@ -116,10 +116,10 @@ } } else - if(xp_core.initial_apts_corr.need_correction==1) + if(xp_core->initial_apts_corr.need_correction==1) { - xp_core.initial_apts += ((float)(xp_core.initial_apts_corr.pts_bytes-xp_core.initial_apts_corr.nbytes))/(float)sh_audio->i_bps; - xp_core.initial_apts_corr.need_correction=0; + xp_core->initial_apts += ((float)(xp_core->initial_apts_corr.pts_bytes-xp_core->initial_apts_corr.nbytes))/(float)sh_audio->i_bps; + xp_core->initial_apts_corr.need_correction=0; } MSG_OK("[AC] %s decoder: [%s] drv:%s.%s ratio %i->%i\n",mp_conf.audio_codec?"Forcing":"Selecting" ,sh_audio->codec->codec_name Modified: mplayerxp/libmpcodecs/dec_video.c =================================================================== --- mplayerxp/libmpcodecs/dec_video.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpcodecs/dec_video.c 2012-11-01 08:38:09 UTC (rev 272) @@ -264,7 +264,7 @@ if(drop_frame) return 0; update_subtitle(sh_video,pts,mpi->xp_idx); - vo_flush_page(vo_data,dae_curr_vdecoded()); + vo_flush_page(vo_data,dae_curr_vdecoded(xp_core)); t2=GetTimer()-t2; tt=t2*0.000001f; Modified: mplayerxp/libmpcodecs/vd.c =================================================================== --- mplayerxp/libmpcodecs/vd.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpcodecs/vd.c 2012-11-01 08:38:09 UTC (rev 272) @@ -272,7 +272,7 @@ // Note: buffer allocation may be moved to mpcodecs_config_vo() later... mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,int w, int h){ MSG_DBG2("mpcodecs_get_image(vf_%s,%i,%i,%i,%i) was called\n",((vf_instance_t *)(sh->vfilter))->info->name,mp_imgtype,mp_imgflag,w,h); - mp_image_t* mpi=vf_get_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h,dae_curr_vdecoded()); + mp_image_t* mpi=vf_get_image(sh->vfilter,sh->codec->outfmt[sh->outfmtidx],mp_imgtype,mp_imgflag,w,h,dae_curr_vdecoded(xp_core)); mpi->x=mpi->y=0; if(mpi->xp_idx==XP_IDX_INVALID) MSG_V("[mpcodecs_get_image] Incorrect mpi->xp_idx. Be ready for segfault!\n"); Modified: mplayerxp/libmpdemux/cache2.c =================================================================== --- mplayerxp/libmpdemux/cache2.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpdemux/cache2.c 2012-11-01 08:38:09 UTC (rev 272) @@ -296,7 +296,7 @@ unsigned rc; if((rc=xmp_register_thread(NULL,sig_cache2,cache2_routine,"cache2"))==UINT_MAX) return 0; - c->pth=&xp_core.mpxp_threads[rc]; + c->pth=&xp_core->mpxp_threads[rc]; // wait until cache is filled at least prefill_init % MSG_V("CACHE_PRE_INIT: %lld [%lld] %lld pre:%d eof:%d SS=%u \n", START_FILEPOS(c),c->read_filepos,END_FILEPOS(c),_min,c->eof,ss); Modified: mplayerxp/libmpdemux/demuxer_r.c =================================================================== --- mplayerxp/libmpdemux/demuxer_r.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpdemux/demuxer_r.c 2012-11-01 08:38:09 UTC (rev 272) @@ -22,7 +22,7 @@ { float retval; demuxer_t*demuxer=ds->demuxer; - xp_core.initial_apts_corr.need_correction=0; + xp_core->initial_apts_corr.need_correction=0; MSG_DBG2("initial_apts from: stream_pts=%f pts_bytes=%u got_bytes=%u i_bps=%u\n" ,ds->pts,ds_tell_pts(ds),nbytes,((sh_audio_t*)ds->demuxer->audio->sh)->i_bps); /* FIXUP AUDIO PTS*/ @@ -48,9 +48,9 @@ retval = ds->pts+ds->pts_corr+((float)(ds_tell_pts(ds)-nbytes))/(float)(((sh_audio_t*)ds->demuxer->audio->sh)->i_bps); else { - xp_core.initial_apts_corr.need_correction=1; - xp_core.initial_apts_corr.pts_bytes=ds_tell_pts(ds); - xp_core.initial_apts_corr.nbytes=nbytes; + xp_core->initial_apts_corr.need_correction=1; + xp_core->initial_apts_corr.pts_bytes=ds_tell_pts(ds); + xp_core->initial_apts_corr.nbytes=nbytes; retval = ds->pts; } MSG_DBG2("initial_apts is: %f\n",retval); @@ -67,7 +67,7 @@ if(mp_conf.benchmark) t=GetTimer(); retval = demux_getc(ds); *pts=get_ds_stream_pts(ds,1); - if(xp_core.initial_apts == HUGE) xp_core.initial_apts=*pts; + if(xp_core->initial_apts == HUGE) xp_core->initial_apts=*pts; if(mp_conf.benchmark) { t2=GetTimer();t=t2-t; @@ -112,7 +112,7 @@ if(mp_conf.benchmark) t=GetTimer(); retval = demux_read_data(ds,mem,len); *pts=get_ds_stream_pts(ds,retval); - if(xp_core.initial_apts == HUGE) xp_core.initial_apts=*pts; + if(xp_core->initial_apts == HUGE) xp_core->initial_apts=*pts; if(mp_conf.benchmark) { t2=GetTimer();t=t2-t; @@ -136,7 +136,7 @@ if(mp_conf.benchmark) t=GetTimer(); retval = ds_get_packet(ds,start); *pts=get_ds_stream_pts(ds,retval); - if(xp_core.initial_apts == HUGE) xp_core.initial_apts=*pts; + if(xp_core->initial_apts == HUGE) xp_core->initial_apts=*pts; if(mp_conf.benchmark) { t2=GetTimer();t=t2-t; Modified: mplayerxp/libmpsub/spudec.c =================================================================== --- mplayerxp/libmpsub/spudec.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libmpsub/spudec.c 2012-11-01 08:38:09 UTC (rev 272) @@ -623,7 +623,7 @@ spudec_handle_t *spu = (spudec_handle_t *)this; if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts && spu->image) { - draw_alpha(vo,dae_curr_vdecoded(),spu->start_col, spu->start_row, spu->width, spu->height, + draw_alpha(vo,dae_curr_vdecoded(xp_core),spu->start_col, spu->start_row, spu->width, spu->height, spu->image, spu->aimage, spu->stride); spu->spu_changed = 0; } @@ -779,7 +779,7 @@ || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) { if (spu->image) { - draw_alpha(vo,dae_curr_vdecoded(),spu->start_col, spu->start_row, spu->width, spu->height, + draw_alpha(vo,dae_curr_vdecoded(xp_core),spu->start_col, spu->start_row, spu->width, spu->height, spu->image, spu->aimage, spu->stride); spu->spu_changed = 0; } @@ -1085,7 +1085,7 @@ if ((int)(spu->scaled_start_row) < 0) spu->scaled_start_row = 0; break; } - draw_alpha(vo,dae_curr_vdecoded(),spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height, + draw_alpha(vo,dae_curr_vdecoded(xp_core),spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height, spu->scaled_image, spu->scaled_aimage, spu->scaled_stride); spu->spu_changed = 0; } Modified: mplayerxp/libvo/sub.c =================================================================== --- mplayerxp/libvo/sub.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libvo/sub.c 2012-11-01 08:38:09 UTC (rev 272) @@ -532,7 +532,7 @@ // obj->flags&=~OSDFLAG_OLD_BBOX; if(obj->cleared_frames>=0) { obj->cleared_frames++; - if(obj->cleared_frames>=xp_core.num_v_buffs) + if(obj->cleared_frames>=xp_core->num_v_buffs) obj->cleared_frames=-1; // All cleared stop } } Modified: mplayerxp/libvo/video_out.c =================================================================== --- mplayerxp/libvo/video_out.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/libvo/video_out.c 2012-11-01 08:38:09 UTC (rev 272) @@ -391,7 +391,7 @@ /* TODO: smart analizer of scaling possibilities of vo_driver */ if((event & VO_EVENT_RESIZE) == VO_EVENT_RESIZE) { - xp_core.in_resize=1; + xp_core->in_resize=1; vf_reinit_vo(priv->dri.cap.w,priv->dri.cap.h,priv->dri.cap.fourcc,1); } vf_reinit_vo(priv->dri.cap.w,priv->dri.cap.h,priv->dri.cap.fourcc,0); Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/mplayer.c 2012-11-01 08:38:09 UTC (rev 272) @@ -116,6 +116,7 @@ #define INITED_VCODEC 0x00000200 #define INITED_VOBSUB 0x00000400 #define INITED_SUBTITLE 0x10000000 +#define INITED_XMP 0x80000000 #define INITED_ALL 0xFFFFFFFF #define PT_NEXT_ENTRY 1 @@ -144,15 +145,15 @@ mp_conf_t mp_conf; static volatile char antiviral_hole2[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; -mp_data_t*mp_data=NULL; +mp_data_t* mp_data=NULL; +xp_core_t* xp_core=NULL; /************************************************************************** Decoding ahead **************************************************************************/ - +static volatile char antiviral_hole3[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; ao_data_t* ao_data=NULL; vo_data_t* vo_data=NULL; -static volatile char antiviral_hole3[__VM_PAGE_SIZE__] __PAGE_ALIGNED__; /************************************************************************** Config file @@ -233,6 +234,7 @@ mp_free(mp_data->priv); mp_free(mp_data); mp_data=NULL; + xmp_uninit(); mp_uninit_malloc(1); } @@ -607,7 +609,11 @@ mask=priv->inited_flags&mask; MP_UNIT("uninit_xp"); - xmp_uninit_engine(0); + if(mask&INITED_XMP) { + priv->inited_flags&=~INITED_XMP; + MP_UNIT("uninit_xmp"); + xmp_uninit_engine(0); + } if (mask&INITED_SPUDEC){ priv->inited_flags&=~INITED_SPUDEC; @@ -719,7 +725,7 @@ if(sh_audio) while(get_len_audio_buffer()) usleep(0); if(sh_video) { for(;;) { - if(dae_played_fra(xp_core.video).eof) break; + if(dae_played_fra(xp_core->video).eof) break; usleep(0); } } @@ -992,7 +998,7 @@ // Update buffer if needed MP_UNIT("mpca_decode"); // Enter AUDIO decoder module t=GetTimer(); - while(sh_audio->a_buffer_len<playsize && !xp_core.audio->eof){ + while(sh_audio->a_buffer_len<playsize && !xp_core->audio->eof){ if(mp_conf.xp>=XP_VideoAudio) { ret=read_audio_buffer(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len], playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len,&pts); @@ -1014,7 +1020,7 @@ MP_UNIT("uninit_ao"); ao_uninit(ao_data); } - xp_core.audio->eof=1; + xp_core->audio->eof=1; break; } } @@ -1121,12 +1127,12 @@ priv_t*priv=mp_data->priv; MSG_STATUS("A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d [frms: [%i]]\n", a_pts-delay,v_pts,AV_delay,priv->c_total - ,xp_core.video->num_played_frames,xp_core.video->num_decoded_frames + ,xp_core->video->num_played_frames,xp_core->video->num_decoded_frames ,(v_pts>0.5)?(int)(100.0*mp_data->bench->video/(double)v_pts):0 ,(v_pts>0.5)?(int)(100.0*mp_data->bench->vout/(double)v_pts):0 ,(v_pts>0.5)?(100.0*(mp_data->bench->audio+mp_data->bench->audio_decode)/(double)v_pts):0 ,mp_data->output_quality - ,dae_curr_vplayed() + ,dae_curr_vplayed(xp_core) ); fflush(stdout); } @@ -1134,14 +1140,14 @@ static void show_status_line_no_apts(float v_pts) { priv_t*priv=mp_data->priv; sh_audio_t* sh_audio=priv->demuxer->audio->sh; - if(mp_conf.av_sync_pts && sh_audio && (!xp_core.audio->eof || ao_get_delay(ao_data))) { + if(mp_conf.av_sync_pts && sh_audio && (!xp_core->audio->eof || ao_get_delay(ao_data))) { float a_pts = sh_audio->timer-ao_get_delay(ao_data); MSG_STATUS("A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d\r" ,a_pts ,v_pts ,a_pts-v_pts ,0.0 - ,xp_core.video->num_played_frames,xp_core.video->num_decoded_frames + ,xp_core->video->num_played_frames,xp_core->video->num_decoded_frames ,(v_pts>0.5)?(int)(100.0*mp_data->bench->video/(double)v_pts):0 ,(v_pts>0.5)?(int)(100.0*mp_data->bench->vout/(double)v_pts):0 ,(v_pts>0.5)?(100.0*(mp_data->bench->audio+mp_data->bench->audio_decode)/(double)v_pts):0 @@ -1150,7 +1156,7 @@ } else MSG_STATUS("V:%6.1f %3d %2d%% %2d%% %4.1f%% %d\r" ,v_pts - ,xp_core.video->num_played_frames + ,xp_core->video->num_played_frames ,(v_pts>0.5)?(int)(100.0*mp_data->bench->video/(double)v_pts):0 ,(v_pts>0.5)?(int)(100.0*mp_data->bench->vout/(double)v_pts):0 ,(v_pts>0.5)?(100.0*(mp_data->bench->audio+mp_data->bench->audio_decode)/(double)v_pts):0 @@ -1193,12 +1199,13 @@ sh_video_t* sh_video=priv->demuxer->video->sh; float sleep_time=0; if(sh_audio) { - /* FIXME!!! need the same technique to detect xp_core.audio->eof as for video_eof! + /* FIXME!!! need the same technique to detect xp_core->audio->eof as for video_eof! often ao_get_delay() never returns 0 :( */ - if(xp_core.audio->eof && !get_delay_audio_buffer()) goto nosound_model; - if((!xp_core.audio->eof || ao_get_delay(ao_data)) && + if(xp_core->audio->eof && !get_delay_audio_buffer()) goto nosound_model; + if((!xp_core->audio->eof || ao_get_delay(ao_data)) && (!mp_data->use_pts_fix2 || (!sh_audio->chapter_change && !sh_video->chapter_change))) - sleep_time=screen_pts-(sh_audio->timer-ao_get_delay(ao_data)); + sleep_time=screen_pts-((sh_audio->timer-ao_get_delay(ao_data)) + +(mp_conf.av_sync_pts?0:xp_core->initial_apts)); else if(mp_data->use_pts_fix2 && sh_audio->chapter_change) sleep_time=0; else @@ -1217,7 +1224,7 @@ #define XP_MIN_TIMESLICE 0.010 /* under Linux on x86 min time_slice = 10 ms */ #define XP_MIN_AUDIOBUFF 0.05 #define XP_MAX_TIMESLICE 0.1 - if(sh_audio && (!xp_core.audio->eof || ao_get_delay(ao_data)) && sleep_time>XP_MAX_TIMESLICE) { + if(sh_audio && (!xp_core->audio->eof || ao_get_delay(ao_data)) && sleep_time>XP_MAX_TIMESLICE) { float t; if( mp_conf.xp < XP_VAPlay ) { @@ -1257,7 +1264,6 @@ sh_audio_t* sh_audio=priv->demuxer->audio->sh; sh_video_t* sh_video=priv->demuxer->video->sh; demux_stream_t *d_audio=priv->demuxer->audio; - float screen_pts=0; float v_pts=0; float sleep_time=0; int can_blit=0; @@ -1265,44 +1271,42 @@ int final_frame=0; frame_attr_t shva_prev,shva; - shva_prev=dae_played_fra(xp_core.video); + shva_prev=dae_played_fra(xp_core->video); final_frame = shva_prev.eof; - if(xp_core.video->eof && final_frame) return 1; + if(xp_core->video->eof && final_frame) return 1; - can_blit=dae_try_inc_played(xp_core.video); /* <-- TRY SWITCH TO NEXT FRAME */ - shva=dae_next_played_fra(xp_core.video); + can_blit=dae_try_inc_played(xp_core->video); /* <-- TRY SWITCH TO NEXT FRAME */ + shva=dae_next_played_fra(xp_core->video); v_pts = shva.v_pts; - /*------------------------ frame decoded. --------------------*/ /* blit frame */ - if(xp_core.video->eof) can_blit=1; /* force blitting until end of stream will be reached */ + if(xp_core->video->eof) can_blit=1; /* force blitting until end of stream will be reached */ vplayer_check_chapter_change(&shva_prev,v_pts); #if 0 -MSG_INFO("xp_core.initial_apts=%f a_eof=%i a_pts=%f sh_audio->timer=%f v_pts=%f stream_pts=%f duration=%f\n" -,xp_core.initial_apts -,xp_core.audio->eof -,sh_audio && !xp_core.audio->eof?d_audio->pts+(ds_tell_pts_r(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps:0 -,sh_audio && !xp_core.audio->eof?sh_audio->timer-ao_get_delay(ao_data):0 +MSG_INFO("xp_core->initial_apts=%f a_eof=%i a_pts=%f sh_audio->timer=%f v_pts=%f stream_pts=%f duration=%f\n" +,xp_core->initial_apts +,xp_core->audio->eof +,sh_audio && !xp_core->audio->eof?d_audio->pts+(ds_tell_pts_r(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps:0 +,sh_audio && !xp_core->audio->eof?sh_audio->timer-ao_get_delay(ao_data):0 ,shva.v_pts ,shva.stream_pts ,shva.duration); #endif /*--------- add OSD to the next frame contents ---------*/ if(can_blit) { - screen_pts=v_pts-(mp_conf.av_sync_pts?0:xp_core.initial_apts); #ifdef USE_OSD MSG_D("dec_ahead_main: draw_osd to %u\n",player_idx); MP_UNIT("draw_osd"); update_osd(shva.stream_pts); - vo_draw_osd(vo_data,dae_next_played(xp_core.video)); + vo_draw_osd(vo_data,dae_next_played(xp_core->video)); #endif } MP_UNIT("change_frame2"); /* don't flip if there is nothing new to display */ if(!can_blit) { static int drop_message=0; - if(!drop_message && xp_core.video->num_slow_frames > 50) { + if(!drop_message && xp_core->video->num_slow_frames > 50) { drop_message=1; if(priv->mpxp_after_seek) priv->mpxp_after_seek--; else MSG_WARN(MSGTR_SystemTooSlow); @@ -1320,15 +1324,15 @@ /* It's time to sleep ;)...*/ MP_UNIT("sleep"); GetRelativeTime(); /* reset timer */ - sleep_time=vplayer_compute_sleep_time(&shva_prev,screen_pts); + sleep_time=vplayer_compute_sleep_time(&shva_prev,v_pts); if(mp_conf.benchmark && sleep_time < 0 && sleep_time < priv->max_av_resync) priv->max_av_resync=sleep_time; if(!(vo_data->flags&256)){ /* flag 256 means: libvo driver does its timing (dvb card) */ if(!vplayer_do_sleep(rtc_fd,sleep_time)) return 0; } - player_idx=dae_next_played(xp_core.video); + player_idx=dae_next_played(xp_core->video); vo_select_frame(vo_data,player_idx); - dae_inc_played(xp_core.video); + dae_inc_played(xp_core->video); MSG_D("\ndec_ahead_main: schedule %u on screen\n",player_idx); t2=GetTimer()-t2; tt = t2*0.000001f; @@ -1346,7 +1350,7 @@ /* FIXME: this block was added to fix A-V resync caused by some strange things like playing 48KHz audio on 44.1KHz soundcard and other. Now we know PTS of every audio frame so don't need to have it */ - if(sh_audio && (!xp_core.audio->eof || ao_get_delay(ao_data)) && !mp_conf.av_sync_pts) { + if(sh_audio && (!xp_core->audio->eof || ao_get_delay(ao_data)) && !mp_conf.av_sync_pts) { float a_pts=0; // unplayed bytes in our and soundcard/dma buffer: @@ -1400,7 +1404,7 @@ sh_video_t* sh_video=priv->demuxer->video->sh; demux_stream_t *d_dvdsub=priv->demuxer->sub; int seek_rval=1; - xp_core.audio->eof=0; + xp_core->audio->eof=0; if(seek->secs || seek->flags&DEMUX_SEEK_SET) { seek_rval=demux_seek_r(priv->demuxer,seek); priv->mpxp_after_seek=25; /* 1 sec delay */ @@ -1462,7 +1466,7 @@ } } - if(sh_video) dae_wait_decoder_outrun(xp_core.video); + if(sh_video) dae_wait_decoder_outrun(xp_core->video); } void mpxp_reset_vcache(void) @@ -1527,9 +1531,9 @@ 100.0*mp_data->bench->demux/total_time_usage, 100.0*mp_data->bench->c2/total_time_usage, 100.0*tot/total_time_usage); - unsigned nframes=xp_core.video->num_played_frames; + unsigned nframes=xp_core->video->num_played_frames; MSG_INFO("\nREAL RESULTS: from %u was dropped=%u\n" - ,nframes,xp_core.video->num_dropped_frames); + ,nframes,xp_core->video->num_dropped_frames); MSG_INFO("\nMax. A-V resync is: %f\n",fabs(priv->max_av_resync)); } @@ -1996,18 +2000,19 @@ sh_audio_t* sh_audio=priv->demuxer->audio->sh; sh_video_t* sh_video=priv->demuxer->video->sh; MP_UNIT("init_xp"); - if(sh_video && xp_core.num_v_buffs < 3) {/* we need at least 3 buffers to suppress screen judering */ - MSG_FATAL("Not enough buffers for DECODING AHEAD!\nNeed %u buffers but exist only %u\n",3,xp_core.num_v_buffs); + if(sh_video && xp_core->num_v_buffs < 3) {/* we need at least 3 buffers to suppress screen judering */ + MSG_FATAL("Not enough buffers for DECODING AHEAD!\nNeed %u buffers but exist only %u\n",3,xp_core->num_v_buffs); exit_player("Try other '-vo' driver.\n"); } if(xmp_init_engine(sh_video,sh_audio)!=0) exit_player("Can't initialize decoding ahead!\n"); if(xmp_run_decoders()!=0) exit_player("Can't run decoding ahead!\n"); - if(sh_video) MSG_OK("Using DECODING AHEAD mplayer's core with %u video buffers\n",xp_core.num_v_buffs); - else MSG_OK("Using DECODING AHEAD mplayer's core with %u audio buffers\n",xp_core.num_a_buffs); + if(sh_video) MSG_OK("Using DECODING AHEAD mplayer's core with %u video buffers\n",xp_core->num_v_buffs); + else MSG_OK("Using DECODING AHEAD mplayer's core with %u audio buffers\n",xp_core->num_a_buffs); /* reset counters */ - xp_core.video->num_dropped_frames=0; + if(sh_video) xp_core->video->num_dropped_frames=0; + priv->inited_flags|=INITED_XMP; } static void mpxp_print_audio_status(void) { @@ -2074,7 +2079,7 @@ if (priv->ao_inited && sh_audio) { if( mp_conf.xp >= XP_VAPlay ) { - xp_core.in_pause=1; + xp_core->in_pause=1; while( !dec_ahead_can_aseek ) usleep(0); } ao_pause(ao_data); // pause audio, keep data if possible @@ -2094,7 +2099,7 @@ if (priv->ao_inited && sh_audio) { ao_resume(ao_data); // resume audio if( mp_conf.xp >= XP_VAPlay ) { - xp_core.in_pause=0; + xp_core->in_pause=0; __MP_SYNCHRONIZE(audio_play_mutex,pthread_cond_signal(&audio_play_cond)); } } @@ -2137,7 +2142,7 @@ i_abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0; if(i_abs) { seek->flags = DEMUX_SEEK_SET|DEMUX_SEEK_PERCENTS; - if(sh_video) priv->osd_function= (v > dae_played_fra(xp_core.video).v_pts) ? OSD_FFW : OSD_REW; + if(sh_video) priv->osd_function= (v > dae_played_fra(xp_core->video).v_pts) ? OSD_FFW : OSD_REW; seek->secs = v/100.; } else { @@ -2334,7 +2339,7 @@ vo_fullscreen(vo_data); break; case MP_CMD_VO_SCREENSHOT: - vo_screenshot(vo_data,dae_curr_vplayed()); + vo_screenshot(vo_data,dae_curr_vplayed(xp_core)); break; case MP_CMD_SUB_POS: { @@ -2432,7 +2437,7 @@ } } - xp_core.num_a_buffs = vo_conf.da_buffs; + xp_core->num_a_buffs = vo_conf.da_buffs; init_player(); @@ -2525,7 +2530,7 @@ //============ Open priv->demuxerS --- DETECT file type ======================= if(mp_conf.playbackspeed_factor!=1.0) mp_conf.has_audio=0; - xp_core.initial_apts=HUGE; + xp_core->initial_apts=HUGE; if(!mp_conf.has_audio) mp_conf.audio_id=-2; // do NOT read audio packets... if(!mp_conf.has_video) mp_conf.video_id=-2; // do NOT read video packets... if(!mp_conf.has_dvdsub) mp_conf.dvdsub_id=-2;// do NOT read subtitle packets... @@ -2616,7 +2621,7 @@ goto main; } - xp_core.num_v_buffs=vo_get_num_frames(vo_data); /* that really known after init_vcodecs */ + xp_core->num_v_buffs=vo_get_num_frames(vo_data); /* that really known after init_vcodecs */ if(mp_conf.autoq>0){ /* Auto quality option enabled*/ @@ -2711,17 +2716,17 @@ */ mp_data->seek_time = GetTimerMS(); - if(sh_video) dae_wait_decoder_outrun(xp_core.video); + if(sh_video) dae_wait_decoder_outrun(xp_core->video); if(xmp_run_players()!=0) exit_player("Can't run xp players!\n"); - MSG_OK("Using the next %i threads:\n",xp_core.num_threads); + MSG_OK("Using the next %i threads:\n",xp_core->num_threads); unsigned idx; - for(idx=0;idx<xp_core.num_threads;idx++) + for(idx=0;idx<xp_core->num_threads;idx++) MSG_OK("[%i] %s (id=%u, pth_id=%lu)\n" ,idx - ,xp_core.mpxp_threads[idx]->name - ,xp_core.mpxp_threads[idx]->pid - ,xp_core.mpxp_threads[idx]->pth_id); + ,xp_core->mpxp_threads[idx]->name + ,xp_core->mpxp_threads[idx]->pid + ,xp_core->mpxp_threads[idx]->pth_id); //==================== START PLAYING ======================= MSG_OK(MSGTR_StartPlaying);fflush(stdout); @@ -2743,14 +2748,14 @@ if(mp_conf.benchmark && mp_conf.verbose) show_benchmark_status(); else mpxp_print_audio_status(); - if(mp_conf.xp >= XP_VAPlay) { usleep(100000); eof = xp_core.audio->eof; } + if(mp_conf.xp >= XP_VAPlay) { usleep(100000); eof = xp_core->audio->eof; } goto read_input; } else { int l_eof; /*========================== PLAY VIDEO ============================*/ if(input_state.need_repaint) goto repaint; - if((sh_video->is_static ||(stream->type&STREAMTYPE_MENU)==STREAMTYPE_MENU) && xp_core.video->num_played_frames) { + if((sh_video->is_static ||(stream->type&STREAMTYPE_MENU)==STREAMTYPE_MENU) && xp_core->video->num_played_frames) { /* don't decode if it's picture */ usleep(0); } else { @@ -2792,7 +2797,7 @@ if(mp_conf.loop_times==1) mp_conf.loop_times=-1; eof=0; - xp_core.audio->eof=0; + xp_core->audio->eof=0; seek_args.flags=DEMUX_SEEK_SET|DEMUX_SEEK_PERCENTS; seek_args.secs=0; // seek to start of movie (0%) } @@ -2803,14 +2808,14 @@ xmp_halt_threads(0); if(seek_args.secs && sh_video) { - frame_attr_t shvap = dae_played_fra(xp_core.video); - frame_attr_t shvad = xp_core.video->fra[dae_prev_decoded(xp_core.video)]; - seek_args.secs -= (xp_core.bad_pts?shvad.v_pts:d_video->pts)-shvap.v_pts; + frame_attr_t shvap = dae_played_fra(xp_core->video); + frame_attr_t shvad = xp_core->video->fra[dae_prev_decoded(xp_core->video)]; + seek_args.secs -= (xp_core->bad_pts?shvad.v_pts:d_video->pts)-shvap.v_pts; } mpxp_seek(&osd,&seek_args); - xp_core.audio->eof=0; + xp_core->audio->eof=0; seek_args.secs=0; seek_args.flags=DEMUX_SEEK_CUR|DEMUX_SEEK_SECONDS; @@ -2877,7 +2882,7 @@ priv->vo_inited=0; priv->ao_inited=0; eof = 0; - xp_core.audio->eof=0; + xp_core->audio->eof=0; goto play_next_file; } Modified: mplayerxp/postproc/vf.c =================================================================== --- mplayerxp/postproc/vf.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/postproc/vf.c 2012-11-01 08:38:09 UTC (rev 272) @@ -244,7 +244,7 @@ } else { MSG_DBG2("vf_get_image forces xp_idx retrieving\n"); - mpi->xp_idx=dae_curr_vdecoded(); + mpi->xp_idx=dae_curr_vdecoded(xp_core); } if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) if(vf->start_slice) vf->start_slice(vf,mpi); Modified: mplayerxp/sig_hand.c =================================================================== --- mplayerxp/sig_hand.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/sig_hand.c 2012-11-01 08:38:09 UTC (rev 272) @@ -52,19 +52,19 @@ { int i; pthread_t _self = pthread_self(); - for(i=0; i < xp_core.num_threads && !pthread_equal(xp_core.mpxp_threads[i]->pth_id, _self); i++); - if(i >= xp_core.num_threads || - !pthread_equal(xp_core.mpxp_threads[i]->pth_id, _self)) i = 0; /* Use 0 as default handler */ + for(i=0; i < xp_core->num_threads && !pthread_equal(xp_core->mpxp_threads[i]->pth_id, _self); i++); + if(i >= xp_core->num_threads || + !pthread_equal(xp_core->mpxp_threads[i]->pth_id, _self)) i = 0; /* Use 0 as default handler */ mp_msg(MSGT_CPLAYER,MSGL_FATAL,__FILE__,__LINE__,"catching signal: %s in thread: %s (%i) in module: %s\n" ,strsignal(signo) - ,xp_core.mpxp_threads[i]->name + ,xp_core->mpxp_threads[i]->name ,i - ,xp_core.mpxp_threads[i]->unit); + ,xp_core->mpxp_threads[i]->unit); #ifdef HAVE_BACKTRACE dump_trace(); #endif - xp_core.mpxp_threads[i]->sigfunc(); + xp_core->mpxp_threads[i]->sigfunc(); signal(signo,SIG_DFL); /* try coredump*/ Modified: mplayerxp/sig_hand.h =================================================================== --- mplayerxp/sig_hand.h 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/sig_hand.h 2012-11-01 08:38:09 UTC (rev 272) @@ -7,8 +7,8 @@ #include <sys/types.h> #include "xmp_core.h" -static inline void __MP_UNIT(unsigned id,const char *name) { xp_core.mpxp_threads[id]->unit=name; } -static inline void MP_UNIT(const char *name) { xp_core.mpxp_threads[main_id]->unit=name; } +static inline void __MP_UNIT(unsigned id,const char *name) { xp_core->mpxp_threads[id]->unit=name; } +static inline void MP_UNIT(const char *name) { xp_core->mpxp_threads[main_id]->unit=name; } extern void init_signal_handling( void ); extern void uninit_signal_handling( int xp_id ); Modified: mplayerxp/xmp_core.c =================================================================== --- mplayerxp/xmp_core.c 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/xmp_core.c 2012-11-01 08:38:09 UTC (rev 272) @@ -35,31 +35,29 @@ #define MSG_T(args...) #endif -xp_core_t xp_core; - void xmp_init(void) { - memset(&xp_core,0,sizeof(xp_core_t)); - xp_core.initial_apts=HUGE; + xp_core=mp_mallocz(sizeof(xp_core_t)); + xp_core->initial_apts=HUGE; } -void xmp_uninit(void) {} +void xmp_uninit(void) { mp_free(xp_core); xp_core=NULL; } unsigned xmp_register_main(sig_handler_t sigfunc) { unsigned idx=0; - xp_core.mpxp_threads[idx]=mp_mallocz(sizeof(mpxp_thread_t)); - xp_core.mpxp_threads[idx]->p_idx=idx; - xp_core.mpxp_threads[idx]->pid=getpid(); - xp_core.main_pth_id=xp_core.mpxp_threads[idx]->pth_id=pthread_self(); - xp_core.mpxp_threads[idx]->name = "main"; - xp_core.mpxp_threads[idx]->sigfunc = sigfunc; - xp_core.mpxp_threads[idx]->dae = NULL; - xp_core.num_threads++; + xp_core->mpxp_threads[idx]=mp_mallocz(sizeof(mpxp_thread_t)); + xp_core->mpxp_threads[idx]->p_idx=idx; + xp_core->mpxp_threads[idx]->pid=getpid(); + xp_core->main_pth_id=xp_core->mpxp_threads[idx]->pth_id=pthread_self(); + xp_core->mpxp_threads[idx]->name = "main"; + xp_core->mpxp_threads[idx]->sigfunc = sigfunc; + xp_core->mpxp_threads[idx]->dae = NULL; + xp_core->num_threads++; return idx; } static void print_stopped_thread(unsigned idx) { - MSG_OK("*** stop thread: [%i] %s\n",idx,xp_core.mpxp_threads[idx]->name); + MSG_OK("*** stop thread: [%i] %s\n",idx,xp_core->mpxp_threads[idx]->name); } void xmp_killall_threads(pthread_t _self) @@ -67,12 +65,12 @@ unsigned i; for(i=0;i < MAX_MPXP_THREADS;i++) { if( _self && - xp_core.mpxp_threads[i]->pth_id && - xp_core.mpxp_threads[i]->pth_id != xp_core.main_pth_id) { - pthread_kill(xp_core.mpxp_threads[i]->pth_id,SIGKILL); + xp_core->mpxp_threads[i]->pth_id && + xp_core->mpxp_threads[i]->pth_id != xp_core->main_pth_id) { + pthread_kill(xp_core->mpxp_threads[i]->pth_id,SIGKILL); print_stopped_thread(i); - mp_free(xp_core.mpxp_threads[i]); - xp_core.mpxp_threads[i]=NULL; + mp_free(xp_core->mpxp_threads[i]); + xp_core->mpxp_threads[i]=NULL; } } } @@ -141,7 +139,7 @@ if(it) { do { usleep(0); - }while(dae_get_decoder_outrun(it) < xp_core.num_v_buffs/2); + }while(dae_get_decoder_outrun(it) < xp_core->num_v_buffs/2); } } @@ -201,15 +199,16 @@ volatile float dec_ahead_audio_delay; static int xp_thread_decode_audio(void) { - sh_audio_t* sh_audio=xp_core.audio->sh; - sh_video_t* sh_video=xp_core.video->sh; + sh_audio_t* sh_audio=xp_core->audio->sh; + sh_video_t* sh_video=NULL; + if(xp_core->video) sh_video=xp_core->video->sh; int free_buf, vbuf_size, pref_buf; unsigned len=0; free_buf = get_free_audio_buffer(); if( free_buf == -1 ) { /* End of file */ - xp_core.audio->eof = 1; + xp_core->audio->eof = 1; return 0; } if( free_buf < (int)sh_audio->audio_out_minsize ) /* full */ @@ -220,9 +219,9 @@ if( len < MAX_OUTBURST ) /* Buffer underrun */ return decode_audio_buffer(MAX_OUTBURST); - if(xp_core.has_video) { + if(xp_core->video) { /* Match video buffer */ - vbuf_size = dae_get_decoder_outrun(xp_core.video); + vbuf_size = dae_get_decoder_outrun(xp_core->video); pref_buf = vbuf_size / sh_video->fps * sh_audio->af_bps; pref_buf -= len; if( pref_buf > 0 ) { @@ -250,14 +249,14 @@ "*********************************************\n" "Try increase number of buffer for decoding ahead\n" "Exist: %u, need: %u\n" - ,xp_core.num_v_buffs,(unsigned)(max_frame_delay*3*sh_video->fps)+3); + ,xp_core->num_v_buffs,(unsigned)(max_frame_delay*3*sh_video->fps)+3); prev_warn_delay=max_frame_delay; } } static unsigned compute_frame_dropping(sh_video_t* sh_video,float v_pts,float drop_barrier) { unsigned rc=0; - float screen_pts=dae_played_fra(xp_core.video).v_pts-(mp_conf.av_sync_pts?0:xp_core.initial_apts); + float screen_pts=dae_played_fra(xp_core->video).v_pts-(mp_conf.av_sync_pts?0:xp_core->initial_apts); static float prev_delta=64; float delta,max_frame_delay;/* delay for decoding of top slow frame */ max_frame_delay = mp_data->bench->max_video+mp_data->bench->max_vout; @@ -265,7 +264,7 @@ /* TODO: Replace the constants with some values which are depended on - xp_core.num_v_buffs and max_frame_delay to find out the smoothest way + xp_core->num_v_buffs and max_frame_delay to find out the smoothest way to display frames on slow machines. MAYBE!!!: (won't work with some realmedia streams for example) Try to borrow avifile's logic (btw, GPL'ed ;) for very slow systems: @@ -275,7 +274,7 @@ */ delta=v_pts-screen_pts; if(max_frame_delay*3 > drop_barrier) { - if(drop_barrier < (float)(xp_core.num_v_buffs-2)/sh_video->fps) drop_barrier += 1/sh_video->fps; + if(drop_barrier < (float)(xp_core->num_v_buffs-2)/sh_video->fps) drop_barrier += 1/sh_video->fps; else if(mp_conf.verbose) show_warn_cant_sync(sh_video,max_frame_delay); } @@ -292,7 +291,7 @@ if(delta < drop_barrier*2/3) fr_skip_divisor=3; else fr_skip_divisor=4; /* delta < drop_barrier */ - rc = (dae_curr_vdecoded()%fr_skip_divisor)?0:1; + rc = (dae_curr_vdecoded(xp_core)%fr_skip_divisor)?0:1; if(delta>prev_delta) rc=0; } MSG_D("DEC_AHEAD: max_frame_delay*3=%f drop_barrier=%f prev_delta=%f delta=%f(v_pts=%f screen_pts=%f) n_fr_to_drop=%u\n",max_frame_delay*3,drop_barrier,prev_delta,delta,v_pts,xp_screen_pts,xp_n_frame_to_drop); @@ -303,10 +302,10 @@ static void reorder_pts_in_mpeg(void) { unsigned idx0=0, idx1, idx2, idx3; - idx1 = dae_curr_vdecoded(); - idx2 = dae_prev_vdecoded(); - frame_attr_t* fra=xp_core.video->fra; - while( dae_curr_vplayed() != idx2 && + idx1 = dae_curr_vdecoded(xp_core); + idx2 = dae_prev_vdecoded(xp_core); + frame_attr_t* fra=xp_core->video->fra; + while( dae_curr_vplayed(xp_core) != idx2 && fra[idx2].v_pts > fra[idx1].v_pts && fra[idx2].v_pts < fra[idx1].v_pts+1.0 ) { float tmp; @@ -318,16 +317,16 @@ fra[idx2].stream_pts = fra[idx2].v_pts; fra[idx2].duration = fra[idx1].v_pts - fra[idx2].v_pts; - idx3=(idx2-1)%xp_core.num_v_buffs; + idx3=(idx2-1)%xp_core->num_v_buffs; if(fra[idx2].v_pts > fra[idx3].v_pts && fra[idx2].v_pts - fra[idx3].v_pts < 1.0) fra[idx3].duration = fra[idx2].v_pts - fra[idx3].v_pts; - if(idx1 != dae_curr_vdecoded()) fra[idx1].duration = fra[idx0].v_pts - fra[idx1].v_pts; + if(idx1 != dae_curr_vdecoded(xp_core)) fra[idx1].duration = fra[idx0].v_pts - fra[idx1].v_pts; idx0 = idx1; idx1 = idx2; - idx2=(idx2-1)%xp_core.num_v_buffs; + idx2=(idx2-1)%xp_core->num_v_buffs; } } @@ -346,21 +345,21 @@ priv->state=Pth_Run; priv->dae->eof = 0; - xp_core.audio->eof=0; + xp_core->audio->eof=0; MSG_T("\nDEC_AHEAD: entering...\n"); __MP_UNIT(priv->p_idx,"dec_ahead"); priv->pid = getpid(); - if(!(xp_core.has_audio && mp_conf.xp < XP_VAFull)) + if(!(xp_core->audio && mp_conf.xp < XP_VAFull)) priv->name = "video decoder+vf"; - drop_barrier=(float)(xp_core.num_v_buffs/2)*(1/sh_video->fps); + drop_barrier=(float)(xp_core->num_v_buffs/2)*(1/sh_video->fps); if(mp_conf.av_sync_pts == -1 && !mp_data->use_pts_fix2) - xp_core.bad_pts = d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_ES || + xp_core->bad_pts = d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_ES || d_video->demuxer->file_format == DEMUXER_TYPE_MPEG4_ES || d_video->demuxer->file_format == DEMUXER_TYPE_H264_ES || d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_PS || d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_TS; else - xp_core.bad_pts = mp_conf.av_sync_pts?0:1; + xp_core->bad_pts = mp_conf.av_sync_pts?0:1; while(!priv->dae->eof){ unsigned char* start=NULL; int in_size; @@ -369,7 +368,7 @@ pt_sleep: priv->state=Pth_ASleep; while(priv->state==Pth_ASleep) usleep(0); - if(xp_core.bad_pts) mpeg_timer=HUGE; + if(xp_core->bad_pts) mpeg_timer=HUGE; continue; } __MP_UNIT(priv->p_idx,"dec_ahead 1"); @@ -378,7 +377,7 @@ #if 0 /* prevent reent access to non-reent demuxer */ //if(sh_video->num_frames>200) *((char*)0x100) = 1; // Testing crash - if(xp_core.has_audio && mp_conf.xp<XP_VAFull) { + if(xp_core->audio && mp_conf.xp<XP_VAFull) { __MP_UNIT(priv->p_idx,"decode audio"); while(2==xp_thread_decode_audio()) ; __MP_UNIT(priv->p_idx,"dec_ahead 2"); @@ -387,14 +386,14 @@ /*-------------------- Decode a frame: -----------------------*/ in_size=video_read_frame_r(sh_video,&duration,&v_pts,&start,sh_video->fps); if(in_size<0) { - xp_core.video->fra[xp_core.video->decoder_idx].eof=1; + xp_core->video->fra[xp_core->video->decoder_idx].eof=1; priv->dae->eof=1; break; } /* in_size==0: it's or broken stream or demuxer's bug */ if(in_size==0 && priv->state!=Pth_Canceling) continue; /* frame was decoded into current decoder_idx */ - if(xp_core.bad_pts) { + if(xp_core->bad_pts) { if(mpeg_timer==HUGE) mpeg_timer=v_pts; else if( mpeg_timer-duration<v_pts ) { mpeg_timer=v_pts; @@ -408,7 +407,7 @@ int cur_time; cur_time = GetTimerMS(); /* Ugly solution: disable frame dropping right after seeking! */ - if(cur_time - mp_data->seek_time > (xp_core.num_v_buffs/sh_video->fps)*100) xp_n_frame_to_drop=compute_frame_dropping(sh_video,v_pts,drop_barrier); + if(cur_time - mp_data->seek_time > (xp_core->num_v_buffs/sh_video->fps)*100) xp_n_frame_to_drop=compute_frame_dropping(sh_video,v_pts,drop_barrier); } /* if( mp_conf.frame_dropping ) */ if(!finite(v_pts)) MSG_WARN("Bug of demuxer! Value of video pts=%f\n",v_pts); #if 0 @@ -427,8 +426,8 @@ else drop_param=0; /* decode: */ if(mp_data->output_quality) { - unsigned total = xp_core.num_v_buffs/2; - unsigned distance = dae_get_decoder_outrun(xp_core.video); + unsigned total = xp_core->num_v_buffs/2; + unsigned distance = dae_get_decoder_outrun(xp_core->video); int our_quality; our_quality = mp_data->output_quality*distance/total; if(drop_param) mpcv_set_quality(sh_video,0); @@ -436,22 +435,23 @@ if(mp_conf.autoq) mpcv_set_quality(sh_video,our_quality>0?our_quality:0); } blit_frame=mpcv_decode(sh_video,start,in_size,drop_param,v_pts); +MSG_DBG2("DECODER: %i[%i] %f\n",dae_curr_vdecoded(xp_core),in_size,v_pts); if(mp_data->output_quality) { if(drop_param) mpcv_set_quality(sh_video,mp_data->output_quality); } if(!blit_frame && drop_param) priv->dae->num_dropped_frames++; if(blit_frame) { - unsigned idx=dae_curr_vdecoded(); - if(xp_core.bad_pts) - xp_core.video->fra[idx].v_pts=mpeg_timer; + unsigned idx=dae_curr_vdecoded(xp_core); + if(xp_core->bad_pts) + xp_core->video->fra[idx].v_pts=mpeg_timer; else - xp_core.video->fra[idx].v_pts = v_pts; - xp_core.video->fra[idx].stream_pts = v_pts; - xp_core.video->fra[idx].duration=duration; - xp_core.video->fra[idx].eof=0; - if(!xp_core.bad_pts) { - int _idx = dae_prev_vdecoded(); - xp_core.video->fra[_idx].duration=v_pts-xp_core.video->fra[_idx].v_pts; + xp_core->video->fra[idx].v_pts = v_pts; + xp_core->video->fra[idx].stream_pts = v_pts; + xp_core->video->fra[idx].duration=duration; + xp_core->video->fra[idx].eof=0; + if(!xp_core->bad_pts) { + int _idx = dae_prev_vdecoded(xp_core); + xp_core->video->fra[_idx].duration=v_pts-xp_core->video->fra[_idx].v_pts; } if(mp_conf.frame_reorder) reorder_pts_in_mpeg(); } /* if (blit_frame) */ @@ -459,12 +459,12 @@ /* ------------ sleep --------------- */ /* sleep if thread is too fast ;) */ if(blit_frame) - while(!dae_inc_decoded(xp_core.video)) { + while(!dae_inc_decoded(xp_core->video)) { MSG_T("DEC_AHEAD: sleep: player=%i decoder=%i)\n" ,dae_curr_vplayed(),dae_curr_vdecoded()); if(priv->state==Pth_Canceling) goto pt_exit; if(priv->state==Pth_Sleep) goto pt_sleep; - if(xp_core.has_audio && mp_conf.xp<XP_VAFull) { + if(xp_core->audio && mp_conf.xp<XP_VAFull) { __MP_UNIT(priv->p_idx,"decode audio"); xp_thread_decode_audio(); __MP_UNIT(priv->p_idx,"dec_ahead 5"); @@ -474,8 +474,8 @@ /*------------------------ frame decoded. --------------------*/ } /* while(!priv->dae->eof)*/ -if(xp_core.has_audio && mp_conf.xp<XP_VAFull) { - while(!xp_core.audio->eof && priv->state!=Pth_Canceling && priv->state!=Pth_Sleep) { +if(xp_core->audio && mp_conf.xp<XP_VAFull) { + while(!xp_core->audio->eof && priv->state!=Pth_Canceling && priv->state!=Pth_Sleep) { __MP_UNIT(priv->p_idx,"decode audio"); if(!xp_thread_decode_audio()) usleep(1); __MP_UNIT(priv->p_idx,NULL); @@ -498,8 +498,8 @@ float d; priv->state=Pth_Run; - xp_core.video->eof=0; - xp_core.audio->eof=0; + if(xp_core->video) xp_core->video->eof=0; + xp_core->audio->eof=0; MSG_T("\nDEC_AHEAD: entering...\n"); priv->pid = getpid(); __MP_UNIT(priv->p_idx,"dec_ahead"); @@ -513,7 +513,7 @@ } __MP_UNIT(priv->p_idx,"decode audio"); while((ret = xp_thread_decode_audio()) == 2) {/* Almost empty buffer */ - if(xp_core.audio->eof) break; + if(xp_core->audio->eof) break; } dec_ahead_can_adseek=1; @@ -522,7 +522,7 @@ __MP_UNIT(priv->p_idx,"sleep"); LOCK_AUDIO_DECODE(); if(priv->state!=Pth_Canceling) { - if(xp_core.audio->eof) { + if(xp_core->audio->eof) { __MP_UNIT(priv->p_idx,"wait end of work"); pthread_cond_wait( &audio_decode_cond, &audio_decode_mutex ); } else if(ret==0) { /* Full buffer or end of file */ @@ -534,7 +534,7 @@ } else timeout.tv_sec = audio_play_timeout.tv_sec; } else { - if(xp_core.in_pause) + if(xp_core->in_pause) d = 1.0; else d = 0.1; @@ -579,16 +579,15 @@ { xmp_stop_threads(force); - if(xp_core.has_video) { - dae_uninit(xp_core.video); - xp_core.has_video=0; + if(xp_core->video) { + dae_uninit(xp_core->video); + xp_core->video=NULL; } - if(xp_core.has_audio) { /* audio state doesn't matter on segfault :( */ + if(xp_core->audio) { /* audio state doesn't matter on segfault :( */ uninit_audio_buffer(); - xp_core.has_audio=0; + xp_core->audio=NULL; } - xmp_uninit(); } /* Min audio buffer to keep mp_free, used to tell differ between full and empty buffer */ @@ -597,33 +596,29 @@ int xmp_init_engine(sh_video_t *shv, sh_audio_t *sha) { if(shv) { - xp_core.has_video=1; - xp_core.video=mp_malloc(sizeof(dec_ahead_engine_t)); - dae_init(xp_core.video,xp_core.num_v_buffs,shv); - } else {/* if (mp_conf.xp >= XP_VAFull) mp_conf.xp = XP_VAPlay;*/ + xp_core->video=mp_mallocz(sizeof(dec_ahead_engine_t)); + dae_init(xp_core->video,xp_core->num_v_buffs,shv); } - if(mp_conf.xp>=XP_VideoAudio && sha) { int asize; unsigned o_bps; unsigned min_reserv; o_bps=sha->afilter_inited?sha->af_bps:sha->o_bps; - if(xp_core.has_video) asize = max(3*sha->audio_out_minsize,max(3*MAX_OUTBURST,o_bps*xp_core.num_v_buffs/shv->fps))+MIN_BUFFER_RESERV; - else asize = o_bps*xp_core.num_a_buffs; + if(xp_core->video) asize = max(3*sha->audio_out_minsize,max(3*MAX_OUTBURST,o_bps*xp_core->num_v_buffs/shv->fps))+MIN_BUFFER_RESERV; + else asize = o_bps*xp_core->num_a_buffs; /* FIXME: get better indices from asize/real_audio_packet_size */ min_reserv = sha->audio_out_minsize; if (o_bps > sha->o_bps) min_reserv = (float)min_reserv * (float)o_bps / (float)sha->o_bps; init_audio_buffer(asize+min_reserv,min_reserv+MIN_BUFFER_RESERV,asize/(sha->audio_out_minsize<10000?sha->audio_out_minsize:4000)+100,sha); - xp_core.has_audio=1; - xp_core.audio=mp_malloc(sizeof(dec_ahead_engine_t)); - dae_init(xp_core.audio,xp_core.num_a_buffs,sha); + xp_core->audio=mp_mallocz(sizeof(dec_ahead_engine_t)); + dae_init(xp_core->audio,xp_core->num_a_buffs,sha); } return 0; } unsigned xmp_register_thread(dec_ahead_engine_t* dae,sig_handler_t sigfunc,mpxp_routine_t routine,const char *name) { - unsigned idx=xp_core.num_threads; + unsigned idx=xp_core->num_threads; int rc; if(idx>=MAX_MPXP_THREADS) return UINT_MAX; pthread_attr_t attr; @@ -639,32 +634,32 @@ /* requires root privelegies */ pthread_attr_setschedpolicy(&attr,SCHED_FIFO); #endif - xp_core.mpxp_threads[idx]=mp_mallocz(sizeof(mpxp_thread_t)); + xp_core->mpxp_threads[idx]=mp_mallocz(sizeof(mpxp_thread_t)); - xp_core.mpxp_threads[idx]->p_idx=idx; - xp_core.mpxp_threads[idx]->name=name; - xp_core.mpxp_threads[idx]->routine=routine; - xp_core.mpxp_threads[idx]->sigfunc=sigfunc; - xp_core.mpxp_threads[idx]->state=Pth_Stand; - xp_core.mpxp_threads[idx]->dae=dae; + xp_core->mpxp_threads[idx]->p_idx=idx; + xp_core->mpxp_threads[idx]->name=name; + xp_core->mpxp_threads[idx]->routine=routine; + xp_core->mpxp_threads[idx]->sigfunc=sigfunc; + xp_core->mpxp_threads[idx]->state=Pth_Stand; + xp_core->mpxp_threads[idx]->dae=dae; - rc=pthread_create(&xp_core.mpxp_threads[idx]->pth_id,&attr,routine,xp_core.mpxp_threads[idx]); + rc=pthread_create(&xp_core->mpxp_threads[idx]->pth_id,&attr,routine,xp_core->mpxp_threads[idx]); pthread_attr_destroy(&attr); - xp_core.num_threads++; + xp_core->num_threads++; return (rc?UINT_MAX:idx); } int xmp_run_decoders( void ) { unsigned rc; - if((xp_core.has_audio && mp_conf.xp >= XP_VAFull) || !xp_core.has_video) { - if((rc=xmp_register_thread(xp_core.audio,sig_audio_decode,a_dec_ahead_routine,"audio decoder+af"))==UINT_MAX) return rc; - while(xp_core.mpxp_threads[rc]->state!=Pth_Run) usleep(0); + if((xp_core->audio && mp_conf.xp >= XP_VAFull) || !xp_core->video) { + if((rc=xmp_register_thread(xp_core->audio,sig_audio_decode,a_dec_ahead_routine,"audio decoder+af"))==UINT_MAX) return rc; + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); } - if(xp_core.has_video) { - if((rc=xmp_register_thread(xp_core.video,sig_dec_ahead_video,Va_dec_ahead_routine,"video+audio decoders & af+vf"))==UINT_MAX) return rc; - while(xp_core.mpxp_threads[rc]->state!=Pth_Run) usleep(0); + if(xp_core->video) { + if((rc=xmp_register_thread(xp_core->video,sig_dec_ahead_video,Va_dec_ahead_routine,"video+audio decoders & af+vf"))==UINT_MAX) return rc; + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); } return 0; } @@ -672,9 +667,9 @@ int xmp_run_players(void) { unsigned rc; - if( xp_core.has_audio && mp_conf.xp >= XP_VAPlay ) { - if((rc=xmp_register_thread(xp_core.audio,sig_audio_play,audio_play_routine,"audio player"))==UINT_MAX) return rc; - while(xp_core.mpxp_threads[rc]->state!=Pth_Run) usleep(0); + if( xp_core->audio && mp_conf.xp >= XP_VAPlay ) { + if((rc=xmp_register_thread(xp_core->audio,sig_audio_play,audio_play_routine,"audio player"))==UINT_MAX) return rc; + while(xp_core->mpxp_threads[rc]->state!=Pth_Run) usleep(0); } return 0; } @@ -683,15 +678,15 @@ void xmp_stop_threads(int force) { unsigned i; - for(i=1;i<xp_core.num_threads;i++) { - if(force) pthread_kill(xp_core.mpxp_threads[i]->pth_id,SIGKILL); + for(i=1;i<xp_core->num_threads;i++) { + if(force) pthread_kill(xp_core->mpxp_threads[i]->pth_id,SIGKILL); else { - xp_core.mpxp_threads[i]->state=Pth_Canceling; - while(xp_core.mpxp_threads[i]->state==Pth_Canceling) usleep(0); + xp_core->mpxp_threads[i]->state=Pth_Canceling; + while(xp_core->mpxp_threads[i]->state==Pth_Canceling) usleep(0); } print_stopped_thread(i); - mp_free(xp_core.mpxp_threads[i]); - xp_core.mpxp_threads[i]=NULL; + mp_free(xp_core->mpxp_threads[i]); + xp_core->mpxp_threads[i]=NULL; } } @@ -699,9 +694,9 @@ void xmp_halt_threads(int is_reset_vcache) { unsigned i; - for(i=1;i<xp_core.num_threads;i++) { - xp_core.mpxp_threads[i]->state=Pth_Sleep; - while(xp_core.mpxp_threads[i]->state==Pth_Sleep) usleep(0); + for(i=1;i<xp_core->num_threads;i++) { + xp_core->mpxp_threads[i]->state=Pth_Sleep; + while(xp_core->mpxp_threads[i]->state==Pth_Sleep) usleep(0); } } @@ -709,17 +704,17 @@ void xmp_restart_threads(int xp_id) { /* reset counters */ - dae_reset(xp_core.video); + dae_reset(xp_core->video); /* temporary solution */ reset_audio_buffer(); /* Ugly hack: but we should read audio packet before video after seeking. Else we'll get picture destortion on the screen */ - xp_core.initial_apts=HUGE; + xp_core->initial_apts=HUGE; unsigned i; - for(i=1;i<xp_core.num_threads;i++) { - xp_core.mpxp_threads[i]->state=Pth_Run; - while(xp_core.mpxp_threads[i]->state==Pth_ASleep) usleep(0); + for(i=1;i<xp_core->num_threads;i++) { + xp_core->mpxp_threads[i]->state=Pth_Run; + while(xp_core->mpxp_threads[i]->state==Pth_ASleep) usleep(0); } } @@ -795,7 +790,7 @@ samples = 10; min_audio = MAX_AUDIO_TIME; max_audio = 0; - } else if( !xp_core.audio->eof && collect_samples) { + } else if( !xp_core->audio->eof && collect_samples) { if( dec_ahead_audio_delay < min_audio ) min_audio = dec_ahead_audio_delay; if( dec_ahead_audio_delay > max_audio ) @@ -852,7 +847,7 @@ __MP_UNIT(priv->p_idx,"audio pause"); LOCK_AUDIO_PLAY(); - while( xp_core.in_pause && priv->state!=Pth_Canceling) { + while( xp_core->in_pause && priv->state!=Pth_Canceling) { pthread_cond_wait( &audio_play_cond, &audio_play_mutex ); } UNLOCK_AUDIO_PLAY(); @@ -883,7 +878,7 @@ void dec_ahead_reset_sh_video(sh_video_t *shv) { - sh_video_t* sh_video=xp_core.video->sh; + sh_video_t* sh_video=xp_core->video->sh; sh_video->vfilter = shv->vfilter; } @@ -892,8 +887,8 @@ MSG_T("sig_dec_ahead_video\n"); mp_msg_flush(); - xp_core.video->eof = 1; - xp_core.video->fra[dae_curr_vdecoded()].eof=1; + xp_core->video->eof = 1; + xp_core->video->fra[dae_curr_vdecoded(xp_core)].eof=1; /* Unlock all mutex ( man page says it may deadlock, but what is worse deadlock here or later? ) Modified: mplayerxp/xmp_core.h =================================================================== --- mplayerxp/xmp_core.h 2012-10-31 17:45:52 UTC (rev 271) +++ mplayerxp/xmp_core.h 2012-11-01 08:38:09 UTC (rev 272) @@ -68,8 +68,6 @@ }initial_audio_pts_correction_t; typedef struct xp_core_s { - int has_video; - int has_audio; dec_ahead_engine_t* video; dec_ahead_engine_t* audio; volatile int in_pause; @@ -85,7 +83,7 @@ float initial_apts; initial_audio_pts_correction_t initial_apts_corr; }xp_core_t; -extern xp_core_t xp_core; +extern xp_core_t *xp_core; extern void xmp_init(void); extern void xmp_uninit(void); @@ -124,12 +122,12 @@ extern unsigned dae_get_decoder_outrun(const dec_ahead_engine_t* it); extern void dae_wait_decoder_outrun(const dec_ahead_engine_t* it); -static inline unsigned dae_curr_vplayed() { return xp_core.video->player_idx; } -static inline unsigned dae_curr_vdecoded() { return xp_core.video->decoder_idx; } -static inline unsigned dae_prev_vplayed() { return dae_prev_played(xp_core.video); } -static inline unsigned dae_prev_vdecoded() { return dae_prev_decoded(xp_core.video); } -static inline unsigned dae_next_vplayed() { return dae_next_played(xp_core.video); } -static inline unsigned dae_next_vdecoded() { return dae_next_decoded(xp_core.video); } +static inline unsigned dae_curr_vplayed(const xp_core_t* xpc) { return xpc->video->player_idx; } +static inline unsigned dae_curr_vdecoded(const xp_core_t* xpc) { return xpc->video->decoder_idx; } +static inline unsigned dae_prev_vplayed(const xp_core_t* xpc) { return dae_prev_played(xpc->video); } +static inline unsigned dae_prev_vdecoded(const xp_core_t* xpc) { return dae_prev_decoded(xpc->video); } +static inline unsigned dae_next_vplayed(const xp_core_t* xpc) { return dae_next_played(xpc->video); } +static inline unsigned dae_next_vdecoded(const xp_core_t* xpc) { return dae_next_decoded(xpc->video); } extern frame_attr_t dae_played_fra(const dec_ahead_engine_t* it); extern frame_attr_t dae_decoded_fra(const dec_ahead_engine_t* it); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |