@@ -205,14 +205,10 @@ fn map_captions_to_edited_timeline(
205205 timeline : & TimelineConfiguration ,
206206 recording_durations : & [ f64 ] ,
207207) -> Vec < MappedCaption > {
208- let sanitized: Vec < CaptionSegment > = raw_segments
209- . iter ( )
210- . map ( clamp_caption_segment_words)
211- . collect ( ) ;
212-
213208 if timeline. segments . is_empty ( ) || recording_durations. is_empty ( ) {
214- return sanitized
215- . into_iter ( )
209+ return raw_segments
210+ . iter ( )
211+ . map ( clamp_caption_segment_words)
216212 . map ( |segment| MappedCaption {
217213 id : segment. id ,
218214 start : f64:: from ( segment. start ) ,
@@ -238,7 +234,7 @@ fn map_captions_to_edited_timeline(
238234
239235 let mut result = Vec :: new ( ) ;
240236
241- for caption in & sanitized {
237+ for caption in raw_segments {
242238 let mut mapped_caption_segments: Vec < MappedCaption > = Vec :: new ( ) ;
243239 let word_bounds = if caption. words . is_empty ( ) {
244240 None
@@ -247,7 +243,7 @@ fn map_captions_to_edited_timeline(
247243 ( f64:: INFINITY , f64:: NEG_INFINITY ) ,
248244 |( start, end) , word| {
249245 let word_start = f64:: from ( word. start ) ;
250- let word_end = f64:: from ( word. end ) ;
246+ let word_end = f64:: from ( word. end . min ( word . start + MAX_CAPTION_WORD_DURATION ) ) ;
251247 if word_start. is_nan ( ) || word_end. is_nan ( ) {
252248 None
253249 } else {
@@ -269,7 +265,7 @@ fn map_captions_to_edited_timeline(
269265 for word in & caption. words {
270266 let Some ( ( start, end) ) = map_time_range_within_mapping (
271267 f64:: from ( word. start ) ,
272- f64:: from ( word. end ) ,
268+ f64:: from ( word. end . min ( word . start + MAX_CAPTION_WORD_DURATION ) ) ,
273269 mapping,
274270 ) else {
275271 continue ;
@@ -446,6 +442,9 @@ pub fn synchronize_captions(project: &mut ProjectConfiguration, recording_durati
446442 derive_caption_track_segments ( & captions. segments , timeline, recording_durations) ;
447443}
448444
445+ #[ cfg( test) ]
446+ mod projection_tests;
447+
449448#[ cfg( test) ]
450449mod tests {
451450 use super :: * ;
0 commit comments