summaryrefslogtreecommitdiffstats
path: root/libhb
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
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')
-rw-r--r--libhb/decvobsub.c12
-rw-r--r--libhb/sync.c30
2 files changed, 29 insertions, 13 deletions
diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c
index 102d7f0ce..9bd1b7808 100644
--- a/libhb/decvobsub.c
+++ b/libhb/decvobsub.c
@@ -208,7 +208,7 @@ static void ParseControls( hb_work_object_t * w )
int date, next;
pv->pts_start = 0;
- pv->pts_stop = 0;
+ pv->pts_stop = -1;
pv->pts_forced = 0;
pv->alpha[3] = 0;
@@ -267,7 +267,7 @@ static void ParseControls( hb_work_object_t * w )
break;
case 0x02: // 0x02 - STP_DSP - Stop Display, no arguments
- if(!pv->pts_stop)
+ if(pv->pts_stop == -1)
pv->pts_stop = pv->pts + date * 1024;
break;
@@ -343,7 +343,7 @@ static void ParseControls( hb_work_object_t * w )
}
// fading-out
- if( currAlpha < lastAlpha && !pv->pts_stop )
+ if( currAlpha < lastAlpha && pv->pts_stop == -1 )
{
pv->pts_stop = pv->pts + date * 1024;
}
@@ -377,12 +377,6 @@ static void ParseControls( hb_work_object_t * w )
}
i = next;
}
-
- if( !pv->pts_stop )
- {
- /* Show it for 3 seconds */
- pv->pts_stop = pv->pts_start + 3 * 90000;
- }
}
/***********************************************************************
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