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 {
12838 let data = enc.finish();12838 let data = enc.finish();
12839 12839
12840 let (width, height) = (64usize, 64usize);12840 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();
12842 let ref_plane = |scale: usize| PlaneBuf {12842 let ref_plane = |scale: usize| PlaneBuf {
12843 data: ref_pattern12843 data: ref_pattern
12844 .iter()12844 .iter()
@@ -12881,7 +12881,7 @@ mod tests {
12881 tile_y1: height,12881 tile_y1: height,
12882 };12882 };
12883 let mut u = PlaneBuf {12883 let mut u = PlaneBuf {
12884- data: vec![0u8; (width / 2) * (height / 2)],12884+ data: vec![0u16; (width / 2) * (height / 2)],
12885 width: width / 2,12885 width: width / 2,
12886 height: height / 2,12886 height: height / 2,
12887 true_width: width / 2,12887 true_width: width / 2,
@@ -12892,7 +12892,7 @@ mod tests {
12892 tile_y1: height / 2,12892 tile_y1: height / 2,
12893 };12893 };
12894 let mut v = PlaneBuf {12894 let mut v = PlaneBuf {
12895- data: vec![0u8; (width / 2) * (height / 2)],12895+ data: vec![0u16; (width / 2) * (height / 2)],
12896 width: width / 2,12896 width: width / 2,
12897 height: height / 2,12897 height: height / 2,
12898 true_width: width / 2,12898 true_width: width / 2,
@@ -12957,7 +12957,7 @@ mod tests {
12957 .unwrap();12957 .unwrap();
12958 12958
12959 let (px, py) = (c * SUB, r * SUB);12959 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];
12961 crate::mc::predict(12961 crate::mc::predict(
12962 &ref_y.data,12962 &ref_y.data,
12963 ref_y.width,12963 ref_y.width,
@@ -12969,7 +12969,7 @@ mod tests {
12969 side,12969 side,
12970 &mut want_near,12970 &mut want_near,
12971 );12971 );
12972- let mut want_nearest = vec![0u8; side * side];12972+ let mut want_nearest = vec![0u16; side * side];
12973 crate::mc::predict(12973 crate::mc::predict(
12974 &ref_y.data,12974 &ref_y.data,
12975 ref_y.width,12975 ref_y.width,
@@ -12986,7 +12986,7 @@ mod tests {
12986 "test setup: the two candidate MVs must predict differently"12986 "test setup: the two candidate MVs must predict differently"
12987 );12987 );
12988 12988
12989- let mut got = vec![0u8; side * side];12989+ let mut got = vec![0u16; side * side];
12990 for row in 0..side {12990 for row in 0..side {
12991 got[row * side..(row + 1) * side].copy_from_slice(12991 got[row * side..(row + 1) * side].copy_from_slice(
12992 &y.data[(py + row) * y.width + px..(py + row) * y.width + px + side],12992 &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(
600 /// off-by-one from double rounding.600 /// off-by-one from double rounding.
601 #[test]601 #[test]
602 fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {602 fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {
603- let reference = vec![100u8; 16 * 16];603+ let reference = vec![100u16; 16 * 16];
604 let mut pred0 = vec![0i32; 16];604 let mut pred0 = vec![0i32; 16];
605 predict_compound_intermediate(605 predict_compound_intermediate(
606 &reference,606 &reference,
@@ -618,7 +618,7 @@ fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {
618 assert!(pred0.iter().all(|&v| v == 1600), "{pred0:?}");618 assert!(pred0.iter().all(|&v| v == 1600), "{pred0:?}");
619 619
620 let pred1 = pred0.clone();620 let pred1 = pred0.clone();
621- let mut dst = vec![0u8; 16];621+ let mut dst = vec![0u16; 16];
622 combine_compound(&pred0, &pred1, 8, 8, &mut dst);622 combine_compound(&pred0, &pred1, 8, 8, &mut dst);
623 assert!(dst.iter().all(|&v| v == 100), "{dst:?}");623 assert!(dst.iter().all(|&v| v == 100), "{dst:?}");
624 }624 }
@@ -670,9 +670,11 @@ mod tests {
670 // real (0, 0) coordinates -- clamping then reproduces the identical670 // real (0, 0) coordinates -- clamping then reproduces the identical
671 // extended border the dump already captured.671 // extended border the dump already captured.
672 let stride = 24;672 let stride = 24;
673- let mut reference = vec![0u8; stride * 24];673+ let mut reference = vec![0u16; stride * 24];
674 for (r, row) in window.iter().enumerate() {674 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+ }
676 }678 }
677 // predict()'s own edge clamp starts at true (0,0); shift so the679 // predict()'s own edge clamp starts at true (0,0); shift so the
678 // dumped window's row/col 4 lands there by biasing x_q4/y_q4's680 // dumped window's row/col 4 lands there by biasing x_q4/y_q4's
@@ -682,7 +684,7 @@ mod tests {
682 // whole-pel part of x_q4/y_q4 by +4 to land on real (0,0).684 // whole-pel part of x_q4/y_q4 by +4 to land on real (0,0).
683 let x_q4 = (4 + 0) * 16 + 15; // real block x0=0, xfrac=15685 let x_q4 = (4 + 0) * 16 + 15; // real block x0=0, xfrac=15
684 let y_q4 = (4 + 0) * 16 + 7; // real block y0=0, yfrac=7686 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];
686 predict_with_filter(688 predict_with_filter(
687 &reference,689 &reference,
688 stride,690 stride,
@@ -696,7 +698,7 @@ mod tests {
696 &mut dst,698 &mut dst,
697 );699 );
698 #[rustfmt::skip]700 #[rustfmt::skip]
699- let expected_row0: [u8; 16] =701+ let expected_row0: [u16; 16] =
700 [114,114,114,114,115,115,115,116,116,116,116,116,117,117,116,116];702 [114,114,114,114,115,115,115,116,116,116,116,116,117,117,116,116];
701 assert_eq!(703 assert_eq!(
702 &dst[0..16],704 &dst[0..16],
@@ -704,7 +706,7 @@ mod tests {
704 "row0 vs aomdec's real av1_convolve_2d_sr_c output"706 "row0 vs aomdec's real av1_convolve_2d_sr_c output"
705 );707 );
706 #[rustfmt::skip]708 #[rustfmt::skip]
707- let expected_row15: [u8; 16] =709+ let expected_row15: [u16; 16] =
708 [103,103,104,104,104,105,105,106,106,106,107,107,107,107,107,107];710 [103,103,104,104,104,105,105,106,106,106,107,107,107,107,107,107];
709 assert_eq!(711 assert_eq!(
710 &dst[15 * 16..15 * 16 + 16],712 &dst[15 * 16..15 * 16 + 16],
@@ -717,8 +719,8 @@ mod tests {
717 fn integer_mv_is_identity() {719 fn integer_mv_is_identity() {
718 let width = 12;720 let width = 12;
719 let height = 12;721 let height = 12;
720- let reference: Vec<u8> = (0..width * height).map(|i| (i * 7 % 251) as u8).collect();722+ let reference: Vec<u16> = (0..width * height).map(|i| (i * 7 % 251) as u16).collect();
721- let mut dst = vec![0u8; 6 * 6];723+ let mut dst = vec![0u16; 6 * 6];
722 predict(724 predict(
723 &reference,725 &reference,
724 width,726 width,
@@ -746,10 +748,10 @@ mod tests {
746 // Step 2 so every half-pel position lands on an exact integer.748 // Step 2 so every half-pel position lands on an exact integer.
747 let width = 16;749 let width = 16;
748 let height = 16;750 let height = 16;
749- let reference: Vec<u8> = (0..width * height)751+ let reference: Vec<u16> = (0..width * height)
750- .map(|i| (2 * (i % width)) as u8)752+ .map(|i| (2 * (i % width)) as u16)
751 .collect();753 .collect();
752- let mut dst = vec![0u8; 4 * 4];754+ let mut dst = vec![0u16; 4 * 4];
753 // Half-pel in x only: fraction 8/16, integer part at column 5.755 // Half-pel in x only: fraction 8/16, integer part at column 5.
754 predict(756 predict(
755 &reference,757 &reference,
@@ -778,10 +780,10 @@ mod tests {
778 fn constant_plane_has_unit_dc_gain_at_every_subpel_position() {780 fn constant_plane_has_unit_dc_gain_at_every_subpel_position() {
779 let width = 20;781 let width = 20;
780 let height = 20;782 let height = 20;
781- let reference = vec![142u8; width * height];783+ let reference = vec![142u16; width * height];
782 for yfrac in 0..16 {784 for yfrac in 0..16 {
783 for xfrac in 0..16 {785 for xfrac in 0..16 {
784- let mut dst = vec![0u8; 5 * 5];786+ let mut dst = vec![0u16; 5 * 5];
785 predict(787 predict(
786 &reference,788 &reference,
787 width,789 width,
@@ -810,11 +812,11 @@ mod tests {
810 // it happened to produce two merely-different numbers.812 // it happened to produce two merely-different numbers.
811 let width = 10;813 let width = 10;
812 let height = 10;814 let height = 10;
813- let reference: Vec<u8> = (0..height)815+ let reference: Vec<u16> = (0..height)
814- .flat_map(|y| (0..width).map(move |x| (20 * x + 4 * y) as u8))816+ .flat_map(|y| (0..width).map(move |x| (20 * x + 4 * y) as u16))
815 .collect();817 .collect();
816 818
817- let mut horiz = vec![0u8; 4 * 4];819+ let mut horiz = vec![0u16; 4 * 4];
818 predict(820 predict(
819 &reference,821 &reference,
820 width,822 width,
@@ -826,7 +828,7 @@ mod tests {
826 4,828 4,
827 &mut horiz,829 &mut horiz,
828 );830 );
829- let mut vert = vec![0u8; 4 * 4];831+ let mut vert = vec![0u16; 4 * 4];
830 predict(832 predict(
831 &reference,833 &reference,
832 width,834 width,
@@ -865,8 +867,8 @@ mod tests {
865 fn mv_past_the_edge_clamps_instead_of_panicking() {867 fn mv_past_the_edge_clamps_instead_of_panicking() {
866 let width = 8;868 let width = 8;
867 let height = 8;869 let height = 8;
868- let reference: Vec<u8> = (0..width * height).map(|i| (i * 3 % 200) as u8).collect();870+ let reference: Vec<u16> = (0..width * height).map(|i| (i * 3 % 200) as u16).collect();
869- let mut dst = vec![0u8; 4 * 4];871+ let mut dst = vec![0u16; 4 * 4];
870 // Whole-sample position far above and to the left of the plane, with872 // Whole-sample position far above and to the left of the plane, with
871 // an odd fraction so both filter passes exercise the clamp.873 // an odd fraction so both filter passes exercise the clamp.
872 predict(874 predict(
@@ -886,7 +888,7 @@ mod tests {
886 "an MV past the top-left edge must clamp to the corner sample, got {dst:?}"888 "an MV past the top-left edge must clamp to the corner sample, got {dst:?}"
887 );889 );
888 890
889- let mut dst2 = vec![0u8; 4 * 4];891+ let mut dst2 = vec![0u16; 4 * 4];
890 predict(892 predict(
891 &reference,893 &reference,
892 width,894 width,