Skip to content

Commit

Permalink
apply format changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
alastor0325 committed Jan 31, 2025
1 parent 0cf6c85 commit b7fcc34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 1 addition & 3 deletions mp4parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5591,9 +5591,7 @@ fn read_video_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleEntry>
BoxType::PixelAspectRatioBox => {
let pasp = read_pasp(&mut b)?;
let aspect_ratio = pasp.h_spacing as f32 / pasp.v_spacing as f32;
let is_valid_aspect_ratio = |value: f32| -> bool {
value > 0.0 && value < 10.0
};
let is_valid_aspect_ratio = |value: f32| -> bool { value > 0.0 && value < 10.0 };
// Only set pixel_aspect_ratio if it is valid
if is_valid_aspect_ratio(aspect_ratio) {
pixel_aspect_ratio = Some(aspect_ratio);
Expand Down
11 changes: 9 additions & 2 deletions mp4parse/tests/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,8 +1490,15 @@ fn public_parse_pasp_h264() {
assert_eq!(v.codec_type, mp4::CodecType::H264);
assert_eq!(v.width, 640);
assert_eq!(v.height, 480);
assert!(v.pixel_aspect_ratio.is_some(), "pixel_aspect_ratio should exist");
assert_eq!(v.pixel_aspect_ratio.unwrap() as f32, 16.0 / 9.0, "pixel_aspect_ratio should be 16/9");
assert!(
v.pixel_aspect_ratio.is_some(),
"pixel_aspect_ratio should exist"
);
assert_eq!(
v.pixel_aspect_ratio.unwrap() as f32,
16.0 / 9.0,
"pixel_aspect_ratio should be 16/9"
);
}
}

Expand Down

0 comments on commit b7fcc34

Please sign in to comment.