diff options
author | jstebbins <[email protected]> | 2012-12-08 21:51:06 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-12-08 21:51:06 +0000 |
commit | 5299bc74c04ed8908ab2b18ce01b9c43b0ae99b7 (patch) | |
tree | aca38305e10887a7c4506e3d5085c426a3b79f60 /libhb | |
parent | feb7340f66dfadfa10f67e95e3298aba123024ef (diff) |
libhb: Fix a timing problem when rendering vobsubs
So, if we are rendering the subtitles, do not delay them in sync. The
renderer is responsible for handling stop == -1.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5092 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/rendersub.c | 14 | ||||
-rw-r--r-- | libhb/sync.c | 38 |
2 files changed, 41 insertions, 11 deletions
diff --git a/libhb/rendersub.c b/libhb/rendersub.c index c9e9f02cf..4e37699ae 100644 --- a/libhb/rendersub.c +++ b/libhb/rendersub.c @@ -248,12 +248,18 @@ static void ApplySub( hb_filter_private_t * pv, hb_buffer_t * buf, hb_buffer_t * static void ApplyVOBSubs( hb_filter_private_t * pv, hb_buffer_t * buf ) { int ii; - hb_buffer_t * sub; + hb_buffer_t *sub, *next; - for( ii = 0; ii < hb_list_count( pv->sub_list ); ) + for( ii = 0; ii < hb_list_count(pv->sub_list); ) { sub = hb_list_item( pv->sub_list, ii ); - if( sub->s.stop <= buf->s.start ) + if (ii + 1 < hb_list_count(pv->sub_list)) + next = hb_list_item( pv->sub_list, ii + 1 ); + else + next = NULL; + + if ((sub->s.stop != -1 && sub->s.stop <= buf->s.start) || + (next != NULL && sub->s.stop == -1 && next->s.start <= buf->s.start)) { // Subtitle stop is in the past, delete it hb_list_rem( pv->sub_list, sub ); @@ -541,6 +547,8 @@ static int ssa_work( hb_filter_object_t * filter, while( ( sub = hb_fifo_get( filter->subtitle->fifo_out ) ) ) { // Parse MKV-SSA packet + // SSA subtitles always have an explicit stop time, so we + // do not need to do special processing for stop == -1 ass_process_chunk( pv->ssaTrack, (char*)sub->data, sub->size, sub->s.start / 90, (sub->s.stop - sub->s.start) / 90 ); diff --git a/libhb/sync.c b/libhb/sync.c index 16517cb3a..592ebb8c3 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -560,23 +560,45 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, // muxer or renderer filter. while ( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) != NULL ) { - if ( sub->s.stop == -1 && hb_fifo_size( subtitle->fifo_raw ) < 2 ) - break; + hb_lock( pv->common->mutex ); + sub_start = sub->s.start - pv->common->video_pts_slip; + hb_unlock( pv->common->mutex ); + + if (sub->s.stop == -1) + { + if (subtitle->config.dest != RENDERSUB && + hb_fifo_size( subtitle->fifo_raw ) < 2) + { + // For passthru subs, we want to wait for the + // next subtitle so that we can fill in the stop time. + // This way the muxer can compute the duration of + // the subtitle. + // + // For render subs, we need to ensure that they + // get to the renderer before the associated video + // that they are to be applied to. It is the + // responsibility of the renderer to handle + // stop == -1. + break; + } + } sub = hb_fifo_get( subtitle->fifo_raw ); if ( sub->s.stop == -1 ) { hb_buffer_t *next; next = hb_fifo_see( subtitle->fifo_raw ); - sub->s.stop = next->s.start; + if (next != NULL) + sub->s.stop = next->s.start; } // Need to re-write subtitle timestamps to account // for any slippage. - hb_lock( pv->common->mutex ); - sub_start = sub->s.start - pv->common->video_pts_slip; - hb_unlock( pv->common->mutex ); - duration = sub->s.stop - sub->s.start; - sub_stop = sub_start + duration; + sub_stop = -1; + if ( sub->s.stop != -1 ) + { + duration = sub->s.stop - sub->s.start; + sub_stop = sub_start + duration; + } sub->s.start = sub_start; sub->s.stop = sub_stop; |