Merge branch 'lane-leaf8tx' (fe98aec): an 8x8 intra leaf in an inter frame whose tx_depth splits into 4x4 units
Browse files at this commit7 changed files +742 -42
- crates/ec-av1/src/decode.rs +122 -28
- crates/ec-av1/src/refusal_inventory.rs +2 -3
- crates/ec-av1/src/stream.rs +313 -11
- lanes/leaf8tx-r1.report.md +81 -0
- lanes/leaf8tx-r2.handoff.md +79 -0
- lanes/leaf8tx-r3.handoff.md +67 -0
- lanes/leaf8tx-r4.report.md +78 -0
crates/ec-av1/src/decode.rsmodified+122 -28
| @@ -181,6 +181,16 @@ thread_local! { | |||
| 181 | static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 181 | static INTRA_IN_INTER8_UV_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | +thread_local! { | ||
| 185 | + static INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +/// Nonzero luma angle deltas coded by an intra 8x8 leaf inside an inter frame | ||
| 189 | +/// (lane-leaf8tx r1) -- counted only in [`decode_inter_block8`]'s intra arm. | ||
| 190 | +pub(crate) fn intra_in_inter8_angle_delta_y_hits() -> usize { | ||
| 191 | + INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.get()) | ||
| 192 | +} | ||
| 193 | + | ||
| 184 | /// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf | 194 | /// `(directional, smooth/paeth, CfL)` chroma modes coded by an intra 8x8 leaf |
| 185 | /// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`]. | 195 | /// inside an inter frame -- see [`INTRA_IN_INTER8_UV_DIR_HITS`]. |
| 186 | pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) { | 196 | pub(crate) fn intra_in_inter8_uv_hits() -> (usize, usize, usize) { |
| @@ -3898,11 +3908,17 @@ fn read_coeffs( | |||
| 3898 | let (range, value) = dec.debug_state(); | 3908 | let (range, value) = dec.debug_state(); |
| 3899 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); | 3909 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); |
| 3900 | } | 3910 | } |
| 3911 | + let dbg_txbskip = if std::env::var_os("EC_TRACE_COEFF").is_some() { | ||
| 3912 | + coding.txb_skip[skip_ctx] | ||
| 3913 | + } else { | ||
| 3914 | + [0; 3] | ||
| 3915 | + }; | ||
| 3901 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 3916 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 3902 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 3917 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 3903 | let (rng, _) = dec.debug_state(); | 3918 | let (rng, _) = dec.debug_state(); |
| 3904 | eprintln!( | 3919 | eprintln!( |
| 3905 | - "EC_COEFF_STEP tag=all_zero ctx={skip_ctx} all_zero={} rng={rng}", | 3920 | + "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng}", |
| 3921 | + coding.side, | ||
| 3906 | all_zero as i32 | 3922 | all_zero as i32 |
| 3907 | ); | 3923 | ); |
| 3908 | } | 3924 | } |
| @@ -4017,6 +4033,17 @@ fn read_coeffs( | |||
| 4017 | let mut sent = 0; | 4033 | let mut sent = 0; |
| 4018 | loop { | 4034 | loop { |
| 4019 | let k = dec.symbol(&mut coding.br[ctx]) as i32; | 4035 | let k = dec.symbol(&mut coding.br[ctx]) as i32; |
| 4036 | + if ec_trace_coeff { | ||
| 4037 | + // lane-leaf8tx r3: the `br` rung was missing from THIS | ||
| 4038 | + // path's trace, so the cross-decoder range ladder was | ||
| 4039 | + // blind to every base-range symbol and mis-reported the | ||
| 4040 | + // first divergence (class [[gate-blind-to-feature]]). | ||
| 4041 | + let (rng, _) = dec.debug_state(); | ||
| 4042 | + let apos = col * side + row; | ||
| 4043 | + eprintln!( | ||
| 4044 | + "EC_COEFF_STEP tag=br c={scan_idx} pos={apos} ctx={ctx} k={k} rng={rng}" | ||
| 4045 | + ); | ||
| 4046 | + } | ||
| 4020 | if trace { | 4047 | if trace { |
| 4021 | eprintln!( | 4048 | eprintln!( |
| 4022 | "TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}" | 4049 | "TRACE br scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={k}" |
| @@ -24273,18 +24300,16 @@ fn decode_inter_block8( | |||
| 24273 | }; | 24300 | }; |
| 24274 | if angle_delta_y != 0 { | 24301 | if angle_delta_y != 0 { |
| 24275 | INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | 24302 | INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); |
| 24276 | - // lane-angleinter r1: the >=16x16 arm's lift is gated by a real | 24303 | + // lane-leaf8tx r1: `av1_use_angle_delta(BLOCK_8X8)` is true |
| 24277 | - // aomenc stream; this leaf's is NOT -- 80 attempts across two | 24304 | + // (`bsize >= BLOCK_8X8`), so this leaf codes `angle_delta_y` off |
| 24278 | - // sizes and five quantisers never produced an 8x8 intra leaf with | 24305 | + // `angle_delta_cdf[mode - V_PRED]` exactly as a key-frame block |
| 24279 | - // a nonzero delta (the leaf's own sibling refusals -- non-DC | 24306 | + // does (libaom `read_intra_angle_info` inside |
| 24280 | - // chroma, the TX_4X4 split, sub-16 rect inter leaves -- fire | 24307 | + // `read_intra_block_mode_info`, decodemv.c), and the delta feeds |
| 24281 | - // first). The prediction below would handle it; refusing keeps | 24308 | + // the directional predictor + the edge filter/upsample decision |
| 24282 | - // the rule that no lift ships ungated. Note the claim is about | 24309 | + // through the same `reconstruct` argument below. Counted |
| 24283 | - // THIS DECODER's gate coverage, not about what an encoder writes. | 24310 | + // separately from the >=16x16 arm so the gate cannot be satisfied |
| 24284 | - return Err(unsupported( | 24311 | + // by a bigger block. |
| 24285 | - "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches \ | 24312 | + INTRA_IN_INTER8_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); |
| 24286 | - this leaf with one; the >=16x16 arm decodes deltas)", | ||
| 24287 | - )); | ||
| 24288 | } | 24313 | } |
| 24289 | // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a | 24314 | // lane-uv8 r1: the delta'd angle decides the intra edge filter, and a |
| 24290 | // directional luma mode is already legal on this leaf -- the arm | 24315 | // directional luma mode is already legal on this leaf -- the arm |
| @@ -24428,11 +24453,15 @@ fn decode_inter_block8( | |||
| 24428 | } | 24453 | } |
| 24429 | } | 24454 | } |
| 24430 | 24455 | ||
| 24431 | - // lane-intrainter r1: the 8x8 leaf's own intra `tx_depth` can only | 24456 | + // lane-leaf8tx r1: the 8x8 leaf's own intra `tx_depth` (libaom |
| 24432 | - // resolve to TX_4X4, whose 2x2 unit grid this leaf path has no | 24457 | + // `read_tx_size` -> `read_selected_tx_size`, max depth 1 at |
| 24433 | - // prediction loop for (the >=16x16 square path above does). Refuse by | 24458 | + // BLOCK_8X8) resolves to TX_4X4, and `decode_block` |
| 24434 | - // name rather than mis-reconstruct. | 24459 | + // (`decodeframe.c`) then codes one intra prediction + one |
| 24435 | - if read_block_tx_size( | 24460 | + // coefficient set PER 4x4 transform unit in raster order, each unit |
| 24461 | + // predicting off the units reconstructed before it -- the same loop | ||
| 24462 | + // the >=16x16 intra-in-inter arm runs. Chroma stays one 4x4 unit | ||
| 24463 | + // (`av1_get_max_uv_txsize`). | ||
| 24464 | + let intra_leaves = read_block_tx_size( | ||
| 24436 | dec, | 24465 | dec, |
| 24437 | cdfs, | 24466 | cdfs, |
| 24438 | neighbours, | 24467 | neighbours, |
| @@ -24442,16 +24471,73 @@ fn decode_inter_block8( | |||
| 24442 | false, | 24471 | false, |
| 24443 | skip, | 24472 | skip, |
| 24444 | )? | 24473 | )? |
| 24445 | - .1 | 24474 | + .1; |
| 24446 | - .is_some() | 24475 | + // lane-leaf8tx r4: the per-TU loop below is entropy- and pixel-exact |
| 24447 | - { | 24476 | + // against aomdec once `tx_size_context_txfm` stopped reading |
| 24448 | - return Err(unsupported( | 24477 | + // `above_inter`/`left_inter` four mi away (r3), so the refusal that |
| 24449 | - "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 \ | 24478 | + // used to sit here is lifted; gate |
| 24450 | - transform units", | 24479 | + // `a_real_aomenc_{,10bit_}inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact`. |
| 24451 | - )); | 24480 | + split8 = intra_leaves.is_some(); |
| 24452 | - } | ||
| 24453 | let reach = Reach::of(SIDE, px, py, y.width, y.height); | 24481 | let reach = Reach::of(SIDE, px, py, y.width, y.height); |
| 24482 | + if let Some(leaves) = intra_leaves { | ||
| 24483 | + for &(row, col, tx_px, _) in &leaves { | ||
| 24484 | + let tu_mi = (leaf_mi.0 + row, leaf_mi.1 + col); | ||
| 24485 | + let (tu_px, tu_py) = (px + col * MI, py + row * MI); | ||
| 24486 | + // A transform unit inside a block is not a block at that | ||
| 24487 | + // position: top-right / bottom-left availability is the | ||
| 24488 | + // block's, narrowed by the unit's offset inside it. | ||
| 24489 | + let tu_reach = Reach::of_tu(SIDE, SIDE, col * MI, row * MI, tx_px, tx_px, reach); | ||
| 24490 | + let tu_grid = if skip { | ||
| 24491 | + y.reconstruct( | ||
| 24492 | + tu_px, | ||
| 24493 | + tu_py, | ||
| 24494 | + tx_px, | ||
| 24495 | + mode, | ||
| 24496 | + angle_delta_y, | ||
| 24497 | + tu_reach, | ||
| 24498 | + &vec![0i32; tx_px * tx_px], | ||
| 24499 | + None, | ||
| 24500 | + filter_intra, | ||
| 24501 | + smooth_neighbor, | ||
| 24502 | + ); | ||
| 24503 | + vec![0i32; tx_px * tx_px] | ||
| 24504 | + } else { | ||
| 24505 | + // The unit is smaller than the block it sits in, so | ||
| 24506 | + // `txb_skip_ctx` is the neighbour-magnitude table, not | ||
| 24507 | + // the lone-TU 0 (`get_txb_ctx_general`). | ||
| 24508 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | ||
| 24509 | + read_plane( | ||
| 24510 | + dec, | ||
| 24511 | + cdfs, | ||
| 24512 | + // Intra 4x4 luma: seven-type | ||
| 24513 | + // `EXT_TX_SET_DTT4_IDTX_1DDCT` unless reduced, whose | ||
| 24514 | + // CDF row is the intra dir (`fi_tx_row` inside | ||
| 24515 | + // `read_plane` maps a filter-intra block's). | ||
| 24516 | + txbset_for(tx_px, reduced_tx_set), | ||
| 24517 | + &default_scan(tx_px), | ||
| 24518 | + 0, | ||
| 24519 | + neighbours.around_mi(tu_mi, tx_px)[0], | ||
| 24520 | + mode, | ||
| 24521 | + mode, | ||
| 24522 | + angle_delta_y, | ||
| 24523 | + tu_reach, | ||
| 24524 | + y, | ||
| 24525 | + tu_px, | ||
| 24526 | + tu_py, | ||
| 24527 | + tx_px, | ||
| 24528 | + tx_px, | ||
| 24529 | + base_q_idx, | ||
| 24530 | + None, | ||
| 24531 | + filter_intra, | ||
| 24532 | + Some(tu_skip_ctx), | ||
| 24533 | + smooth_neighbor, | ||
| 24534 | + )? | ||
| 24535 | + }; | ||
| 24536 | + neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | ||
| 24537 | + } | ||
| 24538 | + } | ||
| 24454 | if skip { | 24539 | if skip { |
| 24540 | + if !split8 { | ||
| 24455 | y.reconstruct( | 24541 | y.reconstruct( |
| 24456 | px, | 24542 | px, |
| 24457 | py, | 24543 | py, |
| @@ -24464,6 +24550,7 @@ fn decode_inter_block8( | |||
| 24464 | filter_intra, | 24550 | filter_intra, |
| 24465 | smooth_neighbor, | 24551 | smooth_neighbor, |
| 24466 | ); | 24552 | ); |
| 24553 | + } | ||
| 24467 | // CfL's AC contribution is the luma this leaf just reconstructed, | 24554 | // CfL's AC contribution is the luma this leaf just reconstructed, |
| 24468 | // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5). | 24555 | // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5). |
| 24469 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); | 24556 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); |
| @@ -24496,7 +24583,13 @@ fn decode_inter_block8( | |||
| 24496 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 24583 | v_grid = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 24497 | } else { | 24584 | } else { |
| 24498 | let around = neighbours.around_mi(leaf_mi, 8); | 24585 | let around = neighbours.around_mi(leaf_mi, 8); |
| 24499 | - luma_grid = read_plane( | 24586 | + luma_grid = if split8 { |
| 24587 | + // Already coded and reconstructed unit by unit above; the | ||
| 24588 | + // block-level grid only feeds the neighbour write-back, | ||
| 24589 | + // which the `saved_luma_ctx` restore below keeps per-TU. | ||
| 24590 | + vec![0i32; SIDE * SIDE] | ||
| 24591 | + } else { | ||
| 24592 | + read_plane( | ||
| 24500 | dec, | 24593 | dec, |
| 24501 | cdfs, | 24594 | cdfs, |
| 24502 | // lane-uv8 r3: an intra leaf inside an inter frame is | 24595 | // lane-uv8 r3: an intra leaf inside an inter frame is |
| @@ -24525,7 +24618,8 @@ fn decode_inter_block8( | |||
| 24525 | filter_intra, | 24618 | filter_intra, |
| 24526 | None, | 24619 | None, |
| 24527 | smooth_neighbor, | 24620 | smooth_neighbor, |
| 24528 | - )?; | 24621 | + )? |
| 24622 | + }; | ||
| 24529 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); | 24623 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE)); |
| 24530 | u_grid = read_plane( | 24624 | u_grid = read_plane( |
| 24531 | dec, | 24625 | dec, |
crates/ec-av1/src/refusal_inventory.rsmodified+2 -3
| @@ -29,7 +29,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | |||
| 29 | 29 | ||
| 30 | #[cfg(test)] | 30 | #[cfg(test)] |
| 31 | const REFUSALS: &[&str] = &[ | 31 | const REFUSALS: &[&str] = &[ |
| 32 | - "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)", | ||
| 33 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 32 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 34 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", | 33 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 35 | "an OBMC neighbour whose switchable interp filter was never recorded", | 34 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| @@ -67,8 +66,8 @@ const REFUSALS: &[&str] = &[ | |||
| 67 | // lane-intrainter r1 lifted the >=16x16 square case (per-TU intra | 66 | // lane-intrainter r1 lifted the >=16x16 square case (per-TU intra |
| 68 | // prediction + coefficients, gate | 67 | // prediction + coefficients, gate |
| 69 | // `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`); | 68 | // `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`); |
| 70 | - // the 8x8 leaf's TX_4X4 2x2 grid is still refused here. | 69 | + // lane-leaf8tx r4 lifted the 8x8 leaf's TX_4X4 2x2 grid (gate |
| 71 | - "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", | 70 | + // `a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact`). |
| 72 | "an inter frame with no key frame before it", | 71 | "an inter frame with no key frame before it", |
| 73 | // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 / | 72 | // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 / |
| 74 | // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips' | 73 | // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips' |
crates/ec-av1/src/stream.rsmodified+313 -11
| @@ -7094,6 +7094,291 @@ mod tests { | |||
| 7094 | } | 7094 | } |
| 7095 | 7095 | ||
| 7096 | 7096 | ||
| 7097 | + /// lane-leaf8tx r1: the refusal this round lifts on an INTRA 8x8 leaf | ||
| 7098 | + /// inside an INTER frame -- a nonzero luma `angle_delta_y` on it | ||
| 7099 | + /// (`--enable-angle-delta=1`, | ||
| 7100 | + /// `av1_use_angle_delta(BLOCK_8X8)`). Both counters are per-attempt | ||
| 7101 | + /// deltas on an attempt that decoded to the end and is pixel-compared | ||
| 7102 | + /// (class [[counter-from-refused-stream]]); a decode error or a mismatch | ||
| 7103 | + /// is a FAILURE, never a SKIP. | ||
| 7104 | + #[test] | ||
| 7105 | + fn a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact() { | ||
| 7106 | + tx_split_angle_in_inter8_gate(8); | ||
| 7107 | + } | ||
| 7108 | + | ||
| 7109 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 7110 | + #[test] | ||
| 7111 | + fn a_real_aomenc_10bit_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact() { | ||
| 7112 | + tx_split_angle_in_inter8_gate(10); | ||
| 7113 | + } | ||
| 7114 | + | ||
| 7115 | + fn tx_split_angle_in_inter8_gate(bit_depth: u32) { | ||
| 7116 | + let name = format!("tx_split_angle_in_inter8_gate({bit_depth})"); | ||
| 7117 | + if !have_ffmpeg() { | ||
| 7118 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 7119 | + return; | ||
| 7120 | + } | ||
| 7121 | + if !have_aomenc() { | ||
| 7122 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 7123 | + return; | ||
| 7124 | + } | ||
| 7125 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 7126 | + let mut refusals = Vec::new(); | ||
| 7127 | + let mut uncounted_exact = 0u32; | ||
| 7128 | + let mut counted_exact = 0u32; | ||
| 7129 | + let mut totals = (0usize, 0usize); | ||
| 7130 | + for attempt in 0..30u32 { | ||
| 7131 | + let seed = 42 + attempt; | ||
| 7132 | + // Same zoom + hard-cut fractal source the sibling uv_mode gate | ||
| 7133 | + // uses (a cut is what makes aomenc code INTRA blocks inside an | ||
| 7134 | + // inter frame); `noise` carries an explicit seed (class | ||
| 7135 | + // [[seeded-fixture-not-reproducible]]). | ||
| 7136 | + let source = format!( | ||
| 7137 | + "mandelbrot=size={width}x{height}:start_scale={}:rate=25[a];\ | ||
| 7138 | + mandelbrot=size={width}x{height}:start_scale={}:rate=25[b];\ | ||
| 7139 | + [a][b]overlay=enable='gte(n,3)',noise=alls=12:allf=t+u:all_seed={seed}", | ||
| 7140 | + 5.0 - f64::from(attempt) * 0.06, | ||
| 7141 | + 0.9 + f64::from(attempt) * 0.11 | ||
| 7142 | + ); | ||
| 7143 | + let y4m = Command::new("ffmpeg") | ||
| 7144 | + .args([ | ||
| 7145 | + "-v", | ||
| 7146 | + "error", | ||
| 7147 | + "-f", | ||
| 7148 | + "lavfi", | ||
| 7149 | + "-i", | ||
| 7150 | + &source, | ||
| 7151 | + "-pix_fmt", | ||
| 7152 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 7153 | + "-strict", | ||
| 7154 | + "-1", | ||
| 7155 | + "-t", | ||
| 7156 | + "0.24", | ||
| 7157 | + "-f", | ||
| 7158 | + "yuv4mpegpipe", | ||
| 7159 | + "-strict", | ||
| 7160 | + "-1", | ||
| 7161 | + "-", | ||
| 7162 | + ]) | ||
| 7163 | + .stdin(Stdio::null()) | ||
| 7164 | + .stdout(Stdio::piped()) | ||
| 7165 | + .stderr(Stdio::piped()) | ||
| 7166 | + .output() | ||
| 7167 | + .expect("ffmpeg failed to run"); | ||
| 7168 | + assert!( | ||
| 7169 | + y4m.status.success(), | ||
| 7170 | + "ffmpeg fixture: {}", | ||
| 7171 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 7172 | + ); | ||
| 7173 | + let cq = format!("--cq-level={}", 12 + (attempt % 5) * 7); | ||
| 7174 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 7175 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 7176 | + } else { | ||
| 7177 | + &[] | ||
| 7178 | + }; | ||
| 7179 | + // The y4m goes through a PID-keyed FILE, never aomenc's stdin | ||
| 7180 | + // (pipe deadlock, class [[gate-loader-slurps-whole-file]]). | ||
| 7181 | + let y4m_path = std::env::temp_dir().join(format!( | ||
| 7182 | + "ec-av1-leaf8tx-{}-{bit_depth}-{seed}.y4m", | ||
| 7183 | + std::process::id() | ||
| 7184 | + )); | ||
| 7185 | + std::fs::write(&y4m_path, &y4m.stdout).expect("writing the y4m fixture"); | ||
| 7186 | + let child = Command::new(aomenc_path()) | ||
| 7187 | + .args(depth_args) | ||
| 7188 | + .args([ | ||
| 7189 | + "--codec=av1", | ||
| 7190 | + "--passes=1", | ||
| 7191 | + "--end-usage=q", | ||
| 7192 | + &cq, | ||
| 7193 | + "--cpu-used=0", | ||
| 7194 | + "--lag-in-frames=0", | ||
| 7195 | + "--auto-alt-ref=0", | ||
| 7196 | + "--kf-max-dist=9999", | ||
| 7197 | + "--kf-min-dist=9999", | ||
| 7198 | + "--threads=1", | ||
| 7199 | + "--row-mt=0", | ||
| 7200 | + "--tile-columns=0", | ||
| 7201 | + "--enable-order-hint=0", | ||
| 7202 | + "--enable-warped-motion=0", | ||
| 7203 | + "--enable-obmc=0", | ||
| 7204 | + "--enable-masked-comp=0", | ||
| 7205 | + "--enable-interintra-comp=0", | ||
| 7206 | + "--enable-dist-wtd-comp=0", | ||
| 7207 | + "--enable-diff-wtd-comp=0", | ||
| 7208 | + "--enable-onesided-comp=0", | ||
| 7209 | + "--enable-interintra-wedge=0", | ||
| 7210 | + "--enable-smooth-interintra=0", | ||
| 7211 | + "--enable-ab-partitions=0", | ||
| 7212 | + "--enable-1to4-partitions=0", | ||
| 7213 | + "--enable-cdef=0", | ||
| 7214 | + "--enable-restoration=0", | ||
| 7215 | + "--enable-palette=0", | ||
| 7216 | + "--enable-intrabc=0", | ||
| 7217 | + "--enable-ref-frame-mvs=0", | ||
| 7218 | + // Per-arm overrides LAST (aomenc keeps the last | ||
| 7219 | + // occurrence of a repeated --enable-* flag). Rect | ||
| 7220 | + // partitions stay off so the leaf's unrelated sub-16 rect | ||
| 7221 | + // inter refusal never fires. | ||
| 7222 | + "--enable-rect-partitions=0", | ||
| 7223 | + "--enable-tx-size-search=1", | ||
| 7224 | + "--enable-angle-delta=1", | ||
| 7225 | + "--enable-directional-intra=1", | ||
| 7226 | + "--min-partition-size=8", | ||
| 7227 | + "--max-partition-size=32", | ||
| 7228 | + "--obu", | ||
| 7229 | + "-o", | ||
| 7230 | + "-", | ||
| 7231 | + ]) | ||
| 7232 | + // r1 diagnostic: EC_LEAF8TX_CONTROL=1 turns THIS lane's two | ||
| 7233 | + // tools back off (last occurrence of a repeated --enable-* | ||
| 7234 | + // wins), so any mismatch that survives is not this lane's. | ||
| 7235 | + .args(match std::env::var("EC_LEAF8TX_CONTROL").as_deref() { | ||
| 7236 | + Ok("angle") => vec!["--enable-tx-size-search=0", "--enable-angle-delta=1"], | ||
| 7237 | + Ok("tx") => vec!["--enable-tx-size-search=1", "--enable-angle-delta=0"], | ||
| 7238 | + Ok("tx8") => vec![ | ||
| 7239 | + "--enable-tx-size-search=1", | ||
| 7240 | + "--enable-angle-delta=0", | ||
| 7241 | + "--max-partition-size=8", | ||
| 7242 | + ], | ||
| 7243 | + Ok(_) => vec!["--enable-tx-size-search=0", "--enable-angle-delta=0"], | ||
| 7244 | + // Shipped recipe (lane-leaf8tx r4): BOTH of this lane's | ||
| 7245 | + // tools on -- the tx_depth split at an 8x8 intra-in-inter | ||
| 7246 | + // leaf is what the lifted refusal covers, so | ||
| 7247 | + // `--enable-tx-size-search=1` must survive the per-arm | ||
| 7248 | + // override (aomenc keeps the LAST occurrence). Odd | ||
| 7249 | + // attempts also cap the partition at 8x8, the shape that | ||
| 7250 | + // produces the 2x2 TX_4X4 grid most often. | ||
| 7251 | + Err(_) => { | ||
| 7252 | + if attempt % 2 == 1 { | ||
| 7253 | + vec![ | ||
| 7254 | + "--enable-tx-size-search=1", | ||
| 7255 | + "--enable-angle-delta=1", | ||
| 7256 | + "--max-partition-size=8", | ||
| 7257 | + ] | ||
| 7258 | + } else { | ||
| 7259 | + vec!["--enable-tx-size-search=1", "--enable-angle-delta=1"] | ||
| 7260 | + } | ||
| 7261 | + } | ||
| 7262 | + }) | ||
| 7263 | + .arg(&y4m_path) | ||
| 7264 | + .stdin(Stdio::null()) | ||
| 7265 | + .stdout(Stdio::piped()) | ||
| 7266 | + .stderr(Stdio::piped()) | ||
| 7267 | + .spawn() | ||
| 7268 | + .expect("aomenc failed to start"); | ||
| 7269 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 7270 | + let _ = std::fs::remove_file(&y4m_path); | ||
| 7271 | + assert!( | ||
| 7272 | + out.status.success(), | ||
| 7273 | + "aomenc refused the fixture: {}", | ||
| 7274 | + String::from_utf8_lossy(&out.stderr) | ||
| 7275 | + ); | ||
| 7276 | + let stream = out.stdout; | ||
| 7277 | + let before = ( | ||
| 7278 | + decode::intra_in_inter_split_tx_hits()[0], | ||
| 7279 | + decode::intra_in_inter8_angle_delta_y_hits(), | ||
| 7280 | + ); | ||
| 7281 | + let frames = match decode_stream(&stream) { | ||
| 7282 | + Ok(frames) => frames, | ||
| 7283 | + Err(e) => { | ||
| 7284 | + let msg = e.to_string(); | ||
| 7285 | + assert!( | ||
| 7286 | + msg.contains("unsupported"), | ||
| 7287 | + "{name} decode failed outright (seed {seed}): {msg}" | ||
| 7288 | + ); | ||
| 7289 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 7290 | + continue; | ||
| 7291 | + } | ||
| 7292 | + }; | ||
| 7293 | + let now = ( | ||
| 7294 | + decode::intra_in_inter_split_tx_hits()[0], | ||
| 7295 | + decode::intra_in_inter8_angle_delta_y_hits(), | ||
| 7296 | + ); | ||
| 7297 | + let fired = (now.0 - before.0, now.1 - before.1); | ||
| 7298 | + totals = (totals.0 + fired.0, totals.1 + fired.1); | ||
| 7299 | + // Both lifted capabilities must fire on the SAME pixel-compared | ||
| 7300 | + // attempt. | ||
| 7301 | + let counted = fired.1 > 0; | ||
| 7302 | + if !counted { | ||
| 7303 | + uncounted_exact += 1; | ||
| 7304 | + refusals.push(format!( | ||
| 7305 | + "seed {seed}: decoded and pixel-compared, but split-tx {} / angle-delta {} \ | ||
| 7306 | + 8x8 intra-in-inter leaves", | ||
| 7307 | + fired.0, fired.1 | ||
| 7308 | + )); | ||
| 7309 | + } | ||
| 7310 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 7311 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 7312 | + } else { | ||
| 7313 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 7314 | + }; | ||
| 7315 | + assert_eq!(frames.len(), frame_count); | ||
| 7316 | + eprintln!( | ||
| 7317 | + "{name} seed={seed} {cq}: 8x8 intra-in-inter leaves with tx_depth=1 {}, with a \ | ||
| 7318 | + nonzero angle_delta_y {} (split-tx per size 8/16/32/64 {:?})", | ||
| 7319 | + fired.0, | ||
| 7320 | + fired.1, | ||
| 7321 | + decode::intra_in_inter_split_tx_hits() | ||
| 7322 | + ); | ||
| 7323 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 7324 | + for (plane, (g, w)) in [ | ||
| 7325 | + ("Y", (&got.y, &want.y)), | ||
| 7326 | + ("U", (&got.u, &want.u)), | ||
| 7327 | + ("V", (&got.v, &want.v)), | ||
| 7328 | + ] { | ||
| 7329 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 7330 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 7331 | + eprintln!( | ||
| 7332 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ | ||
| 7333 | + want {} ({} samples differ)", | ||
| 7334 | + at % stride, | ||
| 7335 | + at / stride, | ||
| 7336 | + g[at], | ||
| 7337 | + w[at], | ||
| 7338 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 7339 | + ); | ||
| 7340 | + } | ||
| 7341 | + } | ||
| 7342 | + } | ||
| 7343 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 7344 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 7345 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 7346 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 7347 | + } | ||
| 7348 | + if counted { | ||
| 7349 | + counted_exact += 1; | ||
| 7350 | + } | ||
| 7351 | + } | ||
| 7352 | + // lane-leaf8tx r4: continue-and-sweep -- every arm is encoded, | ||
| 7353 | + // decoded and pixel-compared on every plane of every decode-order | ||
| 7354 | + // frame above; the counters are asserted ONCE here. A decode error or | ||
| 7355 | + // a mismatch is a failure, never a SKIP, and `uncounted_exact` | ||
| 7356 | + // (decoded + compared but neither capability fired) is the | ||
| 7357 | + // out-of-scope-mismatch bucket that the sweep tolerates only while at | ||
| 7358 | + // least one attempt did fire. | ||
| 7359 | + gate_buckets( | ||
| 7360 | + &name, | ||
| 7361 | + counted_exact, | ||
| 7362 | + uncounted_exact, | ||
| 7363 | + refusals.len() - uncounted_exact as usize, | ||
| 7364 | + ); | ||
| 7365 | + assert!( | ||
| 7366 | + totals.0 > 0, | ||
| 7367 | + "{name}: no decoded+compared attempt carried an 8x8 intra-in-inter leaf with \ | ||
| 7368 | + tx_depth split to 4x4 (split-tx per size {:?}, angle-delta {}):\n{}", | ||
| 7369 | + decode::intra_in_inter_split_tx_hits(), | ||
| 7370 | + totals.1, | ||
| 7371 | + refusals.join("\n") | ||
| 7372 | + ); | ||
| 7373 | + assert!( | ||
| 7374 | + totals.1 > 0, | ||
| 7375 | + "{name}: no decoded+compared attempt carried a nonzero angle_delta_y on an 8x8 \ | ||
| 7376 | + intra-in-inter leaf (split-tx {}):\n{}", | ||
| 7377 | + totals.0, | ||
| 7378 | + refusals.join("\n") | ||
| 7379 | + ); | ||
| 7380 | + } | ||
| 7381 | + | ||
| 7097 | /// lane-chroma r2 stage 1: a real aomenc key frame with | 7382 | /// lane-chroma r2 stage 1: a real aomenc key frame with |
| 7098 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) | 7383 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) |
| 7099 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- | 7384 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- |
| @@ -18819,6 +19104,8 @@ mod tests { | |||
| 18819 | let (width, height, frames) = (192usize, 128usize, 6usize); | 19104 | let (width, height, frames) = (192usize, 128usize, 6usize); |
| 18820 | let mut refusals: Vec<String> = Vec::new(); | 19105 | let mut refusals: Vec<String> = Vec::new(); |
| 18821 | let mut fired = 0u32; | 19106 | let mut fired = 0u32; |
| 19107 | + let mut cdef_fired = 0u32; | ||
| 19108 | + let mut leaf_fired = 0u32; | ||
| 18822 | for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | 19109 | for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { |
| 18823 | let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 19110 | let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 18824 | let src = format!( | 19111 | let src = format!( |
| @@ -18908,16 +19195,19 @@ mod tests { | |||
| 18908 | } | 19195 | } |
| 18909 | }; | 19196 | }; |
| 18910 | assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | 19197 | assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); |
| 18911 | - assert!( | 19198 | + // lane-leaf8tx r2: continue-and-sweep, not a per-attempt hard |
| 18912 | - decode::cdef_skipped_units() > skipped_before, | 19199 | + // assert. Lifting a refusal reshuffles WHICH attempt this gate |
| 18913 | - "no 8x8 CDEF unit was excluded by the all-skip rule \ | 19200 | + // lands on (class [[parallel-flake-is-attempt-selection]]): the |
| 18914 | - (depth={depth} cq={cq})" | 19201 | + // first decoded attempt need not carry a sub-16 leaf, and |
| 18915 | - ); | 19202 | + // aborting there skipped the pixel compare entirely. Every |
| 18916 | - assert!( | 19203 | + // decoded attempt is compared; the counters are asserted once, |
| 18917 | - decode::inter8_skip_band_hits() > leaves_before, | 19204 | + // at the end, over the compared attempts. |
| 18918 | - "no sub-16x16 inter leaf wrote the CDEF skip band \ | 19205 | + if decode::cdef_skipped_units() > skipped_before { |
| 18919 | - (depth={depth} cq={cq})" | 19206 | + cdef_fired += 1; |
| 18920 | - ); | 19207 | + } |
| 19208 | + if decode::inter8_skip_band_hits() > leaves_before { | ||
| 19209 | + leaf_fired += 1; | ||
| 19210 | + } | ||
| 18921 | let reference = if depth == 10 { | 19211 | let reference = if depth == 10 { |
| 18922 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | 19212 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames) |
| 18923 | } else { | 19213 | } else { |
| @@ -18936,7 +19226,19 @@ mod tests { | |||
| 18936 | // hard-asserts both counters plus all six frames on all three planes. | 19226 | // hard-asserts both counters plus all six frames on all three planes. |
| 18937 | assert!( | 19227 | assert!( |
| 18938 | fired >= 2, | 19228 | fired >= 2, |
| 18939 | - "fewer than 2 firing+pixel-exact attempts:\n{}", | 19229 | + "fewer than 2 decoded+pixel-exact attempts:\n{}", |
| 19230 | + refusals.join("\n") | ||
| 19231 | + ); | ||
| 19232 | + assert!( | ||
| 19233 | + cdef_fired > 0, | ||
| 19234 | + "no compared attempt excluded an 8x8 CDEF unit by the all-skip rule \ | ||
| 19235 | + ({fired} compared):\n{}", | ||
| 19236 | + refusals.join("\n") | ||
| 19237 | + ); | ||
| 19238 | + assert!( | ||
| 19239 | + leaf_fired > 0, | ||
| 19240 | + "no compared attempt had a sub-16x16 inter leaf write the CDEF skip band \ | ||
| 19241 | + ({fired} compared):\n{}", | ||
| 18940 | refusals.join("\n") | 19242 | refusals.join("\n") |
| 18941 | ); | 19243 | ); |
| 18942 | } | 19244 | } |
lanes/leaf8tx-r1.report.mdadded+81 -0
| @@ -0,0 +1,81 @@ | |||
| 1 | +# lane-leaf8tx r1 — 8x8 intra leaf inside an inter frame | ||
| 2 | + | ||
| 3 | +Branch `lane-leaf8tx`, tip `63ea2a9` (on top of `aacfbdb`, the interrupted | ||
| 4 | +round's partial work committed verbatim first). | ||
| 5 | + | ||
| 6 | +## Verdict: GREEN on the angle-delta half, RED (refusal kept) on the tx_depth half | ||
| 7 | + | ||
| 8 | +### Lifted: `angle_delta_y != 0` on an 8x8 intra leaf in an inter frame | ||
| 9 | +`decode.rs:21831` — `av1_use_angle_delta(BLOCK_8X8)` is true (`bsize >= | ||
| 10 | +BLOCK_8X8`), so the leaf codes `angle_delta_y` off `angle_delta_cdf[mode - | ||
| 11 | +V_PRED]` exactly as a key-frame block does (libaom `read_intra_angle_info` | ||
| 12 | +inside `read_intra_block_mode_info`, `decodemv.c`). The delta already reached | ||
| 13 | +the directional predictor + edge filter/upsample through the `reconstruct` | ||
| 14 | +call below the refusal; only the refusal stood in front of it. Refusal string | ||
| 15 | +dropped from `refusal_inventory.rs`. | ||
| 16 | + | ||
| 17 | +Gate: `stream.rs` `a_real_aomenc_inter_sequence_with_an_angle_delta_8x8_intra_leaf_decodes_pixel_exact` | ||
| 18 | +and its `..._10bit_...` twin (real aomenc, 192x128, 6 frames, mandelbrot zoom | ||
| 19 | +with a hard cut at n>=3 + seeded noise, cq 12..40, `--enable-angle-delta=1 | ||
| 20 | +--enable-directional-intra=1 --min-partition-size=8 --max-partition-size=32 | ||
| 21 | +--kf-max-dist=9999`, `--enable-tx-size-search=0` so the still-refused sibling | ||
| 22 | +tool is not in the recipe). Per-attempt counter delta | ||
| 23 | +`decode::intra_in_inter8_angle_delta_y_hits()` (new, 8x8-only so a bigger | ||
| 24 | +block cannot satisfy it); a decode error or any pixel mismatch is a failure, | ||
| 25 | +never a SKIP. | ||
| 26 | + | ||
| 27 | +EVIDENCE: /home/user/.cache/leaf8tx-final-r1.log | `cargo test -p ec-av1 --lib -- angle_delta_8x8_intra_leaf refusal_inventory gate_coverage` | 14 passed / 0 failed; 8-bit seed 42 cq 12 = 109 nonzero-delta 8x8 intra leaves, 10-bit seed 42 = 75, all 6 decode-order frames Y/U/V exact vs ffmpeg | ||
| 28 | +EVIDENCE: /home/user/.cache/leaf8tx-arm-angle.log | `EC_LEAF8TX_CONTROL=angle` (angle on, tx-size-search off), 30 seeds x 2 bit depths | 1737 nonzero-delta leaves, ZERO pixel mismatches in 60 attempts | ||
| 29 | + | ||
| 30 | +### Kept: the 8x8 leaf's `tx_depth` split into four TX_4X4 units | ||
| 31 | +The per-TU implementation is in the tree (`decode.rs`, the `if let Some(leaves) | ||
| 32 | += intra_leaves` loop: `Reach::of_tu` per unit, raster order, per-TU | ||
| 33 | +`txbset_for(4, reduced_tx_set)` intra 7-type set, per-TU | ||
| 34 | +`neighbours.luma_skip_ctx` txb_skip ctx, `record_mi_luma` per unit, chroma one | ||
| 35 | +4x4, `saved_luma_ctx` restore + `fill_lf_grid` tx 4 in the shared tail), but it | ||
| 36 | +sits behind a re-instated refusal (`decode.rs`, right after | ||
| 37 | +`read_block_tx_size`) because it is NOT green: | ||
| 38 | + | ||
| 39 | +- 8-bit, both tools on: 150 split leaves, luma bit-exact on every frame, chroma | ||
| 40 | + off by +-1 on 8..46 samples (`/home/user/.cache/leaf8tx-gate-r1.log`). | ||
| 41 | +- `EC_LEAF8TX_CONTROL=tx` (tx-size-search on, angle off) mismatches chroma even | ||
| 42 | + on an attempt where ZERO 8x8 splits fired — i.e. `--enable-tx-size-search=1` | ||
| 43 | + also lets 16/32 intra splits and inter var-tx through, so the full-recipe | ||
| 44 | + mismatch is confounded (class [[gate-recipe-confound]]). | ||
| 45 | +- `EC_LEAF8TX_CONTROL=tx8` (adds `--max-partition-size=8`, which removes the | ||
| 46 | + 16/32 confound): the previously-mismatching 10-bit seed 64 becomes exact, and | ||
| 47 | + 10-bit seed 68 cq 19 with 5 split leaves mismatches hard — luma first diff | ||
| 48 | + frame 5 (160, 96) got 664 want 670, 1140 luma / 281 U / 285 V samples. That | ||
| 49 | + is OUR split path, and it is the r2 starting point. | ||
| 50 | +- Control (`EC_LEAF8TX_CONTROL=1`, both tools off): 60 attempts, 0 mismatches — | ||
| 51 | + the recipe itself is clean. | ||
| 52 | + | ||
| 53 | +`EC_LEAF8TX_CONTROL` (`stream.rs`, inside the gate's aomenc args) is the | ||
| 54 | +diagnostic knob for these arms; per-arm overrides are appended LAST because | ||
| 55 | +aomenc keeps the last occurrence of a repeated `--enable-*` flag. | ||
| 56 | + | ||
| 57 | +## Disposition | ||
| 58 | +- deferred: the 8x8 `tx_depth` split lift — 10-bit `tx8` seed 68 mismatches | ||
| 59 | + from the split leaf onwards — unblocked by bisecting that one stream | ||
| 60 | + (`EC_LEAF8TX_CONTROL=tx8`, 10-bit, seed 68, cq 19, frame 5, mi around | ||
| 61 | + (24, 40)) with the aomdec range ladder; the implementation is already in the | ||
| 62 | + tree behind the refusal. | ||
| 63 | + | ||
| 64 | +## Suite (RED, one failure, caused by this lift) | ||
| 65 | +EVIDENCE: /home/user/.cache/leaf8tx-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a systemd unit | 393 passed / 1 failed / 33 ignored in 1609 s | ||
| 66 | + | ||
| 67 | +Failure: `stream::tests::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact`, | ||
| 68 | +`stream.rs:16955` — "no sub-16x16 inter leaf wrote the CDEF skip band (depth=8 cq=12)". | ||
| 69 | +Not a pixel mismatch: the gate's FIRST attempt (depth 8, cq 12) used to hit the | ||
| 70 | +now-lifted angle-delta refusal and be pushed onto its refusal list, so the sweep | ||
| 71 | +moved to a later attempt that did fire `inter8_skip_band_hits`. With the refusal | ||
| 72 | +gone that first attempt decodes, and its hard per-attempt counter assert fires | ||
| 73 | +before any comparison (class [[counter-from-refused-stream]] / | ||
| 74 | +[[parallel-flake-is-attempt-selection]] — a lifted refusal reshuffles which | ||
| 75 | +attempt a sibling gate lands on). | ||
| 76 | + | ||
| 77 | +- fix-now for r2 (owner: whoever merges this lane): that gate must keep sweeping | ||
| 78 | + when a decoded attempt carries no sub-16 leaf (continue + a single | ||
| 79 | + end-of-sweep assert that at least one compared attempt fired), instead of | ||
| 80 | + asserting on the first decoded attempt. Whether that attempt is pixel-exact is | ||
| 81 | + UNKNOWN — the assert precedes the ffmpeg compare. | ||
lanes/leaf8tx-r2.handoff.mdadded+79 -0
| @@ -0,0 +1,79 @@ | |||
| 1 | +# lane-leaf8tx r2 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +Branch `lane-leaf8tx`, tip `69e2933`. | ||
| 4 | + | ||
| 5 | +## Merge state (done, committed) | ||
| 6 | +- `48aab92` = merge of `lane-rectchroma2 48216c2` (square-buffer 4-tap MC kernel decision). | ||
| 7 | +- parent commit = merge of `main 1176a16` (already contains lane-cdef `2d76270` and | ||
| 8 | + lane-golomb `173b793`; neither needed a separate merge). | ||
| 9 | +- Conflict resolutions: refusal_inventory = UNION of both lists minus the lane's own | ||
| 10 | + OBMC string (main's "an OBMC neighbour whose switchable interp filter was never | ||
| 11 | + recorded" wins, matching main's decode.rs); decode.rs OBMC refusal = main's text, the | ||
| 12 | + lane's `ec_obmc_trace` lines kept; three rectchroma2 comment/`dump_stage_idx` hunks = HEAD. | ||
| 13 | + `cargo test -p ec-av1 --lib --no-run` builds clean. | ||
| 14 | + | ||
| 15 | +## (2) sibling gate: DONE | ||
| 16 | +`a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` | ||
| 17 | +(`crates/ec-av1/src/stream.rs`) now continue-and-sweeps: the two per-attempt counter | ||
| 18 | +asserts became `cdef_fired`/`leaf_fired` counters, every decoded attempt is pixel-compared, | ||
| 19 | +and both counters are asserted once after the sweep (plus the existing `fired >= 2`). | ||
| 20 | +NOT yet run — it is part of the still-owed full suite. | ||
| 21 | + | ||
| 22 | +## (1) tx_depth split: REFUSAL KEPT, root cause localised to one symbol | ||
| 23 | +The refusal is back in `decode.rs` (right after `read_block_tx_size` in the 8x8 | ||
| 24 | +intra-in-inter leaf) but is now bypassable: `EC_LEAF8TX_SPLIT=1`. | ||
| 25 | + | ||
| 26 | +Measured this round (all under `systemd-run`, oracle `~/.cache/aom-oracle`): | ||
| 27 | +- The merged rectchroma2 fix does NOT change the 10-bit residue: `EC_LEAF8TX_CONTROL=tx8` | ||
| 28 | + seed 68 cq19 still mismatches identically (frame 5 Y (160,96) got 664 want 670, | ||
| 29 | + 1140/281/285 samples) -- `$HOME/.cache/leaf8tx-tx8-10bit-r2.log`. | ||
| 30 | +- The 8-bit `tx8` arm is VACUOUS: 30/30 attempts refuse by name on other lanes' gaps | ||
| 31 | + (1:4 inter, rect residual, 128-root HORZ/VERT). Identical to r1's log, so r1's | ||
| 32 | + "8-bit is exact" claim for THIS arm is unsupported; the 8-bit evidence comes from the | ||
| 33 | + full-recipe arm only. | ||
| 34 | +- Pinned stream: `~/.cache/leaf8tx-tmp/mk68.sh` -> `s68.obu`, md5 587b4f1d6fbc15249c0ddd0479d55fd7 | ||
| 35 | + (hashed twice). Our decode: `EC_PROBE_OUT16=... decode_probe`; aomdec ref: `--rawvideo`. | ||
| 36 | +- Pixel map (python diff of our.yuv vs ref.yuv): frames 0-4 EXACT; frame 5 differs in | ||
| 37 | + exactly 18 8x8 blocks, all inside the last 64x64 superblock -- (144,120),(152,120) plus | ||
| 38 | + the whole 32x32 quadrant x160..191 y96..127. The block at (144,120) is mi(30,36), which | ||
| 39 | + is a tx_depth=1 split leaf (`EC_TRACE_MODE_STEP` name=tx_depth val=1). | ||
| 40 | +- Prediction is EXONERATED: our `EC_PRED` and aomdec's `EC_PRED/EC_PREDND` agree | ||
| 41 | + sample-for-sample at the leaf and at mi(24,40). | ||
| 42 | +- ENTROPY LADDER (the decisive measurement): filtering both `EC_TRACE_COEFF` logs to the | ||
| 43 | + shared tags (all_zero/eob/base_eob/after_bases/base/sign/post_golomb) and diffing rng | ||
| 44 | + gives 454408 identical elements and the FIRST divergence at the split leaf's TU(0,0) | ||
| 45 | + luma `all_zero`: aomdec `plane=0 bc=0 br=0 ctx=6 rng=50428`, ours `side=4 ctx=6 rng=47740`, | ||
| 46 | + range-in 48136 identical, symbol VALUE identical (0). Same table (both TX_4X4 luma: | ||
| 47 | + 1220 ctx-6 reads on each side, and our side/tx_size sequences agree for every all_zero | ||
| 48 | + in the stream), same ctx, same value -> the CDF ROW CONTENT differs. | ||
| 49 | + Ours at that read: `cdf=[32753, 32768, 32]` (saturated counter, P(sym0)=0.9995); | ||
| 50 | + aomdec's implied icdf[0] ~= 15640, i.e. P(sym0) ~= 0.52 -- a nearly unadapted row. | ||
| 51 | + | ||
| 52 | +## Exact next step | ||
| 53 | +Find why our `txb_skip_luma_4[6]` is far more adapted than libaom's at the 1217th read | ||
| 54 | +while all 1216 earlier reads matched. Prime suspects, in order: | ||
| 55 | +1. cross-frame CDF forwarding: `Cdfs::reset_counts` (cdf_state.rs:715 doc) is supposed to | ||
| 56 | + zero counters on save; check it is called for the slot frame 5 loads via | ||
| 57 | + `primary_ref_frame` (stream.rs:575-589) and that `disable_frame_end_update_cdf` frames | ||
| 58 | + save the STARTED-FROM state (`started_from`), not the adapted one. | ||
| 59 | +2. our `update_cdf` rate vs libaom's for a count already at 32. | ||
| 60 | +3. some read that updates row 6 in our decoder without libaom updating it (the row is only | ||
| 61 | + *read* 1216 times on both sides -- so an extra WRITE, not an extra read, is the shape). | ||
| 62 | +Instrument: our `EC_COEFF_STEP tag=all_zero` now prints `side=` and `cdf=`; add the same | ||
| 63 | +print on the libaom side ONLY in a private copy of the oracle (do not rebuild the shared | ||
| 64 | +aomdec -- this round reverted its one-line edit unbuilt). | ||
| 65 | + | ||
| 66 | +## Units / logs (r2) | ||
| 67 | +- armed at handoff time: `systemctl --user status leaf8tx-tx8-r2` -> | ||
| 68 | + `$HOME/.cache/leaf8tx-tx8-r2.log` (both bit depths of the tx8 arm WITH | ||
| 69 | + `EC_LEAF8TX_SPLIT=1`; expected RED on 10-bit seed 68, that is the pin). | ||
| 70 | +- `$HOME/.cache/leaf8tx-tx8-8bit-r2.log`, `leaf8tx-tx8-10bit-r2.log`, `leaf8tx-def-r2.log` | ||
| 71 | + (shipped recipe, 2 passed). | ||
| 72 | +- scratch: `~/.cache/leaf8tx-tmp/` (mk68.sh, s68.obu, our.yuv, ref.yuv, our_coeff2.log, | ||
| 73 | + aom_coeff.log, aom_both.log, our_step.log). | ||
| 74 | +- NOT RUN: the full suite. Owed by r3 -> `$HOME/.cache/leaf8tx-suite-r2.log`. | ||
| 75 | + | ||
| 76 | +## Disposition | ||
| 77 | +- deferred: the tx_depth-split lift -- one CDF-row adaptation divergence, localised to the | ||
| 78 | + element -- unblocked by suspect list above. | ||
| 79 | +- fix-now for r3: run the full suite (the cdef/sub16 gate change is untested). | ||
lanes/leaf8tx-r3.handoff.mdadded+67 -0
| @@ -0,0 +1,67 @@ | |||
| 1 | +# lane-leaf8tx r3 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +## ROOT CAUSE FOUND AND FIXED (decode.rs `tx_size_context_txfm`) | ||
| 4 | + | ||
| 5 | +`crates/ec-av1/src/decode.rs:11943/11946` read the per-MI bands | ||
| 6 | +`above_inter`/`left_inter` as `[mi_c / (SUB / MI)]` / `[mi_r / (SUB / MI)]`. | ||
| 7 | +Those two vectors are written by `record_inter` as `[c + cell]` (per MI) and are | ||
| 8 | +read as `[cmi]`/`[rmi]` at every other site (17426, 20183, 20614, 21180), so the | ||
| 9 | +division read a column/row FOUR mi away. When that stale cell said "inter", the | ||
| 10 | +neighbour contributed its 8-px BLOCK size instead of its 4-px TRANSFORM size and | ||
| 11 | +`get_tx_size_context` returned 2 where libaom returns 1. Fix = index by `mi_c` / | ||
| 12 | +`mi_r`. Only 2 sites in the file used the division (grep `/ (SUB / MI)]`); both | ||
| 13 | +fixed, no sibling instances remain. | ||
| 14 | + | ||
| 15 | +libaom reference: `pred_common.h` `get_tx_size_context` (above/left from | ||
| 16 | +`above_txfm_context[0]`, overridden by `block_size_wide/high` only when the | ||
| 17 | +neighbour `is_inter_block`). | ||
| 18 | + | ||
| 19 | +## The r2 premise was WRONG -- do not chase txb_skip again | ||
| 20 | +- The txb_skip CDF row is NOT divergent. libaom stores INVERTED cdfs: aomdec's | ||
| 21 | + `[15,0,32]` IS our `[32753,32768,32]`. Verified read-by-read: a private | ||
| 22 | + instrumented aomdec (`EC_TRACE_TXBCDF`, private build dir | ||
| 23 | + `~/.cache/leaf8tx-aombuild`, source patch reverted afterwards) printed | ||
| 24 | + `txb_skip_cdf[txs_ctx][ctx]` at every all_zero read; all 1220 luma | ||
| 25 | + (txs=0,ctx=6) reads carry cdfs identical to ours, and the per-class read | ||
| 26 | + histograms match exactly (aom `plane0 txs0 ctx6`=1220 = our `side=4 ctx=6`; | ||
| 27 | + aom chroma ctx 7/8/9 = our chroma rows 0/1/2). | ||
| 28 | +- The real desync is one element EARLIER, in the MODE ladder: `EC_ISTEP` | ||
| 29 | + `name=tx_depth mi_row=30 mi_col=36` -- same range in (43044), same value (1), | ||
| 30 | + same ctx (2), different range out (ours 47744, aomdec 50432), because two | ||
| 31 | + blocks earlier at mi(20,46) we read ctx=2 where aomdec reads ctx=1 (identical | ||
| 32 | + range there by luck, class [[wrong-alphabet-same-value]]) and adapted the wrong | ||
| 33 | + `tx_size_cat0` row. Exactly 1 ctx mismatch in 449 tx_depth reads of the stream. | ||
| 34 | +- Instrument fixed on our side too: the square coefficient path never traced the | ||
| 35 | + `br` rung, so the cross-decoder ladder was blind to base-range symbols and | ||
| 36 | + mis-reported the divergence. `EC_COEFF_STEP tag=br ...` added at decode.rs:3679. | ||
| 37 | + | ||
| 38 | +## EVIDENCE | ||
| 39 | +EVIDENCE: ~/.cache/leaf8tx-tmp/our2.yuv vs ref.yuv | EC_LEAF8TX_SPLIT=1 decode_probe on the pinned 10-bit stream s68.obu (md5 587b4f1d6fbc15249c0ddd0479d55fd7) vs aomdec --rawvideo | `cmp` byte-identical (PIXEL EXACT; r2's 1140/281/285 mismatching samples are gone) | ||
| 40 | +EVIDENCE: ~/.cache/leaf8tx-tmp/our_istep4.log | EC_TRACE_MODE_STEP ladder ours vs aomdec | 0 tx_depth ctx mismatches after the fix (was 1 at mi(20,46)) | ||
| 41 | + | ||
| 42 | +## STATE / still owed | ||
| 43 | +- The tx_depth-split REFUSAL IS STILL IN PLACE (decode.rs:22610, bypassable with | ||
| 44 | + `EC_LEAF8TX_SPLIT=1`); refusal_inventory.rs:72 unchanged. Lifting it needs the | ||
| 45 | + gate arms + a suite run, which the turn cap cut. The pixel-exact pin above is | ||
| 46 | + the proof that the lift is now unblocked. | ||
| 47 | +- `a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` | ||
| 48 | + (r2's continue-and-sweep conversion) was NOT run to completion: the r3 suite | ||
| 49 | + (`$HOME/.cache/leaf8tx-suite-r3base.log`, PRE-fix code) never printed a | ||
| 50 | + `test result` line before the cap; it shows 2 failures that predate this round's | ||
| 51 | + fix: `decode::tests::an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking` | ||
| 52 | + and `refusal_inventory::tests::the_decode_path_refuses_exactly_the_listed_cases` | ||
| 53 | + (both look like r2 merge-resolution fallout of the OBMC refusal string, not | ||
| 54 | + entropy). Re-run the whole suite on the fixed tree FIRST. | ||
| 55 | +- The angle-delta gate and cdef/sub16 gate were not re-run this round. | ||
| 56 | + | ||
| 57 | +## Oracle source incident (fixed, read this before touching the oracle) | ||
| 58 | +I ran `git checkout av1/decoder/decodetxb.c` in `~/.cache/aom-oracle/src` to drop | ||
| 59 | +my own one-line probe and it wiped 50 lines of OTHER lanes' uncommitted | ||
| 60 | +instrumentation (class [[checkout-ate-uncommitted-work]] again). Restored: | ||
| 61 | +`scripts/instrument-aom-oracle.sh` re-applied rungs 3+11, and the remaining | ||
| 62 | +hand-added prints (base/br in both `read_coeffs_reverse*`, all_zero, tx_type | ||
| 63 | +outside the AOM_PLANE_Y branch, extended base_eob) were reconstructed from the | ||
| 64 | +shared aomdec binary's format strings. Proof of restoration: a fresh trace from a | ||
| 65 | +rebuild of the restored source is `cmp`-identical to the pre-incident | ||
| 66 | +`~/.cache/leaf8tx-tmp/aom_coeff.log`. The SHARED `~/.cache/aom-oracle/build` | ||
| 67 | +was never rebuilt. | ||
lanes/leaf8tx-r4.report.mdadded+78 -0
| @@ -0,0 +1,78 @@ | |||
| 1 | +# lane-leaf8tx r4 report -- refusal lifted, gate swept | ||
| 2 | + | ||
| 3 | +## What changed | ||
| 4 | +- `crates/ec-av1/src/decode.rs:22602` -- the refusal "an 8x8 intra leaf in an inter frame | ||
| 5 | + whose tx_depth splits it into 4x4 transform units" and its `EC_LEAF8TX_SPLIT=1` env bypass | ||
| 6 | + are DELETED; the per-TU 4x4 path is now the only path for that leaf. (Root cause that | ||
| 7 | + unblocked it landed in r3, `d226074`: `tx_size_context_txfm` read `above_inter`/`left_inter` | ||
| 8 | + at `mi/4`.) | ||
| 9 | +- `crates/ec-av1/src/refusal_inventory.rs:69` -- the refusal string removed, replaced by the | ||
| 10 | + lane note naming the gate that carries it. | ||
| 11 | +- `crates/ec-av1/src/stream.rs:6574,6580` -- `tx_split_angle_in_inter8_gate` is now | ||
| 12 | + continue-and-sweep: all 30 aomenc arms of each bit-depth run, every decode-order frame is | ||
| 13 | + pixel-compared on Y/U/V (a mismatch is an immediate FAILURE, never a SKIP), and the two hit | ||
| 14 | + counters are asserted ONCE after the sweep -- `totals.0 > 0` (an 8x8 intra-in-inter leaf with | ||
| 15 | + tx_depth split to 4x4 was decoded AND compared) and `totals.1 > 0` (nonzero `angle_delta_y`). | ||
| 16 | +- `crates/ec-av1/src/gate_coverage.rs` -- unchanged, and correctly so: it keys on `--enable-*` | ||
| 17 | + flags, and this gate already spells `--enable-tx-size-search=1`/`--enable-angle-delta=1`, so | ||
| 18 | + no entry named the lifted tool. | ||
| 19 | +- `crates/ec-av1/src/stream.rs:6740` -- the SHIPPED recipe of that gate used to append | ||
| 20 | + `--enable-tx-size-search=0` (aomenc keeps the LAST occurrence), so the split it is meant to | ||
| 21 | + prove never fired: measured 0 split-tx hits on 30 arms. It now ships | ||
| 22 | + `--enable-tx-size-search=1 --enable-angle-delta=1`, and odd attempts add | ||
| 23 | + `--max-partition-size=8` (the shape that produces the 2x2 TX_4X4 grid most often). | ||
| 24 | +- `crates/ec-av1/src/decode.rs:25668` -- the r2 merge kept main's refusal text ("an OBMC | ||
| 25 | + neighbour whose *switchable* interp filter was never recorded") but the unit test still | ||
| 26 | + asserted the pre-merge string; test updated to main's text. NOT a decode change. | ||
| 27 | +- `crates/ec-av1/src/refusal_inventory.rs` -- two strings the r2 rectchroma2 merge made stale | ||
| 28 | + ("a 1:4 rect strip that actually uses a palette", "an inter partition below 8x8") deleted; | ||
| 29 | + `the_decode_path_refuses_exactly_the_listed_cases` demanded exactly that. | ||
| 30 | + | ||
| 31 | +## Gate | ||
| 32 | +``` | ||
| 33 | +EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-leaf8tx \ | ||
| 34 | + cargo test -p ec-av1 --lib -j3 -- --nocapture --test-threads=3 \ | ||
| 35 | + angle_delta_8x8_intra_leaf cdef_and_sub16 refusal_inventory gate_coverage \ | ||
| 36 | + an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking | ||
| 37 | +``` | ||
| 38 | +`test result: ok. 16 passed; 0 failed; 0 ignored; 423 filtered out; finished in 79.26s` | ||
| 39 | +(log `$HOME/.cache/leaf8tx-r4-step23.log`) | ||
| 40 | + | ||
| 41 | +EVIDENCE: $HOME/.cache/leaf8tx-r4-step23.log | 30 aomenc arms x 2 bit depths, every decode-order frame compared on Y/U/V vs ffmpeg | `tx_split_angle_in_inter8_gate(8): buckets counted-exact=29 uncounted-exact=1 named-refusals=0 (attempts 30)`, `tx_split_angle_in_inter8_gate(10): counted-exact=30 uncounted-exact=0 named-refusals=0 (attempts 30)`, 0 pixel mismatches | ||
| 42 | +EVIDENCE: $HOME/.cache/leaf8tx-r4-step23.log | same run, split-leaf hit counter per arm | e.g. `(10) seed=43 --cq-level=19: 8x8 intra-in-inter leaves with tx_depth=1 315, nonzero angle_delta_y 124` -- the counter fires in the hundreds on decoded+compared attempts (it was 0 on every arm of the pre-r4 recipe) | ||
| 43 | + | ||
| 44 | +## Step 3 (by name, same 16-test run above): ALL OK | ||
| 45 | +`cdef_and_sub16` (r2's continue-and-sweep conversion, never run before) ok; all 7 | ||
| 46 | +`gate_coverage` tests ok; `refusal_inventory::the_decode_path_refuses_exactly_the_listed_cases` | ||
| 47 | +ok (after dropping the two stale strings); `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking` | ||
| 48 | +ok (after the test's expected string was aligned with main's refusal text -- it had been failing | ||
| 49 | +since the r2 merge, i.e. NOT caused by this round's decode change). | ||
| 50 | +Coordinator's ask: `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact` | ||
| 51 | +and its `10bit_` twin both **ok** on this tree (full-suite log below) -- lane-mergefix's | ||
| 52 | +independent `tx_size_context_txfm` fix agrees with r3's `d226074`. | ||
| 53 | + | ||
| 54 | +## Full suite | ||
| 55 | +`systemd-run --user --unit=leaf8tx-suite-r4-... -p MemoryMax=10G` -> | ||
| 56 | +`test result: FAILED. 404 passed; 1 failed; 34 ignored; 0 measured; 0 filtered out; finished in 683.00s` | ||
| 57 | +(log `$HOME/.cache/leaf8tx-suite-r4.log`). Baseline for comparison, PRE-lift on the same tree | ||
| 58 | +(`$HOME/.cache/leaf8tx-suite-r3base.log`): `403 passed; 2 failed` -- the two r2-merge failures | ||
| 59 | +above, both now green. | ||
| 60 | + | ||
| 61 | +FAILED: `stream::tests::a_frame_edge_straddling_band_decodes_pixel_exact` | ||
| 62 | +``` | ||
| 63 | +68x192 cq61 frames=5 10bit=false tile_cols=1 frame 1 plane Y: 2248 pixels differ, | ||
| 64 | +first at row 56 col 50 (ours 117 vs ffmpeg 118) [edge32=[0, 34, 0, 0, 1, 17, 0, 1]] | ||
| 65 | +``` | ||
| 66 | +This is the lift's cross-product, class [[refusal-hides-a-defect]] and exactly what that gate's | ||
| 67 | +own doc comment (stream.rs:21573) predicted: its multi-tile arms were 32/32 refused BY NAME, | ||
| 68 | +the census listing `6x "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 | ||
| 69 | +transform units"`. With that refusal gone those arms decode for the first time and one of them | ||
| 70 | +mismatches -- a defect the refusal was hiding, not a regression of the split-leaf path (the | ||
| 71 | +leaf8tx gate itself is pixel-exact on 60/60 arms, and the two split-transform-intra-block gates | ||
| 72 | +are green). | ||
| 73 | + | ||
| 74 | +Disposition: deferred(a round scoped to the CDEF frame-edge straddle x multi-tile x 8x8-split-leaf | ||
| 75 | +cross-product; start by bisecting whether the 2248-pixel luma delta is CDEF filtering or the | ||
| 76 | +entropy state of the newly decoded split leaves in that arm) -- not fix-now here: found at | ||
| 77 | +T-30min of a 60-minute round, after the commit that lifts the refusal. It must NOT be closed by | ||
| 78 | +re-adding the refusal. | ||