Per-reference GLOBAL warp on compound blocks (was silently translational)
Browse files at this commite67ae7fa5e449ad0a9c79f1d5104f0a9c1a3cabeParent: 1c1fd67- feat
- per-reference GLOBAL warp on compound blocks (was silently translational)
5 changed files +536 -23
- crates/ec-av1/src/decode.rs +124 -6
- crates/ec-av1/src/mc.rs +9 -1
- crates/ec-av1/src/stream.rs +201 -0
- crates/ec-av1/src/warp.rs +104 -16
- lanes/cwarp-r1.report.md +98 -0
crates/ec-av1/src/decode.rsmodified+124 -6
| @@ -638,6 +638,21 @@ pub(crate) fn warp_selected_hits() -> usize { | |||
| 638 | WARP_SELECTED_HITS.with(|c| c.get()) | 638 | WARP_SELECTED_HITS.with(|c| c.get()) |
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | +// lane-cwarp r1: how many COMPOUND_REFERENCE blocks had at least one | ||
| 642 | +// reference predicted through the per-ref GLOBAL warp (`av1_warp_plane` | ||
| 643 | +// into the compound intermediate) rather than translationally -- the | ||
| 644 | +// gate's proof that a `GLOBAL_GLOBALMV` block under a ROTZOOM/AFFINE model | ||
| 645 | +// really reached [`crate::warp::warp_affine_compound`]. | ||
| 646 | +thread_local! { | ||
| 647 | + static COMPOUND_WARP_HITS: std::cell::Cell<usize> = | ||
| 648 | + const { std::cell::Cell::new(0) }; | ||
| 649 | +} | ||
| 650 | + | ||
| 651 | +/// Current value of [`COMPOUND_WARP_HITS`]. | ||
| 652 | +pub(crate) fn compound_warp_hits() -> usize { | ||
| 653 | + COMPOUND_WARP_HITS.with(|c| c.get()) | ||
| 654 | +} | ||
| 655 | + | ||
| 641 | // How many blocks decoded `interintra == 1` with the non-wedge blended | 656 | // How many blocks decoded `interintra == 1` with the non-wedge blended |
| 642 | // prediction applied (lane-interintra r1) -- the gate's proof that a | 657 | // prediction applied (lane-interintra r1) -- the gate's proof that a |
| 643 | // stream actually exercised interintra. | 658 | // stream actually exercised interintra. |
| @@ -9058,6 +9073,45 @@ fn decode_inter_block( | |||
| 9058 | && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation; | 9073 | && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation; |
| 9059 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; | 9074 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 9060 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; | 9075 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 9076 | + // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is | ||
| 9077 | + // PER REFERENCE SLOT -- mode GLOBAL_GLOBALMV, block >= 8x8, and | ||
| 9078 | + // THAT slot's own gm model > TRANSLATION. `bw4`/`bh4` come from | ||
| 9079 | + // the write extent below, so recompute the size bound from | ||
| 9080 | + // `side` here (the block's own size, what libaom's `bsize` | ||
| 9081 | + // is). | ||
| 9082 | + let is_global_mv0 = is_globalmv | ||
| 9083 | + && side >= 8 | ||
| 9084 | + && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1; | ||
| 9085 | + let is_global_mv1 = is_globalmv | ||
| 9086 | + && side >= 8 | ||
| 9087 | + && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; | ||
| 9088 | + // libaom `av1_init_warp_params` + `allow_warp`'s | ||
| 9089 | + // `global_warp_allowed` branch, run once per reference for a | ||
| 9090 | + // compound block exactly as for a single-ref one (reconinter.c | ||
| 9091 | + // `build_inter_predictors_8x8_and_bigger` loops over `ref` and | ||
| 9092 | + // calls `av1_init_warp_params` inside the loop) -- WARPED_CAUSAL | ||
| 9093 | + // never reaches here (spec 5.11.27 / libaom `read_motion_mode`: | ||
| 9094 | + // `has_second_ref` returns SIMPLE_TRANSLATION), so the local-warp | ||
| 9095 | + // arm of `allow_warp` is dead on this path and only the global | ||
| 9096 | + // one applies. `force_integer_mv` short-circuits | ||
| 9097 | + // `av1_init_warp_params` before `allow_warp`. | ||
| 9098 | + let compound_warp = |ref_frame: i8, eligible: bool| { | ||
| 9099 | + if eligible | ||
| 9100 | + && !force_integer_mv | ||
| 9101 | + && !global_motion[(ref_frame - LAST_FRAME) as usize].invalid | ||
| 9102 | + { | ||
| 9103 | + crate::warp::global_warp_params( | ||
| 9104 | + global_motion[(ref_frame - LAST_FRAME) as usize].params, | ||
| 9105 | + ) | ||
| 9106 | + } else { | ||
| 9107 | + None | ||
| 9108 | + } | ||
| 9109 | + }; | ||
| 9110 | + let warp0 = compound_warp(ref0, is_global_mv0); | ||
| 9111 | + let warp1 = compound_warp(ref1, is_global_mv1); | ||
| 9112 | + if warp0.is_some() || warp1.is_some() { | ||
| 9113 | + COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9114 | + } | ||
| 9061 | // spec `get_ref_filter_type`: matches when EITHER of the | 9115 | // spec `get_ref_filter_type`: matches when EITHER of the |
| 9062 | // neighbour's two references equals this block's own ref0 -- | 9116 | // neighbour's two references equals this block's own ref0 -- |
| 9063 | // `above_ref1`/`left_ref1` is the neighbour's real second | 9117 | // `above_ref1`/`left_ref1` is the neighbour's real second |
| @@ -9108,12 +9162,8 @@ fn decode_inter_block( | |||
| 9108 | // own gm model > TRANSLATION (IDENTITY excluded | 9162 | // own gm model > TRANSLATION (IDENTITY excluded |
| 9109 | // too -- the two-predicate trap, distinct from | 9163 | // too -- the two-predicate trap, distinct from |
| 9110 | // `gm_nontrans` above which allows IDENTITY). | 9164 | // `gm_nontrans` above which allows IDENTITY). |
| 9111 | - is_global_mv0: is_globalmv | 9165 | + is_global_mv0, |
| 9112 | - && bw4.min(bh4) >= 2 | 9166 | + is_global_mv1, |
| 9113 | - && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1, | ||
| 9114 | - is_global_mv1: is_globalmv | ||
| 9115 | - && bw4.min(bh4) >= 2 | ||
| 9116 | - && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1, | ||
| 9117 | }, | 9167 | }, |
| 9118 | ); | 9168 | ); |
| 9119 | } | 9169 | } |
| @@ -9456,6 +9506,16 @@ fn decode_inter_block( | |||
| 9456 | v_filter, | 9506 | v_filter, |
| 9457 | &mut inter0_y, | 9507 | &mut inter0_y, |
| 9458 | ); | 9508 | ); |
| 9509 | + // lane-cwarp r1: this reference's own GLOBAL warp replaces the | ||
| 9510 | + // translational tap (libaom `av1_warp_plane` with | ||
| 9511 | + // `conv_params->is_compound`); the blend below is unchanged. | ||
| 9512 | + if let Some(wp) = &warp0 { | ||
| 9513 | + crate::warp::warp_affine_compound( | ||
| 9514 | + wp, &py0.data, py0.true_width as i32, py0.true_height as i32, | ||
| 9515 | + py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32, | ||
| 9516 | + side as i32, side as i32, 0, 0, | ||
| 9517 | + ); | ||
| 9518 | + } | ||
| 9459 | let mut inter1_y = vec![0i32; side * side]; | 9519 | let mut inter1_y = vec![0i32; side * side]; |
| 9460 | mc::predict_compound_intermediate( | 9520 | mc::predict_compound_intermediate( |
| 9461 | &py1.data, | 9521 | &py1.data, |
| @@ -9470,6 +9530,16 @@ fn decode_inter_block( | |||
| 9470 | v_filter, | 9530 | v_filter, |
| 9471 | &mut inter1_y, | 9531 | &mut inter1_y, |
| 9472 | ); | 9532 | ); |
| 9533 | + // lane-cwarp r1: this reference's own GLOBAL warp replaces the | ||
| 9534 | + // translational tap (libaom `av1_warp_plane` with | ||
| 9535 | + // `conv_params->is_compound`); the blend below is unchanged. | ||
| 9536 | + if let Some(wp) = &warp1 { | ||
| 9537 | + crate::warp::warp_affine_compound( | ||
| 9538 | + wp, &py1.data, py1.true_width as i32, py1.true_height as i32, | ||
| 9539 | + py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32, | ||
| 9540 | + side as i32, side as i32, 0, 0, | ||
| 9541 | + ); | ||
| 9542 | + } | ||
| 9473 | let mut pred_y = vec![0u16; side * side]; | 9543 | let mut pred_y = vec![0u16; side * side]; |
| 9474 | let mut diffwtd_mask_y = Vec::new(); | 9544 | let mut diffwtd_mask_y = Vec::new(); |
| 9475 | // lane-wedge r3: `mask_y` is the DIFFWTD buffer just computed OR | 9545 | // lane-wedge r3: `mask_y` is the DIFFWTD buffer just computed OR |
| @@ -9505,6 +9575,18 @@ fn decode_inter_block( | |||
| 9505 | v_filter, | 9575 | v_filter, |
| 9506 | &mut inter0_u, | 9576 | &mut inter0_u, |
| 9507 | ); | 9577 | ); |
| 9578 | + // `av1_init_warp_params` bails when the PLANE's block is | ||
| 9579 | + // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma | ||
| 9580 | + // block of an 8x8 luma block stays translational. | ||
| 9581 | + if let Some(wp) = &warp0 { | ||
| 9582 | + if chroma_side >= 8 { | ||
| 9583 | + crate::warp::warp_affine_compound( | ||
| 9584 | + wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32, | ||
| 9585 | + pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32, | ||
| 9586 | + chroma_side as i32, chroma_side as i32, chroma_side as i32, 1, 1, | ||
| 9587 | + ); | ||
| 9588 | + } | ||
| 9589 | + } | ||
| 9508 | let mut inter1_u = vec![0i32; chroma_side * chroma_side]; | 9590 | let mut inter1_u = vec![0i32; chroma_side * chroma_side]; |
| 9509 | mc::predict_compound_intermediate( | 9591 | mc::predict_compound_intermediate( |
| 9510 | &pu1.data, | 9592 | &pu1.data, |
| @@ -9519,6 +9601,18 @@ fn decode_inter_block( | |||
| 9519 | v_filter, | 9601 | v_filter, |
| 9520 | &mut inter1_u, | 9602 | &mut inter1_u, |
| 9521 | ); | 9603 | ); |
| 9604 | + // `av1_init_warp_params` bails when the PLANE's block is | ||
| 9605 | + // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma | ||
| 9606 | + // block of an 8x8 luma block stays translational. | ||
| 9607 | + if let Some(wp) = &warp1 { | ||
| 9608 | + if chroma_side >= 8 { | ||
| 9609 | + crate::warp::warp_affine_compound( | ||
| 9610 | + wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32, | ||
| 9611 | + pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32, | ||
| 9612 | + chroma_side as i32, chroma_side as i32, chroma_side as i32, 1, 1, | ||
| 9613 | + ); | ||
| 9614 | + } | ||
| 9615 | + } | ||
| 9522 | let mut pred_u = vec![0u16; chroma_side * chroma_side]; | 9616 | let mut pred_u = vec![0u16; chroma_side * chroma_side]; |
| 9523 | if let Some(mask_y) = mask_y { | 9617 | if let Some(mask_y) = mask_y { |
| 9524 | mc::blend_masked_compound( | 9618 | mc::blend_masked_compound( |
| @@ -9549,6 +9643,18 @@ fn decode_inter_block( | |||
| 9549 | v_filter, | 9643 | v_filter, |
| 9550 | &mut inter0_v, | 9644 | &mut inter0_v, |
| 9551 | ); | 9645 | ); |
| 9646 | + // `av1_init_warp_params` bails when the PLANE's block is | ||
| 9647 | + // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma | ||
| 9648 | + // block of an 8x8 luma block stays translational. | ||
| 9649 | + if let Some(wp) = &warp0 { | ||
| 9650 | + if chroma_side >= 8 { | ||
| 9651 | + crate::warp::warp_affine_compound( | ||
| 9652 | + wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32, | ||
| 9653 | + pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32, | ||
| 9654 | + chroma_side as i32, chroma_side as i32, chroma_side as i32, 1, 1, | ||
| 9655 | + ); | ||
| 9656 | + } | ||
| 9657 | + } | ||
| 9552 | let mut inter1_v = vec![0i32; chroma_side * chroma_side]; | 9658 | let mut inter1_v = vec![0i32; chroma_side * chroma_side]; |
| 9553 | mc::predict_compound_intermediate( | 9659 | mc::predict_compound_intermediate( |
| 9554 | &pv1.data, | 9660 | &pv1.data, |
| @@ -9563,6 +9669,18 @@ fn decode_inter_block( | |||
| 9563 | v_filter, | 9669 | v_filter, |
| 9564 | &mut inter1_v, | 9670 | &mut inter1_v, |
| 9565 | ); | 9671 | ); |
| 9672 | + // `av1_init_warp_params` bails when the PLANE's block is | ||
| 9673 | + // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma | ||
| 9674 | + // block of an 8x8 luma block stays translational. | ||
| 9675 | + if let Some(wp) = &warp1 { | ||
| 9676 | + if chroma_side >= 8 { | ||
| 9677 | + crate::warp::warp_affine_compound( | ||
| 9678 | + wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32, | ||
| 9679 | + pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32, | ||
| 9680 | + chroma_side as i32, chroma_side as i32, chroma_side as i32, 1, 1, | ||
| 9681 | + ); | ||
| 9682 | + } | ||
| 9683 | + } | ||
| 9566 | let mut pred_v = vec![0u16; chroma_side * chroma_side]; | 9684 | let mut pred_v = vec![0u16; chroma_side * chroma_side]; |
| 9567 | if let Some(mask_y) = mask_y { | 9685 | if let Some(mask_y) = mask_y { |
| 9568 | mc::blend_masked_compound( | 9686 | mc::blend_masked_compound( |
crates/ec-av1/src/mc.rsmodified+9 -1
| @@ -674,7 +674,15 @@ pub fn diffwtd_mask(pred0: &[i32], pred1: &[i32], inv: bool, mask: &mut [u8]) { | |||
| 674 | assert_eq!(pred0.len(), pred1.len(), "both refs predict the same block"); | 674 | assert_eq!(pred0.len(), pred1.len(), "both refs predict the same block"); |
| 675 | assert_eq!(mask.len(), pred0.len(), "one mask byte per pixel"); | 675 | assert_eq!(mask.len(), pred0.len(), "one mask byte per pixel"); |
| 676 | for i in 0..mask.len() { | 676 | for i in 0..mask.len() { |
| 677 | - let diff = round2((pred0[i] - pred1[i]).abs(), INTER_POST_ROUND); | 677 | + // lane-cwarp r1: libaom's `round` is `2*FILTER_BITS - round_0 - |
| 678 | + // round_1 + (bd - 8)` (`diffwtd_mask_d16`, reconinter.c:306) -- the | ||
| 679 | + // `(bd - 8)` term (which this function's own doc comment already | ||
| 680 | + // named) was missing, so every 10-bit DIFFWTD mask was computed 4x | ||
| 681 | + // too coarse. Caught by lane-cwarp's 10-bit gate arm: a 10-bit | ||
| 682 | + // compound stream with global motion AND warp disabled still | ||
| 683 | + // mismatched at frame 1. | ||
| 684 | + let round = INTER_POST_ROUND + u32::from(crate::decode::bit_depth() - 8); | ||
| 685 | + let diff = round2((pred0[i] - pred1[i]).abs(), round); | ||
| 678 | let m = (38 + diff / 16).clamp(0, 64); | 686 | let m = (38 + diff / 16).clamp(0, 64); |
| 679 | mask[i] = if inv { (64 - m) as u8 } else { m as u8 }; | 687 | mask[i] = if inv { (64 - m) as u8 } else { m as u8 }; |
| 680 | } | 688 | } |
crates/ec-av1/src/stream.rsmodified+201 -0
| @@ -5960,6 +5960,207 @@ mod tests { | |||
| 5960 | ); | 5960 | ); |
| 5961 | } | 5961 | } |
| 5962 | 5962 | ||
| 5963 | + /// lane-cwarp r1: a real `--enable-global-motion=1 --enable-dist-wtd-comp=1` | ||
| 5964 | + /// stream over a rotating/zooming source, so a `GLOBAL_GLOBALMV` compound | ||
| 5965 | + /// block lands under a ROTZOOM/AFFINE model and each of its two references | ||
| 5966 | + /// is predicted through its OWN global warp | ||
| 5967 | + /// (`crate::warp::warp_affine_compound`, libaom `av1_warp_plane` with | ||
| 5968 | + /// `conv_params->is_compound`) rather than translationally. Before r1 that | ||
| 5969 | + /// path was SILENTLY WRONG -- no refusal named it, both taps went through | ||
| 5970 | + /// `mc::predict_compound_intermediate`. `compound_warp_hits() > 0` is a | ||
| 5971 | + /// hard assert: a run where the encoder never emitted one proves nothing. | ||
| 5972 | + /// A decode error or a pixel mismatch is a FAILURE, never a skip. | ||
| 5973 | + fn run_compound_global_warp_gate(name: &str, ten_bit: bool) { | ||
| 5974 | + let _gate_lock = lock_gate_counters(); | ||
| 5975 | + assert!(have_ffmpeg(), "{name}: ffmpeg required"); | ||
| 5976 | + assert!(have_aomenc(), "{name}: no aomenc at {}", aomenc_path().display()); | ||
| 5977 | + let (width, height, frame_count) = (64usize, 64usize, 24usize); | ||
| 5978 | + let before = crate::decode::compound_warp_hits(); | ||
| 5979 | + let mut matched = 0u32; | ||
| 5980 | + let mut named_refusals = 0u32; | ||
| 5981 | + let mut attempts = 0u32; | ||
| 5982 | + for cq in [32u32, 45, 55] { | ||
| 5983 | + for (i, rate) in [0.010f64, 0.022].iter().enumerate() { | ||
| 5984 | + attempts += 1; | ||
| 5985 | + let duration = frame_count as f64 / 25.0; | ||
| 5986 | + // A rotation about the frame centre plus a slow zoom is what | ||
| 5987 | + // aomenc's global-motion search fits a ROTZOOM/AFFINE model to; | ||
| 5988 | + // mandelbrot gives it real, non-flat texture to track. | ||
| 5989 | + let source = format!( | ||
| 5990 | + "mandelbrot=size={w}x{h}:rate=25:start_x={sx}:start_y=-0.4,\ | ||
| 5991 | + rotate=a={rate}*n:ow={w}:oh={h}:c=black,scale={width}:{height}", | ||
| 5992 | + w = width * 2, | ||
| 5993 | + h = height * 2, | ||
| 5994 | + sx = -0.6 + 0.01 * (i as f64), | ||
| 5995 | + ); | ||
| 5996 | + let pix_fmt = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 5997 | + let y4m = Command::new("ffmpeg") | ||
| 5998 | + .args([ | ||
| 5999 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", | ||
| 6000 | + &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1", | ||
| 6001 | + "-f", "yuv4mpegpipe", "-", | ||
| 6002 | + ]) | ||
| 6003 | + .stdin(Stdio::null()) | ||
| 6004 | + .stdout(Stdio::piped()) | ||
| 6005 | + .stderr(Stdio::piped()) | ||
| 6006 | + .output() | ||
| 6007 | + .expect("ffmpeg failed to run"); | ||
| 6008 | + assert!( | ||
| 6009 | + y4m.status.success(), | ||
| 6010 | + "ffmpeg fixture: {}", | ||
| 6011 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 6012 | + ); | ||
| 6013 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 6014 | + let mut args: Vec<&str> = vec![ | ||
| 6015 | + "--codec=av1", | ||
| 6016 | + "--passes=1", | ||
| 6017 | + "--end-usage=q", | ||
| 6018 | + &cq_arg, | ||
| 6019 | + "--cpu-used=0", | ||
| 6020 | + "--kf-max-dist=1000", | ||
| 6021 | + "--threads=1", | ||
| 6022 | + "--row-mt=0", | ||
| 6023 | + "--auto-alt-ref=1", | ||
| 6024 | + "--lag-in-frames=25", | ||
| 6025 | + "--enable-fwd-kf=0", | ||
| 6026 | + "--enable-order-hint=1", | ||
| 6027 | + // the two tools this gate exists for | ||
| 6028 | + "--enable-global-motion=1", | ||
| 6029 | + "--enable-dist-wtd-comp=1", | ||
| 6030 | + "--enable-warped-motion=1", | ||
| 6031 | + "--enable-obmc=1", | ||
| 6032 | + "--enable-masked-comp=1", | ||
| 6033 | + "--enable-onesided-comp=0", | ||
| 6034 | + "--enable-interintra-comp=1", | ||
| 6035 | + "--enable-interintra-wedge=0", | ||
| 6036 | + "--enable-smooth-interintra=1", | ||
| 6037 | + "--tune-content=default", | ||
| 6038 | + // partition/intra tools this decoder does not code yet -- | ||
| 6039 | + // same exclusion list every compound gate carries. | ||
| 6040 | + "--enable-rect-partitions=0", | ||
| 6041 | + "--enable-ab-partitions=0", | ||
| 6042 | + "--enable-1to4-partitions=0", | ||
| 6043 | + "--enable-filter-intra=0", | ||
| 6044 | + "--enable-smooth-intra=0", | ||
| 6045 | + "--enable-paeth-intra=0", | ||
| 6046 | + "--enable-directional-intra=0", | ||
| 6047 | + "--enable-angle-delta=0", | ||
| 6048 | + "--enable-tx-size-search=0", | ||
| 6049 | + "--enable-cdef=0", | ||
| 6050 | + "--enable-restoration=0", | ||
| 6051 | + "--max-partition-size=32", | ||
| 6052 | + "--min-partition-size=32", | ||
| 6053 | + "--enable-palette=0", | ||
| 6054 | + "--enable-intrabc=0", | ||
| 6055 | + "--enable-cfl-intra=0", | ||
| 6056 | + "--enable-ref-frame-mvs=0", | ||
| 6057 | + ]; | ||
| 6058 | + if ten_bit { | ||
| 6059 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 6060 | + } | ||
| 6061 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 6062 | + let mut child = Command::new(aomenc_path()) | ||
| 6063 | + .args(&args) | ||
| 6064 | + .stdin(Stdio::piped()) | ||
| 6065 | + .stdout(Stdio::piped()) | ||
| 6066 | + .stderr(Stdio::piped()) | ||
| 6067 | + .spawn() | ||
| 6068 | + .expect("aomenc failed to start"); | ||
| 6069 | + child | ||
| 6070 | + .stdin | ||
| 6071 | + .take() | ||
| 6072 | + .expect("aomenc stdin") | ||
| 6073 | + .write_all(&y4m.stdout) | ||
| 6074 | + .expect("writing y4m to aomenc"); | ||
| 6075 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 6076 | + assert!( | ||
| 6077 | + out.status.success(), | ||
| 6078 | + "aomenc refused the fixture: {}", | ||
| 6079 | + String::from_utf8_lossy(&out.stderr) | ||
| 6080 | + ); | ||
| 6081 | + let stream = out.stdout; | ||
| 6082 | + let frames = match decode_stream(&stream) { | ||
| 6083 | + Err(e) => { | ||
| 6084 | + let msg = e.to_string(); | ||
| 6085 | + assert!( | ||
| 6086 | + msg.contains("unsupported"), | ||
| 6087 | + "{name} failed outright, not a named refusal (cq {cq}): {msg}" | ||
| 6088 | + ); | ||
| 6089 | + assert!( | ||
| 6090 | + !msg.contains("warp"), | ||
| 6091 | + "{name} refused on warp (cq {cq}) -- warp decode is ported: {msg}" | ||
| 6092 | + ); | ||
| 6093 | + named_refusals += 1; | ||
| 6094 | + eprintln!("{name} cq {cq} rate {rate} refusal: {msg}"); | ||
| 6095 | + continue; | ||
| 6096 | + } | ||
| 6097 | + Ok(frames) => frames, | ||
| 6098 | + }; | ||
| 6099 | + let want = if ten_bit { | ||
| 6100 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 6101 | + } else { | ||
| 6102 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 6103 | + }; | ||
| 6104 | + assert_eq!(frames.len(), frame_count); | ||
| 6105 | + if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") | ||
| 6106 | + && frames | ||
| 6107 | + .iter() | ||
| 6108 | + .zip(&want) | ||
| 6109 | + .any(|(g, w)| g.y != w.y || g.u != w.u || g.v != w.v) | ||
| 6110 | + { | ||
| 6111 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 6112 | + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (cq {cq}) to {path}"); | ||
| 6113 | + } | ||
| 6114 | + for (i, (got, want)) in frames.iter().zip(&want).enumerate() { | ||
| 6115 | + assert_eq!(got.y, want.y, "{name} frame {i} luma vs ffmpeg (cq {cq})"); | ||
| 6116 | + assert_eq!(got.u, want.u, "{name} frame {i} U vs ffmpeg (cq {cq})"); | ||
| 6117 | + assert_eq!(got.v, want.v, "{name} frame {i} V vs ffmpeg (cq {cq})"); | ||
| 6118 | + } | ||
| 6119 | + matched += 1; | ||
| 6120 | + } | ||
| 6121 | + } | ||
| 6122 | + let hits = crate::decode::compound_warp_hits() - before; | ||
| 6123 | + eprintln!( | ||
| 6124 | + "{name}: {matched}/{attempts} pixel-exact, {named_refusals} named refusals, \ | ||
| 6125 | + compound_warp_hits={hits}" | ||
| 6126 | + ); | ||
| 6127 | + assert!( | ||
| 6128 | + hits > 0, | ||
| 6129 | + "{name}: no compound block was predicted through a per-ref global warp \ | ||
| 6130 | + ({matched} matches, {named_refusals} refusals of {attempts}) -- gate vacuous" | ||
| 6131 | + ); | ||
| 6132 | + assert!(matched > 0, "{name}: every attempt refused -- no pixel comparison ran"); | ||
| 6133 | + } | ||
| 6134 | + | ||
| 6135 | + /// 8-bit arm of [`run_compound_global_warp_gate`]. | ||
| 6136 | + #[test] | ||
| 6137 | + fn a_real_compound_global_warp_stream_decodes_pixel_exact() { | ||
| 6138 | + run_compound_global_warp_gate("a_real_compound_global_warp_stream_decodes_pixel_exact", false); | ||
| 6139 | + } | ||
| 6140 | + | ||
| 6141 | + /// 10-bit arm of [`run_compound_global_warp_gate`] -- both of his films are | ||
| 6142 | + /// `yuv420p10le`, and `warp_affine`'s `bd` was hardcoded 8 before r1. | ||
| 6143 | + /// | ||
| 6144 | + /// IGNORED, blocked by a PRE-EXISTING 10-bit COMPOUND defect this lane did | ||
| 6145 | + /// not introduce and does not own. Ablation run by lane-cwarp r1 on this | ||
| 6146 | + /// very recipe: with `--enable-global-motion=0 --enable-warped-motion=0` | ||
| 6147 | + /// (no warp of any kind reachable) the 10-bit stream STILL mismatches at | ||
| 6148 | + /// frame 1 luma, cq 32; with `--auto-alt-ref=0 --lag-in-frames=0 | ||
| 6149 | + /// --enable-dist-wtd-comp=0` (single-reference 10-bit inter only) the same | ||
| 6150 | + /// recipe is 6/6 pixel-exact. So: 10-bit single-ref inter is exact, 10-bit | ||
| 6151 | + /// compound is not. `mc::diffwtd_mask`'s missing `(bd - 8)` round term was | ||
| 6152 | + /// found and fixed while bisecting this, but is NOT the whole defect. | ||
| 6153 | + /// Un-ignore the moment the 10-bit compound path is fixed -- the warp | ||
| 6154 | + /// wiring under test here is bit-depth generic already. | ||
| 6155 | + #[test] | ||
| 6156 | + #[ignore = "blocked by a pre-existing 10-bit compound MC defect (see doc comment)"] | ||
| 6157 | + fn a_real_compound_global_warp_10bit_stream_decodes_pixel_exact() { | ||
| 6158 | + run_compound_global_warp_gate( | ||
| 6159 | + "a_real_compound_global_warp_10bit_stream_decodes_pixel_exact", | ||
| 6160 | + true, | ||
| 6161 | + ); | ||
| 6162 | + } | ||
| 6163 | + | ||
| 5963 | /// lane-maskcomp r2 / lane-wedge r3: `--enable-masked-comp=1` streams | 6164 | /// lane-maskcomp r2 / lane-wedge r3: `--enable-masked-comp=1` streams |
| 5964 | /// must consume `compound_type`/`wedge_idx`/`wedge_sign`/`mask_type` | 6165 | /// must consume `compound_type`/`wedge_idx`/`wedge_sign`/`mask_type` |
| 5965 | /// entropy-exact AND build the real blend, DIFFWTD or WEDGE -- | 6166 | /// entropy-exact AND build the real blend, DIFFWTD or WEDGE -- |
crates/ec-av1/src/warp.rsmodified+104 -16
| @@ -2,11 +2,13 @@ | |||
| 2 | //! `av1/common/warped_motion.c`: estimate a 2x3 affine model from up to | 2 | //! `av1/common/warped_motion.c`: estimate a 2x3 affine model from up to |
| 3 | //! `LEAST_SQUARES_SAMPLES_MAX` neighbour-block motion samples | 3 | //! `LEAST_SQUARES_SAMPLES_MAX` neighbour-block motion samples |
| 4 | //! ([`find_projection`]), then filter the reference through it with an 8x8 | 4 | //! ([`find_projection`]), then filter the reference through it with an 8x8 |
| 5 | -//! tiled, two-pass 8-tap warped filter ([`warp_affine`]). 8-bit, | 5 | +//! tiled, two-pass 8-tap warped filter ([`warp_affine`]). Bit-depth generic |
| 6 | -//! non-compound only (this decoder's warp arm only ever reaches a | 6 | +//! (lane-cwarp: `bd` is `crate::decode::bit_depth()`, was a hardcoded 8). |
| 7 | -//! single-ref, non-skip-mode block, spec `is_motion_variation_allowed_bsize` | 7 | +//! `WARPED_CAUSAL` is single-ref by construction (spec 5.11.27: |
| 8 | -//! -- `conv_params->is_compound` is always false on that path, so libaom's | 8 | +//! `motion_mode` is only read when `RefFrame[1] <= INTRA_FRAME`), but GLOBAL |
| 9 | -//! compound/highbd branches are dropped). | 9 | +//! warp applies per reference on a compound block too -- |
| 10 | +//! [`warp_affine_compound`] is that path (libaom `av1_warp_plane` with | ||
| 11 | +//! `conv_params->is_compound`). | ||
| 10 | 12 | ||
| 11 | /// `WARPEDMODEL_PREC_BITS` (`av1/common/mv.h`). | 13 | /// `WARPEDMODEL_PREC_BITS` (`av1/common/mv.h`). |
| 12 | const WARPEDMODEL_PREC_BITS: u32 = 16; | 14 | const WARPEDMODEL_PREC_BITS: u32 = 16; |
| @@ -419,11 +421,13 @@ fn clip_pixel(v: i32) -> u16 { | |||
| 419 | v.clamp(0, crate::decode::sample_max()) as u16 | 421 | v.clamp(0, crate::decode::sample_max()) as u16 |
| 420 | } | 422 | } |
| 421 | 423 | ||
| 422 | -/// `av1_warp_affine_c` (`warped_motion.c`), 8-bit, non-compound only: | 424 | +/// `av1_highbd_warp_affine_c` (`warped_motion.c`)'s non-compound branch: |
| 423 | /// filters `reference` (row-major, `stride`, true extent `width`x`height`) | 425 | /// filters `reference` (row-major, `stride`, true extent `width`x`height`) |
| 424 | /// through `params`' affine model into `dst` (row-major, `p_stride`), an | 426 | /// through `params`' affine model into `dst` (row-major, `p_stride`), an |
| 425 | /// `p_width`x`p_height` block whose top-left sits at `(p_col, p_row)` in the | 427 | /// `p_width`x`p_height` block whose top-left sits at `(p_col, p_row)` in the |
| 426 | -/// (possibly chroma-subsampled) plane `dst` belongs to. | 428 | +/// (possibly chroma-subsampled) plane `dst` belongs to. Bit depth comes from |
| 429 | +/// the stream (`crate::decode::bit_depth`), the same thread-local | ||
| 430 | +/// [`clip_pixel`] already clamps against -- libaom's `bd` parameter. | ||
| 427 | #[allow(clippy::too_many_arguments)] | 431 | #[allow(clippy::too_many_arguments)] |
| 428 | pub fn warp_affine( | 432 | pub fn warp_affine( |
| 429 | params: &WarpParams, | 433 | params: &WarpParams, |
| @@ -439,6 +443,91 @@ pub fn warp_affine( | |||
| 439 | p_stride: i32, | 443 | p_stride: i32, |
| 440 | subsampling_x: i32, | 444 | subsampling_x: i32, |
| 441 | subsampling_y: i32, | 445 | subsampling_y: i32, |
| 446 | +) { | ||
| 447 | + let bd = i32::from(crate::decode::bit_depth()); | ||
| 448 | + // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0`. | ||
| 449 | + let reduce_bits_vert = 2 * FILTER_BITS - REDUCE_BITS_HORIZ; | ||
| 450 | + warp_inner( | ||
| 451 | + params, reference, width, height, stride, p_col, p_row, p_width, p_height, | ||
| 452 | + subsampling_x, subsampling_y, bd, reduce_bits_vert, | ||
| 453 | + |row, col, sum| { | ||
| 454 | + dst[row * p_stride as usize + col] = | ||
| 455 | + clip_pixel(sum - (1 << (bd - 1)) - (1 << bd)); | ||
| 456 | + }, | ||
| 457 | + ); | ||
| 458 | +} | ||
| 459 | + | ||
| 460 | +/// lane-cwarp: `av1_highbd_warp_affine_c`'s `conv_params->is_compound` | ||
| 461 | +/// branch (`do_average == 0`, i.e. "write the CONV_BUF entry"): identical | ||
| 462 | +/// filter, but the vertical pass rounds by `conv_params->round_1` | ||
| 463 | +/// (`COMPOUND_ROUND1_BITS == 7`, [`mc::predict_compound_intermediate`]'s | ||
| 464 | +/// `INTER_ROUND_1_COMPOUND`) instead of `2*FILTER_BITS - round_0`, and the | ||
| 465 | +/// result stays in the compound intermediate domain rather than becoming a | ||
| 466 | +/// pixel. libaom keeps a constant bias in its CONV_BUF (the | ||
| 467 | +/// `1 << offset_bits_horiz` / `1 << offset_bits_vert` terms, which survive | ||
| 468 | +/// both roundings exactly because both exceed their shift) and subtracts | ||
| 469 | +/// `(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))` | ||
| 470 | +/// at the blend; this crate's intermediates are UNBIASED (see | ||
| 471 | +/// [`mc::diffwtd_mask`]'s derivation), so the identical constant -- | ||
| 472 | +/// `(1 << (bd + 4)) + (1 << (bd + 3))` -- is removed here instead, making | ||
| 473 | +/// the output directly interchangeable with | ||
| 474 | +/// [`mc::predict_compound_intermediate`]'s for | ||
| 475 | +/// [`mc::combine_compound`]/[`mc::blend_masked_compound`]. | ||
| 476 | +#[allow(clippy::too_many_arguments)] | ||
| 477 | +pub fn warp_affine_compound( | ||
| 478 | + params: &WarpParams, | ||
| 479 | + reference: &[u16], | ||
| 480 | + width: i32, | ||
| 481 | + height: i32, | ||
| 482 | + stride: i32, | ||
| 483 | + dst: &mut [i32], | ||
| 484 | + p_col: i32, | ||
| 485 | + p_row: i32, | ||
| 486 | + p_width: i32, | ||
| 487 | + p_height: i32, | ||
| 488 | + p_stride: i32, | ||
| 489 | + subsampling_x: i32, | ||
| 490 | + subsampling_y: i32, | ||
| 491 | +) { | ||
| 492 | + let bd = i32::from(crate::decode::bit_depth()); | ||
| 493 | + let bias = (1 << (bd + 4)) + (1 << (bd + 3)); | ||
| 494 | + warp_inner( | ||
| 495 | + params, reference, width, height, stride, p_col, p_row, p_width, p_height, | ||
| 496 | + subsampling_x, subsampling_y, bd, COMPOUND_ROUND1_BITS, | ||
| 497 | + |row, col, sum| { | ||
| 498 | + dst[row * p_stride as usize + col] = sum - bias; | ||
| 499 | + }, | ||
| 500 | + ); | ||
| 501 | +} | ||
| 502 | + | ||
| 503 | +/// `conv_params->round_0` (`ROUND0_BITS`), the warp filter's horizontal | ||
| 504 | +/// rounding -- `InterRound0`, bit-depth independent for 8/10-bit content | ||
| 505 | +/// (libaom only raises it at `bd == 12`, which this decoder refuses). | ||
| 506 | +const REDUCE_BITS_HORIZ: i32 = 3; | ||
| 507 | +/// `COMPOUND_ROUND1_BITS` (`convolve.h`): `conv_params->round_1` when | ||
| 508 | +/// `is_compound`. | ||
| 509 | +const COMPOUND_ROUND1_BITS: i32 = 7; | ||
| 510 | + | ||
| 511 | +/// The shared body of [`warp_affine`]/[`warp_affine_compound`] | ||
| 512 | +/// (`av1_highbd_warp_affine_c`): everything up to and including the | ||
| 513 | +/// vertical `ROUND_POWER_OF_TWO(sum, reduce_bits_vert)`, with `store` | ||
| 514 | +/// receiving `(row, col, sum)` in block-local coordinates. | ||
| 515 | +#[allow(clippy::too_many_arguments)] | ||
| 516 | +fn warp_inner( | ||
| 517 | + params: &WarpParams, | ||
| 518 | + reference: &[u16], | ||
| 519 | + width: i32, | ||
| 520 | + height: i32, | ||
| 521 | + stride: i32, | ||
| 522 | + p_col: i32, | ||
| 523 | + p_row: i32, | ||
| 524 | + p_width: i32, | ||
| 525 | + p_height: i32, | ||
| 526 | + subsampling_x: i32, | ||
| 527 | + subsampling_y: i32, | ||
| 528 | + bd: i32, | ||
| 529 | + reduce_bits_vert: i32, | ||
| 530 | + mut store: impl FnMut(usize, usize, i32), | ||
| 442 | ) { | 531 | ) { |
| 443 | let mat = ¶ms.wmmat; | 532 | let mat = ¶ms.wmmat; |
| 444 | let (alpha, beta, gamma, delta) = ( | 533 | let (alpha, beta, gamma, delta) = ( |
| @@ -447,11 +536,9 @@ pub fn warp_affine( | |||
| 447 | params.gamma as i64, | 536 | params.gamma as i64, |
| 448 | params.delta as i64, | 537 | params.delta as i64, |
| 449 | ); | 538 | ); |
| 450 | - const BD: i32 = 8; | 539 | + let reduce_bits_horiz = REDUCE_BITS_HORIZ; |
| 451 | - let reduce_bits_horiz = 3; // conv_params->round_0, non-compound 8-bit (InterRound0) | 540 | + let offset_bits_horiz = bd + FILTER_BITS - 1; |
| 452 | - let reduce_bits_vert = 2 * FILTER_BITS - reduce_bits_horiz; // InterRound1 | 541 | + let offset_bits_vert = bd + 2 * FILTER_BITS - reduce_bits_horiz; |
| 453 | - let offset_bits_horiz = BD + FILTER_BITS - 1; | ||
| 454 | - let offset_bits_vert = BD + 2 * FILTER_BITS - reduce_bits_horiz; | ||
| 455 | 542 | ||
| 456 | let mut i = p_row; | 543 | let mut i = p_row; |
| 457 | while i < p_row + p_height { | 544 | while i < p_row + p_height { |
| @@ -509,10 +596,11 @@ pub fn warp_affine( | |||
| 509 | sum += tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32; | 596 | sum += tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32; |
| 510 | } | 597 | } |
| 511 | sum = round2(sum as i64, reduce_bits_vert as u32) as i32; | 598 | sum = round2(sum as i64, reduce_bits_vert as u32) as i32; |
| 512 | - let out_row = (i - p_row + k + 4) as usize; | 599 | + store( |
| 513 | - let out_col = (j - p_col + l + 4) as usize; | 600 | + (i - p_row + k + 4) as usize, |
| 514 | - dst[out_row * p_stride as usize + out_col] = | 601 | + (j - p_col + l + 4) as usize, |
| 515 | - clip_pixel(sum - (1 << (BD - 1)) - (1 << BD)); | 602 | + sum, |
| 603 | + ); | ||
| 516 | sy += gamma; | 604 | sy += gamma; |
| 517 | l += 1; | 605 | l += 1; |
| 518 | } | 606 | } |
lanes/cwarp-r1.report.mdadded+98 -0
| @@ -0,0 +1,98 @@ | |||
| 1 | +# lane-cwarp r1 -- per-reference GLOBAL warp on compound blocks | ||
| 2 | + | ||
| 3 | +VERDICT: DONE for the 8-bit path (new hard gate green, 37 real compound-warp | ||
| 4 | +blocks). 10-bit arm is written but `#[ignore]`d, blocked by a PRE-EXISTING | ||
| 5 | +10-bit *compound* MC defect this lane isolated but does not own. | ||
| 6 | + | ||
| 7 | +## Defect (charter premise re-measured, held) | ||
| 8 | +`decode_inter_block`'s COMPOUND_REFERENCE branch predicted BOTH taps | ||
| 9 | +translationally through `mc::predict_compound_intermediate`. libaom runs | ||
| 10 | +`av1_init_warp_params` inside its per-reference loop | ||
| 11 | +(`reconinter.c build_inter_predictors_8x8_and_bigger`), so each reference of a | ||
| 12 | +`GLOBAL_GLOBALMV` block whose own gm model is > TRANSLATION is filtered through | ||
| 13 | +`av1_warp_plane` into the compound intermediate. No refusal named this: the | ||
| 14 | +pixels were silently wrong. Confirmed live -- the new gate hits 37 such blocks | ||
| 15 | +in 6 real aomenc streams. | ||
| 16 | + | ||
| 17 | +`WARPED_CAUSAL` on a compound block: confirmed impossible, left alone. | ||
| 18 | +libaom `decodemv.c read_motion_mode` -> `motion_mode_allowed` returns | ||
| 19 | +SIMPLE_TRANSLATION for `has_second_ref(mbmi)`; spec 5.11.27 the same. So only | ||
| 20 | +the GLOBAL arm of `allow_warp` is live on the compound path. | ||
| 21 | + | ||
| 22 | +## Changed | ||
| 23 | +- `crates/ec-av1/src/warp.rs` | ||
| 24 | + - `warp_affine` split into a shared `warp_inner` + a store closure; the old | ||
| 25 | + hardcoded `const BD: i32 = 8` is now `crate::decode::bit_depth()` (the same | ||
| 26 | + thread-local `clip_pixel`/`sample_max` already use, so no call site moved). | ||
| 27 | + `REDUCE_BITS_HORIZ`/`COMPOUND_ROUND1_BITS` named from libaom's | ||
| 28 | + `conv_params->round_0`/`COMPOUND_ROUND1_BITS`. | ||
| 29 | + NOTE for lane-hbdinter: this is the whole of the warp bit-depth change -- | ||
| 30 | + one `bd` local and two offset expressions, no signature change. | ||
| 31 | + - new `warp_affine_compound`: `av1_highbd_warp_affine_c`'s | ||
| 32 | + `conv_params->is_compound && !do_average` branch -- vertical pass rounds by | ||
| 33 | + `round_1 == 7` and the output stays in the compound intermediate domain. | ||
| 34 | + libaom's CONV_BUF carries a constant bias that its blend subtracts | ||
| 35 | + (`(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`); | ||
| 36 | + this crate's intermediates are unbiased, so exactly that constant -- | ||
| 37 | + `(1 << (bd+4)) + (1 << (bd+3))` -- is removed here, making the output | ||
| 38 | + interchangeable with `mc::predict_compound_intermediate`'s for | ||
| 39 | + `combine_compound`/`blend_masked_compound`. Both offset terms survive their | ||
| 40 | + roundings exactly (each exceeds its shift), so bias removal is bit-exact, | ||
| 41 | + not an approximation. | ||
| 42 | +- `crates/ec-av1/src/decode.rs` | ||
| 43 | + - compound branch: `is_global_mv0`/`is_global_mv1` hoisted out of the MiGrid | ||
| 44 | + stamp (and their size bound corrected from `bw4.min(bh4) >= 2`, which used | ||
| 45 | + the frame-CLIPPED write extent, to `side >= 8`, libaom's unclipped `bsize` | ||
| 46 | + -- differs only for a block whose visible extent is 4px); | ||
| 47 | + `compound_warp(ref, eligible)` builds each ref's `global_warp_params` | ||
| 48 | + (skipped on `force_integer_mv` or `gm.invalid`, mirroring | ||
| 49 | + `av1_init_warp_params` + `allow_warp`), and each of the six | ||
| 50 | + `predict_compound_intermediate` outputs is replaced by | ||
| 51 | + `warp_affine_compound` when that ref warps. Chroma is gated on | ||
| 52 | + `chroma_side >= 8` -- `av1_init_warp_params` returns early on | ||
| 53 | + `block_width < 8`, and that is the PLANE's block, so an 8x8 luma block's | ||
| 54 | + 4x4 chroma stays translational. | ||
| 55 | + - new `COMPOUND_WARP_HITS` counter + `compound_warp_hits()`. | ||
| 56 | +- `crates/ec-av1/src/mc.rs` -- `diffwtd_mask`'s round is | ||
| 57 | + `2*FILTER_BITS - round_0 - round_1 + (bd - 8)` (libaom `diffwtd_mask_d16`, | ||
| 58 | + reconinter.c:306); the `(bd - 8)` term was missing (this function's own doc | ||
| 59 | + comment already named it), so every 10-bit DIFFWTD mask was 4x too coarse. | ||
| 60 | + Found while bisecting the 10-bit failure. 8-bit unaffected (`bd-8 == 0`). | ||
| 61 | + UNGATED: the only 10-bit compound gate is the ignored one below. | ||
| 62 | +- `crates/ec-av1/src/stream.rs` -- `run_compound_global_warp_gate` + the two | ||
| 63 | + gates below. No refusal string existed for this defect, so none is lifted; | ||
| 64 | + `refusal_inventory.rs`/`gate_coverage.rs` needed no change (both green). | ||
| 65 | + | ||
| 66 | +## Gate | ||
| 67 | +`a_real_compound_global_warp_stream_decodes_pixel_exact` (8-bit): rotating | ||
| 68 | +mandelbrot (`rotate=a=RATE*n` over a 2x source, scaled to 64x64), 24 frames, | ||
| 69 | +`--enable-global-motion=1 --enable-dist-wtd-comp=1 --lag-in-frames=25 | ||
| 70 | +--auto-alt-ref=1 --enable-warped-motion=1 --enable-masked-comp=1`, 3 cq x 2 | ||
| 71 | +rotation rates. Hard-asserts `compound_warp_hits() > 0` and `matched > 0`; a | ||
| 72 | +decode error or a pixel mismatch is a panic, never a skip. | ||
| 73 | + | ||
| 74 | +EVIDENCE: cargo test -p ec-av1 --release --lib -- a_real_compound_global_warp --nocapture (EC_AV1_REQUIRE_AOMENC=1) | 6 real aomenc encodes, every display frame's Y/U/V vs ffmpeg | `6/6 pixel-exact, 0 named refusals, compound_warp_hits=37` | ||
| 75 | + | ||
| 76 | +EVIDENCE: same command with `--enable-global-motion=0 --enable-warped-motion=0` and, separately, `--auto-alt-ref=0 --lag-in-frames=0 --enable-dist-wtd-comp=0` (10-bit arm) | 2 ablation runs | warp-free 10-bit compound FAILS at frame 1 luma cq 32; 10-bit single-ref inter is 6/6 pixel-exact -> the residual is 10-bit COMPOUND, not warp | ||
| 77 | + | ||
| 78 | +EVIDENCE: cargo test -p ec-av1 --release --lib (EC_AV1_REQUIRE_AOMENC=1) | whole ec-av1 lib suite | **271 passed, 0 failed, 23 ignored**, 312s | ||
| 79 | + | ||
| 80 | +Hidden frames: the gate encodes with `--auto-alt-ref=1 --lag-in-frames=25`, so | ||
| 81 | +hidden alt-refs exist and every shown frame that references them is compared; | ||
| 82 | +a wrong hidden-frame reconstruction propagates into those. There is no | ||
| 83 | +decode-order oracle compare here (the repo's `EC_AV1_DECODE_ORDER_DUMP` rung is | ||
| 84 | +8-bit-only and manual) -- same standard as the other compound gates. | ||
| 85 | + | ||
| 86 | +## Residue | ||
| 87 | +- deferred(the 10-bit compound MC defect): `a_real_compound_global_warp_10bit_stream_decodes_pixel_exact` | ||
| 88 | + is `#[ignore]`d with the ablation in its doc comment. Unblocked by whoever | ||
| 89 | + owns 10-bit compound MC; un-ignore it then -- the warp path under it is | ||
| 90 | + already bit-depth generic. | ||
| 91 | +- flagged (same defect shape, NOT fixed): `decode_inter_block8`'s compound | ||
| 92 | + branch (decode.rs ~10969-11072 on this branch) has the identical | ||
| 93 | + translational-only compound prediction. For an 8x8 leaf the luma block is | ||
| 94 | + exactly 8x8, so libaom WOULD warp luma there (chroma 4x4 would not). Not | ||
| 95 | + wired this round: the 8x8 leaf's own gates are the subject of lane-gmaffine | ||
| 96 | + and a change here would land untested. | ||
| 97 | +- accepted: `mc::diffwtd_mask`'s `(bd - 8)` fix is source-verified against | ||
| 98 | + libaom but has no green 10-bit gate behind it yet (see above). | ||