forge
Explore
Log in

Don't you dare go Hollow

A recorded inter write names where its prediction comes from

Browse files at this commit

8aa7db153f618b6c26409eee75368ba7ca71c195Ahmet Kaan GümüşParent: 11ef8ca
  • refactor
    • a recorded inter write names where its prediction comes from
Show full message
refactor(av1): a recorded inter write names where its prediction comes from

lane-wave4 step 1: `ReconOp::Mc` carries a `PredSrc` (an owned window, or
an offset into the block prediction a worker builds) and the inter readers
take a `Pred` instead of a slice, so a prediction can be deferred without
touching every call site again. No deferral yet: every site passes
`Pred::dense`, which is the same window copy as before.
crates/ec-av1/src/decode.rsmodified+231 -72
@@ -2112,7 +2112,117 @@ impl Residual {
2112 }2112 }
2113 }2113 }
2114 2114
2115+/// Where a recorded motion-compensated write reads its prediction from.
2116+///
2117+/// lane-wave4: a block's whole-block prediction (mc + warp + interintra) is
2118+/// the parse thread's single biggest reconstruction cost, so at
2119+/// `EC_AV1_RECON_THREADS > 1` it is not built at parse at all: the block
2120+/// pushes a [`ReconOp::Pred`] carrying the build as a closure, the worker
2121+/// runs it into its own three-plane slot, and every transform unit of that
2122+/// block then reads its window out of that slot ([`Pred::Cur`]).
2123+#[derive(Clone, Copy)]
2124+pub(crate) enum Pred<'a> {
2125+ /// A prediction the parse thread already built. `stride == 0` means "the
2126+ /// reader's own `stride` argument", which is every pre-lane-wave4 site.
2127+ Inline(&'a [u16], usize),
2128+ /// The current block's deferred prediction: plane, its stride, and this
2129+ /// unit's offset into it.
2130+ Cur { plane: usize, stride: usize, off: usize },
2131+}
2132+
2133+impl<'a> Pred<'a> {
2134+ fn dense(buf: &'a [u16]) -> Self {
2135+ Self::Inline(buf, 0)
2136+ }
2137+ /// The same prediction read at an explicit stride.
2138+ fn view(self, stride: usize) -> Self {
2139+ match self {
2140+ Self::Inline(b, _) => Self::Inline(b, stride),
2141+ Self::Cur { plane, off, .. } => Self::Cur { plane, stride, off },
2142+ }
2143+ }
2144+ /// The materialised buffer and the stride to read it at (`stride` is the
2145+ /// reader's own when this prediction was built dense); `None` for a
2146+ /// deferred prediction, which only a recorded op can carry.
2147+ fn inline(self, stride: usize) -> Option<(&'a [u16], usize)> {
2148+ match self {
2149+ Self::Inline(b, s) => Some((b, if s == 0 { stride } else { s })),
2150+ Self::Cur { .. } => None,
2151+ }
2152+ }
2153+ /// This prediction's window starting `n` samples in.
2154+ fn offset(self, n: usize) -> Self {
2155+ match self {
2156+ Self::Inline(b, s) => Self::Inline(&b[n..], s),
2157+ Self::Cur { plane, stride, off } => Self::Cur { plane, stride, off: off + n },
2158+ }
2159+ }
2160+}
2161+
2162+/// [`Pred`], resolved into what a recorded op carries.
2163+pub(crate) enum PredSrc {
2164+ Owned(Vec<u16>),
2165+ Cur { plane: usize, off: usize },
2166+}
2167+
2168+/// One block's whole-block prediction build, deferred to a recon worker.
2169+///
2170+/// The closure borrows the tile's reference pictures and its own frame-level
2171+/// tables; [`WaveGuard`] joins every worker before the tile decoder returns,
2172+/// so those borrows outlive it -- the [`ReconPlanes`] trade-off, stated once
2173+/// here for the closure's `'static`/`Send` laundering in [`push_pred`].
2174+pub(crate) struct PredBuild(
2175+ Box<
2176+ dyn FnOnce(
2177+ &mut PlaneBuf<'static>,
2178+ &mut PlaneBuf<'static>,
2179+ &mut PlaneBuf<'static>,
2180+ &crate::decode::FrameCtx,
2181+ ) -> [Vec<u16>; 3],
2182+ >,
2183+);
2184+
2185+// SAFETY: see [`PredBuild`] -- the captured borrows are read-only reference
2186+// pictures and frame tables, and the closure runs on exactly one worker.
2187+#[allow(unsafe_code)]
2188+unsafe impl Send for PredBuild {}
2189+
2190+/// `true` when this tile's writes are recorded for the wavefront instead of
2191+/// performed at the push site, i.e. when a prediction may be deferred.
2192+fn recon_deferred(fctx: &crate::decode::FrameCtx) -> bool {
2193+ fctx.recon_planes.with(std::cell::Cell::get).is_none()
2194+}
2195+
2196+/// Records one block's prediction build for the worker that reconstructs it.
2197+#[allow(unsafe_code)]
2198+fn push_pred<'a>(
2199+ fctx: &crate::decode::FrameCtx,
2200+ f: impl FnOnce(
2201+ &mut PlaneBuf<'static>,
2202+ &mut PlaneBuf<'static>,
2203+ &mut PlaneBuf<'static>,
2204+ &crate::decode::FrameCtx,
2205+ ) -> [Vec<u16>; 3]
2206+ + 'a,
2207+) {
2208+ type Built = [Vec<u16>; 3];
2209+ type Dyn<'x> = dyn FnOnce(
2210+ &mut PlaneBuf<'static>,
2211+ &mut PlaneBuf<'static>,
2212+ &mut PlaneBuf<'static>,
2213+ &crate::decode::FrameCtx,
2214+ ) -> Built
2215+ + 'x;
2216+ let boxed: Box<Dyn<'a>> = Box::new(f);
2217+ // SAFETY: see [`PredBuild`] -- every worker is joined by [`WaveGuard`]
2218+ // before the borrows the closure holds go out of scope.
2219+ let boxed: Box<Dyn<'static>> = unsafe { std::mem::transmute(boxed) };
2220+ push_op(fctx, ReconOp::Pred(PredBuild(boxed)));
2221+}
2222+
2115 pub(crate) enum ReconOp {2223 pub(crate) enum ReconOp {
2224+ /// lane-wave4: build this block's prediction into the worker's slot.
2225+ Pred(PredBuild),
2116 Intra {2226 Intra {
2117 plane: usize,2227 plane: usize,
2118 x: usize,2228 x: usize,
@@ -2141,7 +2251,7 @@ pub(crate) enum ReconOp {
2141 stride: usize,2251 stride: usize,
2142 w: usize,2252 w: usize,
2143 h: usize,2253 h: usize,
2144- prediction: Vec<u16>,2254+ prediction: PredSrc,
2145 residual: Residual,2255 residual: Residual,
2146 },2256 },
2147 }2257 }
@@ -2222,7 +2332,7 @@ fn push_op(fctx: &crate::decode::FrameCtx, op: ReconOp) {
2222 if let Some(ReconPlanes(y, u, v)) = fctx.recon_planes.with(std::cell::Cell::get) {2332 if let Some(ReconPlanes(y, u, v)) = fctx.recon_planes.with(std::cell::Cell::get) {
2223 // SAFETY: see [`ReconPlanes`] -- one thread, and the write is the one2333 // SAFETY: see [`ReconPlanes`] -- one thread, and the write is the one
2224 // the parse site would have performed itself before lane-wave1.2334 // the parse site would have performed itself before lane-wave1.
2225- unsafe { exec_op(op, &mut *y, &mut *u, &mut *v, fctx) };2335+ unsafe { exec_op(op, &mut *y, &mut *u, &mut *v, &mut Default::default(), fctx) };
2226 return;2336 return;
2227 }2337 }
2228 fctx.recon_ops.with(|c| c.borrow_mut().push(op));2338 fctx.recon_ops.with(|c| c.borrow_mut().push(op));
@@ -2295,9 +2405,10 @@ fn wave_worker(st: &WaveState) {
2295 // SAFETY: this job writes only superblock (r, c)'s own pixels, and2405 // SAFETY: this job writes only superblock (r, c)'s own pixels, and
2296 // every superblock that could have written or be reading them is2406 // every superblock that could have written or be reading them is
2297 // complete by the wavefront rule above.2407 // complete by the wavefront rule above.
2408+ let mut cur: [Vec<u16>; 3] = Default::default();
2298 unsafe {2409 unsafe {
2299 for op in ops {2410 for op in ops {
2300- exec_op(op, &mut *y, &mut *u, &mut *v, &fctx);2411+ exec_op(op, &mut *y, &mut *u, &mut *v, &mut cur, &fctx);
2301 }2412 }
2302 }2413 }
2303 let mut q = st.q.lock().unwrap();2414 let mut q = st.q.lock().unwrap();
@@ -2520,14 +2631,25 @@ fn push_mc_rect_owned(
2520 stride: usize,2631 stride: usize,
2521 w: usize,2632 w: usize,
2522 h: usize,2633 h: usize,
2523- prediction: &[u16],2634+ prediction: Pred<'_>,
2524 residual: Vec<i32>, fctx: &crate::decode::FrameCtx,2635 residual: Vec<i32>, fctx: &crate::decode::FrameCtx,
2525 ) {2636 ) {
2526- if inline_mc(plane, x, y, stride, w, h, prediction, &residual, fctx) {2637+ let (src, stride) = match prediction.inline(stride) {
2638+ Some(v) => v,
2639+ None => {
2640+ let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2641+ push_op(fctx, ReconOp::Mc {
2642+ plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },
2643+ residual: Residual::Done(residual),
2644+ });
2645+ return;
2646+ }
2647+ };
2648+ if inline_mc(plane, x, y, stride, w, h, src, &residual, fctx) {
2527 return;2649 return;
2528 }2650 }
2529 push_op(fctx, ReconOp::Mc {2651 push_op(fctx, ReconOp::Mc {
2530- plane, x, y, stride, w, h, prediction: prediction.to_vec(),2652+ plane, x, y, stride, w, h, prediction: PredSrc::Owned(src.to_vec()),
2531 residual: Residual::Done(residual),2653 residual: Residual::Done(residual),
2532 });2654 });
2533 }2655 }
@@ -2567,7 +2689,7 @@ fn push_mc(
2567 x: usize,2689 x: usize,
2568 y: usize,2690 y: usize,
2569 side: usize,2691 side: usize,
2570- prediction: &[u16],2692+ prediction: Pred<'_>,
2571 residual: &[i32], fctx: &crate::decode::FrameCtx,2693 residual: &[i32], fctx: &crate::decode::FrameCtx,
2572 ) {2694 ) {
2573 push_mc_rect(plane, x, y, side, side, side, prediction, residual, fctx);2695 push_mc_rect(plane, x, y, side, side, side, prediction, residual, fctx);
@@ -2582,15 +2704,26 @@ fn push_mc_rect(
2582 stride: usize,2704 stride: usize,
2583 w: usize,2705 w: usize,
2584 h: usize,2706 h: usize,
2585- prediction: &[u16],2707+ prediction: Pred<'_>,
2586 residual: &[i32], fctx: &crate::decode::FrameCtx,2708 residual: &[i32], fctx: &crate::decode::FrameCtx,
2587 ) {2709 ) {
2588- if inline_mc(plane, x, y, stride, w, h, prediction, residual, fctx) {2710+ let (src, stride) = match prediction.inline(stride) {
2711+ Some(v) => v,
2712+ None => {
2713+ let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2714+ push_op(fctx, ReconOp::Mc {
2715+ plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },
2716+ residual: Residual::Done(residual.to_vec()),
2717+ });
2718+ return;
2719+ }
2720+ };
2721+ if inline_mc(plane, x, y, stride, w, h, src, residual, fctx) {
2589 return;2722 return;
2590 }2723 }
2591 push_op(fctx, ReconOp::Mc {2724 push_op(fctx, ReconOp::Mc {
2592 plane, x, y, stride, w, h,2725 plane, x, y, stride, w, h,
2593- prediction: prediction.to_vec(), residual: Residual::Done(residual.to_vec()),2726+ prediction: PredSrc::Owned(src.to_vec()), residual: Residual::Done(residual.to_vec()),
2594 });2727 });
2595 }2728 }
2596 2729
@@ -2638,11 +2771,28 @@ fn push_mc_rect_tx(
2638 stride: usize,2771 stride: usize,
2639 w: usize,2772 w: usize,
2640 h: usize,2773 h: usize,
2641- prediction: &[u16],2774+ prediction: Pred<'_>,
2642 tx: TxParams,2775 tx: TxParams,
2643 grid: &[i32],2776 grid: &[i32],
2644 fctx: &crate::decode::FrameCtx,2777 fctx: &crate::decode::FrameCtx,
2645 ) {2778 ) {
2779+ // lane-wave4: a deferred prediction is not there to be windowed -- the
2780+ // op carries its offset into the block's prediction instead, and the
2781+ // residual is laid out at that same stride (`reconstruct_mc_rect` reads
2782+ // both buffers at one stride).
2783+ let (prediction, stride) = match prediction.inline(stride) {
2784+ Some(v) => v,
2785+ None => {
2786+ let Pred::Cur { plane: sp, stride: ss, off } = prediction else { unreachable!() };
2787+ let mut tx = tx;
2788+ tx.stride = ss;
2789+ push_op(fctx, ReconOp::Mc {
2790+ plane, x, y, stride: ss, w, h, prediction: PredSrc::Cur { plane: sp, off },
2791+ residual: Residual::Coeffs(tx, grid.to_vec()),
2792+ });
2793+ return;
2794+ }
2795+ };
2646 if fctx.recon_planes.with(std::cell::Cell::get).is_some() {2796 if fctx.recon_planes.with(std::cell::Cell::get).is_some() {
2647 inline_mc(plane, x, y, stride, w, h, prediction, &tx.run(grid), fctx);2797 inline_mc(plane, x, y, stride, w, h, prediction, &tx.run(grid), fctx);
2648 return;2798 return;
@@ -2660,7 +2810,7 @@ fn push_mc_rect_tx(
2660 let mut tx = tx;2810 let mut tx = tx;
2661 tx.stride = 0;2811 tx.stride = 0;
2662 push_op(fctx, ReconOp::Mc {2812 push_op(fctx, ReconOp::Mc {
2663- plane, x, y, stride: w, w, h, prediction: window,2813+ plane, x, y, stride: w, w, h, prediction: PredSrc::Owned(window),
2664 residual: Residual::Coeffs(tx, grid.to_vec()),2814 residual: Residual::Coeffs(tx, grid.to_vec()),
2665 });2815 });
2666 }2816 }
@@ -2684,8 +2834,9 @@ fn flush_recon(
2684 wave_barrier(fctx);2834 wave_barrier(fctx);
2685 let mut ops = fctx.recon_spare.with(|c| std::mem::take(&mut *c.borrow_mut()));2835 let mut ops = fctx.recon_spare.with(|c| std::mem::take(&mut *c.borrow_mut()));
2686 fctx.recon_ops.with(|c| std::mem::swap(&mut *c.borrow_mut(), &mut ops));2836 fctx.recon_ops.with(|c| std::mem::swap(&mut *c.borrow_mut(), &mut ops));
2837+ let mut cur: [Vec<u16>; 3] = Default::default();
2687 for op in ops.drain(..) {2838 for op in ops.drain(..) {
2688- exec_op(op, y, u, v, fctx);2839+ exec_op(op, y, u, v, &mut cur, fctx);
2689 }2840 }
2690 fctx.recon_spare.with(|c| *c.borrow_mut() = ops);2841 fctx.recon_spare.with(|c| *c.borrow_mut() = ops);
2691 }2842 }
@@ -2697,9 +2848,11 @@ fn exec_op(
2697 y: &mut PlaneBuf<'static>,2848 y: &mut PlaneBuf<'static>,
2698 u: &mut PlaneBuf<'static>,2849 u: &mut PlaneBuf<'static>,
2699 v: &mut PlaneBuf<'static>,2850 v: &mut PlaneBuf<'static>,
2851+ cur: &mut [Vec<u16>; 3],
2700 fctx: &crate::decode::FrameCtx,2852 fctx: &crate::decode::FrameCtx,
2701 ) {2853 ) {
2702 match op {2854 match op {
2855+ ReconOp::Pred(b) => *cur = (b.0)(y, u, v, fctx),
2703 ReconOp::Intra {2856 ReconOp::Intra {
2704 plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl,2857 plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl,
2705 filter_intra, smooth_neighbor, pred,2858 filter_intra, smooth_neighbor, pred,
@@ -2708,7 +2861,17 @@ fn exec_op(
2708 cfl, filter_intra, smooth_neighbor, pred, fctx,2861 cfl, filter_intra, smooth_neighbor, pred, fctx,
2709 ),2862 ),
2710 ReconOp::Mc { plane, x, y: oy, stride, w, h, prediction, residual } => {2863 ReconOp::Mc { plane, x, y: oy, stride, w, h, prediction, residual } => {
2711- exec_mc(y, u, v, plane, x, oy, stride, w, h, &prediction, &residual.resolve(), fctx);2864+ let residual = residual.resolve();
2865+ match prediction {
2866+ PredSrc::Owned(p) => {
2867+ exec_mc(y, u, v, plane, x, oy, stride, w, h, &p, &residual, fctx);
2868+ }
2869+ PredSrc::Cur { plane: sp, off } => {
2870+ let src = std::mem::take(&mut cur[sp]);
2871+ exec_mc(y, u, v, plane, x, oy, stride, w, h, &src[off..], &residual, fctx);
2872+ cur[sp] = src;
2873+ }
2874+ }
2712 }2875 }
2713 }2876 }
2714 }2877 }
@@ -16941,7 +17104,7 @@ fn read_inter_plane_rect(
16941 _plane: &mut PlaneBuf<'static>,17104 _plane: &mut PlaneBuf<'static>,
16942 x: usize,17105 x: usize,
16943 y: usize,17106 y: usize,
16944- prediction: &[u16],17107+ prediction: Pred<'_>,
16945 inherited_luma_tx_type: Option<TxType>,17108 inherited_luma_tx_type: Option<TxType>,
16946 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,17109 luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx,
16947 ) -> Result<(Vec<i32>, TxType)> {17110 ) -> Result<(Vec<i32>, TxType)> {
@@ -17052,7 +17215,7 @@ fn read_inter_luma8(
17052 y: &mut PlaneBuf<'static>,17215 y: &mut PlaneBuf<'static>,
17053 px: usize,17216 px: usize,
17054 py: usize,17217 py: usize,
17055- pred_y: &[u16],17218+ pred_y: Pred<'_>,
17056 mode_for_tx: usize,17219 mode_for_tx: usize,
17057 base_q_idx: u8,17220 base_q_idx: u8,
17058 scan8: &[u16],17221 scan8: &[u16],
@@ -17087,11 +17250,7 @@ fn read_inter_luma8(
17087 for tu_row in 0..2 {17250 for tu_row in 0..2 {
17088 for tu_col in 0..2 {17251 for tu_col in 0..2 {
17089 let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col);17252 let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col);
17090- let mut tu_pred = Vec::with_capacity(16);17253+ let tu_pred = pred_y.view(8).offset(tu_row * 4 * 8 + tu_col * 4);
17091- for rr in 0..4 {
17092- let start = (tu_row * 4 + rr) * 8 + tu_col * 4;
17093- tu_pred.extend_from_slice(&pred_y[start..start + 4]);
17094- }
17095 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1);17254 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1);
17096 let (tu_grid, tu_tx_type) = read_inter_plane(17255 let (tu_grid, tu_tx_type) = read_inter_plane(
17097 dec,17256 dec,
@@ -17110,7 +17269,7 @@ fn read_inter_luma8(
17110 py + tu_row * 4,17269 py + tu_row * 4,
17111 4,17270 4,
17112 base_q_idx,17271 base_q_idx,
17113- &tu_pred,17272+ tu_pred,
17114 None,17273 None,
17115 Some(tu_skip_ctx), fctx,17274 Some(tu_skip_ctx), fctx,
17116 )?;17275 )?;
@@ -21525,7 +21684,7 @@ fn read_inter_plane(
21525 y: usize,21684 y: usize,
21526 side: usize,21685 side: usize,
21527 _base_q_idx: u8,21686 _base_q_idx: u8,
21528- prediction: &[u16],21687+ prediction: Pred<'_>,
21529 // lane-chromau: this block's own luma transform's *actual coded*21688 // lane-chromau: this block's own luma transform's *actual coded*
21530 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's21689 // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's
21531 // chroma plane never codes its own `tx_type` symbol, but (unlike an21690 // chroma plane never codes its own `tx_type` symbol, but (unlike an
@@ -24117,7 +24276,7 @@ fn decode_inter_block(
24117 side,24276 side,
24118 write_w,24277 write_w,
24119 write_h,24278 write_h,
24120- &pred_y,24279+ Pred::dense(&pred_y),
24121 &vec![0i32; side * side], fctx,24280 &vec![0i32; side * side], fctx,
24122 );24281 );
24123 push_mc_rect(1, 24282 push_mc_rect(1,
@@ -24126,7 +24285,7 @@ fn decode_inter_block(
24126 chroma_side,24285 chroma_side,
24127 write_chroma_w,24286 write_chroma_w,
24128 write_chroma_h,24287 write_chroma_h,
24129- &pred_u,24288+ Pred::dense(&pred_u),
24130 &vec![0i32; chroma_side * chroma_side], fctx,24289 &vec![0i32; chroma_side * chroma_side], fctx,
24131 );24290 );
24132 push_mc_rect(2, 24291 push_mc_rect(2,
@@ -24135,7 +24294,7 @@ fn decode_inter_block(
24135 chroma_side,24294 chroma_side,
24136 write_chroma_w,24295 write_chroma_w,
24137 write_chroma_h,24296 write_chroma_h,
24138- &pred_v,24297+ Pred::dense(&pred_v),
24139 &vec![0i32; chroma_side * chroma_side], fctx,24298 &vec![0i32; chroma_side * chroma_side], fctx,
24140 );24299 );
24141 luma_grid = vec![0i32; side * side];24300 luma_grid = vec![0i32; side * side];
@@ -24189,7 +24348,7 @@ fn decode_inter_block(
24189 tu_py,24348 tu_py,
24190 tx_px,24349 tx_px,
24191 base_q_idx,24350 base_q_idx,
24192- &tu_pred,24351+ Pred::dense(&tu_pred),
24193 None,24352 None,
24194 Some(tu_skip_ctx), fctx,24353 Some(tu_skip_ctx), fctx,
24195 )?24354 )?
@@ -24217,7 +24376,7 @@ fn decode_inter_block(
24217 y,24376 y,
24218 tu_px,24377 tu_px,
24219 tu_py,24378 tu_py,
24220- &pred_y[start..],24379+ Pred::dense(&pred_y[start..]),
24221 None,24380 None,
24222 Some(tu_skip_ctx), fctx,24381 Some(tu_skip_ctx), fctx,
24223 )?24382 )?
@@ -24274,7 +24433,7 @@ fn decode_inter_block(
24274 cu_y,24433 cu_y,
24275 cu_tx,24434 cu_tx,
24276 base_q_idx,24435 base_q_idx,
24277- &cu_pred,24436+ Pred::dense(&cu_pred),
24278 Some(first_tx_type),24437 Some(first_tx_type),
24279 Some(3), fctx,24438 Some(3), fctx,
24280 )?24439 )?
@@ -24321,7 +24480,7 @@ fn decode_inter_block(
24321 y,24480 y,
24322 px,24481 px,
24323 py,24482 py,
24324- &pred_y,24483+ Pred::dense(&pred_y),
24325 None,24484 None,
24326 None, fctx,24485 None, fctx,
24327 )?;24486 )?;
@@ -24341,7 +24500,7 @@ fn decode_inter_block(
24341 py,24500 py,
24342 side,24501 side,
24343 base_q_idx,24502 base_q_idx,
24344- &pred_y,24503+ Pred::dense(&pred_y),
24345 None,24504 None,
24346 None, fctx,24505 None, fctx,
24347 )?;24506 )?;
@@ -24371,7 +24530,7 @@ fn decode_inter_block(
24371 u,24530 u,
24372 cpx,24531 cpx,
24373 cpy,24532 cpy,
24374- &pred_u,24533+ Pred::dense(&pred_u),
24375 Some(luma_tx_type),24534 Some(luma_tx_type),
24376 None, fctx,24535 None, fctx,
24377 )?24536 )?
@@ -24393,7 +24552,7 @@ fn decode_inter_block(
24393 v,24552 v,
24394 cpx,24553 cpx,
24395 cpy,24554 cpy,
24396- &pred_v,24555+ Pred::dense(&pred_v),
24397 Some(luma_tx_type),24556 Some(luma_tx_type),
24398 None, fctx,24557 None, fctx,
24399 )?24558 )?
@@ -24416,7 +24575,7 @@ fn decode_inter_block(
24416 cpy,24575 cpy,
24417 chroma_side,24576 chroma_side,
24418 base_q_idx,24577 base_q_idx,
24419- &pred_u,24578+ Pred::dense(&pred_u),
24420 Some(luma_tx_type),24579 Some(luma_tx_type),
24421 None, fctx,24580 None, fctx,
24422 )?24581 )?
@@ -24434,7 +24593,7 @@ fn decode_inter_block(
24434 cpy,24593 cpy,
24435 chroma_side,24594 chroma_side,
24436 base_q_idx,24595 base_q_idx,
24437- &pred_v,24596+ Pred::dense(&pred_v),
24438 Some(luma_tx_type),24597 Some(luma_tx_type),
24439 None, fctx,24598 None, fctx,
24440 )?24599 )?
@@ -25328,7 +25487,7 @@ fn decode_inter_block(
25328 side,25487 side,
25329 write_w,25488 write_w,
25330 write_h,25489 write_h,
25331- &pred_y,25490+ Pred::dense(&pred_y),
25332 &vec![0i32; side * side], fctx,25491 &vec![0i32; side * side], fctx,
25333 );25492 );
25334 if has_chroma {25493 if has_chroma {
@@ -25338,7 +25497,7 @@ fn decode_inter_block(
25338 chroma_side,25497 chroma_side,
25339 write_chroma_w,25498 write_chroma_w,
25340 write_chroma_h,25499 write_chroma_h,
25341- &pred_u,25500+ Pred::dense(&pred_u),
25342 &vec![0i32; chroma_side * chroma_side], fctx,25501 &vec![0i32; chroma_side * chroma_side], fctx,
25343 );25502 );
25344 push_mc_rect(2, 25503 push_mc_rect(2,
@@ -25347,7 +25506,7 @@ fn decode_inter_block(
25347 chroma_side,25506 chroma_side,
25348 write_chroma_w,25507 write_chroma_w,
25349 write_chroma_h,25508 write_chroma_h,
25350- &pred_v,25509+ Pred::dense(&pred_v),
25351 &vec![0i32; chroma_side * chroma_side], fctx,25510 &vec![0i32; chroma_side * chroma_side], fctx,
25352 );25511 );
25353 }25512 }
@@ -25414,7 +25573,7 @@ fn decode_inter_block(
25414 tu_py,25573 tu_py,
25415 tx_px,25574 tx_px,
25416 base_q_idx,25575 base_q_idx,
25417- &tu_pred,25576+ Pred::dense(&tu_pred),
25418 None,25577 None,
25419 Some(tu_skip_ctx), fctx,25578 Some(tu_skip_ctx), fctx,
25420 )?25579 )?
@@ -25442,7 +25601,7 @@ fn decode_inter_block(
25442 y,25601 y,
25443 tu_px,25602 tu_px,
25444 tu_py,25603 tu_py,
25445- &pred_y[start..],25604+ Pred::dense(&pred_y[start..]),
25446 None,25605 None,
25447 Some(tu_skip_ctx), fctx,25606 Some(tu_skip_ctx), fctx,
25448 )?25607 )?
@@ -25499,7 +25658,7 @@ fn decode_inter_block(
25499 cu_y,25658 cu_y,
25500 cu_tx,25659 cu_tx,
25501 base_q_idx,25660 base_q_idx,
25502- &cu_pred,25661+ Pred::dense(&cu_pred),
25503 Some(first_tx_type),25662 Some(first_tx_type),
25504 Some(3), fctx,25663 Some(3), fctx,
25505 )?25664 )?
@@ -25546,7 +25705,7 @@ fn decode_inter_block(
25546 y,25705 y,
25547 px,25706 px,
25548 py,25707 py,
25549- &pred_y,25708+ Pred::dense(&pred_y),
25550 None,25709 None,
25551 None, fctx,25710 None, fctx,
25552 )?;25711 )?;
@@ -25566,7 +25725,7 @@ fn decode_inter_block(
25566 py,25725 py,
25567 side,25726 side,
25568 base_q_idx,25727 base_q_idx,
25569- &pred_y,25728+ Pred::dense(&pred_y),
25570 None,25729 None,
25571 None, fctx,25730 None, fctx,
25572 )?;25731 )?;
@@ -25605,7 +25764,7 @@ fn decode_inter_block(
25605 u,25764 u,
25606 cpx,25765 cpx,
25607 cpy,25766 cpy,
25608- &pred_u,25767+ Pred::dense(&pred_u),
25609 Some(luma_tx_type),25768 Some(luma_tx_type),
25610 None, fctx,25769 None, fctx,
25611 )?25770 )?
@@ -25627,7 +25786,7 @@ fn decode_inter_block(
25627 v,25786 v,
25628 cpx,25787 cpx,
25629 cpy,25788 cpy,
25630- &pred_v,25789+ Pred::dense(&pred_v),
25631 Some(luma_tx_type),25790 Some(luma_tx_type),
25632 None, fctx,25791 None, fctx,
25633 )?25792 )?
@@ -25650,7 +25809,7 @@ fn decode_inter_block(
25650 cpy,25809 cpy,
25651 chroma_side,25810 chroma_side,
25652 base_q_idx,25811 base_q_idx,
25653- &pred_u,25812+ Pred::dense(&pred_u),
25654 Some(luma_tx_type),25813 Some(luma_tx_type),
25655 None, fctx,25814 None, fctx,
25656 )?25815 )?
@@ -25668,7 +25827,7 @@ fn decode_inter_block(
25668 cpy,25827 cpy,
25669 chroma_side,25828 chroma_side,
25670 base_q_idx,25829 base_q_idx,
25671- &pred_v,25830+ Pred::dense(&pred_v),
25672 Some(luma_tx_type),25831 Some(luma_tx_type),
25673 None, fctx,25832 None, fctx,
25674 )?25833 )?
@@ -26962,7 +27121,7 @@ fn decode_inter_sub8_split4(
26962 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which27121 // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which
26963 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).27122 // `read_inter_plane`'s `plane_idx == 0` arm already assumes).
26964 if skip {27123 if skip {
26965- push_mc(0, px, py, B4, &pred_y, &vec![0i32; B4 * B4], fctx);27124+ push_mc(0, px, py, B4, Pred::dense(&pred_y), &vec![0i32; B4 * B4], fctx);
26966 neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);27125 neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]);
26967 } else {27126 } else {
26968 let around = neighbours.around_mi(lmi, B4);27127 let around = neighbours.around_mi(lmi, B4);
@@ -26983,7 +27142,7 @@ fn decode_inter_sub8_split4(
26983 py,27142 py,
26984 B4,27143 B4,
26985 base_q_idx,27144 base_q_idx,
26986- &pred_y,27145+ Pred::dense(&pred_y),
26987 None,27146 None,
26988 None, fctx,27147 None, fctx,
26989 )?;27148 )?;
@@ -27077,19 +27236,19 @@ fn decode_inter_sub8_split4(
27077 }27236 }
27078 }27237 }
27079 let (u_grid, v_grid) = if last_skip {27238 let (u_grid, v_grid) = if last_skip {
27080- push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);27239+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);
27081- push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);27240+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);
27082 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])27241 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
27083 } else {27242 } else {
27084 let around = neighbours.around_mi(group_mi, 8);27243 let around = neighbours.around_mi(group_mi, 8);
27085 let ug = read_inter_plane(27244 let ug = read_inter_plane(
27086 dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,27245 dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,
27087- &pred_u, Some(first_tx_type), None, fctx,27246+ Pred::dense(&pred_u), Some(first_tx_type), None, fctx,
27088 )?27247 )?
27089 .0;27248 .0;
27090 let vg = read_inter_plane(27249 let vg = read_inter_plane(
27091 dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,27250 dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,
27092- &pred_v, Some(first_tx_type), None, fctx,27251+ Pred::dense(&pred_v), Some(first_tx_type), None, fctx,
27093 )?27252 )?
27094 .0;27253 .0;
27095 let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0);27254 let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0);
@@ -27935,7 +28094,7 @@ fn decode_inter_sub8_rect2(
27935 }28094 }
27936 }28095 }
27937 if skip {28096 if skip {
27938- push_mc_rect(0, px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE], fctx);28097+ push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
27939 neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);28098 neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]);
27940 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);28099 neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx);
27941 } else {28100 } else {
@@ -27971,7 +28130,7 @@ fn decode_inter_sub8_rect2(
27971 tu_py,28130 tu_py,
27972 tw,28131 tw,
27973 base_q_idx,28132 base_q_idx,
27974- &tu_pred,28133+ Pred::dense(&tu_pred),
27975 None,28134 None,
27976 Some(tu_skip_ctx), fctx,28135 Some(tu_skip_ctx), fctx,
27977 )?28136 )?
@@ -27996,7 +28155,7 @@ fn decode_inter_sub8_rect2(
27996 y,28155 y,
27997 tu_px,28156 tu_px,
27998 tu_py,28157 tu_py,
27999- &pred_y[start..],28158+ Pred::dense(&pred_y[start..]),
28000 None,28159 None,
28001 None, fctx,28160 None, fctx,
28002 )?28161 )?
@@ -28101,19 +28260,19 @@ fn decode_inter_sub8_rect2(
28101 }28260 }
28102 }28261 }
28103 let (u_grid, v_grid) = if last_skip {28262 let (u_grid, v_grid) = if last_skip {
28104- push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx);28263+ push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx);
28105- push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx);28264+ push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx);
28106 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])28265 (vec![0i32; B4 * B4], vec![0i32; B4 * B4])
28107 } else {28266 } else {
28108 let around = neighbours.around_mi(group_mi, 8);28267 let around = neighbours.around_mi(group_mi, 8);
28109 let ug = read_inter_plane(28268 let ug = read_inter_plane(
28110 dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,28269 dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx,
28111- &pred_u, Some(first_tx_type), None, fctx,28270+ Pred::dense(&pred_u), Some(first_tx_type), None, fctx,
28112 )?28271 )?
28113 .0;28272 .0;
28114 let vg = read_inter_plane(28273 let vg = read_inter_plane(
28115 dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,28274 dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx,
28116- &pred_v, Some(first_tx_type), None, fctx,28275+ Pred::dense(&pred_v), Some(first_tx_type), None, fctx,
28117 )?28276 )?
28118 .0;28277 .0;
28119 let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0);28278 let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0);
@@ -28938,19 +29097,19 @@ fn decode_inter_block8(
28938 .129097 .1
28939 .is_some();29098 .is_some();
28940 if skip {29099 if skip {
28941- push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);29100+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
28942 push_mc(1, 29101 push_mc(1,
28943 cpx,29102 cpx,
28944 cpy,29103 cpy,
28945 CHROMA_SIDE,29104 CHROMA_SIDE,
28946- &pred_u,29105+ Pred::dense(&pred_u),
28947 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29106 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
28948 );29107 );
28949 push_mc(2, 29108 push_mc(2,
28950 cpx,29109 cpx,
28951 cpy,29110 cpy,
28952 CHROMA_SIDE,29111 CHROMA_SIDE,
28953- &pred_v,29112+ Pred::dense(&pred_v),
28954 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29113 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
28955 );29114 );
28956 luma_grid = vec![0i32; SIDE * SIDE];29115 luma_grid = vec![0i32; SIDE * SIDE];
@@ -28966,7 +29125,7 @@ fn decode_inter_block8(
28966 y,29125 y,
28967 px,29126 px,
28968 py,29127 py,
28969- &pred_y,29128+ Pred::dense(&pred_y),
28970 mode_for_tx,29129 mode_for_tx,
28971 base_q_idx,29130 base_q_idx,
28972 scan8,29131 scan8,
@@ -28988,7 +29147,7 @@ fn decode_inter_block8(
28988 cpy,29147 cpy,
28989 CHROMA_SIDE,29148 CHROMA_SIDE,
28990 base_q_idx,29149 base_q_idx,
28991- &pred_u,29150+ Pred::dense(&pred_u),
28992 Some(luma_tx_type),29151 Some(luma_tx_type),
28993 None, fctx,29152 None, fctx,
28994 )?29153 )?
@@ -29006,7 +29165,7 @@ fn decode_inter_block8(
29006 cpy,29165 cpy,
29007 CHROMA_SIDE,29166 CHROMA_SIDE,
29008 base_q_idx,29167 base_q_idx,
29009- &pred_v,29168+ Pred::dense(&pred_v),
29010 Some(luma_tx_type),29169 Some(luma_tx_type),
29011 None, fctx,29170 None, fctx,
29012 )?29171 )?
@@ -29588,19 +29747,19 @@ fn decode_inter_block8(
29588 .129747 .1
29589 .is_some();29748 .is_some();
29590 if skip {29749 if skip {
29591- push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx);29750+ push_mc(0, px, py, SIDE, Pred::dense(&pred_y), &vec![0i32; SIDE * SIDE], fctx);
29592 push_mc(1, 29751 push_mc(1,
29593 cpx,29752 cpx,
29594 cpy,29753 cpy,
29595 CHROMA_SIDE,29754 CHROMA_SIDE,
29596- &pred_u,29755+ Pred::dense(&pred_u),
29597 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29756 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
29598 );29757 );
29599 push_mc(2, 29758 push_mc(2,
29600 cpx,29759 cpx,
29601 cpy,29760 cpy,
29602 CHROMA_SIDE,29761 CHROMA_SIDE,
29603- &pred_v,29762+ Pred::dense(&pred_v),
29604 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,29763 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx,
29605 );29764 );
29606 luma_grid = vec![0i32; SIDE * SIDE];29765 luma_grid = vec![0i32; SIDE * SIDE];
@@ -29616,7 +29775,7 @@ fn decode_inter_block8(
29616 y,29775 y,
29617 px,29776 px,
29618 py,29777 py,
29619- &pred_y,29778+ Pred::dense(&pred_y),
29620 mode_for_tx,29779 mode_for_tx,
29621 base_q_idx,29780 base_q_idx,
29622 scan8,29781 scan8,
@@ -29638,7 +29797,7 @@ fn decode_inter_block8(
29638 cpy,29797 cpy,
29639 CHROMA_SIDE,29798 CHROMA_SIDE,
29640 base_q_idx,29799 base_q_idx,
29641- &pred_u,29800+ Pred::dense(&pred_u),
29642 Some(luma_tx_type),29801 Some(luma_tx_type),
29643 None, fctx,29802 None, fctx,
29644 )?29803 )?
@@ -29656,7 +29815,7 @@ fn decode_inter_block8(
29656 cpy,29815 cpy,
29657 CHROMA_SIDE,29816 CHROMA_SIDE,
29658 base_q_idx,29817 base_q_idx,
29659- &pred_v,29818+ Pred::dense(&pred_v),
29660 Some(luma_tx_type),29819 Some(luma_tx_type),
29661 None, fctx,29820 None, fctx,
29662 )?29821 )?