libfreemkv 0.31.4: prune 144 vacuous tests (keep spec-grounded subset)
This commit is contained in:
@@ -631,27 +631,6 @@ mod tests {
|
||||
|
||||
// --- YCbCr → RGB green channel + neutral chroma ---
|
||||
|
||||
#[test]
|
||||
fn ycbcr_green_channel_formula() {
|
||||
// G = Y - 0.344*(Cb-128) - 0.714*(Cr-128). For pure-ish green choose
|
||||
// Y=145, Cb=54, Cr=34: G should be high, R and B low. (Full-range BT.601
|
||||
// per the module's deliberate convention.)
|
||||
let [r, g, b] = ycbcr_to_rgb(&[0x00, 145, 54, 34]);
|
||||
assert!(g > 200, "G high for green, got {g}");
|
||||
assert!(r < 80, "R low for green, got {r}");
|
||||
assert!(b < 80, "B low for green, got {b}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ycbcr_neutral_chroma_is_grey() {
|
||||
// Cb=Cr=128 (neutral) → R=G=B=Y for any Y. (Confirms the chroma terms
|
||||
// vanish at 128.)
|
||||
for y in [0u8, 64, 128, 200, 255] {
|
||||
let [r, g, b] = ycbcr_to_rgb(&[0x00, y, 128, 128]);
|
||||
assert_eq!([r, g, b], [y, y, y], "neutral chroma → grey at Y={y}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ycbcr_blue_channel_clamps_high() {
|
||||
// B = Y + 1.772*(Cb-128). Y=128, Cb=255 → 128 + 1.772*127 ≈ 353 → clamp 255.
|
||||
|
||||
@@ -1518,17 +1518,6 @@ mod tests {
|
||||
|
||||
// --- IRAP keyframe boundary values ---
|
||||
|
||||
#[test]
|
||||
fn irap_lower_boundary_type_16_is_keyframe() {
|
||||
// BLA_W_LP = 16, the inclusive lower boundary of NAL_BLA_W_LP..=23.
|
||||
let mut parser = HevcParser::new();
|
||||
let mut data = vec![0x00, 0x00, 0x01];
|
||||
data.extend_from_slice(&hevc_nal_header(16));
|
||||
data.extend_from_slice(&[0x10, 0x20]);
|
||||
let f = parser.parse(&make_pes(data, Some(0)));
|
||||
assert!(f[0].keyframe);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_15_just_below_irap_not_keyframe() {
|
||||
// Type 15 (RASL_R) is one below the IRAP range and must NOT be a keyframe.
|
||||
|
||||
@@ -225,17 +225,6 @@ mod tests {
|
||||
assert_eq!(f[0].data, vec![0xAB], "5 BD bytes → 1 PCM byte");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bd_exactly_four_bytes_dropped() {
|
||||
// Exactly 4 bytes = header only: `len <= offset` (4 <= 4) → dropped.
|
||||
let mut parser = LpcmParser::new();
|
||||
assert!(
|
||||
parser
|
||||
.parse(&make_pes(vec![0x00, 0x01, 0x00, 0x91], Some(0)))
|
||||
.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bd_three_bytes_dropped() {
|
||||
// Fewer than the 4-byte header → dropped, no panic / no underflow slice.
|
||||
|
||||
@@ -803,20 +803,6 @@ mod tests {
|
||||
assert_eq!(f2[0].pts_ns, 0, "no PTS/DTS → 0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn frame_data_is_whole_pes_not_just_picture() {
|
||||
// The emitted frame data is the ENTIRE PES payload (pes.data.clone()),
|
||||
// not just the picture NAL — MPEG-2 ES is muxed as-is. Confirm a seq
|
||||
// header + picture PES emits the whole buffer.
|
||||
let mut parser = Mpeg2Parser::new();
|
||||
let mut data = make_seq_header(720, 480, 3, 4);
|
||||
data.extend_from_slice(&make_picture_header(PICTURE_TYPE_I));
|
||||
data.extend_from_slice(&[0x12, 0x34]);
|
||||
let f = parser.parse(&make_pes(data.clone(), Some(0)));
|
||||
assert_eq!(f.len(), 1);
|
||||
assert_eq!(f[0].data, data, "frame data = whole PES payload");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parser_resolution_method() {
|
||||
let mut parser = Mpeg2Parser::new();
|
||||
|
||||
@@ -433,17 +433,6 @@ mod tests {
|
||||
|
||||
// --- duration computation and clamping ---
|
||||
|
||||
#[test]
|
||||
fn duration_is_clear_minus_display() {
|
||||
// BlockDuration = clear_pts - display_pts (in ns). display @ 90000 (1s),
|
||||
// clear @ 450000 (5s) → duration 4s.
|
||||
let mut parser = PgsParser::new();
|
||||
let _ = parser.parse(&make_pes(pcs_bytes(1), Some(90000)));
|
||||
let f = parser.parse(&make_pes(pcs_bytes(0), Some(450000)));
|
||||
assert_eq!(f[0].pts_ns, 1_000_000_000);
|
||||
assert_eq!(f[0].duration_ns, Some(4_000_000_000));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duration_clamps_to_zero_when_clear_precedes_display() {
|
||||
// A clear PTS earlier than the display PTS (corrupt/out-of-order stream)
|
||||
|
||||
@@ -163,15 +163,6 @@ mod tests {
|
||||
|
||||
// --- skip_start_code: boundary / form selection ---
|
||||
|
||||
#[test]
|
||||
fn skip_4byte_preferred_over_3byte_when_extra_zero_present() {
|
||||
// `00 00 00 01`: the function must recognise the 4-byte form (return
|
||||
// pos+4), not stop at a phantom 3-byte interpretation. data[pos+2]==0x00
|
||||
// and data[pos+3]==0x01 select the 4-byte branch.
|
||||
let data = [0x00, 0x00, 0x00, 0x01, 0x42];
|
||||
assert_eq!(skip_start_code(&data, 0), Some(4));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skip_start_code_at_nonzero_pos() {
|
||||
// skip must honour pos: a 3-byte code at offset 2 returns 2+3 = 5.
|
||||
|
||||
@@ -526,12 +526,6 @@ mod tests {
|
||||
assert_eq!(truehd_channels(1 << 20), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truehd_channels_71_layout_low5_bits() {
|
||||
// Standard 7.1: 8ch bits 0-4 = L/R(2)+C(1)+LFE(1)+Ls/Rs(2)+Lb/Rb(2) = 8.
|
||||
assert_eq!(truehd_channels(0x1F), Some(8));
|
||||
}
|
||||
|
||||
// --- truehd_channels_from_stream: major-sync variant bit + scan ---
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -588,47 +588,6 @@ mod tests {
|
||||
assert_eq!(parse_vc1_resolution(&sh), Some((8192, 8192)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolution_field_is_12_bits_no_higher() {
|
||||
// Asserting the field width: a width one step above the max (8194 →
|
||||
// coded_w 4096) overflows the 12-bit MAX_CODED_WIDTH field (4096 & 0xFFF
|
||||
// = 0), so it cannot encode 8194 — it wraps to (0+1)*2 = 2. This proves
|
||||
// the 12-bit masking in the parser, i.e. it never reads a 13th bit.
|
||||
let sh = make_ap_seq_header(8194, 720);
|
||||
assert_eq!(
|
||||
parse_vc1_resolution(&sh),
|
||||
Some((2, 720)),
|
||||
"coded_w field is masked to 12 bits → 4096 wraps to 0 → width 2"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolution_deescapes_emulation_prevention() {
|
||||
// VC-1 Annex-B EBDU payload may carry an emulation-prevention 0x03 after
|
||||
// a 00 00 run. The resolution parser must de-escape before bit
|
||||
// extraction; an EP byte in the first few payload bytes would otherwise
|
||||
// shift every later bit and corrupt the dimensions. Build a header whose
|
||||
// de-escaped payload encodes 1280x720, then splice 00 00 03 into the raw
|
||||
// payload and confirm it still decodes 1280x720.
|
||||
let base = make_ap_seq_header(1280, 720);
|
||||
// base = [00 00 01 0F][5 payload bytes]. Insert a benign EP run that
|
||||
// de-escapes away: find a spot where two zeros precede our inserted 0x03.
|
||||
// Construct payload manually: prepend 00 00 03 then the real 5 bytes; the
|
||||
// de-escaper drops the 0x03, leaving 00 00 + the 5 bytes → but that
|
||||
// shifts the fields. Instead, the real coverage: the de-escaper collects
|
||||
// 5 bytes skipping EP. Put the EP at the very front so after stripping we
|
||||
// still recover the 5 meaningful bytes... that changes leading bits.
|
||||
// Simpler grounded check: a payload with a trailing EP byte (after the 5
|
||||
// needed bytes) must not change the result, since only 5 are collected.
|
||||
let mut sh = base.clone();
|
||||
sh.extend_from_slice(&[0x00, 0x00, 0x03, 0xFF]); // trailing EP run
|
||||
assert_eq!(
|
||||
parse_vc1_resolution(&sh),
|
||||
Some((1280, 720)),
|
||||
"trailing EP bytes beyond the 5 collected must not affect parsing"
|
||||
);
|
||||
}
|
||||
|
||||
// --- codec_private BITMAPINFOHEADER field layout ---
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user