forge
Explore
Log in

Don't you dare go Hollow

Bypass sub-pel filtering for whole-pel motion prediction

Browse files at this commit

ef383d94d4cfd6950441c03eef89ed5fa6d57048Ahmet Kaan GümüşParent: f44b458
  • perf
    • bypass sub-pel filtering for whole-pel motion prediction
Show full message
perf(av1): bypass sub-pel filtering for whole-pel motion prediction

Profiled the inter path (stage_timing_breakdown_inter, 720p GOP): 403 of a
408ms motion-search bucket was crate::mc::predict, almost entirely from the
search's own whole-pel log/diamond stage. SUBPEL_FILTERS[0] is the identity
tap and both rounding shifts are exactly that filter's gain, so the two
8-tap passes reproduce the reference sample byte-for-byte at zero fraction
(integer_mv_is_identity already pinned this) -- a clamped direct copy is
bit-identical, not an approximation. Motion search bucket 408.55ms ->
181.85ms, frame total 818.88ms -> 585.24ms, same 997 output bytes.
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