FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
mxf: saturate interlaced picture height
Nigel Ihza Firdausy9fcd14ec1192
diff --git a/crates/mxf/src/essence.rs b/crates/mxf/src/essence.rsindex b40c19be0..84cb277b2 100644--- a/crates/mxf/src/essence.rs+++ b/crates/mxf/src/essence.rs@@ -151,7 +151,7 @@ impl PictureInfo {/// Frame height: field-based layouts code the height of one field.pub fn frame_height(&self) -> u32 {let h = if self.display_height > 0 { self.display_height } else { self.stored_height };- if matches!(self.frame_layout, 1 | 3) { h * 2 } else { h }+ if matches!(self.frame_layout, 1 | 3) { h.saturating_mul(2) } else { h }}pub fn frame_width(&self) -> u32 {if self.display_width > 0 { self.display_width } else { self.stored_width }@@ -268,6 +268,14 @@ mod tests {Ul(b)}+ #[test]+ fn interlaced_picture_height_does_not_overflow() {+ let picture = PictureInfo { stored_height: u32::MAX, frame_layout: 1, ..Default::default() };+ assert_eq!(picture.frame_height(), u32::MAX);+ let picture = PictureInfo { display_height: 240, stored_height: u32::MAX, frame_layout: 3, ..Default::default() };+ assert_eq!(picture.frame_height(), 480);+ }+#[test]fn identifies_picture_codings() {assert_eq!(identify_picture(Some(ul(&[4, 1, 2, 2, 1, 0x31, 0x40, 1])), None, false), Codec::Avc { intra: false });