Repair test suite + fix sample key-range overlap bug
The suite had accumulated breakage from prior refactors: - selection unification: rewrite the integration tests for the single unified clip_instances collection (shapes+clips are one set now). - tempo-map: thread a TempoMap (constant 60 BPM = identity) into the clip remap_time tests so the second-based expectations hold. - drop two dead rgba_to_yuv420p tests that asserted tight plane sizes incompatible with the function's 16-macroblock alignment. - ignore the WIP theme var() cascade test (theme system not wired up). Also a real bug the tests caught: auto_key_ranges produced overlapping sample key ranges (the midpoint key mapped to both adjacent samples). Start each range one past the previous midpoint.
This commit is contained in:
@@ -1350,61 +1350,10 @@ mod tests {
|
||||
assert!(v[0] > 128, "V value: {}", v[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgba_to_yuv420p_dimensions() {
|
||||
// 4×4 image (16 pixels)
|
||||
let rgba = vec![0u8; 4 * 4 * 4]; // All black
|
||||
let (y, u, v) = rgba_to_yuv420p(&rgba, 4, 4);
|
||||
|
||||
// Y should be full resolution: 4×4 = 16 pixels
|
||||
assert_eq!(y.len(), 16);
|
||||
|
||||
// U and V should be quarter resolution: 2×2 = 4 pixels each
|
||||
assert_eq!(u.len(), 4);
|
||||
assert_eq!(v.len(), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rgba_to_yuv420p_2x2_subsampling() {
|
||||
// Create 2×2 image with different colors in each corner
|
||||
let mut rgba = vec![0u8; 2 * 2 * 4];
|
||||
|
||||
// Top-left: Red
|
||||
rgba[0] = 255;
|
||||
rgba[1] = 0;
|
||||
rgba[2] = 0;
|
||||
rgba[3] = 255;
|
||||
|
||||
// Top-right: Green
|
||||
rgba[4] = 0;
|
||||
rgba[5] = 255;
|
||||
rgba[6] = 0;
|
||||
rgba[7] = 255;
|
||||
|
||||
// Bottom-left: Blue
|
||||
rgba[8] = 0;
|
||||
rgba[9] = 0;
|
||||
rgba[10] = 255;
|
||||
rgba[11] = 255;
|
||||
|
||||
// Bottom-right: White
|
||||
rgba[12] = 255;
|
||||
rgba[13] = 255;
|
||||
rgba[14] = 255;
|
||||
rgba[15] = 255;
|
||||
|
||||
let (y, u, v) = rgba_to_yuv420p(&rgba, 2, 2);
|
||||
|
||||
// Y plane should have 4 distinct values (one per pixel)
|
||||
assert_eq!(y.len(), 4);
|
||||
|
||||
// U and V should have 1 value each (averaged over 2×2 block)
|
||||
assert_eq!(u.len(), 1);
|
||||
assert_eq!(v.len(), 1);
|
||||
|
||||
// The averaged chroma should be close to neutral (128)
|
||||
// since we have all primary colors + white
|
||||
assert!(u[0] >= 100 && u[0] <= 156, "U value: {}", u[0]);
|
||||
assert!(v[0] >= 100 && v[0] <= 156, "V value: {}", v[0]);
|
||||
}
|
||||
// NOTE: `rgba_to_yuv420p` rounds dimensions up to multiples of 16 (H.264
|
||||
// macroblock alignment), so its plane lengths are the aligned sizes, not the
|
||||
// tight input dimensions. The former `test_rgba_to_yuv420p_dimensions` and
|
||||
// `_2x2_subsampling` tests asserted tight sizes and were removed when that
|
||||
// alignment was added. (This function is now unused in production — swscale
|
||||
// `CpuYuvConverter` and the GPU `export::gpu_yuv` path handle conversion.)
|
||||
}
|
||||
|
||||
@@ -471,7 +471,10 @@ fn auto_key_ranges(notes: &[u8]) -> Vec<(u8, u8)> {
|
||||
let min = if i == 0 {
|
||||
0
|
||||
} else {
|
||||
((notes[i - 1] as u16 + notes[i] as u16 + 1) / 2) as u8
|
||||
// One past the previous note's midpoint boundary, so adjacent ranges
|
||||
// don't both claim the midpoint key. The previous note's max is
|
||||
// floor((notes[i-1] + notes[i]) / 2); start here at that + 1.
|
||||
(((notes[i - 1] as u16 + notes[i] as u16) / 2) + 1) as u8
|
||||
};
|
||||
let max = if i == notes.len() - 1 {
|
||||
127
|
||||
|
||||
@@ -897,6 +897,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "WIP theme system: CSS var() custom-property resolution not yet implemented (theme.rs is kept under #[allow(dead_code)] and not wired up)"]
|
||||
fn test_cascade_resolve() {
|
||||
let css = r#"
|
||||
:root { --bg: #ff0000; }
|
||||
|
||||
Reference in New Issue
Block a user