mirror of
https://github.com/freemkv/libfreemkv.git
synced 2026-10-07 18:13:10 +00:00
tests: pin the Class II MKB gate and the primary Dolby Vision dvcC
The Class II fixture was a bare type record, which derives nothing with or without the gate; the planted derivable MKB now derives under a pre-recorded type and not under Class II. The primary DV track's dvcC bytes (base layer present, compatibility id 0) are asserted beside the enhancement-layer track's.
This commit is contained in:
@@ -1244,6 +1244,24 @@ mod position_recovery_tests {
|
||||
}
|
||||
}
|
||||
|
||||
// The Class II gate is what refuses the derivation: the planted MKB derives its media key
|
||||
// as a pre-recorded block, and the same records under the Class II type derive nothing.
|
||||
#[test]
|
||||
fn a_class_ii_type_refuses_an_otherwise_derivable_mkb() {
|
||||
let p = plant_mkb();
|
||||
let pk = aesg3(&p.dkey, 1);
|
||||
assert_eq!(
|
||||
derive_media_key_from_pk(&p.mkb, &[pk]),
|
||||
Some(p.mk),
|
||||
"control"
|
||||
);
|
||||
let mut class2 = p.mkb.clone();
|
||||
class2[4..8].copy_from_slice(&MKB_TYPE_10_CLASS_II.to_be_bytes());
|
||||
assert_eq!(mkb_type(&class2), Some(MkbType::ClassII));
|
||||
assert!(MkbTables::parse(&class2).is_none());
|
||||
assert_eq!(derive_media_key_from_pk(&class2, &[pk]), None);
|
||||
}
|
||||
|
||||
/// Sanity-check the fixture itself before anything is asserted about the
|
||||
/// functions under test: an MKB the parser cannot read would make every
|
||||
/// "returns None" body look correct.
|
||||
|
||||
@@ -7782,6 +7782,16 @@ mod tests {
|
||||
assert_eq!(MkvTrack::video(&v).dv_config, Some(want));
|
||||
}
|
||||
|
||||
// A primary DV track carries its own base layer: rpu=1 el=1 bl=1, compatibility id 0.
|
||||
#[test]
|
||||
fn dolby_vision_primary_track_dvcc_bytes() {
|
||||
let mut v = uhd_video(HdrFormat::DolbyVision, ColorSpace::Bt2020);
|
||||
v.frame_rate = crate::disc::FrameRate::F23_976;
|
||||
let mut want = vec![0u8; 24];
|
||||
want[..5].copy_from_slice(&[0x01, 0x00, 0x0E, 0x37, 0x00]);
|
||||
assert_eq!(MkvTrack::video(&v).dv_config, Some(want));
|
||||
}
|
||||
|
||||
// dvcC level follows the 2160p frame rate; unknown rate keeps the 2160p24 level.
|
||||
#[test]
|
||||
fn dv_level_follows_the_frame_rate() {
|
||||
|
||||
Reference in New Issue
Block a user