From 5c6d055a15fdeb48315b8eeea0ee51d3301d01e8 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 18:28:20 +0000 Subject: Rename ambiguous "pts" variable to subpts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29706 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mpcommon.c') diff --git a/mpcommon.c b/mpcommon.c index ba738dcee4..bbdfd32b7a 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -147,8 +147,8 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) double endpts; vo_sub = &subs; while (d_dvdsub->first) { - double pts = ds_get_next_pts(d_dvdsub); - if (pts > curpts) + double subpts = ds_get_next_pts(d_dvdsub); + if (subpts > curpts) break; endpts = d_dvdsub->first->endpts; len = ds_get_packet_sub(d_dvdsub, &packet); @@ -164,15 +164,15 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) if (!ass_track) continue; if (type == 'a') { // ssa/ass subs with libass ass_process_chunk(ass_track, packet, len, - (long long)(pts*1000 + 0.5), - (long long)((endpts-pts)*1000 + 0.5)); + (long long)(subpts*1000 + 0.5), + (long long)((endpts-subpts)*1000 + 0.5)); } else { // plaintext subs with libass vo_sub = NULL; - if (pts != MP_NOPTS_VALUE) { - if (endpts == MP_NOPTS_VALUE) endpts = pts + 3; + if (subpts != MP_NOPTS_VALUE) { + if (endpts == MP_NOPTS_VALUE) endpts = subpts + 3; sub_clear_text(&subs, MP_NOPTS_VALUE); sub_add_text(&subs, packet, len, endpts); - subs.start = pts * 100; + subs.start = subpts * 100; subs.end = endpts * 100; ass_process_subtitle(ass_track, &subs); } @@ -180,7 +180,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) continue; } #endif - if (pts != MP_NOPTS_VALUE) { + if (subpts != MP_NOPTS_VALUE) { if (endpts == MP_NOPTS_VALUE) sub_clear_text(&subs, MP_NOPTS_VALUE); if (type == 'a') { // ssa/ass subs without libass => convert to plaintext -- cgit v1.2.3 From 8dad891bf98a8e51fe3bbbc3d2a0cbfc8f8a7268 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 19:01:33 +0000 Subject: Factor out sh_video->pts into a refpts variable. This simplifies a future patch that reduces the dependency on sh_video. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29707 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'mpcommon.c') diff --git a/mpcommon.c b/mpcommon.c index bbdfd32b7a..c0b5acc806 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -71,6 +71,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) int len; char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; static subtitle subs; + double refpts = sh_video->pts; if (reset) { sub_clear_text(&subs, MP_NOPTS_VALUE); if (vo_sub) { @@ -84,15 +85,14 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) } // find sub if (subdata) { - double pts = sh_video->pts; if (sub_fps==0) sub_fps = sh_video->fps; current_module = "find_sub"; - if (pts > sub_last_pts || pts < sub_last_pts-1.0) { - find_sub(subdata, (pts+sub_delay) * + if (refpts > sub_last_pts || refpts < sub_last_pts-1.0) { + find_sub(subdata, (refpts+sub_delay) * (subdata->sub_uses_time ? 100. : sub_fps)); if (vo_sub) vo_sub_last = vo_sub; // FIXME! frame counter... - sub_last_pts = pts; + sub_last_pts = refpts; } } @@ -108,12 +108,12 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) // Vobsub len = 0; if (vo_vobsub) { - if (sh_video->pts+sub_delay >= 0) { - len = vobsub_get_packet(vo_vobsub, sh_video->pts+sub_delay, + if (refpts+sub_delay >= 0) { + len = vobsub_get_packet(vo_vobsub, refpts+sub_delay, (void**)&packet, ×tamp); if (len > 0) { - timestamp -= (sh_video->pts + sub_delay - sh_video->timer)*90000; - mp_dbg(MSGT_CPLAYER,MSGL_V,"\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len,sh_video->pts,sh_video->timer,timestamp / 90000.0,timestamp); + timestamp -= (refpts + sub_delay - sh_video->timer)*90000; + mp_dbg(MSGT_CPLAYER,MSGL_V,"\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len,refpts,sh_video->timer,timestamp / 90000.0,timestamp); } } } else { @@ -125,14 +125,14 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) // d_video->pts which would have been the simplest // improvement doesn't work because mpeg specific hacks // in video.c set d_video->pts to 0. - float x = d_dvdsub->pts - sh_video->pts; + float x = d_dvdsub->pts - refpts; if (x > -20 && x < 20) // prevent missing subs on pts reset timestamp = 90000*(sh_video->timer + d_dvdsub->pts - + sub_delay - sh_video->pts); + + sub_delay - refpts); else timestamp = 90000*(sh_video->timer + sub_delay); mp_dbg(MSGT_CPLAYER, MSGL_V, "\rDVD sub: len=%d " "v_pts=%5.3f s_pts=%5.3f ts=%d \n", len, - sh_video->pts, d_dvdsub->pts, timestamp); + refpts, d_dvdsub->pts, timestamp); } } if (len<=0 || !packet) break; @@ -143,7 +143,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) if (spudec_changed(vo_spudec)) vo_osd_changed(OSDTYPE_SPU); } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) { - double curpts = sh_video->pts + sub_delay; + double curpts = refpts + sub_delay; double endpts; vo_sub = &subs; while (d_dvdsub->first) { -- cgit v1.2.3 From f9c8809a396ba7d587544ef92e952ff894ab9972 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 19:04:24 +0000 Subject: Include mpcommon.h in mpcommon.c, ensures that the declarations in the header match those in the file. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29708 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'mpcommon.c') diff --git a/mpcommon.c b/mpcommon.c index c0b5acc806..394a71461f 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -14,6 +14,7 @@ #include "stream/tv.h" #include "libavutil/intreadwrite.h" #include "m_option.h" +#include "mpcommon.h" double sub_last_pts = -303; -- cgit v1.2.3 From bf16f6f4f329b7903ba550c458545fbdb41f5314 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 21:21:58 +0000 Subject: Make update_subtitles work without sh_video for text subtitles. This fixes a crash with e.g. auto-enabled subtitles and -novideo due to command.c calling update_subtitles even without video and is a step toward subtitle support for audio-only files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29710 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mpcommon.c') diff --git a/mpcommon.c b/mpcommon.c index 394a71461f..e28614390d 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -66,13 +66,12 @@ if (HAVE_CMOV) } -void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) +void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset) { unsigned char *packet=NULL; int len; char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; static subtitle subs; - double refpts = sh_video->pts; if (reset) { sub_clear_text(&subs, MP_NOPTS_VALUE); if (vo_sub) { @@ -86,7 +85,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) } // find sub if (subdata) { - if (sub_fps==0) sub_fps = sh_video->fps; + if (sub_fps==0) sub_fps = sh_video ? sh_video->fps : 25; current_module = "find_sub"; if (refpts > sub_last_pts || refpts < sub_last_pts-1.0) { find_sub(subdata, (refpts+sub_delay) * -- cgit v1.2.3 From 4b182ff652ee52647913a065801df12c99989173 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 23 Sep 2009 21:48:48 +0000 Subject: Add support for displaying subtitles on the command-line when playing audio-only files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29712 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'mpcommon.c') diff --git a/mpcommon.c b/mpcommon.c index e28614390d..162dbbf26e 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -75,8 +75,7 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd if (reset) { sub_clear_text(&subs, MP_NOPTS_VALUE); if (vo_sub) { - vo_sub = NULL; - vo_osd_changed(OSDTYPE_SUBTITLE); + set_osd_subtitle(NULL); } if (vo_spudec) { spudec_reset(vo_spudec); @@ -145,7 +144,6 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) { double curpts = refpts + sub_delay; double endpts; - vo_sub = &subs; while (d_dvdsub->first) { double subpts = ds_get_next_pts(d_dvdsub); if (subpts > curpts) @@ -167,7 +165,6 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd (long long)(subpts*1000 + 0.5), (long long)((endpts-subpts)*1000 + 0.5)); } else { // plaintext subs with libass - vo_sub = NULL; if (subpts != MP_NOPTS_VALUE) { if (endpts == MP_NOPTS_VALUE) endpts = subpts + 3; sub_clear_text(&subs, MP_NOPTS_VALUE); @@ -195,11 +192,11 @@ void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvd packet = p; } sub_add_text(&subs, packet, len, endpts); - vo_osd_changed(OSDTYPE_SUBTITLE); + set_osd_subtitle(&subs); } } if (sub_clear_text(&subs, curpts)) - vo_osd_changed(OSDTYPE_SUBTITLE); + set_osd_subtitle(&subs); } current_module=NULL; } -- cgit v1.2.3