summaryrefslogtreecommitdiffstats
path: root/mpcommon.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-10 12:53:05 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:43 +0200
commitd6322407c503bbca1f1bb48e06e275f7b610a3a8 (patch)
treec91fb481adc01438c39ace4ace6c5e0ddf30dfdd /mpcommon.c
parent1882a37adb50774089d5d508ef9910d4b2a30db4 (diff)
downloadmpv-d6322407c503bbca1f1bb48e06e275f7b610a3a8.tar.bz2
mpv-d6322407c503bbca1f1bb48e06e275f7b610a3a8.tar.xz
subs: change subdelay handling and vobsub timing
Make subdelay handling work the same way for all subtitle types and also allow changing subtitle delay to work better with vobsubs. This probably breaks vobsub behaviour with timestamp wrapping though. Positive values for sub delay now delay subtitles compared to video, where before the effect was in the opposite direction. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31663 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mpcommon.c')
-rw-r--r--mpcommon.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/mpcommon.c b/mpcommon.c
index 0b6d95d92b..47706ed497 100644
--- a/mpcommon.c
+++ b/mpcommon.c
@@ -89,6 +89,7 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
sh_video_t *sh_video, double refpts, double sub_offset,
demux_stream_t *d_dvdsub, int reset)
{
+ double curpts = refpts + sub_delay;
unsigned char *packet=NULL;
int len;
char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
@@ -109,7 +110,7 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
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(mpctx, subdata, (refpts+sub_delay) *
+ find_sub(mpctx, subdata, curpts *
(subdata->sub_uses_time ? 100. : sub_fps));
if (vo_sub) vo_sub_last = vo_sub;
// FIXME! frame counter...
@@ -121,18 +122,16 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
if (vo_spudec && (vobsub_id >= 0 || (opts->sub_id >= 0 && 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
- * relative to sh_video->timer */
+ spudec_heartbeat(vo_spudec, 90000*curpts);
+ /* Get a sub packet from the DVD or a vobsub */
while(1) {
// Vobsub
len = 0;
if (vo_vobsub) {
- if (refpts+sub_delay >= 0) {
- len = vobsub_get_packet(vo_vobsub, refpts+sub_delay,
+ if (curpts >= 0) {
+ len = vobsub_get_packet(vo_vobsub, curpts,
(void**)&packet, &timestamp);
if (len > 0) {
- 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);
}
}
@@ -147,9 +146,8 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
// in video.c set d_video->pts to 0.
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 - refpts);
- else timestamp = 90000*(sh_video->timer + sub_delay);
+ timestamp = 90000*d_dvdsub->pts;
+ else timestamp = 90000*curpts;
mp_dbg(MSGT_CPLAYER, MSGL_V, "\rDVD sub: len=%d "
"v_pts=%5.3f s_pts=%5.3f ts=%d \n", len,
refpts, d_dvdsub->pts, timestamp);
@@ -164,7 +162,6 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
vo_osd_changed(OSDTYPE_SPU);
} else if (opts->sub_id >= 0
&& (type == 't' || type == 'm' || type == 'a' || type == 'd')) {
- double curpts = refpts + sub_delay;
double endpts;
if (type == 'd' && !d_dvdsub->demuxer->teletext) {
tt_stream_props tsp = {0};