diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/deccc608sub.c | 10 | ||||
-rw-r--r-- | libhb/decmpeg2.c | 7 | ||||
-rw-r--r-- | libhb/muxmp4.c | 22 | ||||
-rw-r--r-- | libhb/reader.c | 7 | ||||
-rw-r--r-- | libhb/sync.c | 69 |
5 files changed, 89 insertions, 26 deletions
diff --git a/libhb/deccc608sub.c b/libhb/deccc608sub.c index 2b0b199fa..0451b251e 100644 --- a/libhb/deccc608sub.c +++ b/libhb/deccc608sub.c @@ -2048,10 +2048,18 @@ void handle_command (/*const */ unsigned char c1, const unsigned char c2, struct } void handle_end_of_data (struct s_write *wb) -{ +{ + hb_buffer_t *buffer; + // We issue a EraseDisplayedMemory here so if there's any captions pending // they get written to file. handle_command (0x14, 0x2c, wb); // EDM + + /* + * At the end of the subtitle stream HB wants an empty buffer + */ + buffer = hb_buffer_init( 0 ); + hb_fifo_push( wb->subtitle->fifo_raw, buffer ); } void handle_double (const unsigned char c1, const unsigned char c2, struct s_write *wb) diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c index 9d28c9775..756eb9768 100644 --- a/libhb/decmpeg2.c +++ b/libhb/decmpeg2.c @@ -658,6 +658,13 @@ static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_list_add( pv->list, *buf_in ); *buf_in = NULL; status = HB_WORK_DONE; + /* + * Let the Closed Captions know that it is the end of the data. + */ + if( pv->libmpeg2->subtitle ) + { + handle_end_of_data( &pv->libmpeg2->cc608 ); + } } *buf_out = NULL; diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index bdeea8c42..6795a33ec 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -598,15 +598,25 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data, while( ( sub = hb_fifo_see( subtitle->fifo_out )) != NULL ) { - if (sub->start < buf->start ) { + if( sub->size == 0 ) + { + /* + * EOF + */ + hb_log("MuxMP4: Text Sub: EOF"); sub = hb_fifo_get( subtitle->fifo_out ); - hb_log("MuxMP4: Text Sub:%lld: %s", sub->start, sub->data); hb_buffer_close( &sub ); } else { - /* - * Not time yet - */ - break; + if( sub->start < buf->start ) { + sub = hb_fifo_get( subtitle->fifo_out ); + hb_log("MuxMP4: Text Sub:%lld: %s", sub->start, sub->data); + hb_buffer_close( &sub ); + } else { + /* + * Not time yet + */ + break; + } } } } diff --git a/libhb/reader.c b/libhb/reader.c index e0345378f..f7470bfa2 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -457,6 +457,13 @@ static void ReaderFunc( void * _r ) push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) ); } + hb_subtitle_t *subtitle; + for( n = 0; ( subtitle = hb_list_item( r->job->title->list_subtitle, n ) ); ++n ) + { + if ( subtitle->fifo_in ) + push_buf( r, subtitle->fifo_in, hb_buffer_init(0) ); + } + hb_list_empty( &list ); hb_buffer_close( &ps ); if (r->dvd) diff --git a/libhb/sync.c b/libhb/sync.c index b102b49f7..39be41310 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -414,7 +414,7 @@ static void SyncVideo( hb_work_object_t * w ) * What about discontinuity boundaries - not delt * with here - Van? */ - if( sub->start < cur->start ) + if( sub->size == 0 || sub->start < cur->start ) { sub = hb_fifo_get( subtitle->fifo_raw ); sub->start = pv->next_start; @@ -431,6 +431,14 @@ static void SyncVideo( hb_work_object_t * w ) hb_buffer_t * sub2; while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) ) { + if( sub->size == 0 ) + { + /* + * EOF, pass it through immediately. + */ + break; + } + /* If two subtitles overlap, make the first one stop when the second one starts */ sub2 = hb_fifo_see2( subtitle->fifo_raw ); @@ -468,6 +476,14 @@ static void SyncVideo( hb_work_object_t * w ) hb_buffer_close( &sub ); } + if( sub && sub->size == 0 ) + { + /* + * Continue immediately on subtitle EOF + */ + break; + } + /* * There is a valid subtitle, is it time to display it? */ @@ -606,28 +622,43 @@ static void SyncVideo( hb_work_object_t * w ) if( sub && subtitle && subtitle->format == PICTURESUB ) { - if( subtitle->dest == RENDERSUB ) + if( sub->size > 0 ) { - /* - * Tack onto the video buffer for rendering - */ - buf_tmp->sub = hb_buffer_init( sub->size ); - buf_tmp->sub->x = sub->x; - buf_tmp->sub->y = sub->y; - buf_tmp->sub->width = sub->width; - buf_tmp->sub->height = sub->height; - memcpy( buf_tmp->sub->data, sub->data, sub->size ); + if( subtitle->dest == RENDERSUB ) + { + /* + * Tack onto the video buffer for rendering + */ + buf_tmp->sub = hb_buffer_init( sub->size ); + buf_tmp->sub->x = sub->x; + buf_tmp->sub->y = sub->y; + buf_tmp->sub->width = sub->width; + buf_tmp->sub->height = sub->height; + memcpy( buf_tmp->sub->data, sub->data, sub->size ); + } else { + /* + * Pass-Through, pop it off of the raw queue, rewrite times and + * make it available to be muxed. + */ + uint64_t sub_duration; + sub = hb_fifo_get( subtitle->fifo_raw ); + sub_duration = sub->stop - sub->start; + sub->start = buf_tmp->start; + sub->stop = sub->start + duration; + hb_fifo_push( subtitle->fifo_out, sub ); + } } else { /* - * Pass-Through, pop it off of the raw queue, rewrite times and - * make it available to be muxed. + * EOF - consume for rendered, else pass through */ - uint64_t sub_duration; - sub = hb_fifo_get( subtitle->fifo_raw ); - sub_duration = sub->stop - sub->start; - sub->start = buf_tmp->start; - sub->stop = sub->start + duration; - hb_fifo_push( subtitle->fifo_out, sub ); + if( subtitle->dest == RENDERSUB ) + { + sub = hb_fifo_get( subtitle->fifo_raw ); + hb_buffer_close( &sub ); + } else { + sub = hb_fifo_get( subtitle->fifo_raw ); + hb_fifo_push( subtitle->fifo_out, sub ); + } } } |