Merge branch 'lane-av1-msearch': whole-pel fast path in mc::predict
Browse files at this commit1 changed file +26 -0
- crates/ec-av1/src/mc.rs +26 -0
crates/ec-av1/src/mc.rsmodified+26 -0
| @@ -111,6 +111,32 @@ pub fn predict( | |||
| 111 | let y0 = y_q4.div_euclid(16); | 111 | let y0 = y_q4.div_euclid(16); |
| 112 | let yfrac = y_q4.rem_euclid(16) as usize; | 112 | let yfrac = y_q4.rem_euclid(16) as usize; |
| 113 | 113 | ||
| 114 | + // Whole-pel fast path: `SUBPEL_FILTERS[0]` is the identity tap (`128` at | ||
| 115 | + // its centre, everything else `0`), and both rounding shifts are exactly | ||
| 116 | + // that filter's own gain (see `INTER_ROUND_1`'s doc comment), so the two | ||
| 117 | + // 8-tap passes reproduce the reference sample byte-for-byte here -- | ||
| 118 | + // `integer_mv_is_identity` below pins that. Skipping straight to a | ||
| 119 | + // clamped copy is bit-identical, not an approximation: it matters | ||
| 120 | + // because the motion search's own log/diamond stage (`motion.rs`) is | ||
| 121 | + // whole-pel-only and calls `predict` for every candidate it prices, so | ||
| 122 | + // this path is what most of a search's `predict` calls actually hit | ||
| 123 | + // (measured: `stage_timing_breakdown_inter` attributed 403 of a 720p | ||
| 124 | + // inter frame's 408ms motion-search bucket to `predict`, almost all of | ||
| 125 | + // it whole-pel candidates from stage 1). | ||
| 126 | + if xfrac == 0 && yfrac == 0 { | ||
| 127 | + for row in 0..block_h { | ||
| 128 | + let y = y0 + row as i32; | ||
| 129 | + for col in 0..block_w { | ||
| 130 | + let x = x0 + col as i32; | ||
| 131 | + dst[row * block_w + col] = | ||
| 132 | + sample(reference, stride, true_width, true_height, x, y) as u8; | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + #[cfg(test)] | ||
| 136 | + crate::encode::stage_add(1, stage_t.elapsed()); | ||
| 137 | + return; | ||
| 138 | + } | ||
| 139 | + | ||
| 114 | let h_filter = &SUBPEL_FILTERS[xfrac]; | 140 | let h_filter = &SUBPEL_FILTERS[xfrac]; |
| 115 | let v_filter = &SUBPEL_FILTERS[yfrac]; | 141 | let v_filter = &SUBPEL_FILTERS[yfrac]; |
| 116 | 142 | ||