From 61e4a801913f76695aa8445206d27720ba7bac8b Mon Sep 17 00:00:00 2001 From: reimar Date: Sat, 6 Jan 2007 19:07:58 +0000 Subject: Subtitle handling cleanup: factor out code for parsing embedded subtitles and adding and removing of lines in subtitle struct into subreader.c. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21845 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mplayer.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index e672f95743..920de07c54 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2893,6 +2893,9 @@ static double playing_audio_pts(sh_audio_t *sh_audio, demux_stream_t *d_audio, static void update_subtitles(void) { + unsigned char *packet=NULL; + int len; + char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; // find sub if (subdata) { double pts = sh_video->pts; @@ -2908,9 +2911,8 @@ static void update_subtitles(void) } // DVD sub: - if (vo_config_count && vo_spudec) { - unsigned char* packet=NULL; - int len, timestamp; + if (vo_config_count && vo_spudec && type == 'v') { + int timestamp; current_module = "spudec"; spudec_heartbeat(vo_spudec, 90000*sh_video->timer); /* Get a sub packet from the DVD or a vobsub and make a timestamp @@ -2953,6 +2955,22 @@ static void update_subtitles(void) if (spudec_changed(vo_spudec)) vo_osd_changed(OSDTYPE_SPU); + } else if (dvdsub_id >= 0 && type == 't') { + double pts = MP_NOPTS_VALUE; + while (d_dvdsub->first) { + double nextpts = ds_get_next_pts(d_dvdsub); + if (nextpts == MP_NOPTS_VALUE || nextpts - sub_delay > sh_video->pts) + break; + len = ds_get_packet_sub(d_dvdsub, &packet); + pts = nextpts - sub_delay; + } + if (pts != MP_NOPTS_VALUE) { + static subtitle subs; + sub_clear_text(&subs, MP_NOPTS_VALUE); + sub_add_text(&subs, packet, len, MP_NOPTS_VALUE); + vo_sub = &subs; + vo_osd_changed(OSDTYPE_SUBTITLE); + } } current_module=NULL; } -- cgit v1.2.3