The CDEF sub-16 inter-leaf gate sweeps instead of hard-asserting its counters on the first decoded attempt
Browse files at this commit3f8f4401a16b720f014375dd1deb04d3c80365aaParent: 942b908- fix
- the CDEF sub-16 inter-leaf gate sweeps instead of hard-asserting its counters on the first decoded attempt
2 changed files +42 -18
- crates/ec-av1/src/decode.rs +14 -7
- crates/ec-av1/src/stream.rs +28 -11
crates/ec-av1/src/decode.rsmodified+14 -7
| @@ -3555,11 +3555,17 @@ fn read_coeffs( | |||
| 3555 | let (range, value) = dec.debug_state(); | 3555 | let (range, value) = dec.debug_state(); |
| 3556 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); | 3556 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); |
| 3557 | } | 3557 | } |
| 3558 | + let dbg_txbskip = if std::env::var_os("EC_TRACE_COEFF").is_some() { | ||
| 3559 | + coding.txb_skip[skip_ctx] | ||
| 3560 | + } else { | ||
| 3561 | + [0; 3] | ||
| 3562 | + }; | ||
| 3558 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 3563 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 3559 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 3564 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 3560 | let (rng, _) = dec.debug_state(); | 3565 | let (rng, _) = dec.debug_state(); |
| 3561 | eprintln!( | 3566 | eprintln!( |
| 3562 | - "EC_COEFF_STEP tag=all_zero ctx={skip_ctx} all_zero={} rng={rng}", | 3567 | + "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng}", |
| 3568 | + coding.side, | ||
| 3563 | all_zero as i32 | 3569 | all_zero as i32 |
| 3564 | ); | 3570 | ); |
| 3565 | } | 3571 | } |
| @@ -22575,12 +22581,13 @@ fn decode_inter_block8( | |||
| 22575 | skip, | 22581 | skip, |
| 22576 | )? | 22582 | )? |
| 22577 | .1; | 22583 | .1; |
| 22578 | - // lane-leaf8tx r1: the per-TU loop below is written and decodes the | 22584 | + // lane-leaf8tx r2: the per-TU loop below is written and its ENTROPY is |
| 22579 | - // 8-bit arm's 150 split leaves pixel-exact, but a 10-bit stream | 22585 | + // range-exact against aomdec for 1216 of 1217 luma 4x4 txb_skip reads |
| 22580 | - // (`EC_LEAF8TX_CONTROL=tx8`, seed 68, cq 19) still mismatches from | 22586 | + // on the 10-bit seed-68 stream, but the 1217th (the split leaf at |
| 22581 | - // the split leaf onwards (luma 1140 samples from (160, 96)), so the | 22587 | + // mi(30,36) of frame 5) reads the same table/ctx with a DIFFERENT |
| 22582 | - // refusal stays until a gate is green -- no lift without one. | 22588 | + // adapted CDF row, so the refusal stays until a gate is green. |
| 22583 | - if intra_leaves.is_some() { | 22589 | + // `EC_LEAF8TX_SPLIT=1` bypasses it for the ablation arms. |
| 22590 | + if intra_leaves.is_some() && std::env::var_os("EC_LEAF8TX_SPLIT").is_none() { | ||
| 22584 | return Err(unsupported( | 22591 | return Err(unsupported( |
| 22585 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 \ | 22592 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 \ |
| 22586 | transform units", | 22593 | transform units", |
crates/ec-av1/src/stream.rsmodified+28 -11
| @@ -17490,6 +17490,8 @@ mod tests { | |||
| 17490 | let (width, height, frames) = (192usize, 128usize, 6usize); | 17490 | let (width, height, frames) = (192usize, 128usize, 6usize); |
| 17491 | let mut refusals: Vec<String> = Vec::new(); | 17491 | let mut refusals: Vec<String> = Vec::new(); |
| 17492 | let mut fired = 0u32; | 17492 | let mut fired = 0u32; |
| 17493 | + let mut cdef_fired = 0u32; | ||
| 17494 | + let mut leaf_fired = 0u32; | ||
| 17493 | for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | 17495 | for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { |
| 17494 | let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 17496 | let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 17495 | let src = format!( | 17497 | let src = format!( |
| @@ -17579,16 +17581,19 @@ mod tests { | |||
| 17579 | } | 17581 | } |
| 17580 | }; | 17582 | }; |
| 17581 | assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | 17583 | assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); |
| 17582 | - assert!( | 17584 | + // lane-leaf8tx r2: continue-and-sweep, not a per-attempt hard |
| 17583 | - decode::cdef_skipped_units() > skipped_before, | 17585 | + // assert. Lifting a refusal reshuffles WHICH attempt this gate |
| 17584 | - "no 8x8 CDEF unit was excluded by the all-skip rule \ | 17586 | + // lands on (class [[parallel-flake-is-attempt-selection]]): the |
| 17585 | - (depth={depth} cq={cq})" | 17587 | + // first decoded attempt need not carry a sub-16 leaf, and |
| 17586 | - ); | 17588 | + // aborting there skipped the pixel compare entirely. Every |
| 17587 | - assert!( | 17589 | + // decoded attempt is compared; the counters are asserted once, |
| 17588 | - decode::inter8_skip_band_hits() > leaves_before, | 17590 | + // at the end, over the compared attempts. |
| 17589 | - "no sub-16x16 inter leaf wrote the CDEF skip band \ | 17591 | + if decode::cdef_skipped_units() > skipped_before { |
| 17590 | - (depth={depth} cq={cq})" | 17592 | + cdef_fired += 1; |
| 17591 | - ); | 17593 | + } |
| 17594 | + if decode::inter8_skip_band_hits() > leaves_before { | ||
| 17595 | + leaf_fired += 1; | ||
| 17596 | + } | ||
| 17592 | let reference = if depth == 10 { | 17597 | let reference = if depth == 10 { |
| 17593 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | 17598 | ffmpeg_decode_sequence_10bit(&stream, width, height, frames) |
| 17594 | } else { | 17599 | } else { |
| @@ -17607,7 +17612,19 @@ mod tests { | |||
| 17607 | // hard-asserts both counters plus all six frames on all three planes. | 17612 | // hard-asserts both counters plus all six frames on all three planes. |
| 17608 | assert!( | 17613 | assert!( |
| 17609 | fired >= 2, | 17614 | fired >= 2, |
| 17610 | - "fewer than 2 firing+pixel-exact attempts:\n{}", | 17615 | + "fewer than 2 decoded+pixel-exact attempts:\n{}", |
| 17616 | + refusals.join("\n") | ||
| 17617 | + ); | ||
| 17618 | + assert!( | ||
| 17619 | + cdef_fired > 0, | ||
| 17620 | + "no compared attempt excluded an 8x8 CDEF unit by the all-skip rule \ | ||
| 17621 | + ({fired} compared):\n{}", | ||
| 17622 | + refusals.join("\n") | ||
| 17623 | + ); | ||
| 17624 | + assert!( | ||
| 17625 | + leaf_fired > 0, | ||
| 17626 | + "no compared attempt had a sub-16x16 inter leaf write the CDEF skip band \ | ||
| 17627 | + ({fired} compared):\n{}", | ||
| 17611 | refusals.join("\n") | 17628 | refusals.join("\n") |
| 17612 | ); | 17629 | ); |
| 17613 | } | 17630 | } |