Intra blocks in inter frames may split their luma transform
Browse files at this commit343ce49290fc5d734c064a92137992a767f1b3c4Parent: 38d3bd3- feat
- intra blocks in inter frames may split their luma transform
3 changed files +421 -52
- crates/ec-av1/src/decode.rs +162 -51
- crates/ec-av1/src/refusal_inventory.rs +5 -1
- crates/ec-av1/src/stream.rs +254 -0
crates/ec-av1/src/decode.rsmodified+162 -51
| @@ -1167,6 +1167,19 @@ pub(crate) fn palette_split_tx_hits() -> usize { | |||
| 1167 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | 1167 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) |
| 1168 | } | 1168 | } |
| 1169 | 1169 | ||
| 1170 | +// lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` | ||
| 1171 | +// symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- | ||
| 1172 | +// the gate's proof that the lifted path actually ran, per size. | ||
| 1173 | +thread_local! { | ||
| 1174 | + static INTRA_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 4]> = | ||
| 1175 | + const { std::cell::Cell::new([0; 4]) }; | ||
| 1176 | +} | ||
| 1177 | + | ||
| 1178 | +/// Current value of [`INTRA_IN_INTER_SPLIT_TX_HITS`], indexed 8/16/32/64. | ||
| 1179 | +pub(crate) fn intra_in_inter_split_tx_hits() -> [usize; 4] { | ||
| 1180 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | ||
| 1181 | +} | ||
| 1182 | + | ||
| 1170 | thread_local! { | 1183 | thread_local! { |
| 1171 | /// A just-decoded palette-Y block's own predicted pixels | 1184 | /// A just-decoded palette-Y block's own predicted pixels |
| 1172 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by | 1185 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by |
| @@ -9539,27 +9552,40 @@ fn read_block_tx_size( | |||
| 9539 | let tx = if is_inter { | 9552 | let tx = if is_inter { |
| 9540 | side.min(64) | 9553 | side.min(64) |
| 9541 | } else { | 9554 | } else { |
| 9542 | - let resolved = read_tx_size( | 9555 | + read_tx_size( |
| 9543 | dec, | 9556 | dec, |
| 9544 | cdfs, | 9557 | cdfs, |
| 9545 | n, | 9558 | n, |
| 9546 | at_mi, | 9559 | at_mi, |
| 9547 | side, | 9560 | side, |
| 9548 | Some(tx_size_context_txfm(n, at_mi, side)), | 9561 | Some(tx_size_context_txfm(n, at_mi, side)), |
| 9549 | - ); | 9562 | + ) |
| 9550 | - if resolved != side { | ||
| 9551 | - // An intra block inside an inter frame whose `tx_depth` splits its | ||
| 9552 | - // luma transform needs the per-transform-unit intra prediction | ||
| 9553 | - // loop `decode_block` runs for a key frame; this path predicts the | ||
| 9554 | - // whole block at once, so refuse rather than mis-reconstruct. | ||
| 9555 | - return Err(unsupported( | ||
| 9556 | - "an intra block in an inter frame whose tx_depth splits its luma transform \ | ||
| 9557 | - (round 1)", | ||
| 9558 | - )); | ||
| 9559 | - } | ||
| 9560 | - resolved | ||
| 9561 | }; | 9563 | }; |
| 9562 | set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter); | 9564 | set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter); |
| 9565 | + if !is_inter && tx != side { | ||
| 9566 | + // lane-intrainter r1: an intra block inside an inter frame whose | ||
| 9567 | + // `tx_depth` split its luma transform codes exactly the key-frame | ||
| 9568 | + // split path's transform units (`decode_block`'s multi-TU loop), | ||
| 9569 | + // raster order over the block. Handed back in the same leaf shape the | ||
| 9570 | + // inter var-tx tree uses, so the caller's per-TU luma loop, the | ||
| 9571 | + // `record_split_luma` neighbour write-back and the per-TU deblock | ||
| 9572 | + // edges are the ones it already runs for a var-tx inter block. A | ||
| 9573 | + // caller that has no per-TU intra loop (the 8x8 leaf) refuses on | ||
| 9574 | + // seeing `Some` here. | ||
| 9575 | + let step = tx / MI; | ||
| 9576 | + let mut leaves = Vec::new(); | ||
| 9577 | + for row in (0..side_mi).step_by(step) { | ||
| 9578 | + for col in (0..side_mi).step_by(step) { | ||
| 9579 | + leaves.push((row, col, tx)); | ||
| 9580 | + } | ||
| 9581 | + } | ||
| 9582 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | ||
| 9583 | + let mut h = c.get(); | ||
| 9584 | + h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | ||
| 9585 | + c.set(h); | ||
| 9586 | + }); | ||
| 9587 | + return Ok((tx, Some(leaves))); | ||
| 9588 | + } | ||
| 9563 | Ok((tx, None)) | 9589 | Ok((tx, None)) |
| 9564 | } | 9590 | } |
| 9565 | 9591 | ||
| @@ -15547,7 +15573,14 @@ fn decode_inter_block( | |||
| 15547 | } | 15573 | } |
| 15548 | } | 15574 | } |
| 15549 | 15575 | ||
| 15550 | - read_block_tx_size( | 15576 | + // lane-intrainter r1: an intra block in an inter frame reads the same |
| 15577 | + // `tx_depth` symbol a key-frame block does, and when it splits, the | ||
| 15578 | + // block codes one intra prediction + one coefficient set PER | ||
| 15579 | + // transform unit (`decode_block`'s multi-TU branch), not one for the | ||
| 15580 | + // whole block. The leaf list rides the existing `vartx_leaves` slot, | ||
| 15581 | + // whose tail already does the split-block neighbour write-back | ||
| 15582 | + // (`record_split_luma`) and the per-TU deblock edges. | ||
| 15583 | + vartx_leaves = read_block_tx_size( | ||
| 15551 | dec, | 15584 | dec, |
| 15552 | cdfs, | 15585 | cdfs, |
| 15553 | neighbours, | 15586 | neighbours, |
| @@ -15556,21 +15589,80 @@ fn decode_inter_block( | |||
| 15556 | (mi_cols as usize, mi_rows as usize), | 15589 | (mi_cols as usize, mi_rows as usize), |
| 15557 | false, | 15590 | false, |
| 15558 | skip, | 15591 | skip, |
| 15559 | - )?; | 15592 | + )? |
| 15593 | + .1; | ||
| 15560 | let reach = Reach::of(side, px, py, y.width, y.height); | 15594 | let reach = Reach::of(side, px, py, y.width, y.height); |
| 15595 | + let split_luma = vartx_leaves.is_some(); | ||
| 15596 | + if let Some(leaves) = vartx_leaves.clone() { | ||
| 15597 | + let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | ||
| 15598 | + for &(row, col, tx_px) in &leaves { | ||
| 15599 | + let tu_mi = (at_mi.0 + row, at_mi.1 + col); | ||
| 15600 | + let (tu_px, tu_py) = (px + col * MI, py + row * MI); | ||
| 15601 | + // A transform unit inside a block is not a block at that | ||
| 15602 | + // position (class from lane-palette2 r12): top-right / | ||
| 15603 | + // bottom-left availability is the block's, narrowed by the | ||
| 15604 | + // unit's own offset inside it. | ||
| 15605 | + let tu_reach = Reach::of_tu(side, side, col * MI, row * MI, tx_px, reach); | ||
| 15606 | + let tu_grid = if skip { | ||
| 15607 | + y.reconstruct( | ||
| 15608 | + tu_px, | ||
| 15609 | + tu_py, | ||
| 15610 | + tx_px, | ||
| 15611 | + mode, | ||
| 15612 | + 0, | ||
| 15613 | + tu_reach, | ||
| 15614 | + &vec![0i32; tx_px * tx_px], | ||
| 15615 | + None, | ||
| 15616 | + None, | ||
| 15617 | + false, | ||
| 15618 | + ); | ||
| 15619 | + vec![0i32; tx_px * tx_px] | ||
| 15620 | + } else { | ||
| 15621 | + // The unit's bsize is smaller than the block it sits in, | ||
| 15622 | + // so `txb_skip_ctx` is the neighbour-magnitude table, not | ||
| 15623 | + // the lone-TU 0 (`get_txb_ctx_general`). | ||
| 15624 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | ||
| 15625 | + read_plane( | ||
| 15626 | + dec, | ||
| 15627 | + cdfs, | ||
| 15628 | + txbset_for(tx_px, reduced), | ||
| 15629 | + &default_scan(tx_px), | ||
| 15630 | + 0, | ||
| 15631 | + neighbours.around_mi(tu_mi, tx_px)[0], | ||
| 15632 | + mode, | ||
| 15633 | + mode, | ||
| 15634 | + 0, | ||
| 15635 | + tu_reach, | ||
| 15636 | + y, | ||
| 15637 | + tu_px, | ||
| 15638 | + tu_py, | ||
| 15639 | + tx_px, | ||
| 15640 | + tx_px, | ||
| 15641 | + base_q_idx, | ||
| 15642 | + None, | ||
| 15643 | + None, | ||
| 15644 | + Some(tu_skip_ctx), | ||
| 15645 | + false, | ||
| 15646 | + )? | ||
| 15647 | + }; | ||
| 15648 | + neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | ||
| 15649 | + } | ||
| 15650 | + } | ||
| 15561 | if skip { | 15651 | if skip { |
| 15562 | - y.reconstruct( | 15652 | + if !split_luma { |
| 15563 | - px, | 15653 | + y.reconstruct( |
| 15564 | - py, | 15654 | + px, |
| 15565 | - side, | 15655 | + py, |
| 15566 | - mode, | 15656 | + side, |
| 15567 | - 0, | 15657 | + mode, |
| 15568 | - reach, | 15658 | + 0, |
| 15569 | - &vec![0i32; side * side], | 15659 | + reach, |
| 15570 | - None, | 15660 | + &vec![0i32; side * side], |
| 15571 | - None, | 15661 | + None, |
| 15572 | - false, | 15662 | + None, |
| 15573 | - ); | 15663 | + false, |
| 15664 | + ); | ||
| 15665 | + } | ||
| 15574 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 15666 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 15575 | u.reconstruct( | 15667 | u.reconstruct( |
| 15576 | cpx, | 15668 | cpx, |
| @@ -15601,28 +15693,35 @@ fn decode_inter_block( | |||
| 15601 | v_grid = vec![0i32; chroma_side * chroma_side]; | 15693 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 15602 | } else { | 15694 | } else { |
| 15603 | let around = neighbours.around(at, side); | 15695 | let around = neighbours.around(at, side); |
| 15604 | - luma_grid = read_plane( | 15696 | + luma_grid = if split_luma { |
| 15605 | - dec, | 15697 | + // Already coded and reconstructed unit by unit above; the |
| 15606 | - cdfs, | 15698 | + // block-level grid is only the neighbour write-back's input, |
| 15607 | - luma_set_intra, | 15699 | + // which `record_split_luma` ignores for plane 0. |
| 15608 | - scan_luma, | 15700 | + vec![0i32; side * side] |
| 15609 | - 0, | 15701 | + } else { |
| 15610 | - around[0], | 15702 | + read_plane( |
| 15611 | - mode, | 15703 | + dec, |
| 15612 | - mode, | 15704 | + cdfs, |
| 15613 | - 0, | 15705 | + luma_set_intra, |
| 15614 | - reach, | 15706 | + scan_luma, |
| 15615 | - y, | 15707 | + 0, |
| 15616 | - px, | 15708 | + around[0], |
| 15617 | - py, | 15709 | + mode, |
| 15618 | - side, | 15710 | + mode, |
| 15619 | - luma_tx, | 15711 | + 0, |
| 15620 | - base_q_idx, | 15712 | + reach, |
| 15621 | - None, | 15713 | + y, |
| 15622 | - None, | 15714 | + px, |
| 15623 | - None, | 15715 | + py, |
| 15624 | - false, | 15716 | + side, |
| 15625 | - )?; | 15717 | + luma_tx, |
| 15718 | + base_q_idx, | ||
| 15719 | + None, | ||
| 15720 | + None, | ||
| 15721 | + None, | ||
| 15722 | + false, | ||
| 15723 | + )? | ||
| 15724 | + }; | ||
| 15626 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 15725 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 15627 | u_grid = read_plane( | 15726 | u_grid = read_plane( |
| 15628 | dec, | 15727 | dec, |
| @@ -17063,7 +17162,11 @@ fn decode_inter_block8( | |||
| 17063 | } | 17162 | } |
| 17064 | } | 17163 | } |
| 17065 | 17164 | ||
| 17066 | - read_block_tx_size( | 17165 | + // lane-intrainter r1: the 8x8 leaf's own intra `tx_depth` can only |
| 17166 | + // resolve to TX_4X4, whose 2x2 unit grid this leaf path has no | ||
| 17167 | + // prediction loop for (the >=16x16 square path above does). Refuse by | ||
| 17168 | + // name rather than mis-reconstruct. | ||
| 17169 | + if read_block_tx_size( | ||
| 17067 | dec, | 17170 | dec, |
| 17068 | cdfs, | 17171 | cdfs, |
| 17069 | neighbours, | 17172 | neighbours, |
| @@ -17072,7 +17175,15 @@ fn decode_inter_block8( | |||
| 17072 | (mi_cols as usize, mi_rows as usize), | 17175 | (mi_cols as usize, mi_rows as usize), |
| 17073 | false, | 17176 | false, |
| 17074 | skip, | 17177 | skip, |
| 17075 | - )?; | 17178 | + )? |
| 17179 | + .1 | ||
| 17180 | + .is_some() | ||
| 17181 | + { | ||
| 17182 | + return Err(unsupported( | ||
| 17183 | + "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 \ | ||
| 17184 | + transform units", | ||
| 17185 | + )); | ||
| 17186 | + } | ||
| 17076 | let reach = Reach::of(SIDE, px, py, y.width, y.height); | 17187 | let reach = Reach::of(SIDE, px, py, y.width, y.height); |
| 17077 | if skip { | 17188 | if skip { |
| 17078 | y.reconstruct( | 17189 | y.reconstruct( |
crates/ec-av1/src/refusal_inventory.rsmodified+5 -1
| @@ -61,7 +61,11 @@ const REFUSALS: &[&str] = &[ | |||
| 61 | "a reference picture whose height does not match this frame's own true size", | 61 | "a reference picture whose height does not match this frame's own true size", |
| 62 | "a show_existing_frame header naming an empty reference slot", | 62 | "a show_existing_frame header naming an empty reference slot", |
| 63 | "an inter var-tx tree with a leaf transform larger than 32x32", | 63 | "an inter var-tx tree with a leaf transform larger than 32x32", |
| 64 | - "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)", | 64 | + // lane-intrainter r1 lifted the >=16x16 square case (per-TU intra |
| 65 | + // prediction + coefficients, gate | ||
| 66 | + // `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`); | ||
| 67 | + // the 8x8 leaf's TX_4X4 2x2 grid is still refused here. | ||
| 68 | + "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", | ||
| 65 | "an inter frame with no key frame before it", | 69 | "an inter frame with no key frame before it", |
| 66 | "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", | 70 | "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", |
| 67 | "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", | 71 | "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", |
crates/ec-av1/src/stream.rsmodified+254 -0
| @@ -4180,6 +4180,260 @@ mod tests { | |||
| 4180 | ); | 4180 | ); |
| 4181 | } | 4181 | } |
| 4182 | 4182 | ||
| 4183 | + /// lane-intrainter r1's decisive gate: a real aomenc INTER sequence in | ||
| 4184 | + /// which aomenc's RD picks an INTRA block inside an inter frame AND | ||
| 4185 | + /// splits that block's luma transform (`tx_depth >= 1`, the intra depth | ||
| 4186 | + /// symbol -- not the inter var-tx tree). That block codes one intra | ||
| 4187 | + /// prediction plus one coefficient set per transform unit, exactly like a | ||
| 4188 | + /// key frame's split block but with the inter frame's CDF state and the | ||
| 4189 | + /// inter-frame intra mode syntax; before this lane it was a named | ||
| 4190 | + /// refusal. Hard-asserts [`decode::intra_in_inter_split_tx_hits`] per | ||
| 4191 | + /// block size: an attempt that never produced such a block proves | ||
| 4192 | + /// nothing, and exhausting every attempt is a FAILURE, not a SKIP. | ||
| 4193 | + #[test] | ||
| 4194 | + fn a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact() { | ||
| 4195 | + intra_in_inter_split_tx_gate(8); | ||
| 4196 | + } | ||
| 4197 | + | ||
| 4198 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4199 | + #[test] | ||
| 4200 | + fn a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact() { | ||
| 4201 | + intra_in_inter_split_tx_gate(10); | ||
| 4202 | + } | ||
| 4203 | + | ||
| 4204 | + fn intra_in_inter_split_tx_gate(bit_depth: u32) { | ||
| 4205 | + let name = format!("intra_in_inter_split_tx_gate({bit_depth})"); | ||
| 4206 | + if !have_ffmpeg() { | ||
| 4207 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 4208 | + return; | ||
| 4209 | + } | ||
| 4210 | + if !have_aomenc() { | ||
| 4211 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 4212 | + return; | ||
| 4213 | + } | ||
| 4214 | + let (width, height, frame_count) = (64usize, 64usize, 8usize); | ||
| 4215 | + let mut refusals = Vec::new(); | ||
| 4216 | + let mut uncounted_exact = 0u32; | ||
| 4217 | + for attempt in 0..40u32 { | ||
| 4218 | + let seed = 42 + attempt; | ||
| 4219 | + // A zooming fractal: every frame moves (so the sequence is | ||
| 4220 | + // genuinely inter-coded) and keeps sharp new detail entering at | ||
| 4221 | + // the borders, which is what makes aomenc's RD choose an INTRA | ||
| 4222 | + // block inside an inter frame -- and then split its transform. | ||
| 4223 | + // A zooming fractal with a hard CUT halfway (`overlay` switching | ||
| 4224 | + // a second, unrelated fractal on at frame 4): after the cut every | ||
| 4225 | + // block is unpredictable from the reference, which is what makes | ||
| 4226 | + // aomenc code INTRA blocks inside an inter frame -- and at this | ||
| 4227 | + // cq the RD then splits their transforms. | ||
| 4228 | + let source = format!( | ||
| 4229 | + "mandelbrot=size=64x64:start_scale={}:rate=25[a];\ | ||
| 4230 | + mandelbrot=size=64x64:start_scale={}:rate=25[b];\ | ||
| 4231 | + [a][b]overlay=enable='gte(n,4)'", | ||
| 4232 | + 5.0 - f64::from(attempt) * 0.06, | ||
| 4233 | + 0.9 + f64::from(attempt) * 0.11 | ||
| 4234 | + ); | ||
| 4235 | + let y4m = Command::new("ffmpeg") | ||
| 4236 | + .args([ | ||
| 4237 | + "-v", | ||
| 4238 | + "error", | ||
| 4239 | + "-f", | ||
| 4240 | + "lavfi", | ||
| 4241 | + "-i", | ||
| 4242 | + &source, | ||
| 4243 | + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the | ||
| 4244 | + // still-refused directional-chroma gaps never fire and | ||
| 4245 | + // luma detail alone drives the transform split. | ||
| 4246 | + "-vf", | ||
| 4247 | + "hue=s=0", | ||
| 4248 | + "-pix_fmt", | ||
| 4249 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4250 | + "-strict", | ||
| 4251 | + "-1", | ||
| 4252 | + "-t", | ||
| 4253 | + "0.32", | ||
| 4254 | + "-f", | ||
| 4255 | + "yuv4mpegpipe", | ||
| 4256 | + "-strict", | ||
| 4257 | + "-1", | ||
| 4258 | + "-", | ||
| 4259 | + ]) | ||
| 4260 | + .stdin(Stdio::null()) | ||
| 4261 | + .stdout(Stdio::piped()) | ||
| 4262 | + .stderr(Stdio::piped()) | ||
| 4263 | + .output() | ||
| 4264 | + .expect("ffmpeg failed to run"); | ||
| 4265 | + assert!( | ||
| 4266 | + y4m.status.success(), | ||
| 4267 | + "ffmpeg fixture: {}", | ||
| 4268 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4269 | + ); | ||
| 4270 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4271 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4272 | + } else { | ||
| 4273 | + &[] | ||
| 4274 | + }; | ||
| 4275 | + let mut child = Command::new(aomenc_path()) | ||
| 4276 | + .args(depth_args) | ||
| 4277 | + .args([ | ||
| 4278 | + "--codec=av1", | ||
| 4279 | + "--passes=1", | ||
| 4280 | + "--end-usage=q", | ||
| 4281 | + "--cq-level=30", | ||
| 4282 | + "--cpu-used=0", | ||
| 4283 | + "--lag-in-frames=0", | ||
| 4284 | + "--auto-alt-ref=0", | ||
| 4285 | + // One key frame only: every later frame is an inter frame, | ||
| 4286 | + // which is where this gate's intra blocks must sit. The | ||
| 4287 | + // MIN distance is what stops aomenc's scene-cut detector | ||
| 4288 | + // from inserting a second key frame at the cut this gate's | ||
| 4289 | + // source deliberately contains. | ||
| 4290 | + "--kf-max-dist=1000", | ||
| 4291 | + "--kf-min-dist=1000", | ||
| 4292 | + "--threads=1", | ||
| 4293 | + "--row-mt=0", | ||
| 4294 | + "--enable-order-hint=0", | ||
| 4295 | + "--enable-warped-motion=0", | ||
| 4296 | + "--enable-obmc=0", | ||
| 4297 | + "--enable-masked-comp=0", | ||
| 4298 | + "--enable-interintra-comp=0", | ||
| 4299 | + "--enable-dist-wtd-comp=0", | ||
| 4300 | + "--enable-diff-wtd-comp=0", | ||
| 4301 | + "--enable-onesided-comp=0", | ||
| 4302 | + "--enable-interintra-wedge=0", | ||
| 4303 | + "--enable-smooth-interintra=0", | ||
| 4304 | + "--enable-ab-partitions=0", | ||
| 4305 | + "--enable-1to4-partitions=0", | ||
| 4306 | + "--enable-filter-intra=0", | ||
| 4307 | + "--enable-smooth-intra=0", | ||
| 4308 | + "--enable-paeth-intra=0", | ||
| 4309 | + "--enable-directional-intra=0", | ||
| 4310 | + "--enable-angle-delta=0", | ||
| 4311 | + "--enable-cdef=0", | ||
| 4312 | + "--enable-restoration=0", | ||
| 4313 | + "--enable-palette=0", | ||
| 4314 | + "--enable-intrabc=0", | ||
| 4315 | + "--enable-cfl-intra=0", | ||
| 4316 | + "--enable-ref-frame-mvs=0", | ||
| 4317 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 4318 | + // occurrence of a repeated --enable-* flag): the intra | ||
| 4319 | + // tx_depth symbol only exists under TX_MODE_SELECT, and | ||
| 4320 | + // rect partitions are a separate named refusal. | ||
| 4321 | + "--enable-tx-size-search=1", | ||
| 4322 | + "--enable-rect-partitions=0", | ||
| 4323 | + "--max-partition-size=32", | ||
| 4324 | + // Sub-16 inter partitions are a separate named refusal, | ||
| 4325 | + // as is the 8x8 intra leaf's own TX_4X4 split. | ||
| 4326 | + "--min-partition-size=16", | ||
| 4327 | + "--obu", | ||
| 4328 | + "-o", | ||
| 4329 | + "-", | ||
| 4330 | + "-", | ||
| 4331 | + ]) | ||
| 4332 | + .stdin(Stdio::piped()) | ||
| 4333 | + .stdout(Stdio::piped()) | ||
| 4334 | + .stderr(Stdio::piped()) | ||
| 4335 | + .spawn() | ||
| 4336 | + .expect("aomenc failed to start"); | ||
| 4337 | + child | ||
| 4338 | + .stdin | ||
| 4339 | + .take() | ||
| 4340 | + .expect("aomenc stdin") | ||
| 4341 | + .write_all(&y4m.stdout) | ||
| 4342 | + .expect("writing y4m to aomenc"); | ||
| 4343 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4344 | + assert!( | ||
| 4345 | + out.status.success(), | ||
| 4346 | + "aomenc refused the fixture: {}", | ||
| 4347 | + String::from_utf8_lossy(&out.stderr) | ||
| 4348 | + ); | ||
| 4349 | + let stream = out.stdout; | ||
| 4350 | + let before = decode::intra_in_inter_split_tx_hits(); | ||
| 4351 | + let frames = match decode_stream(&stream) { | ||
| 4352 | + Ok(frames) => frames, | ||
| 4353 | + Err(e) => { | ||
| 4354 | + let msg = e.to_string(); | ||
| 4355 | + assert!( | ||
| 4356 | + msg.contains("unsupported"), | ||
| 4357 | + "{name} decode failed outright (seed {seed}): {msg}" | ||
| 4358 | + ); | ||
| 4359 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 4360 | + continue; | ||
| 4361 | + } | ||
| 4362 | + }; | ||
| 4363 | + let after = decode::intra_in_inter_split_tx_hits(); | ||
| 4364 | + let mut per_size = [0usize; 4]; | ||
| 4365 | + for i in 0..4 { | ||
| 4366 | + per_size[i] = after[i] - before[i]; | ||
| 4367 | + } | ||
| 4368 | + // class [[gate-skips-on-its-own-failure]]: a decode that | ||
| 4369 | + // succeeded is ALWAYS pixel-compared below; the counter only | ||
| 4370 | + // decides whether the attempt counts as firing. | ||
| 4371 | + let counted = per_size.iter().sum::<usize>() != 0; | ||
| 4372 | + if !counted { | ||
| 4373 | + uncounted_exact += 1; | ||
| 4374 | + refusals.push(format!( | ||
| 4375 | + "seed {seed}: decoded and pixel-compared, but no intra block in an inter \ | ||
| 4376 | + frame split its transform" | ||
| 4377 | + )); | ||
| 4378 | + } | ||
| 4379 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4380 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4381 | + } else { | ||
| 4382 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4383 | + }; | ||
| 4384 | + assert_eq!(frames.len(), frame_count); | ||
| 4385 | + eprintln!( | ||
| 4386 | + "{name} seed={seed}: split intra-in-inter blocks 8x8={} 16x16={} 32x32={} \ | ||
| 4387 | + 64x64={}", | ||
| 4388 | + per_size[0], per_size[1], per_size[2], per_size[3] | ||
| 4389 | + ); | ||
| 4390 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4391 | + for (plane, (g, w)) in [ | ||
| 4392 | + ("Y", (&got.y, &want.y)), | ||
| 4393 | + ("U", (&got.u, &want.u)), | ||
| 4394 | + ("V", (&got.v, &want.v)), | ||
| 4395 | + ] { | ||
| 4396 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4397 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4398 | + eprintln!( | ||
| 4399 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ | ||
| 4400 | + want {} ({} samples differ)", | ||
| 4401 | + at % stride, | ||
| 4402 | + at / stride, | ||
| 4403 | + g[at], | ||
| 4404 | + w[at], | ||
| 4405 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4406 | + ); | ||
| 4407 | + } | ||
| 4408 | + } | ||
| 4409 | + } | ||
| 4410 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4411 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 4412 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 4413 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 4414 | + } | ||
| 4415 | + if counted { | ||
| 4416 | + gate_buckets( | ||
| 4417 | + &name, | ||
| 4418 | + 1, | ||
| 4419 | + uncounted_exact, | ||
| 4420 | + refusals.len() - uncounted_exact as usize, | ||
| 4421 | + ); | ||
| 4422 | + return; | ||
| 4423 | + } | ||
| 4424 | + } | ||
| 4425 | + gate_buckets( | ||
| 4426 | + &name, | ||
| 4427 | + 0, | ||
| 4428 | + uncounted_exact, | ||
| 4429 | + refusals.len() - uncounted_exact as usize, | ||
| 4430 | + ); | ||
| 4431 | + panic!( | ||
| 4432 | + "{name} never observed a split-transform intra block in an inter frame:\n{}", | ||
| 4433 | + refusals.join("\n") | ||
| 4434 | + ); | ||
| 4435 | + } | ||
| 4436 | + | ||
| 4183 | /// lane-chroma r2 stage 1: a real aomenc key frame with | 4437 | /// lane-chroma r2 stage 1: a real aomenc key frame with |
| 4184 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) | 4438 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) |
| 4185 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- | 4439 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- |