forge
Explore
Log in

Don't you dare go Hollow

An all-zero inter residual reconstructs as a prediction copy

Browse files at this commit

c5b674a94b8b3a1684d2cd0d052ed8c96cf53a2dAhmet Kaan GümüşParent: ba6ddd4
  • perf
    • an all-zero inter residual reconstructs as a prediction copy
Show full message
perf(av1): an all-zero inter residual reconstructs as a prediction copy

`reconstruct_mc_rect` expanded the empty all-zero marker into a `side * h`
slice of the 64 KB `ZERO_RESIDUAL` static and added those zeros sample by
sample -- for 60% of the units. The zero case now runs the same clamp
without the residual operand (identical arithmetic at `r == 0`; the
prediction->plane copy the charter names is kept).

instructions:u on the 4K segment: 453.00 G -> 450.45 G at (16, 4, 2)
threads, 444.33 G -> 441.90 G at one thread.
crates/ec-av1/src/decode.rsmodified+15 -0
@@ -22226,6 +22226,21 @@ impl PlaneBuf<'_> {
2222622226 // three row bases are computed once per row instead of a
2222722227 // multiply-add per sample (the samples themselves are unchanged).
2222822228 let max = crate::decode::sample_max(fctx);
22229+ // lane-recoparse: an all-zero residual (60% of the units) is a plain
22230+ // prediction copy -- the same arithmetic with `r == 0`, without
22231+ // reading `side * h` zeros out of [`ZERO_RESIDUAL`].
22232+ if residual.is_empty() {
22233+ for row in 0..h {
22234+ let src = row * side;
22235+ let dst = (y + row) * self.width + x;
22236+ let pred = &prediction[src..src + w];
22237+ let out = &mut self.data.to_mut()[dst..dst + w];
22238+ for (o, &p) in out.iter_mut().zip(pred) {
22239+ *o = i32::from(p).clamp(0, max) as u16;
22240+ }
22241+ }
22242+ return;
22243+ }
2222922244 let residual = dense_residual(residual, side * h);
2223022245 for row in 0..h {
2223122246 let src = row * side;