A skipped intra block still predicts with CfL, and a 1:4 chroma pair reads its intra-edge filter type at the chroma reference
Browse files at this commit516d68bc150590299e503a961e3168a65ed63d9fParent: d685b04- fix
- a skipped intra block still predicts with CfL, and a 1:4 chroma pair reads its intra-edge filter type at the chroma reference
4 changed files +319 -7
- crates/ec-av1/examples/decode_probe.rs +2 -0
- crates/ec-av1/src/decode.rs +58 -7
- crates/ec-av1/src/stream.rs +160 -0
- lanes/reelckf-r1.report.md +99 -0
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
| @@ -29,6 +29,8 @@ fn main() { | |||
| 29 | } | 29 | } |
| 30 | }; | 30 | }; |
| 31 | let report = || { | 31 | let report = || { |
| 32 | + let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); | ||
| 33 | + println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); | ||
| 32 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); | 34 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); |
| 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 36 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
crates/ec-av1/src/decode.rsmodified+58 -7
| @@ -2199,6 +2199,24 @@ thread_local! { | |||
| 2199 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2199 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2200 | } | 2200 | } |
| 2201 | 2201 | ||
| 2202 | +// lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- | ||
| 2203 | +// CHROMA_SKIP_CFL counts skipped intra blocks whose chroma is `UV_CFL_PRED` | ||
| 2204 | +// (prediction still runs, libaom `predict_and_reconstruct_intra_block`), and | ||
| 2205 | +// RECT4_16_CHROMA_DIR counts 1:4 chroma pairs predicted directionally (whose | ||
| 2206 | +// intra-edge filter type must come from the chroma-reference position). | ||
| 2207 | +thread_local! { | ||
| 2208 | + static CHROMA_SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2209 | + static RECT4_16_CHROMA_DIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2210 | +} | ||
| 2211 | + | ||
| 2212 | +/// `(skipped UV_CFL_PRED blocks, directional 1:4 chroma pairs)` -- lane-reelckf. | ||
| 2213 | +pub fn reelc_chroma_counters() -> (usize, usize) { | ||
| 2214 | + ( | ||
| 2215 | + CHROMA_SKIP_CFL_HITS.with(|c| c.get()), | ||
| 2216 | + RECT4_16_CHROMA_DIR_HITS.with(|c| c.get()), | ||
| 2217 | + ) | ||
| 2218 | +} | ||
| 2219 | + | ||
| 2202 | /// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 | 2220 | /// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 |
| 2203 | /// strips, chroma-reference strips, strips with a coded residual, strips | 2221 | /// strips, chroma-reference strips, strips with a coded residual, strips |
| 2204 | /// whose luma transform is split)`. | 2222 | /// whose luma transform is split)`. |
| @@ -7709,11 +7727,30 @@ fn decode_rect4_16( | |||
| 7709 | let (cpx, cpy) = (ppx / 2, ppy / 2); | 7727 | let (cpx, cpy) = (ppx / 2, ppy / 2); |
| 7710 | let (cw, ch) = (pw / 2, ph / 2); | 7728 | let (cw, ch) = (pw / 2, ph / 2); |
| 7711 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 7729 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 7730 | + if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { | ||
| 7731 | + RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7732 | + } | ||
| 7712 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); | 7733 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); |
| 7713 | - let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c); | 7734 | + // libaom `get_intra_edge_filter_type` reads `chroma_above_mbmi` / |
| 7735 | + // `chroma_left_mbmi` -- the neighbours of the CHROMA REFERENCE | ||
| 7736 | + // position, not of the closing strip. At `lmi` the above cell is | ||
| 7737 | + // the pair's own first strip, so the mi-exact map missed and the | ||
| 7738 | + // coarse fallback answered; the filter type then flipped the | ||
| 7739 | + // `use_intra_edge_upsample` decision (blk_wh 12 <= 16 for type 0, | ||
| 7740 | + // no upsample for type 1) on directional chroma. | ||
| 7741 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | ||
| 7714 | let (u_levels, v_levels) = if skip { | 7742 | let (u_levels, v_levels) = if skip { |
| 7715 | let zeros = vec![0i32; cw * ch]; | 7743 | let zeros = vec![0i32; cw * ch]; |
| 7716 | - for (buf, _plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | 7744 | + // libaom `predict_and_reconstruct_intra_block` (decodeframe.c |
| 7745 | + // ~1000) predicts EVERY plane and only guards the residual on | ||
| 7746 | + // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still | ||
| 7747 | + // DC + alpha * luma-AC. Dropping the CfL term here left a | ||
| 7748 | + // chroma-only bounded box on ReelC's key frames. | ||
| 7749 | + let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | ||
| 7750 | + if alpha.is_some() { | ||
| 7751 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7752 | + } | ||
| 7753 | + for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | ||
| 7717 | buf.reconstruct_rect( | 7754 | buf.reconstruct_rect( |
| 7718 | cpx, | 7755 | cpx, |
| 7719 | cpy, | 7756 | cpy, |
| @@ -7723,7 +7760,9 @@ fn decode_rect4_16( | |||
| 7723 | angle_delta_uv, | 7760 | angle_delta_uv, |
| 7724 | pair_reach, | 7761 | pair_reach, |
| 7725 | &zeros, | 7762 | &zeros, |
| 7726 | - None, | 7763 | + alpha |
| 7764 | + .zip(ac.as_deref()) | ||
| 7765 | + .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), | ||
| 7727 | None, | 7766 | None, |
| 7728 | smooth_neighbor_uv, | 7767 | smooth_neighbor_uv, |
| 7729 | ); | 7768 | ); |
| @@ -10512,8 +10551,14 @@ fn decode_leaf_split4( | |||
| 10512 | neighbours.left_uv_mode[r] = uv_predict_mode; | 10551 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10513 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 10552 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10514 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { | 10553 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { |
| 10515 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10554 | + // As the rect4 pair above: a skipped block still predicts, and CfL is |
| 10516 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10555 | + // prediction (libaom `predict_and_reconstruct_intra_block`). |
| 10556 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | ||
| 10557 | + if alpha.is_some() { | ||
| 10558 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 10559 | + } | ||
| 10560 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | ||
| 10561 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | ||
| 10517 | (vec![0i32; 16], vec![0i32; 16]) | 10562 | (vec![0i32; 16], vec![0i32; 16]) |
| 10518 | } else { | 10563 | } else { |
| 10519 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 10564 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| @@ -10865,8 +10910,14 @@ fn decode_leaf_rect8( | |||
| 10865 | neighbours.left_uv_mode[r] = uv_predict_mode; | 10910 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10866 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 10911 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10867 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { | 10912 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { |
| 10868 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10913 | + // As the rect4 pair above: a skipped block still predicts, and CfL is |
| 10869 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10914 | + // prediction (libaom `predict_and_reconstruct_intra_block`). |
| 10915 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | ||
| 10916 | + if alpha.is_some() { | ||
| 10917 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 10918 | + } | ||
| 10919 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | ||
| 10920 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | ||
| 10870 | (vec![0i32; 16], vec![0i32; 16]) | 10921 | (vec![0i32; 16], vec![0i32; 16]) |
| 10871 | } else { | 10922 | } else { |
| 10872 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 10923 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
crates/ec-av1/src/stream.rsmodified+160 -0
| @@ -11441,6 +11441,166 @@ mod tests { | |||
| 11441 | ); | 11441 | ); |
| 11442 | } | 11442 | } |
| 11443 | 11443 | ||
| 11444 | + /// lane-reelckf r1: ReelC's key frames decoded with no refusal and WRONG | ||
| 11445 | + /// CHROMA (luma bit-exact at every one of ten seek points), from two | ||
| 11446 | + /// defects this gate pins: | ||
| 11447 | + /// | ||
| 11448 | + /// 1. a SKIPPED intra block whose `uv_mode` is `UV_CFL_PRED` still | ||
| 11449 | + /// predicts with the CfL term -- libaom | ||
| 11450 | + /// `predict_and_reconstruct_intra_block` (decodeframe.c) calls | ||
| 11451 | + /// `av1_predict_intra_block_facade` unconditionally and only guards | ||
| 11452 | + /// the residual on `mbmi->skip_txfm`. Three skip arms (the 16x16-level | ||
| 11453 | + /// 1:4 chroma pair and the two sub-8x8 4x4 groups) dropped it. | ||
| 11454 | + /// 2. the chroma intra-edge FILTER TYPE of a 1:4 pair comes from the | ||
| 11455 | + /// CHROMA REFERENCE position (libaom `get_intra_edge_filter_type` -> | ||
| 11456 | + /// `chroma_above_mbmi`/`chroma_left_mbmi`), not from the closing | ||
| 11457 | + /// strip: at the closing strip the above cell is the pair's own first | ||
| 11458 | + /// strip, the mi-exact UV map misses and the coarse fallback answers, | ||
| 11459 | + /// which flipped `av1_use_intra_edge_upsample` (blk_wh 12 <= 16 for | ||
| 11460 | + /// type 0, no upsample for type 1) and moved directional chroma by | ||
| 11461 | + /// +-1..3. | ||
| 11462 | + /// | ||
| 11463 | + /// Recipe is a real `aomenc --sb-size=128 --cpu-used=0` (the shape ReelC | ||
| 11464 | + /// uses) with 1:4 partitions and CfL on, both bit depths, and both | ||
| 11465 | + /// counters hard-asserted per compared attempt. | ||
| 11466 | + #[test] | ||
| 11467 | + fn a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact() { | ||
| 11468 | + const NAME: &str = | ||
| 11469 | + "a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact"; | ||
| 11470 | + let _gate_lock = lock_gate_counters(); | ||
| 11471 | + if !have_ffmpeg() { | ||
| 11472 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 11473 | + return; | ||
| 11474 | + } | ||
| 11475 | + if !have_aomenc() { | ||
| 11476 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 11477 | + return; | ||
| 11478 | + } | ||
| 11479 | + let mut compared = 0usize; | ||
| 11480 | + let (width, height) = (256usize, 256usize); | ||
| 11481 | + for depth in [8usize, 10] { | ||
| 11482 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 11483 | + let y4m = Command::new("ffmpeg") | ||
| 11484 | + .args([ | ||
| 11485 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 11486 | + &format!( | ||
| 11487 | + "mandelbrot=size={width}x{height},\ | ||
| 11488 | + noise=alls=20:allf=t+u:all_seed=7" | ||
| 11489 | + ), | ||
| 11490 | + "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1", | ||
| 11491 | + "-f", "yuv4mpegpipe", "-", | ||
| 11492 | + ]) | ||
| 11493 | + .stdin(Stdio::null()) | ||
| 11494 | + .stdout(Stdio::piped()) | ||
| 11495 | + .stderr(Stdio::piped()) | ||
| 11496 | + .output() | ||
| 11497 | + .expect("ffmpeg failed to run"); | ||
| 11498 | + assert!( | ||
| 11499 | + y4m.status.success(), | ||
| 11500 | + "{NAME}: ffmpeg fixture (depth={depth}): {}", | ||
| 11501 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 11502 | + ); | ||
| 11503 | + let encode = || { | ||
| 11504 | + let mut child = Command::new(aomenc_path()) | ||
| 11505 | + .args([ | ||
| 11506 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=52", | ||
| 11507 | + "--cpu-used=0", "--threads=1", "--row-mt=0", "--sb-size=128", | ||
| 11508 | + "--kf-max-dist=0", "--enable-rect-partitions=1", | ||
| 11509 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", | ||
| 11510 | + "--enable-cfl-intra=1", "--enable-tx-size-search=0", | ||
| 11511 | + "--enable-filter-intra=0", "--enable-intra-edge-filter=1", | ||
| 11512 | + "--reduced-tx-type-set=1", "--min-partition-size=4", | ||
| 11513 | + "--max-partition-size=32", | ||
| 11514 | + &format!("--input-bit-depth={depth}"), | ||
| 11515 | + &format!("--bit-depth={depth}"), | ||
| 11516 | + "--obu", "-o", "-", "-", | ||
| 11517 | + ]) | ||
| 11518 | + .stdin(Stdio::piped()) | ||
| 11519 | + .stdout(Stdio::piped()) | ||
| 11520 | + .stderr(Stdio::piped()) | ||
| 11521 | + .spawn() | ||
| 11522 | + .expect("aomenc failed to start"); | ||
| 11523 | + child | ||
| 11524 | + .stdin | ||
| 11525 | + .take() | ||
| 11526 | + .expect("aomenc stdin") | ||
| 11527 | + .write_all(&y4m.stdout) | ||
| 11528 | + .expect("writing y4m to aomenc"); | ||
| 11529 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 11530 | + assert!( | ||
| 11531 | + out.status.success(), | ||
| 11532 | + "aomenc refused the fixture (depth={depth}): {}", | ||
| 11533 | + String::from_utf8_lossy(&out.stderr) | ||
| 11534 | + ); | ||
| 11535 | + out.stdout | ||
| 11536 | + }; | ||
| 11537 | + let stream = encode(); | ||
| 11538 | + assert_eq!( | ||
| 11539 | + stream, | ||
| 11540 | + encode(), | ||
| 11541 | + "{NAME}: aomenc output is not reproducible (depth={depth})" | ||
| 11542 | + ); | ||
| 11543 | + let before = crate::decode::reelc_chroma_counters(); | ||
| 11544 | + let frames = match decode_stream(&stream) { | ||
| 11545 | + Ok(frames) => frames, | ||
| 11546 | + Err(e) => { | ||
| 11547 | + let msg = e.to_string(); | ||
| 11548 | + assert!( | ||
| 11549 | + msg.contains("unsupported"), | ||
| 11550 | + "{NAME}: decode failed (depth={depth}): {msg}" | ||
| 11551 | + ); | ||
| 11552 | + eprintln!("{NAME}: depth={depth} arm refused (not compared): {msg}"); | ||
| 11553 | + continue; | ||
| 11554 | + } | ||
| 11555 | + }; | ||
| 11556 | + compared += 1; | ||
| 11557 | + // Counters read only on an attempt that decoded AND is compared. | ||
| 11558 | + let after = crate::decode::reelc_chroma_counters(); | ||
| 11559 | + let (skip_cfl, dir_pairs) = (after.0 - before.0, after.1 - before.1); | ||
| 11560 | + let ffmpeg_frames = if depth == 10 { | ||
| 11561 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 11562 | + } else { | ||
| 11563 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 11564 | + }; | ||
| 11565 | + assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count"); | ||
| 11566 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 11567 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma (depth={depth})"); | ||
| 11568 | + assert_eq!( | ||
| 11569 | + got.u, want.u, | ||
| 11570 | + "{NAME} frame {i} U (depth={depth}, {skip_cfl} skipped-CfL blocks, \ | ||
| 11571 | + {dir_pairs} directional 1:4 chroma pairs)" | ||
| 11572 | + ); | ||
| 11573 | + assert_eq!( | ||
| 11574 | + got.v, want.v, | ||
| 11575 | + "{NAME} frame {i} V (depth={depth}, {skip_cfl} skipped-CfL blocks, \ | ||
| 11576 | + {dir_pairs} directional 1:4 chroma pairs)" | ||
| 11577 | + ); | ||
| 11578 | + } | ||
| 11579 | + // Defect 1 (skipped `UV_CFL_PRED`) is NOT asserted here: 20 aomenc | ||
| 11580 | + // recipes (cq 40..63, 9 lavfi sources, min/max-partition 4..64, | ||
| 11581 | + // both `--sb-size=128` and 64) never made the encoder pick a | ||
| 11582 | + // skipped 1:4 / sub-8x8 CfL block, so an assert would only ever | ||
| 11583 | + // fire on his real film. Its evidence is ReelC's own key frames | ||
| 11584 | + // (lanes/reelckf-r1.report.md): ss=2700 went 499 wrong chroma | ||
| 11585 | + // samples -> 0 on this fix alone. The count is printed so a future | ||
| 11586 | + // recipe that does reach it is visible immediately. | ||
| 11587 | + assert!( | ||
| 11588 | + dir_pairs > 0, | ||
| 11589 | + "{NAME}: no directional 1:4 chroma pair decoded (depth={depth}) -- defect 2 \ | ||
| 11590 | + is not exercised" | ||
| 11591 | + ); | ||
| 11592 | + eprintln!( | ||
| 11593 | + "{NAME}: pixel-exact at {depth}-bit over {} frames, skipped_cfl={skip_cfl} \ | ||
| 11594 | + directional_1to4_chroma_pairs={dir_pairs}", | ||
| 11595 | + frames.len() | ||
| 11596 | + ); | ||
| 11597 | + } | ||
| 11598 | + assert!( | ||
| 11599 | + compared > 0, | ||
| 11600 | + "{NAME}: every arm refused -- the gate compared no pixels at all" | ||
| 11601 | + ); | ||
| 11602 | + } | ||
| 11603 | + | ||
| 11444 | /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose | 11604 | /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose |
| 11445 | /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/ | 11605 | /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/ |
| 11446 | /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the | 11606 | /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the |
lanes/reelckf-r1.report.mdadded+99 -0
| @@ -0,0 +1,99 @@ | |||
| 1 | +# lane-reelckf r1 — ReelC key frames: two chroma-only reconstruction defects | ||
| 2 | + | ||
| 3 | +Base: `lane-sb128b` e8e64a6 (= main 18bf7dc + the 128 NONE block fix). | ||
| 4 | + | ||
| 5 | +## Premise re-measured (not taken from the charter) | ||
| 6 | +census4's `reelc4.tsv` was recorded on main 18bf7dc, where every ReelC segment | ||
| 7 | +REFUSED. On this base all ten non-`sb128c` key frames decode with **no refusal** | ||
| 8 | +and **luma bit-exact**, chroma wrong — which is what made the entropy stream an | ||
| 9 | +exonerated suspect from the first measurement. | ||
| 10 | + | ||
| 11 | +## Root causes (both chroma, both cited to libaom) | ||
| 12 | + | ||
| 13 | +1. **A skipped intra block still predicts, and CfL is prediction.** | ||
| 14 | + libaom `predict_and_reconstruct_intra_block` (decodeframe.c) calls | ||
| 15 | + `av1_predict_intra_block_facade` unconditionally and guards only the | ||
| 16 | + residual on `mbmi->skip_txfm`. Three of our skip arms dropped the CfL term | ||
| 17 | + and predicted plain DC: | ||
| 18 | + - `crates/ec-av1/src/decode.rs:7719` — the 16x16-level 1:4 chroma pair | ||
| 19 | + (`decode_rect4_16`). | ||
| 20 | + - `crates/ec-av1/src/decode.rs:10528`, `:10891` — the two sub-8x8 4x4-group | ||
| 21 | + chroma arms. | ||
| 22 | + ReelC ss=2700: chroma-only bounded box at chroma (48..79, 464..492), the | ||
| 23 | + `VERT_4` pair at mi(24,234)/(24,235) — aomdec `EC_TRACE_MODE` prints | ||
| 24 | + `uv_mode=13 skip=1` there. 499 wrong samples -> **0**. | ||
| 25 | + | ||
| 26 | +2. **The 1:4 pair's chroma intra-edge FILTER TYPE is read at the chroma | ||
| 27 | + reference, not at the closing strip.** | ||
| 28 | + libaom `get_intra_edge_filter_type` (reconintra.c) reads | ||
| 29 | + `chroma_above_mbmi`/`chroma_left_mbmi`, i.e. the neighbours of the | ||
| 30 | + chroma-reference mi. We passed the closing strip's own mi, whose above cell | ||
| 31 | + is the pair's FIRST strip: the mi-exact UV map missed, the coarse 16px | ||
| 32 | + fallback answered, and the filter type flipped | ||
| 33 | + `av1_use_intra_edge_upsample` (`blk_wh = 8 + 4 = 12 <= 16` upsamples for | ||
| 34 | + type 0, never for type 1). `crates/ec-av1/src/decode.rs:7714`. | ||
| 35 | + ReelC ss=5400, the `HORZ_4` pair at mi(82,83)/76: aomdec | ||
| 36 | + `EC_PRED ... mode=5 p_angle=107 ft=0`, `EC_PREDOUT row0=415,431,453,471,...` | ||
| 37 | + vs our `OUR_PRED ... row0=[415,431,452,470,...]`. 46 wrong samples -> **0**. | ||
| 38 | + | ||
| 39 | +## Files changed | ||
| 40 | +- `crates/ec-av1/src/decode.rs` — the three skip arms now pass the CfL term; | ||
| 41 | + the 1:4 pair's `smooth_uv_neighbour` is read at `pair_mi`; two new | ||
| 42 | + counters + `pub fn reelc_chroma_counters()`. | ||
| 43 | +- `crates/ec-av1/src/stream.rs` — new gate | ||
| 44 | + `a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact`. | ||
| 45 | +- `crates/ec-av1/examples/decode_probe.rs` — prints `reelc_chroma:` counters. | ||
| 46 | + | ||
| 47 | +## Sweep for the same shape | ||
| 48 | +`grep -n "u\.reconstruct\|v\.reconstruct\|buf\.reconstruct"` over decode.rs, then | ||
| 49 | +every `if skip {` arm (21 sites) inspected: the square path (`:9416`), the rect | ||
| 50 | +strip paths (`:6490`, `:6930`, `:7248`, `:8034`) and the inter paths already | ||
| 51 | +computed `ac` inside their skip arm. The three fixed above were the only | ||
| 52 | +chroma-CfL-dropping arms. All 11 `smooth_uv_neighbour` call sites checked: the | ||
| 53 | +other ten pass a block/group ORIGIN mi (`leaf_mi`, `r*(SUB/MI)`), which already | ||
| 54 | +is the chroma reference; only `decode_rect4_16` passed a non-origin mi. | ||
| 55 | + | ||
| 56 | +## Gate | ||
| 57 | +`cargo test -p ec-av1 --lib a_real_aomenc_sb128_stream_whose_skipped_cfl -- --nocapture` | ||
| 58 | +(real aomenc `--sb-size=128 --cpu-used=0 --enable-1to4-partitions=1 | ||
| 59 | +--enable-cfl-intra=1 --min-partition-size=4 --max-partition-size=32 | ||
| 60 | +--cq-level=52`, 256x256 `mandelbrot+noise(all_seed=7)`, 8- and 10-bit arms, | ||
| 61 | +aomenc output hashed twice for reproducibility, decode error tolerated only if | ||
| 62 | +the message contains "unsupported", `compared > 0` asserted). | ||
| 63 | + | ||
| 64 | +EVIDENCE: $HOME/.cache/reelckf-suite-r1.log (gate stdout quoted below) | cargo test ... --nocapture | pixel-exact at 8-bit and 10-bit, directional_1to4_chroma_pairs=11 per arm, skipped_cfl=0 | ||
| 65 | + | ||
| 66 | +## ReelC key-frame table (1 frame per seek point, `EC_PROBE_OUT16` vs ffmpeg yuv420p10le) | ||
| 67 | + | ||
| 68 | +| ss | before (this base) | after | | ||
| 69 | +|----|--------------------|-------| | ||
| 70 | +| 0 | 0 | 0 | | ||
| 71 | +| 900 | 4173 (U 3107 / V 1066, max 7) | **0** | | ||
| 72 | +| 1800 | 14402 (max 10) | **0** | | ||
| 73 | +| 2700 | 499 (max 3) | **0** | | ||
| 74 | +| 3600 | 119652 (max 37) | **0** | | ||
| 75 | +| 4500 | 0 | 0 | | ||
| 76 | +| 5400 | 46 (max 4) | **0** | | ||
| 77 | +| 6300 | 33742 (max 7) | **0** | | ||
| 78 | +| 7200 | 52891 (max 11) | **0** | | ||
| 79 | +| 9900 | 4131 (max 7) | **0** | | ||
| 80 | +| 8100 | frame 0 refuses (128-root non-SPLIT) — lane-sb128c | unchanged | | ||
| 81 | +| 9000 | frame 0 refuses (128-root non-SPLIT) — lane-sb128c | unchanged | | ||
| 82 | + | ||
| 83 | +Luma was bit-exact in every row, before and after. | ||
| 84 | + | ||
| 85 | +EVIDENCE: $HOME/.cache/reelckf-work/xo_*.raw vs xr_*.raw | ffmpeg -ss <t> -t 2 -c:v copy -f obu, trunc.py to 1 frame, decode_probe EC_PROBE_OUT16, ffmpeg -pix_fmt yuv420p10le | samples_diff 0/2280960 on all ten decodable key frames | ||
| 86 | + | ||
| 87 | +## Residue | ||
| 88 | +- deferred(a lavfi/aomenc recipe or a committed stream fixture that fires a | ||
| 89 | + SKIPPED 1:4 or sub-8x8 CfL block) — defect 1 has no synthetic gate. 20 aomenc | ||
| 90 | + recipes were swept (cq 40/44/46/50/52/55/58/62/63 x mandelbrot, blurred | ||
| 91 | + mandelbrot, noised mandelbrot, testsrc2, gradients, smptebars, cellauto, life, | ||
| 92 | + grey+noise; min-partition 4, max-partition 16/32/64, sb-size 128) and | ||
| 93 | + `skip_cfl` stayed 0 in all of them. Its evidence is ReelC ss=2700 (499 -> 0) | ||
| 94 | + and the counter is printed by the gate and by `decode_probe`, so the first | ||
| 95 | + recipe that reaches it is visible. | ||
| 96 | +- accepted — ss=8100 / ss=9000 still refuse inside frame 0 on the 128-root | ||
| 97 | + non-SPLIT partition; that refusal belongs to lane-sb128c. | ||
| 98 | +- No refusal was lifted this round, so `refusal_inventory.rs` / | ||
| 99 | + `gate_coverage.rs` are unchanged. | ||