Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

WINCI: Repair upstream HEVC timing and CRLF translation validation

Cathy Shapiro626df5ac86c0
diff --git a/crates/platform/src/nvenc/session.rs b/crates/platform/src/nvenc/session.rs
index 1791c017c..6f8d1cfaf 100644
--- a/crates/platform/src/nvenc/session.rs
+++ b/crates/platform/src/nvenc/session.rs
@@ -408,9 +408,11 @@ impl Session {
vui.colourPrimaries = u32::from(p.signal.primaries);
vui.transferCharacteristics = u32::from(p.signal.transfer);
vui.colourMatrix = u32::from(p.signal.matrix);
- vui.timingInfoPresentFlag = 1;
- vui.numUnitInTicks = p.fps.1;
- vui.timeScale = p.fps.0;
+ // Let NVENC derive timing from frameRateNum/frameRateDen. Some drivers
+ // reverse the explicitly supplied HEVC VUI timing pair.
+ vui.timingInfoPresentFlag = 0;
+ vui.numUnitInTicks = 0;
+ vui.timeScale = 0;
}
}
diff --git a/crates/platform/tests/nvenc_hevc.rs b/crates/platform/tests/nvenc_hevc.rs
index d10835298..acd2bee9b 100644
--- a/crates/platform/tests/nvenc_hevc.rs
+++ b/crates/platform/tests/nvenc_hevc.rs
@@ -321,3 +321,19 @@ fn a_keyframe_every_one_or_two_pictures_is_written_without_b_frames() {
assert_eq!(n + dec.flush().len(), 12, "keyint {keyint}");
}
}
+
+#[test]
+fn vui_timing_matches_integer_and_fractional_frame_rates() {
+ let _one = SERIAL.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
+ for fps in [(24, 1), (25, 1), (30_000, 1_001)] {
+ let mut cfg = config(640, 360);
+ cfg.fps = fps;
+ cfg.bframes = false;
+ let Some((enc, _, _)) = encode_all(&cfg, 2) else { return };
+ let sps_nal = enc.parameter_sets().0;
+ let sps = Sps::parse(&unescape_rbsp(&sps_nal[2..])).unwrap();
+ let (units, scale) = sps.vui.and_then(|v| v.timing).expect("HEVC VUI timing");
+ assert!(units > 0 && scale > 0);
+ assert_eq!(u64::from(scale) * u64::from(fps.1), u64::from(units) * u64::from(fps.0), "timing for {fps:?}");
+ }
+}
diff --git a/crates/ui-egui/src/i18n/mod.rs b/crates/ui-egui/src/i18n/mod.rs
index c04416c6a..3e7e4869b 100644
--- a/crates/ui-egui/src/i18n/mod.rs
+++ b/crates/ui-egui/src/i18n/mod.rs
@@ -369,14 +369,28 @@ mod tests {
dirs.push(p);
} else if p.extension().is_some_and(|e| e == "rs") {
let text = std::fs::read_to_string(&p).unwrap_or_default();
- let cut = text.find("#[cfg(test)]\nmod tests").unwrap_or(text.len());
- out.push((p.display().to_string(), text[..cut].to_string()));
+ out.push((p.display().to_string(), production_source(&text)));
}
}
}
out
}
+ fn production_source(text: &str) -> String {
+ let text = text.replace("\r\n", "\n");
+ let cut = text.find("#[cfg(test)]\nmod tests").unwrap_or(text.len());
+ text[..cut].to_string()
+ }
+
+ #[test]
+ fn translation_scan_excludes_test_modules_with_either_line_ending() {
+ let source = "tl!(\"Save\");\n#[cfg(test)]\nmod tests { tl!(\"test-only string\"); }";
+ for text in [source.to_string(), source.replace('\n', "\r\n")] {
+ let production = production_source(&text);
+ assert_eq!(tl_literals(&production), vec!["Save"]);
+ }
+ }
+
/// The (unescaped) string literals passed to `tl!` and `tlf!` in a source file.
fn tl_literals(text: &str) -> Vec<String> {
let mut out = Vec::new();