summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-11-10 17:40:10 +0000
committerjstebbins <[email protected]>2009-11-10 17:40:10 +0000
commit5cc0054c9778fcb8b952e14abeab94a532e1bf5c (patch)
tree6ca8df3bdcfd96cc97901795b733508e11de74b9
parent867a53a08540f6ae2101599a30e30a59ce40521c (diff)
don't drop the last SRT subtitle
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2921 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/decsrtsub.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/libhb/decsrtsub.c b/libhb/decsrtsub.c
index fa3b9c468..15015aae2 100644
--- a/libhb/decsrtsub.c
+++ b/libhb/decsrtsub.c
@@ -315,6 +315,69 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
}
}
}
+
+ hb_buffer_t *buffer = NULL;
+ if( *pv->current_entry.text )
+ {
+ long length;
+ char *p, *q;
+ int line = 1;
+ uint64_t start_time = ( pv->current_entry.start +
+ pv->subtitle->config.offset ) * 90;
+ uint64_t stop_time = ( pv->current_entry.stop +
+ pv->subtitle->config.offset ) * 90;
+
+ if( !( start_time > pv->start_time && stop_time < pv->stop_time ) )
+ {
+ hb_deep_log( 3, "Discarding SRT at time start %"PRId64", stop %"PRId64, start_time, stop_time);
+ memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+ return NULL;
+ }
+
+ length = strlen( pv->current_entry.text );
+
+ for( q = p = pv->current_entry.text; *p; p++)
+ {
+ if( *p == '\n' )
+ {
+ if ( line == 1 )
+ {
+ *q = *p;
+ line = 2;
+ }
+ else
+ {
+ *q = ' ';
+ }
+ q++;
+ }
+ else if( *p != '\r' )
+ {
+ *q = *p;
+ q++;
+ }
+ else
+ {
+ length--;
+ }
+ }
+ *q = '\0';
+
+ buffer = hb_buffer_init( length + 1 );
+
+ if( buffer )
+ {
+ buffer->start = start_time - pv->start_time;
+ buffer->stop = stop_time - pv->start_time;
+
+ memcpy( buffer->data, pv->current_entry.text, length + 1 );
+ }
+ }
+ memset( &pv->current_entry, 0, sizeof( srt_entry_t ) );
+ if( buffer )
+ {
+ return buffer;
+ }
return NULL;
}