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