[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[177] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-10-19 17:07:03
|
Revision: 177 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=177&view=rev Author: nickols_k Date: 2012-10-19 17:06:52 +0000 (Fri, 19 Oct 2012) Log Message: ----------- decode and paint SUBTITLE within XP-thread Modified Paths: -------------- mplayerxp/libmpcodecs/dec_video.c mplayerxp/libvo/sub.c mplayerxp/libvo/sub.h mplayerxp/libvo/video_out.c mplayerxp/libvo/video_out.h mplayerxp/mplayer.c mplayerxp/spudec.c mplayerxp/spudec.h Modified: mplayerxp/libmpcodecs/dec_video.c =================================================================== --- mplayerxp/libmpcodecs/dec_video.c 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/libmpcodecs/dec_video.c 2012-10-19 17:06:52 UTC (rev 177) @@ -19,6 +19,7 @@ #include "stream.h" #include "demuxer.h" #include "parse_es.h" +#include "sig_hand.h" #include "codec-cfg.h" @@ -30,6 +31,9 @@ #include "dec_ahead.h" #include "dec_video.h" +#include "spudec.h" +#include "vobsub.h" + // =================================================================== vf_cfg_t vf_cfg; // Configuration for audio filters @@ -230,7 +234,7 @@ } } -extern void update_subtitle(float v_pts); +static void update_subtitle(sh_video_t *sh_video,float v_pts,unsigned idx); int decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame, float pts){ vf_instance_t* vf; mp_image_t *mpi=NULL; @@ -262,7 +266,7 @@ } if(drop_frame) return 0; - update_subtitle(pts); + update_subtitle(sh_video,pts,mpi->xp_idx); vo_flush_page(dae_curr_vdecoded()); t2=GetTimer()-t2; @@ -284,3 +288,66 @@ if(sh_video->inited && mpvdec) mpvdec->control(sh_video,VDCTRL_RESYNC_STREAM,NULL); } +extern float sub_fps; +#ifdef USE_SUB +extern subtitle* mp_subtitles; +static float sub_last_pts = -303; +#endif +static void update_subtitle(sh_video_t *sh_video,float v_pts,unsigned xp_idx) +{ +#ifdef USE_SUB + // find sub + if(mp_subtitles && v_pts>0){ + float pts=v_pts; + if(sub_fps==0) sub_fps=sh_video->fps; + pinfo[xp_id].current_module="find_sub"; + if (pts > sub_last_pts || pts < sub_last_pts-1.0 ) { + find_sub(mp_subtitles,sub_uses_time?(100*pts):(pts*sub_fps)); // FIXME! frame counter... + sub_last_pts = pts; + } + pinfo[xp_id].current_module=NULL; + } +#endif + + // DVD sub: +#if 0 + if(vo_flags & 0x08){ + static vo_mpegpes_t packet; + static vo_mpegpes_t *pkg=&packet; + packet.timestamp=sh_video->timer*90000.0; + packet.id=0x20; /* Subpic */ + while((packet.size=ds_get_packet_sub(d_dvdsub,&packet.data))>0){ + MSG_V("\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",packet.size,v_pts,d_dvdsub->pts); + vo_draw_frame(&pkg); + } + }else +#endif + if(vo.spudec){ + unsigned char* packet=NULL; + int len,timestamp; + pinfo[xp_id].current_module="spudec"; + spudec_now_pts(vo.spudec,90000*v_pts); + if(spudec_visible(vo.spudec)) { + vo_draw_spudec_direct(xp_idx); + } else { + spudec_heartbeat(vo.spudec,90000*v_pts); + if (vo.vobsub) { + if (v_pts >= 0) { + while((len=vobsub_get_packet(vo.vobsub, v_pts,(any_t**)&packet, ×tamp))>0){ + timestamp -= (v_pts - sh_video->timer)*90000; + MSG_V("\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len,v_pts,sh_video->timer,timestamp / 90000.0,timestamp); + spudec_assemble(vo.spudec,packet,len,90000*d_dvdsub->pts); + } + } + } else { + while((len=ds_get_packet_sub(d_dvdsub,&packet))>0){ + MSG_V("\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",len,v_pts,d_dvdsub->pts); + spudec_assemble(vo.spudec,packet,len,90000*d_dvdsub->pts); + } + } + /* detect wether the sub has changed or not */ + if(spudec_changed(vo.spudec)) vo_draw_spudec_direct(xp_idx); + pinfo[xp_id].current_module=NULL; + } + } +} Modified: mplayerxp/libvo/sub.c =================================================================== --- mplayerxp/libvo/sub.c 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/libvo/sub.c 2012-10-19 17:06:52 UTC (rev 177) @@ -531,6 +531,10 @@ } } +void __FASTCALL__ vo_draw_spudec(unsigned idx,int dxs,int dys,draw_osd_f draw_alpha){ + spudec_draw_scaled(vo.spudec, dxs, dys, draw_alpha); // FIXME +} + void __FASTCALL__ vo_draw_text(unsigned idx,int dxs,int dys,draw_osd_f draw_alpha){ mp_osd_obj_t* obj=vo_osd_list; vo_update_osd(dxs,dys); Modified: mplayerxp/libvo/sub.h =================================================================== --- mplayerxp/libvo/sub.h 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/libvo/sub.h 2012-10-19 17:06:52 UTC (rev 177) @@ -91,6 +91,9 @@ typedef void (* __FASTCALL__ draw_osd_f)(unsigned idx,int x0,int y0, int w,int h,const unsigned char* src,const unsigned char *srca, int stride); typedef void (* __FASTCALL__ clear_osd_f)(unsigned idx,int x0,int y0, int w,int h); +/* for direct calll from XP-thread*/ +extern void __FASTCALL__ vo_draw_spudec(unsigned idx,int dxs,int dys,draw_osd_f draw_alpha); + extern void __FASTCALL__ vo_draw_text(unsigned idx,int dxs,int dys, draw_osd_f draw_alpha); extern void __FASTCALL__ vo_remove_text(unsigned idx,int dxs,int dys,clear_osd_f remove); Modified: mplayerxp/libvo/video_out.c =================================================================== --- mplayerxp/libvo/video_out.c 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/libvo/video_out.c 2012-10-19 17:06:52 UTC (rev 177) @@ -828,6 +828,18 @@ } } +void vo_draw_spudec_direct(unsigned idx) +{ + MSG_DBG3("dri_vo_dbg: vo_draw_osd\n"); + if(dri.has_dri && !(dri.cap.caps & DRI_CAP_HWOSD)) + { +// if( dri.cap.x || dri.cap.y || +// dri.cap.w != dri.cap.width || dri.cap.h != dri.cap.height) +// vo_remove_text(idx,dri.cap.width,dri.cap.height,dri_remove_osd); + vo_draw_spudec(idx,dri.cap.width,dri.cap.height,dri_draw_osd); + } +} + void vo_uninit( void ) { MSG_DBG3("dri_vo_dbg: vo_uninit\n"); Modified: mplayerxp/libvo/video_out.h =================================================================== --- mplayerxp/libvo/video_out.h 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/libvo/video_out.h 2012-10-19 17:06:52 UTC (rev 177) @@ -179,6 +179,7 @@ extern void vo_select_frame(unsigned idx); extern void vo_flush_page(unsigned decoder_idx); extern void vo_draw_osd(unsigned idx); +extern void vo_draw_spudec_direct(unsigned idx); extern void vo_uninit( void ); extern uint32_t __FASTCALL__ vo_control(uint32_t request, any_t*data); extern int __FASTCALL__ vo_is_final(void); Modified: mplayerxp/mplayer.c =================================================================== --- mplayerxp/mplayer.c 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/mplayer.c 2012-10-19 17:06:52 UTC (rev 177) @@ -110,6 +110,9 @@ static int osd_show_framedrop = 0; static int osd_function=OSD_PLAY; int output_quality=0; +#ifdef USE_SUB +subtitle* mp_subtitles=NULL; +#endif int xp_id=0; pid_t mplayer_pid; @@ -286,10 +289,6 @@ static sh_video_t *sh_video=NULL; static demuxer_t *demuxer=NULL; pthread_mutex_t audio_timer_mutex=PTHREAD_MUTEX_INITIALIZER; -#ifdef USE_SUB -static subtitle* subtitles=NULL; -static float sub_last_pts = -303; -#endif /* XP audio buffer */ typedef struct audio_buffer_index_s { float pts; @@ -719,10 +718,10 @@ inited_flags&=~INITED_SUBTITLE; pinfo[xp_id].current_module="sub_free"; mp_input_uninit(); - sub_free( subtitles ); + sub_free( mp_subtitles ); sub_name=NULL; vo.sub=NULL; - subtitles=NULL; + mp_subtitles=NULL; } #endif pinfo[xp_id].current_module=NULL; @@ -1177,63 +1176,6 @@ #endif //================= Update OSD ==================== -void update_subtitle(float v_pts) -{ - -#ifdef USE_SUB - // find sub - if(subtitles && v_pts>0){ - float pts=v_pts; - if(sub_fps==0) sub_fps=sh_video->fps; - pinfo[xp_id].current_module="find_sub"; - if (pts > sub_last_pts || pts < sub_last_pts-1.0 ) { - find_sub(subtitles,sub_uses_time?(100*pts):(pts*sub_fps)); // FIXME! frame counter... - sub_last_pts = pts; - } - pinfo[xp_id].current_module=NULL; - } -#endif 8 - - // DVD sub: -#if 0 - if(vo_flags & 0x08){ - static vo_mpegpes_t packet; - static vo_mpegpes_t *pkg=&packet; - packet.timestamp=sh_video->timer*90000.0; - packet.id=0x20; /* Subpic */ - while((packet.size=ds_get_packet_sub(d_dvdsub,&packet.data))>0){ - MSG_V("\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",packet.size,v_pts,d_dvdsub->pts); - vo_draw_frame(&pkg); - } - }else -#endif - if(vo.spudec){ - unsigned char* packet=NULL; - int len,timestamp; - pinfo[xp_id].current_module="spudec"; - spudec_heartbeat(vo.spudec,90000*v_pts); - if (vo.vobsub) { - if (v_pts >= 0) { - while((len=vobsub_get_packet(vo.vobsub, v_pts,(any_t**)&packet, ×tamp))>0){ - timestamp -= (v_pts - sh_video->timer)*90000; - MSG_V("\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len,v_pts,sh_video->timer,timestamp / 90000.0,timestamp); - spudec_assemble(vo.spudec,packet,len,90000*d_dvdsub->pts); - - } - } - } else { - while((len=ds_get_packet_sub(d_dvdsub,&packet))>0){ - MSG_V("\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",len,v_pts,d_dvdsub->pts); - spudec_assemble(vo.spudec,packet,len,90000*d_dvdsub->pts); - } - } - /* detect wether the sub has changed or not */ - if(spudec_changed(vo.spudec)) - vo_osd_changed(OSDTYPE_SPU); - pinfo[xp_id].current_module=NULL; - } -} - static void __show_status_line(float a_pts,float video_pts,float delay,float AV_delay,video_stat_t *vstat) { MSG_STATUS("A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d %d [frms: [%i]]\n", a_pts-delay,video_pts,AV_delay,c_total, @@ -1953,17 +1895,17 @@ // check .sub pinfo[xp_id].current_module="read_subtitles_file"; if(sub_name){ - subtitles=sub_read_file(sub_name, sh_video->fps); - if(!subtitles) MSG_ERR(MSGTR_CantLoadSub,sub_name); + mp_subtitles=sub_read_file(sub_name, sh_video->fps); + if(!mp_subtitles) MSG_ERR(MSGTR_CantLoadSub,sub_name); } else if(sub_auto) { // auto load sub file ... - subtitles=sub_read_file( filename ? sub_filename( get_path("sub/"), filename ) + mp_subtitles=sub_read_file( filename ? sub_filename( get_path("sub/"), filename ) : "default.sub", sh_video->fps ); } - if(subtitles) + if(mp_subtitles) { inited_flags|=INITED_SUBTITLE; - if(stream_dump_type>1) list_sub_file(subtitles); + if(stream_dump_type>1) list_sub_file(mp_subtitles); } #endif } Modified: mplayerxp/spudec.c =================================================================== --- mplayerxp/spudec.c 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/spudec.c 2012-10-19 17:06:52 UTC (rev 177) @@ -578,6 +578,12 @@ spu->packet_size = spu->packet_offset = 0; } +void __FASTCALL__ spudec_now_pts(any_t*this, unsigned int pts100) +{ + spudec_handle_t *spu = (spudec_handle_t*) this; + spu->now_pts = pts100; +} + void __FASTCALL__ spudec_heartbeat(any_t*this, unsigned int pts100) { spudec_handle_t *spu = (spudec_handle_t*) this; Modified: mplayerxp/spudec.h =================================================================== --- mplayerxp/spudec.h 2012-10-19 14:37:49 UTC (rev 176) +++ mplayerxp/spudec.h 2012-10-19 17:06:52 UTC (rev 177) @@ -9,6 +9,7 @@ extern float spu_gaussvar; void __FASTCALL__ spudec_heartbeat(any_t*_this, unsigned int pts100); +void __FASTCALL__ spudec_now_pts(any_t*_this, unsigned int pts100); void __FASTCALL__ spudec_assemble(any_t*_this, unsigned char *packet, unsigned int len, unsigned int pts100); void __FASTCALL__ spudec_draw(any_t*this, draw_osd_f draw_alpha); void __FASTCALL__ spudec_draw_scaled(any_t*_this, unsigned int dxs, unsigned int dys,draw_osd_f draw_alpha); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |