A recorded inter write names where its prediction comes from
Browse files at this commit8aa7db153f618b6c26409eee75368ba7ca71c195Parent: 11ef8ca- refactor
- a recorded inter write names where its prediction comes from
1 changed file +231 -72
- crates/ec-av1/src/decode.rs +231 -72
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 | 2223 | pub(crate) enum ReconOp { |
| 2224 | + /// lane-wave4: build this block's prediction into the worker's slot. | |
| 2225 | + Pred(PredBuild), | |
| 2116 | 2226 | Intra { |
| 2117 | 2227 | plane: usize, |
| 2118 | 2228 | x: usize, |
| @@ -2141,7 +2251,7 @@ pub(crate) enum ReconOp { | ||
| 2141 | 2251 | stride: usize, |
| 2142 | 2252 | w: usize, |
| 2143 | 2253 | h: usize, |
| 2144 | - prediction: Vec<u16>, | |
| 2254 | + prediction: PredSrc, | |
| 2145 | 2255 | residual: Residual, |
| 2146 | 2256 | }, |
| 2147 | 2257 | } |
| @@ -2222,7 +2332,7 @@ fn push_op(fctx: &crate::decode::FrameCtx, op: ReconOp) { | ||
| 2222 | 2332 | if let Some(ReconPlanes(y, u, v)) = fctx.recon_planes.with(std::cell::Cell::get) { |
| 2223 | 2333 | // SAFETY: see [`ReconPlanes`] -- one thread, and the write is the one |
| 2224 | 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 | 2336 | return; |
| 2227 | 2337 | } |
| 2228 | 2338 | fctx.recon_ops.with(|c| c.borrow_mut().push(op)); |
| @@ -2295,9 +2405,10 @@ fn wave_worker(st: &WaveState) { | ||
| 2295 | 2405 | // SAFETY: this job writes only superblock (r, c)'s own pixels, and |
| 2296 | 2406 | // every superblock that could have written or be reading them is |
| 2297 | 2407 | // complete by the wavefront rule above. |
| 2408 | + let mut cur: [Vec<u16>; 3] = Default::default(); | |
| 2298 | 2409 | unsafe { |
| 2299 | 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 | 2414 | let mut q = st.q.lock().unwrap(); |
| @@ -2520,14 +2631,25 @@ fn push_mc_rect_owned( | ||
| 2520 | 2631 | stride: usize, |
| 2521 | 2632 | w: usize, |
| 2522 | 2633 | h: usize, |
| 2523 | - prediction: &[u16], | |
| 2634 | + prediction: Pred<'_>, | |
| 2524 | 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 | 2649 | return; |
| 2528 | 2650 | } |
| 2529 | 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 | 2653 | residual: Residual::Done(residual), |
| 2532 | 2654 | }); |
| 2533 | 2655 | } |
| @@ -2567,7 +2689,7 @@ fn push_mc( | ||
| 2567 | 2689 | x: usize, |
| 2568 | 2690 | y: usize, |
| 2569 | 2691 | side: usize, |
| 2570 | - prediction: &[u16], | |
| 2692 | + prediction: Pred<'_>, | |
| 2571 | 2693 | residual: &[i32], fctx: &crate::decode::FrameCtx, |
| 2572 | 2694 | ) { |
| 2573 | 2695 | push_mc_rect(plane, x, y, side, side, side, prediction, residual, fctx); |
| @@ -2582,15 +2704,26 @@ fn push_mc_rect( | ||
| 2582 | 2704 | stride: usize, |
| 2583 | 2705 | w: usize, |
| 2584 | 2706 | h: usize, |
| 2585 | - prediction: &[u16], | |
| 2707 | + prediction: Pred<'_>, | |
| 2586 | 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 | 2722 | return; |
| 2590 | 2723 | } |
| 2591 | 2724 | push_op(fctx, ReconOp::Mc { |
| 2592 | 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 | 2771 | stride: usize, |
| 2639 | 2772 | w: usize, |
| 2640 | 2773 | h: usize, |
| 2641 | - prediction: &[u16], | |
| 2774 | + prediction: Pred<'_>, | |
| 2642 | 2775 | tx: TxParams, |
| 2643 | 2776 | grid: &[i32], |
| 2644 | 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 | 2796 | if fctx.recon_planes.with(std::cell::Cell::get).is_some() { |
| 2647 | 2797 | inline_mc(plane, x, y, stride, w, h, prediction, &tx.run(grid), fctx); |
| 2648 | 2798 | return; |
| @@ -2660,7 +2810,7 @@ fn push_mc_rect_tx( | ||
| 2660 | 2810 | let mut tx = tx; |
| 2661 | 2811 | tx.stride = 0; |
| 2662 | 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 | 2814 | residual: Residual::Coeffs(tx, grid.to_vec()), |
| 2665 | 2815 | }); |
| 2666 | 2816 | } |
| @@ -2684,8 +2834,9 @@ fn flush_recon( | ||
| 2684 | 2834 | wave_barrier(fctx); |
| 2685 | 2835 | let mut ops = fctx.recon_spare.with(|c| std::mem::take(&mut *c.borrow_mut())); |
| 2686 | 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 | 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 | 2841 | fctx.recon_spare.with(|c| *c.borrow_mut() = ops); |
| 2691 | 2842 | } |
| @@ -2697,9 +2848,11 @@ fn exec_op( | ||
| 2697 | 2848 | y: &mut PlaneBuf<'static>, |
| 2698 | 2849 | u: &mut PlaneBuf<'static>, |
| 2699 | 2850 | v: &mut PlaneBuf<'static>, |
| 2851 | + cur: &mut [Vec<u16>; 3], | |
| 2700 | 2852 | fctx: &crate::decode::FrameCtx, |
| 2701 | 2853 | ) { |
| 2702 | 2854 | match op { |
| 2855 | + ReconOp::Pred(b) => *cur = (b.0)(y, u, v, fctx), | |
| 2703 | 2856 | ReconOp::Intra { |
| 2704 | 2857 | plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl, |
| 2705 | 2858 | filter_intra, smooth_neighbor, pred, |
| @@ -2708,7 +2861,17 @@ fn exec_op( | ||
| 2708 | 2861 | cfl, filter_intra, smooth_neighbor, pred, fctx, |
| 2709 | 2862 | ), |
| 2710 | 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 | 17104 | _plane: &mut PlaneBuf<'static>, |
| 16942 | 17105 | x: usize, |
| 16943 | 17106 | y: usize, |
| 16944 | - prediction: &[u16], | |
| 17107 | + prediction: Pred<'_>, | |
| 16945 | 17108 | inherited_luma_tx_type: Option<TxType>, |
| 16946 | 17109 | luma_skip_ctx: Option<usize>, fctx: &crate::decode::FrameCtx, |
| 16947 | 17110 | ) -> Result<(Vec<i32>, TxType)> { |
| @@ -17052,7 +17215,7 @@ fn read_inter_luma8( | ||
| 17052 | 17215 | y: &mut PlaneBuf<'static>, |
| 17053 | 17216 | px: usize, |
| 17054 | 17217 | py: usize, |
| 17055 | - pred_y: &[u16], | |
| 17218 | + pred_y: Pred<'_>, | |
| 17056 | 17219 | mode_for_tx: usize, |
| 17057 | 17220 | base_q_idx: u8, |
| 17058 | 17221 | scan8: &[u16], |
| @@ -17087,11 +17250,7 @@ fn read_inter_luma8( | ||
| 17087 | 17250 | for tu_row in 0..2 { |
| 17088 | 17251 | for tu_col in 0..2 { |
| 17089 | 17252 | let tu_mi = (leaf_mi.0 + tu_row, leaf_mi.1 + tu_col); |
| 17090 | - let mut tu_pred = Vec::with_capacity(16); | |
| 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 | - } | |
| 17253 | + let tu_pred = pred_y.view(8).offset(tu_row * 4 * 8 + tu_col * 4); | |
| 17095 | 17254 | let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); |
| 17096 | 17255 | let (tu_grid, tu_tx_type) = read_inter_plane( |
| 17097 | 17256 | dec, |
| @@ -17110,7 +17269,7 @@ fn read_inter_luma8( | ||
| 17110 | 17269 | py + tu_row * 4, |
| 17111 | 17270 | 4, |
| 17112 | 17271 | base_q_idx, |
| 17113 | - &tu_pred, | |
| 17272 | + tu_pred, | |
| 17114 | 17273 | None, |
| 17115 | 17274 | Some(tu_skip_ctx), fctx, |
| 17116 | 17275 | )?; |
| @@ -21525,7 +21684,7 @@ fn read_inter_plane( | ||
| 21525 | 21684 | y: usize, |
| 21526 | 21685 | side: usize, |
| 21527 | 21686 | _base_q_idx: u8, |
| 21528 | - prediction: &[u16], | |
| 21687 | + prediction: Pred<'_>, | |
| 21529 | 21688 | // lane-chromau: this block's own luma transform's *actual coded* |
| 21530 | 21689 | // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's |
| 21531 | 21690 | // chroma plane never codes its own `tx_type` symbol, but (unlike an |
| @@ -24117,7 +24276,7 @@ fn decode_inter_block( | ||
| 24117 | 24276 | side, |
| 24118 | 24277 | write_w, |
| 24119 | 24278 | write_h, |
| 24120 | - &pred_y, | |
| 24279 | + Pred::dense(&pred_y), | |
| 24121 | 24280 | &vec![0i32; side * side], fctx, |
| 24122 | 24281 | ); |
| 24123 | 24282 | push_mc_rect(1, |
| @@ -24126,7 +24285,7 @@ fn decode_inter_block( | ||
| 24126 | 24285 | chroma_side, |
| 24127 | 24286 | write_chroma_w, |
| 24128 | 24287 | write_chroma_h, |
| 24129 | - &pred_u, | |
| 24288 | + Pred::dense(&pred_u), | |
| 24130 | 24289 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 24131 | 24290 | ); |
| 24132 | 24291 | push_mc_rect(2, |
| @@ -24135,7 +24294,7 @@ fn decode_inter_block( | ||
| 24135 | 24294 | chroma_side, |
| 24136 | 24295 | write_chroma_w, |
| 24137 | 24296 | write_chroma_h, |
| 24138 | - &pred_v, | |
| 24297 | + Pred::dense(&pred_v), | |
| 24139 | 24298 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 24140 | 24299 | ); |
| 24141 | 24300 | luma_grid = vec![0i32; side * side]; |
| @@ -24189,7 +24348,7 @@ fn decode_inter_block( | ||
| 24189 | 24348 | tu_py, |
| 24190 | 24349 | tx_px, |
| 24191 | 24350 | base_q_idx, |
| 24192 | - &tu_pred, | |
| 24351 | + Pred::dense(&tu_pred), | |
| 24193 | 24352 | None, |
| 24194 | 24353 | Some(tu_skip_ctx), fctx, |
| 24195 | 24354 | )? |
| @@ -24217,7 +24376,7 @@ fn decode_inter_block( | ||
| 24217 | 24376 | y, |
| 24218 | 24377 | tu_px, |
| 24219 | 24378 | tu_py, |
| 24220 | - &pred_y[start..], | |
| 24379 | + Pred::dense(&pred_y[start..]), | |
| 24221 | 24380 | None, |
| 24222 | 24381 | Some(tu_skip_ctx), fctx, |
| 24223 | 24382 | )? |
| @@ -24274,7 +24433,7 @@ fn decode_inter_block( | ||
| 24274 | 24433 | cu_y, |
| 24275 | 24434 | cu_tx, |
| 24276 | 24435 | base_q_idx, |
| 24277 | - &cu_pred, | |
| 24436 | + Pred::dense(&cu_pred), | |
| 24278 | 24437 | Some(first_tx_type), |
| 24279 | 24438 | Some(3), fctx, |
| 24280 | 24439 | )? |
| @@ -24321,7 +24480,7 @@ fn decode_inter_block( | ||
| 24321 | 24480 | y, |
| 24322 | 24481 | px, |
| 24323 | 24482 | py, |
| 24324 | - &pred_y, | |
| 24483 | + Pred::dense(&pred_y), | |
| 24325 | 24484 | None, |
| 24326 | 24485 | None, fctx, |
| 24327 | 24486 | )?; |
| @@ -24341,7 +24500,7 @@ fn decode_inter_block( | ||
| 24341 | 24500 | py, |
| 24342 | 24501 | side, |
| 24343 | 24502 | base_q_idx, |
| 24344 | - &pred_y, | |
| 24503 | + Pred::dense(&pred_y), | |
| 24345 | 24504 | None, |
| 24346 | 24505 | None, fctx, |
| 24347 | 24506 | )?; |
| @@ -24371,7 +24530,7 @@ fn decode_inter_block( | ||
| 24371 | 24530 | u, |
| 24372 | 24531 | cpx, |
| 24373 | 24532 | cpy, |
| 24374 | - &pred_u, | |
| 24533 | + Pred::dense(&pred_u), | |
| 24375 | 24534 | Some(luma_tx_type), |
| 24376 | 24535 | None, fctx, |
| 24377 | 24536 | )? |
| @@ -24393,7 +24552,7 @@ fn decode_inter_block( | ||
| 24393 | 24552 | v, |
| 24394 | 24553 | cpx, |
| 24395 | 24554 | cpy, |
| 24396 | - &pred_v, | |
| 24555 | + Pred::dense(&pred_v), | |
| 24397 | 24556 | Some(luma_tx_type), |
| 24398 | 24557 | None, fctx, |
| 24399 | 24558 | )? |
| @@ -24416,7 +24575,7 @@ fn decode_inter_block( | ||
| 24416 | 24575 | cpy, |
| 24417 | 24576 | chroma_side, |
| 24418 | 24577 | base_q_idx, |
| 24419 | - &pred_u, | |
| 24578 | + Pred::dense(&pred_u), | |
| 24420 | 24579 | Some(luma_tx_type), |
| 24421 | 24580 | None, fctx, |
| 24422 | 24581 | )? |
| @@ -24434,7 +24593,7 @@ fn decode_inter_block( | ||
| 24434 | 24593 | cpy, |
| 24435 | 24594 | chroma_side, |
| 24436 | 24595 | base_q_idx, |
| 24437 | - &pred_v, | |
| 24596 | + Pred::dense(&pred_v), | |
| 24438 | 24597 | Some(luma_tx_type), |
| 24439 | 24598 | None, fctx, |
| 24440 | 24599 | )? |
| @@ -25328,7 +25487,7 @@ fn decode_inter_block( | ||
| 25328 | 25487 | side, |
| 25329 | 25488 | write_w, |
| 25330 | 25489 | write_h, |
| 25331 | - &pred_y, | |
| 25490 | + Pred::dense(&pred_y), | |
| 25332 | 25491 | &vec![0i32; side * side], fctx, |
| 25333 | 25492 | ); |
| 25334 | 25493 | if has_chroma { |
| @@ -25338,7 +25497,7 @@ fn decode_inter_block( | ||
| 25338 | 25497 | chroma_side, |
| 25339 | 25498 | write_chroma_w, |
| 25340 | 25499 | write_chroma_h, |
| 25341 | - &pred_u, | |
| 25500 | + Pred::dense(&pred_u), | |
| 25342 | 25501 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 25343 | 25502 | ); |
| 25344 | 25503 | push_mc_rect(2, |
| @@ -25347,7 +25506,7 @@ fn decode_inter_block( | ||
| 25347 | 25506 | chroma_side, |
| 25348 | 25507 | write_chroma_w, |
| 25349 | 25508 | write_chroma_h, |
| 25350 | - &pred_v, | |
| 25509 | + Pred::dense(&pred_v), | |
| 25351 | 25510 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 25352 | 25511 | ); |
| 25353 | 25512 | } |
| @@ -25414,7 +25573,7 @@ fn decode_inter_block( | ||
| 25414 | 25573 | tu_py, |
| 25415 | 25574 | tx_px, |
| 25416 | 25575 | base_q_idx, |
| 25417 | - &tu_pred, | |
| 25576 | + Pred::dense(&tu_pred), | |
| 25418 | 25577 | None, |
| 25419 | 25578 | Some(tu_skip_ctx), fctx, |
| 25420 | 25579 | )? |
| @@ -25442,7 +25601,7 @@ fn decode_inter_block( | ||
| 25442 | 25601 | y, |
| 25443 | 25602 | tu_px, |
| 25444 | 25603 | tu_py, |
| 25445 | - &pred_y[start..], | |
| 25604 | + Pred::dense(&pred_y[start..]), | |
| 25446 | 25605 | None, |
| 25447 | 25606 | Some(tu_skip_ctx), fctx, |
| 25448 | 25607 | )? |
| @@ -25499,7 +25658,7 @@ fn decode_inter_block( | ||
| 25499 | 25658 | cu_y, |
| 25500 | 25659 | cu_tx, |
| 25501 | 25660 | base_q_idx, |
| 25502 | - &cu_pred, | |
| 25661 | + Pred::dense(&cu_pred), | |
| 25503 | 25662 | Some(first_tx_type), |
| 25504 | 25663 | Some(3), fctx, |
| 25505 | 25664 | )? |
| @@ -25546,7 +25705,7 @@ fn decode_inter_block( | ||
| 25546 | 25705 | y, |
| 25547 | 25706 | px, |
| 25548 | 25707 | py, |
| 25549 | - &pred_y, | |
| 25708 | + Pred::dense(&pred_y), | |
| 25550 | 25709 | None, |
| 25551 | 25710 | None, fctx, |
| 25552 | 25711 | )?; |
| @@ -25566,7 +25725,7 @@ fn decode_inter_block( | ||
| 25566 | 25725 | py, |
| 25567 | 25726 | side, |
| 25568 | 25727 | base_q_idx, |
| 25569 | - &pred_y, | |
| 25728 | + Pred::dense(&pred_y), | |
| 25570 | 25729 | None, |
| 25571 | 25730 | None, fctx, |
| 25572 | 25731 | )?; |
| @@ -25605,7 +25764,7 @@ fn decode_inter_block( | ||
| 25605 | 25764 | u, |
| 25606 | 25765 | cpx, |
| 25607 | 25766 | cpy, |
| 25608 | - &pred_u, | |
| 25767 | + Pred::dense(&pred_u), | |
| 25609 | 25768 | Some(luma_tx_type), |
| 25610 | 25769 | None, fctx, |
| 25611 | 25770 | )? |
| @@ -25627,7 +25786,7 @@ fn decode_inter_block( | ||
| 25627 | 25786 | v, |
| 25628 | 25787 | cpx, |
| 25629 | 25788 | cpy, |
| 25630 | - &pred_v, | |
| 25789 | + Pred::dense(&pred_v), | |
| 25631 | 25790 | Some(luma_tx_type), |
| 25632 | 25791 | None, fctx, |
| 25633 | 25792 | )? |
| @@ -25650,7 +25809,7 @@ fn decode_inter_block( | ||
| 25650 | 25809 | cpy, |
| 25651 | 25810 | chroma_side, |
| 25652 | 25811 | base_q_idx, |
| 25653 | - &pred_u, | |
| 25812 | + Pred::dense(&pred_u), | |
| 25654 | 25813 | Some(luma_tx_type), |
| 25655 | 25814 | None, fctx, |
| 25656 | 25815 | )? |
| @@ -25668,7 +25827,7 @@ fn decode_inter_block( | ||
| 25668 | 25827 | cpy, |
| 25669 | 25828 | chroma_side, |
| 25670 | 25829 | base_q_idx, |
| 25671 | - &pred_v, | |
| 25830 | + Pred::dense(&pred_v), | |
| 25672 | 25831 | Some(luma_tx_type), |
| 25673 | 25832 | None, fctx, |
| 25674 | 25833 | )? |
| @@ -26962,7 +27121,7 @@ fn decode_inter_sub8_split4( | ||
| 26962 | 27121 | // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which |
| 26963 | 27122 | // `read_inter_plane`'s `plane_idx == 0` arm already assumes). |
| 26964 | 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 | 27125 | neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]); |
| 26967 | 27126 | } else { |
| 26968 | 27127 | let around = neighbours.around_mi(lmi, B4); |
| @@ -26983,7 +27142,7 @@ fn decode_inter_sub8_split4( | ||
| 26983 | 27142 | py, |
| 26984 | 27143 | B4, |
| 26985 | 27144 | base_q_idx, |
| 26986 | - &pred_y, | |
| 27145 | + Pred::dense(&pred_y), | |
| 26987 | 27146 | None, |
| 26988 | 27147 | None, fctx, |
| 26989 | 27148 | )?; |
| @@ -27077,19 +27236,19 @@ fn decode_inter_sub8_split4( | ||
| 27077 | 27236 | } |
| 27078 | 27237 | } |
| 27079 | 27238 | let (u_grid, v_grid) = if last_skip { |
| 27080 | - push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 27081 | - push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 27239 | + push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx); | |
| 27240 | + push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx); | |
| 27082 | 27241 | (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) |
| 27083 | 27242 | } else { |
| 27084 | 27243 | let around = neighbours.around_mi(group_mi, 8); |
| 27085 | 27244 | let ug = read_inter_plane( |
| 27086 | 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 | 27248 | .0; |
| 27090 | 27249 | let vg = read_inter_plane( |
| 27091 | 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 | 27253 | .0; |
| 27095 | 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 | 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 | 28098 | neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]); |
| 27940 | 28099 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx); |
| 27941 | 28100 | } else { |
| @@ -27971,7 +28130,7 @@ fn decode_inter_sub8_rect2( | ||
| 27971 | 28130 | tu_py, |
| 27972 | 28131 | tw, |
| 27973 | 28132 | base_q_idx, |
| 27974 | - &tu_pred, | |
| 28133 | + Pred::dense(&tu_pred), | |
| 27975 | 28134 | None, |
| 27976 | 28135 | Some(tu_skip_ctx), fctx, |
| 27977 | 28136 | )? |
| @@ -27996,7 +28155,7 @@ fn decode_inter_sub8_rect2( | ||
| 27996 | 28155 | y, |
| 27997 | 28156 | tu_px, |
| 27998 | 28157 | tu_py, |
| 27999 | - &pred_y[start..], | |
| 28158 | + Pred::dense(&pred_y[start..]), | |
| 28000 | 28159 | None, |
| 28001 | 28160 | None, fctx, |
| 28002 | 28161 | )? |
| @@ -28101,19 +28260,19 @@ fn decode_inter_sub8_rect2( | ||
| 28101 | 28260 | } |
| 28102 | 28261 | } |
| 28103 | 28262 | let (u_grid, v_grid) = if last_skip { |
| 28104 | - push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 28105 | - push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 28263 | + push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &vec![0i32; B4 * B4], fctx); | |
| 28264 | + push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &vec![0i32; B4 * B4], fctx); | |
| 28106 | 28265 | (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) |
| 28107 | 28266 | } else { |
| 28108 | 28267 | let around = neighbours.around_mi(group_mi, 8); |
| 28109 | 28268 | let ug = read_inter_plane( |
| 28110 | 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 | 28272 | .0; |
| 28114 | 28273 | let vg = read_inter_plane( |
| 28115 | 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 | 28277 | .0; |
| 28119 | 28278 | let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); |
| @@ -28938,19 +29097,19 @@ fn decode_inter_block8( | ||
| 28938 | 29097 | .1 |
| 28939 | 29098 | .is_some(); |
| 28940 | 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 | 29101 | push_mc(1, |
| 28943 | 29102 | cpx, |
| 28944 | 29103 | cpy, |
| 28945 | 29104 | CHROMA_SIDE, |
| 28946 | - &pred_u, | |
| 29105 | + Pred::dense(&pred_u), | |
| 28947 | 29106 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 28948 | 29107 | ); |
| 28949 | 29108 | push_mc(2, |
| 28950 | 29109 | cpx, |
| 28951 | 29110 | cpy, |
| 28952 | 29111 | CHROMA_SIDE, |
| 28953 | - &pred_v, | |
| 29112 | + Pred::dense(&pred_v), | |
| 28954 | 29113 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 28955 | 29114 | ); |
| 28956 | 29115 | luma_grid = vec![0i32; SIDE * SIDE]; |
| @@ -28966,7 +29125,7 @@ fn decode_inter_block8( | ||
| 28966 | 29125 | y, |
| 28967 | 29126 | px, |
| 28968 | 29127 | py, |
| 28969 | - &pred_y, | |
| 29128 | + Pred::dense(&pred_y), | |
| 28970 | 29129 | mode_for_tx, |
| 28971 | 29130 | base_q_idx, |
| 28972 | 29131 | scan8, |
| @@ -28988,7 +29147,7 @@ fn decode_inter_block8( | ||
| 28988 | 29147 | cpy, |
| 28989 | 29148 | CHROMA_SIDE, |
| 28990 | 29149 | base_q_idx, |
| 28991 | - &pred_u, | |
| 29150 | + Pred::dense(&pred_u), | |
| 28992 | 29151 | Some(luma_tx_type), |
| 28993 | 29152 | None, fctx, |
| 28994 | 29153 | )? |
| @@ -29006,7 +29165,7 @@ fn decode_inter_block8( | ||
| 29006 | 29165 | cpy, |
| 29007 | 29166 | CHROMA_SIDE, |
| 29008 | 29167 | base_q_idx, |
| 29009 | - &pred_v, | |
| 29168 | + Pred::dense(&pred_v), | |
| 29010 | 29169 | Some(luma_tx_type), |
| 29011 | 29170 | None, fctx, |
| 29012 | 29171 | )? |
| @@ -29588,19 +29747,19 @@ fn decode_inter_block8( | ||
| 29588 | 29747 | .1 |
| 29589 | 29748 | .is_some(); |
| 29590 | 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 | 29751 | push_mc(1, |
| 29593 | 29752 | cpx, |
| 29594 | 29753 | cpy, |
| 29595 | 29754 | CHROMA_SIDE, |
| 29596 | - &pred_u, | |
| 29755 | + Pred::dense(&pred_u), | |
| 29597 | 29756 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 29598 | 29757 | ); |
| 29599 | 29758 | push_mc(2, |
| 29600 | 29759 | cpx, |
| 29601 | 29760 | cpy, |
| 29602 | 29761 | CHROMA_SIDE, |
| 29603 | - &pred_v, | |
| 29762 | + Pred::dense(&pred_v), | |
| 29604 | 29763 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 29605 | 29764 | ); |
| 29606 | 29765 | luma_grid = vec![0i32; SIDE * SIDE]; |
| @@ -29616,7 +29775,7 @@ fn decode_inter_block8( | ||
| 29616 | 29775 | y, |
| 29617 | 29776 | px, |
| 29618 | 29777 | py, |
| 29619 | - &pred_y, | |
| 29778 | + Pred::dense(&pred_y), | |
| 29620 | 29779 | mode_for_tx, |
| 29621 | 29780 | base_q_idx, |
| 29622 | 29781 | scan8, |
| @@ -29638,7 +29797,7 @@ fn decode_inter_block8( | ||
| 29638 | 29797 | cpy, |
| 29639 | 29798 | CHROMA_SIDE, |
| 29640 | 29799 | base_q_idx, |
| 29641 | - &pred_u, | |
| 29800 | + Pred::dense(&pred_u), | |
| 29642 | 29801 | Some(luma_tx_type), |
| 29643 | 29802 | None, fctx, |
| 29644 | 29803 | )? |
| @@ -29656,7 +29815,7 @@ fn decode_inter_block8( | ||
| 29656 | 29815 | cpy, |
| 29657 | 29816 | CHROMA_SIDE, |
| 29658 | 29817 | base_q_idx, |
| 29659 | - &pred_v, | |
| 29818 | + Pred::dense(&pred_v), | |
| 29660 | 29819 | Some(luma_tx_type), |
| 29661 | 29820 | None, fctx, |
| 29662 | 29821 | )? |