Mercurial > mplayer.hg
diff mplayer.c @ 21827:b0bc0d81f91b
Subtitle handling cleanup: factor out code for parsing embedded subtitles
and adding and removing of lines in subtitle struct into subreader.c.
author | reimar |
---|---|
date | Sat, 06 Jan 2007 19:07:58 +0000 |
parents | fa9422a466e5 |
children | b36abbbca01e |
line wrap: on
line diff
--- a/mplayer.c Sat Jan 06 19:02:19 2007 +0000 +++ b/mplayer.c Sat Jan 06 19:07:58 2007 +0000 @@ -2893,6 +2893,9 @@ 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 @@ } // 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 @@ 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; }