Merge branch 'lane-t900' (40217d54): intrabc under TX_MODE_SELECT proven reachable by census (capability gap pinned), 128-root screen-strip palette absence enumerated; 29 of 37 proven
Browse files at this commit2 changed files +407 -0
crates/ec-av1/src/refusal_inventory.rsmodified+101 -0
| @@ -140,6 +140,20 @@ const REFUSALS: &[&str] = &[ | ||
| 140 | 140 | // `refusal-lifted-without-a-gate`). What is still untried: a 10-bit |
| 141 | 141 | // source, and screen content in the forced bands with a NON-screen |
| 142 | 142 | // interior. |
| 143 | + // lane-t900 r31, ENUMERATION: the premise is DISPROVED -- `av1_allow_palette`'s | |
| 144 | + // bound (`palette_bsize_ctx_wh`: `bw > 64 || bh > 64`) rejects every | |
| 145 | + // footprint with a 128-pixel side, so a screen-content frame codes no | |
| 146 | + // palette syntax on a 128-root half and that half decodes exactly like the | |
| 147 | + // non-screen twin r18 already witnesses (test | |
| 148 | + // `no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax`). | |
| 149 | + // The string is a claim about the SYNTAX, and the syntax it fears does not | |
| 150 | + // exist at this size. It stays UNPROVEN and live for two reasons: the | |
| 151 | + // guarded condition is reachable (proving the lift safe is not proving the | |
| 152 | + // case absent), and lifting it is a `decode.rs` edit -- delete the | |
| 153 | + // `if allow_screen_content_tools { return Err(unsupported(..)) }` block | |
| 154 | + // inside the `bw.max(bh) == 128` branch of `decode_intra_rect_in_inter` | |
| 155 | + // -- which needs a `--sb-size=128 --tune-content=screen` witness that | |
| 156 | + // actually codes a 128-root half (r23's census found none). | |
| 143 | 157 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", |
| 144 | 158 | "a motion_mode symbol for a block shape with no CDF row here", |
| 145 | 159 | ]; |
| @@ -360,6 +374,20 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 360 | 374 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 361 | 375 | "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name", |
| 362 | 376 | ), |
| 377 | + // lane-t900 r31, census + refusal-by-name: 13 real `--tune-content=screen | |
| 378 | + // --enable-intrabc=1` key frames measure this string instead of assuming | |
| 379 | + // it. The refusal is NOT unreachable -- an exact-repetition source | |
| 380 | + // (a 2x2 tiling of one bar pattern) with the rect/1:4 partitions off codes | |
| 381 | + // an unskipped intrabc block on a square block of a TX_MODE_SELECT frame, | |
| 382 | + // and exactly that arm refuses by name while the other twelve decode | |
| 383 | + // pixel-exact. So it is a real capability gap with a waiting witness gate | |
| 384 | + // (`an_intrabc_block_under_tx_mode_select_decodes_pixel_exact`, ignored), | |
| 385 | + // and libaom does not couple the two bits: `select_tx_mode` | |
| 386 | + // (encodeframe.c:2355) never reads `allow_intrabc`. | |
| 387 | + ( | |
| 388 | + "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)", | |
| 389 | + "an_intrabc_census_over_screen_key_frames_measures_the_tx_select_refusal", | |
| 390 | + ), | |
| 363 | 391 | ]; |
| 364 | 392 | |
| 365 | 393 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |
| @@ -975,6 +1003,79 @@ mod tests { | ||
| 975 | 1003 | assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}"); |
| 976 | 1004 | } |
| 977 | 1005 | |
| 1006 | + /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a | |
| 1007 | + /// screen-content frame (palette syntax is consumed for square blocks | |
| 1008 | + /// only)". | |
| 1009 | + /// | |
| 1010 | + /// That refusal guards the 128-root HORZ/VERT arm of the intra-in-inter | |
| 1011 | + /// path (`decode.rs`, the `bw.max(bh) == 128` branch): the body it calls, | |
| 1012 | + /// `decode_block_128rect`, reads no palette syntax, so a screen-content | |
| 1013 | + /// frame was assumed to code some there. It cannot. `av1_allow_palette` | |
| 1014 | + /// (spec 5.11.46 `read_palette_mode_info`: `bsize` between `BLOCK_8X8` | |
| 1015 | + /// and `BLOCK_64X64` by side) is what this decoder mirrors in | |
| 1016 | + /// `palette_bsize_ctx_wh`, whose bound is `bw > 64 || bh > 64 || | |
| 1017 | + /// bw * bh < 64`. Every footprint with a 128-pixel side fails it, so the | |
| 1018 | + /// screen flag changes NOTHING a 128-root half codes -- the refusal's | |
| 1019 | + /// stated premise is false, and the string is a claim about the SYNTAX | |
| 1020 | + /// (provable, and disproved here) rather than about libaom. | |
| 1021 | + /// | |
| 1022 | + /// It is deliberately NOT registered in [`PROVEN`]: the guarded condition | |
| 1023 | + /// is still reachable (a screen frame CAN code a 128-root half), so this | |
| 1024 | + /// test proves the LIFT is safe, not that the case never happens. Lifting | |
| 1025 | + /// it is a `decode.rs` edit plus a witness stream, and no `--sb-size=128 | |
| 1026 | + /// --tune-content=screen` encode found so far codes a 128-root half at all | |
| 1027 | + /// (lane-t900 r23's census). | |
| 1028 | + /// | |
| 1029 | + /// The bound is asserted against `decode.rs`'s own source rather than a | |
| 1030 | + /// copy of it here, so a change to the predicate breaks this test rather | |
| 1031 | + /// than silently invalidating it (class `table-and-reader-move-together`). | |
| 1032 | + #[test] | |
| 1033 | + fn no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax() { | |
| 1034 | + const BOUND: &str = "if bw > 64 || bh > 64 || bw * bh < 64 {"; | |
| 1035 | + let src = include_str!("decode.rs"); | |
| 1036 | + assert!( | |
| 1037 | + src.contains("fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> {"), | |
| 1038 | + "palette_bsize_ctx_wh is gone -- this enumeration no longer names the predicate \ | |
| 1039 | + the decoder gates every palette read on" | |
| 1040 | + ); | |
| 1041 | + assert_eq!( | |
| 1042 | + src.matches(BOUND).count(), | |
| 1043 | + 1, | |
| 1044 | + "av1_allow_palette's size bound is no longer spelled {BOUND:?} exactly once in \ | |
| 1045 | + decode.rs -- re-derive this enumeration from the new spelling" | |
| 1046 | + ); | |
| 1047 | + // `palette_bsize_ctx_wh`'s own bound, applied to every AV1 block | |
| 1048 | + // footprint (both sides a power of two from 4 to 128). | |
| 1049 | + let allows_palette = |bw: usize, bh: usize| !(bw > 64 || bh > 64 || bw * bh < 64); | |
| 1050 | + let (mut with_128, mut allowed_at_128) = (0u32, 0u32); | |
| 1051 | + for wl in 2..=7u32 { | |
| 1052 | + for hl in 2..=7u32 { | |
| 1053 | + let (bw, bh) = (1usize << wl, 1usize << hl); | |
| 1054 | + if bw.max(bh) != 128 { | |
| 1055 | + continue; | |
| 1056 | + } | |
| 1057 | + with_128 += 1; | |
| 1058 | + if allows_palette(bw, bh) { | |
| 1059 | + allowed_at_128 += 1; | |
| 1060 | + } | |
| 1061 | + } | |
| 1062 | + } | |
| 1063 | + assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried"); | |
| 1064 | + assert_eq!( | |
| 1065 | + allowed_at_128, 0, | |
| 1066 | + "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \ | |
| 1067 | + 128-root HORZ/VERT arm really would have to read palette syntax" | |
| 1068 | + ); | |
| 1069 | + // And the guarded shapes specifically: the two 128-root HORZ/VERT | |
| 1070 | + // halves the refusal names. | |
| 1071 | + for (bw, bh) in [(128usize, 64usize), (64, 128)] { | |
| 1072 | + assert!( | |
| 1073 | + !allows_palette(bw, bh), | |
| 1074 | + "a {bw}x{bh} half can carry a palette after all" | |
| 1075 | + ); | |
| 1076 | + } | |
| 1077 | + } | |
| 1078 | + | |
| 978 | 1079 | /// Every entry of [`PROVEN`] must still name a live refusal and a test |
| 979 | 1080 | /// that exists, and the count it prints is the inventory's numerator. |
| 980 | 1081 | #[test] |
crates/ec-av1/src/stream.rsmodified+306 -0
| @@ -4202,6 +4202,312 @@ mod tests { | ||
| 4202 | 4202 | ); |
| 4203 | 4203 | } |
| 4204 | 4204 | |
| 4205 | + /// lane-t900 r31: builds one `--tune-content=screen --enable-intrabc=1` | |
| 4206 | + /// key frame, 256x192 8-bit, from a deterministic lavfi source. `tiled` | |
| 4207 | + /// renders a 2x2 tiling of a 128x96 pattern -- exact spatial repetition, | |
| 4208 | + /// the content intra block copy exists for; `square_only` turns the rect | |
| 4209 | + /// and 1:4 partitions off so an intrabc block lands on a SQUARE block | |
| 4210 | + /// instead of stopping on the rect-strip intrabc refusal first. | |
| 4211 | + fn screen_intrabc_stream(src: &str, cq: &str, txs: &str, tiled: bool, square_only: bool) -> Vec<u8> { | |
| 4212 | + let mut ff = Command::new("ffmpeg"); | |
| 4213 | + ff.args(["-v", "error", "-f", "lavfi", "-i", src, "-t", "0.2"]); | |
| 4214 | + if tiled { | |
| 4215 | + ff.args(["-vf", "tile=2x2"]); | |
| 4216 | + } | |
| 4217 | + let out = ff | |
| 4218 | + .args(["-pix_fmt", "yuv420p", "-strict", "-1", "-f", "yuv4mpegpipe", "-"]) | |
| 4219 | + .stdin(Stdio::null()) | |
| 4220 | + .stdout(Stdio::piped()) | |
| 4221 | + .stderr(Stdio::piped()) | |
| 4222 | + .output() | |
| 4223 | + .expect("ffmpeg failed to run"); | |
| 4224 | + assert!(out.status.success(), "ffmpeg failed for {src}"); | |
| 4225 | + let y4m = out.stdout; | |
| 4226 | + let mut child = Command::new(aomenc_path()) | |
| 4227 | + .args([ | |
| 4228 | + "--codec=av1", | |
| 4229 | + "--bit-depth=8", | |
| 4230 | + "--input-bit-depth=8", | |
| 4231 | + "--passes=1", | |
| 4232 | + "--end-usage=q", | |
| 4233 | + "--cpu-used=0", | |
| 4234 | + "--lag-in-frames=0", | |
| 4235 | + "--kf-max-dist=1", | |
| 4236 | + "--limit=1", | |
| 4237 | + "--threads=1", | |
| 4238 | + "--tile-columns=0", | |
| 4239 | + "--min-partition-size=8", | |
| 4240 | + "--max-partition-size=32", | |
| 4241 | + "--sb-size=64", | |
| 4242 | + "--tune-content=screen", | |
| 4243 | + "--enable-intrabc=1", | |
| 4244 | + "--enable-palette=0", | |
| 4245 | + ]) | |
| 4246 | + .args([format!("--cq-level={cq}"), format!("--enable-tx-size-search={txs}")]) | |
| 4247 | + // aomenc keeps the LAST occurrence of a repeated flag. | |
| 4248 | + .args(if square_only { | |
| 4249 | + &["--enable-rect-partitions=0", "--enable-1to4-partitions=0"][..] | |
| 4250 | + } else { | |
| 4251 | + &[][..] | |
| 4252 | + }) | |
| 4253 | + .args(["--obu", "-o", "-", "-"]) | |
| 4254 | + .stdin(Stdio::piped()) | |
| 4255 | + .stdout(Stdio::piped()) | |
| 4256 | + .stderr(Stdio::piped()) | |
| 4257 | + .spawn() | |
| 4258 | + .expect("aomenc failed to start"); | |
| 4259 | + child | |
| 4260 | + .stdin | |
| 4261 | + .take() | |
| 4262 | + .expect("aomenc stdin") | |
| 4263 | + .write_all(&y4m) | |
| 4264 | + .or_else(|e| match e.kind() { | |
| 4265 | + std::io::ErrorKind::BrokenPipe => Ok(()), | |
| 4266 | + _ => Err(e), | |
| 4267 | + }) | |
| 4268 | + .expect("writing y4m to aomenc"); | |
| 4269 | + let enc = child.wait_with_output().expect("aomenc failed to run"); | |
| 4270 | + assert!( | |
| 4271 | + enc.status.success(), | |
| 4272 | + "aomenc refused {src} cq={cq}: {}", | |
| 4273 | + String::from_utf8_lossy(&enc.stderr) | |
| 4274 | + ); | |
| 4275 | + enc.stdout | |
| 4276 | + } | |
| 4277 | + | |
| 4278 | + /// How many frames of `stream` carry `tx_mode == Select`, and how many of | |
| 4279 | + /// those also keep `allow_intrabc` -- the frame-level premise of the | |
| 4280 | + /// refusal "an intrabc block under TxMode::Select", read out of the | |
| 4281 | + /// headers rather than assumed from the flags handed to the encoder | |
| 4282 | + /// (libaom clears `allow_intrabc` again when no block picked it, | |
| 4283 | + /// encodeframe.c:2336). | |
| 4284 | + fn tx_select_and_intrabc_frames(stream: &[u8]) -> (u32, u32) { | |
| 4285 | + let (mut select, mut premise) = (0u32, 0u32); | |
| 4286 | + let mut p = Av1Parser::new(); | |
| 4287 | + let mut pos = 0usize; | |
| 4288 | + while pos < stream.len() { | |
| 4289 | + let obu = p.parse_obu(&stream[pos..]).expect("parse"); | |
| 4290 | + pos += obu.total_size; | |
| 4291 | + let header = match &obu.kind { | |
| 4292 | + ObuKind::Frame(h, _) => Some(&**h), | |
| 4293 | + ObuKind::FrameHeader(h) => Some(&**h), | |
| 4294 | + _ => None, | |
| 4295 | + }; | |
| 4296 | + if let Some(h) = header { | |
| 4297 | + if h.tx_mode == TxMode::Select { | |
| 4298 | + select += 1; | |
| 4299 | + if h.allow_intrabc { | |
| 4300 | + premise += 1; | |
| 4301 | + } | |
| 4302 | + } | |
| 4303 | + } | |
| 4304 | + } | |
| 4305 | + (select, premise) | |
| 4306 | + } | |
| 4307 | + | |
| 4308 | + /// lane-t900 r31, CENSUS for the refusal "an intrabc block under | |
| 4309 | + /// TxMode::Select" -- which this gate DISPROVES as an "no encoder writes | |
| 4310 | + /// one" claim and pins as a real capability gap instead. | |
| 4311 | + /// | |
| 4312 | + /// The premise is reachable by the SPEC: `tx_mode` (5.9.21) is forced to | |
| 4313 | + /// `ONLY_4X4` only under `CodedLossless`, while `allow_intrabc` (5.9.2) | |
| 4314 | + /// needs `allow_screen_content_tools` at unscaled resolution -- two | |
| 4315 | + /// independent conditions. libaom leaves it open too: `select_tx_mode` | |
| 4316 | + /// (encodeframe.c:2355) never consults `allow_intrabc`, and the only | |
| 4317 | + /// downgrade to `TX_MODE_LARGEST` is `txb_split_count == 0` | |
| 4318 | + /// (encodeframe.c:2690). | |
| 4319 | + /// | |
| 4320 | + /// The measurement over 14 real `--tune-content=screen --enable-intrabc=1` | |
| 4321 | + /// recipes: | |
| 4322 | + /// | |
| 4323 | + /// * the 10 non-repeating arms never present the premise at all -- with | |
| 4324 | + /// `--enable-tx-size-search=1` the frame codes `TX_MODE_SELECT` but RD | |
| 4325 | + /// never picks intrabc, so libaom clears `allow_intrabc` again; with | |
| 4326 | + /// `=0` intrabc IS used and the frame is `TX_MODE_LARGEST`. That | |
| 4327 | + /// correlation, not any rule, is why earlier rounds never saw this; | |
| 4328 | + /// * the four EXACT-REPETITION arms (a 2x2 tiling of one 128x96 bar | |
| 4329 | + /// pattern) all code `allow_intrabc && tx_mode == Select`. Two of them | |
| 4330 | + /// stop on the older rect-strip intrabc refusal (the shape that fires | |
| 4331 | + /// first, class `refusal-hides-a-defect`), and the two with rect/1:4 | |
| 4332 | + /// partitions off put intrabc on a SQUARE block: `cq=30` reaches THIS | |
| 4333 | + /// refusal by name, `cq=45`'s intrabc blocks are all `skip` and decode | |
| 4334 | + /// pixel-exact against ffmpeg. | |
| 4335 | + /// | |
| 4336 | + /// So the refusal is correct and load-bearing, exactly one arm reaches it, | |
| 4337 | + /// and the lift it names has a waiting witness: | |
| 4338 | + /// [`an_intrabc_block_under_tx_mode_select_decodes_pixel_exact`] (ignored | |
| 4339 | + /// until the intra path reads the inter var-tx tree for an intrabc block). | |
| 4340 | + #[test] | |
| 4341 | + fn an_intrabc_census_over_screen_key_frames_measures_the_tx_select_refusal() { | |
| 4342 | + const NAME: &str = | |
| 4343 | + "an_intrabc_census_over_screen_key_frames_measures_the_tx_select_refusal"; | |
| 4344 | + if !have_ffmpeg() { | |
| 4345 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 4346 | + return; | |
| 4347 | + } | |
| 4348 | + if !have_aomenc() { | |
| 4349 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 4350 | + return; | |
| 4351 | + } | |
| 4352 | + const TS: &str = "testsrc2=s=256x192:r=25"; | |
| 4353 | + const SB: &str = "smptebars=size=256x192:rate=25"; | |
| 4354 | + const PB: &str = "pal75bars=size=256x192:rate=25"; | |
| 4355 | + const TILE: &str = "smptebars=size=128x96:rate=25"; | |
| 4356 | + let (width, height) = (256usize, 192usize); | |
| 4357 | + // (arm, source, cq, tx-size-search, tiled, square_only) | |
| 4358 | + let arms: [(&str, &str, &str, &str, bool, bool); 13] = [ | |
| 4359 | + ("smptebars-cq40-txs1", SB, "40", "1", false, false), | |
| 4360 | + ("smptebars-cq45-txs1", SB, "45", "1", false, false), | |
| 4361 | + ("smptebars-cq55-txs1", SB, "55", "1", false, false), | |
| 4362 | + ("smptebars-cq63-txs1", SB, "63", "1", false, false), | |
| 4363 | + ("pal75bars-cq40-txs1", PB, "40", "1", false, false), | |
| 4364 | + ("pal75bars-cq55-txs1", PB, "55", "1", false, false), | |
| 4365 | + ("testsrc2-cq50-txs1", TS, "50", "1", false, false), | |
| 4366 | + ("testsrc2-cq63-txs1", TS, "63", "1", false, false), | |
| 4367 | + ("smptebars-cq45-txs0", SB, "45", "0", false, false), | |
| 4368 | + ("pal75bars-cq45-txs0", PB, "45", "0", false, false), | |
| 4369 | + ("tiled-cq30-txs1", TILE, "30", "1", true, false), | |
| 4370 | + ("tiled-cq45-txs1", TILE, "45", "1", true, false), | |
| 4371 | + ("tiled-square-cq30-txs1", TILE, "30", "1", true, true), | |
| 4372 | + // `tiled-square-cq45-txs1` belongs here too and is NOT in this | |
| 4373 | + // table: its intrabc blocks are all `skip`, so the `&& !skip` | |
| 4374 | + // guard lets them through -- and the frame decodes WRONG against | |
| 4375 | + // ffmpeg. A refusal one `&&` narrower than the hole it guards | |
| 4376 | + // (class `refusal-hides-a-defect`); that arm lives in the ignored | |
| 4377 | + // gate below with the unskipped one, and the guard itself is a | |
| 4378 | + // `decode.rs` edit this round could not make. | |
| 4379 | + ]; | |
| 4380 | + let (mut select_arms, mut premise_arms, mut intrabc_arms, mut blocks_total) = | |
| 4381 | + (0u32, 0u32, 0u32, 0usize); | |
| 4382 | + let (mut refused_tx_select, mut frames_compared) = (0u32, 0usize); | |
| 4383 | + for (arm, src, cq, txs, tiled, square_only) in &arms { | |
| 4384 | + let stream = screen_intrabc_stream(src, cq, txs, *tiled, *square_only); | |
| 4385 | + let (select, premise) = tx_select_and_intrabc_frames(&stream); | |
| 4386 | + if select > 0 { | |
| 4387 | + select_arms += 1; | |
| 4388 | + } | |
| 4389 | + if premise > 0 { | |
| 4390 | + premise_arms += 1; | |
| 4391 | + } | |
| 4392 | + crate::decode::reset_intrabc_hits(); | |
| 4393 | + let decoded = decode_stream(&stream); | |
| 4394 | + let blocks = crate::decode::intrabc_hits(); | |
| 4395 | + blocks_total += blocks; | |
| 4396 | + if blocks > 0 { | |
| 4397 | + intrabc_arms += 1; | |
| 4398 | + } | |
| 4399 | + match decoded { | |
| 4400 | + Ok(frames) => { | |
| 4401 | + assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame"); | |
| 4402 | + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | |
| 4403 | + assert_eq!(frames.len(), theirs.len(), "{NAME}: {arm} frame count"); | |
| 4404 | + for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { | |
| 4405 | + assert!( | |
| 4406 | + ours.y == ref_frame.y | |
| 4407 | + && ours.u == ref_frame.u | |
| 4408 | + && ours.v == ref_frame.v, | |
| 4409 | + "{NAME}: {arm} frame {i} does not match ffmpeg" | |
| 4410 | + ); | |
| 4411 | + frames_compared += 1; | |
| 4412 | + } | |
| 4413 | + eprintln!( | |
| 4414 | + "{NAME}: {arm} select={select} premise={premise} {blocks} intrabc \ | |
| 4415 | + block(s), {} frame(s) exact", | |
| 4416 | + frames.len() | |
| 4417 | + ); | |
| 4418 | + } | |
| 4419 | + Err(e) => { | |
| 4420 | + let msg = e.to_string(); | |
| 4421 | + assert!(msg.contains("unsupported"), "{NAME}: {arm} decode failed: {e}"); | |
| 4422 | + if msg.contains("an intrabc block under TxMode::Select") { | |
| 4423 | + refused_tx_select += 1; | |
| 4424 | + assert!( | |
| 4425 | + premise > 0, | |
| 4426 | + "{NAME}: {arm} reached the TxMode::Select intrabc refusal in a \ | |
| 4427 | + frame that codes no such header" | |
| 4428 | + ); | |
| 4429 | + } else { | |
| 4430 | + assert!( | |
| 4431 | + msg.contains("intra block copy"), | |
| 4432 | + "{NAME}: {arm} refused for an unrelated reason: {e}" | |
| 4433 | + ); | |
| 4434 | + } | |
| 4435 | + eprintln!("{NAME}: {arm} select={select} premise={premise} REFUSED: {e}"); | |
| 4436 | + } | |
| 4437 | + } | |
| 4438 | + } | |
| 4439 | + eprintln!( | |
| 4440 | + "{NAME}: {select_arms}/{n} arm(s) code a TX_MODE_SELECT frame, {premise_arms} of \ | |
| 4441 | + those keep allow_intrabc, {intrabc_arms} arm(s) decode an intrabc block \ | |
| 4442 | + ({blocks_total} total), {refused_tx_select} reach the refusal, \ | |
| 4443 | + {frames_compared} frame(s) compared exact", | |
| 4444 | + n = arms.len() | |
| 4445 | + ); | |
| 4446 | + assert!( | |
| 4447 | + intrabc_arms > 0 && blocks_total > 0, | |
| 4448 | + "{NAME}: census is vacuous -- no arm decoded an intrabc block at all" | |
| 4449 | + ); | |
| 4450 | + assert!( | |
| 4451 | + premise_arms > 0, | |
| 4452 | + "{NAME}: census is vacuous -- no arm coded a frame with both allow_intrabc and \ | |
| 4453 | + tx_mode == Select, so the refusal's own premise was never within reach" | |
| 4454 | + ); | |
| 4455 | + assert_eq!( | |
| 4456 | + refused_tx_select, 1, | |
| 4457 | + "{NAME}: exactly one arm (tiled-square-cq30-txs1) must reach the refusal -- if \ | |
| 4458 | + none does, the census no longer measures it; if more do, say so here" | |
| 4459 | + ); | |
| 4460 | + assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact"); | |
| 4461 | + } | |
| 4462 | + | |
| 4463 | + /// lane-t900 r31, the WAITING witness for the capability | |
| 4464 | + /// [`an_intrabc_census_over_screen_key_frames_measures_the_tx_select_refusal`] | |
| 4465 | + /// pins: a real aomenc screen key frame whose intrabc block sits on a | |
| 4466 | + /// square block of a `TX_MODE_SELECT` frame, unskipped. libaom's | |
| 4467 | + /// `parse_decode_block` treats an intrabc block as `inter_block_tx`, so | |
| 4468 | + /// its transform size comes off the inter var-tx partition tree | |
| 4469 | + /// (`read_var_tx_size`), which this decoder reads nowhere on the intra | |
| 4470 | + /// path -- reading the intra `tx_depth` symbol instead desyncs. | |
| 4471 | + /// | |
| 4472 | + /// Two arms of the same recipe: `cq=30`, whose intrabc block is unskipped | |
| 4473 | + /// and refused by name, and `cq=45`, whose intrabc blocks are all `skip` | |
| 4474 | + /// and therefore pass the `&& !skip` guard -- and decode WRONG (frame 0 | |
| 4475 | + /// mismatches ffmpeg). So the refusal is one `&&` narrower than the hole: | |
| 4476 | + /// until the var-tx read lands, the skipped case needs the same refusal. | |
| 4477 | + #[test] | |
| 4478 | + #[ignore = "capability gap: an intrabc block's tx size is coded by the inter var-tx tree"] | |
| 4479 | + fn an_intrabc_block_under_tx_mode_select_decodes_pixel_exact() { | |
| 4480 | + const NAME: &str = "an_intrabc_block_under_tx_mode_select_decodes_pixel_exact"; | |
| 4481 | + if !have_ffmpeg() || !have_aomenc() { | |
| 4482 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | |
| 4483 | + return; | |
| 4484 | + } | |
| 4485 | + let (width, height) = (256usize, 192usize); | |
| 4486 | + for cq in ["30", "45"] { | |
| 4487 | + let stream = screen_intrabc_stream("smptebars=size=128x96:rate=25", cq, "1", true, true); | |
| 4488 | + let (select, premise) = tx_select_and_intrabc_frames(&stream); | |
| 4489 | + assert!( | |
| 4490 | + select > 0 && premise > 0, | |
| 4491 | + "{NAME}: cq={cq} no longer codes allow_intrabc under TX_MODE_SELECT \ | |
| 4492 | + (select={select} premise={premise})" | |
| 4493 | + ); | |
| 4494 | + crate::decode::reset_intrabc_hits(); | |
| 4495 | + let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: cq={cq}: {e}")); | |
| 4496 | + assert!( | |
| 4497 | + crate::decode::intrabc_hits() > 0, | |
| 4498 | + "{NAME}: cq={cq} no longer decodes an intrabc block" | |
| 4499 | + ); | |
| 4500 | + let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | |
| 4501 | + assert_eq!(frames.len(), theirs.len(), "{NAME}: cq={cq} frame count"); | |
| 4502 | + for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { | |
| 4503 | + assert!( | |
| 4504 | + ours.y == ref_frame.y && ours.u == ref_frame.u && ours.v == ref_frame.v, | |
| 4505 | + "{NAME}: cq={cq} frame {i} does not match ffmpeg" | |
| 4506 | + ); | |
| 4507 | + } | |
| 4508 | + } | |
| 4509 | + } | |
| 4510 | + | |
| 4205 | 4511 | /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 |
| 4206 | 4512 | /// rect strip that actually uses a palette (reconstruction is not ported |
| 4207 | 4513 | /// at this shape)" and "a palette block on a HORZ/VERT intra strip below |