forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/w0t-subs' into simplify/w0

Browse files at this commit

4eb263f036c3e08ad77fe8ded9053860167b8e57Ahmet Kaan GümüşParent: 45bfe95c56a74b
crates/ec-ass/src/lib.rsmodified+4 -1
@@ -237,11 +237,14 @@ fn dialogue(format: &[String], row: &str, wrap_style: u8) -> Option<SubtitleCue>
237 let values: Vec<&str> = row.splitn(format.len(), ',').collect();237 let values: Vec<&str> = row.splitn(format.len(), ',').collect();
238 let start_us = parse_clock(column(format, &values, "Start")?)?;238 let start_us = parse_clock(column(format, &values, "Start")?)?;
239 let end_us = parse_clock(column(format, &values, "End")?)?;239 let end_us = parse_clock(column(format, &values, "End")?)?;
240+ if end_us <= start_us {
241+ return None;
242+ }
240 let text = column(format, &values, "Text").unwrap_or_default();243 let text = column(format, &values, "Text").unwrap_or_default();
241 let (segments, positioning) = body(text, wrap_style);244 let (segments, positioning) = body(text, wrap_style);
242 Some(SubtitleCue {245 Some(SubtitleCue {
243 start_us,246 start_us,
244- end_us: end_us.max(start_us),247+ end_us,
245 style_ref: column(format, &values, "Style")248 style_ref: column(format, &values, "Style")
246 .filter(|s| !s.is_empty())249 .filter(|s| !s.is_empty())
247 .map(str::to_owned),250 .map(str::to_owned),
crates/ec-cc/tests/streams.rsmodified+1 -1
@@ -143,7 +143,7 @@ fn ffmpeg_cues(path: &PathBuf, demuxer_args: &[&str]) -> Vec<(String, f64)> {
143 assert!(st.success());143 assert!(st.success());
144 let text = std::fs::read_to_string(&srt).unwrap();144 let text = std::fs::read_to_string(&srt).unwrap();
145 let mut out = Vec::new();145 let mut out = Vec::new();
146- for block in text.split("\n\n") {146+ for block in text.split("\n\n").filter(|b| !b.trim().is_empty()) {
147 let mut l = block.lines();147 let mut l = block.lines();
148 l.next().unwrap();148 l.next().unwrap();
149 let Some(tl) = l.next() else { continue };149 let Some(tl) = l.next() else { continue };
crates/ec-subs/tests/open_media.rsmodified+3 -3
@@ -9,7 +9,7 @@ fn a_real_subrip_track_parses_whole() {
9 let bytes = fixture("subs/TOS-en.srt");9 let bytes = fixture("subs/TOS-en.srt");
10 let track = ec_subs::srt::parse(&bytes).unwrap();10 let track = ec_subs::srt::parse(&bytes).unwrap();
11 assert_eq!(track.source, Some(SourceFormat::Srt));11 assert_eq!(track.source, Some(SourceFormat::Srt));
12- assert!(track.cues.len() > 100, "{} cues", track.cues.len());12+ assert_eq!(track.cues.len(), 76, "ffmpeg reads 76 cues");
13 assert_eq!(track.skipped, 0, "a whole file should have no torn blocks");13 assert_eq!(track.skipped, 0, "a whole file should have no torn blocks");
14 for cue in &track.cues {14 for cue in &track.cues {
15 assert!(cue.end_us >= cue.start_us);15 assert!(cue.end_us >= cue.start_us);
@@ -33,7 +33,7 @@ fn a_real_ass_script_parses_whole() {
33 let track = ec_ass::parse(&bytes).unwrap();33 let track = ec_ass::parse(&bytes).unwrap();
34 assert_eq!(track.source, Some(SourceFormat::AssOrSsa));34 assert_eq!(track.source, Some(SourceFormat::AssOrSsa));
35 assert!(!track.styles.is_empty(), "a script declares styles");35 assert!(!track.styles.is_empty(), "a script declares styles");
36- assert!(track.cues.len() > 100, "{} cues", track.cues.len());36+ assert_eq!(track.cues.len(), 76, "ffmpeg reads 76 cues");
37 assert_eq!(track.skipped, 0, "a whole script should have no torn rows");37 assert_eq!(track.skipped, 0, "a whole script should have no torn rows");
38 let with_text = track38 let with_text = track
39 .cues39 .cues
@@ -101,7 +101,7 @@ fn a_real_pgs_stream_decodes_to_plausible_bitmaps() {
101 .count();101 .count();
102 assert!(rows > 4, "display set {frames} paints {rows} rows");102 assert!(rows > 4, "display set {frames} paints {rows} rows");
103 }103 }
104- assert!(frames > 100, "{frames} display sets");104+ assert_eq!(frames, 1, "ffprobe reads one subtitle frame");
105 assert!(105 assert!(
106 painted * 3 > frames,106 painted * 3 > frames,
107 "{painted} of {frames} display sets painted anything"107 "{painted} of {frames} display sets painted anything"