forge
Explore
Log in

Don't you dare go Hollow

U16 widen compiles clean, 263/263 tests pass, 8-bit output bit-exact

Browse files at this commit

35100f3dc3522119c8dcd9fb7726bd991e6c5e84Ahmet Kaan GümüşParent: f83f39f
  • feat
    • u16 widen compiles clean, 263/263 tests pass, 8-bit output bit-exact
Show full message
feat(av1): u16 widen compiles clean, 263/263 tests pass, 8-bit output bit-exact

Closes the 42-error checkpoint from r1's saved diff. decode.rs/warp.rs/mc.rs
call sites widened through OBMC and interintra blend chains; encode.rs and
motion.rs's own buffers stay u8 (encoder is 8-bit only this round) with a
local u16 round-trip box (intra_predict_u8 in encode.rs, inline conversion
in mc_trial and motion::search_traced_from_step) at their 4 call sites into
the now-widened intra::predict/mc::predict. bit_depth != 8 refusal
untouched, no 10-bit gate added.
crates/ec-av1/src/decode.rsmodified+6 -6
@@ -12838,7 +12838,7 @@ mod tests {
1283812838 let data = enc.finish();
1283912839
1284012840 let (width, height) = (64usize, 64usize);
12841- let ref_pattern: Vec<u8> = (0..width * height).map(|i| (i % 251) as u8).collect();
12841+ let ref_pattern: Vec<u16> = (0..width * height).map(|i| (i % 251) as u16).collect();
1284212842 let ref_plane = |scale: usize| PlaneBuf {
1284312843 data: ref_pattern
1284412844 .iter()
@@ -12881,7 +12881,7 @@ mod tests {
1288112881 tile_y1: height,
1288212882 };
1288312883 let mut u = PlaneBuf {
12884- data: vec![0u8; (width / 2) * (height / 2)],
12884+ data: vec![0u16; (width / 2) * (height / 2)],
1288512885 width: width / 2,
1288612886 height: height / 2,
1288712887 true_width: width / 2,
@@ -12892,7 +12892,7 @@ mod tests {
1289212892 tile_y1: height / 2,
1289312893 };
1289412894 let mut v = PlaneBuf {
12895- data: vec![0u8; (width / 2) * (height / 2)],
12895+ data: vec![0u16; (width / 2) * (height / 2)],
1289612896 width: width / 2,
1289712897 height: height / 2,
1289812898 true_width: width / 2,
@@ -12957,7 +12957,7 @@ mod tests {
1295712957 .unwrap();
1295812958
1295912959 let (px, py) = (c * SUB, r * SUB);
12960- let mut want_near = vec![0u8; side * side];
12960+ let mut want_near = vec![0u16; side * side];
1296112961 crate::mc::predict(
1296212962 &ref_y.data,
1296312963 ref_y.width,
@@ -12969,7 +12969,7 @@ mod tests {
1296912969 side,
1297012970 &mut want_near,
1297112971 );
12972- let mut want_nearest = vec![0u8; side * side];
12972+ let mut want_nearest = vec![0u16; side * side];
1297312973 crate::mc::predict(
1297412974 &ref_y.data,
1297512975 ref_y.width,
@@ -12986,7 +12986,7 @@ mod tests {
1298612986 "test setup: the two candidate MVs must predict differently"
1298712987 );
1298812988
12989- let mut got = vec![0u8; side * side];
12989+ let mut got = vec![0u16; side * side];
1299012990 for row in 0..side {
1299112991 got[row * side..(row + 1) * side].copy_from_slice(
1299212992 &y.data[(py + row) * y.width + px..(py + row) * y.width + px + side],
crates/ec-av1/src/mc.rsmodified+23 -21
@@ -600,7 +600,7 @@ pub fn blend_masked_compound(
600600 /// off-by-one from double rounding.
601601 #[test]
602602 fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {
603- let reference = vec![100u8; 16 * 16];
603+ let reference = vec![100u16; 16 * 16];
604604 let mut pred0 = vec![0i32; 16];
605605 predict_compound_intermediate(
606606 &reference,
@@ -618,7 +618,7 @@ fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {
618618 assert!(pred0.iter().all(|&v| v == 1600), "{pred0:?}");
619619
620620 let pred1 = pred0.clone();
621- let mut dst = vec![0u8; 16];
621+ let mut dst = vec![0u16; 16];
622622 combine_compound(&pred0, &pred1, 8, 8, &mut dst);
623623 assert!(dst.iter().all(|&v| v == 100), "{dst:?}");
624624 }
@@ -670,9 +670,11 @@ mod tests {
670670 // real (0, 0) coordinates -- clamping then reproduces the identical
671671 // extended border the dump already captured.
672672 let stride = 24;
673- let mut reference = vec![0u8; stride * 24];
673+ let mut reference = vec![0u16; stride * 24];
674674 for (r, row) in window.iter().enumerate() {
675- reference[r * stride..r * stride + stride].copy_from_slice(row);
675+ for (c, &v) in row.iter().enumerate() {
676+ reference[r * stride + c] = u16::from(v);
677+ }
676678 }
677679 // predict()'s own edge clamp starts at true (0,0); shift so the
678680 // dumped window's row/col 4 lands there by biasing x_q4/y_q4's
@@ -682,7 +684,7 @@ mod tests {
682684 // whole-pel part of x_q4/y_q4 by +4 to land on real (0,0).
683685 let x_q4 = (4 + 0) * 16 + 15; // real block x0=0, xfrac=15
684686 let y_q4 = (4 + 0) * 16 + 7; // real block y0=0, yfrac=7
685- let mut dst = vec![0u8; 16 * 16];
687+ let mut dst = vec![0u16; 16 * 16];
686688 predict_with_filter(
687689 &reference,
688690 stride,
@@ -696,7 +698,7 @@ mod tests {
696698 &mut dst,
697699 );
698700 #[rustfmt::skip]
699- let expected_row0: [u8; 16] =
701+ let expected_row0: [u16; 16] =
700702 [114,114,114,114,115,115,115,116,116,116,116,116,117,117,116,116];
701703 assert_eq!(
702704 &dst[0..16],
@@ -704,7 +706,7 @@ mod tests {
704706 "row0 vs aomdec's real av1_convolve_2d_sr_c output"
705707 );
706708 #[rustfmt::skip]
707- let expected_row15: [u8; 16] =
709+ let expected_row15: [u16; 16] =
708710 [103,103,104,104,104,105,105,106,106,106,107,107,107,107,107,107];
709711 assert_eq!(
710712 &dst[15 * 16..15 * 16 + 16],
@@ -717,8 +719,8 @@ mod tests {
717719 fn integer_mv_is_identity() {
718720 let width = 12;
719721 let height = 12;
720- let reference: Vec<u8> = (0..width * height).map(|i| (i * 7 % 251) as u8).collect();
721- let mut dst = vec![0u8; 6 * 6];
722+ let reference: Vec<u16> = (0..width * height).map(|i| (i * 7 % 251) as u16).collect();
723+ let mut dst = vec![0u16; 6 * 6];
722724 predict(
723725 &reference,
724726 width,
@@ -746,10 +748,10 @@ mod tests {
746748 // Step 2 so every half-pel position lands on an exact integer.
747749 let width = 16;
748750 let height = 16;
749- let reference: Vec<u8> = (0..width * height)
750- .map(|i| (2 * (i % width)) as u8)
751+ let reference: Vec<u16> = (0..width * height)
752+ .map(|i| (2 * (i % width)) as u16)
751753 .collect();
752- let mut dst = vec![0u8; 4 * 4];
754+ let mut dst = vec![0u16; 4 * 4];
753755 // Half-pel in x only: fraction 8/16, integer part at column 5.
754756 predict(
755757 &reference,
@@ -778,10 +780,10 @@ mod tests {
778780 fn constant_plane_has_unit_dc_gain_at_every_subpel_position() {
779781 let width = 20;
780782 let height = 20;
781- let reference = vec![142u8; width * height];
783+ let reference = vec![142u16; width * height];
782784 for yfrac in 0..16 {
783785 for xfrac in 0..16 {
784- let mut dst = vec![0u8; 5 * 5];
786+ let mut dst = vec![0u16; 5 * 5];
785787 predict(
786788 &reference,
787789 width,
@@ -810,11 +812,11 @@ mod tests {
810812 // it happened to produce two merely-different numbers.
811813 let width = 10;
812814 let height = 10;
813- let reference: Vec<u8> = (0..height)
814- .flat_map(|y| (0..width).map(move |x| (20 * x + 4 * y) as u8))
815+ let reference: Vec<u16> = (0..height)
816+ .flat_map(|y| (0..width).map(move |x| (20 * x + 4 * y) as u16))
815817 .collect();
816818
817- let mut horiz = vec![0u8; 4 * 4];
819+ let mut horiz = vec![0u16; 4 * 4];
818820 predict(
819821 &reference,
820822 width,
@@ -826,7 +828,7 @@ mod tests {
826828 4,
827829 &mut horiz,
828830 );
829- let mut vert = vec![0u8; 4 * 4];
831+ let mut vert = vec![0u16; 4 * 4];
830832 predict(
831833 &reference,
832834 width,
@@ -865,8 +867,8 @@ mod tests {
865867 fn mv_past_the_edge_clamps_instead_of_panicking() {
866868 let width = 8;
867869 let height = 8;
868- let reference: Vec<u8> = (0..width * height).map(|i| (i * 3 % 200) as u8).collect();
869- let mut dst = vec![0u8; 4 * 4];
870+ let reference: Vec<u16> = (0..width * height).map(|i| (i * 3 % 200) as u16).collect();
871+ let mut dst = vec![0u16; 4 * 4];
870872 // Whole-sample position far above and to the left of the plane, with
871873 // an odd fraction so both filter passes exercise the clamp.
872874 predict(
@@ -886,7 +888,7 @@ mod tests {
886888 "an MV past the top-left edge must clamp to the corner sample, got {dst:?}"
887889 );
888890
889- let mut dst2 = vec![0u8; 4 * 4];
891+ let mut dst2 = vec![0u16; 4 * 4];
890892 predict(
891893 &reference,
892894 width,