Merge 05263618 (422blockhalf) — suite green: review PASS 0.86 on 213c1eb0, suite queued READY
Browse files at this commit2 changed files +552 -138
- crates/ec-av1/src/decode.rs +419 -138
- lanes/av1422blockhalf.report.md +133 -0
crates/ec-av1/src/decode.rsmodified+419 -138
| @@ -10304,6 +10304,21 @@ fn decode_rect_split( | |||
| 10304 | let (px, py) = (mi_c * MI, mi_r * MI); | 10304 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 10305 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); | 10305 | let (cpx, cpy) = (px >> ss_x(fctx), py >> ss_y(fctx)); |
| 10306 | let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); | 10306 | let (chroma_w, chroma_h) = (bw >> ss_x(fctx), bh >> ss_y(fctx)); |
| 10307 | + // lane-av1-422blockhalf: at ss (1,0) the tall/wide 1:2 and 1:4 strips' | ||
| 10308 | + // chroma plane block is BLOCK_INVALID (`av1_ss_size_lookup[...][1][0]`, | ||
| 10309 | + // blockd.h -- the 4:2:2 column maps BLOCK_8X16/16X32/32X64/64X128 and | ||
| 10310 | + // BLOCK_8X32/16X64, plus 4-wide BLOCK_4X16, to BLOCK_INVALID), so | ||
| 10311 | + // `av1_get_max_uv_txsize` indexes `max_txsize_rect_lookup` OUT OF BOUNDS | ||
| 10312 | + // and the pinned Release oracle byte there is TX_4X8 (the lane-av1-422m | ||
| 10313 | + // measurement). The plane is still coded -- `decode_token_recon_block` | ||
| 10314 | + // steps it in that (4, 8) unit shape -- so the strip's chroma tiles into | ||
| 10315 | + // 4x8 rect units, plane-major. | ||
| 10316 | + let chroma_422_oob = ss_x(fctx) == 1 | ||
| 10317 | + && ss_y(fctx) == 0 | ||
| 10318 | + && matches!( | ||
| 10319 | + (bw, bh), | ||
| 10320 | + (8, 16) | (16, 32) | (32, 64) | (64, 128) | (8, 32) | (16, 64) | ||
| 10321 | + ); | ||
| 10307 | // The chroma transform is picked before any symbol is read, so an | 10322 | // The chroma transform is picked before any symbol is read, so an |
| 10308 | // unsupported chroma shape refuses before this strip desyncs the tile. | 10323 | // unsupported chroma shape refuses before this strip desyncs the tile. |
| 10309 | let chroma: Option<(TxbSet, &[u16])> = match (chroma_w, chroma_h) { | 10324 | let chroma: Option<(TxbSet, &[u16])> = match (chroma_w, chroma_h) { |
| @@ -10334,10 +10349,16 @@ fn decode_rect_split( | |||
| 10334 | // (16x8 luma -> 8x8 chroma) -- the square rows below. At 4:2:0 and 4:4:4 a | 10349 | // (16x8 luma -> 8x8 chroma) -- the square rows below. At 4:2:0 and 4:4:4 a |
| 10335 | // rect strip's chroma is itself rect, so the square rows are unreachable | 10350 | // rect strip's chroma is itself rect, so the square rows are unreachable |
| 10336 | // there and cannot change their results. | 10351 | // there and cannot change their results. |
| 10337 | - let chroma_tiled = matches!( | 10352 | + // lane-av1-422blockhalf: the tiled arms below handle every shape this |
| 10338 | - (chroma_w, chroma_h), | 10353 | + // strip can carry (including the 4:2:2 BLOCK_INVALID planes), so the |
| 10339 | - (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8) | 10354 | + // diagnostic names only the shapes that would actually refuse -- it used |
| 10340 | - ); | 10355 | + // to fire for every tiled square too (the parent lane's `chroma=8x8` |
| 10356 | + // rows) and sent the next lane chasing handled shapes. | ||
| 10357 | + let chroma_tiled = chroma_422_oob | ||
| 10358 | + || matches!( | ||
| 10359 | + (chroma_w, chroma_h), | ||
| 10360 | + (64, 32) | (32, 64) | (64, 16) | (16, 64) | (32, 32) | (16, 16) | (8, 8) | ||
| 10361 | + ); | ||
| 10341 | if !m.skip { | 10362 | if !m.skip { |
| 10342 | if let Some(i) = match (chroma_w, chroma_h) { | 10363 | if let Some(i) = match (chroma_w, chroma_h) { |
| 10343 | (32, 8) => Some(0), | 10364 | (32, 8) => Some(0), |
| @@ -10354,23 +10375,13 @@ fn decode_rect_split( | |||
| 10354 | }); | 10375 | }); |
| 10355 | } | 10376 | } |
| 10356 | } | 10377 | } |
| 10357 | - if chroma.is_none() && !chroma_tiled { | 10378 | + if !m.skip && chroma.is_none() && !chroma_tiled { |
| 10358 | // Diagnostic for the next caller that lands here (class | 10379 | // Diagnostic for the next caller that lands here (class |
| 10359 | // refusal-names-a-correlate: the message names the tool, not the | 10380 | // refusal-names-a-correlate: the message names the tool, not the |
| 10360 | // shape); the refusal below keeps its inventory-pinned wording. | 10381 | // shape); the refusal below keeps its inventory-pinned wording. |
| 10361 | - // The condition is the refusal's exact precondition, so the | ||
| 10362 | - // print can never fire without the refusal (or vice versa): the | ||
| 10363 | - // four 64-axis chroma shapes are tiled below and at LOSSLESS the | ||
| 10364 | - // 4x4 walk never consults `chroma` at all -- libaom has no such | ||
| 10365 | - // transform to name a row for (`av1_get_tx_size` returns TX_4X4 | ||
| 10366 | - // for every plane at lossless, blockd.h:1383; outside it | ||
| 10367 | - // `av1_get_adjusted_tx_size` collapses TX_64X32/32X64 to TX_32X32 | ||
| 10368 | - // for chroma, blockd.h:1361-1367). lane-av1-ll64: the old | ||
| 10369 | - // ungated print fired on those working routes and mislabelled | ||
| 10370 | - // them a gap (one lane report cited it as a decode stop). | ||
| 10371 | eprintln!( | 10382 | eprintln!( |
| 10372 | "EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} \ | 10383 | "EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} \ |
| 10373 | - chroma={chroma_w}x{chroma_h} libaom_lossless_tx=none" | 10384 | + chroma={chroma_w}x{chroma_h}" |
| 10374 | ); | 10385 | ); |
| 10375 | } | 10386 | } |
| 10376 | } | 10387 | } |
| @@ -10680,20 +10691,59 @@ fn decode_rect_split( | |||
| 10680 | (zero.clone(), zero) | 10691 | (zero.clone(), zero) |
| 10681 | } else if m.skip { | 10692 | } else if m.skip { |
| 10682 | let zero = Grid::Zero(chroma_w * chroma_h); | 10693 | let zero = Grid::Zero(chroma_w * chroma_h); |
| 10683 | - if let Some((ub, _)) = &m.palette_uv { | 10694 | + if chroma_422_oob { |
| 10684 | - set_palette_pred(ub.clone(), fctx); | 10695 | + // lane-av1-422blockhalf: libaom predicts an INTRA strip's chroma |
| 10685 | - } | 10696 | + // per transform unit even when the strip is skipped |
| 10686 | - push_intra_rect(1, | 10697 | + // (`decode_token_recon_block`'s per-TU plane walk runs before the |
| 10687 | - cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, | 10698 | + // skip guard), so the BLOCK_INVALID plane predicts as (4, 8) |
| 10688 | - m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, | 10699 | + // units -- one whole-plane push here would ask the intra |
| 10689 | - ); | 10700 | + // predictor for a 1:8 rect it never needs. |
| 10690 | - if let Some((_, vb)) = &m.palette_uv { | 10701 | + let (uw, uh) = (4usize, 8usize); |
| 10691 | - set_palette_pred(vb.clone(), fctx); | 10702 | + for plane_idx in 1..=2 { |
| 10703 | + if let Some((ub, vb)) = &m.palette_uv { | ||
| 10704 | + let buf = if plane_idx == 1 { ub } else { vb }; | ||
| 10705 | + set_palette_pred(buf.clone(), fctx); | ||
| 10706 | + } | ||
| 10707 | + for cu_row in 0..chroma_h / uh { | ||
| 10708 | + for cu_col in 0..chroma_w / uw { | ||
| 10709 | + push_intra_rect( | ||
| 10710 | + plane_idx, | ||
| 10711 | + cpx + cu_col * uw, | ||
| 10712 | + cpy + cu_row * uh, | ||
| 10713 | + uw, | ||
| 10714 | + uh, | ||
| 10715 | + m.uv_predict_mode, | ||
| 10716 | + m.angle_delta_uv, | ||
| 10717 | + reach, | ||
| 10718 | + &ZERO_RESIDUAL[..uw * uh], | ||
| 10719 | + m.alpha.zip(ac.clone()).map(|((au, av), ac)| { | ||
| 10720 | + ( | ||
| 10721 | + if plane_idx == 1 { au } else { av }, | ||
| 10722 | + ac, | ||
| 10723 | + ) | ||
| 10724 | + }), | ||
| 10725 | + None, | ||
| 10726 | + m.smooth_neighbor_uv, fctx, | ||
| 10727 | + ); | ||
| 10728 | + } | ||
| 10729 | + } | ||
| 10730 | + } | ||
| 10731 | + } else { | ||
| 10732 | + if let Some((ub, _)) = &m.palette_uv { | ||
| 10733 | + set_palette_pred(ub.clone(), fctx); | ||
| 10734 | + } | ||
| 10735 | + push_intra_rect(1, | ||
| 10736 | + cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, | ||
| 10737 | + m.alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, m.smooth_neighbor_uv, fctx, | ||
| 10738 | + ); | ||
| 10739 | + if let Some((_, vb)) = &m.palette_uv { | ||
| 10740 | + set_palette_pred(vb.clone(), fctx); | ||
| 10741 | + } | ||
| 10742 | + push_intra_rect(2, | ||
| 10743 | + cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, | ||
| 10744 | + m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, | ||
| 10745 | + ); | ||
| 10692 | } | 10746 | } |
| 10693 | - push_intra_rect(2, | ||
| 10694 | - cpx, cpy, chroma_w, chroma_h, m.uv_predict_mode, m.angle_delta_uv, reach, &zero, | ||
| 10695 | - m.alpha.zip(ac).map(|((_, av), ac)| (av, ac)), None, m.smooth_neighbor_uv, fctx, | ||
| 10696 | - ); | ||
| 10697 | (zero.clone(), zero) | 10747 | (zero.clone(), zero) |
| 10698 | } else if lossless(fctx) { | 10748 | } else if lossless(fctx) { |
| 10699 | // lane-lossless: the strip's chroma plane block is coded as 4x4 | 10749 | // lane-lossless: the strip's chroma plane block is coded as 4x4 |
| @@ -10763,15 +10813,22 @@ fn decode_rect_split( | |||
| 10763 | let [ug, vg] = last; | 10813 | let [ug, vg] = last; |
| 10764 | (ug, vg) | 10814 | (ug, vg) |
| 10765 | } else if chroma_tiled { | 10815 | } else if chroma_tiled { |
| 10766 | - let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = match (chroma_w, chroma_h) { | 10816 | + let (uw, uh, set, scan): (usize, usize, TxbSet, &[u16]) = if chroma_422_oob { |
| 10767 | - (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)), | 10817 | + // lane-av1-422blockhalf: the BLOCK_INVALID-plane strip's (4, 8) |
| 10768 | - (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16), | 10818 | + // units -- the Release oracle's out-of-bounds |
| 10769 | - (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32), | 10819 | + // `max_txsize_rect_lookup[BLOCK_INVALID]` byte (see above). |
| 10770 | - // lane-av1-422: the 4:2:2 square chroma planes (height unhalved), | 10820 | + (4, 8, TxbSet::ChromaRect8x4, &SCAN_4X8) |
| 10771 | - // through the square reader like every other square chroma unit. | 10821 | + } else { |
| 10772 | - (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)), | 10822 | + match (chroma_w, chroma_h) { |
| 10773 | - (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)), | 10823 | + (64, 32) | (32, 64) | (32, 32) => (32, 32, TxbSet::Chroma32, default_scan(32)), |
| 10774 | - _ => unreachable!("chroma_tiled"), | 10824 | + (64, 16) => (32, 16, TxbSet::ChromaRect32x16, &SCAN_32X16), |
| 10825 | + (16, 64) => (16, 32, TxbSet::ChromaRect32x16, &SCAN_16X32), | ||
| 10826 | + // lane-av1-422: the 4:2:2 square chroma planes (height unhalved), | ||
| 10827 | + // through the square reader like every other square chroma unit. | ||
| 10828 | + (16, 16) => (16, 16, TxbSet::Chroma16, default_scan(16)), | ||
| 10829 | + (8, 8) => (8, 8, TxbSet::Chroma8, default_scan(8)), | ||
| 10830 | + _ => unreachable!("chroma_tiled"), | ||
| 10831 | + } | ||
| 10775 | }; | 10832 | }; |
| 10776 | // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 | 10833 | // lane-av1-422: the witness counter, keyed to ss (1,0) so only a 4:2:2 |
| 10777 | // frame's square chroma units count it. | 10834 | // frame's square chroma units count it. |
| @@ -10780,7 +10837,15 @@ fn decode_rect_split( | |||
| 10780 | } | 10837 | } |
| 10781 | let (nw, nh) = (chroma_w / uw, chroma_h / uh); | 10838 | let (nw, nh) = (chroma_w / uw, chroma_h / uh); |
| 10782 | let bigger = chroma_w * chroma_h > uw * uh; | 10839 | let bigger = chroma_w * chroma_h > uw * uh; |
| 10783 | - let default_tx = TxType::DctDct; | 10840 | + // `av1_get_ext_tx_set_type`: a chroma transform whose square-up size |
| 10841 | + // is TX_32X32 or bigger resolves to `EXT_TX_SET_DCTONLY` for intra; | ||
| 10842 | + // smaller rect units (the 4:2:2 BLOCK_INVALID-plane (4, 8)s) take the | ||
| 10843 | + // mode-indexed default, the same rule the unsplit arm below applies. | ||
| 10844 | + let default_tx = if uw.max(uh) >= 32 { | ||
| 10845 | + TxType::DctDct | ||
| 10846 | + } else { | ||
| 10847 | + default_intra_tx_type(m.uv_predict_mode as u8) | ||
| 10848 | + }; | ||
| 10784 | let mut last = [Grid::Zero(uw * uh), Grid::Zero(uw * uh)]; | 10849 | let mut last = [Grid::Zero(uw * uh), Grid::Zero(uw * uh)]; |
| 10785 | for plane_idx in 1..=2 { | 10850 | for plane_idx in 1..=2 { |
| 10786 | for cu_row in 0..nh { | 10851 | for cu_row in 0..nh { |
| @@ -10791,7 +10856,17 @@ fn decode_rect_split( | |||
| 10791 | mi_r + cu_row * (luma_span_y / MI), | 10856 | mi_r + cu_row * (luma_span_y / MI), |
| 10792 | mi_c + cu_col * (luma_span_x / MI), | 10857 | mi_c + cu_col * (luma_span_x / MI), |
| 10793 | ); | 10858 | ); |
| 10794 | - let cu_around = neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y); | 10859 | + // lane-av1-422blockhalf: the 4:2:2 (4, 8) units read their |
| 10860 | + // chroma context per chroma cell | ||
| 10861 | + // ([`Neighbours::around_mi_422_chroma`], the block-8 | ||
| 10862 | + // rule) -- the plain rect walk samples one chroma cell | ||
| 10863 | + // twice at ss_x 1. Every pre-existing shape keeps its own | ||
| 10864 | + // walk. | ||
| 10865 | + let cu_around = if chroma_422_oob { | ||
| 10866 | + neighbours.around_mi_422_chroma(cu_mi, luma_span_x, luma_span_y) | ||
| 10867 | + } else { | ||
| 10868 | + neighbours.around_mi_rect(cu_mi, luma_span_x, luma_span_y) | ||
| 10869 | + }; | ||
| 10795 | let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh); | 10870 | let (cu_x, cu_y) = (cpx + cu_col * uw, cpy + cu_row * uh); |
| 10796 | let cfl = m.alpha.map(|(au, av)| { | 10871 | let cfl = m.alpha.map(|(au, av)| { |
| 10797 | let alpha = if plane_idx == 1 { au } else { av }; | 10872 | let alpha = if plane_idx == 1 { au } else { av }; |
| @@ -23756,6 +23831,12 @@ fn read_inter_rect_chroma( | |||
| 23756 | let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh); | 23831 | let (nx, ny) = (write_chroma_w / uw, write_chroma_h / uh); |
| 23757 | let multi = nx * ny > 1; | 23832 | let multi = nx * ny > 1; |
| 23758 | let set = rect_inter_chroma_set(uw, uh)?; | 23833 | let set = rect_inter_chroma_set(uw, uh)?; |
| 23834 | + // lane-av1-422blockhalf: the assembled block grid is the PRED stride x | ||
| 23835 | + // the plane's true height -- at 4:2:2 a square block's plane is | ||
| 23836 | + // (side/2, side), so the old `chroma_side`-square sizing under-allocated | ||
| 23837 | + // every row past `chroma_stride` once the caller began passing the | ||
| 23838 | + // per-axis stride. | ||
| 23839 | + let assembled_h = write_chroma_h.max(chroma_side); | ||
| 23759 | let mut assembled: [Vec<i32>; 2] = [Vec::new(), Vec::new()]; | 23840 | let mut assembled: [Vec<i32>; 2] = [Vec::new(), Vec::new()]; |
| 23760 | // The multi-unit stamps below are rewritten by the caller's whole-block | 23841 | // The multi-unit stamps below are rewritten by the caller's whole-block |
| 23761 | // record (`record_rect_mi`/`record_split_luma_rect_mi` write ONE | 23842 | // record (`record_rect_mi`/`record_split_luma_rect_mi` write ONE |
| @@ -23767,8 +23848,8 @@ fn read_inter_rect_chroma( | |||
| 23767 | if multi { | 23848 | if multi { |
| 23768 | hit!(CHROMA_SPLIT_TX_HITS); | 23849 | hit!(CHROMA_SPLIT_TX_HITS); |
| 23769 | assembled = [ | 23850 | assembled = [ |
| 23770 | - vec![0i32; chroma_side * chroma_side], | 23851 | + vec![0i32; chroma_side * assembled_h], |
| 23771 | - vec![0i32; chroma_side * chroma_side], | 23852 | + vec![0i32; chroma_side * assembled_h], |
| 23772 | ]; | 23853 | ]; |
| 23773 | } | 23854 | } |
| 23774 | for plane_idx in 1..=2 { | 23855 | for plane_idx in 1..=2 { |
| @@ -23819,7 +23900,12 @@ fn read_inter_rect_chroma( | |||
| 23819 | } | 23900 | } |
| 23820 | units.push((cu_mi, plane_idx, cu_grid, span_x, span_y)); | 23901 | units.push((cu_mi, plane_idx, cu_grid, span_x, span_y)); |
| 23821 | } else { | 23902 | } else { |
| 23822 | - assembled[plane_idx - 1] = embed_rect_grid(&cu_grid, uw, uh, chroma_side); | 23903 | + let mut full = vec![0i32; chroma_side * assembled_h]; |
| 23904 | + for rr in 0..uh { | ||
| 23905 | + full[rr * chroma_side..][..uw] | ||
| 23906 | + .copy_from_slice(&cu_grid[rr * uw..][..uw]); | ||
| 23907 | + } | ||
| 23908 | + assembled[plane_idx - 1] = full; | ||
| 23823 | } | 23909 | } |
| 23824 | } | 23910 | } |
| 23825 | } | 23911 | } |
| @@ -32524,6 +32610,20 @@ fn decode_inter_block( | |||
| 32524 | } | 32610 | } |
| 32525 | _ => (write_w >> ss_x(fctx), write_h >> ss_y(fctx)), | 32611 | _ => (write_w >> ss_x(fctx), write_h >> ss_y(fctx)), |
| 32526 | }; | 32612 | }; |
| 32613 | + // lane-av1-422blockhalf: the chroma PREDICTION buffers take the PLANE | ||
| 32614 | + // BLOCK's own per-axis shape at 4:2:2 -- (side/2, side) -- instead of the | ||
| 32615 | + // enclosing square `chroma_side` the pre-port model indexed, and the | ||
| 32616 | + // masked-compound blend reads its luma mask through the plane's real | ||
| 32617 | + // subsampling shifts (aom_dsp/blend-a64-mask.c's four branches; the | ||
| 32618 | + // stop-note this lane owns). Every consumer below strides with | ||
| 32619 | + // `chroma_stride`. At 4:2:0 and 4:4:4 both values reduce to the square | ||
| 32620 | + // `chroma_side` verbatim, so only 4:2:2 changes shape. | ||
| 32621 | + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; | ||
| 32622 | + let (chroma_stride, chroma_buf_h) = if chroma_422 { | ||
| 32623 | + (write_chroma_w, write_chroma_h) | ||
| 32624 | + } else { | ||
| 32625 | + (chroma_side, chroma_side) | ||
| 32626 | + }; | ||
| 32527 | let (chroma_set, chroma_tx, scan_chroma) = | 32627 | let (chroma_set, chroma_tx, scan_chroma) = |
| 32528 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 && strip_chroma.is_none() { | 32628 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 && strip_chroma.is_none() { |
| 32529 | let tx = if side >= 64 { 32 } else { side }; | 32629 | let tx = if side >= 64 { 32 } else { side }; |
| @@ -33405,7 +33505,7 @@ fn decode_inter_block( | |||
| 33405 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y, fctx); | 33505 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y, fctx); |
| 33406 | } | 33506 | } |
| 33407 | 33507 | ||
| 33408 | - let mut inter0_u = vec![0i32; chroma_side * chroma_side]; | 33508 | + let mut inter0_u = vec![0i32; chroma_stride * chroma_buf_h]; |
| 33409 | mc::predict_compound_intermediate_kern( | 33509 | mc::predict_compound_intermediate_kern( |
| 33410 | &pu0.data, | 33510 | &pu0.data, |
| 33411 | pu0.width, | 33511 | pu0.width, |
| @@ -33414,8 +33514,8 @@ fn decode_inter_block( | |||
| 33414 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), | 33514 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 33415 | mv_to_q4(cpy, mv0.0, ss_x(fctx)), | 33515 | mv_to_q4(cpy, mv0.0, ss_x(fctx)), |
| 33416 | scale0, | 33516 | scale0, |
| 33417 | - chroma_side, | 33517 | + chroma_stride, |
| 33418 | - chroma_side, | 33518 | + chroma_buf_h, |
| 33419 | write_chroma_w, | 33519 | write_chroma_w, |
| 33420 | write_chroma_h, | 33520 | write_chroma_h, |
| 33421 | h_filter, | 33521 | h_filter, |
| @@ -33429,11 +33529,11 @@ fn decode_inter_block( | |||
| 33429 | crate::warp::warp_affine_compound( | 33529 | crate::warp::warp_affine_compound( |
| 33430 | wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32, | 33530 | wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32, |
| 33431 | pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32, | 33531 | pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32, |
| 33432 | - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | 33532 | + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 33433 | ); | 33533 | ); |
| 33434 | } | 33534 | } |
| 33435 | } | 33535 | } |
| 33436 | - let mut inter1_u = vec![0i32; chroma_side * chroma_side]; | 33536 | + let mut inter1_u = vec![0i32; chroma_stride * chroma_buf_h]; |
| 33437 | mc::predict_compound_intermediate_kern( | 33537 | mc::predict_compound_intermediate_kern( |
| 33438 | &pu1.data, | 33538 | &pu1.data, |
| 33439 | pu1.width, | 33539 | pu1.width, |
| @@ -33442,8 +33542,8 @@ fn decode_inter_block( | |||
| 33442 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), | 33542 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 33443 | mv_to_q4(cpy, mv1.0, ss_x(fctx)), | 33543 | mv_to_q4(cpy, mv1.0, ss_x(fctx)), |
| 33444 | scale1, | 33544 | scale1, |
| 33445 | - chroma_side, | 33545 | + chroma_stride, |
| 33446 | - chroma_side, | 33546 | + chroma_buf_h, |
| 33447 | write_chroma_w, | 33547 | write_chroma_w, |
| 33448 | write_chroma_h, | 33548 | write_chroma_h, |
| 33449 | h_filter, | 33549 | h_filter, |
| @@ -33457,35 +33557,33 @@ fn decode_inter_block( | |||
| 33457 | crate::warp::warp_affine_compound( | 33557 | crate::warp::warp_affine_compound( |
| 33458 | wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32, | 33558 | wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32, |
| 33459 | pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32, | 33559 | pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32, |
| 33460 | - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | 33560 | + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 33461 | ); | 33561 | ); |
| 33462 | } | 33562 | } |
| 33463 | } | 33563 | } |
| 33464 | - let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side); | 33564 | + let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h); |
| 33465 | if let Some(mask_y) = mask_y { | 33565 | if let Some(mask_y) = mask_y { |
| 33466 | - // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma | 33566 | + // lane-av1-422blockhalf: the blend walks this plane's own |
| 33467 | - // prediction is still the square-cut model (the owning | 33567 | + // (chroma_stride x chroma_buf_h) rect through the plane's |
| 33468 | - // parent-lane surface) -- its buffer is `chroma_side`-square | 33568 | + // real subsampling shifts -- the mask read is aom_dsp/ |
| 33469 | - // and cannot be indexed by the subsampled-axis mask walks, | 33569 | + // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct |
| 33470 | - // so at ss_x != ss_y the blend keeps the direct | 33570 | + // luma sample at 4:2:0/4:4:4. |
| 33471 | - // luma-resolution read (the pre-port behaviour, known | ||
| 33472 | - // divergent there) until that surface itself is ported. | ||
| 33473 | mc::blend_masked_compound( | 33571 | mc::blend_masked_compound( |
| 33474 | &inter0_u, | 33572 | &inter0_u, |
| 33475 | &inter1_u, | 33573 | &inter1_u, |
| 33476 | mask_y, | 33574 | mask_y, |
| 33477 | side, | 33575 | side, |
| 33478 | - chroma_side, | 33576 | + chroma_stride, |
| 33479 | - chroma_side, | 33577 | + chroma_buf_h, |
| 33480 | - if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 }, | 33578 | + ss_x(fctx), |
| 33481 | - if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 }, | 33579 | + ss_y(fctx), |
| 33482 | &mut pred_u, fctx, | 33580 | &mut pred_u, fctx, |
| 33483 | ); | 33581 | ); |
| 33484 | } else { | 33582 | } else { |
| 33485 | mc::combine_compound(&inter0_u, &inter1_u, fwd_offset, bck_offset, &mut pred_u, fctx); | 33583 | mc::combine_compound(&inter0_u, &inter1_u, fwd_offset, bck_offset, &mut pred_u, fctx); |
| 33486 | } | 33584 | } |
| 33487 | 33585 | ||
| 33488 | - let mut inter0_v = vec![0i32; chroma_side * chroma_side]; | 33586 | + let mut inter0_v = vec![0i32; chroma_stride * chroma_buf_h]; |
| 33489 | mc::predict_compound_intermediate_kern( | 33587 | mc::predict_compound_intermediate_kern( |
| 33490 | &pv0.data, | 33588 | &pv0.data, |
| 33491 | pv0.width, | 33589 | pv0.width, |
| @@ -33494,8 +33592,8 @@ fn decode_inter_block( | |||
| 33494 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), | 33592 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 33495 | mv_to_q4(cpy, mv0.0, ss_x(fctx)), | 33593 | mv_to_q4(cpy, mv0.0, ss_x(fctx)), |
| 33496 | scale0, | 33594 | scale0, |
| 33497 | - chroma_side, | 33595 | + chroma_stride, |
| 33498 | - chroma_side, | 33596 | + chroma_buf_h, |
| 33499 | write_chroma_w, | 33597 | write_chroma_w, |
| 33500 | write_chroma_h, | 33598 | write_chroma_h, |
| 33501 | h_filter, | 33599 | h_filter, |
| @@ -33509,11 +33607,11 @@ fn decode_inter_block( | |||
| 33509 | crate::warp::warp_affine_compound( | 33607 | crate::warp::warp_affine_compound( |
| 33510 | wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32, | 33608 | wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32, |
| 33511 | pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32, | 33609 | pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32, |
| 33512 | - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | 33610 | + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 33513 | ); | 33611 | ); |
| 33514 | } | 33612 | } |
| 33515 | } | 33613 | } |
| 33516 | - let mut inter1_v = vec![0i32; chroma_side * chroma_side]; | 33614 | + let mut inter1_v = vec![0i32; chroma_stride * chroma_buf_h]; |
| 33517 | mc::predict_compound_intermediate_kern( | 33615 | mc::predict_compound_intermediate_kern( |
| 33518 | &pv1.data, | 33616 | &pv1.data, |
| 33519 | pv1.width, | 33617 | pv1.width, |
| @@ -33522,8 +33620,8 @@ fn decode_inter_block( | |||
| 33522 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), | 33620 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 33523 | mv_to_q4(cpy, mv1.0, ss_x(fctx)), | 33621 | mv_to_q4(cpy, mv1.0, ss_x(fctx)), |
| 33524 | scale1, | 33622 | scale1, |
| 33525 | - chroma_side, | 33623 | + chroma_stride, |
| 33526 | - chroma_side, | 33624 | + chroma_buf_h, |
| 33527 | write_chroma_w, | 33625 | write_chroma_w, |
| 33528 | write_chroma_h, | 33626 | write_chroma_h, |
| 33529 | h_filter, | 33627 | h_filter, |
| @@ -33537,28 +33635,26 @@ fn decode_inter_block( | |||
| 33537 | crate::warp::warp_affine_compound( | 33635 | crate::warp::warp_affine_compound( |
| 33538 | wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32, | 33636 | wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32, |
| 33539 | pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32, | 33637 | pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32, |
| 33540 | - chroma_side as i32, chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | 33638 | + chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 33541 | ); | 33639 | ); |
| 33542 | } | 33640 | } |
| 33543 | } | 33641 | } |
| 33544 | - let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side); | 33642 | + let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h); |
| 33545 | if let Some(mask_y) = mask_y { | 33643 | if let Some(mask_y) = mask_y { |
| 33546 | - // lane-av1-422sub8rect stop-note: this fn's 4:2:2 chroma | 33644 | + // lane-av1-422blockhalf: the blend walks this plane's own |
| 33547 | - // prediction is still the square-cut model (the owning | 33645 | + // (chroma_stride x chroma_buf_h) rect through the plane's |
| 33548 | - // parent-lane surface) -- its buffer is `chroma_side`-square | 33646 | + // real subsampling shifts -- the mask read is aom_dsp/ |
| 33549 | - // and cannot be indexed by the subsampled-axis mask walks, | 33647 | + // blend-a64-mask.c's `(1, 0)` branch at 4:2:2, the direct |
| 33550 | - // so at ss_x != ss_y the blend keeps the direct | 33648 | + // luma sample at 4:2:0/4:4:4. |
| 33551 | - // luma-resolution read (the pre-port behaviour, known | ||
| 33552 | - // divergent there) until that surface itself is ported. | ||
| 33553 | mc::blend_masked_compound( | 33649 | mc::blend_masked_compound( |
| 33554 | &inter0_v, | 33650 | &inter0_v, |
| 33555 | &inter1_v, | 33651 | &inter1_v, |
| 33556 | mask_y, | 33652 | mask_y, |
| 33557 | side, | 33653 | side, |
| 33558 | - chroma_side, | 33654 | + chroma_stride, |
| 33559 | - chroma_side, | 33655 | + chroma_buf_h, |
| 33560 | - if ss_x(fctx) == ss_y(fctx) { ss_x(fctx) } else { 0 }, | 33656 | + ss_x(fctx), |
| 33561 | - if ss_x(fctx) == ss_y(fctx) { ss_y(fctx) } else { 0 }, | 33657 | + ss_y(fctx), |
| 33562 | &mut pred_v, fctx, | 33658 | &mut pred_v, fctx, |
| 33563 | ); | 33659 | ); |
| 33564 | } else { | 33660 | } else { |
| @@ -33574,8 +33670,8 @@ fn decode_inter_block( | |||
| 33574 | push_pred(fctx, build); | 33670 | push_pred(fctx, build); |
| 33575 | ( | 33671 | ( |
| 33576 | Pred::Cur { plane: 0, stride: side, off: 0 }, | 33672 | Pred::Cur { plane: 0, stride: side, off: 0 }, |
| 33577 | - Pred::Cur { plane: 1, stride: chroma_side, off: 0 }, | 33673 | + Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, |
| 33578 | - Pred::Cur { plane: 2, stride: chroma_side, off: 0 }, | 33674 | + Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }, |
| 33579 | ) | 33675 | ) |
| 33580 | } else { | 33676 | } else { |
| 33581 | let mut built: [Vec<u16>; 3] = Default::default(); | 33677 | let mut built: [Vec<u16>; 3] = Default::default(); |
| @@ -33584,8 +33680,8 @@ fn decode_inter_block( | |||
| 33584 | (pred_y, pred_u, pred_v) = (by, bu, bv); | 33680 | (pred_y, pred_u, pred_v) = (by, bu, bv); |
| 33585 | ( | 33681 | ( |
| 33586 | Pred::Inline(&pred_y, side), | 33682 | Pred::Inline(&pred_y, side), |
| 33587 | - Pred::Inline(&pred_u, chroma_side), | 33683 | + Pred::Inline(&pred_u, chroma_stride), |
| 33588 | - Pred::Inline(&pred_v, chroma_side), | 33684 | + Pred::Inline(&pred_v, chroma_stride), |
| 33589 | ) | 33685 | ) |
| 33590 | }; | 33686 | }; |
| 33591 | 33687 | ||
| @@ -33626,24 +33722,24 @@ fn decode_inter_block( | |||
| 33626 | push_mc_rect(1, | 33722 | push_mc_rect(1, |
| 33627 | cpx, | 33723 | cpx, |
| 33628 | cpy, | 33724 | cpy, |
| 33629 | - chroma_side, | 33725 | + chroma_stride, |
| 33630 | write_chroma_w, | 33726 | write_chroma_w, |
| 33631 | write_chroma_h, | 33727 | write_chroma_h, |
| 33632 | su, | 33728 | su, |
| 33633 | - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, | 33729 | + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, |
| 33634 | ); | 33730 | ); |
| 33635 | push_mc_rect(2, | 33731 | push_mc_rect(2, |
| 33636 | cpx, | 33732 | cpx, |
| 33637 | cpy, | 33733 | cpy, |
| 33638 | - chroma_side, | 33734 | + chroma_stride, |
| 33639 | write_chroma_w, | 33735 | write_chroma_w, |
| 33640 | write_chroma_h, | 33736 | write_chroma_h, |
| 33641 | sv, | 33737 | sv, |
| 33642 | - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, | 33738 | + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, |
| 33643 | ); | 33739 | ); |
| 33644 | luma_grid = Grid::Zero(side * side); | 33740 | luma_grid = Grid::Zero(side * side); |
| 33645 | - u_grid = Grid::Zero(chroma_side * chroma_side); | 33741 | + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 33646 | - v_grid = Grid::Zero(chroma_side * chroma_side); | 33742 | + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 33647 | } else { | 33743 | } else { |
| 33648 | // lane-inter4 r2: a rect strip's coefficient context spans its | 33744 | // lane-inter4 r2: a rect strip's coefficient context spans its |
| 33649 | // OWN width above and height left -- reading `side` cells both | 33745 | // OWN width above and height left -- reading `side` cells both |
| @@ -33974,12 +34070,12 @@ fn decode_inter_block( | |||
| 33974 | // root a rect (128x64/64x128) block's chroma is per mu | 34070 | // root a rect (128x64/64x128) block's chroma is per mu |
| 33975 | // chunk too, so this test comes BEFORE the `rect_tu` one. | 34071 | // chunk too, so this test comes BEFORE the `rect_tu` one. |
| 33976 | u_grid = if u_units.is_empty() { | 34072 | u_grid = if u_units.is_empty() { |
| 33977 | - Grid::Zero(chroma_side * chroma_side) | 34073 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 33978 | } else { | 34074 | } else { |
| 33979 | Grid::Own(std::mem::take(&mut u_units)) | 34075 | Grid::Own(std::mem::take(&mut u_units)) |
| 33980 | }; | 34076 | }; |
| 33981 | v_grid = if v_units.is_empty() { | 34077 | v_grid = if v_units.is_empty() { |
| 33982 | - Grid::Zero(chroma_side * chroma_side) | 34078 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 33983 | } else { | 34079 | } else { |
| 33984 | Grid::Own(std::mem::take(&mut v_units)) | 34080 | Grid::Own(std::mem::take(&mut v_units)) |
| 33985 | }; | 34081 | }; |
| @@ -33990,7 +34086,7 @@ fn decode_inter_block( | |||
| 33990 | read_inter_chroma_lossless( | 34086 | read_inter_chroma_lossless( |
| 33991 | dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), | 34087 | dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), |
| 33992 | (0, 0), (write_chroma_w, write_chroma_h), | 34088 | (0, 0), (write_chroma_w, write_chroma_h), |
| 33993 | - (write_chroma_w, write_chroma_h), chroma_side, | 34089 | + (write_chroma_w, write_chroma_h), chroma_stride, |
| 33994 | mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, | 34090 | mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, |
| 33995 | )?; | 34091 | )?; |
| 33996 | let zero = chroma_side * chroma_side; | 34092 | let zero = chroma_side * chroma_side; |
| @@ -34025,7 +34121,7 @@ fn decode_inter_block( | |||
| 34025 | at_mi, | 34121 | at_mi, |
| 34026 | (cpx, cpy), | 34122 | (cpx, cpy), |
| 34027 | (write_chroma_w, write_chroma_h), | 34123 | (write_chroma_w, write_chroma_h), |
| 34028 | - chroma_side, | 34124 | + chroma_stride, |
| 34029 | mode_for_tx, | 34125 | mode_for_tx, |
| 34030 | luma_tx_type, fctx, | 34126 | luma_tx_type, fctx, |
| 34031 | )?; | 34127 | )?; |
| @@ -34827,8 +34923,8 @@ fn decode_inter_block( | |||
| 34827 | return; | 34923 | return; |
| 34828 | }; | 34924 | }; |
| 34829 | let mut pred_y = refill(std::mem::take(&mut out[0]), side * side); | 34925 | let mut pred_y = refill(std::mem::take(&mut out[0]), side * side); |
| 34830 | - let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_side * chroma_side); | 34926 | + let mut pred_u = refill(std::mem::take(&mut out[1]), chroma_stride * chroma_buf_h); |
| 34831 | - let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_side * chroma_side); | 34927 | + let mut pred_v = refill(std::mem::take(&mut out[2]), chroma_stride * chroma_buf_h); |
| 34832 | if luma_scale == mc::REF_NO_SCALE { | 34928 | if luma_scale == mc::REF_NO_SCALE { |
| 34833 | mc::predict_with_filters_kern( | 34929 | mc::predict_with_filters_kern( |
| 34834 | &py_ref.data, | 34930 | &py_ref.data, |
| @@ -34852,8 +34948,8 @@ fn decode_inter_block( | |||
| 34852 | pu_ref.true_height, | 34948 | pu_ref.true_height, |
| 34853 | mv_to_q4(cpx, mv.1, ss_x(fctx)), | 34949 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34854 | mv_to_q4(cpy, mv.0, ss_x(fctx)), | 34950 | mv_to_q4(cpy, mv.0, ss_x(fctx)), |
| 34855 | - chroma_side, | 34951 | + chroma_stride, |
| 34856 | - chroma_side, | 34952 | + chroma_buf_h, |
| 34857 | write_chroma_w, | 34953 | write_chroma_w, |
| 34858 | write_chroma_h, | 34954 | write_chroma_h, |
| 34859 | h_filter, | 34955 | h_filter, |
| @@ -34867,8 +34963,8 @@ fn decode_inter_block( | |||
| 34867 | pv_ref.true_height, | 34963 | pv_ref.true_height, |
| 34868 | mv_to_q4(cpx, mv.1, ss_x(fctx)), | 34964 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34869 | mv_to_q4(cpy, mv.0, ss_x(fctx)), | 34965 | mv_to_q4(cpy, mv.0, ss_x(fctx)), |
| 34870 | - chroma_side, | 34966 | + chroma_stride, |
| 34871 | - chroma_side, | 34967 | + chroma_buf_h, |
| 34872 | write_chroma_w, | 34968 | write_chroma_w, |
| 34873 | write_chroma_h, | 34969 | write_chroma_h, |
| 34874 | h_filter, | 34970 | h_filter, |
| @@ -34900,8 +34996,8 @@ fn decode_inter_block( | |||
| 34900 | mv_to_q4(cpx, mv.1, ss_x(fctx)), | 34996 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34901 | mv_to_q4(cpy, mv.0, ss_x(fctx)), | 34997 | mv_to_q4(cpy, mv.0, ss_x(fctx)), |
| 34902 | luma_scale, | 34998 | luma_scale, |
| 34903 | - chroma_side, | 34999 | + chroma_stride, |
| 34904 | - chroma_side, | 35000 | + chroma_buf_h, |
| 34905 | write_chroma_w, | 35001 | write_chroma_w, |
| 34906 | write_chroma_h, | 35002 | write_chroma_h, |
| 34907 | h_filter, | 35003 | h_filter, |
| @@ -34916,8 +35012,8 @@ fn decode_inter_block( | |||
| 34916 | mv_to_q4(cpx, mv.1, ss_x(fctx)), | 35012 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34917 | mv_to_q4(cpy, mv.0, ss_x(fctx)), | 35013 | mv_to_q4(cpy, mv.0, ss_x(fctx)), |
| 34918 | luma_scale, | 35014 | luma_scale, |
| 34919 | - chroma_side, | 35015 | + chroma_stride, |
| 34920 | - chroma_side, | 35016 | + chroma_buf_h, |
| 34921 | write_chroma_w, | 35017 | write_chroma_w, |
| 34922 | write_chroma_h, | 35018 | write_chroma_h, |
| 34923 | h_filter, | 35019 | h_filter, |
| @@ -34957,13 +35053,11 @@ fn decode_inter_block( | |||
| 34957 | if warp_plane_allowed(write_chroma_w, write_chroma_h) { | 35053 | if warp_plane_allowed(write_chroma_w, write_chroma_h) { |
| 34958 | crate::warp::warp_affine( | 35054 | crate::warp::warp_affine( |
| 34959 | params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32, | 35055 | params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32, |
| 34960 | - pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32, | 35056 | + pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 34961 | - chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | ||
| 34962 | ); | 35057 | ); |
| 34963 | crate::warp::warp_affine( | 35058 | crate::warp::warp_affine( |
| 34964 | params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32, | 35059 | params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32, |
| 34965 | - pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32, | 35060 | + pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_stride as i32, chroma_buf_h as i32, chroma_stride as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, |
| 34966 | - chroma_side as i32, chroma_side as i32, ss_x(fctx) as i32, ss_y(fctx) as i32, fctx, | ||
| 34967 | ); | 35061 | ); |
| 34968 | } | 35062 | } |
| 34969 | } | 35063 | } |
| @@ -34977,11 +35071,11 @@ fn decode_inter_block( | |||
| 34977 | } | 35071 | } |
| 34978 | interintra_blend(y, px, py, write_w, write_h, side, 0, 0, ii, wedge_mask, &mut pred_y, fctx); | 35072 | interintra_blend(y, px, py, write_w, write_h, side, 0, 0, ii, wedge_mask, &mut pred_y, fctx); |
| 34979 | interintra_blend( | 35073 | interintra_blend( |
| 34980 | - u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx), | 35074 | + u, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx), |
| 34981 | ss_y(fctx), ii, wedge_mask, &mut pred_u, fctx, | 35075 | ss_y(fctx), ii, wedge_mask, &mut pred_u, fctx, |
| 34982 | ); | 35076 | ); |
| 34983 | interintra_blend( | 35077 | interintra_blend( |
| 34984 | - v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_side, ss_x(fctx), | 35078 | + v, cpx, cpy, write_chroma_w, write_chroma_h, chroma_stride, ss_x(fctx), |
| 34985 | ss_y(fctx), ii, wedge_mask, &mut pred_v, fctx, | 35079 | ss_y(fctx), ii, wedge_mask, &mut pred_v, fctx, |
| 34986 | ); | 35080 | ); |
| 34987 | } | 35081 | } |
| @@ -35020,7 +35114,7 @@ fn decode_inter_block( | |||
| 35020 | &mut piece, fctx, | 35114 | &mut piece, fctx, |
| 35021 | ); | 35115 | ); |
| 35022 | for row in 0..piece_h { | 35116 | for row in 0..piece_h { |
| 35023 | - dst[row * chroma_side..row * chroma_side + piece_w] | 35117 | + dst[row * chroma_stride..row * chroma_stride + piece_w] |
| 35024 | .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]); | 35118 | .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]); |
| 35025 | } | 35119 | } |
| 35026 | } | 35120 | } |
| @@ -35045,8 +35139,8 @@ fn decode_inter_block( | |||
| 35045 | push_pred(fctx, build); | 35139 | push_pred(fctx, build); |
| 35046 | ( | 35140 | ( |
| 35047 | Pred::Cur { plane: 0, stride: side, off: 0 }, | 35141 | Pred::Cur { plane: 0, stride: side, off: 0 }, |
| 35048 | - Pred::Cur { plane: 1, stride: chroma_side, off: 0 }, | 35142 | + Pred::Cur { plane: 1, stride: chroma_stride, off: 0 }, |
| 35049 | - Pred::Cur { plane: 2, stride: chroma_side, off: 0 }, | 35143 | + Pred::Cur { plane: 2, stride: chroma_stride, off: 0 }, |
| 35050 | ) | 35144 | ) |
| 35051 | } else { | 35145 | } else { |
| 35052 | if interintra_mode.is_some() { | 35146 | if interintra_mode.is_some() { |
| @@ -35070,8 +35164,8 @@ fn decode_inter_block( | |||
| 35070 | // through to the ordinary whole-block predictor. | 35164 | // through to the ordinary whole-block predictor. |
| 35071 | ( | 35165 | ( |
| 35072 | Pred::Inline(&pred_y, side), | 35166 | Pred::Inline(&pred_y, side), |
| 35073 | - Pred::Inline(&pred_u, chroma_side), | 35167 | + Pred::Inline(&pred_u, chroma_stride), |
| 35074 | - Pred::Inline(&pred_v, chroma_side), | 35168 | + Pred::Inline(&pred_v, chroma_stride), |
| 35075 | ) | 35169 | ) |
| 35076 | }; | 35170 | }; |
| 35077 | 35171 | ||
| @@ -35116,25 +35210,25 @@ fn decode_inter_block( | |||
| 35116 | push_mc_rect(1, | 35210 | push_mc_rect(1, |
| 35117 | cpx, | 35211 | cpx, |
| 35118 | cpy, | 35212 | cpy, |
| 35119 | - chroma_side, | 35213 | + chroma_stride, |
| 35120 | write_chroma_w, | 35214 | write_chroma_w, |
| 35121 | write_chroma_h, | 35215 | write_chroma_h, |
| 35122 | su, | 35216 | su, |
| 35123 | - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, | 35217 | + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, |
| 35124 | ); | 35218 | ); |
| 35125 | push_mc_rect(2, | 35219 | push_mc_rect(2, |
| 35126 | cpx, | 35220 | cpx, |
| 35127 | cpy, | 35221 | cpy, |
| 35128 | - chroma_side, | 35222 | + chroma_stride, |
| 35129 | write_chroma_w, | 35223 | write_chroma_w, |
| 35130 | write_chroma_h, | 35224 | write_chroma_h, |
| 35131 | sv, | 35225 | sv, |
| 35132 | - &ZERO_RESIDUAL[..chroma_side * chroma_side], fctx, | 35226 | + &ZERO_RESIDUAL[..chroma_stride * chroma_buf_h], fctx, |
| 35133 | ); | 35227 | ); |
| 35134 | } | 35228 | } |
| 35135 | luma_grid = Grid::Zero(side * side); | 35229 | luma_grid = Grid::Zero(side * side); |
| 35136 | - u_grid = Grid::Zero(chroma_side * chroma_side); | 35230 | + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 35137 | - v_grid = Grid::Zero(chroma_side * chroma_side); | 35231 | + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 35138 | } else { | 35232 | } else { |
| 35139 | // lane-inter4 r2: a rect strip's coefficient context spans its | 35233 | // lane-inter4 r2: a rect strip's coefficient context spans its |
| 35140 | // OWN width above and height left -- reading `side` cells both | 35234 | // OWN width above and height left -- reading `side` cells both |
| @@ -35479,19 +35573,19 @@ fn decode_inter_block( | |||
| 35479 | // `reconstruct_inter_block`'s `for (plane...)` guarded by | 35573 | // `reconstruct_inter_block`'s `for (plane...)` guarded by |
| 35480 | // `xd->is_chroma_ref`) codes NO chroma transform here, so | 35574 | // `xd->is_chroma_ref`) codes NO chroma transform here, so |
| 35481 | // neither symbol nor context exists. | 35575 | // neither symbol nor context exists. |
| 35482 | - u_grid = Grid::Zero(chroma_side * chroma_side); | 35576 | + u_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 35483 | - v_grid = Grid::Zero(chroma_side * chroma_side); | 35577 | + v_grid = Grid::Zero(chroma_stride * chroma_buf_h); |
| 35484 | } else if side > 64 { | 35578 | } else if side > 64 { |
| 35485 | // Already read inside the mu-chunk loop above -- at the 128 | 35579 | // Already read inside the mu-chunk loop above -- at the 128 |
| 35486 | // root a rect (128x64/64x128) block's chroma is per mu | 35580 | // root a rect (128x64/64x128) block's chroma is per mu |
| 35487 | // chunk too, so this test comes BEFORE the `rect_tu` one. | 35581 | // chunk too, so this test comes BEFORE the `rect_tu` one. |
| 35488 | u_grid = if u_units.is_empty() { | 35582 | u_grid = if u_units.is_empty() { |
| 35489 | - Grid::Zero(chroma_side * chroma_side) | 35583 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 35490 | } else { | 35584 | } else { |
| 35491 | Grid::Own(std::mem::take(&mut u_units)) | 35585 | Grid::Own(std::mem::take(&mut u_units)) |
| 35492 | }; | 35586 | }; |
| 35493 | v_grid = if v_units.is_empty() { | 35587 | v_grid = if v_units.is_empty() { |
| 35494 | - Grid::Zero(chroma_side * chroma_side) | 35588 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 35495 | } else { | 35589 | } else { |
| 35496 | Grid::Own(std::mem::take(&mut v_units)) | 35590 | Grid::Own(std::mem::take(&mut v_units)) |
| 35497 | }; | 35591 | }; |
| @@ -35502,7 +35596,7 @@ fn decode_inter_block( | |||
| 35502 | read_inter_chroma_lossless( | 35596 | read_inter_chroma_lossless( |
| 35503 | dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), | 35597 | dec, cdfs, neighbours, u, v, su, sv, at_mi, (cpx, cpy), |
| 35504 | (0, 0), (write_chroma_w, write_chroma_h), | 35598 | (0, 0), (write_chroma_w, write_chroma_h), |
| 35505 | - (write_chroma_w, write_chroma_h), chroma_side, | 35599 | + (write_chroma_w, write_chroma_h), chroma_stride, |
| 35506 | mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, | 35600 | mode_for_tx, base_q_idx, &mut uo, &mut vo, fctx, |
| 35507 | )?; | 35601 | )?; |
| 35508 | let zero = chroma_side * chroma_side; | 35602 | let zero = chroma_side * chroma_side; |
| @@ -35534,7 +35628,7 @@ fn decode_inter_block( | |||
| 35534 | at_mi, | 35628 | at_mi, |
| 35535 | (cpx, cpy), | 35629 | (cpx, cpy), |
| 35536 | (write_chroma_w, write_chroma_h), | 35630 | (write_chroma_w, write_chroma_h), |
| 35537 | - chroma_side, | 35631 | + chroma_stride, |
| 35538 | mode_for_tx, | 35632 | mode_for_tx, |
| 35539 | luma_tx_type, fctx, | 35633 | luma_tx_type, fctx, |
| 35540 | )?; | 35634 | )?; |
| @@ -36239,12 +36333,12 @@ fn decode_inter_block( | |||
| 36239 | // Chroma is already coded and reconstructed per mu chunk above. | 36333 | // Chroma is already coded and reconstructed per mu chunk above. |
| 36240 | luma_grid = Grid::Zero(side * side); | 36334 | luma_grid = Grid::Zero(side * side); |
| 36241 | u_grid = if u_units.is_empty() { | 36335 | u_grid = if u_units.is_empty() { |
| 36242 | - Grid::Zero(chroma_side * chroma_side) | 36336 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 36243 | } else { | 36337 | } else { |
| 36244 | Grid::Own(std::mem::take(&mut u_units)) | 36338 | Grid::Own(std::mem::take(&mut u_units)) |
| 36245 | }; | 36339 | }; |
| 36246 | v_grid = if v_units.is_empty() { | 36340 | v_grid = if v_units.is_empty() { |
| 36247 | - Grid::Zero(chroma_side * chroma_side) | 36341 | + Grid::Zero(chroma_stride * chroma_buf_h) |
| 36248 | } else { | 36342 | } else { |
| 36249 | Grid::Own(std::mem::take(&mut v_units)) | 36343 | Grid::Own(std::mem::take(&mut v_units)) |
| 36250 | }; | 36344 | }; |
| @@ -38626,6 +38720,28 @@ fn decode_inter_sub8_rect2( | |||
| 38626 | // there is no shared group unit (aomdec EC_COEFF on | 38720 | // there is no shared group unit (aomdec EC_COEFF on |
| 38627 | // `av1-profile1-444.ivf` decode-order frame 1, mi (3,8)). | 38721 | // `av1-profile1-444.ivf` decode-order frame 1, mi (3,8)). |
| 38628 | let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; | 38722 | let chroma_444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; |
| 38723 | + // lane-av1-422blockhalf: at ss (1,0) the chroma reference is PER PIECE | ||
| 38724 | + // too, keyed by `is_chroma_reference`'s own terms: an 8x4 HORZ piece is | ||
| 38725 | + // 2 mi wide (`!(bw & 1)`), so BOTH pieces of the group are references; | ||
| 38726 | + // a 4x8 VERT piece is 1 mi wide, so only the ODD-column piece is | ||
| 38727 | + // (`mi_col & 1`) -- measured on the pinned t422 fixture frame 1: the | ||
| 38728 | + // horz group at mi (8,10)/(9,10) reads U+V TX_4X4 after EACH piece's | ||
| 38729 | + // luma (rng 37134/37852 then 63752/50952), and the vert group at | ||
| 38730 | + // (3,10)/(3,11) reads U+V on the odd-column piece (3,11) alone. The old | ||
| 38731 | + // `i == 1` rule coded the group's chroma on the wrong piece (and, for | ||
| 38732 | + // horz, half of the units) and desynced frame 1 at (8,10)'s uv_mode. | ||
| 38733 | + let chroma_422 = ss_x(fctx) == 1 && ss_y(fctx) == 0; | ||
| 38734 | + // 4:4:4: every piece. 4:2:2: both horz pieces, the odd-column vert piece. | ||
| 38735 | + // 4:2:0 keeps its existing second-piece model untouched. | ||
| 38736 | + let piece_is_chroma_ref = |i: usize| -> bool { | ||
| 38737 | + if ss_x(fctx) == 0 && ss_y(fctx) == 0 { | ||
| 38738 | + true | ||
| 38739 | + } else if chroma_422 { | ||
| 38740 | + !vert || ((gc + i) & 1) == 1 | ||
| 38741 | + } else { | ||
| 38742 | + i == 1 | ||
| 38743 | + } | ||
| 38744 | + }; | ||
| 38629 | // This piece's first transform's luma `tx_type` (libaom `mbmi->tx_type`): | 38745 | // This piece's first transform's luma `tx_type` (libaom `mbmi->tx_type`): |
| 38630 | // an inter block's chroma plane never codes its own symbol but inherits | 38746 | // an inter block's chroma plane never codes its own symbol but inherits |
| 38631 | // the colocated luma type (`av1_get_tx_type`, blockd.h:1291). | 38747 | // the colocated luma type (`av1_get_tx_type`, blockd.h:1291). |
| @@ -38686,7 +38802,7 @@ fn decode_inter_sub8_rect2( | |||
| 38686 | "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", | 38802 | "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", |
| 38687 | bw, | 38803 | bw, |
| 38688 | bh, | 38804 | bh, |
| 38689 | - i == 1, | 38805 | + piece_is_chroma_ref(i), |
| 38690 | fctx.tx_select_inter.with(std::cell::Cell::get), | 38806 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 38691 | ); | 38807 | ); |
| 38692 | } | 38808 | } |
| @@ -38704,7 +38820,7 @@ fn decode_inter_sub8_rect2( | |||
| 38704 | group_mi, | 38820 | group_mi, |
| 38705 | lmi, | 38821 | lmi, |
| 38706 | (bw, bh), | 38822 | (bw, bh), |
| 38707 | - chroma_444 || i == 1, | 38823 | + piece_is_chroma_ref(i), |
| 38708 | skip, | 38824 | skip, |
| 38709 | scan4, | 38825 | scan4, |
| 38710 | y, | 38826 | y, |
| @@ -38715,7 +38831,7 @@ fn decode_inter_sub8_rect2( | |||
| 38715 | fctx.tx_select_inter.with(std::cell::Cell::get), | 38831 | fctx.tx_select_inter.with(std::cell::Cell::get), |
| 38716 | reduced_tx_set, fctx, | 38832 | reduced_tx_set, fctx, |
| 38717 | )?; | 38833 | )?; |
| 38718 | - if i == 1 { | 38834 | + if piece_is_chroma_ref(i) { |
| 38719 | intra_chroma = true; | 38835 | intra_chroma = true; |
| 38720 | } | 38836 | } |
| 38721 | continue; | 38837 | continue; |
| @@ -39142,6 +39258,166 @@ fn decode_inter_sub8_rect2( | |||
| 39142 | neighbours.record_mi_chroma(lmi, bw, bh, 1, &ug); | 39258 | neighbours.record_mi_chroma(lmi, bw, bh, 1, &ug); |
| 39143 | neighbours.record_mi_chroma(lmi, bw, bh, 2, &vg); | 39259 | neighbours.record_mi_chroma(lmi, bw, bh, 2, &vg); |
| 39144 | } | 39260 | } |
| 39261 | + // lane-av1-422blockhalf: the 4:2:2 per-piece arm. The chroma | ||
| 39262 | + // reference piece codes its own U and V TX_4X4 units right after its | ||
| 39263 | + // luma -- both pieces of a horz group, the odd-column piece of a | ||
| 39264 | + // vert one (see `piece_is_chroma_ref` above; measured on the pinned | ||
| 39265 | + // t422 fixture frame 1, horz group (8,10)/(9,10) and vert group | ||
| 39266 | + // (3,10)/(3,11)). The unit anchors at the FLOORED chroma cell | ||
| 39267 | + // (`av1_setup_dst_planes`' `(mi_col & !1) * MI >> ss_x`, the | ||
| 39268 | + // lane-av1-422kf2 rule) and reads through | ||
| 39269 | + // [`Neighbours::around_mi_422_chroma`]'s per-chroma-cell context. | ||
| 39270 | + // A horz piece IS 4x4 chroma (8 luma wide, ss_y 0): its unit | ||
| 39271 | + // predicts whole from its own mv/filters. A vert piece is 2 chroma | ||
| 39272 | + // px wide, so its 4-px unit predicts in halves -- | ||
| 39273 | + // `build_inter_predictors_sub8x8`'s rule: the left 2x4 from the | ||
| 39274 | + // piece to the LEFT (the group's own left piece, or the decoded | ||
| 39275 | + // neighbour when the group starts on an odd column), the right 2x4 | ||
| 39276 | + // from this piece. A skipped reference piece still predicts (spec | ||
| 39277 | + // 7.11.3) but codes no coefficients. | ||
| 39278 | + } else if chroma_422 && piece_is_chroma_ref(i) { | ||
| 39279 | + const B4: usize = 4; | ||
| 39280 | + let (pc_ref, pc_mv, pc_hf, pc_vf) = piece[i].expect("inter piece recorded above"); | ||
| 39281 | + let unit_x = ((lmi.1 & !1) * MI) >> ss_x(fctx); | ||
| 39282 | + let unit_y = py; | ||
| 39283 | + // The left 2x4 half's source: the in-group left piece when this | ||
| 39284 | + // piece is the group's second, else the decoded neighbour one mi | ||
| 39285 | + // to the left (an odd-column group start). Its interp filters | ||
| 39286 | + // are not on the mi grid, so an outside neighbour borrows this | ||
| 39287 | + // piece's own. | ||
| 39288 | + let left_piece = if i > 0 { | ||
| 39289 | + piece[i - 1] | ||
| 39290 | + } else if lmi.1 > 0 { | ||
| 39291 | + grid.get(rmi, lmi.1 - 1).filter(|mi| mi.is_inter).map( | ||
| 39292 | + |mi| { | ||
| 39293 | + ( | ||
| 39294 | + mi.ref_frame, | ||
| 39295 | + (i32::from(mi.mv.0), i32::from(mi.mv.1)), | ||
| 39296 | + pc_hf, | ||
| 39297 | + pc_vf, | ||
| 39298 | + ) | ||
| 39299 | + }, | ||
| 39300 | + ) | ||
| 39301 | + } else { | ||
| 39302 | + None | ||
| 39303 | + }; | ||
| 39304 | + let build_c = move |_y: &mut PlaneBuf<'static>, | ||
| 39305 | + _u: &mut PlaneBuf<'static>, | ||
| 39306 | + _v: &mut PlaneBuf<'static>, | ||
| 39307 | + fctx: &crate::decode::FrameCtx, | ||
| 39308 | + out: &mut [Vec<u16>; 3]| { | ||
| 39309 | + let Some((pc_ref_y, sref_u, sref_v)) = ref_planes_deferred(pc_ref, refpix) else { | ||
| 39310 | + return; | ||
| 39311 | + }; | ||
| 39312 | + let pc_scale = mc::scale_factor(pc_ref_y.width, frame_width); | ||
| 39313 | + let mut pred_u = refill(std::mem::take(&mut out[1]), B4 * B4); | ||
| 39314 | + let mut pred_v = refill(std::mem::take(&mut out[2]), B4 * B4); | ||
| 39315 | + for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { | ||
| 39316 | + let mut buf = vec![0u16; B4 * B4]; | ||
| 39317 | + if vert { | ||
| 39318 | + // Right 2x4 half: this piece's own ref/mv/filters. | ||
| 39319 | + let mut half = vec![0u16; 2 * 4]; | ||
| 39320 | + mc::predict_maybe_scaled( | ||
| 39321 | + &plane.data, | ||
| 39322 | + plane.width, | ||
| 39323 | + plane.true_width, | ||
| 39324 | + plane.true_height, | ||
| 39325 | + mv_to_q4(unit_x + 2, pc_mv.1, ss_x(fctx)), | ||
| 39326 | + mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)), | ||
| 39327 | + pc_scale, | ||
| 39328 | + 2, | ||
| 39329 | + 4, | ||
| 39330 | + pc_hf, | ||
| 39331 | + pc_vf, | ||
| 39332 | + &mut half, fctx, | ||
| 39333 | + ); | ||
| 39334 | + for row in 0..4 { | ||
| 39335 | + buf[row * B4 + 2..row * B4 + 4] | ||
| 39336 | + .copy_from_slice(&half[row * 2..row * 2 + 2]); | ||
| 39337 | + } | ||
| 39338 | + // Left 2x4 half: the piece to the left (an | ||
| 39339 | + // intra/off-frame neighbour reduces to whole-from-own, | ||
| 39340 | + // `is_sub8x8_inter`'s rule). | ||
| 39341 | + let (l_ref, l_mv, l_hf, l_vf) = match left_piece { | ||
| 39342 | + Some((l_ref, l_mv, l_hf, l_vf)) => (l_ref, l_mv, l_hf, l_vf), | ||
| 39343 | + None => (pc_ref, pc_mv, pc_hf, pc_vf), | ||
| 39344 | + }; | ||
| 39345 | + let Some((l_y, l_u, _)) = ref_planes_deferred(l_ref, refpix) else { | ||
| 39346 | + continue; | ||
| 39347 | + }; | ||
| 39348 | + mc::predict_maybe_scaled( | ||
| 39349 | + &l_u.data, | ||
| 39350 | + l_u.width, | ||
| 39351 | + l_u.true_width, | ||
| 39352 | + l_u.true_height, | ||
| 39353 | + mv_to_q4(unit_x, l_mv.1, ss_x(fctx)), | ||
| 39354 | + mv_to_q4(unit_y, l_mv.0, ss_y(fctx)), | ||
| 39355 | + mc::scale_factor(l_y.width, frame_width), | ||
| 39356 | + 2, | ||
| 39357 | + 4, | ||
| 39358 | + l_hf, | ||
| 39359 | + l_vf, | ||
| 39360 | + &mut half, fctx, | ||
| 39361 | + ); | ||
| 39362 | + for row in 0..4 { | ||
| 39363 | + buf[row * B4..row * B4 + 2] | ||
| 39364 | + .copy_from_slice(&half[row * 2..row * 2 + 2]); | ||
| 39365 | + } | ||
| 39366 | + } else { | ||
| 39367 | + mc::predict_maybe_scaled( | ||
| 39368 | + &plane.data, | ||
| 39369 | + plane.width, | ||
| 39370 | + plane.true_width, | ||
| 39371 | + plane.true_height, | ||
| 39372 | + mv_to_q4(unit_x, pc_mv.1, ss_x(fctx)), | ||
| 39373 | + mv_to_q4(unit_y, pc_mv.0, ss_y(fctx)), | ||
| 39374 | + pc_scale, | ||
| 39375 | + B4, | ||
| 39376 | + B4, | ||
| 39377 | + pc_hf, | ||
| 39378 | + pc_vf, | ||
| 39379 | + &mut buf, fctx, | ||
| 39380 | + ); | ||
| 39381 | + } | ||
| 39382 | + dst.copy_from_slice(&buf); | ||
| 39383 | + } | ||
| 39384 | + out[1] = pred_u; | ||
| 39385 | + out[2] = pred_v; | ||
| 39386 | + }; | ||
| 39387 | + let (pred_cu, pred_cv): (Vec<u16>, Vec<u16>); | ||
| 39388 | + let (su, sv) = if recon_deferred(fctx) { | ||
| 39389 | + push_pred(fctx, build_c); | ||
| 39390 | + ( | ||
| 39391 | + Pred::Cur { plane: 1, stride: B4, off: 0 }, | ||
| 39392 | + Pred::Cur { plane: 2, stride: B4, off: 0 }, | ||
| 39393 | + ) | ||
| 39394 | + } else { | ||
| 39395 | + let mut built: [Vec<u16>; 3] = Default::default(); | ||
| 39396 | + build_c(y, u, v, fctx, &mut built); | ||
| 39397 | + let [_, bu, bv] = built; | ||
| 39398 | + (pred_cu, pred_cv) = (bu, bv); | ||
| 39399 | + (Pred::Inline(&pred_cu, B4), Pred::Inline(&pred_cv, B4)) | ||
| 39400 | + }; | ||
| 39401 | + let ctx_mi = (lmi.0, lmi.1 & !1); | ||
| 39402 | + let ca = neighbours.around_mi_422_chroma(ctx_mi, 8, 4); | ||
| 39403 | + if skip { | ||
| 39404 | + push_mc(1, unit_x, unit_y, B4, su, &ZERO_RESIDUAL[..B4 * B4], fctx); | ||
| 39405 | + push_mc(2, unit_x, unit_y, B4, sv, &ZERO_RESIDUAL[..B4 * B4], fctx); | ||
| 39406 | + neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ZERO_RESIDUAL[..B4 * B4]); | ||
| 39407 | + neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &ZERO_RESIDUAL[..B4 * B4]); | ||
| 39408 | + } else { | ||
| 39409 | + hit!(CHROMA422_INTER_SUB8_HITS); | ||
| 39410 | + let (ug, _) = read_inter_plane( | ||
| 39411 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, ca[1], 0, u, unit_x, unit_y, B4, | ||
| 39412 | + base_q_idx, su, Some(piece_tx_type), None, fctx, | ||
| 39413 | + )?; | ||
| 39414 | + let (vg, _) = read_inter_plane( | ||
| 39415 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, ca[2], 0, v, unit_x, unit_y, B4, | ||
| 39416 | + base_q_idx, sv, Some(piece_tx_type), None, fctx, | ||
| 39417 | + )?; | ||
| 39418 | + neighbours.record_mi_chroma(ctx_mi, 8, 4, 1, &ug); | ||
| 39419 | + neighbours.record_mi_chroma(ctx_mi, 8, 4, 2, &vg); | ||
| 39420 | + } | ||
| 39145 | } | 39421 | } |
| 39146 | neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED); | 39422 | neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED); |
| 39147 | neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false); | 39423 | neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false); |
| @@ -39163,8 +39439,10 @@ fn decode_inter_sub8_rect2( | |||
| 39163 | // `uv_predict_mode`, and this DC stamp ran after it and flattened the | 39439 | // `uv_predict_mode`, and this DC stamp ran after it and flattened the |
| 39164 | // mi-exact cell (class `override-slot-on-one-arm`, this lane's own | 39440 | // mi-exact cell (class `override-slot-on-one-arm`, this lane's own |
| 39165 | // 10-bit film gate regression at 1ad7e0fc; port of lane-av1-cfl's | 39441 | // 10-bit film gate regression at 1ad7e0fc; port of lane-av1-cfl's |
| 39166 | - // 7c6dad53). | 39442 | + // 7c6dad53). lane-av1-422blockhalf: 4:2:2 never takes it either -- the |
| 39167 | - if !chroma_444 && !intra_chroma { | 39443 | + // group unit does not exist there; every chroma-reference piece coded |
| 39444 | + // (and recorded) its own unit inside the loop above. | ||
| 39445 | + if !chroma_444 && !chroma_422 && !intra_chroma { | ||
| 39168 | neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); | 39446 | neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); |
| 39169 | } | 39447 | } |
| 39170 | // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map | 39448 | // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map |
| @@ -39178,7 +39456,10 @@ fn decode_inter_sub8_rect2( | |||
| 39178 | record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); | 39456 | record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); |
| 39179 | // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded | 39457 | // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded |
| 39180 | // and reconstructed the group's one chroma unit itself. | 39458 | // and reconstructed the group's one chroma unit itself. |
| 39181 | - if !chroma_444 && !intra_chroma { | 39459 | + // lane-av1-422blockhalf: 4:2:2 never runs this tail -- the shared group |
| 39460 | + // unit does not exist at ss (1,0); each chroma-reference piece coded its | ||
| 39461 | + // own U/V TX_4X4 inside the loop above, exactly like the 4:4:4 arm. | ||
| 39462 | + if !chroma_444 && !chroma_422 && !intra_chroma { | ||
| 39182 | // The group's single 4x4 chroma unit per plane, on the chroma-reference | 39463 | // The group's single 4x4 chroma unit per plane, on the chroma-reference |
| 39183 | // (second) sub-block's own skip flag. | 39464 | // (second) sub-block's own skip flag. |
| 39184 | const B4: usize = 4; | 39465 | const B4: usize = 4; |
lanes/av1422blockhalf.report.mdadded+133 -0
| @@ -0,0 +1,133 @@ | |||
| 1 | +# lane-av1-422blockhalf — `decode_inter_block`'s 4:2:2 chroma half ported to the | ||
| 2 | +# per-axis plane-block model (per-axis pred buffers + real-subsampling masked | ||
| 3 | +# compound blend), the `EC_RECTCHROMA_GAP` 16x8 / 8x32 chroma shapes coded as | ||
| 4 | +# the (4, 8) unit tiling the Release oracle's OOB `max_txsize_rect_lookup[ | ||
| 5 | +# BLOCK_INVALID]` byte produces, and `decode_inter_sub8_rect2`'s has_chroma | ||
| 6 | +# gating moved from `i == 1` to the per-piece `is_chroma_reference` rule; | ||
| 7 | +# frame 0 stays byte-exact at PREFILT/POSTDEB/POSTCDEF, all 16 frames now | ||
| 8 | +# decode (the frame-11 `(4, 32)` refusal is gone), and the inter-frame | ||
| 9 | +# divergence is REMEASURED and REATTRIBUTED to a partition-dispatch defect | ||
| 10 | +# upstream of the chroma half (ours dispatches SPLIT4 where the oracle codes | ||
| 11 | +# HORZ at mi(8,10)) — frame exactness NOT claimed for frames 1+ | ||
| 12 | + | ||
| 13 | +## Outcome | ||
| 14 | + | ||
| 15 | +1. `decode_inter_block`'s chroma PREDICTION buffers (compound and | ||
| 16 | + single-ref arms, OBMC plan, interintra stride, skip pushes, su/sv Pred | ||
| 17 | + strides, the `read_inter_rect_chroma`/`read_inter_chroma_lossless` pred | ||
| 18 | + strides) are keyed to the PLANE BLOCK's own per-axis shape at ss (1, 0): | ||
| 19 | + `(chroma_stride, chroma_buf_h) = (write_chroma_w, write_chroma_h)` | ||
| 20 | + instead of the enclosing square `chroma_side`. The two masked-compound | ||
| 21 | + blend sites now pass the plane's REAL subsampling shifts — the | ||
| 22 | + stop-note's pre-port direct luma-resolution mask read is gone | ||
| 23 | + (aom_dsp/blend-a64-mask.c's `(1, 0)` branch at 4:2:2). Every replaced | ||
| 24 | + expression reduces to the parent values at 4:2:0/4:4:4 | ||
| 25 | + (`chroma_stride == chroma_buf_h == chroma_side` there), byte-identical | ||
| 26 | + by construction. | ||
| 27 | +2. `read_inter_rect_chroma` now takes the per-axis stride correctly: its | ||
| 28 | + assembled block grid is `stride x plane-height` (`assembled_h`), the | ||
| 29 | + single-unit embed included — the old square `chroma_side * chroma_side` | ||
| 30 | + allocation panicked (`range end index 20 out of range for slice of | ||
| 31 | + length 16`) the moment the per-axis stride reached it. | ||
| 32 | +3. `decode_rect_split`'s 4:2:2 BLOCK_INVALID chroma planes: the tall/wide | ||
| 33 | + 1:2 and 1:4 strips (`8x16, 16x32, 32x64, 8x32, 16x64`, + `64x128` for | ||
| 34 | + 128-SB streams) have NO chroma plane block | ||
| 35 | + (`av1_ss_size_lookup[...][1][0] == BLOCK_INVALID`); the plane is still | ||
| 36 | + coded, tiled into (4, 8) rect units — the Release oracle's | ||
| 37 | + out-of-bounds `max_txsize_rect_lookup[BLOCK_INVALID]` byte is TX_4X8 | ||
| 38 | + (lane-av1-422m's measurement), and `decode_token_recon_block` steps the | ||
| 39 | + plane in that unit shape. Units read `TxbSet::ChromaRect8x4`/`SCAN_4X8` | ||
| 40 | + with `around_mi_422_chroma` ctx, mode-indexed intra tx type (the | ||
| 41 | + `< 32` square-up rule, pre-existing rect units unchanged at DctDct), | ||
| 42 | + per-unit stamps + units replay. SKIP strips predict per (4, 8) unit as | ||
| 43 | + well (`decode_token_recon_block`'s per-TU plane walk runs before the | ||
| 44 | + skip guard) — the old single whole-plane zero push asked the intra | ||
| 45 | + predictor for a 1:8 rect (`dc_rect_multiplier` panic, bw=8 bh=64). | ||
| 46 | + `EC_RECTCHROMA_GAP` now prints only truly-unhandled shapes (it used to | ||
| 47 | + misfire on every tiled square — the parent lane's `chroma=8x8` rows); | ||
| 48 | + it prints ZERO times on the fixture now. `chroma422_chunk` = 344 on the | ||
| 49 | + full fixture (new units provably fire). | ||
| 50 | +4. `decode_inter_sub8_rect2`'s has_chroma gating: per-piece | ||
| 51 | + `is_chroma_reference` — 4:4:4 every piece, 4:2:2 both horz pieces | ||
| 52 | + (`!(bw & 1)`) / the odd-column vert piece (`mi_col & 1`), 4:2:0 keeps | ||
| 53 | + `i == 1` verbatim. The inter pieces take a per-piece inline chroma arm | ||
| 54 | + at 4:2:2 (U then V TX_4X4 at the floored cell, `around_mi_422_chroma` | ||
| 55 | + ctx, inherited piece tx type; horz predicts whole-from-own mv, vert | ||
| 56 | + predicts halves `build_inter_predictors_sub8x8`-style, left half from | ||
| 57 | + the in-group left piece or the decoded grid neighbour when the group | ||
| 58 | + starts on an odd column — filters unavailable on the grid, so an | ||
| 59 | + outside neighbour borrows this piece's filters). The 4:2:0 group tail | ||
| 60 | + (and the group DC stamp) are gated off at 4:2:2. | ||
| 61 | +5. MEASURED (17-frame probe, per-OBU cut harness `/tmp/i422/cut_frames.py`, | ||
| 62 | + comparator ours-padded-u8-cropped vs instrumented | ||
| 63 | + `$HOME/.cache/aom-oracle/build` aomdec-cropped-u8; fixture `/tmp/t422.obu` | ||
| 64 | + sha256 `d3fa4beeb1309033e4a03f5ae5c431c8fa8386ba1ada088684710423c7938129`): | ||
| 65 | + - frame 0: byte-exact at PREFILT, POSTDEB and POSTCDEF on Y, U and V — | ||
| 66 | + 0 diffs everywhere (FINAL not re-run this round; frame 0's final state | ||
| 67 | + is bracketed by POSTCDEF on a key frame). | ||
| 68 | + - all 16 frames decode, exit 0 — the parent lane's frame-11 refusal | ||
| 69 | + (`a coded HORZ/VERT strip whose chroma transform has no rect | ||
| 70 | + coefficient tables here`, the `luma=8x32 tx=8x8 chroma=4x32` GAP) is | ||
| 71 | + gone. | ||
| 72 | + - frames 1..15 still diverge (~24-36k Y, ~13-18k U/V per stage; ladder | ||
| 73 | + in `/tmp/i422/ladder/`). **Frame exactness is NOT claimed.** | ||
| 74 | +6. REATTRIBUTION (the round's real finding): the frames-1+ divergence is | ||
| 75 | + NOT the chroma half. Strict stream-order EC_ISTEP pairing on the | ||
| 76 | + frames-0-1 cut puts the first entropy divergence at index 167 — the | ||
| 77 | + 8x8 group at mi(8,10): the ORACLE codes PARTITION_HORZ (pieces (8,10) | ||
| 78 | + and (9,10) only, both intra with uv; oracle partition trace | ||
| 79 | + `EC_PART mi_row=8 mi_col=10 bsize=3 ctx=0 value=1`) while OURS | ||
| 80 | + dispatches decode_inter_sub8_split4 (EC_SUB8INTRA: `shape=4x4 sub=0 | ||
| 81 | + has_chroma=false mi=8,10` ... four pieces, one extra uv_mode | ||
| 82 | + consumption on the (9,11) odd piece). Same bits, different partition | ||
| 83 | + outcome at the 8x8-leaf partition read (`partition_w8` ctx/value — | ||
| 84 | + ours `ctx=2` at the (8,8) sibling). Every downstream diff in the | ||
| 85 | + ladder is walk-shift noise from that point. This is a pre-existing | ||
| 86 | + defect upstream of the named chroma surfaces, newly visible now that | ||
| 87 | + the chroma shapes no longer refuse. | ||
| 88 | + | ||
| 89 | +## Decision | ||
| 90 | + | ||
| 91 | +- The header refusal STAYS unconditional in `stream.rs`; the bypass was | ||
| 92 | + local-only, applied and reverted byte-identical (0 occurrences left; | ||
| 93 | + `stream::tests::a_non_420_subsampled_sequence_header_is_refused_by_name` | ||
| 94 | + green after the revert). | ||
| 95 | +- 4:2:0/4:4:4 untouched by construction (ss-keyed arms; the 4:2:0 sub8 | ||
| 96 | + group tail and `i == 1` rule verbatim). | ||
| 97 | +- `read_coeffs_rect` untouched; the 4:2:0 group-tail SKIP arm untouched. | ||
| 98 | + | ||
| 99 | +## Deferred | ||
| 100 | + | ||
| 101 | +(a) The (8,10)-class partition-dispatch defect (ours SPLIT4 vs oracle | ||
| 102 | + HORZ) — the frames-1+ exactness blocker. Unblock: capture the 8x8 | ||
| 103 | + leaf partition context both sides (ours `EC_TRACE_PART`, oracle's | ||
| 104 | + shipped partition probe) and compare `partition_ctx_mi` vs libaom's | ||
| 105 | + `partition_context` gather at that leaf; the chroma half itself is | ||
| 106 | + now shape-honest and rides on the fix. | ||
| 107 | +(b) 4-wide strips (4x16, 4x8 luma) at 4:2:2: `decode_rect_split` still | ||
| 108 | + refuses `(2, 16)` chroma by name (no pair-anchor machinery there; the | ||
| 109 | + 4:2:0 `(4, 16)` single-unit arm would be wrong at ss (1, 0)). | ||
| 110 | + Unblock: the split4-style floored-pair anchor ported to the 1-mi-wide | ||
| 111 | + strip callers, then the OOB (4, 8) tiling. | ||
| 112 | +(c) 128-root 4:2:2 chroma chunking (`decode_inter_block`'s side > 64 | ||
| 113 | + mu-chunk chroma) still passes the square `chroma_side` geometry — | ||
| 114 | + unreachable on <=64-superblock streams (this fixture is 64-SB); | ||
| 115 | + flagged for whoever lands 4:2:2 128-SB support. | ||
| 116 | + | ||
| 117 | +## Verification | ||
| 118 | + | ||
| 119 | +- `cargo check -p ec-av1` (target `~/.cache/cargo-target-av1422blockhalf`): | ||
| 120 | + 0 warnings, 0 errors. | ||
| 121 | +- Refusal gate green post-revert (1 passed). | ||
| 122 | +- Probe: `OK: 16 frames decoded`; 0 `EC_RECTCHROMA_GAP` prints; | ||
| 123 | + `chroma422_chunk=344`, `chroma422_square=197` on the full fixture. | ||
| 124 | +- Ladder: frame 0 = 0 diffs at PREFILT/POSTDEB/POSTCDEF (Y=U=V); frames | ||
| 125 | + 1..15 divergent (see 5/6 — attributed, not claimed). | ||
| 126 | + | ||
| 127 | +## State | ||
| 128 | + | ||
| 129 | +- Commit on lane-av1-422blockhalf (no push): the per-axis decode_inter_block | ||
| 130 | + chroma half, the read_inter_rect_chroma stride fix, the decode_rect_split | ||
| 131 | + (4, 8) chroma tiling incl. per-unit skip prediction, the rect2 per-piece | ||
| 132 | + has_chroma gating, and this report. | ||
| 133 | +- Ladder dumps under `/tmp/i422/ladder/` (scratch, not committed). | ||