forge
Explore
Log in

Don't you dare go Hollow

A deferred transform unit takes its window on the worker, not a strided residual

Browse files at this commit

3d6af60965840fa9620794ed5f5139f40c564afaAhmet Kaan GümüşParent: 52da7db
  • perf
    • a deferred transform unit takes its window on the worker, not a strided residual
Show full message
perf(av1): a deferred transform unit takes its window on the worker, not a strided residual

lane-wave4: recording a unit's prediction as an offset into the block made
the worker lay its residual out at the block's stride again (a 4x4 unit of a
64-wide block meant a 64x64 i32 grid). The residual stays dense and the
worker copies the w x h window out of the block prediction instead -- the
copy the parsing thread used to make. Byte-exact, wall unchanged.
crates/ec-av1/src/decode.rsmodified+27 -9
@@ -2162,7 +2162,11 @@ impl<'a> Pred<'a> {
2162 /// [`Pred`], resolved into what a recorded op carries.2162 /// [`Pred`], resolved into what a recorded op carries.
2163 pub(crate) enum PredSrc {2163 pub(crate) enum PredSrc {
2164 Owned(Vec<u16>),2164 Owned(Vec<u16>),
2165- Cur { plane: usize, off: usize },2165+ /// A window of the block prediction: its plane, its offset, and the
2166+ /// stride it is read at -- which is the block's, not necessarily the
2167+ /// op's (a transform unit's residual stays dense, so the worker takes
2168+ /// its window out of the block prediction itself).
2169+ Cur { plane: usize, off: usize, src: usize },
2166 }2170 }
2167 2171
2168 /// One block's whole-block prediction build, deferred to a recon worker.2172 /// One block's whole-block prediction build, deferred to a recon worker.
@@ -2639,7 +2643,8 @@ fn push_mc_rect_owned(
2639 None => {2643 None => {
2640 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };2644 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2641 push_op(fctx, ReconOp::Mc {2645 push_op(fctx, ReconOp::Mc {
2642- plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },2646+ plane, x, y, stride: ss, w, h,
2647+ prediction: PredSrc::Cur { plane: sp, off, src: ss },
2643 residual: Residual::Done(residual),2648 residual: Residual::Done(residual),
2644 });2649 });
2645 return;2650 return;
@@ -2712,7 +2717,8 @@ fn push_mc_rect(
2712 None => {2717 None => {
2713 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };2718 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2714 push_op(fctx, ReconOp::Mc {2719 push_op(fctx, ReconOp::Mc {
2715- plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },2720+ plane, x, y, stride: ss, w, h,
2721+ prediction: PredSrc::Cur { plane: sp, off, src: ss },
2716 residual: Residual::Done(residual.to_vec()),2722 residual: Residual::Done(residual.to_vec()),
2717 });2723 });
2718 return;2724 return;
@@ -2785,9 +2791,10 @@ fn push_mc_rect_tx(
2785 None => {2791 None => {
2786 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };2792 let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2787 let mut tx = tx;2793 let mut tx = tx;
2788- tx.stride = ss;2794+ tx.stride = 0;
2789 push_op(fctx, ReconOp::Mc {2795 push_op(fctx, ReconOp::Mc {
2790- plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },2796+ plane, x, y, stride: w, w, h,
2797+ prediction: PredSrc::Cur { plane: sp, off, src: ss },
2791 residual: Residual::Coeffs(tx, grid.to_vec()),2798 residual: Residual::Coeffs(tx, grid.to_vec()),
2792 });2799 });
2793 return;2800 return;
@@ -2884,10 +2891,21 @@ fn exec_op(
2884 PredSrc::Owned(p) => {2891 PredSrc::Owned(p) => {
2885 exec_mc(y, u, v, plane, x, oy, stride, w, h, &p, &residual, fctx);2892 exec_mc(y, u, v, plane, x, oy, stride, w, h, &p, &residual, fctx);
2886 }2893 }
2887- PredSrc::Cur { plane: sp, off } => {2894+ PredSrc::Cur { plane: sp, off, src } => {
2888- let src = std::mem::take(&mut cur[sp]);2895+ let block = std::mem::take(&mut cur[sp]);
2889- exec_mc(y, u, v, plane, x, oy, stride, w, h, &src[off..], &residual, fctx);2896+ if src == stride {
2890- cur[sp] = src;2897+ exec_mc(y, u, v, plane, x, oy, stride, w, h, &block[off..], &residual, fctx);
2898+ } else {
2899+ // A transform unit's residual is dense, so its window
2900+ // of the block prediction is taken out dense too --
2901+ // the copy the parsing thread used to make, made here.
2902+ let mut window = Vec::with_capacity(w * h);
2903+ for row in 0..h {
2904+ window.extend_from_slice(&block[off + row * src..][..w]);
2905+ }
2906+ exec_mc(y, u, v, plane, x, oy, stride, w, h, &window, &residual, fctx);
2907+ }
2908+ cur[sp] = block;
2891 }2909 }
2892 }2910 }
2893 }2911 }