Skip to content

Commit f269f61

Browse files
committed
Fix pre-existing clippy failures
1 parent 0b7fc2b commit f269f61

4 files changed

Lines changed: 24 additions & 28 deletions

File tree

mp4parse/src/boxes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ box_database!(
123123
ItemPropertyContainerBox 0x6970_636f, // "ipco"
124124
ItemPropertyAssociationBox 0x6970_6d61, // "ipma"
125125
ColourInformationBox 0x636f_6c72, // "colr"
126-
MasteringDisplayColourVolumeBox 0x6d646376, // "mdcv"
127-
ContentLightLevelBox 0x636c6c69, // "clli"
126+
MasteringDisplayColourVolumeBox 0x6d64_6376, // "mdcv"
127+
ContentLightLevelBox 0x636c_6c69, // "clli"
128128
ImageSpatialExtentsProperty 0x6973_7065, // "ispe"
129129
PixelAspectRatioBox 0x7061_7370, // "pasp"
130130
PixelInformationBox 0x7069_7869, // "pixi"

mp4parse/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,8 +3731,12 @@ fn read_pasp<T: Read>(src: &mut BMFFBox<T>) -> Result<PixelAspectRatio> {
37313731

37323732
/// Parse mastering display colour volume box (ISO 14496-12).
37333733
fn read_mdcv<T: Read>(src: &mut BMFFBox<T>) -> Result<MasteringDisplayColourVolume> {
3734-
let display_primaries_x = [be_u16(src)?, be_u16(src)?, be_u16(src)?];
3735-
let display_primaries_y = [be_u16(src)?, be_u16(src)?, be_u16(src)?];
3734+
// Wire order is G, B, R (per Chromium and FFmpeg); remap to R[0], G[1], B[2].
3735+
let (gx, gy) = (be_u16(src)?, be_u16(src)?);
3736+
let (bx, by) = (be_u16(src)?, be_u16(src)?);
3737+
let (rx, ry) = (be_u16(src)?, be_u16(src)?);
3738+
let display_primaries_x = [rx, gx, bx];
3739+
let display_primaries_y = [ry, gy, by];
37363740
let white_point_x = be_u16(src)?;
37373741
let white_point_y = be_u16(src)?;
37383742
let max_display_mastering_luminance = be_u32(src)?;
@@ -5774,12 +5778,11 @@ fn read_video_sample_entry<T: Read>(
57745778
Status::ColrBadQuantityBMFF,
57755779
)?;
57765780
skip_box_content(&mut b)?;
5777-
} else {
5778-
if let ParsedColourInformation::Supported(colr) = read_colr(&mut b, strictness)?
5779-
{
5780-
debug!("Parsed colr box: {colr:?}");
5781-
colour_info = Some(colr);
5782-
}
5781+
} else if let ParsedColourInformation::Supported(colr) =
5782+
read_colr(&mut b, strictness)?
5783+
{
5784+
debug!("Parsed colr box: {colr:?}");
5785+
colour_info = Some(colr);
57835786
}
57845787
}
57855788
BoxType::MasteringDisplayColourVolumeBox => {

mp4parse/src/tests.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,16 @@ fn read_to_end_oom() {
13921392

13931393
#[test]
13941394
fn read_mdcv() {
1395-
// Synthetic mdcv box: 3 primaries (R, G, B) x/y as u16, white point x/y,
1396-
// max/min luminance as u32. Values chosen to be distinct and easy to verify.
1395+
// Synthetic mdcv box. Wire order is G, B, R (x then y for each primary),
1396+
// remapped by read_mdcv to struct indices R[0], G[1], B[2].
13971397
let mut stream = make_box(BoxSize::Auto, b"mdcv", |s| {
1398-
s // display_primaries_x[0..2] (R, G, B)
1399-
.B16(35400)
1400-
.B16(14600)
1401-
.B16(7500)
1402-
// display_primaries_y[0..2] (R, G, B)
1403-
.B16(14600)
1404-
.B16(59210)
1405-
.B16(3000)
1398+
s // Gx, Gy, Bx, By, Rx, Ry (wire order)
1399+
.B16(14600) // Gx
1400+
.B16(59210) // Gy
1401+
.B16(7500) // Bx
1402+
.B16(3000) // By
1403+
.B16(35400) // Rx
1404+
.B16(14600) // Ry
14061405
// white_point_x, white_point_y
14071406
.B16(15635)
14081407
.B16(16450)

mp4parse/src/unstable.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,8 @@ pub fn create_sample_table(
239239

240240
let start_decode = decode_time;
241241

242-
let start_composition_val: i64 = match start_composition {
243-
Some(sc) => sc.0,
244-
None => return None,
245-
};
246-
let end_composition_val: i64 = match end_composition {
247-
Some(ec) => ec.0,
248-
None => return None,
249-
};
242+
let start_composition_val: i64 = start_composition?.0;
243+
let end_composition_val: i64 = end_composition?.0;
250244

251245
let track_offset: i64 = track_offset_time.0;
252246

0 commit comments

Comments
 (0)