forge
Explore
Log in

Don't you dare go Hollow

wip(rectx): round 2's in-flight work, committed at the turn cap by the orchestrator

Browse files at this commit

1122732fdecded977848611ac3adbbcd38fe6003Ahmet Kaan GümüşParent: 6c0af34
State unverified: the agent stopped mid-run with no report.
crates/ec-av1/src/decode.rsmodified+10 -0
@@ -3536,6 +3536,9 @@ fn decode_leaf_rect(
35363536 tx_select: bool,
35373537 ) -> Result<usize> {
35383538 let _ = base_q_idx;
3539+ if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
3540+ eprintln!("decode_leaf_rect: leaf_mi={leaf_mi:?} bw={bw} bh={bh} outer_at={outer_at:?}");
3541+ }
35393542 let (r, c) = outer_at;
35403543 let mut above_mode = neighbours.above_mode[c];
35413544 let mut left_mode = neighbours.left_mode[r];
@@ -3567,6 +3570,9 @@ fn decode_leaf_rect(
35673570 leaf_mi.0,
35683571 leaf_mi.1,
35693572 )?;
3573+ if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
3574+ eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}");
3575+ }
35703576 if filter_intra.is_some() {
35713577 return Err(unsupported(
35723578 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
@@ -3624,6 +3630,10 @@ fn decode_leaf_rect(
36243630 let (l_levels, luma_tx_type) = read_coeffs_rect(
36253631 dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct,
36263632 )?;
3633+ if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() {
3634+ let nz: Vec<(usize, i32)> = l_levels.iter().copied().enumerate().filter(|(_, v)| *v != 0).collect();
3635+ eprintln!(" luma_tx_type={luma_tx_type:?} nz_levels={nz:?}");
3636+ }
36273637 luma_levels = l_levels;
36283638 let luma_residual = dequant_and_inverse_typed_wh(
36293639 &luma_levels, bw, bh, crate::decode::bit_depth(),
crates/ec-av1/src/stream.rsmodified+75 -0
@@ -5328,6 +5328,81 @@ mod tests {
53285328 result.as_ref().map(|f| f.len()).map_err(|e| e.to_string())
53295329 );
53305330 }
5331+ #[test]
5332+ fn scratch_probe_rectx_mandelbrot() {
5333+ let _gate_lock = lock_gate_counters();
5334+ if !have_ffmpeg() || !have_aomenc() {
5335+ eprintln!("SKIP: no tools");
5336+ return;
5337+ }
5338+ let cases = vec![(64usize, 64usize, 24u32, 0.4f64)];
5339+ let mut found = false;
5340+ for (width, height, cq, seed_off) in cases {
5341+ let y4m = Command::new("ffmpeg")
5342+ .args([
5343+ "-v", "error", "-f", "lavfi", "-i",
5344+ &format!("mandelbrot=size={width}x{height}:start_x={seed_off}"),
5345+ "-pix_fmt", "yuv420p", "-t", "1", "-vframes", "1", "-f", "yuv4mpegpipe", "-",
5346+ ])
5347+ .stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped())
5348+ .output().expect("ffmpeg failed to run");
5349+ assert!(y4m.status.success());
5350+ let mut child = Command::new(aomenc_path())
5351+ .args([
5352+ "--threads=1", "--row-mt=0", "--sb-size=64", "--cpu-used=4", "--end-usage=q",
5353+ &format!("--cq-level={cq}"), "--passes=1",
5354+ "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
5355+ "--enable-tx-size-search=0", "--min-partition-size=8",
5356+ "--max-partition-size=32", "--kf-max-dist=0",
5357+ "--obu", "-o", "-", "-",
5358+ ])
5359+ .stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::piped())
5360+ .spawn().expect("aomenc failed to start");
5361+ child.stdin.take().unwrap().write_all(&y4m.stdout).unwrap();
5362+ let out = child.wait_with_output().unwrap();
5363+ assert!(out.status.success());
5364+ let stream = out.stdout;
5365+ let before = crate::decode::rect_leaf_coeff_hits();
5366+ let result = decode_stream(&stream);
5367+ let delta = crate::decode::rect_leaf_coeff_hits() - before;
5368+ if delta > 0 {
5369+ if let Ok(frames) = &result {
5370+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len());
5371+ let mismatched = frames.iter().zip(&ffmpeg_frames).filter(|(g, w)| g.y != w.y || g.u != w.u || g.v != w.v).count();
5372+ eprintln!(
5373+ "HIT {width}x{height} cq={cq} off={seed_off}: rect_leaf_coeff_hits+={delta} mismatched={mismatched}/{}",
5374+ frames.len()
5375+ );
5376+ // debug: locate first y mismatch
5377+ if let (Some(got), Some(want)) = (frames.first(), ffmpeg_frames.first()) {
5378+ 'outer: for row in 0..height {
5379+ for col in 0..width {
5380+ let gi = row * width + col;
5381+ if got.y[gi] != want.y[gi] {
5382+ eprintln!(
5383+ "first Y mismatch at ({col},{row}): got={} want={}",
5384+ got.y[gi], want.y[gi]
5385+ );
5386+ break 'outer;
5387+ }
5388+ }
5389+ }
5390+ }
5391+ if mismatched == 0 {
5392+ found = true;
5393+ break;
5394+ }
5395+ } else {
5396+ eprintln!(
5397+ "{width}x{height} cq={cq} off={seed_off}: rect_leaf_coeff_hits+={delta} result={:?}",
5398+ result.as_ref().map(|f| f.len()).map_err(|e| e.to_string())
5399+ );
5400+ }
5401+ }
5402+ }
5403+ eprintln!("found pixel-exact firing case: {found}");
5404+ }
5405+
53315406 /// lane-rectgate r1: every prior gate pins `--enable-rect-partitions=0
53325407 /// --enable-ab-partitions=0 --min/max-partition-size=32` so aomenc never
53335408 /// gets to choose a real rect/ab split. This charter's premise ("rect