forge
Explore
Log in

Don't you dare go Hollow

wip(av1): rect strip bisection (orchestrator-committed at the turn cap)

Browse files at this commit

2ea3bfc8d99d9dcfe0c33627ddfb8458c1ba308dAhmet Kaan GümüşParent: c8e7f7e
crates/ec-av1/src/decode.rsmodified+53 -4
@@ -1900,11 +1900,23 @@ fn read_intra_mode_rect(
19001900 0
19011901 };
19021902 let mut filter_intra = None;
1903+ if std::env::var_os("EC_AV1_TRACE").is_some() {
1904+ let (rng, _) = dec.debug_state();
1905+ eprintln!(
1906+ "TRACE_RECT_PREFI mode={mode} uv_mode={uv_mode} enable_filter_intra={} \
1907+ class={:?} rng={rng}",
1908+ enable_filter_intra as i32,
1909+ filter_intra_size_class_rect(bw, bh)
1910+ );
1911+ }
19031912 if mode == DC_PRED
19041913 && enable_filter_intra
19051914 && let Some(class) = filter_intra_size_class_rect(bw, bh)
19061915 {
19071916 let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0;
1917+ if std::env::var_os("EC_AV1_TRACE").is_some() {
1918+ eprintln!("TRACE_RECT_USEFI value={}", use_filter_intra as i32);
1919+ }
19081920 if use_filter_intra {
19091921 FILTER_INTRA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
19101922 let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode);
@@ -2035,6 +2047,14 @@ fn decode_block_rect(
20352047 let (cpx, cpy) = (px / 2, py / 2);
20362048 let (chroma_w, chroma_h) = (bw / 2, bh / 2);
20372049 let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height);
2050+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2051+ let (rng, _) = dec.debug_state();
2052+ eprintln!(
2053+ "TRACE_RECT_IMODE mi_row={mi_r} mi_col={mi_c} mode={mode} uv_mode={uv_mode} \
2054+ skip={} tx={depth} rng={rng}",
2055+ skip as i32
2056+ );
2057+ }
20382058 if skip {
20392059 y.reconstruct_rect(
20402060 px,
@@ -2109,11 +2129,27 @@ fn decode_block_rect(
21092129 // lanes/rectwire-r3.report.md for what was ruled out (base_ctx_rect's
21102130 // 5-neighbour offsets, u/v_skip_ctx's above+left formula, and
21112131 // dc_sign_ctx's around-index all cross-checked byte-for-byte against
2112- // libaom and match). Refusing by name again (r1 behavior) rather than
2113- // risk landing the desync.
2132+ // libaom and match). lane-rectwire r4: range-ladder against the
2133+ // now-instrumented oracle (EC_TRACE_MODE's intra EC_IMODE/EC_IMODE_VAL)
2134+ // narrowed the divergence past skip/y_mode/uv_mode (values AND range
2135+ // both confirmed in sync -- rng=58692 on both sides right after
2136+ // uv_mode, with `enable_filter_intra=0` on this frame so neither side
2137+ // reads a filter_intra symbol) to the `tx_size_cat2` depth read
2138+ // immediately after: ours moves rng 58692 -> 43570, which cannot be
2139+ // reconciled with oracle's own EC_IMODE_VAL (rng=58692, taken *after*
2140+ // its own tx_size read) unless oracle's tx symbol is a near-certainty
2141+ // CDF that barely narrows the range -- i.e. this decoder's
2142+ // `tx_size_context_rect` ctx or `cdfs.tx_size_cat2` CDF selection for
2143+ // a 32x16/16x32 strip is the first diverging symbol, not the
2144+ // coefficient-context math r3 already cleared. Not confirmed byte-
2145+ // exact (would need a decodemv.c EC_TRACE_MODE patch specifically on
2146+ // `read_tx_size`'s own rng, not attempted this round -- budget), so
2147+ // still refusing by name rather than risk landing a partial fix on a
2148+ // named-but-unconfirmed suspect.
21142149 return Err(unsupported(
21152150 "a HORZ/VERT intra strip with real (non-skip) coefficients \
2116- (lane-rectwire r3: confirmed desync, not yet isolated)",
2151+ (lane-rectwire r4: divergence narrowed to the tx_size_cat2 depth \
2152+ read, not yet byte-confirmed)",
21172153 ));
21182154 #[allow(unreachable_code)]
21192155 {
@@ -2129,6 +2165,10 @@ fn decode_block_rect(
21292165 dc_sign_ctx(around[0].2),
21302166 TxType::DctDct,
21312167 )?;
2168+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2169+ let (rng, _) = dec.debug_state();
2170+ eprintln!("TRACE_RECT_COEFF plane=0 mi_row={mi_r} mi_col={mi_c} rng={rng}");
2171+ }
21322172 let luma_residual = dequant_and_inverse_typed_wh(
21332173 &luma_levels,
21342174 bw,
@@ -2163,6 +2203,10 @@ fn decode_block_rect(
21632203 dc_sign_ctx(around[1].2),
21642204 u_default_tx,
21652205 )?;
2206+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2207+ let (rng, _) = dec.debug_state();
2208+ eprintln!("TRACE_RECT_COEFF plane=1 mi_row={mi_r} mi_col={mi_c} rng={rng}");
2209+ }
21662210 let u_residual = dequant_and_inverse_typed_wh(
21672211 &u_levels,
21682212 chroma_w,
@@ -2196,6 +2240,10 @@ fn decode_block_rect(
21962240 dc_sign_ctx(around[2].2),
21972241 v_default_tx,
21982242 )?;
2243+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2244+ let (rng, _) = dec.debug_state();
2245+ eprintln!("TRACE_RECT_COEFF plane=2 mi_row={mi_r} mi_col={mi_c} rng={rng}");
2246+ }
21992247 let v_residual = dequant_and_inverse_typed_wh(
22002248 &v_levels,
22012249 chroma_w,
@@ -4489,8 +4537,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
44894537 let part32 = if has_cols32 && has_rows32 {
44904538 let p = dec.symbol(&mut cdfs.partition_w32[ctx32]);
44914539 if std::env::var_os("EC_AV1_TRACE").is_some() {
4540+ let (rng, _) = dec.debug_state();
44924541 eprintln!(
4493- "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p}",
4542+ "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p} rng={rng}",
44944543 r32 * BLOCK_MI,
44954544 c32 * BLOCK_MI
44964545 );