forge
Explore
Log in

Don't you dare go Hollow

Inter reconstruction adds a row at a time

Browse files at this commit

180e07916e8cae5a55842335c3742db2bdc45d30Ahmet Kaan GümüşParent: 8567ed5
  • perf
    • inter reconstruction adds a row at a time
Show full message
perf(av1): inter reconstruction adds a row at a time

`PlaneBuf::reconstruct_mc_rect` re-derived `row * side + col` twice and
`(y + row) * self.width + x + col` once per sample, with a bounds check
on each of the three buffers. `side` is the prediction/residual stride
and `self.width` the plane's, so the three row bases are now taken once
per row and the row slices zipped; the arithmetic on each sample
(`clamp(0, sample_max())`) is untouched, as is the bottom/right overhang
truncation above it.

Byte-exact: EC_PROBE_OUT16 sha256 unchanged on a 1080p and a 4K segment
and on `palette_screen_witness.obu`. Interleaved medians against the
parent build alone (3 pairs, 1080p): 11.17 s -> 11.06 s.
crates/ec-av1/src/decode.rsmodified+12 -4
@@ -19223,11 +19223,19 @@ impl PlaneBuf {
19223 // 768..832). libaom reconstructs those rows into the frame buffer's19223 // 768..832). libaom reconstructs those rows into the frame buffer's
19224 // border; nothing reads them back, so they are simply dropped here.19224 // border; nothing reads them back, so they are simply dropped here.
19225 let (h, w) = (h.min(self.height.saturating_sub(y)), w.min(self.width.saturating_sub(x)));19225 let (h, w) = (h.min(self.height.saturating_sub(y)), w.min(self.width.saturating_sub(x)));
19226+ // lane-perf4: one row of each operand at a time. `side` is the
19227+ // prediction/residual stride and `self.width` the plane's, so the
19228+ // three row bases are computed once per row instead of a
19229+ // multiply-add per sample (the samples themselves are unchanged).
19230+ let max = crate::decode::sample_max();
19226 for row in 0..h {19231 for row in 0..h {
19227- for col in 0..w {19232+ let src = row * side;
19228- let sample = (i32::from(prediction[row * side + col]) + residual[row * side + col])19233+ let dst = (y + row) * self.width + x;
19229- .clamp(0, crate::decode::sample_max()) as u16;19234+ let pred = &prediction[src..src + w];
19230- self.data[(y + row) * self.width + x + col] = sample;19235+ let res = &residual[src..src + w];
19236+ let out = &mut self.data[dst..dst + w];
19237+ for ((o, &p), &r) in out.iter_mut().zip(pred).zip(res) {
19238+ *o = (i32::from(p) + r).clamp(0, max) as u16;
19231 }19239 }
19232 }19240 }
19233 }19241 }