use super::decode_annexb;
const VECTOR: &[u8] = include_bytes!("../../tests/fixtures/hevc/intra-422-10.hevc");
const EXPECTED: u64 = 0xc932_4cae_793f_082f;
fn fnv1a(h: &mut u64, sample: u16) {
for b in sample.to_le_bytes() {
*h ^= u64::from(b);
*h = h.wrapping_mul(0x0100_0000_01b3);
}
}
#[test]
fn a_422_10bit_picture_decodes_sample_exact() {
let f = decode_annexb(VECTOR).expect("decode");
assert_eq!((f.width, f.height, f.bit_depth), (128, 128, 10));
assert_eq!(f.chroma, crate::hevc::ChromaFormat::Yuv422);
let (w, h) = (f.width as usize, f.height as usize);
let mut sum = 0xcbf2_9ce4_8422_2325u64;
for y in 0..h {
for x in 0..w {
fnv1a(&mut sum, f.y[y * f.y_stride as usize + x]);
}
}
for plane in [&f.cb, &f.cr] {
for y in 0..h {
for x in 0..w / 2 {
fnv1a(&mut sum, plane[y * f.c_stride as usize + x]);
}
}
}
assert_eq!(
sum, EXPECTED,
"4:2:2 picture differs from the reference decode"
);
}