forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-av1-msearch': whole-pel fast path in mc::predict

Browse files at this commit

a717fd8fbabe8049fdf17731bd9a511b8c6987faAhmet Kaan GümüşParent: f44b458ef383d9
Motion-search bucket 408.55ms->181.85ms, inter frame total 818.88ms->585.24ms
at 720p, bit-identical output (SUBPEL_FILTERS[0] is the exact identity kernel).
crates/ec-av1/src/mc.rsmodified+26 -0
@@ -111,6 +111,32 @@ pub fn predict(
111111 let y0 = y_q4.div_euclid(16);
112112 let yfrac = y_q4.rem_euclid(16) as usize;
113113
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+
114140 let h_filter = &SUBPEL_FILTERS[xfrac];
115141 let v_filter = &SUBPEL_FILTERS[yfrac];
116142