A split-transform intra HORZ/VERT strip in an inter frame decodes -- the depth symbol's context was the key frame's deblock-grid approximation, and the strip never wrote its own TXFM_CONTEXT bands
Browse files at this commit750a9ca1abdab2f38ace4f0bb3aaf2b5dfbf089dParent: c6f22ad- feat
- a split-transform intra HORZ/VERT strip in an inter frame decodes -- the depth symbol's context was the key frame's deblock-grid approximation, and the strip never wrote its own TXFM_CONTEXT bands
4 changed files +404 -11
- crates/ec-av1/src/decode.rs +72 -10
- crates/ec-av1/src/refusal_inventory.rs +0 -1
- crates/ec-av1/src/stream.rs +263 -0
- lanes/intrasplit-r1.report.md +69 -0
crates/ec-av1/src/decode.rsmodified+72 -10
| @@ -1964,6 +1964,19 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | |||
| 1964 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | 1964 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) |
| 1965 | } | 1965 | } |
| 1966 | 1966 | ||
| 1967 | +// lane-intrasplit r1: intra HORZ/VERT strips inside an INTER frame whose luma | ||
| 1968 | +// transform is SPLIT, bucketed by the read `tx_depth` (index 1 and 2; index 0 | ||
| 1969 | +// is never incremented) -- the gate's proof that the lifted path ran per depth. | ||
| 1970 | +thread_local! { | ||
| 1971 | + static INTRA_RECT_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 3]> = | ||
| 1972 | + const { std::cell::Cell::new([0; 3]) }; | ||
| 1973 | +} | ||
| 1974 | + | ||
| 1975 | +/// Current value of [`INTRA_RECT_IN_INTER_SPLIT_TX_HITS`], indexed by tx depth. | ||
| 1976 | +pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] { | ||
| 1977 | + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | ||
| 1978 | +} | ||
| 1979 | + | ||
| 1967 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader | 1980 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader |
| 1968 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an | 1981 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an |
| 1969 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 | 1982 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 |
| @@ -6212,7 +6225,9 @@ fn decode_intra_rect_in_inter( | |||
| 6212 | } | 6225 | } |
| 6213 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | 6226 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); |
| 6214 | let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { | 6227 | let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { |
| 6215 | - let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); | 6228 | + // The INTER frame's own `TXFM_CONTEXT` bands, not the key frame's |
| 6229 | + // deblock-grid approximation -- [`tx_size_context_txfm_rect`]. | ||
| 6230 | + let ctx = tx_size_context_txfm_rect(neighbours, (mi_r, mi_c), bw.min(64), bh.min(64)); | ||
| 6216 | match tx_cat { | 6231 | match tx_cat { |
| 6217 | 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | 6232 | 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), |
| 6218 | 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | 6233 | 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), |
| @@ -6223,15 +6238,14 @@ fn decode_intra_rect_in_inter( | |||
| 6223 | }; | 6238 | }; |
| 6224 | if depth != 0 { | 6239 | if depth != 0 { |
| 6225 | TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | 6240 | TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); |
| 6226 | - // merge b51719f+lane-intrarect (class merge-cross-product-defect): | 6241 | + // lane-intrasplit r1: a split intra strip in an inter frame walks the |
| 6227 | - // main's 10-bit `split_transform_intra_block` gate reaches this arm | 6242 | + // key frame's own per-TU path ([`decode_rect_split`] below); what was |
| 6228 | - // with a nonzero tx depth, and the split rect-TU walk mis-decodes it | 6243 | + // wrong when this refusal was written was the depth SYMBOL, not the walk. |
| 6229 | - // (2340 luma samples off at seed 51; refusing here restores that gate | 6244 | + INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(|h| { |
| 6230 | - // while the depth-0 strip the lane proved keeps decoding). The lane's | 6245 | + let mut v = h.get(); |
| 6231 | - // own gate never exercised a split strip. | 6246 | + v[depth.min(2)] += 1; |
| 6232 | - return Err(unsupported( | 6247 | + h.set(v); |
| 6233 | - "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | 6248 | + }); |
| 6234 | - )); | ||
| 6235 | } | 6249 | } |
| 6236 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | 6250 | let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 6237 | let modes = RectStripModes { | 6251 | let modes = RectStripModes { |
| @@ -6265,6 +6279,22 @@ fn decode_intra_rect_in_inter( | |||
| 6265 | base_q_idx, | 6279 | base_q_idx, |
| 6266 | REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | 6280 | REDUCED_TX_SET_INTER.with(std::cell::Cell::get), |
| 6267 | )?; | 6281 | )?; |
| 6282 | + // `set_txfm_ctxs` (libaom `decodeframe.c:1078`, at the end of | ||
| 6283 | + // `decode_token_recon_block`): an INTRA block records its TRANSFORM size in | ||
| 6284 | + // both `TXFM_CONTEXT` bands -- the above row over the block's width, the | ||
| 6285 | + // left column over its height. This arm wrote neither before lane-intrasplit | ||
| 6286 | + // r1, so every later block in the frame read a stale `tx_size`/`txfm_split` | ||
| 6287 | + // context across the strip's footprint. | ||
| 6288 | + for i in 0..bw / MI { | ||
| 6289 | + if let Some(cell) = neighbours.above_txfm.get_mut(mi_c + i) { | ||
| 6290 | + *cell = tx_w as u8; | ||
| 6291 | + } | ||
| 6292 | + } | ||
| 6293 | + for i in 0..bh / MI { | ||
| 6294 | + if let Some(cell) = neighbours.left_txfm.get_mut(mi_r + i) { | ||
| 6295 | + *cell = tx_h as u8; | ||
| 6296 | + } | ||
| 6297 | + } | ||
| 6268 | let class = match bw.max(bh) { | 6298 | let class = match bw.max(bh) { |
| 6269 | 64 => 0, | 6299 | 64 => 0, |
| 6270 | 32 => 1, | 6300 | 32 => 1, |
| @@ -11068,6 +11098,38 @@ fn tx_size_context(n: &Neighbours, (mi_r, mi_c): (usize, usize), own_side: usize | |||
| 11068 | /// a neighbour's var-tx tree splits. [`tx_size_context`]'s deblock-grid | 11098 | /// a neighbour's var-tx tree splits. [`tx_size_context`]'s deblock-grid |
| 11069 | /// approximation coincides with this only while every neighbour codes one | 11099 | /// approximation coincides with this only while every neighbour codes one |
| 11070 | /// whole-block transform, which is exactly what `TxMode::Select` ends. | 11100 | /// whole-block transform, which is exactly what `TxMode::Select` ends. |
| 11101 | +/// [`tx_size_context_txfm`] with the block's own width and height (lane-intrasplit | ||
| 11102 | +/// r1): `get_tx_size_context` compares the neighbour ABOVE against | ||
| 11103 | +/// `tx_size_wide[max_txsize_rect_lookup[bsize]]` and the neighbour to the LEFT | ||
| 11104 | +/// against `tx_size_high[...]` (libaom `pred_common.h:342`), which for a 2:1 | ||
| 11105 | +/// strip are two different numbers. The intra strip inside an inter frame read | ||
| 11106 | +/// this through [`tx_size_context_rect`] -- the key frame's deblock-grid | ||
| 11107 | +/// approximation -- so once `TxMode::Select` made the depth symbol exist, it was | ||
| 11108 | +/// read off the wrong CDF row whenever a neighbour's var-tx tree had split. | ||
| 11109 | +fn tx_size_context_txfm_rect( | ||
| 11110 | + n: &Neighbours, | ||
| 11111 | + (mi_r, mi_c): (usize, usize), | ||
| 11112 | + own_w: usize, | ||
| 11113 | + own_h: usize, | ||
| 11114 | +) -> usize { | ||
| 11115 | + let has_above = mi_r > n.tile_row0_mi; | ||
| 11116 | + let has_left = mi_c > n.tile_col0_mi; | ||
| 11117 | + let mut above = usize::from(n.above_txfm[mi_c]) >= own_w; | ||
| 11118 | + let mut left = usize::from(n.left_txfm[mi_r]) >= own_h; | ||
| 11119 | + if has_above && n.above_inter[mi_c / (SUB / MI)] { | ||
| 11120 | + above = n.above_side_mi[mi_c] >= own_w; | ||
| 11121 | + } | ||
| 11122 | + if has_left && n.left_inter[mi_r / (SUB / MI)] { | ||
| 11123 | + left = n.left_side_mi[mi_r] >= own_h; | ||
| 11124 | + } | ||
| 11125 | + match (has_above, has_left) { | ||
| 11126 | + (true, true) => usize::from(above) + usize::from(left), | ||
| 11127 | + (true, false) => usize::from(above), | ||
| 11128 | + (false, true) => usize::from(left), | ||
| 11129 | + (false, false) => 0, | ||
| 11130 | + } | ||
| 11131 | +} | ||
| 11132 | + | ||
| 11071 | fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize { | 11133 | fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize { |
| 11072 | let has_above = mi_r > n.tile_row0_mi; | 11134 | let has_above = mi_r > n.tile_row0_mi; |
| 11073 | let has_left = mi_c > n.tile_col0_mi; | 11135 | let has_left = mi_c > n.tile_col0_mi; |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -1
| @@ -74,7 +74,6 @@ const REFUSALS: &[&str] = &[ | |||
| 74 | // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the | 74 | // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the |
| 75 | // size-group/category diagonal the 2:1 shapes share. | 75 | // size-group/category diagonal the 2:1 shapes share. |
| 76 | "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | 76 | "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", |
| 77 | - "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | ||
| 78 | // The same arm's screen-content gate: palette/intrabc syntax is consumed | 77 | // The same arm's screen-content gate: palette/intrabc syntax is consumed |
| 79 | // for square blocks only, so a strip in such a frame would skip symbols. | 78 | // for square blocks only, so a strip in such a frame would skip symbols. |
| 80 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", | 79 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", |
crates/ec-av1/src/stream.rsmodified+263 -0
| @@ -4975,6 +4975,7 @@ mod tests { | |||
| 4975 | ); | 4975 | ); |
| 4976 | let stream = out.stdout; | 4976 | let stream = out.stdout; |
| 4977 | let before = decode::intra_in_inter_split_tx_hits(); | 4977 | let before = decode::intra_in_inter_split_tx_hits(); |
| 4978 | + let strip_before = decode::intra_rect_in_inter_split_tx_hits(); | ||
| 4978 | let frames = match decode_stream(&stream) { | 4979 | let frames = match decode_stream(&stream) { |
| 4979 | Ok(frames) => frames, | 4980 | Ok(frames) => frames, |
| 4980 | Err(e) => { | 4981 | Err(e) => { |
| @@ -4988,6 +4989,14 @@ mod tests { | |||
| 4988 | } | 4989 | } |
| 4989 | }; | 4990 | }; |
| 4990 | let after = decode::intra_in_inter_split_tx_hits(); | 4991 | let after = decode::intra_in_inter_split_tx_hits(); |
| 4992 | + // lane-intrasplit r1: this gate is what the split intra-STRIP | ||
| 4993 | + // refusal was protecting, so it prints that counter too. | ||
| 4994 | + let strip_after = decode::intra_rect_in_inter_split_tx_hits(); | ||
| 4995 | + eprintln!( | ||
| 4996 | + "{name} seed={seed}: split intra STRIPS depth1={} depth2={}", | ||
| 4997 | + strip_after[1] - strip_before[1], | ||
| 4998 | + strip_after[2] - strip_before[2] | ||
| 4999 | + ); | ||
| 4991 | let mut per_size = [0usize; 4]; | 5000 | let mut per_size = [0usize; 4]; |
| 4992 | for i in 0..4 { | 5001 | for i in 0..4 { |
| 4993 | per_size[i] = after[i] - before[i]; | 5002 | per_size[i] = after[i] - before[i]; |
| @@ -5061,6 +5070,260 @@ mod tests { | |||
| 5061 | ); | 5070 | ); |
| 5062 | } | 5071 | } |
| 5063 | 5072 | ||
| 5073 | + /// lane-intrasplit r1's decisive gate: a real aomenc INTER sequence in | ||
| 5074 | + /// which aomenc's RD picks an intra-coded HORZ/VERT *strip* (a 2:1 | ||
| 5075 | + /// rectangular partition) inside an inter frame AND splits its luma | ||
| 5076 | + /// transform (`tx_depth >= 1`). Until this round that block was the named | ||
| 5077 | + /// refusal "a split (nonzero tx_depth) transform on an intra HORZ/VERT | ||
| 5078 | + /// strip in an inter frame"; it now walks the key frame's own per-TU path | ||
| 5079 | + /// ([`decode::decode_rect_split`]). Hard-asserts | ||
| 5080 | + /// [`decode::intra_rect_in_inter_split_tx_hits`] per depth: an attempt | ||
| 5081 | + /// that never produced such a block proves nothing, and exhausting every | ||
| 5082 | + /// attempt is a FAILURE, not a SKIP. | ||
| 5083 | + #[test] | ||
| 5084 | + fn a_real_aomenc_inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact() { | ||
| 5085 | + intra_rect_in_inter_split_tx_gate(8); | ||
| 5086 | + } | ||
| 5087 | + | ||
| 5088 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 5089 | + #[test] | ||
| 5090 | + fn a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact() { | ||
| 5091 | + intra_rect_in_inter_split_tx_gate(10); | ||
| 5092 | + } | ||
| 5093 | + | ||
| 5094 | + fn intra_rect_in_inter_split_tx_gate(bit_depth: u32) { | ||
| 5095 | + let name = format!("intra_rect_in_inter_split_tx_gate({bit_depth})"); | ||
| 5096 | + if !have_ffmpeg() { | ||
| 5097 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 5098 | + return; | ||
| 5099 | + } | ||
| 5100 | + if !have_aomenc() { | ||
| 5101 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 5102 | + return; | ||
| 5103 | + } | ||
| 5104 | + let (width, height, frame_count) = (192usize, 128usize, 8usize); | ||
| 5105 | + let mut refusals = Vec::new(); | ||
| 5106 | + let mut uncounted_exact = 0u32; | ||
| 5107 | + let mut counted_exact = 0u32; | ||
| 5108 | + let mut seen = [0usize; 3]; | ||
| 5109 | + for attempt in 0..40u32 { | ||
| 5110 | + let seed = 42 + attempt; | ||
| 5111 | + // MEASURED (r1, 40 attempts): the same sweep the merged | ||
| 5112 | + // `intra_rect_in_inter_gate` had to make -- at `--cpu-used=0` | ||
| 5113 | + // aomenc emits AB partitions regardless of | ||
| 5114 | + // `--enable-ab-partitions=0` (ledger), so the preset is swept | ||
| 5115 | + // 1..4, and the quantiser with it (a hard-cut overlay source at | ||
| 5116 | + // cpu-used=0 stopped 38/40 attempts on other lanes' refusals). | ||
| 5117 | + let cpu = attempt % 5; | ||
| 5118 | + let cq = [30u32, 20, 12, 63][((attempt / 5) % 4) as usize]; | ||
| 5119 | + // A FAST ZOOM: consecutive frames share almost no content, so | ||
| 5120 | + // aomenc's RD codes blocks INTRA inside INTER frames | ||
| 5121 | + // (`--kf-min-dist` forbids a new key frame) -- the only way a | ||
| 5122 | + // real encoder reaches this decoder's intra-in-inter arm -- and | ||
| 5123 | + // the fractal's fine detail is what then splits their transforms. | ||
| 5124 | + let source = format!( | ||
| 5125 | + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | ||
| 5126 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 5127 | + ); | ||
| 5128 | + let y4m = Command::new("ffmpeg") | ||
| 5129 | + .args([ | ||
| 5130 | + "-v", | ||
| 5131 | + "error", | ||
| 5132 | + "-f", | ||
| 5133 | + "lavfi", | ||
| 5134 | + "-i", | ||
| 5135 | + &source, | ||
| 5136 | + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the | ||
| 5137 | + // still-refused directional-chroma gaps never fire and | ||
| 5138 | + // luma detail alone drives the transform split. | ||
| 5139 | + "-vf", | ||
| 5140 | + "hue=s=0", | ||
| 5141 | + "-pix_fmt", | ||
| 5142 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 5143 | + "-strict", | ||
| 5144 | + "-1", | ||
| 5145 | + "-t", | ||
| 5146 | + "0.32", | ||
| 5147 | + "-f", | ||
| 5148 | + "yuv4mpegpipe", | ||
| 5149 | + "-strict", | ||
| 5150 | + "-1", | ||
| 5151 | + "-", | ||
| 5152 | + ]) | ||
| 5153 | + .stdin(Stdio::null()) | ||
| 5154 | + .stdout(Stdio::piped()) | ||
| 5155 | + .stderr(Stdio::piped()) | ||
| 5156 | + .output() | ||
| 5157 | + .expect("ffmpeg failed to run"); | ||
| 5158 | + assert!( | ||
| 5159 | + y4m.status.success(), | ||
| 5160 | + "ffmpeg fixture: {}", | ||
| 5161 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 5162 | + ); | ||
| 5163 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 5164 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 5165 | + } else { | ||
| 5166 | + &[] | ||
| 5167 | + }; | ||
| 5168 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 5169 | + let cpu_arg = format!("--cpu-used={cpu}"); | ||
| 5170 | + let mut child = Command::new(aomenc_path()) | ||
| 5171 | + .args(depth_args) | ||
| 5172 | + .args([ | ||
| 5173 | + "--codec=av1", | ||
| 5174 | + "--passes=1", | ||
| 5175 | + "--end-usage=q", | ||
| 5176 | + &cq_arg, | ||
| 5177 | + &cpu_arg, | ||
| 5178 | + "--lag-in-frames=0", | ||
| 5179 | + "--auto-alt-ref=0", | ||
| 5180 | + "--kf-max-dist=9999", | ||
| 5181 | + "--kf-min-dist=9999", | ||
| 5182 | + "--threads=1", | ||
| 5183 | + "--row-mt=0", | ||
| 5184 | + "--enable-order-hint=0", | ||
| 5185 | + "--enable-warped-motion=0", | ||
| 5186 | + "--enable-obmc=0", | ||
| 5187 | + "--enable-masked-comp=0", | ||
| 5188 | + "--enable-interintra-comp=0", | ||
| 5189 | + "--enable-dist-wtd-comp=0", | ||
| 5190 | + "--enable-diff-wtd-comp=0", | ||
| 5191 | + "--enable-onesided-comp=0", | ||
| 5192 | + "--enable-interintra-wedge=0", | ||
| 5193 | + "--enable-smooth-interintra=0", | ||
| 5194 | + "--enable-ab-partitions=0", | ||
| 5195 | + "--enable-1to4-partitions=0", | ||
| 5196 | + "--enable-filter-intra=0", | ||
| 5197 | + "--enable-smooth-intra=0", | ||
| 5198 | + "--enable-paeth-intra=0", | ||
| 5199 | + "--enable-directional-intra=0", | ||
| 5200 | + "--enable-angle-delta=0", | ||
| 5201 | + "--enable-cdef=0", | ||
| 5202 | + "--enable-restoration=0", | ||
| 5203 | + "--enable-palette=0", | ||
| 5204 | + "--enable-intrabc=0", | ||
| 5205 | + "--enable-cfl-intra=0", | ||
| 5206 | + "--enable-ref-frame-mvs=0", | ||
| 5207 | + "--min-partition-size=32", | ||
| 5208 | + "--max-partition-size=32", | ||
| 5209 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 5210 | + // occurrence of a repeated --enable-* flag): this gate | ||
| 5211 | + // needs the rect partitions the strip lives in and the | ||
| 5212 | + // tx_depth symbol, which exists only under TX_MODE_SELECT. | ||
| 5213 | + "--enable-rect-partitions=1", | ||
| 5214 | + "--enable-tx-size-search=1", | ||
| 5215 | + "--obu", | ||
| 5216 | + "-o", | ||
| 5217 | + "-", | ||
| 5218 | + "-", | ||
| 5219 | + ]) | ||
| 5220 | + .stdin(Stdio::piped()) | ||
| 5221 | + .stdout(Stdio::piped()) | ||
| 5222 | + .stderr(Stdio::piped()) | ||
| 5223 | + .spawn() | ||
| 5224 | + .expect("aomenc failed to start"); | ||
| 5225 | + child | ||
| 5226 | + .stdin | ||
| 5227 | + .take() | ||
| 5228 | + .expect("aomenc stdin") | ||
| 5229 | + .write_all(&y4m.stdout) | ||
| 5230 | + .expect("writing y4m to aomenc"); | ||
| 5231 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 5232 | + assert!( | ||
| 5233 | + out.status.success(), | ||
| 5234 | + "aomenc refused the fixture: {}", | ||
| 5235 | + String::from_utf8_lossy(&out.stderr) | ||
| 5236 | + ); | ||
| 5237 | + let stream = out.stdout; | ||
| 5238 | + let before = decode::intra_rect_in_inter_split_tx_hits(); | ||
| 5239 | + let frames = match decode_stream(&stream) { | ||
| 5240 | + Ok(frames) => frames, | ||
| 5241 | + Err(e) => { | ||
| 5242 | + let msg = e.to_string(); | ||
| 5243 | + assert!( | ||
| 5244 | + msg.contains("unsupported"), | ||
| 5245 | + "{name} decode failed outright (seed {seed} cq {cq}): {msg}" | ||
| 5246 | + ); | ||
| 5247 | + refusals.push(format!("seed {seed} cq {cq} cpu {cpu}: {msg}")); | ||
| 5248 | + continue; | ||
| 5249 | + } | ||
| 5250 | + }; | ||
| 5251 | + let after = decode::intra_rect_in_inter_split_tx_hits(); | ||
| 5252 | + let mut per_depth = [0usize; 3]; | ||
| 5253 | + for i in 0..3 { | ||
| 5254 | + per_depth[i] = after[i] - before[i]; | ||
| 5255 | + } | ||
| 5256 | + // class [[gate-skips-on-its-own-failure]]: a decode that | ||
| 5257 | + // succeeded is ALWAYS pixel-compared below; the counter only | ||
| 5258 | + // decides whether the attempt counts as firing. | ||
| 5259 | + let counted = per_depth[1] + per_depth[2] != 0; | ||
| 5260 | + if !counted { | ||
| 5261 | + uncounted_exact += 1; | ||
| 5262 | + refusals.push(format!( | ||
| 5263 | + "seed {seed} cq {cq} cpu {cpu}: decoded and pixel-compared, but no intra rect strip \ | ||
| 5264 | + in an inter frame split its transform" | ||
| 5265 | + )); | ||
| 5266 | + } | ||
| 5267 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 5268 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 5269 | + } else { | ||
| 5270 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 5271 | + }; | ||
| 5272 | + assert_eq!(frames.len(), frame_count); | ||
| 5273 | + eprintln!( | ||
| 5274 | + "{name} seed={seed} cq={cq} cpu={cpu}: split intra strips depth1={} depth2={}", | ||
| 5275 | + per_depth[1], per_depth[2] | ||
| 5276 | + ); | ||
| 5277 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 5278 | + for (plane, (g, w)) in [ | ||
| 5279 | + ("Y", (&got.y, &want.y)), | ||
| 5280 | + ("U", (&got.u, &want.u)), | ||
| 5281 | + ("V", (&got.v, &want.v)), | ||
| 5282 | + ] { | ||
| 5283 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 5284 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 5285 | + eprintln!( | ||
| 5286 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ | ||
| 5287 | + want {} ({} samples differ)", | ||
| 5288 | + at % stride, | ||
| 5289 | + at / stride, | ||
| 5290 | + g[at], | ||
| 5291 | + w[at], | ||
| 5292 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 5293 | + ); | ||
| 5294 | + } | ||
| 5295 | + } | ||
| 5296 | + } | ||
| 5297 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 5298 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed} cq {cq})"); | ||
| 5299 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed} cq {cq})"); | ||
| 5300 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed} cq {cq})"); | ||
| 5301 | + } | ||
| 5302 | + if counted { | ||
| 5303 | + counted_exact += 1; | ||
| 5304 | + seen[1] += per_depth[1]; | ||
| 5305 | + seen[2] += per_depth[2]; | ||
| 5306 | + // Keep sweeping until BOTH reachable depths have been seen in | ||
| 5307 | + // a pixel-exact attempt; one firing attempt is the floor. | ||
| 5308 | + if seen[1] != 0 && seen[2] != 0 { | ||
| 5309 | + break; | ||
| 5310 | + } | ||
| 5311 | + } | ||
| 5312 | + } | ||
| 5313 | + gate_buckets( | ||
| 5314 | + &name, | ||
| 5315 | + counted_exact, | ||
| 5316 | + uncounted_exact, | ||
| 5317 | + refusals.len() - uncounted_exact as usize, | ||
| 5318 | + ); | ||
| 5319 | + eprintln!("{name}: split strips seen depth1={} depth2={}", seen[1], seen[2]); | ||
| 5320 | + assert!( | ||
| 5321 | + seen[1] + seen[2] != 0, | ||
| 5322 | + "{name} never observed a split-transform intra strip in an inter frame:\n{}", | ||
| 5323 | + refusals.join("\n") | ||
| 5324 | + ); | ||
| 5325 | + } | ||
| 5326 | + | ||
| 5064 | /// lane-fiinter r1 (class [[symbol-consumption-gap]] + | 5327 | /// lane-fiinter r1 (class [[symbol-consumption-gap]] + |
| 5065 | /// [[tool-disabled-in-every-gate]]): a real aomenc inter sequence with | 5328 | /// [[tool-disabled-in-every-gate]]): a real aomenc inter sequence with |
| 5066 | /// `--enable-filter-intra=1` (aomenc's own default -- every inter gate | 5329 | /// `--enable-filter-intra=1` (aomenc's own default -- every inter gate |
lanes/intrasplit-r1.report.mdadded+69 -0
| @@ -0,0 +1,69 @@ | |||
| 1 | +# lane-intrasplit r1 — RED (refusal lifted, two root causes fixed, gate never fired) | ||
| 2 | + | ||
| 3 | +Base: 18bf7dc. Branch: lane-intrasplit. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | +- `crates/ec-av1/src/decode.rs:6225` — the refusal "a split (nonzero tx_depth) transform on | ||
| 7 | + an intra HORZ/VERT strip in an inter frame" is gone; a nonzero depth now walks the key | ||
| 8 | + frame's own per-TU path (`depth_to_tx_wh` + `decode_rect_split`, already wired) and bumps | ||
| 9 | + the new per-depth counter. | ||
| 10 | +- `crates/ec-av1/src/decode.rs` (`tx_size_context_txfm_rect`, new, above | ||
| 11 | + `tx_size_context_txfm`) — ROOT CAUSE 1: the arm read its `tx_depth` symbol through | ||
| 12 | + `tx_size_context_rect`, the KEY FRAME's deblock-grid approximation. libaom | ||
| 13 | + `get_tx_size_context` (pred_common.h:342, called from `read_selected_tx_size`, | ||
| 14 | + decodemv.c) reads the two `TXFM_CONTEXT` bands and, for an INTER neighbour, that | ||
| 15 | + neighbour's BLOCK width/height instead. Class [[cdf-row-held-constant]]: wrong CDF row, | ||
| 16 | + same value most of the time, different range. | ||
| 17 | +- `crates/ec-av1/src/decode.rs` (tail of `decode_intra_rect_in_inter`) — ROOT CAUSE 2: | ||
| 18 | + the strip never wrote its own `TXFM_CONTEXT` bands (`set_txfm_ctxs`, | ||
| 19 | + decodeframe.c end of `decode_token_recon_block`), because the call site | ||
| 20 | + (decode.rs:18210) returns early. Every later block in the frame read a stale | ||
| 21 | + `tx_size`/`txfm_split` context across the strip's footprint. | ||
| 22 | +- `crates/ec-av1/src/refusal_inventory.rs` — inventory line dropped. | ||
| 23 | +- `crates/ec-av1/src/stream.rs` — new gate | ||
| 24 | + `a_real_aomenc_{,10bit_}inter_sequence_with_a_split_transform_intra_strip_decodes_pixel_exact` | ||
| 25 | + (192x128, 8 frames, real aomenc, `--enable-rect-partitions=1 --enable-tx-size-search=1`, | ||
| 26 | + `--kf-max-dist/-min-dist=9999 --lag-in-frames=0`, cpu-used and cq (incl. 63) swept, | ||
| 27 | + each flag spelled once with the rect/tx overrides LAST) hard-asserting | ||
| 28 | + `decode::intra_rect_in_inter_split_tx_hits()` per depth. | ||
| 29 | + | ||
| 30 | +## Gate result: RED (never fired) | ||
| 31 | +`cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_a_split_transform_intra_strip` | ||
| 32 | +40/40 attempts stop at OTHER lanes' named refusals; 0 attempts decoded whole, so the lift is | ||
| 33 | +UNGATED and this branch MUST NOT merge as-is. | ||
| 34 | + | ||
| 35 | +EVIDENCE: $HOME/.cache/intrasplit-suite-r1.log | 40-attempt sweep, min/max-partition 32/32, | ||
| 36 | +cpu 0..4, cq 30/20/12/63, zoom-mandelbrot source | refusal histogram: | ||
| 37 | +intra 1:4 strip 9, non-skip inter rect strip 7, inter 16x16 AB/1:4 7, inter SB AB 4, | ||
| 38 | +1:4 inter strip split w/ 64 axis 3, inter sub-8 3, split intra strip w/ 64x32 unit 2, | ||
| 39 | +32x64 unit 2, Golomb tail 2, 8x8 non-DC chroma 1. | ||
| 40 | +Six recipe families were swept (192x128 and 96x96; min/max partition 16/32, 16/64, 32/64, | ||
| 41 | +32/32; hard-cut overlay and fast-zoom sources; sb-size 64): every stream that makes aomenc | ||
| 42 | +pick an intra 2:1 strip with a split transform also carries one of the refusals above. | ||
| 43 | +Same shape as the recorded lane-intra14 r1 and lane-r14 r3 gate hunts. | ||
| 44 | + | ||
| 45 | +## Film probes (charter) | ||
| 46 | +EVIDENCE: scratchpad/intrasplit/{reelb1200,reelc1800}.obu | `ffmpeg -ss 1200/-ss 1800 -t 2 -c:v copy -f obu` | ||
| 47 | +then `cargo run -p ec-av1 --example decode_probe` | new stops: | ||
| 48 | +- ReelB -ss 1200: `a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular | ||
| 49 | + residual coding` (was the split-intra-strip refusal per census4) — 0 frames in | ||
| 50 | + EC_AV1_FINAL_DUMP. | ||
| 51 | +- ReelC -ss 1800: `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path` | ||
| 52 | + (lane-intra14's surface) — 0 frames in EC_AV1_FINAL_DUMP. No 128-superblock refusal was | ||
| 53 | + reached on this segment. | ||
| 54 | + | ||
| 55 | +## Suite | ||
| 56 | +`cargo test -p ec-av1 --lib` (systemd unit, MemoryMax=10G) — see | ||
| 57 | +`$HOME/.cache/intrasplit-suite-r1.log`; totals in the handoff line below. | ||
| 58 | +The two new gate tests FAIL by construction (never fired). One further failure, | ||
| 59 | +`a_real_aomenc_stream_with_film_grain_decodes_pixel_exact`, is being triaged against the | ||
| 60 | +base commit (`$HOME/.cache/intrasplit-base-filmgrain.log`). | ||
| 61 | + | ||
| 62 | +## Residue | ||
| 63 | +- fix-now (next round): make the gate fire. The only untried levers are a content family | ||
| 64 | + that yields 32x16/16x32 intra strips with NO 1:4 or AB partition anywhere in the frame, | ||
| 65 | + or waiting on lane-intra14 (1:4 intra strips) and lane-r14 (inter rect leaves) — both | ||
| 66 | + would remove the two dominant blockers. | ||
| 67 | +- deferred(lane-r14/lane-intra14): the two 64-axis strip refusals ("split intra strip whose | ||
| 68 | + transform unit is 64x32/32x64") are this arm's neighbours but need rectangular 64-axis | ||
| 69 | + luma coefficient tables. | ||