X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fdecsrtsub.c;h=15015aae21ddd7c001f58cb23df0dd0c4a3e316f;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=fa3b9c4689e6e3f4965136ad83947e92466fb1ab;hpb=b61f64e4f4db7efdf5d32d7cd8e14876e9b6474d;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/decsrtsub.c b/libhb/decsrtsub.c index fa3b9c46..15015aae 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; }