summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-11-15 21:36:45 +0000
committerjstebbins <[email protected]>2011-11-15 21:36:45 +0000
commit935fe113ea0008656f4dfec80be731fd6d6c25d1 (patch)
treeca6be6e6969f820d95d33b46e462f923c8402175 /libhb
parentc557fe3d54da7141e898aae7f57f9897d92ba64c (diff)
Make sure decvobsub.c generates valid timestamps
sync.c expects that timestamps will all be resolved by the time buffers reach it. Reader will invalidate timestamps while waiting to resynchronize the SCR. So decoders (inparticular decvobsub) need to extrapolate timestamps when they are not supplied. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4352 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/decvobsub.c27
-rw-r--r--libhb/muxmp4.c6
2 files changed, 29 insertions, 4 deletions
diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c
index 9bd1b7808..fcada87d1 100644
--- a/libhb/decvobsub.c
+++ b/libhb/decvobsub.c
@@ -61,7 +61,7 @@ int decsubInit( hb_work_object_t * w, hb_job_t * job )
w->private_data = pv;
pv->job = job;
- pv->pts = -1;
+ pv->pts = 0;
// Warn if the input color palette is empty
int paletteEmpty = 1;
@@ -116,7 +116,10 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
pv->buf->id = in->id;
pv->buf->sequence = in->sequence;
pv->size_got = in->size;
- pv->pts = in->start;
+ if( in->start >= 0 )
+ {
+ pv->pts = in->start;
+ }
}
}
else
@@ -163,7 +166,12 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
pv->size_sub = 0;
pv->size_got = 0;
pv->size_rle = 0;
- pv->pts = -1;
+
+ // If we don't get a valid next timestamp, use the stop time
+ // of the current sub as the start of the next.
+ // This can happen if reader invalidates timestamps while
+ // waiting for an audio to update the SCR.
+ pv->pts = pv->pts_stop;
}
return HB_WORK_OK;
@@ -207,7 +215,7 @@ static void ParseControls( hb_work_object_t * w )
int command;
int date, next;
- pv->pts_start = 0;
+ pv->pts_start = -1;
pv->pts_stop = -1;
pv->pts_forced = 0;
@@ -377,6 +385,17 @@ static void ParseControls( hb_work_object_t * w )
}
i = next;
}
+ // Generate timestamps if they are not set
+ if( pv->pts_start == -1 )
+ {
+ // Set pts to end of last sub if the start time is unknown.
+ pv->pts_start = pv->pts;
+ }
+ if( pv->pts_stop == -1 )
+ {
+ // Set durtion to 10 sec if unknown.
+ pv->pts_stop = pv->pts + 90000L * 10;
+ }
}
/***********************************************************************
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index 5234c5a7a..d03326b80 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -1106,6 +1106,9 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
{
int64_t duration;
+ if( buf->start < 0 )
+ buf->start = mux_data->sum_dur;
+
if( buf->stop < 0 )
duration = 90000L * 10;
else
@@ -1175,6 +1178,9 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
{
int64_t duration;
+ if( buf->start < 0 )
+ buf->start = mux_data->sum_dur;
+
if( buf->stop < 0 )
duration = 90000L * 10;
else