forge
Explore
Log in

Don't you dare go Hollow

Take the clip's dimensions by position

Browse files at this commit

d04b63e8667d71f53ebbe5dec05eb1b5f283b176Ahmet Kaan GümüşParent: f5dbd0b
  • test
    • take the clip's dimensions by position
Show full message
test(h265): take the clip's dimensions by position

ffprobe prints one comma-separated line per stream and recent builds end
it with a trailing separator, so splitting the line in two handed the
parse a field with a comma still on it and every clip-driven gate
panicked before it measured anything.
crates/ec-h265/tests/encode.rsmodified+11 -5
@@ -740,11 +740,17 @@ fn clip_sources(path: &std::ffi::OsStr, want: usize) -> (usize, usize, Vec<Plane
740740 String::from_utf8_lossy(&dims.stderr)
741741 );
742742 let csv = String::from_utf8_lossy(&dims.stdout);
743- let (w, h) = csv
744- .trim()
745- .split_once(',')
746- .and_then(|(w, h)| Some((w.parse::<usize>().ok()?, h.parse::<usize>().ok()?)))
747- .expect("ffprobe returned dimensions");
743+ // ffprobe prints one comma-separated line per stream, and recent builds
744+ // end it with a trailing separator, so the fields are taken by position
745+ // rather than by splitting the line in two.
746+ let mut fields = csv.lines().next().unwrap_or_default().split(',');
747+ let (w, h) = (|| {
748+ Some((
749+ fields.next()?.trim().parse::<usize>().ok()?,
750+ fields.next()?.trim().parse::<usize>().ok()?,
751+ ))
752+ })()
753+ .unwrap_or_else(|| panic!("ffprobe returned dimensions, got {csv:?}"));
748754 // Pictures to pass over before sampling: the head of a film is titles and
749755 // fades, which are not what a codec is measured on.
750756 let skip: usize = std::env::var("EC_H265_CLIP_SKIP")