4-tap subpel filters for blocks 4 wide or tall
Browse files at this commitaad8b594d36d41560a4eaa03ecd4a51c076ec871Parent: fd61351- fix
- 4-tap subpel filters for blocks 4 wide or tall
1 changed file +29 -2
- crates/ec-av1/src/mc.rs +29 -2
crates/ec-av1/src/mc.rsmodified+29 -2
| @@ -52,6 +52,33 @@ const SUBPEL_FILTERS: [[i32; 8]; 16] = [ | |||
| 52 | [0, 0, -2, 8, 126, -6, 2, 0], | 52 | [0, 0, -2, 8, 126, -6, 2, 0], |
| 53 | ]; | 53 | ]; |
| 54 | 54 | ||
| 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 | + | ||
| 55 | /// A reference sample at `(x, y)`, clamped to the frame's true (unpadded) | 82 | /// A reference sample at `(x, y)`, clamped to the frame's true (unpadded) |
| 56 | /// extent -- `true_width`/`true_height`, which can be narrower than | 83 | /// extent -- `true_width`/`true_height`, which can be narrower than |
| 57 | /// `stride` -- rather than read out of range (spec 7.11.3.4's `Clip3` | 84 | /// `stride` -- rather than read out of range (spec 7.11.3.4's `Clip3` |
| @@ -137,8 +164,8 @@ pub fn predict( | |||
| 137 | return; | 164 | return; |
| 138 | } | 165 | } |
| 139 | 166 | ||
| 140 | - let h_filter = &SUBPEL_FILTERS[xfrac]; | 167 | + let h_filter = if block_w <= 4 { &SUBPEL_FILTERS_4[xfrac] } else { &SUBPEL_FILTERS[xfrac] }; |
| 141 | - let v_filter = &SUBPEL_FILTERS[yfrac]; | 168 | + let v_filter = if block_h <= 4 { &SUBPEL_FILTERS_4[yfrac] } else { &SUBPEL_FILTERS[yfrac] }; |
| 142 | 169 | ||
| 143 | // The vertical pass reads 3 rows above and 4 below the block, so the | 170 | // The vertical pass reads 3 rows above and 4 below the block, so the |
| 144 | // horizontal pass must produce that many extra intermediate rows. | 171 | // horizontal pass must produce that many extra intermediate rows. |