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
This commit is contained in:
reimar 2009-09-23 19:01:33 +00:00
parent 5c6d055a15
commit 8dad891bf9
1 changed files with 12 additions and 12 deletions

View File

@ -71,6 +71,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
int len; int len;
char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
static subtitle subs; static subtitle subs;
double refpts = sh_video->pts;
if (reset) { if (reset) {
sub_clear_text(&subs, MP_NOPTS_VALUE); sub_clear_text(&subs, MP_NOPTS_VALUE);
if (vo_sub) { if (vo_sub) {
@ -84,15 +85,14 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
} }
// find sub // find sub
if (subdata) { if (subdata) {
double pts = sh_video->pts;
if (sub_fps==0) sub_fps = sh_video->fps; if (sub_fps==0) sub_fps = sh_video->fps;
current_module = "find_sub"; current_module = "find_sub";
if (pts > sub_last_pts || pts < sub_last_pts-1.0) { if (refpts > sub_last_pts || refpts < sub_last_pts-1.0) {
find_sub(subdata, (pts+sub_delay) * find_sub(subdata, (refpts+sub_delay) *
(subdata->sub_uses_time ? 100. : sub_fps)); (subdata->sub_uses_time ? 100. : sub_fps));
if (vo_sub) vo_sub_last = vo_sub; if (vo_sub) vo_sub_last = vo_sub;
// FIXME! frame counter... // 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 // Vobsub
len = 0; len = 0;
if (vo_vobsub) { if (vo_vobsub) {
if (sh_video->pts+sub_delay >= 0) { if (refpts+sub_delay >= 0) {
len = vobsub_get_packet(vo_vobsub, sh_video->pts+sub_delay, len = vobsub_get_packet(vo_vobsub, refpts+sub_delay,
(void**)&packet, &timestamp); (void**)&packet, &timestamp);
if (len > 0) { if (len > 0) {
timestamp -= (sh_video->pts + sub_delay - sh_video->timer)*90000; 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,sh_video->pts,sh_video->timer,timestamp / 90000.0,timestamp); 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 { } 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 // d_video->pts which would have been the simplest
// improvement doesn't work because mpeg specific hacks // improvement doesn't work because mpeg specific hacks
// in video.c set d_video->pts to 0. // 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 if (x > -20 && x < 20) // prevent missing subs on pts reset
timestamp = 90000*(sh_video->timer + d_dvdsub->pts timestamp = 90000*(sh_video->timer + d_dvdsub->pts
+ sub_delay - sh_video->pts); + sub_delay - refpts);
else timestamp = 90000*(sh_video->timer + sub_delay); else timestamp = 90000*(sh_video->timer + sub_delay);
mp_dbg(MSGT_CPLAYER, MSGL_V, "\rDVD sub: len=%d " mp_dbg(MSGT_CPLAYER, MSGL_V, "\rDVD sub: len=%d "
"v_pts=%5.3f s_pts=%5.3f ts=%d \n", len, "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; 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)) if (spudec_changed(vo_spudec))
vo_osd_changed(OSDTYPE_SPU); vo_osd_changed(OSDTYPE_SPU);
} else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) { } 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; double endpts;
vo_sub = &subs; vo_sub = &subs;
while (d_dvdsub->first) { while (d_dvdsub->first) {