Merge e93418a9 (ibcskip2) — suite green: ibcskip2-suite GREEN 629/0 23997s on server-3
Browse files at this commit8 changed files +912 -14
- crates/ec-av1/fixtures/444_leaf8_oob.obu +0 -0
- crates/ec-av1/fixtures/ll444_ibc_rect.obu +0 -0
- crates/ec-av1/src/decode.rs +240 -14
- crates/ec-av1/src/stream.rs +257 -0
- lanes/av1ibc444rect.report.md +147 -0
- lanes/av1ibc444rect_fixture_gen.py +40 -0
- lanes/av1ibcskip2.report.md +94 -0
- lanes/av1leaf8oob.report.md +134 -0
crates/ec-av1/fixtures/444_leaf8_oob.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/ll444_ibc_rect.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+240 -14
| @@ -3941,6 +3941,30 @@ pub(crate) fn reset_skipped_intrabc_chroma_arm_hits() { | |||
| 3941 | SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.set(0)); | 3941 | SKIPPED_INTRABC_CHROMA_ARM_HITS.with(|c| c.set(0)); |
| 3942 | } | 3942 | } |
| 3943 | 3943 | ||
| 3944 | +thread_local! { | ||
| 3945 | + /// lane-av1-ibcskip2: a sub-8x8 4:4:4 leaf that is BOTH intrabc AND | ||
| 3946 | + /// `skip` -- the arm whose chroma is the bare frame copy at the DV | ||
| 3947 | + /// (libaom `av1_build_inter_predictors_sb` runs regardless of `skip`). | ||
| 3948 | + /// Before the fix this route predicted intra-DC and every one of this | ||
| 3949 | + /// fixture's 150 such cells differed from the oracle on both chroma | ||
| 3950 | + /// planes. | ||
| 3951 | + static SKIPPED_INTRABC_DV_COPY_HITS: std::cell::Cell<usize> = | ||
| 3952 | + const { std::cell::Cell::new(0) }; | ||
| 3953 | +} | ||
| 3954 | + | ||
| 3955 | +/// Current value of [`SKIPPED_INTRABC_DV_COPY_HITS`]. | ||
| 3956 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3957 | +pub(crate) fn skipped_intrabc_dv_copy_hits() -> usize { | ||
| 3958 | + SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.get()) | ||
| 3959 | +} | ||
| 3960 | + | ||
| 3961 | +/// Zeroes [`SKIPPED_INTRABC_DV_COPY_HITS`] (gate tests call this before a | ||
| 3962 | +/// decode). | ||
| 3963 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 3964 | +pub(crate) fn reset_skipped_intrabc_dv_copy_hits() { | ||
| 3965 | + SKIPPED_INTRABC_DV_COPY_HITS.with(|c| c.set(0)); | ||
| 3966 | +} | ||
| 3967 | + | ||
| 3944 | /// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode). | 3968 | /// Zeroes [`INTRABC_HITS`] (gate tests call this before a decode). |
| 3945 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 3969 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 3946 | pub(crate) fn reset_intrabc_hits() { | 3970 | pub(crate) fn reset_intrabc_hits() { |
| @@ -5340,6 +5364,13 @@ thread_local! { | |||
| 5340 | /// walked at subsampling 0/0 (one unit per mi cell -- the geometry the | 5364 | /// walked at subsampling 0/0 (one unit per mi cell -- the geometry the |
| 5341 | /// hardcoded 4:2:0 span mis-stepped). | 5365 | /// hardcoded 4:2:0 span mis-stepped). |
| 5342 | static RECT_SPLIT_LOSSLESS_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 5366 | static RECT_SPLIT_LOSSLESS_CHROMA444_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 5367 | + /// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose luma | ||
| 5368 | + /// coefficients a lossless frame walked as per-4x4 inter units (the walk | ||
| 5369 | + /// that replaced the single rect unit). | ||
| 5370 | + static INTRABC_RECT8_LOSSLESS_LUMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 5371 | + /// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose chroma a | ||
| 5372 | + /// lossless 4:4:4 frame walked as per-4x4 [`TxbSet::Chroma4`] units. | ||
| 5373 | + static INTRABC_RECT8_LOSSLESS_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 5343 | } | 5374 | } |
| 5344 | 5375 | ||
| 5345 | /// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape | 5376 | /// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape |
| @@ -5370,6 +5401,24 @@ pub fn rect_split_lossless_chroma444_hits() -> usize { | |||
| 5370 | RECT_SPLIT_LOSSLESS_CHROMA444_HITS.with(|c| c.get()) | 5401 | RECT_SPLIT_LOSSLESS_CHROMA444_HITS.with(|c| c.get()) |
| 5371 | } | 5402 | } |
| 5372 | 5403 | ||
| 5404 | +/// How many unskipped intrabc 8x4/4x8 leaves a lossless frame walked luma as | ||
| 5405 | +/// per-4x4 inter units (lane-av1-ibc444rect). | ||
| 5406 | +pub fn intrabc_rect8_lossless_luma_hits() -> usize { | ||
| 5407 | + INTRABC_RECT8_LOSSLESS_LUMA_HITS.with(|c| c.get()) | ||
| 5408 | +} | ||
| 5409 | + | ||
| 5410 | +/// How many unskipped intrabc 8x4/4x8 leaves a lossless 4:4:4 frame walked | ||
| 5411 | +/// chroma as per-4x4 [`TxbSet::Chroma4`] units (lane-av1-ibc444rect). | ||
| 5412 | +pub fn intrabc_rect8_lossless_chroma_hits() -> usize { | ||
| 5413 | + INTRABC_RECT8_LOSSLESS_CHROMA_HITS.with(|c| c.get()) | ||
| 5414 | +} | ||
| 5415 | + | ||
| 5416 | +/// Gate-side reset for the two lane-av1-ibc444rect counters above. | ||
| 5417 | +pub fn reset_ibc444rect_hits() { | ||
| 5418 | + INTRABC_RECT8_LOSSLESS_LUMA_HITS.with(|c| c.set(0)); | ||
| 5419 | + INTRABC_RECT8_LOSSLESS_CHROMA_HITS.with(|c| c.set(0)); | ||
| 5420 | +} | ||
| 5421 | + | ||
| 5373 | /// Gate-side reset for the two lane-av1-loss64 counters above. | 5422 | /// Gate-side reset for the two lane-av1-loss64 counters above. |
| 5374 | pub fn reset_loss64_hits() { | 5423 | pub fn reset_loss64_hits() { |
| 5375 | CHROMA_EDGE_TU_CLIP_HITS.with(|c| c.set(0)); | 5424 | CHROMA_EDGE_TU_CLIP_HITS.with(|c| c.set(0)); |
| @@ -18190,17 +18239,27 @@ fn decode_leaf8( | |||
| 18190 | mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0), | 18239 | mv_to_q4(px, dv_col, 0), mv_to_q4(py, dv_row, 0), |
| 18191 | 8, 8, mc::InterpFilterKind::Bilinear, &mut yb, fctx, | 18240 | 8, 8, mc::InterpFilterKind::Bilinear, &mut yb, fctx, |
| 18192 | ); | 18241 | ); |
| 18193 | - let mut ub = vec![0u16; 4 * 4]; | 18242 | + // The chroma extent is THIS frame's subsampled size of the 8x8 luma |
| 18243 | + // leaf (`get_plane_block_size`): 4x4 at 4:2:0, 8x8 at 4:4:4. The | ||
| 18244 | + // literal 4x4 this replaces hardcoded the 4:2:0 halving -- at 4:4:4 | ||
| 18245 | + // the 16-sample override fed this leaf's own 8x8 chroma reconstruct, | ||
| 18246 | + // which indexed `prediction[16]` of a 16-sample buffer | ||
| 18247 | + // (len 16, index 16 at `PlaneBuf::reconstruct`). The same buffers | ||
| 18248 | + // are windowed at stride 8 by `read_intra_chroma_lossless` (the TX4 | ||
| 18249 | + // 4:4:4-lossless arm) and consumed whole by the TX8 and skip arms, | ||
| 18250 | + // so all three heal with this one sizing. | ||
| 18251 | + let (cw, ch) = (8 >> ss_x(fctx), 8 >> ss_y(fctx)); | ||
| 18252 | + let mut ub = vec![0u16; cw * ch]; | ||
| 18194 | mc::predict_with_filter( | 18253 | mc::predict_with_filter( |
| 18195 | &u.data, u.width, u.true_width, u.true_height, | 18254 | &u.data, u.width, u.true_width, u.true_height, |
| 18196 | - mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_x(fctx)), | 18255 | + mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)), |
| 18197 | - 4, 4, mc::InterpFilterKind::Bilinear, &mut ub, fctx, | 18256 | + cw, ch, mc::InterpFilterKind::Bilinear, &mut ub, fctx, |
| 18198 | ); | 18257 | ); |
| 18199 | - let mut vb = vec![0u16; 4 * 4]; | 18258 | + let mut vb = vec![0u16; cw * ch]; |
| 18200 | mc::predict_with_filter( | 18259 | mc::predict_with_filter( |
| 18201 | &v.data, v.width, v.true_width, v.true_height, | 18260 | &v.data, v.width, v.true_width, v.true_height, |
| 18202 | - mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_x(fctx)), | 18261 | + mv_to_q4(cpx, dv_col, ss_x(fctx)), mv_to_q4(cpy, dv_row, ss_y(fctx)), |
| 18203 | - 4, 4, mc::InterpFilterKind::Bilinear, &mut vb, fctx, | 18262 | + cw, ch, mc::InterpFilterKind::Bilinear, &mut vb, fctx, |
| 18204 | ); | 18263 | ); |
| 18205 | (yb, ub, vb) | 18264 | (yb, ub, vb) |
| 18206 | }); | 18265 | }); |
| @@ -18932,7 +18991,10 @@ fn read_intra_mode_sub8( | |||
| 18932 | /// arm for arm at leaf scale: a skipped leaf keeps its CfL contribution, an | 18991 | /// arm for arm at leaf scale: a skipped leaf keeps its CfL contribution, an |
| 18933 | /// intrabc leaf predicts a frame copy at its DV with the luma `tx_type` | 18992 | /// intrabc leaf predicts a frame copy at its DV with the luma `tx_type` |
| 18934 | /// inherited through [`INTRABC_CHROMA_TX`] (the caller arms it right after | 18993 | /// inherited through [`INTRABC_CHROMA_TX`] (the caller arms it right after |
| 18935 | -/// the luma read). The chroma position, reach and entropy-context span are | 18994 | +/// the luma read) -- and a SKIPPED intrabc leaf is still the DV copy, never |
| 18995 | +/// an intra prediction (lane-av1-ibcskip2: libaom's | ||
| 18996 | +/// `av1_build_inter_predictors_sb` runs for an intrabc block regardless of | ||
| 18997 | +/// `skip`). The chroma position, reach and entropy-context span are | ||
| 18936 | /// the leaf's own (ss 0/0); the 4x8/8x4 unit reads the same | 18998 | /// the leaf's own (ss 0/0); the 4x8/8x4 unit reads the same |
| 18937 | /// `ChromaRect8x4` tables [`decode_rect_split`] proves for that shape. | 18999 | /// `ChromaRect8x4` tables [`decode_rect_split`] proves for that shape. |
| 18938 | /// Records the leaf's own `uv_mode` map entry and chroma above/left state, | 19000 | /// Records the leaf's own `uv_mode` map entry and chroma above/left state, |
| @@ -18969,7 +19031,50 @@ fn sub8_leaf_chroma444( | |||
| 18969 | } else { | 19031 | } else { |
| 18970 | Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) | 19032 | Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx) |
| 18971 | }; | 19033 | }; |
| 18972 | - let grids = if skip { | 19034 | + let grids = if let Some(dv) = intrabc_dv.filter(|_| skip) { |
| 19035 | + // lane-av1-ibcskip2: a SKIPPED intrabc leaf still predicts the frame | ||
| 19036 | + // copy at its DV -- libaom's `av1_build_inter_predictors_sb` runs for | ||
| 19037 | + // an intrabc block regardless of `skip` (only the residual read is | ||
| 19038 | + // dropped), so the reconstruction is the bare DV copy. The intra push | ||
| 19039 | + // in the next arm is the NON-intrabc route; predicting DC there | ||
| 19040 | + // decoded flat cells where this fixture's oracle copies frame bytes | ||
| 19041 | + // (class skipped-intrabc-predicts-intra, | ||
| 19042 | + // lanes/av1ibcskip2.report.md). Same armed-palette-slot route the | ||
| 19043 | + // leaf's own luma skip arm uses (`decode_leaf_split4` / | ||
| 19044 | + // `decode_leaf_rect8`); the caller already flushed the recon queue | ||
| 19045 | + // before its luma DV copy, so the source samples are current. | ||
| 19046 | + let mut ub = vec![0u16; bw * bh]; | ||
| 19047 | + mc::predict_with_filter( | ||
| 19048 | + &u.data, u.width, u.true_width, u.true_height, | ||
| 19049 | + mv_to_q4(px, dv.1, 0), mv_to_q4(py, dv.0, 0), | ||
| 19050 | + bw, bh, mc::InterpFilterKind::Bilinear, &mut ub, fctx, | ||
| 19051 | + ); | ||
| 19052 | + let mut vb = vec![0u16; bw * bh]; | ||
| 19053 | + mc::predict_with_filter( | ||
| 19054 | + &v.data, v.width, v.true_width, v.true_height, | ||
| 19055 | + mv_to_q4(px, dv.1, 0), mv_to_q4(py, dv.0, 0), | ||
| 19056 | + bw, bh, mc::InterpFilterKind::Bilinear, &mut vb, fctx, | ||
| 19057 | + ); | ||
| 19058 | + hit!(SKIPPED_INTRABC_DV_COPY_HITS); | ||
| 19059 | + let zeros = &ZERO_RESIDUAL[..bw * bh]; | ||
| 19060 | + if square { | ||
| 19061 | + set_palette_pred(ub, fctx); | ||
| 19062 | + push_intra(1, px, py, 4, DC_PRED, 0, reach, zeros, None, None, smooth_neighbor_uv, fctx); | ||
| 19063 | + set_palette_pred(vb, fctx); | ||
| 19064 | + push_intra(2, px, py, 4, DC_PRED, 0, reach, zeros, None, None, smooth_neighbor_uv, fctx); | ||
| 19065 | + } else { | ||
| 19066 | + set_palette_pred(ub, fctx); | ||
| 19067 | + push_intra_rect(1, px, py, bw, bh, DC_PRED, 0, reach, zeros, None, None, smooth_neighbor_uv, fctx); | ||
| 19068 | + set_palette_pred(vb, fctx); | ||
| 19069 | + push_intra_rect(2, px, py, bw, bh, DC_PRED, 0, reach, zeros, None, None, smooth_neighbor_uv, fctx); | ||
| 19070 | + } | ||
| 19071 | + // The same arm-without-clear route the 4:2:0 tails count: a skipped | ||
| 19072 | + // leaf reads no coefficient, so the inherited chroma `tx_type` is | ||
| 19073 | + // dropped unconsumed. | ||
| 19074 | + hit!(SKIPPED_INTRABC_CHROMA_ARM_HITS); | ||
| 19075 | + fctx.intrabc_chroma_tx.with(|c| c.set(None)); | ||
| 19076 | + (Grid::Zero(bw * bh), Grid::Zero(bw * bh), 4, 4) | ||
| 19077 | + } else if skip { | ||
| 18973 | let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); | 19078 | let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh)); |
| 18974 | if square { | 19079 | if square { |
| 18975 | push_intra(1, px, py, 4, uv_predict_mode, 0, reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); | 19080 | push_intra(1, px, py, 4, uv_predict_mode, 0, reach, &ZERO_RESIDUAL[..16], alpha.zip(ac).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, fctx); |
| @@ -19016,6 +19121,63 @@ fn sub8_leaf_chroma444( | |||
| 19016 | )?; | 19121 | )?; |
| 19017 | (ug, vg, 4, 4) | 19122 | (ug, vg, 4, 4) |
| 19018 | } else { | 19123 | } else { |
| 19124 | + // lane-av1-ibc444rect: the unskipped lossless chroma walk this | ||
| 19125 | + // lane fixes (one rect unit -> per-4x4 Chroma4 units). | ||
| 19126 | + if lossless(fctx) { | ||
| 19127 | + hit!(INTRABC_RECT8_LOSSLESS_CHROMA_HITS); | ||
| 19128 | + } | ||
| 19129 | + if lossless(fctx) { | ||
| 19130 | + // lane-av1-ibc444rect: at lossless `read_tx_size` forces | ||
| 19131 | + // TX_4X4 on EVERY plane (`av1_get_tx_size`'s lossless | ||
| 19132 | + // first line), so this rect leaf's chroma is (bw/4)*(bh/4) | ||
| 19133 | + // TX_4X4 units at their own 4x4 origins -- not the single | ||
| 19134 | + // `ChromaRect8x4` rect unit the non-lossless arm below reads | ||
| 19135 | + // (`av1_get_max_uv_txsize(BLOCK_8X4)`'s rect, unreachable at | ||
| 19136 | + // lossless). Same walk the leaf's own non-intrabc lossless | ||
| 19137 | + // arm runs (lane-av1-llsub8's fix), plane-major per libaom | ||
| 19138 | + // `decode_token_recon_block`, with the intra predictor | ||
| 19139 | + // swapped for the CURRENT frame at the DV; CFL is never | ||
| 19140 | + // allowed at lossless and no alpha rides an intrabc leaf. | ||
| 19141 | + let mut out_u = Grid::Own(vec![0i32; bw * bh]); | ||
| 19142 | + let mut out_v = Grid::Own(vec![0i32; bw * bh]); | ||
| 19143 | + for (plane_idx, buf) in [(1usize, u), (2usize, v)] { | ||
| 19144 | + for ur in 0..bh / 4usize { | ||
| 19145 | + for uc in 0..bw / 4usize { | ||
| 19146 | + let (umi_r, umi_c) = (lmi.0 + ur, lmi.1 + uc); | ||
| 19147 | + let (upx, upy) = (px + uc * 4, py + ur * 4); | ||
| 19148 | + let mut pb = vec![0u16; 16]; | ||
| 19149 | + mc::predict_with_filter( | ||
| 19150 | + &buf.data, buf.width, buf.true_width, buf.true_height, | ||
| 19151 | + mv_to_q4(upx, dv.1, 0), mv_to_q4(upy, dv.0, 0), | ||
| 19152 | + 4, 4, mc::InterpFilterKind::Bilinear, &mut pb, fctx, | ||
| 19153 | + ); | ||
| 19154 | + set_palette_pred(pb, fctx); | ||
| 19155 | + let unit_around = neighbours.around_mi_rect((umi_r, umi_c), 4, 4); | ||
| 19156 | + let unit_reach = Reach::of(4, upx, upy, y.width, y.height, fctx); | ||
| 19157 | + let grid = read_plane( | ||
| 19158 | + dec, cdfs, TxbSet::Chroma4, scan4, plane_idx, unit_around[plane_idx], | ||
| 19159 | + DC_PRED, DC_PRED, 0, unit_reach, buf, upx, upy, 4, | ||
| 19160 | + TX4, base_q_idx, None, None, Some(3), smooth_neighbor_uv, fctx, | ||
| 19161 | + )?; | ||
| 19162 | + let cell = grid_unit_state(&grid, 4, 0, 0, 4, 4); | ||
| 19163 | + if umi_r < neighbours.mi_rows { | ||
| 19164 | + neighbours.left[umi_r][plane_idx] = cell; | ||
| 19165 | + } | ||
| 19166 | + if umi_c < neighbours.mi_cols { | ||
| 19167 | + neighbours.above[umi_c][plane_idx] = cell; | ||
| 19168 | + } | ||
| 19169 | + let out = if plane_idx == 1 { &mut out_u } else { &mut out_v }; | ||
| 19170 | + if let Grid::Own(v) = out { | ||
| 19171 | + for r in 0..4usize { | ||
| 19172 | + v[(ur * 4 + r) * bw + uc * 4..][..4] | ||
| 19173 | + .copy_from_slice(&grid[r * 4..][..4]); | ||
| 19174 | + } | ||
| 19175 | + } | ||
| 19176 | + } | ||
| 19177 | + } | ||
| 19178 | + } | ||
| 19179 | + (out_u, out_v, 4, 4) | ||
| 19180 | + } else { | ||
| 19019 | let scan: &[u16] = if bw > bh { &SCAN_8X4 } else { &SCAN_4X8 }; | 19181 | let scan: &[u16] = if bw > bh { &SCAN_8X4 } else { &SCAN_4X8 }; |
| 19020 | let default_tx = | 19182 | let default_tx = |
| 19021 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).unwrap_or(TxType::DctDct); | 19183 | fctx.intrabc_chroma_tx.with(std::cell::Cell::get).unwrap_or(TxType::DctDct); |
| @@ -19042,6 +19204,7 @@ fn sub8_leaf_chroma444( | |||
| 19042 | if plane_idx == 1 { out.0 = levels; } else { out.1 = levels; } | 19204 | if plane_idx == 1 { out.0 = levels; } else { out.1 = levels; } |
| 19043 | } | 19205 | } |
| 19044 | out | 19206 | out |
| 19207 | + } | ||
| 19045 | }; | 19208 | }; |
| 19046 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); | 19209 | fctx.intrabc_chroma_tx.with(|c| c.set(None)); |
| 19047 | pair | 19210 | pair |
| @@ -19681,6 +19844,11 @@ fn decode_leaf_rect8( | |||
| 19681 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | 19844 | neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); |
| 19682 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | 19845 | let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); |
| 19683 | if let Some(dv) = intrabc { | 19846 | if let Some(dv) = intrabc { |
| 19847 | + // lane-av1-ibc444rect: the unskipped lossless luma walk this lane | ||
| 19848 | + // fixes (one rect unit -> per-4x4 inter units). | ||
| 19849 | + if !skip && lossless(fctx) { | ||
| 19850 | + hit!(INTRABC_RECT8_LOSSLESS_LUMA_HITS); | ||
| 19851 | + } | ||
| 19684 | // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The | 19852 | // lane-av1txr: an intrabc `BLOCK_4X8`/`BLOCK_8X4` leaf. The |
| 19685 | // prediction is a frame copy at the DV and the residual reads the | 19853 | // prediction is a frame copy at the DV and the residual reads the |
| 19686 | // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf | 19854 | // INTER `LumaRect8x4` set -- but with `TxMode::Select` the leaf |
| @@ -19699,6 +19867,10 @@ fn decode_leaf_rect8( | |||
| 19699 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); | 19867 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height, fctx); |
| 19700 | flush_recon(fctx, y, u, v); | 19868 | flush_recon(fctx, y, u, v); |
| 19701 | let mut luma_leaves: Vec<(usize, usize, usize, usize)> = Vec::new(); | 19869 | let mut luma_leaves: Vec<(usize, usize, usize, usize)> = Vec::new(); |
| 19870 | + // The non-var-tx band publish, deferred to AFTER the unit loop: | ||
| 19871 | + // libaom's `set_txfm_ctxs` runs at `parse_decode_block`'s tail, so | ||
| 19872 | + // a unit's own `txb_skip_ctx` read must see the PRE-block bands. | ||
| 19873 | + let mut publish = Some((bw, bh)); | ||
| 19702 | if tx_select && !skip { | 19874 | if tx_select && !skip { |
| 19703 | // `max_block_wide`/`max_block_high`: the frame's own mi grid, | 19875 | // `max_block_wide`/`max_block_high`: the frame's own mi grid, |
| 19704 | // so a leaf hanging over the right/bottom edge reads no split | 19876 | // so a leaf hanging over the right/bottom edge reads no split |
| @@ -19721,13 +19893,34 @@ fn decode_leaf_rect8( | |||
| 19721 | &mut luma_leaves, | 19893 | &mut luma_leaves, |
| 19722 | ); | 19894 | ); |
| 19723 | hit!(RECT_INTRABC_VARTX_HITS); | 19895 | hit!(RECT_INTRABC_VARTX_HITS); |
| 19896 | + publish = None; | ||
| 19897 | + } else if lossless(fctx) && !skip { | ||
| 19898 | + // lane-av1-ibc444rect: `read_tx_size`'s lossless first line | ||
| 19899 | + // (`decodeframe.c:1203`) answers TX_4X4 for EVERY plane before | ||
| 19900 | + // any tree, and a lossless frame's `TxMode` is `ONLY_4X4` | ||
| 19901 | + // (spec 6.8.20) so no var-tx tree is read either -- the leaf's | ||
| 19902 | + // coefficients are (bw/4)*(bh/4) inter TX_4X4 units at their | ||
| 19903 | + // own origins, plane-major, NOT the single rect transform the | ||
| 19904 | + // non-lossless arm reads (that one is | ||
| 19905 | + // `av1_get_max_uv_txsize(BLOCK_8X4)`'s rect, unreachable at | ||
| 19906 | + // lossless). Same unit structure the non-intrabc lossless | ||
| 19907 | + // split below walks; each unit predicts from the CURRENT | ||
| 19908 | + // frame at the DV. Measured on the lane's `e4` fixture | ||
| 19909 | + // (`ll444_ibc_rect.obu`): the single-rect read desynced the | ||
| 19910 | + // tile and tripped the lossless WHT assert `(4, 8) != (4, 4)` | ||
| 19911 | + // at `TxParams::run`. | ||
| 19912 | + for ur in 0..bh / 4usize { | ||
| 19913 | + for uc in 0..bw / 4usize { | ||
| 19914 | + luma_leaves.push((ur, uc, 4, 4)); | ||
| 19915 | + } | ||
| 19916 | + } | ||
| 19917 | + publish = Some((4, 4)); | ||
| 19724 | } else { | 19918 | } else { |
| 19725 | luma_leaves.push((0, 0, bw, bh)); | 19919 | luma_leaves.push((0, 0, bw, bh)); |
| 19726 | // The non-var-tx arm: a SKIPPED intrabc leaf (or a frame | 19920 | // The non-var-tx arm: a SKIPPED intrabc leaf (or a frame |
| 19727 | // outside `TxMode::Select`) publishes its own rect transform | 19921 | // outside `TxMode::Select`) publishes its own rect transform |
| 19728 | // (`set_txfm_ctxs`'s `skip && is_inter` branch writes the | 19922 | // (`set_txfm_ctxs`'s `skip && is_inter` branch writes the |
| 19729 | // block's own pixels -- the same size here). | 19923 | // block's own pixels -- the same size here). |
| 19730 | - txfm_partition_update_rect(neighbours, lmi, (bw, bh), (bw, bh)); | ||
| 19731 | } | 19924 | } |
| 19732 | // The transform type an intrabc block's CHROMA inherits is the | 19925 | // The transform type an intrabc block's CHROMA inherits is the |
| 19733 | // `tx_type_map` entry at the chroma unit's co-located luma | 19926 | // `tx_type_map` entry at the chroma unit's co-located luma |
| @@ -19786,6 +19979,17 @@ fn decode_leaf_rect8( | |||
| 19786 | ) | 19979 | ) |
| 19787 | }; | 19980 | }; |
| 19788 | let mut coding = cdfs.txb(set, DC_PRED); | 19981 | let mut coding = cdfs.txb(set, DC_PRED); |
| 19982 | + // lane-av1-ibc444rect: `av1_read_tx_type` returns before any | ||
| 19983 | + // symbol for a lossless block (qindex == 0, decodemv.c:681) | ||
| 19984 | + // on EVERY plane and size -- the lossless units this arm now | ||
| 19985 | + // walks must not read the set's tx_type either (`read_plane` | ||
| 19986 | + // does the same for its own call sites). Measured on the | ||
| 19987 | + // lane's `ll444_ibc_rect.obu`: with the symbol read, the | ||
| 19988 | + // first unit's ladder diverged right after a matched | ||
| 19989 | + // `all_zero` (ours +4096 rng on the unused tx_type). | ||
| 19990 | + if lossless(fctx) { | ||
| 19991 | + coding.tx_type = None; | ||
| 19992 | + } | ||
| 19789 | let (levels, tx_type) = read_coeffs_rect( | 19993 | let (levels, tx_type) = read_coeffs_rect( |
| 19790 | dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2), | 19994 | dec, &mut coding, tu_scan, tw, th, skip_ctx, dc_sign_ctx(around.2), |
| 19791 | TxType::DctDct, | 19995 | TxType::DctDct, |
| @@ -19794,11 +19998,28 @@ fn decode_leaf_rect8( | |||
| 19794 | chroma_tx = tx_type; | 19998 | chroma_tx = tx_type; |
| 19795 | fctx.luma_tx_type.with(|c| c.set(tx_type)); | 19999 | fctx.luma_tx_type.with(|c| c.set(tx_type)); |
| 19796 | } | 20000 | } |
| 19797 | - let residual = dequant_and_inverse_typed_wh( | 20001 | + // lane-av1-ibc444rect: the residual goes through [`TxParams`] |
| 19798 | - &levels, tw, th, crate::decode::bit_depth(fctx), block_q_idx(fctx), | 20002 | + // with the frame's lossless flag, exactly like |
| 19799 | - plane_q_delta(0, fctx).0, plane_q_delta(0, fctx).1, tx_type, | 20003 | + // [`read_plane`]'s own dequant -- at lossless `TxParams::run` |
| 19800 | - block_iqmatrix(fctx, 0, tw, th, tx_type), | 20004 | + // is the Walsh-Hadamard inverse on every plane, and the |
| 19801 | - ); | 20005 | + // `dequant_and_inverse_typed_wh` shortcut the lossy var-tx |
| 20006 | + // callers use has no lossless flag (it would run the DCT | ||
| 20007 | + // inverse over the WHT-ordered levels). Measured on the lane | ||
| 20008 | + // fixture: the DCT route left ±1..30 sample errors on every | ||
| 20009 | + // walked leaf's luma. | ||
| 20010 | + let tx = TxParams { | ||
| 20011 | + w: tw, | ||
| 20012 | + h: th, | ||
| 20013 | + bit_depth: crate::decode::bit_depth(fctx), | ||
| 20014 | + q_idx: block_q_idx(fctx), | ||
| 20015 | + dc_delta: plane_q_delta(0, fctx).0, | ||
| 20016 | + ac_delta: plane_q_delta(0, fctx).1, | ||
| 20017 | + tx_type, | ||
| 20018 | + qm: block_iqmatrix(fctx, 0, tw, th, tx_type), | ||
| 20019 | + stride: 0, | ||
| 20020 | + lossless: lossless(fctx), | ||
| 20021 | + }; | ||
| 20022 | + let residual = tx.run(&levels); | ||
| 19802 | if (tw, th) == (4, 4) { | 20023 | if (tw, th) == (4, 4) { |
| 19803 | push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); | 20024 | push_intra(0, tu_px, tu_py, 4, DC_PRED, 0, tu_reach, &residual, None, None, smooth_neighbor, fctx); |
| 19804 | } else { | 20025 | } else { |
| @@ -19816,6 +20037,11 @@ fn decode_leaf_rect8( | |||
| 19816 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | 20037 | neighbours.record_mi_luma(tu_mi, 4, &tu_grid); |
| 19817 | } | 20038 | } |
| 19818 | } | 20039 | } |
| 20040 | + // The deferred non-var-tx band publish (see `publish` above): the | ||
| 20041 | + // units' `txb_skip_ctx` reads ran against the pre-block bands. | ||
| 20042 | + if let Some((pub_w, pub_h)) = publish { | ||
| 20043 | + txfm_partition_update_rect(neighbours, lmi, (pub_w, pub_h), (bw, bh)); | ||
| 20044 | + } | ||
| 19819 | if single { | 20045 | if single { |
| 19820 | let state = neighbour_state(&grid); | 20046 | let state = neighbour_state(&grid); |
| 19821 | for cell in 0..h_mi { | 20047 | for cell in 0..h_mi { |
crates/ec-av1/src/stream.rsmodified+257 -0
| @@ -126,6 +126,23 @@ pub fn rect_intrabc_reads() -> usize { | |||
| 126 | crate::decode::rect_intrabc_reads() | 126 | crate::decode::rect_intrabc_reads() |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | +/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose luma a lossless | ||
| 130 | +/// frame walked as per-4x4 inter units. | ||
| 131 | +pub fn intrabc_rect8_lossless_luma_hits() -> usize { | ||
| 132 | + crate::decode::intrabc_rect8_lossless_luma_hits() | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +/// lane-av1-ibc444rect: unskipped intrabc 8x4/4x8 leaves whose chroma a | ||
| 136 | +/// lossless 4:4:4 frame walked as per-4x4 `Chroma4` units. | ||
| 137 | +pub fn intrabc_rect8_lossless_chroma_hits() -> usize { | ||
| 138 | + crate::decode::intrabc_rect8_lossless_chroma_hits() | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +/// Gate-side reset for the lane-av1-ibc444rect counters above. | ||
| 142 | +pub fn reset_ibc444rect_hits() { | ||
| 143 | + crate::decode::reset_ibc444rect_hits() | ||
| 144 | +} | ||
| 145 | + | ||
| 129 | /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900 | 146 | /// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900 |
| 130 | /// r22) -- the counter a screen-content witness gate reads to prove it | 147 | /// r22) -- the counter a screen-content witness gate reads to prove it |
| 131 | /// exercises the inter-frame palette path, not the key frame's. | 148 | /// exercises the inter-frame palette path, not the key frame's. |
| @@ -6157,7 +6174,131 @@ pub(crate) mod tests { | |||
| 6157 | } | 6174 | } |
| 6158 | } | 6175 | } |
| 6159 | 6176 | ||
| 6177 | + /// lane-av1-leaf8oob: the OOB pin for [`decode_leaf8`]'s intrabc chroma | ||
| 6178 | + /// frame-copy buffers. The closure hardcoding the leaf's chroma | ||
| 6179 | + /// prediction at `4x4` (`vec![0u16; 4 * 4]`, `predict_with_filter` at | ||
| 6180 | + /// `4, 4`) carried the 4:2:0 halving of an 8x8 luma leaf into every | ||
| 6181 | + /// subsampling: at 4:4:4 the leaf's own chroma plane block is 8x8 | ||
| 6182 | + /// (`csz == 8`), so the 16-sample override reached | ||
| 6183 | + /// [`PlaneBuf::reconstruct`] as an 8x8 prediction and indexed | ||
| 6184 | + /// `prediction[16]` of a 16-sample buffer -- | ||
| 6185 | + /// `index out of bounds: the len is 16 but the index is 16` at the | ||
| 6186 | + /// reconstruct call, on every conformant stream of this shape (a panic, | ||
| 6187 | + /// never a refusal). Same signature class as lane-lossless128's | ||
| 6188 | + /// 128-axis lossless extent (`len 16, index 16` there too). | ||
| 6189 | + /// | ||
| 6190 | + /// `crates/ec-av1/fixtures/444_leaf8_oob.obu`, 3577 bytes, sha256 | ||
| 6191 | + /// `72bed2791d1ceba8be7926a052c7838c5d96d4f9d56d28fb69789a753d3593af` | ||
| 6192 | + /// (force-added past the `fixtures` gitignore like every sibling | ||
| 6193 | + /// fixture): the lane ticket's witness-hunt reproducer (s1a/s2e) -- a | ||
| 6194 | + /// 320x256, 3-frame, 8-bit 4:4:4 screen-content keyframe run whose | ||
| 6195 | + /// census pins 4 intrabc 8x8 leaves (the oracle's own MB dump opens on | ||
| 6196 | + /// unbroken inter-classified intra = intrabc blocks). The encoding | ||
| 6197 | + /// recipe is not independently recoverable in this lane; the bytes are | ||
| 6198 | + /// pinned by length + FNV-1a64 here and by the oracle raw fingerprint | ||
| 6199 | + /// below. | ||
| 6200 | + /// | ||
| 6201 | + /// WHAT THIS GATE DOES NOT CLAIM: sample-exactness -- and it pins no | ||
| 6202 | + /// pixel baseline. Measured against the oracle aomdec (`--rawvideo`; | ||
| 6203 | + /// comparison method ground-truthed by the green | ||
| 6204 | + /// `a_lossless_sb128_rect_intra_block_decodes_sample_exact` and | ||
| 6205 | + /// `a_lossless_444_min_partition8_inter_stream_decodes_sample_exact` | ||
| 6206 | + /// witnesses on this same tree), this stream DIVERGES and its output is | ||
| 6207 | + /// not even self-deterministic: frame 0's first differing LUMA sample | ||
| 6208 | + /// is at (275,128), the (y, u, v) differing counts per frame are | ||
| 6209 | + /// (20811, 35467, 32320)/(20308, 39177, 35994)/(20131, 39588, 36601) of | ||
| 6210 | + /// 81920 samples per plane, and under `EC_AV1_PLANE_SENTINEL=1` the | ||
| 6211 | + /// chroma counts move (u f0 35467 -> 35630) while luma stays put. | ||
| 6212 | + /// Sentinel-vs-uninit output diffing localises that dependence to 458 | ||
| 6213 | + /// WHOLE 8x8 chroma blocks (frame 0: chroma x >= 96, y >= 64) reading | ||
| 6214 | + /// samples this decode never wrote -- ambient memory in those slots, | ||
| 6215 | + /// hence any pixel-exact assert here drifts run to run with the batch. | ||
| 6216 | + /// Both facts belong to ONE pre-existing defect this lane must not | ||
| 6217 | + /// chase (the ticket's fix touches only leaf8's chroma prediction | ||
| 6218 | + /// buffers, which cannot feed a luma sample, and the pre-fix run never | ||
| 6219 | + /// got past the panicked leaf): a decode desync on this stream around | ||
| 6220 | + /// frame-0 SB (3..4, 2), after which samples diverge from the oracle | ||
| 6221 | + /// and the misread layout leaves chroma blocks unreconstructed. | ||
| 6222 | + /// Disposition: `deferred(unblock: divergence lane -- EC trace pairing | ||
| 6223 | + /// against the oracle on this fixture)`. So this gate pins exactly what | ||
| 6224 | + /// its ticket owns: fixture identity, a decode that RUNS TO COMPLETION | ||
| 6225 | + /// where the old code died with `len 16, index 16`, and the arm counter. | ||
| 6226 | + /// | ||
| 6227 | + /// Assertions (all before/without any skip path): | ||
| 6228 | + /// 1. fixture bytes: exact length + FNV-1a64; | ||
| 6229 | + /// 2. `decode_stream` succeeds -- 3 frames, 320x256 (the pre-fix run | ||
| 6230 | + /// died here with the len-16/index-16 panic); | ||
| 6231 | + /// 3. non-vacuity: `leaf8_intrabc_hits` moves (measured 0 -> 4), so the | ||
| 6232 | + /// arm owning the fixed buffers really fired; | ||
| 6233 | + /// 4. the oracle aomdec still decodes the pinned bytes (raw size + | ||
| 6234 | + /// fingerprint), anchoring the deferred divergence comparison. | ||
| 6235 | + #[test] | ||
| 6236 | + fn an_intrabc_8x8_leaf_chroma_frame_copy_at_444_decodes_without_the_oob() { | ||
| 6237 | + const NAME: &str = "an_intrabc_8x8_leaf_chroma_frame_copy_at_444_decodes_without_the_oob"; | ||
| 6238 | + const FIXTURE_LEN: usize = 3577; | ||
| 6239 | + const FIXTURE_FNV: u64 = 0x86b9_3a51_fe16_353c; | ||
| 6240 | + const W: usize = 320; | ||
| 6241 | + const H: usize = 256; | ||
| 6242 | + const FRAMES: usize = 3; | ||
| 6243 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| 6244 | + .join("fixtures/444_leaf8_oob.obu"); | ||
| 6245 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | ||
| 6246 | + panic!( | ||
| 6247 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \ | ||
| 6248 | + which is a failure, not a skip", | ||
| 6249 | + obu.display() | ||
| 6250 | + ) | ||
| 6251 | + }); | ||
| 6252 | + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved"); | ||
| 6253 | + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved"); | ||
| 6254 | + | ||
| 6255 | + let _guard = lock_gate_counters(); | ||
| 6256 | + crate::decode::reset_leaf8_intrabc_hits(); | ||
| 6257 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 6258 | + panic!("{NAME}: the pinned stream no longer decodes cleanly: {e}") | ||
| 6259 | + }); | ||
| 6260 | + assert!( | ||
| 6261 | + crate::decode::leaf8_intrabc_hits() > 0, | ||
| 6262 | + "{NAME}: gate is vacuous -- no intrabc 8x8 leaf was decoded, so the arm \ | ||
| 6263 | + owning the fixed chroma buffers never fired" | ||
| 6264 | + ); | ||
| 6265 | + assert_eq!(frames.len(), FRAMES, "{NAME}: frame count"); | ||
| 6266 | + for f in &frames { | ||
| 6267 | + assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions"); | ||
| 6268 | + } | ||
| 6160 | 6269 | ||
| 6270 | + // The oracle aomdec, rawvideo out: FRAMES concatenated yuv444p frames. | ||
| 6271 | + if aomdec_path().is_file() { | ||
| 6272 | + let dir = std::env::temp_dir().join(format!("ec-av1-leaf8oob-{}", std::process::id())); | ||
| 6273 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 6274 | + std::fs::create_dir_all(&dir).expect("scratch dir"); | ||
| 6275 | + let raw = dir.join("aomdec.raw"); | ||
| 6276 | + let out = Command::new(aomdec_path()) | ||
| 6277 | + .args(["--codec=av1", "--rawvideo", "-o"]) | ||
| 6278 | + .arg(&raw) | ||
| 6279 | + .arg(&obu) | ||
| 6280 | + .stdin(Stdio::null()) | ||
| 6281 | + .stdout(Stdio::piped()) | ||
| 6282 | + .stderr(Stdio::piped()) | ||
| 6283 | + .output() | ||
| 6284 | + .expect("aomdec failed to run"); | ||
| 6285 | + assert!( | ||
| 6286 | + out.status.success(), | ||
| 6287 | + "{NAME}: the oracle aomdec refused the stream: {}", | ||
| 6288 | + String::from_utf8_lossy(&out.stderr) | ||
| 6289 | + ); | ||
| 6290 | + let ref_raw = std::fs::read(&raw).expect("aomdec rawvideo output"); | ||
| 6291 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 6292 | + assert_eq!(ref_raw.len(), W * H * 3 * FRAMES, "{NAME}: aomdec raw size"); | ||
| 6293 | + assert_eq!( | ||
| 6294 | + fnv1a64(&ref_raw), | ||
| 6295 | + 0x3821_0bcb_f572_973c, | ||
| 6296 | + "{NAME}: aomdec raw fingerprint moved" | ||
| 6297 | + ); | ||
| 6298 | + } else { | ||
| 6299 | + eprintln!("SKIP {NAME} aomdec arm: no oracle aomdec at {}", aomdec_path().display()); | ||
| 6300 | + } | ||
| 6301 | + } | ||
| 6161 | /// lane-lossless128: a LOSSLESS key frame that codes a 128-axis | 6302 | /// lane-lossless128: a LOSSLESS key frame that codes a 128-axis |
| 6162 | /// (`BLOCK_64X128`) intra block -- the shape libaom's `read_tx_size` forces | 6303 | /// (`BLOCK_64X128`) intra block -- the shape libaom's `read_tx_size` forces |
| 6163 | /// to `TX_4X4` on its very first line (`decodeframe.c:1183`), so every plane | 6304 | /// to `TX_4X4` on its very first line (`decodeframe.c:1183`), so every plane |
| @@ -6387,6 +6528,122 @@ pub(crate) mod tests { | |||
| 6387 | ); | 6528 | ); |
| 6388 | } | 6529 | } |
| 6389 | 6530 | ||
| 6531 | + /// lane-av1-ibc444rect: an unskipped intrabc `BLOCK_8X4`/`BLOCK_4X8` leaf | ||
| 6532 | + /// on a lossless 4:4:4 frame walks its coefficients as per-4x4 inter | ||
| 6533 | + /// `TX_4X4` units on every plane -- `read_tx_size`'s lossless first line | ||
| 6534 | + /// (`decodeframe.c:1203`) forces TX_4X4 before any tree, the frame's | ||
| 6535 | + /// `TxMode` is `ONLY_4X4` so no var-tx tree is read either, and | ||
| 6536 | + /// `av1_read_tx_type`'s qindex==0 early return (`decodemv.c:681`) drops | ||
| 6537 | + /// the tx_type symbol the lossy 4x4 inter sets carry -- NOT the single | ||
| 6538 | + /// `LumaRect8x4Inter`/`ChromaRect8x4` rect unit the non-lossless arm | ||
| 6539 | + /// reads, and not the lossy per-unit arm's tx_type read. | ||
| 6540 | + /// | ||
| 6541 | + /// The pinned fixture `ll444_ibc_rect.obu` (99614 bytes, provenance in | ||
| 6542 | + /// `lanes/av1ibc444rect.report.md`) is a lossless `--profile=1 --i444 | ||
| 6543 | + /// --enable-intrabc=1` key frame. r1 pinned the (then-known) leaf8 | ||
| 6544 | + /// `palette_window` panic as its alignment witness; with that blocker | ||
| 6545 | + /// fixed upstream (lane-av1leaf8oob) the frame decodes to completion and | ||
| 6546 | + /// this gate is the FULL-FRAME exact `aomdec` comparison its r1 doc | ||
| 6547 | + /// promised, flipped by lane-av1-ibcskip2 -- which also closed the | ||
| 6548 | + /// SKIPPED intrabc sub8 chroma cells the r1 measurement called out: a | ||
| 6549 | + /// skipped intrabc leaf's chroma is the bare frame copy at the DV | ||
| 6550 | + /// (libaom's `av1_build_inter_predictors_sb` runs regardless of `skip`), | ||
| 6551 | + /// never the intra-DC push that arm used to run. Fail-before, measured on | ||
| 6552 | + /// this tree with the DV-copy arm cut back to the intra push: 2794 U + | ||
| 6553 | + /// 2830 V samples differ across 180 distinct 4x4 cells, 175 of them | ||
| 6554 | + /// exactly this frame's skipped intrabc leaves, luma clean; with the arm, | ||
| 6555 | + /// 0 differing samples on every plane. | ||
| 6556 | + #[test] | ||
| 6557 | + fn a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units() { | ||
| 6558 | + const NAME: &str = "a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units"; | ||
| 6559 | + const FIXTURE_LEN: usize = 99614; | ||
| 6560 | + const FIXTURE_FNV: u64 = 0xa1b6_a84e_ac6a_656f; | ||
| 6561 | + const W: usize = 320; | ||
| 6562 | + const H: usize = 240; | ||
| 6563 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| 6564 | + .join("fixtures/ll444_ibc_rect.obu"); | ||
| 6565 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | ||
| 6566 | + panic!( | ||
| 6567 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot run, \ | ||
| 6568 | + which is a failure, not a skip", | ||
| 6569 | + obu.display() | ||
| 6570 | + ) | ||
| 6571 | + }); | ||
| 6572 | + assert_eq!(stream.len(), FIXTURE_LEN, "{NAME}: fixture length moved"); | ||
| 6573 | + assert_eq!(fnv1a64(&stream), FIXTURE_FNV, "{NAME}: fixture bytes moved"); | ||
| 6574 | + | ||
| 6575 | + let _guard = lock_gate_counters(); | ||
| 6576 | + crate::decode::reset_ibc444rect_hits(); | ||
| 6577 | + crate::decode::reset_skipped_intrabc_dv_copy_hits(); | ||
| 6578 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 6579 | + panic!("{NAME}: the fixture must decode to completion (the leaf8 \ | ||
| 6580 | + chroma buffers were fixed upstream): {e}") | ||
| 6581 | + }); | ||
| 6582 | + assert_eq!(frames.len(), 1, "{NAME}: shown frame count"); | ||
| 6583 | + let luma = crate::decode::intrabc_rect8_lossless_luma_hits(); | ||
| 6584 | + let chroma = crate::decode::intrabc_rect8_lossless_chroma_hits(); | ||
| 6585 | + assert_eq!( | ||
| 6586 | + (luma, chroma), | ||
| 6587 | + (339, 339), | ||
| 6588 | + "{NAME}: the per-4x4 walk must fire on the fixture's full unskipped \ | ||
| 6589 | + intrabc rect census (got luma {luma}, chroma {chroma}) -- zero \ | ||
| 6590 | + means the fixture no longer reaches the fixed body (class \ | ||
| 6591 | + gate-blind-to-feature), more means the entropy desynced and \ | ||
| 6592 | + garbage blocks read as intrabc rect leaves" | ||
| 6593 | + ); | ||
| 6594 | + let dv_skips = crate::decode::skipped_intrabc_dv_copy_hits(); | ||
| 6595 | + assert_eq!( | ||
| 6596 | + dv_skips, 150, | ||
| 6597 | + "{NAME}: the skipped-intrabc DV-copy chroma arm must fire on every \ | ||
| 6598 | + one of the fixture's 150 skipped intrabc leaves (got {dv_skips}) \ | ||
| 6599 | + -- zero means the arm is unreachable (class gate-blind-to-feature)" | ||
| 6600 | + ); | ||
| 6601 | + | ||
| 6602 | + // The oracle aomdec, rawvideo out: one concatenated yuv444p frame. | ||
| 6603 | + if aomdec_path().is_file() { | ||
| 6604 | + let dir = std::env::temp_dir().join(format!("ec-av1-ibcskip2-{}", std::process::id())); | ||
| 6605 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 6606 | + std::fs::create_dir_all(&dir).expect("scratch dir"); | ||
| 6607 | + let raw = dir.join("aomdec.raw"); | ||
| 6608 | + let out = Command::new(aomdec_path()) | ||
| 6609 | + .args(["--codec=av1", "--rawvideo", "-o"]) | ||
| 6610 | + .arg(&raw) | ||
| 6611 | + .arg(&obu) | ||
| 6612 | + .stdin(Stdio::null()) | ||
| 6613 | + .stdout(Stdio::piped()) | ||
| 6614 | + .stderr(Stdio::piped()) | ||
| 6615 | + .output() | ||
| 6616 | + .expect("aomdec failed to run"); | ||
| 6617 | + assert!( | ||
| 6618 | + out.status.success(), | ||
| 6619 | + "{NAME}: the oracle aomdec refused the stream: {}", | ||
| 6620 | + String::from_utf8_lossy(&out.stderr) | ||
| 6621 | + ); | ||
| 6622 | + let ref_raw = std::fs::read(&raw).expect("aomdec rawvideo output"); | ||
| 6623 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 6624 | + assert_eq!(ref_raw.len(), W * H * 3, "{NAME}: aomdec raw size"); | ||
| 6625 | + let f = &frames[0]; | ||
| 6626 | + for (plane, off, p) in | ||
| 6627 | + [(&f.y, 0usize, "Y"), (&f.u, W * H, "U"), (&f.v, 2 * W * H, "V")] | ||
| 6628 | + { | ||
| 6629 | + let want = &ref_raw[off..off + W * H]; | ||
| 6630 | + let bad = plane.iter().zip(want).filter(|&(&a, &b)| a as u8 != b).count(); | ||
| 6631 | + assert_eq!( | ||
| 6632 | + bad, 0, | ||
| 6633 | + "{NAME}: aomdec plane {p}: {bad} samples differ -- a \ | ||
| 6634 | + regression here reopens the skipped-intrabc sub8 chroma \ | ||
| 6635 | + predictor or the rect walk" | ||
| 6636 | + ); | ||
| 6637 | + } | ||
| 6638 | + } else { | ||
| 6639 | + eprintln!("SKIP {NAME} aomdec arm: no oracle aomdec at {}", aomdec_path().display()); | ||
| 6640 | + } | ||
| 6641 | + eprintln!( | ||
| 6642 | + "{NAME}: frame sample-exact vs oracle aomdec; {luma}+{chroma} rect \ | ||
| 6643 | + walks, {dv_skips} skipped-intrabc DV copies" | ||
| 6644 | + ); | ||
| 6645 | + } | ||
| 6646 | + | ||
| 6390 | /// lane-dkey: the palette-neighbour-band gate. A palette-Y block's size and | 6647 | /// lane-dkey: the palette-neighbour-band gate. A palette-Y block's size and |
| 6391 | /// colours used to stay standing in the mi-granular above/left bands after a | 6648 | /// colours used to stay standing in the mi-granular above/left bands after a |
| 6392 | /// sub-8x8 group was decoded next to it -- the sub-8x8 readers published | 6649 | /// sub-8x8 group was decoded next to it -- the sub-8x8 readers published |
lanes/av1ibc444rect.report.mdadded+147 -0
| @@ -0,0 +1,147 @@ | |||
| 1 | +# lane-av1-ibc444rect: intrabc rect-leaf chroma walk at lossless 4:4:4 (r1) | ||
| 2 | + | ||
| 3 | +## Charter | ||
| 4 | + | ||
| 5 | +Fix the deferred `av1llsub8` gap: intrabc rect leaves at lossless 444 routed | ||
| 6 | +the rect arm's `read_coeffs_rect` path with the wrong unit structure. | ||
| 7 | +Unblocked by the green inter side (av1llinter2). Work in | ||
| 8 | +`edith_codecs-av1ibc444rect` @ 9e77c16b. 4:2:0 stays identical; existing | ||
| 9 | +lossless gates stay green. At most 8 encodes for the fixture. | ||
| 10 | + | ||
| 11 | +## Defect (both planes of the intrabc route) | ||
| 12 | + | ||
| 13 | +`decode_leaf_rect8`'s intrabc arm at lossless pushed ONE rect unit: | ||
| 14 | + | ||
| 15 | +- luma: `read_coeffs_rect(LumaRect8x4Inter, 8x4)` — one TX_8X4-shaped read, | ||
| 16 | +- chroma: `sub8_leaf_chroma444`'s non-square arm, one `ChromaRect8x4` read. | ||
| 17 | + | ||
| 18 | +The oracle codes per-4x4 INTER TX_4X4 units, plane-major: `read_tx_size`'s | ||
| 19 | +lossless first line (`decodeframe.c:1203`) forces TX_4X4 before any tree, the | ||
| 20 | +frame's `TxMode` is `ONLY_4X4` (spec 6.8.20) so no var-tx tree either, and | ||
| 21 | +`av1_read_tx_type`'s `qindex == 0` early return (`decodemv.c:681`) drops the | ||
| 22 | +tx_type symbol the LOSSY 4x4 inter sets DO carry. Fail-before, measured: the | ||
| 23 | +single-rect read desynced the tile and tripped the lossless WHT assert | ||
| 24 | +`(4, 8) != (4, 4)` at `TxParams::run` — the same panic class av1llinter2 | ||
| 25 | +attributed on the inter side. | ||
| 26 | + | ||
| 27 | +## Fix (same shape as the non-intrabc arm) | ||
| 28 | + | ||
| 29 | +1. `decode_leaf_rect8` intrabc arm, `lossless && !skip`: the leaf's luma | ||
| 30 | + coefficients become `(bw/4)*(bh/4)` 4x4 units in the EXISTING per-unit | ||
| 31 | + loop (var-tx `(tw,th)==(4,4)` mechanics: `inter_txbset_for(4)`, | ||
| 32 | + `scan4`, per-unit `around_mi`, `luma_skip_ctx`, DV copy prediction via | ||
| 33 | + the palette slot, `push_intra`). The TXFM band publish moved AFTER the | ||
| 34 | + unit loop (`set_txfm_ctxs` runs at `parse_decode_block`'s tail, so the | ||
| 35 | + units' own `txb_skip_ctx` reads must see the pre-block bands). The units' | ||
| 36 | + `coding.tx_type` is nulled at lossless — WITHOUT this the ladder diverges | ||
| 37 | + immediately (ours +4096 rng on a symbol the oracle never codes; found by | ||
| 38 | + the `EC_TRACE_COEFF` ladder, oracle O#1353 vs ours G#1359-1361 on the | ||
| 39 | + fixture's first leaf). | ||
| 40 | +2. The units' residual goes through `TxParams { lossless: lossless(fctx) }` | ||
| 41 | + (read_plane's own route), NOT `dequant_and_inverse_typed_wh` — the latter | ||
| 42 | + has no lossless flag and ran a DCT inverse over the WHT-ordered levels | ||
| 43 | + (±1..30 sample errors on every walked leaf; gone after the fix). | ||
| 44 | +3. `sub8_leaf_chroma444`'s intrabc non-square arm, `lossless`: per-4x4 | ||
| 45 | + `TxbSet::Chroma4` walk mirroring the lane-av1-llsub8 fix (per-unit | ||
| 46 | + `around_mi_rect`, `Reach::of`, per-unit entropy stamps, `Some(3)` big-row | ||
| 47 | + fold), with the intra predictor swapped for the CURRENT frame at the DV. | ||
| 48 | +4. Skip arms untouched. 4:2:0: the luma walk also applies at 420 lossless | ||
| 49 | + (luma is subsampling-independent) — that route was equally broken before | ||
| 50 | + and no committed gate reaches it; every currently-green stream is | ||
| 51 | + bit-identical (all 16 battery gates below). | ||
| 52 | + | ||
| 53 | +Counters `INTRABC_RECT8_LOSSLESS_LUMA_HITS`/`_CHROMA_HITS` + accessors | ||
| 54 | +(`stream::intrabc_rect8_lossless_{luma,chroma}_hits`, | ||
| 55 | +`reset_ibc444rect_hits`) pin the walk for the gate. | ||
| 56 | + | ||
| 57 | +## Fixture (bounded grid: 8 encodes, budget used 8/8) | ||
| 58 | + | ||
| 59 | +`fixtures/ll444_ibc_rect.obu`, 99614 bytes, sha256 | ||
| 60 | +`482dedca0201beea9b0a05720b5da7fe93c350c9fea7699cdb010c3fbc227ec0`. | ||
| 61 | +Source: `lanes/av1ibc444rect_fixture_gen.py` (sha256 | ||
| 62 | +`3420a1f80603efc16a66a37be72d04dcd66836df0dc79d28710511c165ef92f1`, | ||
| 63 | +y4m sha256 `5d3b8a2cbce29766852806787811f28a0b7b7df75409915666bad087e0cc9768`): | ||
| 64 | +320x240 C444, dithered chaotic base + single-half 8x4/4x8 near-match stamps | ||
| 65 | +(per-copy bias + random flips — never an exact match). Encoder: | ||
| 66 | +`$HOME/.cache/aom-oracle/build/aomenc --codec=av1 --bit-depth=8 | ||
| 67 | +--input-bit-depth=8 --passes=1 --cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 | ||
| 68 | +--limit=1 --threads=1 --tile-columns=0 --lossless=1 --sb-size=128 | ||
| 69 | +--enable-1to4-partitions=1 --profile=1 --i444 --enable-intrabc=1 | ||
| 70 | +--tune-content=screen --min-partition-size=4 --max-partition-size=8 --obu`. | ||
| 71 | +The stream codes hundreds of unskipped intrabc rect leaves (oracle inspect | ||
| 72 | +census: 8x4 + 4x8 + 4x4 intrabc, most non-skip). | ||
| 73 | + | ||
| 74 | +Grid summary (all probed with env-gated shape prints + the counters): | ||
| 75 | +testsrc2-based and five crafted variants; every stream that codes intrabc | ||
| 76 | +rect leaves ALSO codes an intrabc `BLOCK_8X8` leaf (aomenc's dominant | ||
| 77 | +intrabc shape — 284 of them in the E7 census) and/or skipped intrabc leaves. | ||
| 78 | +`--max-partition-size` cannot forbid 8x8 `PARTITION_NONE` while keeping | ||
| 79 | +8x4/4x8 leaves; content shaping reduced but never eliminated 8x8 intrabc. | ||
| 80 | + | ||
| 81 | +## Verification (measured) | ||
| 82 | + | ||
| 83 | +- Entropy: `EC_TRACE_COEFF` ladders aligned ours-vs-instrumented-aomdec | ||
| 84 | + (`~/.cache/aom-oracle/build`, `EC_TRACE_COEFF=1`); post-fix the tile runs | ||
| 85 | + through all walked leaves with no desync (pre-fix: desync at the first | ||
| 86 | + leaf's eob read, then the WHT assert). | ||
| 87 | +- Pixel exactness of the walk vs the oracle `aomdec --rawvideo`, measured | ||
| 88 | + with a THROWAWAY two-line patch of the sibling 8x8 defect (16->block-size | ||
| 89 | + chroma prediction buffers in `decode_leaf8`) — applied ONLY to measure, | ||
| 90 | + reverted before commit, never part of this lane's diff: | ||
| 91 | + - E4 fixture: luma 0 differing samples; chroma diffs ONLY on skipped | ||
| 92 | + intrabc cells (36727 bytes, 100% `(intrabc=1, skip=1)` cells + their | ||
| 93 | + poisoned neighbours; zero on walked leaves). | ||
| 94 | + - E8 (= the committed fixture): 339 walked rect leaves; luma 0 differing | ||
| 95 | + samples; chroma 5624 bytes, again exclusively on `(intrabc=1, skip=1)` | ||
| 96 | + cells + neighbours. | ||
| 97 | +- Gate `a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units` (green): | ||
| 98 | + pins fixture len/FNV, asserts the walk fires exactly (3, 3) before the | ||
| 99 | + known leaf8 death and that the death signature is the leaf8 | ||
| 100 | + `palette_window` slice — i.e. the entropy ladder survived the walked | ||
| 101 | + leaves. Fail-before: pre-fix the death was the `(4, 8) != (4, 4)` WHT | ||
| 102 | + assert. Mutation check: flipping the chroma `Some(3)` ctx to `None` | ||
| 103 | + fails the gate (desync moves the death). | ||
| 104 | +- Battery, all green: `a_lossless_libaom_key_frame_decodes_sample_exact`, | ||
| 105 | + `a_lossless_libaom_inter_frame_decodes_sample_exact`, | ||
| 106 | + `a_real_aomenc_lossless_444_key_frame_decodes_sample_exact`, | ||
| 107 | + `a_skipped_lossless_intrabc_rect_strip_zeroes_its_entropy_bands`, | ||
| 108 | + `a_lossless_444_min_partition64_inter_stream_decodes_pixel_exact`, the new | ||
| 109 | + gate, plus the ten lossy intrabc gates (screen-kf intrabc reads, 16x4 | ||
| 110 | + pair strip, both-orientation rect intrabc, sb128 screen + rect strip, | ||
| 111 | + tx4 leaf chroma, sub8 census, var-tx census, mixed var-tx tree, tx-select | ||
| 112 | + census). `cargo check -p ec-av1 --all-targets`: 0 warnings, 0 errors. | ||
| 113 | + | ||
| 114 | +## Not claimed | ||
| 115 | + | ||
| 116 | +The committed tree does NOT decode either candidate fixture to a full frame: | ||
| 117 | +every reaching stream panics at its first intrabc `BLOCK_8X8` leaf on the | ||
| 118 | +llintra-deferred defect. Whole-fixture 0-diff is therefore NOT claimed and | ||
| 119 | +cannot be measured on this tree; the walk's own samples are measured 0-diff | ||
| 120 | +as above. | ||
| 121 | + | ||
| 122 | +## Blocked-by / deferred (spoken, not hidden) | ||
| 123 | + | ||
| 124 | +1. `decode_leaf8`'s intrabc chroma prediction buffers, hardcoded 4x4 | ||
| 125 | + (16 samples for a 64-sample 4:4:4 reconstruct) — panics at | ||
| 126 | + `palette_window` (decode.rs ~2460). OWNER: the `av1llintra` deferral; this | ||
| 127 | + lane did NOT touch `decode_leaf8` (different function, sibling | ||
| 128 | + ownership). Fix is its own two lines (buffer + predict size follow | ||
| 129 | + `chroma_444`); after it lands, decode completes and this lane's gate | ||
| 130 | + flips to the full-frame exact comparison. | ||
| 131 | +2. Skipped-intrabc sub-8x8 chroma predictor: `sub8_leaf_chroma444`'s skip | ||
| 132 | + arm (and the 4:2:0 group-tail skip arm) predict INTRA-DC where libaom | ||
| 133 | + predicts the frame copy at the DV (`av1_build_inter_predictors_sb` runs | ||
| 134 | + regardless of skip for an intrabc block). All remaining E4/E8 chroma | ||
| 135 | + diffs sit exactly on those cells. UNNAMED in any prior report (loss64 | ||
| 136 | + fixed the STRIP path only); class-adjacent to the RESERVED 4:2:0 | ||
| 137 | + group-tail skip arm, so per the standing reservation this lane stops and | ||
| 138 | + escalates instead of editing. Needs: consult the DV in the skip arms | ||
| 139 | + (armed palette slot), plus a fixture gate. | ||
| 140 | +3. `av1llintra2`'s rect64 lossless chroma gap (`EC_RECTCHROMA_GAP`) remains | ||
| 141 | + deferred in its own lane; not touched here. | ||
| 142 | + | ||
| 143 | +## Function-collision statement | ||
| 144 | + | ||
| 145 | +This lane's diff lands only in `decode_leaf_rect8` and `sub8_leaf_chroma444` | ||
| 146 | +(+ counters in decode.rs, accessors/gate in stream.rs). `decode_leaf8` — | ||
| 147 | +where the blocking sibling defect lives — is untouched, byte-for-byte. | ||
lanes/av1ibc444rect_fixture_gen.pyadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +import sys, random | ||
| 2 | +W, H = 320, 240 | ||
| 3 | +rng = random.Random(60606) | ||
| 4 | +y = bytearray(W*H); u = bytearray(W*H); v = bytearray(W*H) | ||
| 5 | +def base(x, y): | ||
| 6 | + return ((x*3 + y*5) ^ (x*11 + y*13)) & 63 | ||
| 7 | +def wm(wx, wy): # per-window watermark: unique per window | ||
| 8 | + return ((wx*73) ^ (wy*151) ^ ((wx*wy) & 255)) & 63 | ||
| 9 | +for j in range(H): | ||
| 10 | + for i in range(W): | ||
| 11 | + b = (base(i, j) ^ wm(i >> 3, j >> 3)) + 32 | ||
| 12 | + y[j*W+i] = b | ||
| 13 | + u[j*W+i] = 128 + ((base(i+37, j+91) ^ wm((i+37) >> 3, (j+91) >> 3)) & 15) - 7 | ||
| 14 | + v[j*W+i] = 128 - ((base(i+13, j+57) ^ wm((i+13) >> 3, (j+57) >> 3)) & 15) - 7 | ||
| 15 | +patch = [[96 + rng.randrange(64) for _ in range(8)] for _ in range(8)] | ||
| 16 | +def put(X, Y, luma, cuv): | ||
| 17 | + y[Y*W+X] = min(255, max(0, luma)) | ||
| 18 | + u[Y*W+X] = min(255, max(0, cuv)) | ||
| 19 | + v[Y*W+X] = min(255, max(0, 255 - cuv)) | ||
| 20 | +for by in range(0, H, 8): | ||
| 21 | + for bx in range(0, W, 8): | ||
| 22 | + r = rng.random() | ||
| 23 | + if r < 0.55: | ||
| 24 | + shape = (8, 4, 0 if rng.random() < 0.5 else 4) | ||
| 25 | + elif r < 0.85: | ||
| 26 | + shape = (4, 8, 0) | ||
| 27 | + if bx + 4 >= W: shape = (8, 4, rng.randrange(2)*4) | ||
| 28 | + else: | ||
| 29 | + continue | ||
| 30 | + w, h, oy = shape | ||
| 31 | + bias = rng.randrange(-3, 4) | ||
| 32 | + flips = {(rng.randrange(w), rng.randrange(h)) for _ in range(5)} | ||
| 33 | + for j in range(h): | ||
| 34 | + for i in range(w): | ||
| 35 | + s = patch[(by+oy+j) % 8][(bx+i) % 8] | ||
| 36 | + if (i, j) in flips: s ^= 1 | ||
| 37 | + put(bx+i, by+oy+j, s + bias, 100 + (s & 31) + bias) | ||
| 38 | +with open(sys.argv[1], 'wb') as f: | ||
| 39 | + f.write(b'YUV4MPEG2 W320 H240 F25:1 Ip A1:1 C444 XYSCSS=444\nFRAME\n') | ||
| 40 | + f.write(bytes(y)); f.write(bytes(u)); f.write(bytes(v)) | ||
lanes/av1ibcskip2.report.mdadded+94 -0
| @@ -0,0 +1,94 @@ | |||
| 1 | +# lane-av1-ibcskip2: skipped-intrabc sub8 chroma predicts the DV frame copy (r1) | ||
| 2 | + | ||
| 3 | +## Charter | ||
| 4 | + | ||
| 5 | +Close `av1ibc444rect` blocked_by item 2: `sub8_leaf_chroma444`'s skip arm | ||
| 6 | +predicted the intra mode (DC for an intrabc leaf) where libaom predicts the | ||
| 7 | +frame copy at the DV — `av1_build_inter_predictors_sb` runs for an intrabc | ||
| 8 | +block regardless of `skip`; only the residual read is dropped. Work in | ||
| 9 | +`edith_codecs-av1ibcskip2` @ b6d4b528 (`f23115aa` + cherry-picked | ||
| 10 | +`9dbeafab`, the leaf8 chroma-extent fix that unblocked this fixture). The | ||
| 11 | +RESERVED 4:2:0 group-tail chroma SKIP arm is untouched (see collision | ||
| 12 | +statement). | ||
| 13 | + | ||
| 14 | +## Defect (measured on this tree, fail-before) | ||
| 15 | + | ||
| 16 | +The fixture decodes to completion at this HEAD (the parent lane needed a | ||
| 17 | +throwaway leaf8 patch to measure; b6d4b528 landed it). Native reproduction, | ||
| 18 | +oracle `aomdec --rawvideo` vs our decode: | ||
| 19 | + | ||
| 20 | +- luma: 0 differing samples, | ||
| 21 | +- U: 2794 differing samples, V: 2830, across 180 distinct 4x4 cells — | ||
| 22 | + 175 of them EXACTLY the frame's skipped intrabc leaves (150 leaves | ||
| 23 | + covering 175 4x4 cells), the other 5 their immediate neighbours | ||
| 24 | + (poisoned edge state), | ||
| 25 | +- a throwaway cell trace confirmed every diff cell sits on a | ||
| 26 | + `(intrabc=1, skip=1)` leaf or touches one. | ||
| 27 | + | ||
| 28 | +Class: `skipped-intrabc-predicts-intra`. The 4:2:0 group-tail twin (flat DC | ||
| 29 | +at the tails) is the RESERVED arm — not touched, not fixed here. | ||
| 30 | + | ||
| 31 | +## Fix | ||
| 32 | + | ||
| 33 | +New first arm in `sub8_leaf_chroma444` (`if let Some(dv) = | ||
| 34 | +intrabc_dv.filter(|_| skip)`): bilinear MC of the CURRENT frame's U/V at the | ||
| 35 | +DV (the unskipped arm's own `mv_to_q4` route), armed through | ||
| 36 | +`set_palette_pred` and pushed with `ZERO_RESIDUAL` via | ||
| 37 | +`push_intra`/`push_intra_rect` — the same armed-palette-slot route the two | ||
| 38 | +luma skip arms (`decode_leaf_split4`, `decode_leaf_rect8`) already use; the | ||
| 39 | +callers flushed the recon queue before their luma DV copy, so the source | ||
| 40 | +samples are current. The inherited chroma `tx_type` slot is disarmed | ||
| 41 | +(consumed by nothing — a skipped leaf reads no coefficient), keeping | ||
| 42 | +`SKIPPED_INTRABC_CHROMA_ARM_HITS` semantics. Engagement counter | ||
| 43 | +`SKIPPED_INTRABC_DV_COPY_HITS` + accessors pin the route for the gate. | ||
| 44 | + | ||
| 45 | +## Stale gate flip (forced by the cherry-pick) | ||
| 46 | + | ||
| 47 | +`a_lossless_444_intrabc_rect_leaf_walks_per_4x4_units` was RED at HEAD as | ||
| 48 | +committed: it pinned the leaf8 `palette_window` panic ((3, 3) walk hits) | ||
| 49 | +which b6d4b528 removed — the walk now fires its full census (339, 339). | ||
| 50 | +Flipped per its own r1 doc to the full-frame exact `aomdec` comparison: | ||
| 51 | +fixture len/FNV pins kept, (339, 339) census assert, `SKIPPED_INTRABC_ | ||
| 52 | +DV_COPY_HITS == 150` route assert, `aomdec --rawvideo` 0-diff on all three | ||
| 53 | +planes (arm skipped with a notice only when the oracle binary is absent). | ||
| 54 | + | ||
| 55 | +## Verification (measured) | ||
| 56 | + | ||
| 57 | +- Mutation check: the arm mutated to count-but-predict-flat (grey 128 | ||
| 58 | + prediction, flow intact, counter armed) → gate RED at "aomdec plane U: | ||
| 59 | + 2503 samples differ". The pixel comparison is load-bearing; the ==150 | ||
| 60 | + counter assert catches an unreachable arm. | ||
| 61 | +- Gate green (post-fix, mutation reverted): "frame sample-exact vs oracle | ||
| 62 | + aomdec; 339+339 rect walks, 150 skipped-intrabc DV copies". Whole-fixture | ||
| 63 | + 0 differing samples on Y, U and V — also re-measured out-of-gate via a | ||
| 64 | + throwaway plane dump + byte diff before the gate existed (0/0/0). | ||
| 65 | +- Battery (superset of the parent's 16): every `intrabc`-named gate 17 | ||
| 66 | + passed, every `lossless`-named gate 12 passed, every `sb128`-named gate 9 | ||
| 67 | + passed (1 ignored diagnostic each where present), including the parent's | ||
| 68 | + full list, the leaf8oob gate from HEAD's cherry-pick, and this flipped | ||
| 69 | + gate. `cargo check -p ec-av1 --all-targets`: 0 warnings, 0 errors. | ||
| 70 | + | ||
| 71 | +## 4:2:0 / reserved-arm collision statement | ||
| 72 | + | ||
| 73 | +The diff lands only in `sub8_leaf_chroma444` (444-only: all six call sites | ||
| 74 | +sit inside `if chroma_444` blocks; 4:2:0 chroma rides the group tails), | ||
| 75 | +the `SKIPPED_INTRABC_DV_COPY_HITS` counter block in decode.rs, and the | ||
| 76 | +flipped gate in stream.rs. The 4:2:0 group-tail chroma SKIP arm and the | ||
| 77 | +`last_intrabc` tails in `decode_leaf_split4`/`decode_leaf_rect8` — the | ||
| 78 | +RESERVED territory — are byte-for-byte untouched, and none of their call | ||
| 79 | +sites pass `intrabc_dv = Some`, so 4:2:0 control flow through the edited | ||
| 80 | +function is identical; the 420-heavy intrabc/lossless/sb128 battery above | ||
| 81 | +confirms bit-identical behaviour. | ||
| 82 | + | ||
| 83 | +## Not claimed | ||
| 84 | + | ||
| 85 | +Exactness is claimed for the pinned fixture (whole frame, all planes) and | ||
| 86 | +whatever the battery gates already pinned — not a general "every 4:4:4 | ||
| 87 | +intrabc stream decodes exact" statement. The `444_leaf8_oob.obu` | ||
| 88 | +divergence noted in `lanes/av1leaf8oob.report.md` is that lane's deferral, | ||
| 89 | +not re-measured here. | ||
| 90 | + | ||
| 91 | +## Deferred | ||
| 92 | + | ||
| 93 | +Nothing. The charter's deliverable (skip arm consults the DV, fixture gate, | ||
| 94 | +4:2:0 identical, gates green) is complete on this branch. | ||
lanes/av1leaf8oob.report.mdadded+134 -0
| @@ -0,0 +1,134 @@ | |||
| 1 | +# lane-av1leaf8oob: fix the 4:4:4 intrabc 8x8-leaf chroma OOB panic | ||
| 2 | + | ||
| 3 | +Tree: lane-av1-leaf8oob @ 9e77c16b (base = lane-av1llpredgate2's pin). | ||
| 4 | +Reproducer pinned at `crates/ec-av1/fixtures/444_leaf8_oob.obu`. | ||
| 5 | + | ||
| 6 | +## Defect | ||
| 7 | + | ||
| 8 | +`cargo run -p ec-av1 --example decode_probe` on the fixture died with | ||
| 9 | + | ||
| 10 | +``` | ||
| 11 | +thread 'main' panicked at crates/ec-av1/src/decode.rs:3774:16: | ||
| 12 | +index out of bounds: the len is 16 but the index is 16 | ||
| 13 | +``` | ||
| 14 | + | ||
| 15 | +(`PlaneBuf::reconstruct` via `exec_intra` via `decode_leaf8`, reached through | ||
| 16 | +the `#[track_caller]` reconstruct calls at 4:4:4, 8x8 leaf.) | ||
| 17 | + | ||
| 18 | +Root cause, ONE plane-math site as the ticket guessed: `decode_leaf8`'s | ||
| 19 | +intrabc frame-copy closure sized the leaf's chroma prediction buffers with | ||
| 20 | +the literal 4:2:0 halving of an 8x8 luma leaf — `vec![0u16; 4 * 4]` and | ||
| 21 | +`predict_with_filter(.., 4, 4, ..)` for BOTH U and V — while the leaf's own | ||
| 22 | +chroma reconstruct at 4:4:4 runs `csz == 8`. The 16-sample override rode the | ||
| 23 | +`PALETTE_PRED` slot into `reconstruct` as an 8x8 prediction, which indexed | ||
| 24 | +`prediction[row * 8 + col]` = 16 at row 2, col 0: `len 16, index 16`. | ||
| 25 | + | ||
| 26 | +## Fix (source, not a clamp) | ||
| 27 | + | ||
| 28 | +`crates/ec-av1/src/decode.rs`, `decode_leaf8` intrabc closure: the chroma | ||
| 29 | +extent is now derived from the frame's subsampling, | ||
| 30 | +`(cw, ch) = (8 >> ss_x(fctx), 8 >> ss_y(fctx))` for both the buffer size and | ||
| 31 | +the `predict_with_filter` geometry, and the row subpel arg uses `ss_y` like | ||
| 32 | +every sibling intrabc site (rect intrabc at 11570/11910/11920, the | ||
| 33 | +`luma: bool` helper at 13899; bit-identical at every reachable ss since | ||
| 34 | +4:2:2 refuses at the sequence header, so ss_x == ss_y in all decodable | ||
| 35 | +streams). 4:2:0 still computes 4x4 — byte-identical there. | ||
| 36 | + | ||
| 37 | +The one sizing heals all three consumers of the buffers: the TX8 and skip | ||
| 38 | +arms consume them whole at `csz`, and the TX4 4:4:4-lossless arm windows | ||
| 39 | +them at stride 8 inside `read_intra_chroma_lossless` | ||
| 40 | +(`palette_window(buf, stride, ox, oy, 4, 4)` reads up to index 63), which | ||
| 41 | +had the same OOB latent. | ||
| 42 | + | ||
| 43 | +## Class sweep (hardcoded 4:2:0 chroma extent, decode.rs) | ||
| 44 | + | ||
| 45 | +Swept every intrabc chroma prediction site in decode.rs: | ||
| 46 | + | ||
| 47 | +| site | extent | verdict | | ||
| 48 | +|---|---|---| | ||
| 49 | +| `decode_leaf8` intrabc closure (18128/18134 pre-fix) | literal `4*4` | **THE BUG** — fixed | | ||
| 50 | +| `decode_block` square intrabc (16735+) | `chroma_side = side >> ss_x` | ss-derived, clean | | ||
| 51 | +| rect intrabc owned/rect4 (11557+, 11897+) | `cw * ch`, `cside` | ss-derived, clean | | ||
| 52 | +| `predict_intrabc` helper (13899) | `w * h` params, `ss_x`/`ss_y` split | clean | | ||
| 53 | +| `sub8_leaf_chroma444` (18927+) | `bw * bh` (already chroma units) | clean by construction | | ||
| 54 | +| `decode_leaf_split4` 4x4 arm (19423+) | literal `4*4`/`4,4` | 4:2:0-only arm (chroma_444 returns earlier) — literal correct there | | ||
| 55 | +| `decode_leaf_rect8` clamp arm (20106+) | literal `4*4`/`4,4` | same 4:2:0-only arm — literal correct there | | ||
| 56 | + | ||
| 57 | +No second 4:4:4-reachable instance exists in decode.rs. Signature-class | ||
| 58 | +note: lane-lossless128 hit the identical panic text (`len 16, index 16`) | ||
| 59 | +from a 128-axis lossless extent — recurring class, both now pinned by | ||
| 60 | +gates. | ||
| 61 | + | ||
| 62 | +## Gate | ||
| 63 | + | ||
| 64 | +`stream::tests::an_intrabc_8x8_leaf_chroma_frame_copy_at_444_decodes_without_the_oob` | ||
| 65 | +(crates/ec-av1/src/stream.rs), modelled on the av1llpredgate2 pattern: | ||
| 66 | + | ||
| 67 | +- Fixture provenance: the lane ticket's witness-hunt reproducer (s1a/s2e); | ||
| 68 | + 3577 bytes, sha256 | ||
| 69 | + `72bed2791d1ceba8be7926a052c7838c5d96d4f9d56d28fb69789a753d3593af`, | ||
| 70 | + FNV-1a64 `0x86b93a51fe16353c`; 320x256, 3 frames, 8-bit 4:4:4 | ||
| 71 | + screen-content keyframes (the oracle's MB dump opens on unbroken | ||
| 72 | + inter-classified intra = intrabc blocks). The aomenc recipe is not | ||
| 73 | + independently recoverable in this lane — bytes pinned by length + FNV + | ||
| 74 | + oracle raw fingerprint. Force-added past the `fixtures` gitignore like | ||
| 75 | + every sibling fixture; missing file panics, no skip path. | ||
| 76 | +- Assertions: fixture bytes (len + FNV), `decode_stream` succeeds (3 | ||
| 77 | + frames, 320x256 — the pre-fix run died here), `leaf8_intrabc_hits` | ||
| 78 | + 0 -> 4 non-vacuity, and the oracle aomdec still decodes the pinned bytes | ||
| 79 | + (raw 737280 bytes, FNV `0x38210bcbf572973c`). | ||
| 80 | + | ||
| 81 | +### Red-before (mutation verification) | ||
| 82 | + | ||
| 83 | +`git checkout --` of the fix (patch snapshotted to /tmp, restored | ||
| 84 | +byte-identical, `diff`-verified): gate RED at | ||
| 85 | +`decode.rs:3774:16 index out of bounds: the len is 16 but the index is 16` | ||
| 86 | +— the exact ticketed panic. With the fix: green, standalone AND in the | ||
| 87 | +full `intrabc lossless` filter batch (26 passed, 3 consecutive runs). | ||
| 88 | + | ||
| 89 | +### Why the gate pins NO pixel baseline (measured, then scoped out) | ||
| 90 | + | ||
| 91 | +Against the oracle aomdec (`--rawvideo`; comparison method ground-truthed: | ||
| 92 | +`a_lossless_sb128_rect_intra_block_decodes_sample_exact` and | ||
| 93 | +`a_lossless_444_min_partition8_inter_stream_decodes_sample_exact` are green | ||
| 94 | +on this same tree), this stream DIVERGES, and not deterministically: | ||
| 95 | + | ||
| 96 | +- per-frame differing (y, u, v) of 81920 samples/plane: | ||
| 97 | + (20811, 35467, 32320), (20308, 39177, 35994), (20131, 39588, 36601); | ||
| 98 | + frame 0's first differing LUMA sample at (275,128); | ||
| 99 | +- under `EC_AV1_PLANE_SENTINEL=1` chroma counts move (u f0 35467 -> 35630) | ||
| 100 | + while luma stays put; sentinel-vs-uninit output diffing localises the | ||
| 101 | + dependence to 458 WHOLE 8x8 chroma blocks (frame 0: chroma x >= 96, | ||
| 102 | + y >= 64) reading samples this decode never wrote — ambient memory, so | ||
| 103 | + any pixel-exact assert drifts run to run (observed: u f1 39177 vs | ||
| 104 | + 39126 vs 39138 across batch runs). | ||
| 105 | + | ||
| 106 | +Attribution to this lane's diff: none. The fix touches only leaf8's chroma | ||
| 107 | +prediction buffers; intra/intrabc luma reads only luma edges and the luma | ||
| 108 | +plane, so a luma-first divergence cannot come from it, and the pre-fix run | ||
| 109 | +never produced output (panic at the first intrabc 8x8 leaf). | ||
| 110 | + | ||
| 111 | +Unified reading: ONE pre-existing decode desync on this stream around | ||
| 112 | +frame-0 SB (3..4, 2) — after it, samples diverge from the oracle AND the | ||
| 113 | +misread layout leaves whole chroma blocks unreconstructed (which is where | ||
| 114 | +the never-written reads live). An initial-bounds witness would not have | ||
| 115 | +seen this: the stream never decoded before this lane lifted the panic. | ||
| 116 | + | ||
| 117 | +Disposition: `deferred(unblock: divergence lane — EC trace pairing against | ||
| 118 | +the oracle on this fixture; the oracle's AOMMB dump covers only frame 0's | ||
| 119 | +first MB rows, so pairing needs the env-gated rungs)`. | ||
| 120 | + | ||
| 121 | +## Non-regression | ||
| 122 | + | ||
| 123 | +- `cargo test -p ec-av1 --lib -- intrabc lossless`: 26 passed, 0 failed | ||
| 124 | + (3 consecutive runs, including the 4:2:0 intrabc gates | ||
| 125 | + `an_intrabc_tx4_leaf_chroma_inherits_the_luma_type_and_predicts_from_the_frame_copy`, | ||
| 126 | + the sb128 intrabc pixel-exact gates, and the 4:4:4 lossless | ||
| 127 | + minp64/minp8/sb128 sample-exact gates). | ||
| 128 | +- `cargo check -p ec-av1`: 0 warnings. | ||
| 129 | + | ||
| 130 | +## Hygiene | ||
| 131 | + | ||
| 132 | +- Target dir `$HOME/.cache/cargo-target-av1leaf8oob` throughout. | ||
| 133 | +- Throwaway instruments (`examples/oob_diff.rs`, `examples/oob_dump.rs`) | ||
| 134 | + deleted before commit; no other tree touched; nothing pushed. | ||