lane-av1422luma: 4:2:2 IntraBC 1:4 strips code their OWN chroma -- six sweep cells byte-exact, luma desync gone
Browse files at this commit3ce52f6537f95a0e3794f313e3de8719a831e7a4Parent: 4ef5ae81 changed file +100 -16
- crates/ec-av1/src/decode.rs +100 -16
crates/ec-av1/src/decode.rsmodified+100 -16
| @@ -6116,6 +6116,27 @@ thread_local! { | |||
| 6116 | static INTRABC_RECT4_OWN_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 6116 | static INTRABC_RECT4_OWN_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 6117 | } | 6117 | } |
| 6118 | 6118 | ||
| 6119 | +// lane-av1422luma: the ss (1,0) twin of `INTRABC_RECT4_OWN_CHROMA444_HITS` | ||
| 6120 | +// -- how many intra-BC 1:4 strips at 4:2:2 took the own-chroma (no pair) | ||
| 6121 | +// route. Same caveat as the 4:4:4 counter: it proves REACH and nothing else, | ||
| 6122 | +// and 4:2:2 is refused at the sequence header, so no committed test can read | ||
| 6123 | +// it (the count in `lanes/av1422luma.report.md` is from a bypassed probe build). | ||
| 6124 | +thread_local! { | ||
| 6125 | + static INTRABC_RECT4_OWN_CHROMA422_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 6126 | +} | ||
| 6127 | + | ||
| 6128 | +/// Current value of [`INTRABC_RECT4_OWN_CHROMA422_HITS`]. | ||
| 6129 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 6130 | +pub(crate) fn intrabc_rect4_own_chroma422_hits() -> usize { | ||
| 6131 | + INTRABC_RECT4_OWN_CHROMA422_HITS.with(std::cell::Cell::get) | ||
| 6132 | +} | ||
| 6133 | + | ||
| 6134 | +/// Resets [`INTRABC_RECT4_OWN_CHROMA422_HITS`] before a decode. | ||
| 6135 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 6136 | +pub(crate) fn reset_intrabc_rect4_own_chroma422_hits() { | ||
| 6137 | + INTRABC_RECT4_OWN_CHROMA422_HITS.with(|c| c.set(0)); | ||
| 6138 | +} | ||
| 6139 | + | ||
| 6119 | /// Current value of [`INTRABC_RECT4_OWN_CHROMA444_HITS`]. | 6140 | /// Current value of [`INTRABC_RECT4_OWN_CHROMA444_HITS`]. |
| 6120 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 6141 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 6121 | pub(crate) fn intrabc_rect4_own_chroma444_hits() -> usize { | 6142 | pub(crate) fn intrabc_rect4_own_chroma444_hits() -> usize { |
| @@ -18218,10 +18239,31 @@ fn decode_rect4_16_intrabc( | |||
| 18218 | // `--enable-intrabc=0` at the same settings is byte-exact, and the 4:2:0 | 18239 | // `--enable-intrabc=0` at the same settings is byte-exact, and the 4:2:0 |
| 18219 | // twin of the same recipe is byte-exact. | 18240 | // twin of the same recipe is byte-exact. |
| 18220 | // | 18241 | // |
| 18221 | - // 4:2:0 and 4:2:2 keep every constant below verbatim -- the arm is gated on | 18242 | + // 4:2:0 alone keeps every constant below verbatim: a 1:4 strip's chroma |
| 18222 | - // the full ss (0,0), not on a per-axis shift, so `pw / 2` and the literal | 18243 | + // plane block is 4:2:0's PAIR (the block above / beside it), because at |
| 18223 | - // halving are untouched for both. | 18244 | + // ss (1,1) the strip's 8x2 chroma lies INSIDE that neighbour's chroma. |
| 18245 | + // | ||
| 18246 | + // lane-av1422luma: at ss (1,0) that containment is gone -- 4:2:2 subsamples | ||
| 18247 | + // x only, so the strip's chroma is 8x4 (full height) at the STRIP'S OWN | ||
| 18248 | + // origin, and libaom's own clause agrees: `is_chroma_reference` | ||
| 18249 | + // (av1_common_int.h:1454) ends in `|| !subsampling_y`, which answers TRUE | ||
| 18250 | + // for every block at ss_y 0. Reading the strip's chroma at the 4:2:0 pair | ||
| 18251 | + // origin instead puts the unit one mi row high: on `s422_416x250_10b` | ||
| 18252 | + // (416x250 10-bit, sha256 d6aa7f45...) that is the V/U pair's `txb_skip` | ||
| 18253 | + // read at mi (51,84) -- ctx 2 where the oracle reads 8, `all_zero` decoded | ||
| 18254 | + // as 1 instead of 0, and the frame desyncs from there (luma included). | ||
| 18255 | + // The origin half is `lane/av1422seed`'s unlanded hunk, reproduced here so | ||
| 18256 | + // the arm is measurable whole; the gather and the publication extents | ||
| 18257 | + // below are this lane's. VERT_4 stays on the pair: `ss_size_lookup | ||
| 18258 | + // [BLOCK_4X16][1][0]` is BLOCK_INVALID at 4:2:2, so only HORZ reaches it. | ||
| 18224 | let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; | 18259 | let own444 = ss_x(fctx) == 0 && ss_y(fctx) == 0; |
| 18260 | + let own422 = ss_x(fctx) == 1 && ss_y(fctx) == 0 && horz; | ||
| 18261 | + if own422 && has_chroma { | ||
| 18262 | + hit!(INTRABC_RECT4_OWN_CHROMA422_HITS); | ||
| 18263 | + } | ||
| 18264 | + // One predicate for "this strip IS its own chroma reference": the strip's | ||
| 18265 | + // own mi position, its own luma extent, and per-axis subsampled sizes. | ||
| 18266 | + let own_chroma = own444 || own422; | ||
| 18225 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma { | 18267 | if ss_x(fctx) == 0 && ss_y(fctx) == 0 && has_chroma { |
| 18226 | hit!(INTRABC_RECT4_OWN_CHROMA444_HITS); | 18268 | hit!(INTRABC_RECT4_OWN_CHROMA444_HITS); |
| 18227 | } | 18269 | } |
| @@ -18232,9 +18274,13 @@ fn decode_rect4_16_intrabc( | |||
| 18232 | } else { | 18274 | } else { |
| 18233 | (8, 16) | 18275 | (8, 16) |
| 18234 | }; | 18276 | }; |
| 18235 | - let (cw, ch) = if own444 { (bw, bh) } else { (pw / 2, ph / 2) }; | 18277 | + let (cw, ch) = if own_chroma { |
| 18278 | + (bw >> ss_x(fctx), bh >> ss_y(fctx)) | ||
| 18279 | + } else { | ||
| 18280 | + (pw / 2, ph / 2) | ||
| 18281 | + }; | ||
| 18236 | let pair_mi = if has_chroma { | 18282 | let pair_mi = if has_chroma { |
| 18237 | - if own444 { | 18283 | + if own_chroma { |
| 18238 | lmi | 18284 | lmi |
| 18239 | } else if horz { | 18285 | } else if horz { |
| 18240 | (lmi.0 - 1, lmi.1) | 18286 | (lmi.0 - 1, lmi.1) |
| @@ -18245,8 +18291,8 @@ fn decode_rect4_16_intrabc( | |||
| 18245 | lmi | 18291 | lmi |
| 18246 | }; | 18292 | }; |
| 18247 | let (cpx, cpy) = if has_chroma { | 18293 | let (cpx, cpy) = if has_chroma { |
| 18248 | - if own444 { | 18294 | + if own_chroma { |
| 18249 | - (px, py) | 18295 | + (px >> ss_x(fctx), py >> ss_y(fctx)) |
| 18250 | } else { | 18296 | } else { |
| 18251 | (pair_mi.1 * MI / 2, pair_mi.0 * MI / 2) | 18297 | (pair_mi.1 * MI / 2, pair_mi.0 * MI / 2) |
| 18252 | } | 18298 | } |
| @@ -18528,7 +18574,25 @@ fn decode_rect4_16_intrabc( | |||
| 18528 | Grid::Own(vo) | 18574 | Grid::Own(vo) |
| 18529 | }; | 18575 | }; |
| 18530 | } else if has_chroma { | 18576 | } else if has_chroma { |
| 18531 | - let around = neighbours.around_mi_rect(pair_mi, pw, ph); | 18577 | + // lane-av1422luma: the own-chroma route reads its context over its |
| 18578 | + // OWN extent; at ss (1,0) it additionally goes through the | ||
| 18579 | + // every-second-column gather (one chroma 4-px column spans two | ||
| 18580 | + // luma mi columns, so the per-mi gather would count each column's | ||
| 18581 | + // whole-unit dc sign twice and OR in cells the unit does not | ||
| 18582 | + // cover) -- the same choice the `decode_rect4_16` chroma arm | ||
| 18583 | + // makes at `decode.rs:19577`. 4:4:4 keeps the per-mi gather: at | ||
| 18584 | + // ss_x 0 a chroma column IS a luma mi column, so sampling would | ||
| 18585 | + // halve its own above span. | ||
| 18586 | + let (gmi, gw, gh) = if own_chroma { | ||
| 18587 | + (lmi, bw, bh) | ||
| 18588 | + } else { | ||
| 18589 | + (pair_mi, pw, ph) | ||
| 18590 | + }; | ||
| 18591 | + let around = if own422 { | ||
| 18592 | + neighbours.around_mi_422_chroma(gmi, gw, gh) | ||
| 18593 | + } else { | ||
| 18594 | + neighbours.around_mi_rect(gmi, gw, gh) | ||
| 18595 | + }; | ||
| 18532 | let (ug, _) = read_inter_plane_rect( | 18596 | let (ug, _) = read_inter_plane_rect( |
| 18533 | dec, | 18597 | dec, |
| 18534 | cdfs, | 18598 | cdfs, |
| @@ -18589,7 +18653,18 @@ fn decode_rect4_16_intrabc( | |||
| 18589 | luma_grid = g; | 18653 | luma_grid = g; |
| 18590 | chroma_stamped_per_unit = false; | 18654 | chroma_stamped_per_unit = false; |
| 18591 | if has_chroma { | 18655 | if has_chroma { |
| 18592 | - let around = neighbours.around_mi_rect(pair_mi, pw, ph); | 18656 | + // lane-av1422luma: as the lossless twin above -- own extent, and |
| 18657 | + // the sampled gather at 4:2:2 only. | ||
| 18658 | + let (gmi, gw, gh) = if own_chroma { | ||
| 18659 | + (lmi, bw, bh) | ||
| 18660 | + } else { | ||
| 18661 | + (pair_mi, pw, ph) | ||
| 18662 | + }; | ||
| 18663 | + let around = if own422 { | ||
| 18664 | + neighbours.around_mi_422_chroma(gmi, gw, gh) | ||
| 18665 | + } else { | ||
| 18666 | + neighbours.around_mi_rect(gmi, gw, gh) | ||
| 18667 | + }; | ||
| 18593 | let (ug, _) = read_inter_plane_rect( | 18668 | let (ug, _) = read_inter_plane_rect( |
| 18594 | dec, | 18669 | dec, |
| 18595 | cdfs, | 18670 | cdfs, |
| @@ -18652,24 +18727,33 @@ fn decode_rect4_16_intrabc( | |||
| 18652 | let mut last_uv = None; | 18727 | let mut last_uv = None; |
| 18653 | if has_chroma { | 18728 | if has_chroma { |
| 18654 | hit!(RECT4_16_CHROMA_HITS); | 18729 | hit!(RECT4_16_CHROMA_HITS); |
| 18655 | - neighbours.record_uv_mode_mi(pair_mi.0, pair_mi.1, pw / MI, ph / MI, DC_PRED); | 18730 | + // lane-av1422luma: the uv-mode publication and the left/above skip |
| 18731 | + // state below are the STRIP's own at 4:2:2 / 4:4:4 -- publishing the | ||
| 18732 | + // pair extent (one mi row off, `ph`/`pw`) is what the NEXT block's | ||
| 18733 | + // chroma skip context then reads. | ||
| 18734 | + let (rmi, rw, rh) = if own_chroma { | ||
| 18735 | + (lmi, bw, bh) | ||
| 18736 | + } else { | ||
| 18737 | + (pair_mi, pw, ph) | ||
| 18738 | + }; | ||
| 18739 | + neighbours.record_uv_mode_mi(rmi.0, rmi.1, rw / MI, rh / MI, DC_PRED); | ||
| 18656 | if !chroma_stamped_per_unit { | 18740 | if !chroma_stamped_per_unit { |
| 18657 | let u_state = neighbour_state(&u_grid); | 18741 | let u_state = neighbour_state(&u_grid); |
| 18658 | let v_state = neighbour_state(&v_grid); | 18742 | let v_state = neighbour_state(&v_grid); |
| 18659 | let round_up_even = |n: usize| n.div_ceil(2) * 2; | 18743 | let round_up_even = |n: usize| n.div_ceil(2) * 2; |
| 18660 | let bound_h = round_up_even(neighbours.mi_rows); | 18744 | let bound_h = round_up_even(neighbours.mi_rows); |
| 18661 | let bound_w = round_up_even(neighbours.mi_cols); | 18745 | let bound_w = round_up_even(neighbours.mi_cols); |
| 18662 | - for cell in 0..(ph / MI) { | 18746 | + for cell in 0..(rh / MI) { |
| 18663 | - if pair_mi.0 + cell < bound_h | 18747 | + if rmi.0 + cell < bound_h |
| 18664 | - && let Some(slot) = neighbours.left.get_mut(pair_mi.0 + cell) | 18748 | + && let Some(slot) = neighbours.left.get_mut(rmi.0 + cell) |
| 18665 | { | 18749 | { |
| 18666 | slot[1] = u_state; | 18750 | slot[1] = u_state; |
| 18667 | slot[2] = v_state; | 18751 | slot[2] = v_state; |
| 18668 | } | 18752 | } |
| 18669 | } | 18753 | } |
| 18670 | - for cell in 0..(pw / MI) { | 18754 | + for cell in 0..(rw / MI) { |
| 18671 | - if pair_mi.1 + cell < bound_w | 18755 | + if rmi.1 + cell < bound_w |
| 18672 | - && let Some(slot) = neighbours.above.get_mut(pair_mi.1 + cell) | 18756 | + && let Some(slot) = neighbours.above.get_mut(rmi.1 + cell) |
| 18673 | { | 18757 | { |
| 18674 | slot[1] = u_state; | 18758 | slot[1] = u_state; |
| 18675 | slot[2] = v_state; | 18759 | slot[2] = v_state; |