A skipped 8x8 intra leaf whose tx_depth split published its 8-px block side, not TX_4X4, to the next block's tx-size context
Browse files at this commit8a4713225ad83181a4dd61f661f3612e3302dda3Parent: c6f22ad- fix
- a skipped 8x8 intra leaf whose tx_depth split published its 8-px block side, not TX_4X4, to the next block's tx-size context
3 changed files +84 -1
- crates/ec-av1/examples/decode_probe.rs +4 -0
- crates/ec-av1/src/decode.rs +41 -1
- crates/ec-av1/src/stream.rs +39 -0
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
| @@ -33,6 +33,10 @@ fn main() { | |||
| 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 36 | + // lane-kf900 r1: the counter the skipped-8x8-split-transform gate | ||
| 37 | + // asserts -- printed here so a recipe sweep can see it fire without a | ||
| 38 | + // test-binary rebuild. | ||
| 39 | + println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits()); | ||
| 36 | let ir = ec_av1::stream::inter_rect_counters(); | 40 | let ir = ec_av1::stream::inter_rect_counters(); |
| 37 | println!( | 41 | println!( |
| 38 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 42 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+41 -1
| @@ -4140,6 +4140,9 @@ impl Neighbours { | |||
| 4140 | // TX_32X32 -- independent of this block's luma `tx_depth`. | 4140 | // TX_32X32 -- independent of this block's luma `tx_depth`. |
| 4141 | let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8; | 4141 | let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8; |
| 4142 | let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8; | 4142 | let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8; |
| 4143 | + if std::env::var_os("EC_TXGRID_TRACE").is_some() { | ||
| 4144 | + eprintln!("EC_LFGRID mi_row={mi_r} mi_col={mi_c} w_mi={w_mi} h_mi={h_mi} tx_px={tx_px} tx_h_px={tx_h_px}"); | ||
| 4145 | + } | ||
| 4143 | let cur = CURRENT_DELTA_LF.with(|c| c.get()); | 4146 | let cur = CURRENT_DELTA_LF.with(|c| c.get()); |
| 4144 | let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) { | 4147 | let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) { |
| 4145 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) | 4148 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) |
| @@ -5435,6 +5438,13 @@ fn read_intra_mode_rect( | |||
| 5435 | Option<PaletteUv>, | 5438 | Option<PaletteUv>, |
| 5436 | )> { | 5439 | )> { |
| 5437 | let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some(); | 5440 | let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some(); |
| 5441 | + if ec_istep { | ||
| 5442 | + // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | ||
| 5443 | + // (decodemv.c:818), printed at the same point: before the first | ||
| 5444 | + // mode-info symbol of the block, so a cross-decoder range ladder can | ||
| 5445 | + // be keyed on the BLOCK, not just on the symbol sequence. | ||
| 5446 | + eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=rect bw={bw} bh={bh} efi={} cls={:?} rng={}", enable_filter_intra as i32, filter_intra_size_class_rect(bw, bh), dec.debug_state().0); | ||
| 5447 | + } | ||
| 5438 | macro_rules! istep { | 5448 | macro_rules! istep { |
| 5439 | ($name:literal, $val:expr) => { | 5449 | ($name:literal, $val:expr) => { |
| 5440 | if ec_istep { | 5450 | if ec_istep { |
| @@ -5561,9 +5571,11 @@ fn read_intra_mode_rect( | |||
| 5561 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 5571 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 5562 | eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32); | 5572 | eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32); |
| 5563 | } | 5573 | } |
| 5574 | + istep!("use_filter_intra", use_filter_intra as i32); | ||
| 5564 | if use_filter_intra { | 5575 | if use_filter_intra { |
| 5565 | FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | 5576 | FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); |
| 5566 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 5577 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| 5578 | + istep!("filter_intra_mode", fi_mode as i32); | ||
| 5567 | filter_intra = Some(fi_mode); | 5579 | filter_intra = Some(fi_mode); |
| 5568 | } | 5580 | } |
| 5569 | } | 5581 | } |
| @@ -5606,6 +5618,14 @@ fn tx_size_context_rect( | |||
| 5606 | ) -> usize { | 5618 | ) -> usize { |
| 5607 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; | 5619 | let above = mi_r > n.tile_row0_mi && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= own_w; |
| 5608 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; | 5620 | let left = mi_c > n.tile_col0_mi && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= own_h; |
| 5621 | + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | ||
| 5622 | + eprintln!( | ||
| 5623 | + "EC_TXCTX mi_row={mi_r} mi_col={mi_c} w={own_w} h={own_h} above_px={} left_px={} ctx={}", | ||
| 5624 | + if mi_r > n.tile_row0_mi { tx_px_at(n, false, mi_r - 1, mi_c) } else { 0 }, | ||
| 5625 | + if mi_c > n.tile_col0_mi { tx_h_px_at(n, false, mi_r, mi_c - 1) } else { 0 }, | ||
| 5626 | + usize::from(above) + usize::from(left) | ||
| 5627 | + ); | ||
| 5628 | + } | ||
| 5609 | usize::from(above) + usize::from(left) | 5629 | usize::from(above) + usize::from(left) |
| 5610 | } | 5630 | } |
| 5611 | 5631 | ||
| @@ -8370,6 +8390,13 @@ fn read_intra_mode( | |||
| 8370 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for | 8390 | // under `EC_TRACE_MODE_STEP`) so a range ladder can be diffed line for |
| 8371 | // line against the instrumented aomdec, not just `tell()`. | 8391 | // line against the instrumented aomdec, not just `tell()`. |
| 8372 | let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some(); | 8392 | let ec_istep = std::env::var_os("EC_TRACE_MODE_STEP").is_some(); |
| 8393 | + if ec_istep { | ||
| 8394 | + // Mirrors the oracle's own `EC_IMODE mi_row=.. mi_col=.. rng=..` line | ||
| 8395 | + // (decodemv.c:818), printed at the same point: before the first | ||
| 8396 | + // mode-info symbol of the block, so a cross-decoder range ladder can | ||
| 8397 | + // be keyed on the BLOCK, not just on the symbol sequence. | ||
| 8398 | + eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sq side={side} rng={}", dec.debug_state().0); | ||
| 8399 | + } | ||
| 8373 | macro_rules! istep { | 8400 | macro_rules! istep { |
| 8374 | ($name:literal, $val:expr) => { | 8401 | ($name:literal, $val:expr) => { |
| 8375 | if ec_istep { | 8402 | if ec_istep { |
| @@ -10170,7 +10197,17 @@ fn decode_leaf8( | |||
| 10170 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10197 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10171 | } | 10198 | } |
| 10172 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 10199 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10173 | - neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); | 10200 | + // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 10201 | + // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && | ||
| 10202 | + // is_inter_block(mbmi), xd)` (decodemv.c) -- for an INTRA block that skip | ||
| 10203 | + // term is always 0, so a skipped 8x8 leaf whose `tx_depth` resolved to | ||
| 10204 | + // TX_4X4 still publishes 4 to the next block's `get_tx_size_context` | ||
| 10205 | + // (pred_common.h:342). Writing 8 here made the 8x16 strip below the leaf | ||
| 10206 | + // read `tx_size_cat1` row 2 where libaom reads row 1 -- same alphabet, | ||
| 10207 | + // wrong CDF row, so the msac range diverged mid-frame with no refusal | ||
| 10208 | + // (class `wrong-alphabet-same-value`; the ReelB key frame at | ||
| 10209 | + // -ss 900, first bad luma sample row 186 col 1803). | ||
| 10210 | + neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0); | ||
| 10174 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); | 10211 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); |
| 10175 | Ok(mode) | 10212 | Ok(mode) |
| 10176 | } | 10213 | } |
| @@ -10202,6 +10239,9 @@ fn read_intra_mode_sub8( | |||
| 10202 | mi_c: usize, | 10239 | mi_c: usize, |
| 10203 | ) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> { | 10240 | ) -> Result<(bool, usize, i32, Option<(usize, i32, Option<(i32, i32)>)>, Option<usize>)> { |
| 10204 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); | 10241 | let trace = std::env::var_os("EC_AV1_TRACE").is_some(); |
| 10242 | + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | ||
| 10243 | + eprintln!("EC_IMODE mi_row={mi_r} mi_col={mi_c} fn=sub8 rng={}", dec.debug_state().0); | ||
| 10244 | + } | ||
| 10205 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; | 10245 | let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0; |
| 10206 | if trace { | 10246 | if trace { |
| 10207 | eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0); | 10247 | eprintln!("TRACE sub8 skip mi=({mi_r},{mi_c}) ctx={skip_ctx} value={} rng={}", skip as i32, dec.debug_state().0); |
crates/ec-av1/src/stream.rsmodified+39 -0
| @@ -21515,6 +21515,45 @@ mod tests { | |||
| 21515 | } | 21515 | } |
| 21516 | } | 21516 | } |
| 21517 | 21517 | ||
| 21518 | + /// lane-kf900 r1: a SKIPPED 8x8 intra leaf whose `tx_depth` symbol | ||
| 21519 | + /// resolved to TX_4X4 must publish 4 -- not its 8-px block side -- to the | ||
| 21520 | + /// next block's `get_tx_size_context` (libaom `set_txfm_ctxs(mbmi->tx_size, | ||
| 21521 | + /// ..., skip_txfm && is_inter_block(mbmi), xd)`; that skip term is always 0 | ||
| 21522 | + /// for an intra block). `decode_leaf8`'s tail wrote the literal 8, so the | ||
| 21523 | + /// rect strip below such a leaf read `tx_size_cat1` row 2 where libaom | ||
| 21524 | + /// reads row 1 -- same alphabet, wrong CDF row, the msac range diverged | ||
| 21525 | + /// mid-frame with NO refusal. `skip_split_tx_hits` was `pub` and asserted | ||
| 21526 | + /// by no gate at all before this one (class `tool-disabled-in-every-gate`). | ||
| 21527 | + #[test] | ||
| 21528 | + fn a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact() { | ||
| 21529 | + const NAME: &str = | ||
| 21530 | + "a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact"; | ||
| 21531 | + crate::decode::reset_skip_split_tx_hits(); | ||
| 21532 | + run_multi_tile_gate(NAME, 0, 0, 8, 1, &[], false, None); | ||
| 21533 | + if have_ffmpeg() && have_aomenc() { | ||
| 21534 | + assert!( | ||
| 21535 | + crate::decode::skip_split_tx_hits() > 0, | ||
| 21536 | + "{NAME}: no skipped 8x8 intra leaf split its transform -- the gate proves nothing" | ||
| 21537 | + ); | ||
| 21538 | + } | ||
| 21539 | + } | ||
| 21540 | + | ||
| 21541 | + /// [`a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_decodes_pixel_exact`]'s | ||
| 21542 | + /// 10-bit arm -- the film that exposed the defect is yuv420p10le. | ||
| 21543 | + #[test] | ||
| 21544 | + fn a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_10bit_decodes_pixel_exact() | ||
| 21545 | + { | ||
| 21546 | + const NAME: &str = "a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_whose_tx_split_10bit_decodes_pixel_exact"; | ||
| 21547 | + crate::decode::reset_skip_split_tx_hits(); | ||
| 21548 | + run_multi_tile_gate(NAME, 0, 0, 10, 1, &[], false, None); | ||
| 21549 | + if have_ffmpeg() && have_aomenc() { | ||
| 21550 | + assert!( | ||
| 21551 | + crate::decode::skip_split_tx_hits() > 0, | ||
| 21552 | + "{NAME}: no skipped 8x8 intra leaf split its transform -- the gate proves nothing" | ||
| 21553 | + ); | ||
| 21554 | + } | ||
| 21555 | + } | ||
| 21556 | + | ||
| 21518 | #[test] | 21557 | #[test] |
| 21519 | fn a_real_aomenc_multi_tile_intra_10bit_stream_decodes_pixel_exact() { | 21558 | fn a_real_aomenc_multi_tile_intra_10bit_stream_decodes_pixel_exact() { |
| 21520 | run_multi_tile_gate( | 21559 | run_multi_tile_gate( |