The sub-8x8 group predictions build on the recon worker too
Browse files at this commit9137abf43e3f9fc12aed232a3b7a8b1dc32d81baParent: 36b27a7- perf
- the sub-8x8 group predictions build on the recon worker too
1 changed file +140 -40
- crates/ec-av1/src/decode.rs +140 -40
crates/ec-av1/src/decode.rsmodified+140 -40
| @@ -2253,8 +2253,8 @@ fn dense_residual(residual: &[i32], n: usize) -> &[i32] { | |||
| 2253 | /// block then reads its window out of that slot ([`Pred::Cur`]). | 2253 | /// block then reads its window out of that slot ([`Pred::Cur`]). |
| 2254 | #[derive(Clone, Copy)] | 2254 | #[derive(Clone, Copy)] |
| 2255 | pub(crate) enum Pred<'a> { | 2255 | pub(crate) enum Pred<'a> { |
| 2256 | - /// A prediction the parse thread already built. `stride == 0` means "the | 2256 | + /// A prediction the parse thread already built, at its own stride |
| 2257 | - /// reader's own `stride` argument", which is every pre-lane-wave4 site. | 2257 | + /// (`stride == 0` means "the reader's own `stride` argument"). |
| 2258 | Inline(&'a [u16], usize), | 2258 | Inline(&'a [u16], usize), |
| 2259 | /// The current block's deferred prediction: plane, its stride, and this | 2259 | /// The current block's deferred prediction: plane, its stride, and this |
| 2260 | /// unit's offset into it. | 2260 | /// unit's offset into it. |
| @@ -2262,9 +2262,6 @@ pub(crate) enum Pred<'a> { | |||
| 2262 | } | 2262 | } |
| 2263 | 2263 | ||
| 2264 | impl<'a> Pred<'a> { | 2264 | impl<'a> Pred<'a> { |
| 2265 | - fn dense(buf: &'a [u16]) -> Self { | ||
| 2266 | - Self::Inline(buf, 0) | ||
| 2267 | - } | ||
| 2268 | /// The same prediction read at an explicit stride. | 2265 | /// The same prediction read at an explicit stride. |
| 2269 | fn view(self, stride: usize) -> Self { | 2266 | fn view(self, stride: usize) -> Self { |
| 2270 | match self { | 2267 | match self { |
| @@ -28686,12 +28683,14 @@ fn decode_inter_sub8_split4( | |||
| 28686 | neighbours.left_ref[rmi], | 28683 | neighbours.left_ref[rmi], |
| 28687 | neighbours.left_ref1[rmi], | 28684 | neighbours.left_ref1[rmi], |
| 28688 | ); | 28685 | ); |
| 28689 | - let (sref_y, _sref_u, _sref_v) = ref_planes(ref_frame, refpix)?; | 28686 | + // lane-sub8group: this piece's reference SIZE at parse, its pictures |
| 28687 | + // inside the prediction closure below. | ||
| 28688 | + let (ref_width, _) = ref_dims(ref_frame, refpix)?; | ||
| 28690 | // lane-t900 r28: refusal lifted -- this sub-block's own reference may | 28689 | // lane-t900 r28: refusal lifted -- this sub-block's own reference may |
| 28691 | // be scaled (superres); spec 7.11.3.3's walk is per reference, and | 28690 | // be scaled (superres); spec 7.11.3.3's walk is per reference, and |
| 28692 | // each of the group's pieces (luma and its 2x2 chroma) carries its | 28691 | // each of the group's pieces (luma and its 2x2 chroma) carries its |
| 28693 | // OWN factor because each can name a different `ref_frame`. | 28692 | // OWN factor because each can name a different `ref_frame`. |
| 28694 | - let luma_scale = mc::scale_factor(sref_y.width, frame_width); | 28693 | + let luma_scale = mc::scale_factor(ref_width, frame_width); |
| 28695 | if luma_scale != mc::REF_NO_SCALE { | 28694 | if luma_scale != mc::REF_NO_SCALE { |
| 28696 | SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1)); | 28695 | SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1)); |
| 28697 | } | 28696 | } |
| @@ -28854,7 +28853,18 @@ fn decode_inter_sub8_split4( | |||
| 28854 | }, | 28853 | }, |
| 28855 | ); | 28854 | ); |
| 28856 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); | 28855 | piece[i] = Some((ref_frame, mv, h_filter, v_filter)); |
| 28857 | - let mut pred_y = vec![0u16; B4 * B4]; | 28856 | + // lane-sub8group: this piece's prediction as a closure, so it runs |
| 28857 | + // where its writes run -- on a recon worker at more than one | ||
| 28858 | + // reconstruction thread, exactly like the 8x8 leaf's. | ||
| 28859 | + let build = move |_y: &mut PlaneBuf<'static>, | ||
| 28860 | + _u: &mut PlaneBuf<'static>, | ||
| 28861 | + _v: &mut PlaneBuf<'static>, | ||
| 28862 | + fctx: &crate::decode::FrameCtx, | ||
| 28863 | + out: &mut [Vec<u16>; 3]| { | ||
| 28864 | + let Some((sref_y, _, _)) = ref_planes_deferred(ref_frame, refpix) else { | ||
| 28865 | + return; | ||
| 28866 | + }; | ||
| 28867 | + let mut pred_y = refill(std::mem::take(&mut out[0]), B4 * B4); | ||
| 28858 | mc::predict_maybe_scaled( | 28868 | mc::predict_maybe_scaled( |
| 28859 | &sref_y.data, | 28869 | &sref_y.data, |
| 28860 | sref_y.width, | 28870 | sref_y.width, |
| @@ -28869,12 +28879,25 @@ fn decode_inter_sub8_split4( | |||
| 28869 | v_filter, | 28879 | v_filter, |
| 28870 | &mut pred_y, fctx, | 28880 | &mut pred_y, fctx, |
| 28871 | ); | 28881 | ); |
| 28882 | + out[0] = pred_y; | ||
| 28883 | + }; | ||
| 28884 | + let pred_y: Vec<u16>; | ||
| 28885 | + let sy = if recon_deferred(fctx) { | ||
| 28886 | + push_pred(fctx, build); | ||
| 28887 | + Pred::Cur { plane: 0, stride: B4, off: 0 } | ||
| 28888 | + } else { | ||
| 28889 | + let mut built: [Vec<u16>; 3] = Default::default(); | ||
| 28890 | + build(y, u, v, fctx, &mut built); | ||
| 28891 | + let [by, _, _] = built; | ||
| 28892 | + pred_y = by; | ||
| 28893 | + Pred::Inline(&pred_y, B4) | ||
| 28894 | + }; | ||
| 28872 | // `BLOCK_4X4` never signals a transform size, so the luma unit is the | 28895 | // `BLOCK_4X4` never signals a transform size, so the luma unit is the |
| 28873 | // whole block and `get_txb_ctx` takes its `plane_bsize == | 28896 | // whole block and `get_txb_ctx` takes its `plane_bsize == |
| 28874 | // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which | 28897 | // txsize_to_bsize[tx_size]` branch (`txb_skip_ctx = 0`, which |
| 28875 | // `read_inter_plane`'s `plane_idx == 0` arm already assumes). | 28898 | // `read_inter_plane`'s `plane_idx == 0` arm already assumes). |
| 28876 | if skip { | 28899 | if skip { |
| 28877 | - push_mc(0, px, py, B4, Pred::dense(&pred_y), &ZERO_RESIDUAL[..B4 * B4], fctx); | 28900 | + push_mc(0, px, py, B4, sy, &ZERO_RESIDUAL[..B4 * B4], fctx); |
| 28878 | neighbours.record_mi_luma_rect(lmi, B4, B4, &ZERO_RESIDUAL[..B4 * B4]); | 28901 | neighbours.record_mi_luma_rect(lmi, B4, B4, &ZERO_RESIDUAL[..B4 * B4]); |
| 28879 | } else { | 28902 | } else { |
| 28880 | let around = neighbours.around_mi(lmi, B4); | 28903 | let around = neighbours.around_mi(lmi, B4); |
| @@ -28895,7 +28918,7 @@ fn decode_inter_sub8_split4( | |||
| 28895 | py, | 28918 | py, |
| 28896 | B4, | 28919 | B4, |
| 28897 | base_q_idx, | 28920 | base_q_idx, |
| 28898 | - Pred::dense(&pred_y), | 28921 | + sy, |
| 28899 | None, | 28922 | None, |
| 28900 | None, fctx, | 28923 | None, fctx, |
| 28901 | )?; | 28924 | )?; |
| @@ -28934,8 +28957,6 @@ fn decode_inter_sub8_split4( | |||
| 28934 | // Chroma, once for the whole group, on the last sub-block's own `skip` | 28957 | // Chroma, once for the whole group, on the last sub-block's own `skip` |
| 28935 | // flag -- prediction from all four sub-blocks (2x2 pieces), residual as | 28958 | // flag -- prediction from all four sub-blocks (2x2 pieces), residual as |
| 28936 | // one TX_4X4 unit per plane. | 28959 | // one TX_4X4 unit per plane. |
| 28937 | - let mut pred_u = vec![0u16; B4 * B4]; | ||
| 28938 | - let mut pred_v = vec![0u16; B4 * B4]; | ||
| 28939 | // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY | 28960 | // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY |
| 28940 | // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE | 28961 | // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE |
| 28941 | // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. | 28962 | // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. |
| @@ -28947,6 +28968,15 @@ fn decode_inter_sub8_split4( | |||
| 28947 | h.set(st); | 28968 | h.set(st); |
| 28948 | }); | 28969 | }); |
| 28949 | } | 28970 | } |
| 28971 | + // lane-sub8group: the group's chroma pieces, built on the worker that | ||
| 28972 | + // writes them -- the pieces' refs/mvs/filters travel by value. | ||
| 28973 | + let build = move |_y: &mut PlaneBuf<'static>, | ||
| 28974 | + _u: &mut PlaneBuf<'static>, | ||
| 28975 | + _v: &mut PlaneBuf<'static>, | ||
| 28976 | + fctx: &crate::decode::FrameCtx, | ||
| 28977 | + out: &mut [Vec<u16>; 3]| { | ||
| 28978 | + let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4); | ||
| 28979 | + let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4); | ||
| 28950 | for i in 0..4usize { | 28980 | for i in 0..4usize { |
| 28951 | let (dr, dc) = (i / 2, i % 2); | 28981 | let (dr, dc) = (i / 2, i % 2); |
| 28952 | if mixed && i != 3 { | 28982 | if mixed && i != 3 { |
| @@ -28955,8 +28985,10 @@ fn decode_inter_sub8_split4( | |||
| 28955 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | 28985 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { |
| 28956 | continue; | 28986 | continue; |
| 28957 | }; | 28987 | }; |
| 28958 | - let (piece_ref_y, sref_u, sref_v) = | 28988 | + let Some((piece_ref_y, sref_u, sref_v)) = ref_planes_deferred(ref_frame, refpix) |
| 28959 | - ref_planes(ref_frame, refpix)?; | 28989 | + else { |
| 28990 | + continue; | ||
| 28991 | + }; | ||
| 28960 | let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width); | 28992 | let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width); |
| 28961 | let (ox, oy) = if mixed { | 28993 | let (ox, oy) = if mixed { |
| 28962 | (cpx, cpy) | 28994 | (cpx, cpy) |
| @@ -28988,20 +29020,37 @@ fn decode_inter_sub8_split4( | |||
| 28988 | } | 29020 | } |
| 28989 | } | 29021 | } |
| 28990 | } | 29022 | } |
| 29023 | + out[1] = pred_u; | ||
| 29024 | + out[2] = pred_v; | ||
| 29025 | + }; | ||
| 29026 | + let (pred_u, pred_v): (Vec<u16>, Vec<u16>); | ||
| 29027 | + let (su, sv) = if recon_deferred(fctx) { | ||
| 29028 | + push_pred(fctx, build); | ||
| 29029 | + ( | ||
| 29030 | + Pred::Cur { plane: 1, stride: B4, off: 0 }, | ||
| 29031 | + Pred::Cur { plane: 2, stride: B4, off: 0 }, | ||
| 29032 | + ) | ||
| 29033 | + } else { | ||
| 29034 | + let mut built: [Vec<u16>; 3] = Default::default(); | ||
| 29035 | + build(y, u, v, fctx, &mut built); | ||
| 29036 | + let [_, bu, bv] = built; | ||
| 29037 | + (pred_u, pred_v) = (bu, bv); | ||
| 29038 | + (Pred::Inline(&pred_u, B4), Pred::Inline(&pred_v, B4)) | ||
| 29039 | + }; | ||
| 28991 | let (u_grid, v_grid) = if last_skip { | 29040 | let (u_grid, v_grid) = if last_skip { |
| 28992 | - push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx); | 29041 | + push_mc(1, cpx, cpy, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx); |
| 28993 | - push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx); | 29042 | + push_mc(2, cpx, cpy, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx); |
| 28994 | (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4)) | 29043 | (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4)) |
| 28995 | } else { | 29044 | } else { |
| 28996 | let around = neighbours.around_mi(group_mi, 8); | 29045 | let around = neighbours.around_mi(group_mi, 8); |
| 28997 | let ug = read_inter_plane( | 29046 | let ug = read_inter_plane( |
| 28998 | dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | 29047 | dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, |
| 28999 | - Pred::dense(&pred_u), Some(first_tx_type), None, fctx, | 29048 | + su, Some(first_tx_type), None, fctx, |
| 29000 | )? | 29049 | )? |
| 29001 | .0; | 29050 | .0; |
| 29002 | let vg = read_inter_plane( | 29051 | let vg = read_inter_plane( |
| 29003 | dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | 29052 | dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, |
| 29004 | - Pred::dense(&pred_v), Some(first_tx_type), None, fctx, | 29053 | + sv, Some(first_tx_type), None, fctx, |
| 29005 | )? | 29054 | )? |
| 29006 | .0; | 29055 | .0; |
| 29007 | let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); | 29056 | let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); |
| @@ -29656,9 +29705,11 @@ fn decode_inter_sub8_rect2( | |||
| 29656 | neighbours.left_ref[rmi], | 29705 | neighbours.left_ref[rmi], |
| 29657 | neighbours.left_ref1[rmi], | 29706 | neighbours.left_ref1[rmi], |
| 29658 | ); | 29707 | ); |
| 29659 | - let (sref_y, _, _) = ref_planes(ref_frame, refpix)?; | 29708 | + // lane-sub8group: this piece's reference SIZE at parse, its pictures |
| 29709 | + // inside the prediction closure below. | ||
| 29710 | + let (ref_width, _) = ref_dims(ref_frame, refpix)?; | ||
| 29660 | // lane-t900 r28: refusal lifted -- see the split arm above. | 29711 | // lane-t900 r28: refusal lifted -- see the split arm above. |
| 29661 | - let luma_scale = mc::scale_factor(sref_y.width, frame_width); | 29712 | + let luma_scale = mc::scale_factor(ref_width, frame_width); |
| 29662 | if luma_scale != mc::REF_NO_SCALE { | 29713 | if luma_scale != mc::REF_NO_SCALE { |
| 29663 | SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1)); | 29714 | SCALED_SUB8_HITS.with(|c| c.set(c.get() + 1)); |
| 29664 | } | 29715 | } |
| @@ -29820,8 +29871,18 @@ fn decode_inter_sub8_rect2( | |||
| 29820 | // Prediction over the leaf's true footprint, laid out at the group's | 29871 | // Prediction over the leaf's true footprint, laid out at the group's |
| 29821 | // square stride (what `reconstruct_mc_rect` and `read_inter_plane_rect` | 29872 | // square stride (what `reconstruct_mc_rect` and `read_inter_plane_rect` |
| 29822 | // index with). | 29873 | // index with). |
| 29823 | - let mut pred_y = vec![0u16; SIDE * SIDE]; | 29874 | + // lane-sub8group: this piece's prediction as a closure, so it runs |
| 29824 | - { | 29875 | + // where its writes run -- on a recon worker at more than one |
| 29876 | + // reconstruction thread, exactly like the 8x8 leaf's. | ||
| 29877 | + let build = move |_y: &mut PlaneBuf<'static>, | ||
| 29878 | + _u: &mut PlaneBuf<'static>, | ||
| 29879 | + _v: &mut PlaneBuf<'static>, | ||
| 29880 | + fctx: &crate::decode::FrameCtx, | ||
| 29881 | + out: &mut [Vec<u16>; 3]| { | ||
| 29882 | + let Some((sref_y, _, _)) = ref_planes_deferred(ref_frame, refpix) else { | ||
| 29883 | + return; | ||
| 29884 | + }; | ||
| 29885 | + let mut pred_y = refill(std::mem::take(&mut out[0]), SIDE * SIDE); | ||
| 29825 | let mut dense = vec![0u16; bw * bh]; | 29886 | let mut dense = vec![0u16; bw * bh]; |
| 29826 | mc::predict_maybe_scaled( | 29887 | mc::predict_maybe_scaled( |
| 29827 | &sref_y.data, | 29888 | &sref_y.data, |
| @@ -29840,9 +29901,21 @@ fn decode_inter_sub8_rect2( | |||
| 29840 | for row in 0..bh { | 29901 | for row in 0..bh { |
| 29841 | pred_y[row * SIDE..][..bw].copy_from_slice(&dense[row * bw..][..bw]); | 29902 | pred_y[row * SIDE..][..bw].copy_from_slice(&dense[row * bw..][..bw]); |
| 29842 | } | 29903 | } |
| 29843 | - } | 29904 | + out[0] = pred_y; |
| 29905 | + }; | ||
| 29906 | + let pred_y: Vec<u16>; | ||
| 29907 | + let sy = if recon_deferred(fctx) { | ||
| 29908 | + push_pred(fctx, build); | ||
| 29909 | + Pred::Cur { plane: 0, stride: SIDE, off: 0 } | ||
| 29910 | + } else { | ||
| 29911 | + let mut built: [Vec<u16>; 3] = Default::default(); | ||
| 29912 | + build(y, u, v, fctx, &mut built); | ||
| 29913 | + let [by, _, _] = built; | ||
| 29914 | + pred_y = by; | ||
| 29915 | + Pred::Inline(&pred_y, SIDE) | ||
| 29916 | + }; | ||
| 29844 | if skip { | 29917 | if skip { |
| 29845 | - push_mc_rect(0, px, py, SIDE, bw, bh, Pred::dense(&pred_y), &ZERO_RESIDUAL[..SIDE * SIDE], fctx); | 29918 | + push_mc_rect(0, px, py, SIDE, bw, bh, sy, &ZERO_RESIDUAL[..SIDE * SIDE], fctx); |
| 29846 | neighbours.record_mi_luma_rect(lmi, bw, bh, &ZERO_RESIDUAL[..bw * bh]); | 29919 | neighbours.record_mi_luma_rect(lmi, bw, bh, &ZERO_RESIDUAL[..bw * bh]); |
| 29847 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx); | 29920 | neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, bw as u8, bh as u8, ref_frame.max(LAST_FRAME), fctx); |
| 29848 | } else { | 29921 | } else { |
| @@ -29850,16 +29923,18 @@ fn decode_inter_sub8_rect2( | |||
| 29850 | for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { | 29923 | for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { |
| 29851 | let tu_mi = (rmi + row, cmi + col); | 29924 | let tu_mi = (rmi + row, cmi + col); |
| 29852 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); | 29925 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 29926 | + // This unit's offset into the block prediction (lane-sub8group). | ||
| 29927 | + let start = row * MI * SIDE + col * MI; | ||
| 29853 | let (tu_grid, tu_tx_type) = if tw == th { | 29928 | let (tu_grid, tu_tx_type) = if tw == th { |
| 29854 | // A split `TX_4X4` unit: square reader, its own | 29929 | // A split `TX_4X4` unit: square reader, its own |
| 29855 | // `get_txb_ctx_general` neighbour context (the unit is | 29930 | // `get_txb_ctx_general` neighbour context (the unit is |
| 29856 | // smaller than its plane block, so the lone-TU 0 does not | 29931 | // smaller than its plane block, so the lone-TU 0 does not |
| 29857 | // apply). | 29932 | // apply). |
| 29858 | - let mut tu_pred = Vec::with_capacity(tw * th); | 29933 | + // lane-sub8group: the unit's window of the block |
| 29859 | - for rr in 0..th { | 29934 | + // prediction, at the block's stride -- the dense copy the |
| 29860 | - let start = (row * MI + rr) * SIDE + col * MI; | 29935 | + // parse thread used to make is the recorded op's own |
| 29861 | - tu_pred.extend_from_slice(&pred_y[start..start + tw]); | 29936 | + // ([`push_mc_rect_tx`]), and a deferred prediction has no |
| 29862 | - } | 29937 | + // buffer here to copy out of. |
| 29863 | let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | 29938 | let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); |
| 29864 | read_inter_plane( | 29939 | read_inter_plane( |
| 29865 | dec, | 29940 | dec, |
| @@ -29878,7 +29953,7 @@ fn decode_inter_sub8_rect2( | |||
| 29878 | tu_py, | 29953 | tu_py, |
| 29879 | tw, | 29954 | tw, |
| 29880 | base_q_idx, | 29955 | base_q_idx, |
| 29881 | - Pred::dense(&tu_pred), | 29956 | + sy.offset(start), |
| 29882 | None, | 29957 | None, |
| 29883 | Some(tu_skip_ctx), fctx, | 29958 | Some(tu_skip_ctx), fctx, |
| 29884 | )? | 29959 | )? |
| @@ -29886,7 +29961,6 @@ fn decode_inter_sub8_rect2( | |||
| 29886 | // The whole leaf as one `TX_8X4`/`TX_4X8` unit: it IS the | 29961 | // The whole leaf as one `TX_8X4`/`TX_4X8` unit: it IS the |
| 29887 | // plane block, so `get_txb_ctx_general` fixes `txb_skip_ctx` | 29962 | // plane block, so `get_txb_ctx_general` fixes `txb_skip_ctx` |
| 29888 | // at 0 (`luma_skip_ctx: None`). | 29963 | // at 0 (`luma_skip_ctx: None`). |
| 29889 | - let start = row * MI * SIDE + col * MI; | ||
| 29890 | read_inter_plane_rect( | 29964 | read_inter_plane_rect( |
| 29891 | dec, | 29965 | dec, |
| 29892 | cdfs, | 29966 | cdfs, |
| @@ -29903,7 +29977,7 @@ fn decode_inter_sub8_rect2( | |||
| 29903 | y, | 29977 | y, |
| 29904 | tu_px, | 29978 | tu_px, |
| 29905 | tu_py, | 29979 | tu_py, |
| 29906 | - Pred::dense(&pred_y[start..]), | 29980 | + sy.offset(start), |
| 29907 | None, | 29981 | None, |
| 29908 | None, fctx, | 29982 | None, fctx, |
| 29909 | )? | 29983 | )? |
| @@ -29942,8 +30016,6 @@ fn decode_inter_sub8_rect2( | |||
| 29942 | // The group's single 4x4 chroma unit per plane, on the chroma-reference | 30016 | // The group's single 4x4 chroma unit per plane, on the chroma-reference |
| 29943 | // (second) sub-block's own skip flag. | 30017 | // (second) sub-block's own skip flag. |
| 29944 | const B4: usize = 4; | 30018 | const B4: usize = 4; |
| 29945 | - let mut pred_u = vec![0u16; B4 * B4]; | ||
| 29946 | - let mut pred_v = vec![0u16; B4 * B4]; | ||
| 29947 | // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY | 30019 | // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY |
| 29948 | // mi of the group is intra, so a group whose chroma reference is inter but | 30020 | // mi of the group is intra, so a group whose chroma reference is inter but |
| 29949 | // whose sibling is INTRA does NOT get the two-piece sub8x8 prediction: the | 30021 | // whose sibling is INTRA does NOT get the two-piece sub8x8 prediction: the |
| @@ -29963,12 +30035,23 @@ fn decode_inter_sub8_rect2( | |||
| 29963 | (false, true) => (2usize, 4usize), | 30035 | (false, true) => (2usize, 4usize), |
| 29964 | (false, false) => (4usize, 2usize), | 30036 | (false, false) => (4usize, 2usize), |
| 29965 | }; | 30037 | }; |
| 30038 | + // lane-sub8group: the group's chroma pieces, built on the worker that | ||
| 30039 | + // writes them -- the pieces' refs/mvs/filters travel by value. | ||
| 30040 | + let build = move |_y: &mut PlaneBuf<'static>, | ||
| 30041 | + _u: &mut PlaneBuf<'static>, | ||
| 30042 | + _v: &mut PlaneBuf<'static>, | ||
| 30043 | + fctx: &crate::decode::FrameCtx, | ||
| 30044 | + out: &mut [Vec<u16>; 3]| { | ||
| 30045 | + let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4); | ||
| 30046 | + let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4); | ||
| 29966 | for i in 0..2usize { | 30047 | for i in 0..2usize { |
| 29967 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | 30048 | let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { |
| 29968 | continue; | 30049 | continue; |
| 29969 | }; | 30050 | }; |
| 29970 | - let (piece_ref_y, sref_u, sref_v) = | 30051 | + let Some((piece_ref_y, sref_u, sref_v)) = ref_planes_deferred(ref_frame, refpix) |
| 29971 | - ref_planes(ref_frame, refpix)?; | 30052 | + else { |
| 30053 | + continue; | ||
| 30054 | + }; | ||
| 29972 | let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width); | 30055 | let piece_scale = mc::scale_factor(piece_ref_y.width, frame_width); |
| 29973 | let (ox, oy) = if mixed { | 30056 | let (ox, oy) = if mixed { |
| 29974 | (cpx, cpy) | 30057 | (cpx, cpy) |
| @@ -30007,20 +30090,37 @@ fn decode_inter_sub8_rect2( | |||
| 30007 | } | 30090 | } |
| 30008 | } | 30091 | } |
| 30009 | } | 30092 | } |
| 30093 | + out[1] = pred_u; | ||
| 30094 | + out[2] = pred_v; | ||
| 30095 | + }; | ||
| 30096 | + let (pred_u, pred_v): (Vec<u16>, Vec<u16>); | ||
| 30097 | + let (su, sv) = if recon_deferred(fctx) { | ||
| 30098 | + push_pred(fctx, build); | ||
| 30099 | + ( | ||
| 30100 | + Pred::Cur { plane: 1, stride: B4, off: 0 }, | ||
| 30101 | + Pred::Cur { plane: 2, stride: B4, off: 0 }, | ||
| 30102 | + ) | ||
| 30103 | + } else { | ||
| 30104 | + let mut built: [Vec<u16>; 3] = Default::default(); | ||
| 30105 | + build(y, u, v, fctx, &mut built); | ||
| 30106 | + let [_, bu, bv] = built; | ||
| 30107 | + (pred_u, pred_v) = (bu, bv); | ||
| 30108 | + (Pred::Inline(&pred_u, B4), Pred::Inline(&pred_v, B4)) | ||
| 30109 | + }; | ||
| 30010 | let (u_grid, v_grid) = if last_skip { | 30110 | let (u_grid, v_grid) = if last_skip { |
| 30011 | - push_mc(1, cpx, cpy, B4, Pred::dense(&pred_u), &ZERO_RESIDUAL[..B4 * B4], fctx); | 30111 | + push_mc(1, cpx, cpy, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx); |
| 30012 | - push_mc(2, cpx, cpy, B4, Pred::dense(&pred_v), &ZERO_RESIDUAL[..B4 * B4], fctx); | 30112 | + push_mc(2, cpx, cpy, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx); |
| 30013 | (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4)) | 30113 | (Grid::Zero(B4 * B4), Grid::Zero(B4 * B4)) |
| 30014 | } else { | 30114 | } else { |
| 30015 | let around = neighbours.around_mi(group_mi, 8); | 30115 | let around = neighbours.around_mi(group_mi, 8); |
| 30016 | let ug = read_inter_plane( | 30116 | let ug = read_inter_plane( |
| 30017 | dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | 30117 | dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, |
| 30018 | - Pred::dense(&pred_u), Some(first_tx_type), None, fctx, | 30118 | + su, Some(first_tx_type), None, fctx, |
| 30019 | )? | 30119 | )? |
| 30020 | .0; | 30120 | .0; |
| 30021 | let vg = read_inter_plane( | 30121 | let vg = read_inter_plane( |
| 30022 | dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | 30122 | dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, |
| 30023 | - Pred::dense(&pred_v), Some(first_tx_type), None, fctx, | 30123 | + sv, Some(first_tx_type), None, fctx, |
| 30024 | )? | 30124 | )? |
| 30025 | .0; | 30125 | .0; |
| 30026 | let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); | 30126 | let coded = ug.iter().chain(vg.iter()).any(|&c| c != 0); |