Entropy parse split from reconstruction inside the tile decoder
Browse files at this commit1499973b1f11767896691f7a1489d62a9da5d4beParent: 1a45793- refactor
- entropy parse split from reconstruction inside the tile decoder
1 changed file +407 -186
- crates/ec-av1/src/decode.rs +407 -186
crates/ec-av1/src/decode.rsmodified+407 -186
| @@ -79,6 +79,9 @@ pub(crate) struct FrameCtx { | ||
| 79 | 79 | pub(crate) last_frame_wide_margin: std::cell::RefCell<Option<Picture>>, |
| 80 | 80 | pub(crate) reach_sb_px: std::cell::Cell<usize>, |
| 81 | 81 | pub(crate) grain_bit_depth: std::cell::Cell<u32>, |
| 82 | + /// lane-wave1 step (i): this superblock's recorded pixel writes, see | |
| 83 | + /// [`ReconOp`]. Pushed by parse, replayed by [`flush_recon`]. | |
| 84 | + pub(crate) recon_ops: std::cell::RefCell<Vec<ReconOp>>, | |
| 82 | 85 | } |
| 83 | 86 | |
| 84 | 87 | impl std::fmt::Debug for FrameCtx { |
| @@ -136,6 +139,7 @@ impl FrameCtx { | ||
| 136 | 139 | last_frame_wide_margin: std::cell::RefCell::new(None), |
| 137 | 140 | reach_sb_px: std::cell::Cell::new(crate::encode::SUPERBLOCK), |
| 138 | 141 | grain_bit_depth: std::cell::Cell::new(8), |
| 142 | + recon_ops: std::cell::RefCell::new(Vec::new()), | |
| 139 | 143 | } |
| 140 | 144 | } |
| 141 | 145 | } |
| @@ -2010,6 +2014,204 @@ fn take_palette_pred(fctx: &crate::decode::FrameCtx) -> Option<Vec<u16>> { | ||
| 2010 | 2014 | got |
| 2011 | 2015 | } |
| 2012 | 2016 | |
| 2017 | +/// The luma window a `UV_CFL_PRED` chroma block averages its AC signal over | |
| 2018 | +/// (lane-wave1 step (i)). Parse records the window; [`flush_recon`] reads the | |
| 2019 | +/// pixels, because at parse time this block's own luma is still queued. | |
| 2020 | +#[derive(Clone, Copy, Debug)] | |
| 2021 | +pub(crate) struct CflSrc { | |
| 2022 | + px: usize, | |
| 2023 | + py: usize, | |
| 2024 | + bw: usize, | |
| 2025 | + bh: usize, | |
| 2026 | + /// Which averager the parse site asked for -- [`cfl_ac_q3_rect`] and | |
| 2027 | + /// [`cfl_ac_q3`] are not the same function at `bw == bh`. | |
| 2028 | + rect: bool, | |
| 2029 | +} | |
| 2030 | + | |
| 2031 | +fn cfl_src(px: usize, py: usize, side: usize) -> CflSrc { | |
| 2032 | + CflSrc { px, py, bw: side, bh: side, rect: false } | |
| 2033 | +} | |
| 2034 | + | |
| 2035 | +fn cfl_src_rect(px: usize, py: usize, bw: usize, bh: usize) -> CflSrc { | |
| 2036 | + CflSrc { px, py, bw, bh, rect: true } | |
| 2037 | +} | |
| 2038 | + | |
| 2039 | +/// lane-wave1 step (i): the pixel-writing half of block decoding, recorded | |
| 2040 | +/// instead of executed. Each variant is the resolved argument tuple of the | |
| 2041 | +/// `PlaneBuf::reconstruct*` call it replaces, so replaying the queue in push | |
| 2042 | +/// order performs exactly the same writes in exactly the same order -- | |
| 2043 | +/// entropy parsing no longer touches the frame's own planes (except the two | |
| 2044 | +/// sites named in [`flush_recon`]'s doc), which is what lets step (ii) run | |
| 2045 | +/// the replay on a superblock-row wavefront worker. | |
| 2046 | +pub(crate) enum ReconOp { | |
| 2047 | + Intra { | |
| 2048 | + plane: usize, | |
| 2049 | + x: usize, | |
| 2050 | + y: usize, | |
| 2051 | + bw: usize, | |
| 2052 | + bh: usize, | |
| 2053 | + /// `true` when the parse site called `reconstruct_rect` (whose | |
| 2054 | + /// `edges_rect` differs from `edges` even at `bw == bh`). | |
| 2055 | + rect: bool, | |
| 2056 | + mode: usize, | |
| 2057 | + angle_delta: i32, | |
| 2058 | + reach: Reach, | |
| 2059 | + residual: Vec<i32>, | |
| 2060 | + cfl: Option<(i32, CflSrc)>, | |
| 2061 | + filter_intra: Option<usize>, | |
| 2062 | + smooth_neighbor: bool, | |
| 2063 | + /// The palette/intrabc prediction override, taken off | |
| 2064 | + /// [`FrameCtx::palette_pred`] at PUSH time (parse order), never read | |
| 2065 | + /// from that slot by the replay. | |
| 2066 | + pred: Option<Vec<u16>>, | |
| 2067 | + }, | |
| 2068 | + Mc { | |
| 2069 | + plane: usize, | |
| 2070 | + x: usize, | |
| 2071 | + y: usize, | |
| 2072 | + stride: usize, | |
| 2073 | + w: usize, | |
| 2074 | + h: usize, | |
| 2075 | + prediction: Vec<u16>, | |
| 2076 | + residual: Vec<i32>, | |
| 2077 | + }, | |
| 2078 | +} | |
| 2079 | + | |
| 2080 | +fn push_op(fctx: &crate::decode::FrameCtx, op: ReconOp) { | |
| 2081 | + fctx.recon_ops.with(|c| c.borrow_mut().push(op)); | |
| 2082 | +} | |
| 2083 | + | |
| 2084 | +/// [`PlaneBuf::reconstruct`], recorded (lane-wave1 step (i)). | |
| 2085 | +#[allow(clippy::too_many_arguments)] | |
| 2086 | +fn push_intra( | |
| 2087 | + plane: usize, | |
| 2088 | + x: usize, | |
| 2089 | + y: usize, | |
| 2090 | + side: usize, | |
| 2091 | + mode: usize, | |
| 2092 | + angle_delta: i32, | |
| 2093 | + reach: Reach, | |
| 2094 | + residual: &[i32], | |
| 2095 | + cfl: Option<(i32, CflSrc)>, | |
| 2096 | + filter_intra: Option<usize>, | |
| 2097 | + smooth_neighbor: bool, fctx: &crate::decode::FrameCtx, | |
| 2098 | +) { | |
| 2099 | + let pred = take_palette_pred(fctx); | |
| 2100 | + push_op(fctx, ReconOp::Intra { | |
| 2101 | + plane, x, y, bw: side, bh: side, rect: false, mode, angle_delta, reach, | |
| 2102 | + residual: residual.to_vec(), cfl, filter_intra, smooth_neighbor, pred, | |
| 2103 | + }); | |
| 2104 | +} | |
| 2105 | + | |
| 2106 | +/// [`PlaneBuf::reconstruct_rect`], recorded (lane-wave1 step (i)). | |
| 2107 | +#[allow(clippy::too_many_arguments)] | |
| 2108 | +fn push_intra_rect( | |
| 2109 | + plane: usize, | |
| 2110 | + x: usize, | |
| 2111 | + y: usize, | |
| 2112 | + bw: usize, | |
| 2113 | + bh: usize, | |
| 2114 | + mode: usize, | |
| 2115 | + angle_delta: i32, | |
| 2116 | + reach: Reach, | |
| 2117 | + residual: &[i32], | |
| 2118 | + cfl: Option<(i32, CflSrc)>, | |
| 2119 | + filter_intra: Option<usize>, | |
| 2120 | + smooth_neighbor: bool, fctx: &crate::decode::FrameCtx, | |
| 2121 | +) { | |
| 2122 | + let pred = take_palette_pred(fctx); | |
| 2123 | + push_op(fctx, ReconOp::Intra { | |
| 2124 | + plane, x, y, bw, bh, rect: true, mode, angle_delta, reach, | |
| 2125 | + residual: residual.to_vec(), cfl, filter_intra, smooth_neighbor, pred, | |
| 2126 | + }); | |
| 2127 | +} | |
| 2128 | + | |
| 2129 | +/// [`PlaneBuf::reconstruct_mc_rect`] at `stride == w == h == side`, recorded. | |
| 2130 | +fn push_mc( | |
| 2131 | + plane: usize, | |
| 2132 | + x: usize, | |
| 2133 | + y: usize, | |
| 2134 | + side: usize, | |
| 2135 | + prediction: &[u16], | |
| 2136 | + residual: &[i32], fctx: &crate::decode::FrameCtx, | |
| 2137 | +) { | |
| 2138 | + push_mc_rect(plane, x, y, side, side, side, prediction, residual, fctx); | |
| 2139 | +} | |
| 2140 | + | |
| 2141 | +/// [`PlaneBuf::reconstruct_mc_rect`], recorded (lane-wave1 step (i)). | |
| 2142 | +#[allow(clippy::too_many_arguments)] | |
| 2143 | +fn push_mc_rect( | |
| 2144 | + plane: usize, | |
| 2145 | + x: usize, | |
| 2146 | + y: usize, | |
| 2147 | + stride: usize, | |
| 2148 | + w: usize, | |
| 2149 | + h: usize, | |
| 2150 | + prediction: &[u16], | |
| 2151 | + residual: &[i32], fctx: &crate::decode::FrameCtx, | |
| 2152 | +) { | |
| 2153 | + push_op(fctx, ReconOp::Mc { | |
| 2154 | + plane, x, y, stride, w, h, | |
| 2155 | + prediction: prediction.to_vec(), residual: residual.to_vec(), | |
| 2156 | + }); | |
| 2157 | +} | |
| 2158 | + | |
| 2159 | +/// Replays every recorded [`ReconOp`] into the frame's planes, in push order, | |
| 2160 | +/// and empties the queue (lane-wave1 step (i)). | |
| 2161 | +/// | |
| 2162 | +/// Called at the top of each superblock visit and at the end of each tile, so | |
| 2163 | +/// a whole superblock's parsing runs with no plane access at all; the two | |
| 2164 | +/// parse-time pixel READS that survive -- the intrabc source fetch and the | |
| 2165 | +/// interintra intra predictor -- flush ahead of themselves instead, which | |
| 2166 | +/// keeps them byte-exact and names exactly what step (ii) still has to move. | |
| 2167 | +fn flush_recon( | |
| 2168 | + fctx: &crate::decode::FrameCtx, | |
| 2169 | + y: &mut PlaneBuf<'static>, | |
| 2170 | + u: &mut PlaneBuf<'static>, | |
| 2171 | + v: &mut PlaneBuf<'static>, | |
| 2172 | +) { | |
| 2173 | + let ops = fctx.recon_ops.with(|c| std::mem::take(&mut *c.borrow_mut())); | |
| 2174 | + for op in ops { | |
| 2175 | + match op { | |
| 2176 | + ReconOp::Intra { | |
| 2177 | + plane, x, y: oy, bw, bh, rect, mode, angle_delta, reach, residual, cfl, | |
| 2178 | + filter_intra, smooth_neighbor, pred, | |
| 2179 | + } => { | |
| 2180 | + // The CfL AC signal is read HERE, off the luma this very | |
| 2181 | + // replay has already written for this block -- at parse time | |
| 2182 | + // it would have been the previous frame's samples. | |
| 2183 | + let ac = cfl.map(|(alpha, src)| { | |
| 2184 | + let sig = if src.rect { | |
| 2185 | + cfl_ac_q3_rect(&*y, src.px, src.py, src.bw, src.bh) | |
| 2186 | + } else { | |
| 2187 | + cfl_ac_q3(&*y, src.px, src.py, src.bw) | |
| 2188 | + }; | |
| 2189 | + (alpha, sig) | |
| 2190 | + }); | |
| 2191 | + let cfl = ac.as_ref().map(|(a, sig)| (*a, sig.as_slice())); | |
| 2192 | + let target: &mut PlaneBuf<'static> = | |
| 2193 | + match plane { 0 => &mut *y, 1 => &mut *u, _ => &mut *v }; | |
| 2194 | + if rect { | |
| 2195 | + target.reconstruct_rect( | |
| 2196 | + x, oy, bw, bh, mode, angle_delta, reach, &residual, cfl, filter_intra, | |
| 2197 | + smooth_neighbor, pred, fctx, | |
| 2198 | + ); | |
| 2199 | + } else { | |
| 2200 | + target.reconstruct( | |
| 2201 | + x, oy, bw, mode, angle_delta, reach, &residual, cfl, filter_intra, | |
| 2202 | + smooth_neighbor, pred, fctx, | |
| 2203 | + ); | |
| 2204 | + } | |
| 2205 | + } | |
| 2206 | + ReconOp::Mc { plane, x, y: oy, stride, w, h, prediction, residual } => { | |
| 2207 | + let target: &mut PlaneBuf<'static> = | |
| 2208 | + match plane { 0 => &mut *y, 1 => &mut *u, _ => &mut *v }; | |
| 2209 | + target.reconstruct_mc_rect(x, oy, stride, w, h, &prediction, &residual, fctx); | |
| 2210 | + } | |
| 2211 | + } | |
| 2212 | + } | |
| 2213 | +} | |
| 2214 | + | |
| 2013 | 2215 | thread_local! { |
| 2014 | 2216 | /// The current frame's `mi` grid, kept only while a frame header set |
| 2015 | 2217 | /// `allow_intrabc` -- an intrabc block's DV predictor is the ordinary |
| @@ -7693,7 +7895,7 @@ fn decode_rect_split( | ||
| 7693 | 7895 | set_palette_pred(tu_buf, fctx); |
| 7694 | 7896 | } |
| 7695 | 7897 | if m.skip { |
| 7696 | - y.reconstruct_rect( | |
| 7898 | + push_intra_rect(0, | |
| 7697 | 7899 | tu_px, |
| 7698 | 7900 | tu_py, |
| 7699 | 7901 | tx_w, |
| @@ -7751,7 +7953,7 @@ fn decode_rect_split( | ||
| 7751 | 7953 | plane_q_delta(0, fctx).1, |
| 7752 | 7954 | tu_tx_type, |
| 7753 | 7955 | ); |
| 7754 | - y.reconstruct_rect( | |
| 7956 | + push_intra_rect(0, | |
| 7755 | 7957 | tu_px, |
| 7756 | 7958 | tu_py, |
| 7757 | 7959 | tx_w, |
| @@ -7807,7 +8009,7 @@ fn decode_rect_split( | ||
| 7807 | 8009 | plane_q_delta(0, fctx).1, |
| 7808 | 8010 | tu_tx_type, |
| 7809 | 8011 | ); |
| 7810 | - y.reconstruct_rect( | |
| 8012 | + push_intra_rect(0, | |
| 7811 | 8013 | tu_px, |
| 7812 | 8014 | tu_py, |
| 7813 | 8015 | tx_w, |
| @@ -7854,23 +8056,23 @@ fn decode_rect_split( | ||
| 7854 | 8056 | } |
| 7855 | 8057 | } |
| 7856 | 8058 | // CHROMA: one un-split rect transform for the whole strip. |
| 7857 | - let ac = m.alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 8059 | + let ac = m.alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 7858 | 8060 | let reach = block_reach; |
| 7859 | 8061 | let (u_grid, v_grid) = if m.skip { |
| 7860 | 8062 | let zero = vec![0i32; chroma_w * chroma_h]; |
| 7861 | 8063 | if let Some((ub, _)) = &m.palette_uv { |
| 7862 | 8064 | set_palette_pred(ub.clone(), fctx); |
| 7863 | 8065 | } |
| 7864 | - u.reconstruct_rect( | |
| 8066 | + push_intra_rect(1, | |
| 7865 | 8067 | cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, |
| 7866 | - m.alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, | |
| 8068 | + m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, | |
| 7867 | 8069 | ); |
| 7868 | 8070 | if let Some((_, vb)) = &m.palette_uv { |
| 7869 | 8071 | set_palette_pred(vb.clone(), fctx); |
| 7870 | 8072 | } |
| 7871 | - v.reconstruct_rect( | |
| 8073 | + push_intra_rect(2, | |
| 7872 | 8074 | cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, |
| 7873 | - m.alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, | |
| 8075 | + m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, | |
| 7874 | 8076 | ); |
| 7875 | 8077 | (zero.clone(), zero) |
| 7876 | 8078 | } else { |
| @@ -7918,14 +8120,14 @@ fn decode_rect_split( | ||
| 7918 | 8120 | ); |
| 7919 | 8121 | let cfl = m |
| 7920 | 8122 | .alpha |
| 7921 | - .zip(ac.as_deref()) | |
| 8123 | + .zip(ac) | |
| 7922 | 8124 | .map(|((au, av), ac)| (if plane_idx == 1 { au } else { av }, ac)); |
| 7923 | - let plane = if plane_idx == 1 { &mut *u } else { &mut *v }; | |
| 8125 | + let _plane = if plane_idx == 1 { &mut *u } else { &mut *v }; | |
| 7924 | 8126 | if let Some((ub, vb)) = &m.palette_uv { |
| 7925 | 8127 | let buf = if plane_idx == 1 { ub } else { vb }; |
| 7926 | 8128 | set_palette_pred(buf.clone(), fctx); |
| 7927 | 8129 | } |
| 7928 | - plane.reconstruct_rect( | |
| 8130 | + push_intra_rect(plane_idx, | |
| 7929 | 8131 | cpx, |
| 7930 | 8132 | cpy, |
| 7931 | 8133 | chroma_w, |
| @@ -8888,7 +9090,7 @@ fn decode_block_rect( | ||
| 8888 | 9090 | ) |
| 8889 | 9091 | }); |
| 8890 | 9092 | if skip { |
| 8891 | - y.reconstruct_rect( | |
| 9093 | + push_intra_rect(0, | |
| 8892 | 9094 | px, |
| 8893 | 9095 | py, |
| 8894 | 9096 | bw, |
| @@ -8901,11 +9103,11 @@ fn decode_block_rect( | ||
| 8901 | 9103 | filter_intra, |
| 8902 | 9104 | smooth_neighbor, fctx, |
| 8903 | 9105 | ); |
| 8904 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 9106 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 8905 | 9107 | if let Some((ub, _)) = &palette_uv_bufs { |
| 8906 | 9108 | set_palette_pred(ub.clone(), fctx); |
| 8907 | 9109 | } |
| 8908 | - u.reconstruct_rect( | |
| 9110 | + push_intra_rect(1, | |
| 8909 | 9111 | cpx, |
| 8910 | 9112 | cpy, |
| 8911 | 9113 | chroma_w, |
| @@ -8914,14 +9116,14 @@ fn decode_block_rect( | ||
| 8914 | 9116 | angle_delta_uv, |
| 8915 | 9117 | reach, |
| 8916 | 9118 | &vec![0i32; chroma_w * chroma_h], |
| 8917 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 9119 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 8918 | 9120 | None, |
| 8919 | 9121 | smooth_neighbor_uv, fctx, |
| 8920 | 9122 | ); |
| 8921 | 9123 | if let Some((_, vb)) = &palette_uv_bufs { |
| 8922 | 9124 | set_palette_pred(vb.clone(), fctx); |
| 8923 | 9125 | } |
| 8924 | - v.reconstruct_rect( | |
| 9126 | + push_intra_rect(2, | |
| 8925 | 9127 | cpx, |
| 8926 | 9128 | cpy, |
| 8927 | 9129 | chroma_w, |
| @@ -8930,7 +9132,7 @@ fn decode_block_rect( | ||
| 8930 | 9132 | angle_delta_uv, |
| 8931 | 9133 | reach, |
| 8932 | 9134 | &vec![0i32; chroma_w * chroma_h], |
| 8933 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 9135 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 8934 | 9136 | None, |
| 8935 | 9137 | smooth_neighbor_uv, fctx, |
| 8936 | 9138 | ); |
| @@ -9018,7 +9220,7 @@ fn decode_block_rect( | ||
| 9018 | 9220 | plane_q_delta(0, fctx).1, |
| 9019 | 9221 | luma_tx_type, |
| 9020 | 9222 | ); |
| 9021 | - y.reconstruct_rect( | |
| 9223 | + push_intra_rect(0, | |
| 9022 | 9224 | px, |
| 9023 | 9225 | py, |
| 9024 | 9226 | bw, |
| @@ -9031,7 +9233,7 @@ fn decode_block_rect( | ||
| 9031 | 9233 | filter_intra, |
| 9032 | 9234 | smooth_neighbor, fctx, |
| 9033 | 9235 | ); |
| 9034 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 9236 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 9035 | 9237 | if let Some((ub, _)) = &palette_uv_bufs { |
| 9036 | 9238 | set_palette_pred(ub.clone(), fctx); |
| 9037 | 9239 | } |
| @@ -9062,7 +9264,7 @@ fn decode_block_rect( | ||
| 9062 | 9264 | plane_q_delta(1, fctx).1, |
| 9063 | 9265 | u_tx_type, |
| 9064 | 9266 | ); |
| 9065 | - u.reconstruct_rect( | |
| 9267 | + push_intra_rect(1, | |
| 9066 | 9268 | cpx, |
| 9067 | 9269 | cpy, |
| 9068 | 9270 | chroma_w, |
| @@ -9071,7 +9273,7 @@ fn decode_block_rect( | ||
| 9071 | 9273 | angle_delta_uv, |
| 9072 | 9274 | reach, |
| 9073 | 9275 | &u_residual, |
| 9074 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 9276 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 9075 | 9277 | None, |
| 9076 | 9278 | smooth_neighbor_uv, fctx, |
| 9077 | 9279 | ); |
| @@ -9105,7 +9307,7 @@ fn decode_block_rect( | ||
| 9105 | 9307 | plane_q_delta(2, fctx).1, |
| 9106 | 9308 | v_tx_type, |
| 9107 | 9309 | ); |
| 9108 | - v.reconstruct_rect( | |
| 9310 | + push_intra_rect(2, | |
| 9109 | 9311 | cpx, |
| 9110 | 9312 | cpy, |
| 9111 | 9313 | chroma_w, |
| @@ -9114,7 +9316,7 @@ fn decode_block_rect( | ||
| 9114 | 9316 | angle_delta_uv, |
| 9115 | 9317 | reach, |
| 9116 | 9318 | &v_residual, |
| 9117 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 9319 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 9118 | 9320 | None, |
| 9119 | 9321 | smooth_neighbor_uv, fctx, |
| 9120 | 9322 | ); |
| @@ -9359,24 +9561,24 @@ fn decode_leaf_rect( | ||
| 9359 | 9561 | if let Some(b) = &palette_y_buf { |
| 9360 | 9562 | set_palette_pred(b.clone(), fctx); |
| 9361 | 9563 | } |
| 9362 | - y.reconstruct_rect( | |
| 9564 | + push_intra_rect(0, | |
| 9363 | 9565 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra, |
| 9364 | 9566 | smooth_neighbor, fctx, |
| 9365 | 9567 | ); |
| 9366 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 9568 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 9367 | 9569 | if let Some((ub, _)) = &palette_uv_bufs { |
| 9368 | 9570 | set_palette_pred(ub.clone(), fctx); |
| 9369 | 9571 | } |
| 9370 | - u.reconstruct_rect( | |
| 9572 | + push_intra_rect(1, | |
| 9371 | 9573 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels, |
| 9372 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx, | |
| 9574 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx, | |
| 9373 | 9575 | ); |
| 9374 | 9576 | if let Some((_, vb)) = &palette_uv_bufs { |
| 9375 | 9577 | set_palette_pred(vb.clone(), fctx); |
| 9376 | 9578 | } |
| 9377 | - v.reconstruct_rect( | |
| 9579 | + push_intra_rect(2, | |
| 9378 | 9580 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels, |
| 9379 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, | |
| 9581 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, | |
| 9380 | 9582 | ); |
| 9381 | 9583 | } else { |
| 9382 | 9584 | // lane-rectx: a genuine 16x8/8x16 luma transform (`TxbSet::LumaRect16x8`, |
| @@ -9412,11 +9614,11 @@ fn decode_leaf_rect( | ||
| 9412 | 9614 | if let Some(b) = &palette_y_buf { |
| 9413 | 9615 | set_palette_pred(b.clone(), fctx); |
| 9414 | 9616 | } |
| 9415 | - y.reconstruct_rect( | |
| 9617 | + push_intra_rect(0, | |
| 9416 | 9618 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra, |
| 9417 | 9619 | smooth_neighbor, fctx, |
| 9418 | 9620 | ); |
| 9419 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 9621 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 9420 | 9622 | let u_default_tx = default_intra_tx_type(uv_predict_mode as u8); |
| 9421 | 9623 | let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); |
| 9422 | 9624 | let mut u_coding = cdfs.txb(TxbSet::ChromaRect8x4, uv_predict_mode); |
| @@ -9432,9 +9634,9 @@ fn decode_leaf_rect( | ||
| 9432 | 9634 | if let Some((ub, _)) = &palette_uv_bufs { |
| 9433 | 9635 | set_palette_pred(ub.clone(), fctx); |
| 9434 | 9636 | } |
| 9435 | - u.reconstruct_rect( | |
| 9637 | + push_intra_rect(1, | |
| 9436 | 9638 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual, |
| 9437 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx, | |
| 9639 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx, | |
| 9438 | 9640 | ); |
| 9439 | 9641 | let v_default_tx = default_intra_tx_type(uv_predict_mode as u8); |
| 9440 | 9642 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); |
| @@ -9451,9 +9653,9 @@ fn decode_leaf_rect( | ||
| 9451 | 9653 | if let Some((_, vb)) = &palette_uv_bufs { |
| 9452 | 9654 | set_palette_pred(vb.clone(), fctx); |
| 9453 | 9655 | } |
| 9454 | - v.reconstruct_rect( | |
| 9656 | + push_intra_rect(2, | |
| 9455 | 9657 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, |
| 9456 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, | |
| 9658 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx, | |
| 9457 | 9659 | ); |
| 9458 | 9660 | RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1)); |
| 9459 | 9661 | } |
| @@ -9798,7 +10000,7 @@ fn decode_block_rect4( | ||
| 9798 | 10000 | if let Some(b) = &palette_y_buf { |
| 9799 | 10001 | set_palette_pred(b.clone(), fctx); |
| 9800 | 10002 | } |
| 9801 | - y.reconstruct_rect( | |
| 10003 | + push_intra_rect(0, | |
| 9802 | 10004 | px, |
| 9803 | 10005 | py, |
| 9804 | 10006 | bw, |
| @@ -9811,8 +10013,8 @@ fn decode_block_rect4( | ||
| 9811 | 10013 | filter_intra, |
| 9812 | 10014 | smooth_neighbor, fctx, |
| 9813 | 10015 | ); |
| 9814 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 9815 | - for (plane, buf, levels, tx_type) in [ | |
| 10016 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 10017 | + for (plane, _buf, levels, tx_type) in [ | |
| 9816 | 10018 | (1usize, &mut *u, &u_levels, u_tx_type), |
| 9817 | 10019 | (2, &mut *v, &v_levels, v_tx_type), |
| 9818 | 10020 | ] { |
| @@ -9829,7 +10031,7 @@ fn decode_block_rect4( | ||
| 9829 | 10031 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 9830 | 10032 | set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx); |
| 9831 | 10033 | } |
| 9832 | - buf.reconstruct_rect( | |
| 10034 | + push_intra_rect(plane, | |
| 9833 | 10035 | cpx, |
| 9834 | 10036 | cpy, |
| 9835 | 10037 | chroma_w, |
| @@ -9839,7 +10041,7 @@ fn decode_block_rect4( | ||
| 9839 | 10041 | reach, |
| 9840 | 10042 | &residual, |
| 9841 | 10043 | alpha |
| 9842 | - .zip(ac.as_deref()) | |
| 10044 | + .zip(ac) | |
| 9843 | 10045 | .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), |
| 9844 | 10046 | None, |
| 9845 | 10047 | smooth_neighbor_uv, fctx, |
| @@ -9874,7 +10076,7 @@ fn decode_block_rect4( | ||
| 9874 | 10076 | if let Some(b) = &palette_y_buf { |
| 9875 | 10077 | set_palette_pred(b.clone(), fctx); |
| 9876 | 10078 | } |
| 9877 | - y.reconstruct_rect( | |
| 10079 | + push_intra_rect(0, | |
| 9878 | 10080 | px, |
| 9879 | 10081 | py, |
| 9880 | 10082 | bw, |
| @@ -9887,11 +10089,11 @@ fn decode_block_rect4( | ||
| 9887 | 10089 | filter_intra, |
| 9888 | 10090 | smooth_neighbor, fctx, |
| 9889 | 10091 | ); |
| 9890 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 10092 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 9891 | 10093 | if let Some((ub, _)) = &palette_uv_bufs { |
| 9892 | 10094 | set_palette_pred(ub.clone(), fctx); |
| 9893 | 10095 | } |
| 9894 | - u.reconstruct_rect( | |
| 10096 | + push_intra_rect(1, | |
| 9895 | 10097 | cpx, |
| 9896 | 10098 | cpy, |
| 9897 | 10099 | chroma_w, |
| @@ -9900,14 +10102,14 @@ fn decode_block_rect4( | ||
| 9900 | 10102 | angle_delta_uv, |
| 9901 | 10103 | reach, |
| 9902 | 10104 | &u_levels, |
| 9903 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 10105 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 9904 | 10106 | None, |
| 9905 | 10107 | smooth_neighbor_uv, fctx, |
| 9906 | 10108 | ); |
| 9907 | 10109 | if let Some((_, vb)) = &palette_uv_bufs { |
| 9908 | 10110 | set_palette_pred(vb.clone(), fctx); |
| 9909 | 10111 | } |
| 9910 | - v.reconstruct_rect( | |
| 10112 | + push_intra_rect(2, | |
| 9911 | 10113 | cpx, |
| 9912 | 10114 | cpy, |
| 9913 | 10115 | chroma_w, |
| @@ -9916,7 +10118,7 @@ fn decode_block_rect4( | ||
| 9916 | 10118 | angle_delta_uv, |
| 9917 | 10119 | reach, |
| 9918 | 10120 | &v_levels, |
| 9919 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 10121 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 9920 | 10122 | None, |
| 9921 | 10123 | smooth_neighbor_uv, fctx, |
| 9922 | 10124 | ); |
| @@ -10200,7 +10402,7 @@ fn decode_rect4_16_strip( | ||
| 10200 | 10402 | set_palette_pred(tu_buf, fctx); |
| 10201 | 10403 | } |
| 10202 | 10404 | if skip { |
| 10203 | - y.reconstruct_rect( | |
| 10405 | + push_intra_rect(0, | |
| 10204 | 10406 | tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu, |
| 10205 | 10407 | None, filter_intra, smooth_neighbor, fctx, |
| 10206 | 10408 | ); |
| @@ -10239,7 +10441,7 @@ fn decode_rect4_16_strip( | ||
| 10239 | 10441 | plane_q_delta(0, fctx).1, |
| 10240 | 10442 | tu_tx_type, |
| 10241 | 10443 | ); |
| 10242 | - y.reconstruct_rect( | |
| 10444 | + push_intra_rect(0, | |
| 10243 | 10445 | tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &residual, |
| 10244 | 10446 | None, filter_intra, smooth_neighbor, fctx, |
| 10245 | 10447 | ); |
| @@ -10285,7 +10487,7 @@ fn decode_rect4_16_strip( | ||
| 10285 | 10487 | if let Some(b) = &palette_y_buf { |
| 10286 | 10488 | set_palette_pred(b.clone(), fctx); |
| 10287 | 10489 | } |
| 10288 | - y.reconstruct_rect( | |
| 10490 | + push_intra_rect(0, | |
| 10289 | 10491 | px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, |
| 10290 | 10492 | smooth_neighbor, fctx, |
| 10291 | 10493 | ); |
| @@ -10324,7 +10526,7 @@ fn decode_rect4_16_strip( | ||
| 10324 | 10526 | if let Some(b) = &palette_y_buf { |
| 10325 | 10527 | set_palette_pred(b.clone(), fctx); |
| 10326 | 10528 | } |
| 10327 | - y.reconstruct_rect( | |
| 10529 | + push_intra_rect(0, | |
| 10328 | 10530 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 10329 | 10531 | smooth_neighbor, fctx, |
| 10330 | 10532 | ); |
| @@ -10388,15 +10590,15 @@ fn decode_rect4_16_strip( | ||
| 10388 | 10590 | // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still |
| 10389 | 10591 | // DC + alpha * luma-AC. Dropping the CfL term here left a |
| 10390 | 10592 | // chroma-only bounded box on ReelC's key frames. |
| 10391 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | |
| 10593 | + let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); | |
| 10392 | 10594 | if alpha.is_some() { |
| 10393 | 10595 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 10394 | 10596 | } |
| 10395 | - for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | |
| 10597 | + for (_buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | |
| 10396 | 10598 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 10397 | 10599 | set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx); |
| 10398 | 10600 | } |
| 10399 | - buf.reconstruct_rect( | |
| 10601 | + push_intra_rect(plane, | |
| 10400 | 10602 | cpx, |
| 10401 | 10603 | cpy, |
| 10402 | 10604 | cw, |
| @@ -10406,7 +10608,7 @@ fn decode_rect4_16_strip( | ||
| 10406 | 10608 | pair_reach, |
| 10407 | 10609 | &zeros, |
| 10408 | 10610 | alpha |
| 10409 | - .zip(ac.as_deref()) | |
| 10611 | + .zip(ac) | |
| 10410 | 10612 | .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), |
| 10411 | 10613 | None, |
| 10412 | 10614 | smooth_neighbor_uv, fctx, |
| @@ -10436,8 +10638,8 @@ fn decode_rect4_16_strip( | ||
| 10436 | 10638 | let (u_levels, u_tx_type) = planes.pop().expect("plane 1"); |
| 10437 | 10639 | // CfL averages the luma of the WHOLE pair, the region this one |
| 10438 | 10640 | // chroma transform covers. |
| 10439 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | |
| 10440 | - for (plane, buf, levels, tx_type) in [ | |
| 10641 | + let ac = alpha.map(|_| cfl_src_rect(ppx, ppy, pw, ph)); | |
| 10642 | + for (plane, _buf, levels, tx_type) in [ | |
| 10441 | 10643 | (1usize, &mut *u, &u_levels, u_tx_type), |
| 10442 | 10644 | (2, &mut *v, &v_levels, v_tx_type), |
| 10443 | 10645 | ] { |
| @@ -10454,7 +10656,7 @@ fn decode_rect4_16_strip( | ||
| 10454 | 10656 | if let Some((ub, vb)) = &palette_uv_bufs { |
| 10455 | 10657 | set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }, fctx); |
| 10456 | 10658 | } |
| 10457 | - buf.reconstruct_rect( | |
| 10659 | + push_intra_rect(plane, | |
| 10458 | 10660 | cpx, |
| 10459 | 10661 | cpy, |
| 10460 | 10662 | cw, |
| @@ -10464,7 +10666,7 @@ fn decode_rect4_16_strip( | ||
| 10464 | 10666 | pair_reach, |
| 10465 | 10667 | &residual, |
| 10466 | 10668 | alpha |
| 10467 | - .zip(ac.as_deref()) | |
| 10669 | + .zip(ac) | |
| 10468 | 10670 | .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), |
| 10469 | 10671 | None, |
| 10470 | 10672 | smooth_neighbor_uv, fctx, |
| @@ -10757,7 +10959,7 @@ fn decode_block_rect64( | ||
| 10757 | 10959 | ) |
| 10758 | 10960 | }); |
| 10759 | 10961 | if skip { |
| 10760 | - y.reconstruct_rect( | |
| 10962 | + push_intra_rect(0, | |
| 10761 | 10963 | px, |
| 10762 | 10964 | py, |
| 10763 | 10965 | bw, |
| @@ -10770,11 +10972,11 @@ fn decode_block_rect64( | ||
| 10770 | 10972 | filter_intra, |
| 10771 | 10973 | smooth_neighbor, fctx, |
| 10772 | 10974 | ); |
| 10773 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 10975 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 10774 | 10976 | if let Some((ub, _)) = &palette_uv_bufs { |
| 10775 | 10977 | set_palette_pred(ub.clone(), fctx); |
| 10776 | 10978 | } |
| 10777 | - u.reconstruct_rect( | |
| 10979 | + push_intra_rect(1, | |
| 10778 | 10980 | cpx, |
| 10779 | 10981 | cpy, |
| 10780 | 10982 | chroma_w, |
| @@ -10783,14 +10985,14 @@ fn decode_block_rect64( | ||
| 10783 | 10985 | angle_delta_uv, |
| 10784 | 10986 | reach, |
| 10785 | 10987 | &vec![0i32; chroma_w * chroma_h], |
| 10786 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 10988 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 10787 | 10989 | None, |
| 10788 | 10990 | smooth_neighbor_uv, fctx, |
| 10789 | 10991 | ); |
| 10790 | 10992 | if let Some((_, vb)) = &palette_uv_bufs { |
| 10791 | 10993 | set_palette_pred(vb.clone(), fctx); |
| 10792 | 10994 | } |
| 10793 | - v.reconstruct_rect( | |
| 10995 | + push_intra_rect(2, | |
| 10794 | 10996 | cpx, |
| 10795 | 10997 | cpy, |
| 10796 | 10998 | chroma_w, |
| @@ -10799,7 +11001,7 @@ fn decode_block_rect64( | ||
| 10799 | 11001 | angle_delta_uv, |
| 10800 | 11002 | reach, |
| 10801 | 11003 | &vec![0i32; chroma_w * chroma_h], |
| 10802 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 11004 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 10803 | 11005 | None, |
| 10804 | 11006 | smooth_neighbor_uv, fctx, |
| 10805 | 11007 | ); |
| @@ -10896,7 +11098,7 @@ fn decode_block_rect64( | ||
| 10896 | 11098 | plane_q_delta(0, fctx).1, |
| 10897 | 11099 | luma_tx_type, |
| 10898 | 11100 | ); |
| 10899 | - y.reconstruct_rect( | |
| 11101 | + push_intra_rect(0, | |
| 10900 | 11102 | px, |
| 10901 | 11103 | py, |
| 10902 | 11104 | bw, |
| @@ -10925,7 +11127,7 @@ fn decode_block_rect64( | ||
| 10925 | 11127 | } |
| 10926 | 11128 | // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no |
| 10927 | 11129 | // corner crop needed (see doc comment). |
| 10928 | - let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | |
| 11130 | + let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | |
| 10929 | 11131 | // The chroma plane is never truncated (both axes <= 32 after |
| 10930 | 11132 | // subsampling). Under a 1:4 strip it is a true 32x8/8x32: |
| 10931 | 11133 | // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 = |
| @@ -10989,7 +11191,7 @@ fn decode_block_rect64( | ||
| 10989 | 11191 | if let Some((ub, _)) = &palette_uv_bufs { |
| 10990 | 11192 | set_palette_pred(ub.clone(), fctx); |
| 10991 | 11193 | } |
| 10992 | - u.reconstruct_rect( | |
| 11194 | + push_intra_rect(1, | |
| 10993 | 11195 | cpx, |
| 10994 | 11196 | cpy, |
| 10995 | 11197 | chroma_w, |
| @@ -10998,7 +11200,7 @@ fn decode_block_rect64( | ||
| 10998 | 11200 | angle_delta_uv, |
| 10999 | 11201 | reach, |
| 11000 | 11202 | &u_residual, |
| 11001 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 11203 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 11002 | 11204 | None, |
| 11003 | 11205 | smooth_neighbor_uv, fctx, |
| 11004 | 11206 | ); |
| @@ -11046,7 +11248,7 @@ fn decode_block_rect64( | ||
| 11046 | 11248 | if let Some((_, vb)) = &palette_uv_bufs { |
| 11047 | 11249 | set_palette_pred(vb.clone(), fctx); |
| 11048 | 11250 | } |
| 11049 | - v.reconstruct_rect( | |
| 11251 | + push_intra_rect(2, | |
| 11050 | 11252 | cpx, |
| 11051 | 11253 | cpy, |
| 11052 | 11254 | chroma_w, |
| @@ -11055,7 +11257,7 @@ fn decode_block_rect64( | ||
| 11055 | 11257 | angle_delta_uv, |
| 11056 | 11258 | reach, |
| 11057 | 11259 | &v_residual, |
| 11058 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 11260 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 11059 | 11261 | None, |
| 11060 | 11262 | smooth_neighbor_uv, fctx, |
| 11061 | 11263 | ); |
| @@ -11719,12 +11921,16 @@ impl PlaneBuf<'_> { | ||
| 11719 | 11921 | residual: &[i32], |
| 11720 | 11922 | cfl: Option<(i32, &[i32])>, |
| 11721 | 11923 | filter_intra: Option<usize>, |
| 11722 | - smooth_neighbor: bool, fctx: &crate::decode::FrameCtx, | |
| 11924 | + smooth_neighbor: bool, | |
| 11925 | + // lane-wave1 step (i): the palette/intrabc prediction override, taken | |
| 11926 | + // off `FrameCtx::palette_pred` by the PUSH site (parse order) rather | |
| 11927 | + // than by this replay. | |
| 11928 | + pred: Option<Vec<u16>>, fctx: &crate::decode::FrameCtx, | |
| 11723 | 11929 | ) { |
| 11724 | 11930 | // As [`Self::reconstruct`]'s own [`PALETTE_PRED`] override |
| 11725 | 11931 | // (lane-palette2 r4): a palette block's prediction is the |
| 11726 | 11932 | // reconstructed colour-index map, needing no edge pixels at all. |
| 11727 | - let prediction = if let Some(buf) = take_palette_pred(fctx) { | |
| 11933 | + let prediction = if let Some(buf) = pred { | |
| 11728 | 11934 | buf |
| 11729 | 11935 | } else { |
| 11730 | 11936 | let (above, left, corner) = self.edges_rect(x, y, bw, bh, reach); |
| @@ -11823,12 +12029,16 @@ impl PlaneBuf<'_> { | ||
| 11823 | 12029 | // callers until a smooth/paeth `uv_mode` can reach this call at all |
| 11824 | 12030 | // (still refused in `read_intra_mode`/`read_intra_mode_rect`), which |
| 11825 | 12031 | // keeps `false` exact for chroma without this fn needing to know why. |
| 11826 | - smooth_neighbor: bool, fctx: &crate::decode::FrameCtx, | |
| 12032 | + smooth_neighbor: bool, | |
| 12033 | + // lane-wave1 step (i): the palette/intrabc prediction override, taken | |
| 12034 | + // off `FrameCtx::palette_pred` by the PUSH site (parse order) rather | |
| 12035 | + // than by this replay. | |
| 12036 | + pred: Option<Vec<u16>>, fctx: &crate::decode::FrameCtx, | |
| 11827 | 12037 | ) { |
| 11828 | 12038 | // A palette block's own [`PALETTE_PRED`] override (lane-palette r2) |
| 11829 | 12039 | // takes priority over `predict()`/`predict_filter_intra` entirely -- |
| 11830 | 12040 | // palette prediction needs no edge pixels at all. |
| 11831 | - let prediction = if let Some(buf) = take_palette_pred(fctx) { | |
| 12041 | + let prediction = if let Some(buf) = pred { | |
| 11832 | 12042 | buf |
| 11833 | 12043 | } else { |
| 11834 | 12044 | let (above, left, corner) = self.edges(x, y, side, reach); |
| @@ -11922,13 +12132,17 @@ fn read_plane( | ||
| 11922 | 12132 | predict_mode: usize, |
| 11923 | 12133 | angle_delta: i32, |
| 11924 | 12134 | reach: Reach, |
| 11925 | - plane: &mut PlaneBuf<'static>, | |
| 12135 | + // lane-wave1 step (i): unread -- this reader records its write | |
| 12136 | + // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow | |
| 12137 | + // stays in the signature so every call site still proves the plane is | |
| 12138 | + // exclusively held while its coefficients are parsed. | |
| 12139 | + _plane: &mut PlaneBuf<'static>, | |
| 11926 | 12140 | x: usize, |
| 11927 | 12141 | y: usize, |
| 11928 | 12142 | side: usize, |
| 11929 | 12143 | tx_side: usize, |
| 11930 | 12144 | base_q_idx: u8, |
| 11931 | - cfl: Option<(i32, &[i32])>, | |
| 12145 | + cfl: Option<(i32, CflSrc)>, | |
| 11932 | 12146 | filter_intra: Option<usize>, |
| 11933 | 12147 | // Only meaningful for `plane_idx == 0`: `Some` when this transform unit is |
| 11934 | 12148 | // smaller than its own block (spec `get_txb_ctx_general`'s |
| @@ -12019,7 +12233,7 @@ fn read_plane( | ||
| 12019 | 12233 | "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}", |
| 12020 | 12234 | ); |
| 12021 | 12235 | } |
| 12022 | - plane.reconstruct( | |
| 12236 | + push_intra(plane_idx, | |
| 12023 | 12237 | x, |
| 12024 | 12238 | y, |
| 12025 | 12239 | side, |
| @@ -12215,6 +12429,7 @@ fn decode_block( | ||
| 12215 | 12429 | // block vector, with the BILINEAR kernel libaom forces for intrabc -- |
| 12216 | 12430 | // luma is a straight copy, chroma lands half-pel whenever the luma DV is |
| 12217 | 12431 | // odd, which is exactly what the bilinear taps then interpolate. |
| 12432 | + flush_recon(fctx, y, u, v); | |
| 12218 | 12433 | let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| { |
| 12219 | 12434 | let mut yb = vec![0u16; side * side]; |
| 12220 | 12435 | mc::predict_with_filter( |
| @@ -12333,7 +12548,7 @@ fn decode_block( | ||
| 12333 | 12548 | y.width, |
| 12334 | 12549 | y.height, fctx, |
| 12335 | 12550 | ); |
| 12336 | - y.reconstruct( | |
| 12551 | + push_intra(0, | |
| 12337 | 12552 | tu_px, |
| 12338 | 12553 | tu_py, |
| 12339 | 12554 | logical_tx, |
| @@ -12348,7 +12563,7 @@ fn decode_block( | ||
| 12348 | 12563 | } |
| 12349 | 12564 | } |
| 12350 | 12565 | } else { |
| 12351 | - y.reconstruct( | |
| 12566 | + push_intra(0, | |
| 12352 | 12567 | px, |
| 12353 | 12568 | py, |
| 12354 | 12569 | side, |
| @@ -12361,7 +12576,7 @@ fn decode_block( | ||
| 12361 | 12576 | smooth_neighbor, fctx, |
| 12362 | 12577 | ); |
| 12363 | 12578 | } |
| 12364 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | |
| 12579 | + let ac = alpha.map(|_| cfl_src(px, py, side)); | |
| 12365 | 12580 | let cn = (chroma_side / chroma_tx).max(1); |
| 12366 | 12581 | for cu_row in 0..cn { |
| 12367 | 12582 | for cu_col in 0..cn { |
| @@ -12379,7 +12594,7 @@ fn decode_block( | ||
| 12379 | 12594 | if let Some((ub, _)) = &palette_uv_bufs { |
| 12380 | 12595 | set_palette_pred(ub.clone(), fctx); |
| 12381 | 12596 | } |
| 12382 | - u.reconstruct( | |
| 12597 | + push_intra(1, | |
| 12383 | 12598 | cu_x, |
| 12384 | 12599 | cu_y, |
| 12385 | 12600 | chroma_tx, |
| @@ -12387,14 +12602,14 @@ fn decode_block( | ||
| 12387 | 12602 | angle_delta_uv, |
| 12388 | 12603 | cu_r, |
| 12389 | 12604 | &vec![0i32; chroma_tx * chroma_tx], |
| 12390 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 12605 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 12391 | 12606 | None, |
| 12392 | 12607 | smooth_neighbor_uv, fctx, |
| 12393 | 12608 | ); |
| 12394 | 12609 | if let Some((_, vb)) = &palette_uv_bufs { |
| 12395 | 12610 | set_palette_pred(vb.clone(), fctx); |
| 12396 | 12611 | } |
| 12397 | - v.reconstruct( | |
| 12612 | + push_intra(2, | |
| 12398 | 12613 | cu_x, |
| 12399 | 12614 | cu_y, |
| 12400 | 12615 | chroma_tx, |
| @@ -12402,7 +12617,7 @@ fn decode_block( | ||
| 12402 | 12617 | angle_delta_uv, |
| 12403 | 12618 | cu_r, |
| 12404 | 12619 | &vec![0i32; chroma_tx * chroma_tx], |
| 12405 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 12620 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 12406 | 12621 | None, |
| 12407 | 12622 | smooth_neighbor_uv, fctx, |
| 12408 | 12623 | ); |
| @@ -12444,7 +12659,7 @@ fn decode_block( | ||
| 12444 | 12659 | None, |
| 12445 | 12660 | smooth_neighbor, fctx, |
| 12446 | 12661 | )?; |
| 12447 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | |
| 12662 | + let ac = alpha.map(|_| cfl_src(px, py, side)); | |
| 12448 | 12663 | // Armed for exactly this block's two chroma reads (see |
| 12449 | 12664 | // [`INTRABC_CHROMA_TX`]); the luma call above just set |
| 12450 | 12665 | // [`LUMA_TX_TYPE`] to the type it coded. |
| @@ -12471,7 +12686,7 @@ fn decode_block( | ||
| 12471 | 12686 | chroma_side, |
| 12472 | 12687 | chroma_tx, |
| 12473 | 12688 | base_q_idx, |
| 12474 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 12689 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 12475 | 12690 | None, |
| 12476 | 12691 | None, |
| 12477 | 12692 | smooth_neighbor_uv, fctx, |
| @@ -12502,7 +12717,7 @@ fn decode_block( | ||
| 12502 | 12717 | chroma_side, |
| 12503 | 12718 | chroma_tx, |
| 12504 | 12719 | base_q_idx, |
| 12505 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 12720 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 12506 | 12721 | None, |
| 12507 | 12722 | None, |
| 12508 | 12723 | smooth_neighbor_uv, fctx, |
| @@ -12622,7 +12837,7 @@ fn decode_block( | ||
| 12622 | 12837 | } |
| 12623 | 12838 | // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where |
| 12624 | 12839 | // this still runs after every luma unit of the block. |
| 12625 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | |
| 12840 | + let ac = alpha.map(|_| cfl_src(px, py, side)); | |
| 12626 | 12841 | // The block's uv plane block is `chroma_side` across but its uv |
| 12627 | 12842 | // transform is `chroma_tx` (`av1_get_max_uv_txsize` = |
| 12628 | 12843 | // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): |
| @@ -12657,7 +12872,7 @@ fn decode_block( | ||
| 12657 | 12872 | dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode, |
| 12658 | 12873 | uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y, |
| 12659 | 12874 | chroma_tx, chroma_tx, base_q_idx, |
| 12660 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 12875 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 12661 | 12876 | None, chroma_ctx_offset, smooth_neighbor_uv, fctx, |
| 12662 | 12877 | )?; |
| 12663 | 12878 | if let Some((_, vb)) = &palette_uv_bufs { |
| @@ -12667,7 +12882,7 @@ fn decode_block( | ||
| 12667 | 12882 | dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode, |
| 12668 | 12883 | uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y, |
| 12669 | 12884 | chroma_tx, chroma_tx, base_q_idx, |
| 12670 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 12885 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 12671 | 12886 | None, chroma_ctx_offset, smooth_neighbor_uv, fctx, |
| 12672 | 12887 | )?; |
| 12673 | 12888 | if cn > 1 { |
| @@ -12930,7 +13145,7 @@ fn decode_block_128rect( | ||
| 12930 | 13145 | y.height, fctx, |
| 12931 | 13146 | ); |
| 12932 | 13147 | if skip { |
| 12933 | - y.reconstruct( | |
| 13148 | + push_intra(0, | |
| 12934 | 13149 | tu_px, tu_py, logical_tx, mode, angle_delta_y, tu_r, &zero_tu, None, |
| 12935 | 13150 | None, smooth_neighbor, fctx, |
| 12936 | 13151 | ); |
| @@ -12987,11 +13202,11 @@ fn decode_block_128rect( | ||
| 12987 | 13202 | ); |
| 12988 | 13203 | let (cu_x, cu_y) = (cpx + ch_col * chroma_tx, cpy + ch_row * chroma_tx); |
| 12989 | 13204 | if skip { |
| 12990 | - u.reconstruct( | |
| 13205 | + push_intra(1, | |
| 12991 | 13206 | cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None, |
| 12992 | 13207 | None, smooth_neighbor_uv, fctx, |
| 12993 | 13208 | ); |
| 12994 | - v.reconstruct( | |
| 13209 | + push_intra(2, | |
| 12995 | 13210 | cu_x, cu_y, chroma_tx, uv_predict_mode, angle_delta_uv, cu_r, &zero_cu, None, |
| 12996 | 13211 | None, smooth_neighbor_uv, fctx, |
| 12997 | 13212 | ); |
| @@ -13287,6 +13502,7 @@ fn decode_leaf8( | ||
| 13287 | 13502 | // the CURRENT frame's own pre-loop-filter reconstruction (every loop |
| 13288 | 13503 | // filter is off whenever `allow_intrabc`, frame.rs:194/210/252/272) at |
| 13289 | 13504 | // the full-pel block vector, with the BILINEAR kernel libaom forces. |
| 13505 | + flush_recon(fctx, y, u, v); | |
| 13290 | 13506 | let intrabc_bufs = intrabc_dv.map(|(dv_row, dv_col)| { |
| 13291 | 13507 | let mut yb = vec![0u16; 8 * 8]; |
| 13292 | 13508 | mc::predict_with_filter( |
| @@ -13349,7 +13565,7 @@ fn decode_leaf8( | ||
| 13349 | 13565 | y.width, |
| 13350 | 13566 | y.height, fctx, |
| 13351 | 13567 | ); |
| 13352 | - y.reconstruct( | |
| 13568 | + push_intra(0, | |
| 13353 | 13569 | tu_px, |
| 13354 | 13570 | tu_py, |
| 13355 | 13571 | 4, |
| @@ -13367,7 +13583,7 @@ fn decode_leaf8( | ||
| 13367 | 13583 | if let Some(buf) = &palette_y_buf { |
| 13368 | 13584 | set_palette_pred(buf.clone(), fctx); |
| 13369 | 13585 | } |
| 13370 | - y.reconstruct( | |
| 13586 | + push_intra(0, | |
| 13371 | 13587 | px, |
| 13372 | 13588 | py, |
| 13373 | 13589 | 8, |
| @@ -13380,13 +13596,13 @@ fn decode_leaf8( | ||
| 13380 | 13596 | smooth_neighbor, fctx, |
| 13381 | 13597 | ); |
| 13382 | 13598 | } |
| 13383 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | |
| 13599 | + let ac = alpha.map(|_| cfl_src(px, py, 8)); | |
| 13384 | 13600 | if let Some((_, ub, _)) = &intrabc_bufs { |
| 13385 | 13601 | set_palette_pred(ub.clone(), fctx); |
| 13386 | 13602 | } else if let Some((ub, _)) = &palette_uv_bufs { |
| 13387 | 13603 | set_palette_pred(ub.clone(), fctx); |
| 13388 | 13604 | } |
| 13389 | - u.reconstruct( | |
| 13605 | + push_intra(1, | |
| 13390 | 13606 | cpx, |
| 13391 | 13607 | cpy, |
| 13392 | 13608 | 4, |
| @@ -13394,7 +13610,7 @@ fn decode_leaf8( | ||
| 13394 | 13610 | angle_delta_uv, |
| 13395 | 13611 | reach, |
| 13396 | 13612 | &vec![0i32; 16], |
| 13397 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 13613 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 13398 | 13614 | None, |
| 13399 | 13615 | smooth_neighbor_uv, fctx, |
| 13400 | 13616 | ); |
| @@ -13403,7 +13619,7 @@ fn decode_leaf8( | ||
| 13403 | 13619 | } else if let Some((_, vb)) = &palette_uv_bufs { |
| 13404 | 13620 | set_palette_pred(vb.clone(), fctx); |
| 13405 | 13621 | } |
| 13406 | - v.reconstruct( | |
| 13622 | + push_intra(2, | |
| 13407 | 13623 | cpx, |
| 13408 | 13624 | cpy, |
| 13409 | 13625 | 4, |
| @@ -13411,7 +13627,7 @@ fn decode_leaf8( | ||
| 13411 | 13627 | angle_delta_uv, |
| 13412 | 13628 | reach, |
| 13413 | 13629 | &vec![0i32; 16], |
| 13414 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 13630 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 13415 | 13631 | None, |
| 13416 | 13632 | smooth_neighbor_uv, fctx, |
| 13417 | 13633 | ); |
| @@ -13457,7 +13673,7 @@ fn decode_leaf8( | ||
| 13457 | 13673 | if intrabc_dv.is_some() { |
| 13458 | 13674 | fctx.intrabc_chroma_tx.with(|c| c.set(Some(fctx.luma_tx_type.with(std::cell::Cell::get)))); |
| 13459 | 13675 | } |
| 13460 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | |
| 13676 | + let ac = alpha.map(|_| cfl_src(px, py, 8)); | |
| 13461 | 13677 | if let Some((_, ub, _)) = &intrabc_bufs { |
| 13462 | 13678 | set_palette_pred(ub.clone(), fctx); |
| 13463 | 13679 | } else if let Some((ub, _)) = &palette_uv_bufs { |
| @@ -13480,7 +13696,7 @@ fn decode_leaf8( | ||
| 13480 | 13696 | 4, |
| 13481 | 13697 | TX4, |
| 13482 | 13698 | base_q_idx, |
| 13483 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 13699 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 13484 | 13700 | None, |
| 13485 | 13701 | None, |
| 13486 | 13702 | smooth_neighbor_uv, fctx, |
| @@ -13507,7 +13723,7 @@ fn decode_leaf8( | ||
| 13507 | 13723 | 4, |
| 13508 | 13724 | TX4, |
| 13509 | 13725 | base_q_idx, |
| 13510 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 13726 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 13511 | 13727 | None, |
| 13512 | 13728 | None, |
| 13513 | 13729 | smooth_neighbor_uv, fctx, |
| @@ -13597,7 +13813,7 @@ fn decode_leaf8( | ||
| 13597 | 13813 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 13598 | 13814 | } |
| 13599 | 13815 | } |
| 13600 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | |
| 13816 | + let ac = alpha.map(|_| cfl_src(px, py, 8)); | |
| 13601 | 13817 | let chroma_around = neighbours.around_mi(leaf_mi, 8); |
| 13602 | 13818 | if let Some((ub, _)) = &palette_uv_bufs { |
| 13603 | 13819 | set_palette_pred(ub.clone(), fctx); |
| @@ -13619,7 +13835,7 @@ fn decode_leaf8( | ||
| 13619 | 13835 | 4, |
| 13620 | 13836 | TX4, |
| 13621 | 13837 | base_q_idx, |
| 13622 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 13838 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 13623 | 13839 | None, |
| 13624 | 13840 | None, |
| 13625 | 13841 | smooth_neighbor_uv, fctx, |
| @@ -13644,7 +13860,7 @@ fn decode_leaf8( | ||
| 13644 | 13860 | 4, |
| 13645 | 13861 | TX4, |
| 13646 | 13862 | base_q_idx, |
| 13647 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 13863 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 13648 | 13864 | None, |
| 13649 | 13865 | None, |
| 13650 | 13866 | smooth_neighbor_uv, fctx, |
| @@ -13907,7 +14123,7 @@ fn decode_leaf_split4( | ||
| 13907 | 14123 | let (px, py) = (lmi.1 * MI, lmi.0 * MI); |
| 13908 | 14124 | let reach = Reach::of(4, px, py, y.width, y.height, fctx); |
| 13909 | 14125 | if skip { |
| 13910 | - y.reconstruct(px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx); | |
| 14126 | + push_intra(0, px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, smooth_neighbor, fctx); | |
| 13911 | 14127 | neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]); |
| 13912 | 14128 | } else { |
| 13913 | 14129 | let tu_around = neighbours.around_mi(lmi, 4)[0]; |
| @@ -13964,26 +14180,26 @@ fn decode_leaf_split4( | ||
| 13964 | 14180 | // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the |
| 13965 | 14181 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 13966 | 14182 | // their gates goes vacuous. |
| 13967 | - let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 14183 | + let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | |
| 13968 | 14184 | if alpha.is_some() { |
| 13969 | 14185 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 13970 | 14186 | SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); |
| 13971 | 14187 | } |
| 13972 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 13973 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 14188 | + push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 14189 | + push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 13974 | 14190 | (vec![0i32; 16], vec![0i32; 16]) |
| 13975 | 14191 | } else { |
| 13976 | - let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 14192 | + let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | |
| 13977 | 14193 | let chroma_around = neighbours.around_mi(leaf_mi, 8); |
| 13978 | 14194 | let ug = read_plane( |
| 13979 | 14195 | dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode, |
| 13980 | 14196 | angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, |
| 13981 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14197 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 13982 | 14198 | )?; |
| 13983 | 14199 | let vg = read_plane( |
| 13984 | 14200 | dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode, |
| 13985 | 14201 | angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, |
| 13986 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14202 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 13987 | 14203 | )?; |
| 13988 | 14204 | (ug, vg) |
| 13989 | 14205 | }; |
| @@ -14194,7 +14410,7 @@ fn decode_leaf_rect8( | ||
| 14194 | 14410 | // one's reconstruction, which is NOT what a single 4x8 |
| 14195 | 14411 | // prediction of the same mode produces. |
| 14196 | 14412 | let zeros = vec![0i32; 16]; |
| 14197 | - y.reconstruct( | |
| 14413 | + push_intra(0, | |
| 14198 | 14414 | tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, |
| 14199 | 14415 | filter_intra, smooth_neighbor, fctx, |
| 14200 | 14416 | ); |
| @@ -14248,7 +14464,7 @@ fn decode_leaf_rect8( | ||
| 14248 | 14464 | } |
| 14249 | 14465 | let grid = if skip { |
| 14250 | 14466 | let zeros = vec![0i32; bw * bh]; |
| 14251 | - y.reconstruct_rect( | |
| 14467 | + push_intra_rect(0, | |
| 14252 | 14468 | px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, |
| 14253 | 14469 | smooth_neighbor, fctx, |
| 14254 | 14470 | ); |
| @@ -14291,7 +14507,7 @@ fn decode_leaf_rect8( | ||
| 14291 | 14507 | plane_q_delta(0, fctx).1, |
| 14292 | 14508 | tx_type, |
| 14293 | 14509 | ); |
| 14294 | - y.reconstruct_rect( | |
| 14510 | + push_intra_rect(0, | |
| 14295 | 14511 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 14296 | 14512 | smooth_neighbor, fctx, |
| 14297 | 14513 | ); |
| @@ -14336,26 +14552,26 @@ fn decode_leaf_rect8( | ||
| 14336 | 14552 | // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the |
| 14337 | 14553 | // merge keeps one fix and feeds both lanes' counters so neither of |
| 14338 | 14554 | // their gates goes vacuous. |
| 14339 | - let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 14555 | + let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | |
| 14340 | 14556 | if alpha.is_some() { |
| 14341 | 14557 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 14342 | 14558 | SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); |
| 14343 | 14559 | } |
| 14344 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 14345 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 14560 | + push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 14561 | + push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 14346 | 14562 | (vec![0i32; 16], vec![0i32; 16]) |
| 14347 | 14563 | } else { |
| 14348 | - let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 14564 | + let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | |
| 14349 | 14565 | let chroma_around = neighbours.around_mi(leaf_mi, 8); |
| 14350 | 14566 | let ug = read_plane( |
| 14351 | 14567 | dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode, |
| 14352 | 14568 | angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, |
| 14353 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14569 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14354 | 14570 | )?; |
| 14355 | 14571 | let vg = read_plane( |
| 14356 | 14572 | dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode, |
| 14357 | 14573 | angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, |
| 14358 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14574 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 14359 | 14575 | )?; |
| 14360 | 14576 | (ug, vg) |
| 14361 | 14577 | }; |
| @@ -16138,7 +16354,11 @@ fn read_inter_plane_rect( | ||
| 16138 | 16354 | plane_idx: usize, |
| 16139 | 16355 | around: (bool, bool, i32), |
| 16140 | 16356 | tx_mode: usize, |
| 16141 | - plane: &mut PlaneBuf<'static>, | |
| 16357 | + // lane-wave1 step (i): unread -- this reader records its write | |
| 16358 | + // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow | |
| 16359 | + // stays in the signature so every call site still proves the plane is | |
| 16360 | + // exclusively held while its coefficients are parsed. | |
| 16361 | + _plane: &mut PlaneBuf<'static>, | |
| 16142 | 16362 | x: usize, |
| 16143 | 16363 | y: usize, |
| 16144 | 16364 | prediction: &[u16], |
| @@ -16230,7 +16450,7 @@ fn read_inter_plane_rect( | ||
| 16230 | 16450 | for row in 0..h { |
| 16231 | 16451 | strided[row * stride..][..w].copy_from_slice(&residual[row * w..][..w]); |
| 16232 | 16452 | } |
| 16233 | - plane.reconstruct_mc_rect(x, y, stride, w, h, prediction, &strided, fctx); | |
| 16453 | + push_mc_rect(plane_idx, x, y, stride, w, h, prediction, &strided, fctx); | |
| 16234 | 16454 | Ok((grid, tx_type)) |
| 16235 | 16455 | } |
| 16236 | 16456 | |
| @@ -18365,6 +18585,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 18365 | 18585 | // visits of this superblock code nothing at all. |
| 18366 | 18586 | let mut sb128_none = false; |
| 18367 | 18587 | for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 18588 | + // lane-wave1 step (i): the previous superblock's recorded writes. | |
| 18589 | + flush_recon(fctx, &mut y, &mut u, &mut v); | |
| 18368 | 18590 | if row_start { |
| 18369 | 18591 | neighbours.start_row(); |
| 18370 | 18592 | } |
| @@ -20105,6 +20327,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 20105 | 20327 | } |
| 20106 | 20328 | } |
| 20107 | 20329 | } |
| 20330 | + flush_recon(fctx, &mut y, &mut u, &mut v); | |
| 20108 | 20331 | |
| 20109 | 20332 | if tile_num == tile_info.context_update_tile_id { |
| 20110 | 20333 | result_cdfs = cdfs; |
| @@ -20589,18 +20812,7 @@ impl PlaneBuf<'_> { | ||
| 20589 | 20812 | /// compensation's output, rather than [`predict`]'s intra one), writing |
| 20590 | 20813 | /// the clamped reconstruction into the plane at `(x, y)` -- the inter |
| 20591 | 20814 | /// counterpart of [`PlaneBuf::reconstruct`]. |
| 20592 | - fn reconstruct_mc( | |
| 20593 | - &mut self, | |
| 20594 | - x: usize, | |
| 20595 | - y: usize, | |
| 20596 | - side: usize, | |
| 20597 | - prediction: &[u16], | |
| 20598 | - residual: &[i32], fctx: &crate::decode::FrameCtx, | |
| 20599 | - ) { | |
| 20600 | - self.reconstruct_mc_rect(x, y, side, side, side, prediction, residual, fctx); | |
| 20601 | - } | |
| 20602 | - | |
| 20603 | - /// [`Self::reconstruct_mc`], writing only a `w`x`h` sub-rectangle of the | |
| 20815 | + /// [`Self::reconstruct_mc_rect`], writing only a `w`x`h` sub-rectangle of the | |
| 20604 | 20816 | /// `side`x`side` `prediction`/`residual` buffers (which stay `side`-square |
| 20605 | 20817 | /// for stride/indexing) -- lane-partitions r1: a true rectangular HORZ/ |
| 20606 | 20818 | /// VERT strip is predicted at its enclosing square `side` (matching |
| @@ -20656,7 +20868,11 @@ fn read_inter_plane( | ||
| 20656 | 20868 | plane_idx: usize, |
| 20657 | 20869 | around: (bool, bool, i32), |
| 20658 | 20870 | tx_mode: usize, |
| 20659 | - plane: &mut PlaneBuf<'static>, | |
| 20871 | + // lane-wave1 step (i): unread -- this reader records its write | |
| 20872 | + // ([`push_intra`]/[`push_mc`]) instead of performing it; the borrow | |
| 20873 | + // stays in the signature so every call site still proves the plane is | |
| 20874 | + // exclusively held while its coefficients are parsed. | |
| 20875 | + _plane: &mut PlaneBuf<'static>, | |
| 20660 | 20876 | x: usize, |
| 20661 | 20877 | y: usize, |
| 20662 | 20878 | side: usize, |
| @@ -20727,7 +20943,7 @@ fn read_inter_plane( | ||
| 20727 | 20943 | }; |
| 20728 | 20944 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx, fctx); |
| 20729 | 20945 | let residual = dequant_and_inverse_typed(&grid, side, bit_depth(fctx), block_q_idx(fctx), dc_delta, ac_delta, tx_type); |
| 20730 | - plane.reconstruct_mc(x, y, side, prediction, &residual, fctx); | |
| 20946 | + push_mc(plane_idx, x, y, side, prediction, &residual, fctx); | |
| 20731 | 20947 | Ok((grid, tx_type)) |
| 20732 | 20948 | } |
| 20733 | 20949 | |
| @@ -23244,7 +23460,7 @@ fn decode_inter_block( | ||
| 23244 | 23460 | .1 |
| 23245 | 23461 | }; |
| 23246 | 23462 | if skip { |
| 23247 | - y.reconstruct_mc_rect( | |
| 23463 | + push_mc_rect(0, | |
| 23248 | 23464 | px, |
| 23249 | 23465 | py, |
| 23250 | 23466 | side, |
| @@ -23253,7 +23469,7 @@ fn decode_inter_block( | ||
| 23253 | 23469 | &pred_y, |
| 23254 | 23470 | &vec![0i32; side * side], fctx, |
| 23255 | 23471 | ); |
| 23256 | - u.reconstruct_mc_rect( | |
| 23472 | + push_mc_rect(1, | |
| 23257 | 23473 | cpx, |
| 23258 | 23474 | cpy, |
| 23259 | 23475 | chroma_side, |
| @@ -23262,7 +23478,7 @@ fn decode_inter_block( | ||
| 23262 | 23478 | &pred_u, |
| 23263 | 23479 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 23264 | 23480 | ); |
| 23265 | - v.reconstruct_mc_rect( | |
| 23481 | + push_mc_rect(2, | |
| 23266 | 23482 | cpx, |
| 23267 | 23483 | cpy, |
| 23268 | 23484 | chroma_side, |
| @@ -24367,6 +24583,7 @@ fn decode_inter_block( | ||
| 24367 | 24583 | // result, all planes (reconinter.c av1_build_interintra_predictor |
| 24368 | 24584 | // plane loop). |
| 24369 | 24585 | if let Some(ii) = interintra_mode { |
| 24586 | + flush_recon(fctx, y, u, v); | |
| 24370 | 24587 | if write_w != write_h { |
| 24371 | 24588 | INTERINTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 24372 | 24589 | } |
| @@ -24454,7 +24671,7 @@ fn decode_inter_block( | ||
| 24454 | 24671 | .1 |
| 24455 | 24672 | }; |
| 24456 | 24673 | if skip { |
| 24457 | - y.reconstruct_mc_rect( | |
| 24674 | + push_mc_rect(0, | |
| 24458 | 24675 | px, |
| 24459 | 24676 | py, |
| 24460 | 24677 | side, |
| @@ -24464,7 +24681,7 @@ fn decode_inter_block( | ||
| 24464 | 24681 | &vec![0i32; side * side], fctx, |
| 24465 | 24682 | ); |
| 24466 | 24683 | if has_chroma { |
| 24467 | - u.reconstruct_mc_rect( | |
| 24684 | + push_mc_rect(1, | |
| 24468 | 24685 | cpx, |
| 24469 | 24686 | cpy, |
| 24470 | 24687 | chroma_side, |
| @@ -24473,7 +24690,7 @@ fn decode_inter_block( | ||
| 24473 | 24690 | &pred_u, |
| 24474 | 24691 | &vec![0i32; chroma_side * chroma_side], fctx, |
| 24475 | 24692 | ); |
| 24476 | - v.reconstruct_mc_rect( | |
| 24693 | + push_mc_rect(2, | |
| 24477 | 24694 | cpx, |
| 24478 | 24695 | cpy, |
| 24479 | 24696 | chroma_side, |
| @@ -25216,7 +25433,7 @@ fn decode_inter_block( | ||
| 25216 | 25433 | set_palette_pred(window, fctx); |
| 25217 | 25434 | } |
| 25218 | 25435 | let tu_grid = if skip { |
| 25219 | - y.reconstruct( | |
| 25436 | + push_intra(0, | |
| 25220 | 25437 | tu_px, |
| 25221 | 25438 | tu_py, |
| 25222 | 25439 | tx_px, |
| @@ -25286,7 +25503,7 @@ fn decode_inter_block( | ||
| 25286 | 25503 | for plane_idx in 1..3 { |
| 25287 | 25504 | let buf: &mut PlaneBuf<'static> = if plane_idx == 1 { &mut *u } else { &mut *v }; |
| 25288 | 25505 | let cu_grid = if skip { |
| 25289 | - buf.reconstruct( | |
| 25506 | + push_intra(plane_idx, | |
| 25290 | 25507 | cu_x, |
| 25291 | 25508 | cu_y, |
| 25292 | 25509 | cu_tx, |
| @@ -25356,7 +25573,7 @@ fn decode_inter_block( | ||
| 25356 | 25573 | if let Some(buf) = &palette_y_buf { |
| 25357 | 25574 | set_palette_pred(buf.clone(), fctx); |
| 25358 | 25575 | } |
| 25359 | - y.reconstruct( | |
| 25576 | + push_intra(0, | |
| 25360 | 25577 | px, |
| 25361 | 25578 | py, |
| 25362 | 25579 | side, |
| @@ -25369,11 +25586,11 @@ fn decode_inter_block( | ||
| 25369 | 25586 | smooth_neighbor, fctx, |
| 25370 | 25587 | ); |
| 25371 | 25588 | } |
| 25372 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | |
| 25589 | + let ac = alpha.map(|_| cfl_src(px, py, side)); | |
| 25373 | 25590 | if let Some((ub, _)) = &palette_uv_bufs { |
| 25374 | 25591 | set_palette_pred(ub.clone(), fctx); |
| 25375 | 25592 | } |
| 25376 | - u.reconstruct( | |
| 25593 | + push_intra(1, | |
| 25377 | 25594 | cpx, |
| 25378 | 25595 | cpy, |
| 25379 | 25596 | chroma_side, |
| @@ -25381,14 +25598,14 @@ fn decode_inter_block( | ||
| 25381 | 25598 | angle_delta_uv, |
| 25382 | 25599 | reach, |
| 25383 | 25600 | &vec![0i32; chroma_side * chroma_side], |
| 25384 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 25601 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 25385 | 25602 | None, |
| 25386 | 25603 | smooth_neighbor_uv, fctx, |
| 25387 | 25604 | ); |
| 25388 | 25605 | if let Some((_, vb)) = &palette_uv_bufs { |
| 25389 | 25606 | set_palette_pred(vb.clone(), fctx); |
| 25390 | 25607 | } |
| 25391 | - v.reconstruct( | |
| 25608 | + push_intra(2, | |
| 25392 | 25609 | cpx, |
| 25393 | 25610 | cpy, |
| 25394 | 25611 | chroma_side, |
| @@ -25396,7 +25613,7 @@ fn decode_inter_block( | ||
| 25396 | 25613 | angle_delta_uv, |
| 25397 | 25614 | reach, |
| 25398 | 25615 | &vec![0i32; chroma_side * chroma_side], |
| 25399 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 25616 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 25400 | 25617 | None, |
| 25401 | 25618 | smooth_neighbor_uv, fctx, |
| 25402 | 25619 | ); |
| @@ -25437,7 +25654,7 @@ fn decode_inter_block( | ||
| 25437 | 25654 | smooth_neighbor, fctx, |
| 25438 | 25655 | )? |
| 25439 | 25656 | }; |
| 25440 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | |
| 25657 | + let ac = alpha.map(|_| cfl_src(px, py, side)); | |
| 25441 | 25658 | if let Some((ub, _)) = &palette_uv_bufs { |
| 25442 | 25659 | set_palette_pred(ub.clone(), fctx); |
| 25443 | 25660 | } |
| @@ -25458,7 +25675,7 @@ fn decode_inter_block( | ||
| 25458 | 25675 | chroma_side, |
| 25459 | 25676 | chroma_tx, |
| 25460 | 25677 | base_q_idx, |
| 25461 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 25678 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 25462 | 25679 | None, |
| 25463 | 25680 | None, |
| 25464 | 25681 | smooth_neighbor_uv, fctx, |
| @@ -25483,7 +25700,7 @@ fn decode_inter_block( | ||
| 25483 | 25700 | chroma_side, |
| 25484 | 25701 | chroma_tx, |
| 25485 | 25702 | base_q_idx, |
| 25486 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 25703 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 25487 | 25704 | None, |
| 25488 | 25705 | None, |
| 25489 | 25706 | smooth_neighbor_uv, fctx, |
| @@ -26094,7 +26311,7 @@ fn decode_inter_sub8_split4( | ||
| 26094 | 26311 | // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which |
| 26095 | 26312 | // `read_inter_plane`'s `plane_idx == 0` arm already assumes). |
| 26096 | 26313 | if skip { |
| 26097 | - y.reconstruct_mc(px, py, B4, &pred_y, &vec![0i32; B4 * B4], fctx); | |
| 26314 | + push_mc(0, px, py, B4, &pred_y, &vec![0i32; B4 * B4], fctx); | |
| 26098 | 26315 | neighbours.record_mi_luma_rect(lmi, B4, B4, &vec![0i32; B4 * B4]); |
| 26099 | 26316 | } else { |
| 26100 | 26317 | let around = neighbours.around_mi(lmi, B4); |
| @@ -26209,8 +26426,8 @@ fn decode_inter_sub8_split4( | ||
| 26209 | 26426 | } |
| 26210 | 26427 | } |
| 26211 | 26428 | let (u_grid, v_grid) = if last_skip { |
| 26212 | - u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 26213 | - v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 26429 | + push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 26430 | + push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 26214 | 26431 | (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) |
| 26215 | 26432 | } else { |
| 26216 | 26433 | let around = neighbours.around_mi(group_mi, 8); |
| @@ -26439,7 +26656,7 @@ fn decode_intra_sub8_leaf( | ||
| 26439 | 26656 | ); |
| 26440 | 26657 | if skip { |
| 26441 | 26658 | let zeros = vec![0i32; 16]; |
| 26442 | - y.reconstruct( | |
| 26659 | + push_intra(0, | |
| 26443 | 26660 | tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, filter_intra, |
| 26444 | 26661 | smooth_neighbor, fctx, |
| 26445 | 26662 | ); |
| @@ -26481,7 +26698,7 @@ fn decode_intra_sub8_leaf( | ||
| 26481 | 26698 | // fixes `txb_skip_ctx` at 0 (`luma_skip_ctx: None`) -- the same square |
| 26482 | 26699 | // reader [`decode_leaf_split4`] uses. |
| 26483 | 26700 | if skip { |
| 26484 | - y.reconstruct( | |
| 26701 | + push_intra(0, | |
| 26485 | 26702 | px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, |
| 26486 | 26703 | smooth_neighbor, fctx, |
| 26487 | 26704 | ); |
| @@ -26519,7 +26736,7 @@ fn decode_intra_sub8_leaf( | ||
| 26519 | 26736 | } else { |
| 26520 | 26737 | let grid_levels = if skip { |
| 26521 | 26738 | let zeros = vec![0i32; bw * bh]; |
| 26522 | - y.reconstruct_rect( | |
| 26739 | + push_intra_rect(0, | |
| 26523 | 26740 | px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, |
| 26524 | 26741 | smooth_neighbor, fctx, |
| 26525 | 26742 | ); |
| @@ -26554,7 +26771,7 @@ fn decode_intra_sub8_leaf( | ||
| 26554 | 26771 | plane_q_delta(0, fctx).1, |
| 26555 | 26772 | tx_type, |
| 26556 | 26773 | ); |
| 26557 | - y.reconstruct_rect( | |
| 26774 | + push_intra_rect(0, | |
| 26558 | 26775 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 26559 | 26776 | smooth_neighbor, fctx, |
| 26560 | 26777 | ); |
| @@ -26649,26 +26866,26 @@ fn decode_intra_sub8_leaf( | ||
| 26649 | 26866 | // needs `bsize >= BLOCK_8X8`), so the group always clears. |
| 26650 | 26867 | record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); |
| 26651 | 26868 | |
| 26652 | - let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 26869 | + let ac = alpha.map(|_| cfl_src(gpx, gpy, 8)); | |
| 26653 | 26870 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip { |
| 26654 | 26871 | if alpha.is_some() { |
| 26655 | 26872 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 26656 | 26873 | SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); |
| 26657 | 26874 | } |
| 26658 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 26659 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 26875 | + push_intra(1, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | |
| 26876 | + push_intra(2, cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, fctx); | |
| 26660 | 26877 | (vec![0i32; 16], vec![0i32; 16]) |
| 26661 | 26878 | } else { |
| 26662 | 26879 | let chroma_around = neighbours.around_mi(group_mi, 8); |
| 26663 | 26880 | let ug = read_plane( |
| 26664 | 26881 | dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode, |
| 26665 | 26882 | angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, |
| 26666 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 26883 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 26667 | 26884 | )?; |
| 26668 | 26885 | let vg = read_plane( |
| 26669 | 26886 | dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode, |
| 26670 | 26887 | angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, |
| 26671 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 26888 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, fctx, | |
| 26672 | 26889 | )?; |
| 26673 | 26890 | (ug, vg) |
| 26674 | 26891 | }; |
| @@ -27067,7 +27284,7 @@ fn decode_inter_sub8_rect2( | ||
| 27067 | 27284 | } |
| 27068 | 27285 | } |
| 27069 | 27286 | if skip { |
| 27070 | - y.reconstruct_mc_rect(px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 27287 | + push_mc_rect(0, px, py, SIDE, bw, bh, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 27071 | 27288 | neighbours.record_mi_luma_rect(lmi, bw, bh, &vec![0i32; bw * bh]); |
| 27072 | 27289 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx); |
| 27073 | 27290 | } else { |
| @@ -27233,8 +27450,8 @@ fn decode_inter_sub8_rect2( | ||
| 27233 | 27450 | } |
| 27234 | 27451 | } |
| 27235 | 27452 | let (u_grid, v_grid) = if last_skip { |
| 27236 | - u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 27237 | - v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 27453 | + push_mc(1, cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4], fctx); | |
| 27454 | + push_mc(2, cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4], fctx); | |
| 27238 | 27455 | (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) |
| 27239 | 27456 | } else { |
| 27240 | 27457 | let around = neighbours.around_mi(group_mi, 8); |
| @@ -28070,15 +28287,15 @@ fn decode_inter_block8( | ||
| 28070 | 28287 | .1 |
| 28071 | 28288 | .is_some(); |
| 28072 | 28289 | if skip { |
| 28073 | - y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 28074 | - u.reconstruct_mc( | |
| 28290 | + push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 28291 | + push_mc(1, | |
| 28075 | 28292 | cpx, |
| 28076 | 28293 | cpy, |
| 28077 | 28294 | CHROMA_SIDE, |
| 28078 | 28295 | &pred_u, |
| 28079 | 28296 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 28080 | 28297 | ); |
| 28081 | - v.reconstruct_mc( | |
| 28298 | + push_mc(2, | |
| 28082 | 28299 | cpx, |
| 28083 | 28300 | cpy, |
| 28084 | 28301 | CHROMA_SIDE, |
| @@ -28697,6 +28914,7 @@ fn decode_inter_block8( | ||
| 28697 | 28914 | // Non-wedge interintra blend, mutually exclusive with OBMC (the |
| 28698 | 28915 | // motion_mode symbol is not read for an interintra block). |
| 28699 | 28916 | if let Some(ii) = interintra_mode { |
| 28917 | + flush_recon(fctx, y, u, v); | |
| 28700 | 28918 | interintra_blend(y, px, py, SIDE, SIDE, SIDE, ii, wedge_mask, &mut pred_y, fctx); |
| 28701 | 28919 | interintra_blend( |
| 28702 | 28920 | u, cpx, cpy, CHROMA_SIDE, CHROMA_SIDE, CHROMA_SIDE, ii, wedge_mask, &mut pred_u, fctx, |
| @@ -28719,15 +28937,15 @@ fn decode_inter_block8( | ||
| 28719 | 28937 | .1 |
| 28720 | 28938 | .is_some(); |
| 28721 | 28939 | if skip { |
| 28722 | - y.reconstruct_mc(px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 28723 | - u.reconstruct_mc( | |
| 28940 | + push_mc(0, px, py, SIDE, &pred_y, &vec![0i32; SIDE * SIDE], fctx); | |
| 28941 | + push_mc(1, | |
| 28724 | 28942 | cpx, |
| 28725 | 28943 | cpy, |
| 28726 | 28944 | CHROMA_SIDE, |
| 28727 | 28945 | &pred_u, |
| 28728 | 28946 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], fctx, |
| 28729 | 28947 | ); |
| 28730 | - v.reconstruct_mc( | |
| 28948 | + push_mc(2, | |
| 28731 | 28949 | cpx, |
| 28732 | 28950 | cpy, |
| 28733 | 28951 | CHROMA_SIDE, |
| @@ -29090,7 +29308,7 @@ fn decode_inter_block8( | ||
| 29090 | 29308 | set_palette_pred(window, fctx); |
| 29091 | 29309 | } |
| 29092 | 29310 | let tu_grid = if skip { |
| 29093 | - y.reconstruct( | |
| 29311 | + push_intra(0, | |
| 29094 | 29312 | tu_px, |
| 29095 | 29313 | tu_py, |
| 29096 | 29314 | tx_px, |
| @@ -29143,7 +29361,7 @@ fn decode_inter_block8( | ||
| 29143 | 29361 | if let Some(buf) = &palette_y_buf { |
| 29144 | 29362 | set_palette_pred(buf.clone(), fctx); |
| 29145 | 29363 | } |
| 29146 | - y.reconstruct( | |
| 29364 | + push_intra(0, | |
| 29147 | 29365 | px, |
| 29148 | 29366 | py, |
| 29149 | 29367 | SIDE, |
| @@ -29158,11 +29376,11 @@ fn decode_inter_block8( | ||
| 29158 | 29376 | } |
| 29159 | 29377 | // CfL's AC contribution is the luma this leaf just reconstructed, |
| 29160 | 29378 | // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5). |
| 29161 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); | |
| 29379 | + let ac = alpha.map(|_| cfl_src(px, py, SIDE)); | |
| 29162 | 29380 | if let Some((ub, _)) = &palette_uv_bufs { |
| 29163 | 29381 | set_palette_pred(ub.clone(), fctx); |
| 29164 | 29382 | } |
| 29165 | - u.reconstruct( | |
| 29383 | + push_intra(1, | |
| 29166 | 29384 | cpx, |
| 29167 | 29385 | cpy, |
| 29168 | 29386 | CHROMA_SIDE, |
| @@ -29170,14 +29388,14 @@ fn decode_inter_block8( | ||
| 29170 | 29388 | angle_delta_uv, |
| 29171 | 29389 | reach, |
| 29172 | 29390 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], |
| 29173 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 29391 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 29174 | 29392 | None, |
| 29175 | 29393 | smooth_neighbor_uv, fctx, |
| 29176 | 29394 | ); |
| 29177 | 29395 | if let Some((_, vb)) = &palette_uv_bufs { |
| 29178 | 29396 | set_palette_pred(vb.clone(), fctx); |
| 29179 | 29397 | } |
| 29180 | - v.reconstruct( | |
| 29398 | + push_intra(2, | |
| 29181 | 29399 | cpx, |
| 29182 | 29400 | cpy, |
| 29183 | 29401 | CHROMA_SIDE, |
| @@ -29185,7 +29403,7 @@ fn decode_inter_block8( | ||
| 29185 | 29403 | angle_delta_uv, |
| 29186 | 29404 | reach, |
| 29187 | 29405 | &vec![0i32; CHROMA_SIDE * CHROMA_SIDE], |
| 29188 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 29406 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 29189 | 29407 | None, |
| 29190 | 29408 | smooth_neighbor_uv, fctx, |
| 29191 | 29409 | ); |
| @@ -29234,7 +29452,7 @@ fn decode_inter_block8( | ||
| 29234 | 29452 | smooth_neighbor, fctx, |
| 29235 | 29453 | )? |
| 29236 | 29454 | }; |
| 29237 | - let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); | |
| 29455 | + let ac = alpha.map(|_| cfl_src(px, py, SIDE)); | |
| 29238 | 29456 | if let Some((ub, _)) = &palette_uv_bufs { |
| 29239 | 29457 | set_palette_pred(ub.clone(), fctx); |
| 29240 | 29458 | } |
| @@ -29255,7 +29473,7 @@ fn decode_inter_block8( | ||
| 29255 | 29473 | CHROMA_SIDE, |
| 29256 | 29474 | TX4, |
| 29257 | 29475 | base_q_idx, |
| 29258 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | |
| 29476 | + alpha.zip(ac).map(|((au, _), ac)| (au, ac)), | |
| 29259 | 29477 | None, |
| 29260 | 29478 | None, |
| 29261 | 29479 | smooth_neighbor_uv, fctx, |
| @@ -29280,7 +29498,7 @@ fn decode_inter_block8( | ||
| 29280 | 29498 | CHROMA_SIDE, |
| 29281 | 29499 | TX4, |
| 29282 | 29500 | base_q_idx, |
| 29283 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | |
| 29501 | + alpha.zip(ac).map(|((_, av), ac)| (av, ac)), | |
| 29284 | 29502 | None, |
| 29285 | 29503 | None, |
| 29286 | 29504 | smooth_neighbor_uv, fctx, |
| @@ -29819,6 +30037,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 29819 | 30037 | // key-frame tile loop runs). |
| 29820 | 30038 | let mut sb128_none = false; |
| 29821 | 30039 | for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 30040 | + // lane-wave1 step (i): the previous superblock's recorded writes. | |
| 30041 | + flush_recon(fctx, &mut y, &mut u, &mut v); | |
| 29822 | 30042 | if row_start { |
| 29823 | 30043 | neighbours.start_row(); |
| 29824 | 30044 | } |
| @@ -32162,6 +32382,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 32162 | 32382 | } |
| 32163 | 32383 | } |
| 32164 | 32384 | } |
| 32385 | + flush_recon(fctx, &mut y, &mut u, &mut v); | |
| 32165 | 32386 | |
| 32166 | 32387 | if tile_num == tile_info.context_update_tile_id { |
| 32167 | 32388 | result_cdfs = cdfs; |