forge
Explore
Log in

Don't you dare go Hollow

lane-av112bitw: lift the 12-bit warp refusal to the witnessed set

Browse files at this commit

a2555a98c809e4ade3e33e0599b0a7a4d6473274Ahmet Kaan GümüşParent: 70849e0
crates/ec-av1/src/decode.rsmodified+29 -33
@@ -28,15 +28,18 @@ use ec_av1_syntax::{
28 };28 };
29 use ec_core::{Error, Result};29 use ec_core::{Error, Result};
30 30
31-// lane-av112bit: the 12-bit warp refusals below are inline literals31+// lane-av112bit: the 12-bit warp refusal that used to stand at all three
32-// (refusal_inventory.rs extracts them from the decode source); each names the32+// warp decision sites (compound, 16x16+, 8x8 leaf) was an inline literal
33-// witness gap that keeps the path refused -- warp's reduce bits inherit the33+// (refusal_inventory.rs extracts refusal strings from the decode source);
34-// 12-bit `conv_params->round_0` (warped_motion.c:295, convolve.h:81..86).34+// it named the real gap: warp's reduce bits inherited the 12-bit
35-// lane-av112bitc lifted the compound pair of the same family: the compound35+// `conv_params->round_0` (warped_motion.c:295, convolve.h:81..86) and no
36-// combines absorb the CONV_BUF gain drop (`INTER_POST_ROUND - delta`, see36+// witness existed.
37-// `mc::combine_compound`) and the six-frame 12-bit compound witness is37+// lane-av112bitw lifted it from all three sites: `warp::warp_round_0`
38-// byte-exact vs ffmpeg. All sites are PARSE-time: a refused stream never38+// implements the bump (`round_0 += max(bd + FILTER_BITS - round_0 - 14, 0)`,
39-// builds a warp predictor.39+// 5 at 12 bits), and the single-ref witness plus the rotating-mandelbrot
40+// compound-warp witness are both byte-exact vs ffmpeg. Compound inter
41+// itself was lifted by lane-av112bitc before that (the combines absorb the
42+// CONV_BUF gain drop, `INTER_POST_ROUND - delta`, see `mc::combine_compound`).
40 43
41 /// Per-frame decode state, one instance per decoded stream (lane-thread1).44 /// Per-frame decode state, one instance per decoded stream (lane-thread1).
42 ///45 ///
@@ -29093,13 +29096,12 @@ fn decode_inter_block(
29093 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));29096 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
29094 if warp0.is_some() || warp1.is_some() {29097 if warp0.is_some() || warp1.is_some() {
29095 hit!(COMPOUND_WARP_HITS);29098 hit!(COMPOUND_WARP_HITS);
29096- // lane-av112bit: refused by name -- see `WARP_12BIT_REFUSAL`.29099+ // lane-av112bitw: the 12-bit refusal that stood here is
29097- if bit_depth(fctx) == 12 {29100+ // LIFTED with the compound-warp witness: the rotating-
29098- return Err(Error::unsupported(29101+ // mandelbrot 12-bit recipe refused exactly here pre-lift and
29099- "AV1 tile decode",29102+ // now decodes byte-exact vs ffmpeg through the same bumped
29100- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",29103+ // `warp::warp_round_0` shifts
29101- ));29104+ // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`).
29102- }
29103 }29105 }
29104 // spec `get_ref_filter_type`: matches when EITHER of the29106 // spec `get_ref_filter_type`: matches when EITHER of the
29105 // neighbour's two references equals this block's own ref0 --29107 // neighbour's two references equals this block's own ref0 --
@@ -30676,15 +30678,13 @@ fn decode_inter_block(
30676 hit!(AFFINE_GM_HITS);30678 hit!(AFFINE_GM_HITS);
30677 }30679 }
30678 }30680 }
30679- // lane-av112bit: a local `WARPED_CAUSAL` projection (set above) or30681+ // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above)
30680- // a global warp model both land here with `warp_params` set --30682+ // or a global warp model both land here with `warp_params` set --
30681- // refused by name at 12 bits (see `WARP_12BIT_REFUSAL`).30683+ // the 12-bit refusal that used to stand here is LIFTED: warp.rs's
30682- if bit_depth(fctx) == 12 && warp_params.is_some() {30684+ // rounding is parameterised on the bumped `conv_params->round_0`
30683- return Err(Error::unsupported(30685+ // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit
30684- "AV1 tile decode",30686+ // warp stream decodes byte-exact vs ffmpeg
30685- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",30687+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`).
30686- ));
30687- }
30688 if crate::envflags::env_flag!("EC_AV1_TELL") {30688 if crate::envflags::env_flag!("EC_AV1_TELL") {
30689 eprintln!(30689 eprintln!(
30690 "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}",30690 "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}",
@@ -35527,15 +35527,11 @@ fn decode_inter_block8(
35527 hit!(AFFINE_GM_HITS);35527 hit!(AFFINE_GM_HITS);
35528 }35528 }
35529 }35529 }
35530- // lane-av112bit: same 12-bit refusal as the 16x16+ leaf -- a local35530+ // lane-av112bitw: same lift as the 16x16+ leaf -- a local
35531 // `WARPED_CAUSAL` projection or a global model both leave35531 // `WARPED_CAUSAL` projection or a global model both leave
35532- // `warp_params` set here (see `WARP_12BIT_REFUSAL`).35532+ // `warp_params` set here; the 12-bit refusal that stood here is
35533- if bit_depth(fctx) == 12 && warp_params.is_some() {35533+ // lifted with the same witness (`warp::warp_round_0` moved the
35534- return Err(Error::unsupported(35534+ // filter's shifts; the same stream decodes byte-exact vs ffmpeg).
35535- "AV1 tile decode",
35536- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
35537- ));
35538- }
35539 if crate::envflags::env_flag!("EC_TRACE_MODE") {35535 if crate::envflags::env_flag!("EC_TRACE_MODE") {
35540 eprintln!(35536 eprintln!(
35541 "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}",35537 "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}",
crates/ec-av1/src/refusal_inventory.rsmodified+13 -5
@@ -80,7 +80,14 @@ const REFUSALS: &[&str] = &[
80 // lane-av112bitc: compound joined the witnessed set (six-frame 12-bit80 // lane-av112bitc: compound joined the witnessed set (six-frame 12-bit
81 // compound stream byte-exact vs ffmpeg; the combines already absorbed81 // compound stream byte-exact vs ffmpeg; the combines already absorbed
82 // the CONV_BUF gain drop through `INTER_POST_ROUND - delta`).82 // the CONV_BUF gain drop through `INTER_POST_ROUND - delta`).
83- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",83+ // lane-av112bitw: warp joined too -- the refusal left all three decision
84+ // sites (compound, 16x16+, 8x8 leaf): `warp::warp_round_0` implements
85+ // convolve.h's 12-bit `round_0` bump (3 -> 5), and both the single-ref
86+ // witness (`a_12bit_warped_motion_stream_decodes_pixel_exact`, the exact
87+ // recipe that refused pre-lift) and the rotating-mandelbrot
88+ // compound-warp witness
89+ // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`, 28
90+ // compound warp blocks) are byte-exact vs ffmpeg.
84 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",91 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",
85 "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",92 "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",
86 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to93 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
@@ -363,10 +370,11 @@ const PROVEN: &[(&str, &str)] = &[
363 // lane-av112bitc: the compound pair left with its refusal -- the370 // lane-av112bitc: the compound pair left with its refusal -- the
364 // six-frame compound stream now DECODES byte-exact371 // six-frame compound stream now DECODES byte-exact
365 // (`a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact`).372 // (`a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact`).
366- (373+ // lane-av112bitw: the warp pair left too -- its gate now WITNESSES
367- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",374+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`, the same recipe
368- "a_12bit_warped_motion_stream_is_refused_by_name",375+ // that refused pre-lift) and the compound-warp arm witnesses through
369- ),376+ // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
377+ // (hard `compound_warp_hits > 0`).
370 (378 (
371 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",379 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",
372 "a_12bit_film_grain_stream_is_refused_by_name",380 "a_12bit_film_grain_stream_is_refused_by_name",
crates/ec-av1/src/stream.rsmodified+86 -25
@@ -8037,31 +8037,68 @@ pub(crate) mod tests {
8037 }8037 }
8038 }8038 }
8039 8039
8040- /// The 12-bit warp refusal, exercised on a REAL stream: the same source8040+ /// The 12-bit WARP witness (lane-av112bitw): the same source and recipe
8041- /// and recipe with the warp tools ON -- aomenc picks a global warp model8041+ /// with the warp tools ON -- aomenc picks warp models on this content
8042- /// on this content (measured: the decode refuses at the first warped8042+ /// (measured pre-lift: the warp model fires at the third frame, and the
8043- /// block) -- is refused by name.8043+ /// decode refused by name at exactly that block) -- now decodes
8044+ /// BYTE-EXACT against ffmpeg. The warp filter's shifts are the bumped
8045+ /// `conv_params->round_0` (`warp::warp_round_0`, 5 at 12 bits, feeding
8046+ /// `reduce_bits_horiz`, the derived non-compound
8047+ /// `reduce_bits_vert = 2*FILTER_BITS - round_0` and both `offset_bits`),
8048+ /// the whole libaom `get_conv_params_no_round` 12-bit bump.
8049+ ///
8050+ /// Non-vacuous: the same recipe refused by name before the lift, the
8051+ /// gate hard-asserts a warp predictor was really resolved (a warpless
8052+ /// stream would pass the pixel compare and prove nothing), and every
8053+ /// plane of every frame compares against ffmpeg's decode.
8044 #[test]8054 #[test]
8045- fn a_12bit_warped_motion_stream_is_refused_by_name() {8055+ fn a_12bit_warped_motion_stream_decodes_pixel_exact() {
8046- const NAME: &str = "a_12bit_warped_motion_stream_is_refused_by_name";8056+ const NAME: &str = "a_12bit_warped_motion_stream_decodes_pixel_exact";
8047 let _gate_lock = lock_gate_counters();8057 let _gate_lock = lock_gate_counters();
8058+ if !have_ffmpeg() {
8059+ eprintln!("SKIP {NAME}: no ffmpeg");
8060+ return;
8061+ }
8048 if !have_aomenc() {8062 if !have_aomenc() {
8049 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());8063 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8050 return;8064 return;
8051 }8065 }
8052 let y4m = y4m_12bit_subpel_source(6);8066 let y4m = y4m_12bit_subpel_source(6);
8053- // Exactly the recipe measured to refuse at warp: warp ON, global8067+ // Exactly the recipe measured to refuse at warp pre-lift: warp ON,
8054- // motion NOT spelled (spelling it ON makes a GLOBAL_GLOBALMV8068+ // global motion NOT spelled (spelling it ON drives a GLOBAL_GLOBALMV
8055- // compound block reach the compound refusal first), six frames --8069+ // compound block into the compound-warp arm -- see the compound gate
8056- // the warp model fires at the third frame.8070+ // below), six frames -- the warp model fires at the third frame.
8057 let stream = encode_12bit(&y4m, 6, &["--enable-warped-motion=1"]);8071 let stream = encode_12bit(&y4m, 6, &["--enable-warped-motion=1"]);
8058- let err = decode_stream(&stream).unwrap_err().to_string();8072+ assert_12bit_sequence_header(&stream, NAME);
8073+ let (before_selected, before_warp8, before_affine) = (
8074+ decode::warp_selected_hits(),
8075+ decode::warp_hits_8(),
8076+ decode::affine_gm_hits(),
8077+ );
8078+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
8079+ panic!("{NAME}: decode_stream refused a real 12-bit warp stream: {e}")
8080+ });
8081+ assert_eq!(frames.len(), 6);
8082+ let (delta_selected, delta_warp8, delta_affine) = (
8083+ decode::warp_selected_hits() - before_selected,
8084+ decode::warp_hits_8() - before_warp8,
8085+ decode::affine_gm_hits() - before_affine,
8086+ );
8087+ eprintln!(
8088+ "{NAME}: warp_engagement selected(16x16+ symbol)={delta_selected} \
8089+ warped8(usable 8x8 model)={delta_warp8} affine_gm(6-param model)={delta_affine}"
8090+ );
8059 assert!(8091 assert!(
8060- err.contains(8092+ delta_selected + delta_warp8 + delta_affine > 0,
8061- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)"8093+ "{NAME}: no warp predictor was resolved -- the stream carries no \
8062- ),8094+ warp model and the pixel compare would prove nothing"
8063- "{NAME}: expected the 12-bit warp refusal, got: {err}"
8064 );8095 );
8096+ let ffmpeg_frames = ffmpeg_decode_sequence_12bit(&stream, 160, 128, 6);
8097+ for (i, (ours, reference)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8098+ assert_eq!(ours.y, reference.y, "frame {i} luma vs ffmpeg (12-bit warp)");
8099+ assert_eq!(ours.u, reference.u, "frame {i} U vs ffmpeg (12-bit warp)");
8100+ assert_eq!(ours.v, reference.v, "frame {i} V vs ffmpeg (12-bit warp)");
8101+ }
8065 }8102 }
8066 8103
8067 /// The 12-bit COMPOUND witness (lane-av112bitc): the parent's source8104 /// The 12-bit COMPOUND witness (lane-av112bitc): the parent's source
@@ -21181,7 +21218,7 @@ pub(crate) mod tests {
21181 /// `mc::predict_compound_intermediate`. `compound_warp_hits() > 0` is a21218 /// `mc::predict_compound_intermediate`. `compound_warp_hits() > 0` is a
21182 /// hard assert: a run where the encoder never emitted one proves nothing.21219 /// hard assert: a run where the encoder never emitted one proves nothing.
21183 /// A decode error or a pixel mismatch is a FAILURE, never a skip.21220 /// A decode error or a pixel mismatch is a FAILURE, never a skip.
21184- fn run_compound_global_warp_gate(name: &str, ten_bit: bool) {21221+ fn run_compound_global_warp_gate(name: &str, bd: u32) {
21185 let _gate_lock = lock_gate_counters();21222 let _gate_lock = lock_gate_counters();
21186 assert!(have_ffmpeg(), "{name}: ffmpeg required");21223 assert!(have_ffmpeg(), "{name}: ffmpeg required");
21187 assert!(have_aomenc(), "{name}: no aomenc at {}", aomenc_path().display());21224 assert!(have_aomenc(), "{name}: no aomenc at {}", aomenc_path().display());
@@ -21204,7 +21241,11 @@ pub(crate) mod tests {
21204 h = height * 2,21241 h = height * 2,
21205 sx = -0.6 + 0.01 * (i as f64),21242 sx = -0.6 + 0.01 * (i as f64),
21206 );21243 );
21207- let pix_fmt = if ten_bit { "yuv420p10le" } else { "yuv420p" };21244+ let pix_fmt = match bd {
21245+ 8 => "yuv420p",
21246+ 10 => "yuv420p10le",
21247+ _ => "yuv420p12le",
21248+ };
21208 let y4m = Command::new("ffmpeg")21249 let y4m = Command::new("ffmpeg")
21209 .args([21250 .args([
21210 "-v", "error", "-f", "lavfi", "-i", &source, "-t",21251 "-v", "error", "-f", "lavfi", "-i", &source, "-t",
@@ -21222,6 +21263,8 @@ pub(crate) mod tests {
21222 String::from_utf8_lossy(&y4m.stderr)21263 String::from_utf8_lossy(&y4m.stderr)
21223 );21264 );
21224 let cq_arg = format!("--cq-level={cq}");21265 let cq_arg = format!("--cq-level={cq}");
21266+ let (in_depth_arg, depth_arg) =
21267+ (format!("--input-bit-depth={bd}"), format!("--bit-depth={bd}"));
21225 let mut args: Vec<&str> = vec![21268 let mut args: Vec<&str> = vec![
21226 "--codec=av1",21269 "--codec=av1",
21227 "--passes=1",21270 "--passes=1",
@@ -21266,8 +21309,11 @@ pub(crate) mod tests {
21266 "--enable-cfl-intra=0",21309 "--enable-cfl-intra=0",
21267 "--enable-ref-frame-mvs=0",21310 "--enable-ref-frame-mvs=0",
21268 ];21311 ];
21269- if ten_bit {21312+ if bd != 8 {
21270- args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);21313+ args.extend_from_slice(&[
21314+ in_depth_arg.as_str(),
21315+ depth_arg.as_str(),
21316+ ]);
21271 }21317 }
21272 args.extend_from_slice(&["--obu", "-o", "-", "-"]);21318 args.extend_from_slice(&["--obu", "-o", "-", "-"]);
21273 let out = run_with_stdin(Command::new(aomenc_path())21319 let out = run_with_stdin(Command::new(aomenc_path())
@@ -21295,10 +21341,10 @@ pub(crate) mod tests {
21295 }21341 }
21296 Ok(frames) => frames,21342 Ok(frames) => frames,
21297 };21343 };
21298- let want = if ten_bit {21344+ let want = match bd {
21299- ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)21345+ 8 => ffmpeg_decode_sequence(&stream, width, height, frame_count),
21300- } else {21346+ 10 => ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count),
21301- ffmpeg_decode_sequence(&stream, width, height, frame_count)21347+ _ => ffmpeg_decode_sequence_12bit(&stream, width, height, frame_count),
21302 };21348 };
21303 assert_eq!(frames.len(), frame_count);21349 assert_eq!(frames.len(), frame_count);
21304 if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP")21350 if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP")
@@ -21550,7 +21596,7 @@ pub(crate) mod tests {
21550 /// 8-bit arm of [`run_compound_global_warp_gate`].21596 /// 8-bit arm of [`run_compound_global_warp_gate`].
21551 #[test]21597 #[test]
21552 fn a_real_compound_global_warp_stream_decodes_pixel_exact() {21598 fn a_real_compound_global_warp_stream_decodes_pixel_exact() {
21553- run_compound_global_warp_gate("a_real_compound_global_warp_stream_decodes_pixel_exact", false);21599+ run_compound_global_warp_gate("a_real_compound_global_warp_stream_decodes_pixel_exact", 8);
21554 }21600 }
21555 21601
21556 /// 10-bit arm of [`run_compound_global_warp_gate`] -- both of his films are21602 /// 10-bit arm of [`run_compound_global_warp_gate`] -- both of his films are
@@ -21569,7 +21615,22 @@ pub(crate) mod tests {
21569 fn a_real_compound_global_warp_10bit_stream_decodes_pixel_exact() {21615 fn a_real_compound_global_warp_10bit_stream_decodes_pixel_exact() {
21570 run_compound_global_warp_gate(21616 run_compound_global_warp_gate(
21571 "a_real_compound_global_warp_10bit_stream_decodes_pixel_exact",21617 "a_real_compound_global_warp_10bit_stream_decodes_pixel_exact",
21572- true,21618+ 10,
21619+ );
21620+ }
21621+
21622+ /// 12-bit arm of [`run_compound_global_warp_gate`] (lane-av112bitw): the
21623+ /// same rotating-mandelbrot recipe at `--bit-depth=12`. Pre-lift the
21624+ /// first `GLOBAL_GLOBALMV` block under a ROTZOOM model refused ("warped
21625+ /// motion at 12 bits"); the lift runs the same `warp::warp_round_0` bump
21626+ /// through `warp_affine_compound` (`reduce_bits_horiz` 5, compound
21627+ /// `reduce_bits_vert` stays 7, the CONV_BUF blend bias one octave down:
21628+ /// `(1 << (bd + 2)) + (1 << (bd + 1))`).
21629+ #[test]
21630+ fn a_real_compound_global_warp_12bit_stream_decodes_pixel_exact() {
21631+ run_compound_global_warp_gate(
21632+ "a_real_compound_global_warp_12bit_stream_decodes_pixel_exact",
21633+ 12,
21573 );21634 );
21574 }21635 }
21575 21636
crates/ec-av1/src/warp.rsmodified+87 -25
@@ -328,12 +328,20 @@ fn get_shear_params(wmmat: [i32; 6]) -> Option<(i16, i16, i16, i16)> {
328 return None;328 return None;
329 }329 }
330 let mat = wmmat.map(|v| v as i64);330 let mat = wmmat.map(|v| v as i64);
331- let mut alpha = clamp(mat[2] - (1 << WARPEDMODEL_PREC_BITS), i16::MIN as i64, i16::MAX as i64);331+ let mut alpha = clamp(
332+ mat[2] - (1 << WARPEDMODEL_PREC_BITS),
333+ i16::MIN as i64,
334+ i16::MAX as i64,
335+ );
332 let beta = clamp(mat[3], i16::MIN as i64, i16::MAX as i64);336 let beta = clamp(mat[3], i16::MIN as i64, i16::MAX as i64);
333 let (y_mag, shift) = resolve_divisor_32(mat[2].unsigned_abs() as u32);337 let (y_mag, shift) = resolve_divisor_32(mat[2].unsigned_abs() as u32);
334 let y = if mat[2] < 0 { -y_mag } else { y_mag };338 let y = if mat[2] < 0 { -y_mag } else { y_mag };
335 let v = (mat[4] * (1 << WARPEDMODEL_PREC_BITS)) * y;339 let v = (mat[4] * (1 << WARPEDMODEL_PREC_BITS)) * y;
336- let mut gamma = clamp(round2_signed(v, shift as u32), i16::MIN as i64, i16::MAX as i64);340+ let mut gamma = clamp(
341+ round2_signed(v, shift as u32),
342+ i16::MIN as i64,
343+ i16::MAX as i64,
344+ );
337 let v = (mat[3] * mat[4]) * y;345 let v = (mat[3] * mat[4]) * y;
338 let mut delta = clamp(346 let mut delta = clamp(
339 mat[5] - round2_signed(v, shift as u32) - (1 << WARPEDMODEL_PREC_BITS),347 mat[5] - round2_signed(v, shift as u32) - (1 << WARPEDMODEL_PREC_BITS),
@@ -414,7 +422,13 @@ pub fn find_projection(
414 /// translational fallback in that rare case.422 /// translational fallback in that rare case.
415 pub fn global_warp_params(wmmat: [i32; 6]) -> Option<WarpParams> {423 pub fn global_warp_params(wmmat: [i32; 6]) -> Option<WarpParams> {
416 let (alpha, beta, gamma, delta) = get_shear_params(wmmat)?;424 let (alpha, beta, gamma, delta) = get_shear_params(wmmat)?;
417- Some(WarpParams { wmmat, alpha, beta, gamma, delta })425+ Some(WarpParams {
426+ wmmat,
427+ alpha,
428+ beta,
429+ gamma,
430+ delta,
431+ })
418 }432 }
419 433
420 fn clip_pixel(v: i32, fctx: &crate::decode::FrameCtx) -> u16 {434 fn clip_pixel(v: i32, fctx: &crate::decode::FrameCtx) -> u16 {
@@ -442,17 +456,30 @@ pub(crate) fn warp_affine(
442 p_height: i32,456 p_height: i32,
443 p_stride: i32,457 p_stride: i32,
444 subsampling_x: i32,458 subsampling_x: i32,
445- subsampling_y: i32, fctx: &crate::decode::FrameCtx,459+ subsampling_y: i32,
460+ fctx: &crate::decode::FrameCtx,
446 ) {461 ) {
447 if crate::envflags::env_flag!("EC_MC_TRACE") {462 if crate::envflags::env_flag!("EC_MC_TRACE") {
448 eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");463 eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");
449 }464 }
450 let bd = i32::from(crate::decode::bit_depth(fctx));465 let bd = i32::from(crate::decode::bit_depth(fctx));
451- // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0`.466+ // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0` (the
452- let reduce_bits_vert = 2 * FILTER_BITS - REDUCE_BITS_HORIZ;467+ // bumped `conv_params->round_0`, [`warp_round_0`]).
468+ let reduce_bits_vert = 2 * FILTER_BITS - warp_round_0(bd);
453 warp_inner(469 warp_inner(
454- params, reference, width, height, stride, p_col, p_row, p_width, p_height,470+ params,
455- subsampling_x, subsampling_y, bd, reduce_bits_vert,471+ reference,
472+ width,
473+ height,
474+ stride,
475+ p_col,
476+ p_row,
477+ p_width,
478+ p_height,
479+ subsampling_x,
480+ subsampling_y,
481+ bd,
482+ reduce_bits_vert,
456 |row, col, sum| {483 |row, col, sum| {
457 dst[row * p_stride as usize + col] =484 dst[row * p_stride as usize + col] =
458 clip_pixel(sum - (1 << (bd - 1)) - (1 << bd), fctx);485 clip_pixel(sum - (1 << (bd - 1)) - (1 << bd), fctx);
@@ -471,8 +498,8 @@ pub(crate) fn warp_affine(
471 /// both roundings exactly because both exceed their shift) and subtracts498 /// both roundings exactly because both exceed their shift) and subtracts
472 /// `(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`499 /// `(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`
473 /// at the blend; this crate's intermediates are UNBIASED (see500 /// at the blend; this crate's intermediates are UNBIASED (see
474-/// [`mc::diffwtd_mask`]'s derivation), so the identical constant --501+/// [`mc::diffwtd_mask`]'s derivation), so the identical constant, derived
475-/// `(1 << (bd + 4)) + (1 << (bd + 3))` -- is removed here instead, making502+/// from the bumped `round_0` below, is removed here instead, making
476 /// the output directly interchangeable with503 /// the output directly interchangeable with
477 /// [`mc::predict_compound_intermediate`]'s for504 /// [`mc::predict_compound_intermediate`]'s for
478 /// [`mc::combine_compound`]/[`mc::blend_masked_compound`].505 /// [`mc::combine_compound`]/[`mc::blend_masked_compound`].
@@ -490,27 +517,61 @@ pub(crate) fn warp_affine_compound(
490 p_height: i32,517 p_height: i32,
491 p_stride: i32,518 p_stride: i32,
492 subsampling_x: i32,519 subsampling_x: i32,
493- subsampling_y: i32, fctx: &crate::decode::FrameCtx,520+ subsampling_y: i32,
521+ fctx: &crate::decode::FrameCtx,
494 ) {522 ) {
495 let bd = i32::from(crate::decode::bit_depth(fctx));523 let bd = i32::from(crate::decode::bit_depth(fctx));
496- let bias = (1 << (bd + 4)) + (1 << (bd + 3));524+ // The CONV_BUF bias libaom subtracts at the blend:
525+ // `(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`
526+ // with `offset_bits = bd + 2 * FILTER_BITS - round_0` (round_0 the bumped
527+ // [`warp_round_0`], round_1 [`COMPOUND_ROUND1_BITS`], unbumped for
528+ // compound): `(1 << (bd + 4)) + (1 << (bd + 3))` at 8/10-bit, one octave
529+ // less at 12-bit.
530+ let offset_bits = bd + 2 * FILTER_BITS - warp_round_0(bd);
531+ let bias = (1 << (offset_bits - COMPOUND_ROUND1_BITS))
532+ + (1 << (offset_bits - COMPOUND_ROUND1_BITS - 1));
497 warp_inner(533 warp_inner(
498- params, reference, width, height, stride, p_col, p_row, p_width, p_height,534+ params,
499- subsampling_x, subsampling_y, bd, COMPOUND_ROUND1_BITS,535+ reference,
536+ width,
537+ height,
538+ stride,
539+ p_col,
540+ p_row,
541+ p_width,
542+ p_height,
543+ subsampling_x,
544+ subsampling_y,
545+ bd,
546+ COMPOUND_ROUND1_BITS,
500 |row, col, sum| {547 |row, col, sum| {
501 dst[row * p_stride as usize + col] = sum - bias;548 dst[row * p_stride as usize + col] = sum - bias;
502 },549 },
503 );550 );
504 }551 }
505 552
506-/// `conv_params->round_0` (`ROUND0_BITS`), the warp filter's horizontal553+/// `ROUND0_BITS` (`convolve.h`): `conv_params->round_0` before
507-/// rounding -- `InterRound0`, bit-depth independent for 8/10-bit content554+/// `get_conv_params_no_round`'s high-bitdepth buffer-range bump.
508-/// (libaom only raises it at `bd == 12`, which this decoder refuses).555+const ROUND0_BITS: i32 = 3;
509-const REDUCE_BITS_HORIZ: i32 = 3;
510 /// `COMPOUND_ROUND1_BITS` (`convolve.h`): `conv_params->round_1` when556 /// `COMPOUND_ROUND1_BITS` (`convolve.h`): `conv_params->round_1` when
511-/// `is_compound`.557+/// `is_compound` (NOT bumped at 12 bits -- the bump moves `round_0` and, for
558+/// non-compound, `round_1` by the same delta, keeping the filter gain
559+/// constant).
512 const COMPOUND_ROUND1_BITS: i32 = 7;560 const COMPOUND_ROUND1_BITS: i32 = 7;
513 561
562+/// `conv_params->round_0` after `get_conv_params_no_round`'s bump
563+/// (`convolve.h`): `round_0 += max(bd + FILTER_BITS - round_0 - 14, 0)` --
564+/// 3 at 8/10-bit, 5 at 12-bit (`intbufrange = bd + FILTER_BITS - round_0 +
565+/// 2` overflows 16 bits from bd 12 on). The warp filter's
566+/// `reduce_bits_horiz` IS `conv_params->round_0` (`warped_motion.c:295`),
567+/// and the non-compound `reduce_bits_vert` plus both `offset_bits_*` terms
568+/// read back through it, so this one parameter moves every shift the warp
569+/// filter runs (lane-av112bitw: the 12-bit warp witness decodes byte-exact
570+/// through it).
571+fn warp_round_0(bd: i32) -> i32 {
572+ ROUND0_BITS + (bd + FILTER_BITS - ROUND0_BITS - 14).max(0)
573+}
574+
514 /// The shared body of [`warp_affine`]/[`warp_affine_compound`]575 /// The shared body of [`warp_affine`]/[`warp_affine_compound`]
515 /// (`av1_highbd_warp_affine_c`): everything up to and including the576 /// (`av1_highbd_warp_affine_c`): everything up to and including the
516 /// vertical `ROUND_POWER_OF_TWO(sum, reduce_bits_vert)`, with `store`577 /// vertical `ROUND_POWER_OF_TWO(sum, reduce_bits_vert)`, with `store`
@@ -539,7 +600,7 @@ fn warp_inner(
539 params.gamma as i64,600 params.gamma as i64,
540 params.delta as i64,601 params.delta as i64,
541 );602 );
542- let reduce_bits_horiz = REDUCE_BITS_HORIZ;603+ let reduce_bits_horiz = warp_round_0(bd);
543 let offset_bits_horiz = bd + FILTER_BITS - 1;604 let offset_bits_horiz = bd + FILTER_BITS - 1;
544 let offset_bits_vert = bd + 2 * FILTER_BITS - reduce_bits_horiz;605 let offset_bits_vert = bd + 2 * FILTER_BITS - reduce_bits_horiz;
545 606
@@ -570,8 +631,8 @@ fn warp_inner(
570 let mut sx = sx4 + beta * (k as i64 + 4);631 let mut sx = sx4 + beta * (k as i64 + 4);
571 for l in -4..4i32 {632 for l in -4..4i32 {
572 let ix = ix4 + l - 3;633 let ix = ix4 + l - 3;
573- let offs =634+ let offs = (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS)
574- (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize;635+ as usize;
575 let coeffs = &AV1_WARPED_FILTER[offs];636 let coeffs = &AV1_WARPED_FILTER[offs];
576 let mut sum: i32 = 1 << offset_bits_horiz;637 let mut sum: i32 = 1 << offset_bits_horiz;
577 for (m, &c) in coeffs.iter().enumerate() {638 for (m, &c) in coeffs.iter().enumerate() {
@@ -591,12 +652,13 @@ fn warp_inner(
591 let l_hi = (4i32).min(p_col + p_width - j - 4);652 let l_hi = (4i32).min(p_col + p_width - j - 4);
592 let mut l = -4i32;653 let mut l = -4i32;
593 while l < l_hi {654 while l < l_hi {
594- let offs =655+ let offs = (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS)
595- (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize;656+ as usize;
596 let coeffs = &AV1_WARPED_FILTER[offs];657 let coeffs = &AV1_WARPED_FILTER[offs];
597 let mut sum: i32 = 1 << offset_bits_vert;658 let mut sum: i32 = 1 << offset_bits_vert;
598 for m in 0..8i32 {659 for m in 0..8i32 {
599- sum += tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32;660+ sum +=
661+ tmp[(k + m + 4) as usize][(l + 4) as usize] * coeffs[m as usize] as i32;
600 }662 }
601 sum = round2(sum as i64, reduce_bits_vert as u32) as i32;663 sum = round2(sum as i64, reduce_bits_vert as u32) as i32;
602 store(664 store(
lanes/av112bitw.report.mdadded+123 -0
@@ -0,0 +1,123 @@
1+# lane-av112bitw — the 12-bit warp lift
2+
3+Base 786c15b6 (lane-av112bitc's merged tree), worktree `edith_codecs-av112bw`,
4+branch `lane-av1-12bit-warp`. The charter: lift the named 12-bit warp refusal
5+("warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and
6+no 12-bit warp witness exists)") exactly as far as real `aomenc --bit-depth=12`
7+warp witnesses prove byte-exactness against ffmpeg, and keep grain and screen
8+content refused by name.
9+
10+## Reaching the path (encode budget: 3 probes + 6 gate encodes pre-lift + 6 post-lift)
11+
12+1. **Recipe 1 (the parent's refusal recipe, re-proven on this base)**: the
13+ 12-bit sub-pel source (160x128 C420p12, gradient + texture, travelling
14+ box), six frames, `--enable-warped-motion=1` (global motion NOT spelled).
15+ The unmodified tree's gate `a_12bit_warped_motion_stream_is_refused_by_name`
16+ encoded it live and refused by name — warp emits, refusal fires. Post-lift
17+ the same recipe is the single-ref witness.
18+2. **Recipe 2 (negative result, reported per charter)**: same source, warp ON
19+ **and** `--enable-global-motion=1`. It decodes byte-exact post-lift but
20+ `compound_warp_hits` delta is **0**: pan/box content only fits TRANSLATION
21+ global models, and the compound-warp site needs model > TRANSLATION per
22+ slot (`is_global_mv_block`, blockd.h:421-429, pinned by lane-cwarp r1).
23+ NOT a compound-warp witness; the throwaway probe gate was deleted again.
24+3. **Recipe 3 (the lever)**: the lane-cwarp gate's rotating-mandelbrot recipe
25+ (`mandelbrot` + `rotate=a=rate*n`, 128x128 -> 64x64, 24 frames, 3 cq x 2
26+ rate) already hard-asserts `compound_warp_hits > 0` at 8/10 bits. Its
27+ 12-bit arm refused pre-lift at the compound-warp site on the FIRST attempt
28+ (`refused on warp (cq 32)` — reachability + non-vacuity in one run), and
29+ post-lift it is the compound-warp witness.
30+
31+## What changed
32+
33+- **warp.rs** — the hard `REDUCE_BITS_HORIZ: i32 = 3` became
34+ `warp_round_0(bd)` = `ROUND0_BITS + max(bd + FILTER_BITS - ROUND0_BITS -
35+ 14, 0)`, the exact `get_conv_params_no_round` bump (convolve.h:
36+ `intbufrange = bd + FILTER_BITS - round_0 + 2`; overflows 16 bits from
37+ bd 12 on, so `round_0` 3 -> 5). 3 at 8/10-bit (identical to before), 5 at
38+ 12-bit. Everything else derives from it exactly as warped_motion.c:295-301
39+ reads: `reduce_bits_horiz` IS `conv_params->round_0`; the non-compound
40+ `reduce_bits_vert = 2*FILTER_BITS - round_0` (11 -> 9 at 12 bits, filter
41+ gain constant); `offset_bits_horiz`/`offset_bits_vert` keep their formulas.
42+ `warp_affine_compound`'s CONV_BUF blend bias is now derived
43+ (`(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`) —
44+ `(1 << (bd+4)) + (1 << (bd+3))` at 8/10 bits (identical to before), one
45+ octave down at 12 bits; compound `reduce_bits_vert` stays
46+ `COMPOUND_ROUND1_BITS = 7` (the bump never moves compound round_1).
47+- **decode.rs** — all three 12-bit warp refusal sites deleted: the
48+ compound-warp arm (`COMPOUND_WARP_HITS`, 16x16+ path), the 16x16+
49+ single-ref site and the 8x8-leaf site (both guarded
50+ `bit_depth == 12 && warp_params.is_some()`, covering the local
51+ WARPED_CAUSAL arm AND the single-ref global-warp arm — the filter is the
52+ same `warp_affine`, and the model source is bit-depth independent and
53+ 10-bit-pinned). Header comment over the 12-bit family updated: the family
54+ is now grain + screen content only.
55+- **Found during the lift (recorded, closed by it)**: the 8x8-leaf
56+ compound-warp arm (`decode_inter_block8`'s `COMPOUND_WARP_HITS_8` site)
57+ had NO 12-bit refusal at all — a 12-bit stream whose first warp block was
58+ an 8x8 compound leaf would have decoded silently through the wrong
59+ shifts. The refusal map was incomplete, not just unlifted; post-lift the
60+ site runs the witnessed parameterised path like every other warp site.
61+- **refusal_inventory.rs** — the warp string left `REFUSALS` (38 -> 37) and
62+ its pair left `PROVEN`; both slots carry lane-av112bitw notes pointing at
63+ the witnesses. `the_decode_path_refuses_exactly_the_listed_cases` and
64+ `every_proven_refusal_names_a_test_that_exists` both green.
65+- **stream.rs** — the refusal gate was REPLACED by the single-ref witness
66+ (below), and `run_compound_global_warp_gate` was generalised
67+ `ten_bit: bool` -> `bd: u32` with a third caller. The 8/10-bit arms are
68+ byte-identical recipes (8-bit still passes NO depth flags).
69+
70+## The witnesses
71+
72+Encoder: the local aom oracle build (`~/.cache/aom-oracle/build/aomenc`,
73+libaom src `92d4c37fbdd08944a0e721bbaeb13318f10aebb0`); reference decode
74+ffmpeg 8.1.2 (`yuv420p12le` rawvideo). Gates encode live; the committed
75+fixtures are untouched (no new fixture needed).
76+
77+1. **Single-ref** `a_12bit_warped_motion_stream_decodes_pixel_exact` — the
78+ exact recipe that refused pre-lift, 6 frames, byte-exact vs ffmpeg on
79+ every plane of every frame. Engagement: `warp_selected_hits` 7 (16x16+
80+ WARPED_CAUSAL), `warp_hits_8` 1 (usable 8x8 local model),
81+ `affine_gm_hits` 0 (content fits no >TRANSLATION global model — the
82+ single-ref global-warp arm rides on the same filter + the composition
83+ argument, not its own stream). Hard counter assert so a warpless stream
84+ cannot pass vacuously.
85+2. **Compound** `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
86+ — the cwarp rotating-mandelbrot recipe at `--bit-depth=12`: **6/6
87+ attempts pixel-exact, 0 named refusals, compound_warp_hits = 28**, with
88+ the gate's own hard asserts (`hits > 0`, `matched > 0`, no refusal may
89+ contain "warp"). Pre-lift the same gate FAILED with the warp refusal on
90+ attempt 1 — non-vacuity both directions.
91+
92+## Results
93+
94+- 12-bit battery: key, inter, compound (parent fixtures) all still
95+ byte-exact; `a_12bit_screen_content_stream_is_refused_by_name` and
96+ `a_12bit_film_grain_stream_is_refused_by_name` still refuse by name.
97+- Warp family: 8-bit and 10-bit cwarp gates green (the parameterisation is
98+ a no-op at bd <= 10, proven not just claimed), both fimv
99+ force-integer-mv warp-alphabet gates green, both 10-bit film fixture
100+ gates with warp green (`a_10bit_128sb_film_frames_with_warp_cdef_and_interintra...`,
101+ `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach...`).
102+- `refusal_inventory` + `gate_coverage` suites green.
103+- `cargo check -p ec-av1 --all-targets`: 0 warnings.
104+
105+## Open halves (recorded, not silently dropped)
106+
107+1. **Single-ref GLOBAL-warp at 12 bits has no stream of its own** (engagement
108+ 0 on this content): lifted on the composition argument — identical
109+ `warp_affine` filter, bit-depth-independent model source, both pieces
110+ witnessed. A stream whose single-ref blocks warp under a ROTZOOM global
111+ model would close it outright; the mandelbrot content produces those
112+ models only on compound blocks here.
113+2. **Grain and screen content stay refused by name** (untouched, per
114+ charter): `film grain synthesis at 12 bits ...` and
115+ `a 12-bit frame with screen content tools ...` with their real-stream
116+ refusal gates.
117+
118+## Create-list audit
119+
120+Exactly one new file: this report. Touched: `warp.rs` (the parameterisation),
121+`decode.rs` (three refusal deletions + header comment), `stream.rs` (witness
122+gate swap + gate generalisation), `refusal_inventory.rs` (two row removals +
123+notes). No fixture, no junk file.