vp9kf: filter the luma internal-4x4 H edge on the frame's last MI row
Browse files at this commita050448e1fca7d1815f4d560c2bec6af411e6b8aParent: 07af9df2 changed files +85 -7
- crates/ec-vp9/src/loopfilter.rs +59 -7
- lanes/vp9kf.report.md +26 -0
crates/ec-vp9/src/loopfilter.rsmodified+59 -7
| @@ -614,13 +614,13 @@ impl LfGrids { | ||
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | - // Internal 4x4 UV edge at yy + 4 (skipped on the | |
| 618 | - // frame's last MI row: `skip_border_4x4_r`). | |
| 619 | - if int4 & bit != 0 | |
| 620 | - && sbr + row != self.mi_rows - 1 | |
| 621 | - && yy + 8 <= y_h | |
| 622 | - && xx + 8 <= y_w | |
| 623 | - { | |
| 617 | + // Internal 4x4 luma edge at yy + 4. libvpx's luma | |
| 618 | + // path has NO last-row skip: `vp9_filter_block_plane_ | |
| 619 | + // ss00` passes `lfm->int_4x4_y & 0xff` for every MI row | |
| 620 | + // (vp9_loopfilter.c:1286-1311). `skip_border_4x4_r` | |
| 621 | + // exists only in the 4:2:0-chroma path (ss11, | |
| 622 | + // vp9_loopfilter.c:1382) and in non420 under `ss_y`. | |
| 623 | + if int4 & bit != 0 && yy + 8 <= y_h && xx + 8 <= y_w { | |
| 624 | 624 | lpf_edge(y, (yy + 4) * stride + xx, stride, 0, 4, bl, li, th, 8); |
| 625 | 625 | if std::env::var_os("LFTRACE").is_some() { |
| 626 | 626 | eprintln!("H4I {} {}", xx, yy + 4); |
| @@ -852,3 +852,55 @@ impl LfGrids { | ||
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | } |
| 855 | + | |
| 856 | +#[cfg(test)] | |
| 857 | +mod tests { | |
| 858 | + use super::*; | |
| 859 | + use crate::tables::TX_4X4; | |
| 860 | + | |
| 861 | + /// One 64x64 frame (8x8 MI) where every cell is a BLOCK_4X4 at `level`. | |
| 862 | + fn grid(level: u8) -> LfGrids { | |
| 863 | + let (mi_cols, mi_rows) = (8usize, 8usize); | |
| 864 | + LfGrids { | |
| 865 | + level8: vec![level; mi_cols * mi_rows], | |
| 866 | + blk: vec![(0u8, 0, 0); mi_cols * mi_rows], // 0 == BLOCK_4X4 | |
| 867 | + otx: vec![TX_4X4 as u8; mi_cols * mi_rows], | |
| 868 | + mi_cols, | |
| 869 | + mi_rows, | |
| 870 | + } | |
| 871 | + } | |
| 872 | + | |
| 873 | + fn run(g: &LfGrids, y: &mut [u8]) { | |
| 874 | + let mut u = vec![128u8; 32 * 32]; | |
| 875 | + let mut v = vec![128u8; 32 * 32]; | |
| 876 | + g.filter_frame(y, 64, &mut u, &mut v, 32, 64, 64, 32, 32, 0); | |
| 877 | + } | |
| 878 | + | |
| 879 | + /// The luma internal-4x4 horizontal edge fires on the frame's LAST MI row. | |
| 880 | + /// | |
| 881 | + /// `vp9_filter_block_plane_ss00` passes `lfm->int_4x4_y & 0xff` for every | |
| 882 | + /// MI row (vp9_loopfilter.c:1286-1311) - there is no last-row skip in the | |
| 883 | + /// luma path. `skip_border_4x4_r` exists only for 4:2:0 chroma in | |
| 884 | + /// `vp9_filter_block_plane_ss11` (:1382) and in non420 under `ss_y`. | |
| 885 | + /// | |
| 886 | + /// Last MI row here is 56, so the internal edge sits at row 60 with taps | |
| 887 | + /// p1,p0 = rows 58,59 (100) and q0,q1 = rows 60,61 (150): q0 moves. | |
| 888 | + #[test] | |
| 889 | + fn luma_int4_h_edge_is_filtered_on_the_last_mi_row() { | |
| 890 | + let g = grid(8); | |
| 891 | + let stride = 64; | |
| 892 | + // A gentle step (4) between rows 59 and 60: sharp steps fail the | |
| 893 | + // filter_mask gradient test, and a flat pattern cannot move. | |
| 894 | + let mut y = vec![100u8; 64 * 64]; | |
| 895 | + for row in 60..64 { | |
| 896 | + y[row * stride..row * stride + 64].fill(104); | |
| 897 | + } | |
| 898 | + let before = y.clone(); | |
| 899 | + run(&g, &mut y); | |
| 900 | + assert!( | |
| 901 | + (60..62).any(|r| (0..64).any(|c| y[r * stride + c] != before[r * stride + c])), | |
| 902 | + "the internal 4x4 H edge on the last MI row (row 60) was not filtered" | |
| 903 | + ); | |
| 904 | + } | |
| 905 | +} | |
| 906 | + |
lanes/vp9kf.report.mdmodified+26 -0
| @@ -510,3 +510,29 @@ is wrong for >1 tile; "corrupt" is the wrong claim until that is known. | ||
| 510 | 510 | fixture, otherwise "byte-exact" keeps meaning "testsrc2-exact". |
| 511 | 511 | |
| 512 | 512 | `scratch_tiledbg.rs` (header/tile-offset dump) is the companion probe. |
| 513 | + | |
| 514 | +## REVIEWER FINDING CLOSED (2026-09-16) — luma last-row 4x4-int edge | |
| 515 | + | |
| 516 | +An independent reviewer (panel seat, diff `29f35b77..f86ef080`) returned PASS on all five | |
| 517 | +claims (iadst16 vs `inv_txfm.c:520-554` incl. the WRAPLOW casts; all eight mask tables | |
| 518 | +value-for-value vs `vp9_loopfilter.c:39-205`; the `vp9_setup_mask` walk case-for-case; the | |
| 519 | +V-before-H pass order; the tile-bounds test) and found ONE real port error: | |
| 520 | + | |
| 521 | +**The luma internal-4x4 horizontal edge was skipped on the frame's last MI row.** The port | |
| 522 | +gated it on `sbr + row != self.mi_rows - 1` (and mislabelled it "UV edge"), but | |
| 523 | +`skip_border_4x4_r` exists only in the 4:2:0-chroma path (`vp9_filter_block_plane_ss11`, | |
| 524 | +vp9_loopfilter.c:1382) and in non420 under `ss_y`; `vp9_filter_block_plane_ss00` passes | |
| 525 | +`lfm->int_4x4_y & 0xff` for every MI row (:1286-1311), and `vp9_adjust_mask`'s rows mask | |
| 526 | +deliberately keeps the last row's bits (:798-805). So real content loses one filtered edge | |
| 527 | +in the bottom 8 rows whenever the bottom MI row holds a 4x4-tx cell - which neither | |
| 528 | +fixture has (LFTRACE: the fixtures' last int4 anchors are y=200/y=204; their last MI row is | |
| 529 | +232-239), so no existing gate could catch it. | |
| 530 | + | |
| 531 | +Fixed, with a witness that fails pre-fix: | |
| 532 | +`loopfilter::tests::luma_int4_h_edge_is_filtered_on_the_last_mi_row` builds a 64x64 grid of | |
| 533 | +BLOCK_4X4 cells at level 8, steps the plane by 4 at row 60 (a sharper step fails the | |
| 534 | +filter_mask gradient test and moves nothing), and asserts rows 60-61 changed. With the old | |
| 535 | +guard restored the test fails ("...was not filtered"); without it, it passes. lib tests | |
| 536 | +9/9; keyframe_exact still 4/4; the real-content sweep numbers are unchanged (that content | |
| 537 | +does not reach the shape). | |
| 538 | + |