wip(av1): rect strip bisection (orchestrator-committed at the turn cap)
Browse files at this commit2ea3bfc8d99d9dcfe0c33627ddfb8458c1ba308dParent: c8e7f7e1 changed file +53 -4
- crates/ec-av1/src/decode.rs +53 -4
crates/ec-av1/src/decode.rsmodified+53 -4
| @@ -1900,11 +1900,23 @@ fn read_intra_mode_rect( | |||
| 1900 | 0 | 1900 | 0 |
| 1901 | }; | 1901 | }; |
| 1902 | let mut filter_intra = None; | 1902 | 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 | + } | ||
| 1903 | if mode == DC_PRED | 1912 | if mode == DC_PRED |
| 1904 | && enable_filter_intra | 1913 | && enable_filter_intra |
| 1905 | && let Some(class) = filter_intra_size_class_rect(bw, bh) | 1914 | && let Some(class) = filter_intra_size_class_rect(bw, bh) |
| 1906 | { | 1915 | { |
| 1907 | let use_filter_intra = dec.symbol(&mut cdfs.filter_intra[class]) != 0; | 1916 | 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 | + } | ||
| 1908 | if use_filter_intra { | 1920 | if use_filter_intra { |
| 1909 | FILTER_INTRA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 1921 | FILTER_INTRA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1910 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); | 1922 | let fi_mode = dec.symbol(&mut cdfs.filter_intra_mode); |
| @@ -2035,6 +2047,14 @@ fn decode_block_rect( | |||
| 2035 | let (cpx, cpy) = (px / 2, py / 2); | 2047 | let (cpx, cpy) = (px / 2, py / 2); |
| 2036 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); | 2048 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); |
| 2037 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | 2049 | 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 | + } | ||
| 2038 | if skip { | 2058 | if skip { |
| 2039 | y.reconstruct_rect( | 2059 | y.reconstruct_rect( |
| 2040 | px, | 2060 | px, |
| @@ -2109,11 +2129,27 @@ fn decode_block_rect( | |||
| 2109 | // lanes/rectwire-r3.report.md for what was ruled out (base_ctx_rect's | 2129 | // lanes/rectwire-r3.report.md for what was ruled out (base_ctx_rect's |
| 2110 | // 5-neighbour offsets, u/v_skip_ctx's above+left formula, and | 2130 | // 5-neighbour offsets, u/v_skip_ctx's above+left formula, and |
| 2111 | // dc_sign_ctx's around-index all cross-checked byte-for-byte against | 2131 | // 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 | 2132 | + // libaom and match). lane-rectwire r4: range-ladder against the |
| 2113 | - // risk landing the desync. | 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. | ||
| 2114 | return Err(unsupported( | 2149 | return Err(unsupported( |
| 2115 | "a HORZ/VERT intra strip with real (non-skip) coefficients \ | 2150 | "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)", | ||
| 2117 | )); | 2153 | )); |
| 2118 | #[allow(unreachable_code)] | 2154 | #[allow(unreachable_code)] |
| 2119 | { | 2155 | { |
| @@ -2129,6 +2165,10 @@ fn decode_block_rect( | |||
| 2129 | dc_sign_ctx(around[0].2), | 2165 | dc_sign_ctx(around[0].2), |
| 2130 | TxType::DctDct, | 2166 | TxType::DctDct, |
| 2131 | )?; | 2167 | )?; |
| 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 | + } | ||
| 2132 | let luma_residual = dequant_and_inverse_typed_wh( | 2172 | let luma_residual = dequant_and_inverse_typed_wh( |
| 2133 | &luma_levels, | 2173 | &luma_levels, |
| 2134 | bw, | 2174 | bw, |
| @@ -2163,6 +2203,10 @@ fn decode_block_rect( | |||
| 2163 | dc_sign_ctx(around[1].2), | 2203 | dc_sign_ctx(around[1].2), |
| 2164 | u_default_tx, | 2204 | u_default_tx, |
| 2165 | )?; | 2205 | )?; |
| 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 | + } | ||
| 2166 | let u_residual = dequant_and_inverse_typed_wh( | 2210 | let u_residual = dequant_and_inverse_typed_wh( |
| 2167 | &u_levels, | 2211 | &u_levels, |
| 2168 | chroma_w, | 2212 | chroma_w, |
| @@ -2196,6 +2240,10 @@ fn decode_block_rect( | |||
| 2196 | dc_sign_ctx(around[2].2), | 2240 | dc_sign_ctx(around[2].2), |
| 2197 | v_default_tx, | 2241 | v_default_tx, |
| 2198 | )?; | 2242 | )?; |
| 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 | + } | ||
| 2199 | let v_residual = dequant_and_inverse_typed_wh( | 2247 | let v_residual = dequant_and_inverse_typed_wh( |
| 2200 | &v_levels, | 2248 | &v_levels, |
| 2201 | chroma_w, | 2249 | chroma_w, |
| @@ -4489,8 +4537,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 4489 | let part32 = if has_cols32 && has_rows32 { | 4537 | let part32 = if has_cols32 && has_rows32 { |
| 4490 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); | 4538 | let p = dec.symbol(&mut cdfs.partition_w32[ctx32]); |
| 4491 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 4539 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 4540 | + let (rng, _) = dec.debug_state(); | ||
| 4492 | eprintln!( | 4541 | eprintln!( |
| 4493 | - "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p}", | 4542 | + "TRACE partition_w32 mi=({},{}) ctx={ctx32} value={p} rng={rng}", |
| 4494 | r32 * BLOCK_MI, | 4543 | r32 * BLOCK_MI, |
| 4495 | c32 * BLOCK_MI | 4544 | c32 * BLOCK_MI |
| 4496 | ); | 4545 | ); |