summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-04-27 15:05:34 +0000
committerjstebbins <[email protected]>2011-04-27 15:05:34 +0000
commit2d81a5ec8e0851b306b82eea9fead769ff6517b3 (patch)
treed8a03bbc25690f683b7e2bf4b879421ff9ae6dff /libhb/sync.c
parent630a07e488b60f813332d7e740cbaf72ff8d33c1 (diff)
Fix a problem with overlapping vobsubs
Since we now allow subtitles that overlap in time, it is no longer appropriate to arbitrarily set the duration to 3 seconds when vobsubs don't have an explicit stop time. This causes them to overlap on the display. So now, we set the stop time for such vobsubs to -1. Then in sync adjust the stop time to the start of the next vobsub when it is seen. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3961 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/libhb/sync.c b/libhb/sync.c
index 6d7a778a5..eedaedbab 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -582,8 +582,18 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
// If this subtitle track's packets are to be passed thru, do so immediately
if( subtitle->config.dest == PASSTHRUSUB )
{
- while ( ( sub = hb_fifo_get( subtitle->fifo_raw ) ) != NULL )
+ while ( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) != NULL )
{
+ if ( sub->stop == -1 && hb_fifo_size( subtitle->fifo_raw ) < 2 )
+ break;
+
+ sub = hb_fifo_get( subtitle->fifo_raw );
+ if ( sub->stop == -1 )
+ {
+ hb_buffer_t *next;
+ next = hb_fifo_see( subtitle->fifo_raw );
+ sub->stop = next->start;
+ }
// Need to re-write subtitle timestamps to account
// for any slippage.
hb_lock( pv->common->mutex );
@@ -633,13 +643,25 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_buffer_t *cur_sub_tail = NULL;
for ( sub = sync->sub_list; sub != NULL; )
{
+ if ( sub->next && sub->stop == -1 )
+ {
+ sub->stop = sub->next->start;
+ }
+
// Need to re-write subtitle timestamps to account
// for any slippage.
hb_lock( pv->common->mutex );
sub_start = sub->start - pv->common->video_pts_slip;
hb_unlock( pv->common->mutex );
- duration = sub->stop - sub->start;
- sub_stop = sub_start + duration;
+ if ( sub->stop != -1 )
+ {
+ duration = sub->stop - sub->start;
+ sub_stop = sub_start + duration;
+ }
+ else
+ {
+ sub_stop = -1;
+ }
if ( cur->start < sub_start )
{
@@ -649,7 +671,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
else
{
// Subtitle starts now or in the past...
- if ( cur->start < sub_stop )
+ if ( cur->start < sub_stop || sub_stop == -1 )
{
// Subtitle finishes in the future