forge
Explore
Log in

Don't you dare go Hollow

4-tap subpel filters for blocks 4 wide or tall

Browse files at this commit

aad8b594d36d41560a4eaa03ecd4a51c076ec871Ahmet Kaan GümüşParent: fd61351
  • fix
    • 4-tap subpel filters for blocks 4 wide or tall
Show full message
fix(av1): 4-tap subpel filters for blocks 4 wide or tall

Spec 7.11.3.4 selects the filter table per axis: an output dimension of 4
or less reads Subpel_Filters' narrow counterpart (av1_sub_pel_filters_4),
whose outer two taps on each side are zero. We fed every block the 8-tap
table, so 4:2:0 chroma under an 8x8 luma leaf -- the common chroma shape,
not a corner -- reached 3 samples past its edge with nonzero weights and
came out +-1 against the reference decoder wherever the extra taps
mattered. Found by diffing libaom's dec_calc_subpel_params against ours:
the phase matched, the tap table did not.

Closes the 640x360 inter straddle sequence's frame-2 U-plane desync; the
whole sequence now round-trips through ffmpeg pixel-exact.
crates/ec-av1/src/mc.rsmodified+29 -2
@@ -52,6 +52,33 @@ const SUBPEL_FILTERS: [[i32; 8]; 16] = [
5252 [0, 0, -2, 8, 126, -6, 2, 0],
5353 ];
5454
55+/// `Subpel_Filters[EIGHTTAP]`'s narrow-block counterpart (spec 7.11.3.4's
56+/// filter selection is per-axis: a `predict` axis whose output block
57+/// dimension is 4 or less reads this table instead of [`SUBPEL_FILTERS`]),
58+/// mirroring `av1_sub_pel_filters_4` (`filter.h`): the same 8-slot shape but
59+/// zeroed at taps 0/1/6/7, so a 4-wide (or 4-tall) block's filter never
60+/// reaches a full 3 samples past its own edge. Every 4:2:0 chroma block
61+/// under an 8x8 (or smaller) luma leaf hits this on at least one axis --
62+/// this is not an edge case, it is the common chroma shape.
63+const SUBPEL_FILTERS_4: [[i32; 8]; 16] = [
64+ [0, 0, 0, 128, 0, 0, 0, 0],
65+ [0, 0, -4, 126, 8, -2, 0, 0],
66+ [0, 0, -8, 122, 18, -4, 0, 0],
67+ [0, 0, -10, 116, 28, -6, 0, 0],
68+ [0, 0, -12, 110, 38, -8, 0, 0],
69+ [0, 0, -12, 102, 48, -10, 0, 0],
70+ [0, 0, -14, 94, 58, -10, 0, 0],
71+ [0, 0, -12, 84, 66, -10, 0, 0],
72+ [0, 0, -12, 76, 76, -12, 0, 0],
73+ [0, 0, -10, 66, 84, -12, 0, 0],
74+ [0, 0, -10, 58, 94, -14, 0, 0],
75+ [0, 0, -10, 48, 102, -12, 0, 0],
76+ [0, 0, -8, 38, 110, -12, 0, 0],
77+ [0, 0, -6, 28, 116, -10, 0, 0],
78+ [0, 0, -4, 18, 122, -8, 0, 0],
79+ [0, 0, -2, 8, 126, -4, 0, 0],
80+];
81+
5582 /// A reference sample at `(x, y)`, clamped to the frame's true (unpadded)
5683 /// extent -- `true_width`/`true_height`, which can be narrower than
5784 /// `stride` -- rather than read out of range (spec 7.11.3.4's `Clip3`
@@ -137,8 +164,8 @@ pub fn predict(
137164 return;
138165 }
139166
140- let h_filter = &SUBPEL_FILTERS[xfrac];
141- let v_filter = &SUBPEL_FILTERS[yfrac];
167+ let h_filter = if block_w <= 4 { &SUBPEL_FILTERS_4[xfrac] } else { &SUBPEL_FILTERS[xfrac] };
168+ let v_filter = if block_h <= 4 { &SUBPEL_FILTERS_4[yfrac] } else { &SUBPEL_FILTERS[yfrac] };
142169
143170 // The vertical pass reads 3 rows above and 4 below the block, so the
144171 // horizontal pass must produce that many extra intermediate rows.