forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1-12bit-warp: 12-bit warp pixel-exact

Browse files at this commit

bddda13da07cc7e9e9d9034696bff8f07ccc4861Ahmet Kaan GümüşParent: 8d284805c27968
Reviewer PASS, including the 8x8 compound-warp leaf (hits_8=81).
Local suite 607/6/60; the 6 panics were a missing TMPDIR. Re-ran 6/6 pass.
Inventory conflict with the grain merge: both refusals stay lifted, both comments kept.
crates/ec-av1/src/decode.rsmodified+29 -33
@@ -28,15 +28,18 @@ use ec_av1_syntax::{
2828 };
2929 use ec_core::{Error, Result};
3030
31-// lane-av112bit: the 12-bit warp refusals below are inline literals
32-// (refusal_inventory.rs extracts them from the decode source); each names the
33-// witness gap that keeps the path refused -- warp's reduce bits inherit the
34-// 12-bit `conv_params->round_0` (warped_motion.c:295, convolve.h:81..86).
35-// lane-av112bitc lifted the compound pair of the same family: the compound
36-// combines absorb the CONV_BUF gain drop (`INTER_POST_ROUND - delta`, see
37-// `mc::combine_compound`) and the six-frame 12-bit compound witness is
38-// byte-exact vs ffmpeg. All sites are PARSE-time: a refused stream never
39-// builds a warp predictor.
31+// lane-av112bit: the 12-bit warp refusal that used to stand at all three
32+// warp decision sites (compound, 16x16+, 8x8 leaf) was an inline literal
33+// (refusal_inventory.rs extracts refusal strings from the decode source);
34+// it named the real gap: warp's reduce bits inherited the 12-bit
35+// `conv_params->round_0` (warped_motion.c:295, convolve.h:81..86) and no
36+// witness existed.
37+// lane-av112bitw lifted it from all three sites: `warp::warp_round_0`
38+// implements the bump (`round_0 += max(bd + FILTER_BITS - round_0 - 14, 0)`,
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`).
4043
4144 /// Per-frame decode state, one instance per decoded stream (lane-thread1).
4245 ///
@@ -30374,13 +30377,12 @@ fn decode_inter_block(
3037430377 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
3037530378 if warp0.is_some() || warp1.is_some() {
3037630379 hit!(COMPOUND_WARP_HITS);
30377- // lane-av112bit: refused by name -- see `WARP_12BIT_REFUSAL`.
30378- if bit_depth(fctx) == 12 {
30379- return Err(Error::unsupported(
30380- "AV1 tile decode",
30381- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
30382- ));
30383- }
30380+ // lane-av112bitw: the 12-bit refusal that stood here is
30381+ // LIFTED with the compound-warp witness: the rotating-
30382+ // mandelbrot 12-bit recipe refused exactly here pre-lift and
30383+ // now decodes byte-exact vs ffmpeg through the same bumped
30384+ // `warp::warp_round_0` shifts
30385+ // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`).
3038430386 }
3038530387 // spec `get_ref_filter_type`: matches when EITHER of the
3038630388 // neighbour's two references equals this block's own ref0 --
@@ -32107,15 +32109,13 @@ fn decode_inter_block(
3210732109 hit!(AFFINE_GM_HITS);
3210832110 }
3210932111 }
32110- // lane-av112bit: a local `WARPED_CAUSAL` projection (set above) or
32111- // a global warp model both land here with `warp_params` set --
32112- // refused by name at 12 bits (see `WARP_12BIT_REFUSAL`).
32113- if bit_depth(fctx) == 12 && warp_params.is_some() {
32114- return Err(Error::unsupported(
32115- "AV1 tile decode",
32116- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
32117- ));
32118- }
32112+ // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above)
32113+ // or a global warp model both land here with `warp_params` set --
32114+ // the 12-bit refusal that used to stand here is LIFTED: warp.rs's
32115+ // rounding is parameterised on the bumped `conv_params->round_0`
32116+ // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit
32117+ // warp stream decodes byte-exact vs ffmpeg
32118+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`).
3211932119 if crate::envflags::env_flag!("EC_AV1_TELL") {
3212032120 eprintln!(
3212132121 "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}",
@@ -37478,15 +37478,11 @@ fn decode_inter_block8(
3747837478 hit!(AFFINE_GM_HITS);
3747937479 }
3748037480 }
37481- // lane-av112bit: same 12-bit refusal as the 16x16+ leaf -- a local
37481+ // lane-av112bitw: same lift as the 16x16+ leaf -- a local
3748237482 // `WARPED_CAUSAL` projection or a global model both leave
37483- // `warp_params` set here (see `WARP_12BIT_REFUSAL`).
37484- if bit_depth(fctx) == 12 && warp_params.is_some() {
37485- return Err(Error::unsupported(
37486- "AV1 tile decode",
37487- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
37488- ));
37489- }
37483+ // `warp_params` set here; the 12-bit refusal that stood here is
37484+ // lifted with the same witness (`warp::warp_round_0` moved the
37485+ // filter's shifts; the same stream decodes byte-exact vs ffmpeg).
3749037486 if crate::envflags::env_flag!("EC_TRACE_MODE") {
3749137487 eprintln!(
3749237488 "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}",
crates/ec-av1/src/refusal_inventory.rsmodified+13 -5
@@ -98,7 +98,14 @@ const REFUSALS: &[&str] = &[
9898 // `--film-grain-test=5` stream byte-exact vs ffmpeg; the gate that
9999 // replaced the refusal is
100100 // `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`).
101- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
101+ // lane-av112bitw: warp joined too -- the refusal left all three decision
102+ // sites (compound, 16x16+, 8x8 leaf): `warp::warp_round_0` implements
103+ // convolve.h's 12-bit `round_0` bump (3 -> 5), and both the single-ref
104+ // witness (`a_12bit_warped_motion_stream_decodes_pixel_exact`, the exact
105+ // recipe that refused pre-lift) and the rotating-mandelbrot
106+ // compound-warp witness
107+ // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`, 28
108+ // compound warp blocks) are byte-exact vs ffmpeg.
102109 "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",
103110 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
104111 // decode with no refusal and wrong pixels (every chroma extent is
@@ -383,10 +390,11 @@ const PROVEN: &[(&str, &str)] = &[
383390 // lane-av112bitg: the grain refusal left with its witness -- the
384391 // two-frame 12-bit grain stream now DECODES byte-exact
385392 // (`a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`).
386- (
387- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
388- "a_12bit_warped_motion_stream_is_refused_by_name",
389- ),
393+ // lane-av112bitw: the warp pair left too -- its gate now WITNESSES
394+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`, the same recipe
395+ // that refused pre-lift) and the compound-warp arm witnesses through
396+ // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
397+ // (hard `compound_warp_hits > 0`).
390398 (
391399 "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",
392400 "a_12bit_screen_content_stream_is_refused_by_name",
crates/ec-av1/src/stream.rsmodified+131 -31
@@ -8619,31 +8619,68 @@ pub(crate) mod tests {
86198619 }
86208620 }
86218621
8622- /// The 12-bit warp refusal, exercised on a REAL stream: the same source
8623- /// and recipe with the warp tools ON -- aomenc picks a global warp model
8624- /// on this content (measured: the decode refuses at the first warped
8625- /// block) -- is refused by name.
8622+ /// The 12-bit WARP witness (lane-av112bitw): the same source and recipe
8623+ /// with the warp tools ON -- aomenc picks warp models on this content
8624+ /// (measured pre-lift: the warp model fires at the third frame, and the
8625+ /// decode refused by name at exactly that block) -- now decodes
8626+ /// BYTE-EXACT against ffmpeg. The warp filter's shifts are the bumped
8627+ /// `conv_params->round_0` (`warp::warp_round_0`, 5 at 12 bits, feeding
8628+ /// `reduce_bits_horiz`, the derived non-compound
8629+ /// `reduce_bits_vert = 2*FILTER_BITS - round_0` and both `offset_bits`),
8630+ /// the whole libaom `get_conv_params_no_round` 12-bit bump.
8631+ ///
8632+ /// Non-vacuous: the same recipe refused by name before the lift, the
8633+ /// gate hard-asserts a warp predictor was really resolved (a warpless
8634+ /// stream would pass the pixel compare and prove nothing), and every
8635+ /// plane of every frame compares against ffmpeg's decode.
86268636 #[test]
8627- fn a_12bit_warped_motion_stream_is_refused_by_name() {
8628- const NAME: &str = "a_12bit_warped_motion_stream_is_refused_by_name";
8637+ fn a_12bit_warped_motion_stream_decodes_pixel_exact() {
8638+ const NAME: &str = "a_12bit_warped_motion_stream_decodes_pixel_exact";
86298639 let _gate_lock = lock_gate_counters();
8640+ if !have_ffmpeg() {
8641+ eprintln!("SKIP {NAME}: no ffmpeg");
8642+ return;
8643+ }
86308644 if !have_aomenc() {
86318645 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
86328646 return;
86338647 }
86348648 let y4m = y4m_12bit_subpel_source(6);
8635- // Exactly the recipe measured to refuse at warp: warp ON, global
8636- // motion NOT spelled (spelling it ON makes a GLOBAL_GLOBALMV
8637- // compound block reach the compound refusal first), six frames --
8638- // the warp model fires at the third frame.
8649+ // Exactly the recipe measured to refuse at warp pre-lift: warp ON,
8650+ // global motion NOT spelled (spelling it ON drives a GLOBAL_GLOBALMV
8651+ // compound block into the compound-warp arm -- see the compound gate
8652+ // below), six frames -- the warp model fires at the third frame.
86398653 let stream = encode_12bit(&y4m, 6, &["--enable-warped-motion=1"]);
8640- let err = decode_stream(&stream).unwrap_err().to_string();
8654+ assert_12bit_sequence_header(&stream, NAME);
8655+ let (before_selected, before_warp8, before_affine) = (
8656+ decode::warp_selected_hits(),
8657+ decode::warp_hits_8(),
8658+ decode::affine_gm_hits(),
8659+ );
8660+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
8661+ panic!("{NAME}: decode_stream refused a real 12-bit warp stream: {e}")
8662+ });
8663+ assert_eq!(frames.len(), 6);
8664+ let (delta_selected, delta_warp8, delta_affine) = (
8665+ decode::warp_selected_hits() - before_selected,
8666+ decode::warp_hits_8() - before_warp8,
8667+ decode::affine_gm_hits() - before_affine,
8668+ );
8669+ eprintln!(
8670+ "{NAME}: warp_engagement selected(16x16+ symbol)={delta_selected} \
8671+ warped8(usable 8x8 model)={delta_warp8} affine_gm(6-param model)={delta_affine}"
8672+ );
86418673 assert!(
8642- err.contains(
8643- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)"
8644- ),
8645- "{NAME}: expected the 12-bit warp refusal, got: {err}"
8674+ delta_selected + delta_warp8 + delta_affine > 0,
8675+ "{NAME}: no warp predictor was resolved -- the stream carries no \
8676+ warp model and the pixel compare would prove nothing"
86468677 );
8678+ let ffmpeg_frames = ffmpeg_decode_sequence_12bit(&stream, 160, 128, 6);
8679+ for (i, (ours, reference)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8680+ assert_eq!(ours.y, reference.y, "frame {i} luma vs ffmpeg (12-bit warp)");
8681+ assert_eq!(ours.u, reference.u, "frame {i} U vs ffmpeg (12-bit warp)");
8682+ assert_eq!(ours.v, reference.v, "frame {i} V vs ffmpeg (12-bit warp)");
8683+ }
86478684 }
86488685
86498686 /// The 12-bit COMPOUND witness (lane-av112bitc): the parent's source
@@ -21833,12 +21870,13 @@ pub(crate) mod tests {
2183321870 /// `mc::predict_compound_intermediate`. `compound_warp_hits() > 0` is a
2183421871 /// hard assert: a run where the encoder never emitted one proves nothing.
2183521872 /// A decode error or a pixel mismatch is a FAILURE, never a skip.
21836- fn run_compound_global_warp_gate(name: &str, ten_bit: bool) {
21873+ fn run_compound_global_warp_gate(name: &str, bd: u32, min_part: u32, leaf8_assert: bool) {
2183721874 let _gate_lock = lock_gate_counters();
2183821875 assert!(have_ffmpeg(), "{name}: ffmpeg required");
2183921876 assert!(have_aomenc(), "{name}: no aomenc at {}", aomenc_path().display());
2184021877 let (width, height, frame_count) = (64usize, 64usize, 24usize);
2184121878 let before = crate::decode::compound_warp_hits();
21879+ let before8 = crate::decode::compound_warp_hits_8();
2184221880 let mut matched = 0u32;
2184321881 let mut named_refusals = 0u32;
2184421882 let mut attempts = 0u32;
@@ -21856,7 +21894,11 @@ pub(crate) mod tests {
2185621894 h = height * 2,
2185721895 sx = -0.6 + 0.01 * (i as f64),
2185821896 );
21859- let pix_fmt = if ten_bit { "yuv420p10le" } else { "yuv420p" };
21897+ let pix_fmt = match bd {
21898+ 8 => "yuv420p",
21899+ 10 => "yuv420p10le",
21900+ _ => "yuv420p12le",
21901+ };
2186021902 let y4m = Command::new("ffmpeg")
2186121903 .args([
2186221904 "-v", "error", "-f", "lavfi", "-i", &source, "-t",
@@ -21874,6 +21916,8 @@ pub(crate) mod tests {
2187421916 String::from_utf8_lossy(&y4m.stderr)
2187521917 );
2187621918 let cq_arg = format!("--cq-level={cq}");
21919+ let (in_depth_arg, depth_arg) =
21920+ (format!("--input-bit-depth={bd}"), format!("--bit-depth={bd}"));
2187721921 let mut args: Vec<&str> = vec![
2187821922 "--codec=av1",
2187921923 "--passes=1",
@@ -21912,14 +21956,18 @@ pub(crate) mod tests {
2191221956 "--enable-cdef=0",
2191321957 "--enable-restoration=0",
2191421958 "--max-partition-size=32",
21915- "--min-partition-size=32",
2191621959 "--enable-palette=0",
2191721960 "--enable-intrabc=0",
2191821961 "--enable-cfl-intra=0",
2191921962 "--enable-ref-frame-mvs=0",
2192021963 ];
21921- if ten_bit {
21922- args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
21964+ let min_part_arg = format!("--min-partition-size={min_part}");
21965+ args.push(min_part_arg.as_str());
21966+ if bd != 8 {
21967+ args.extend_from_slice(&[
21968+ in_depth_arg.as_str(),
21969+ depth_arg.as_str(),
21970+ ]);
2192321971 }
2192421972 args.extend_from_slice(&["--obu", "-o", "-", "-"]);
2192521973 let out = run_with_stdin(Command::new(aomenc_path())
@@ -21947,10 +21995,10 @@ pub(crate) mod tests {
2194721995 }
2194821996 Ok(frames) => frames,
2194921997 };
21950- let want = if ten_bit {
21951- ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
21952- } else {
21953- ffmpeg_decode_sequence(&stream, width, height, frame_count)
21998+ let want = match bd {
21999+ 8 => ffmpeg_decode_sequence(&stream, width, height, frame_count),
22000+ 10 => ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count),
22001+ _ => ffmpeg_decode_sequence_12bit(&stream, width, height, frame_count),
2195422002 };
2195522003 assert_eq!(frames.len(), frame_count);
2195622004 if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP")
@@ -21971,15 +22019,25 @@ pub(crate) mod tests {
2197122019 }
2197222020 }
2197322021 let hits = crate::decode::compound_warp_hits() - before;
22022+ let hits8 = crate::decode::compound_warp_hits_8() - before8;
2197422023 eprintln!(
2197522024 "{name}: {matched}/{attempts} pixel-exact, {named_refusals} named refusals, \
21976- compound_warp_hits={hits}"
21977- );
21978- assert!(
21979- hits > 0,
21980- "{name}: no compound block was predicted through a per-ref global warp \
21981- ({matched} matches, {named_refusals} refusals of {attempts}) -- gate vacuous"
22025+ compound_warp_hits={hits} compound_warp_hits_8={hits8}"
2198222026 );
22027+ if leaf8_assert {
22028+ assert!(
22029+ hits8 > 0,
22030+ "{name}: no 8x8 COMPOUND leaf was predicted through a per-ref global \
22031+ warp ({hits} bigger compound warp blocks, {matched} matches, \
22032+ {named_refusals} refusals of {attempts}) -- gate vacuous"
22033+ );
22034+ } else {
22035+ assert!(
22036+ hits > 0,
22037+ "{name}: no compound block was predicted through a per-ref global warp \
22038+ ({matched} matches, {named_refusals} refusals of {attempts}) -- gate vacuous"
22039+ );
22040+ }
2198322041 assert!(matched > 0, "{name}: every attempt refused -- no pixel comparison ran");
2198422042 }
2198522043
@@ -22202,7 +22260,12 @@ pub(crate) mod tests {
2220222260 /// 8-bit arm of [`run_compound_global_warp_gate`].
2220322261 #[test]
2220422262 fn a_real_compound_global_warp_stream_decodes_pixel_exact() {
22205- run_compound_global_warp_gate("a_real_compound_global_warp_stream_decodes_pixel_exact", false);
22263+ run_compound_global_warp_gate(
22264+ "a_real_compound_global_warp_stream_decodes_pixel_exact",
22265+ 8,
22266+ 32,
22267+ false,
22268+ );
2220622269 }
2220722270
2220822271 /// 10-bit arm of [`run_compound_global_warp_gate`] -- both of his films are
@@ -22221,6 +22284,43 @@ pub(crate) mod tests {
2222122284 fn a_real_compound_global_warp_10bit_stream_decodes_pixel_exact() {
2222222285 run_compound_global_warp_gate(
2222322286 "a_real_compound_global_warp_10bit_stream_decodes_pixel_exact",
22287+ 10,
22288+ 32,
22289+ false,
22290+ );
22291+ }
22292+
22293+ /// 12-bit arm of [`run_compound_global_warp_gate`] (lane-av112bitw): the
22294+ /// same rotating-mandelbrot recipe at `--bit-depth=12`. Pre-lift the
22295+ /// first `GLOBAL_GLOBALMV` block under a ROTZOOM model refused ("warped
22296+ /// motion at 12 bits"); the lift runs the same `warp::warp_round_0` bump
22297+ /// through `warp_affine_compound` (`reduce_bits_horiz` 5, compound
22298+ /// `reduce_bits_vert` stays 7, the CONV_BUF blend bias one octave down:
22299+ /// `(1 << (bd + 2)) + (1 << (bd + 1))`).
22300+ #[test]
22301+ fn a_real_compound_global_warp_12bit_stream_decodes_pixel_exact() {
22302+ run_compound_global_warp_gate(
22303+ "a_real_compound_global_warp_12bit_stream_decodes_pixel_exact",
22304+ 12,
22305+ 32,
22306+ false,
22307+ );
22308+ }
22309+
22310+ /// 12-bit 8x8 compound-warp LEAF arm (lane-av112bitw, reviewer gap): the
22311+ /// same recipe with the 32x32 partition pin dropped to min 8, so the RD
22312+ /// can code an 8x8 `GLOBAL_GLOBALMV` leaf whose two references warp per
22313+ /// slot -- `decode_inter_block8`'s `COMPOUND_WARP_HITS_8` path, which
22314+ /// the 32x32-pinned compound witness structurally cannot reach. Hard-
22315+ /// asserts `compound_warp_hits_8() > 0` (an 8x8 compound warp leaf bumps
22316+ /// it alongside [`decode::compound_warp_hits`]; a 16x16+ one cannot), so
22317+ /// a stream of only bigger warped blocks fails this gate.
22318+ #[test]
22319+ fn a_real_compound_global_warp_12bit_8x8_leaf_stream_decodes_pixel_exact() {
22320+ run_compound_global_warp_gate(
22321+ "a_real_compound_global_warp_12bit_8x8_leaf_stream_decodes_pixel_exact",
22322+ 12,
22323+ 8,
2222422324 true,
2222522325 );
2222622326 }
crates/ec-av1/src/warp.rsmodified+87 -25
@@ -328,12 +328,20 @@ fn get_shear_params(wmmat: [i32; 6]) -> Option<(i16, i16, i16, i16)> {
328328 return None;
329329 }
330330 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+ );
332336 let beta = clamp(mat[3], i16::MIN as i64, i16::MAX as i64);
333337 let (y_mag, shift) = resolve_divisor_32(mat[2].unsigned_abs() as u32);
334338 let y = if mat[2] < 0 { -y_mag } else { y_mag };
335339 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+ );
337345 let v = (mat[3] * mat[4]) * y;
338346 let mut delta = clamp(
339347 mat[5] - round2_signed(v, shift as u32) - (1 << WARPEDMODEL_PREC_BITS),
@@ -414,7 +422,13 @@ pub fn find_projection(
414422 /// translational fallback in that rare case.
415423 pub fn global_warp_params(wmmat: [i32; 6]) -> Option<WarpParams> {
416424 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+ })
418432 }
419433
420434 fn clip_pixel(v: i32, fctx: &crate::decode::FrameCtx) -> u16 {
@@ -442,17 +456,30 @@ pub(crate) fn warp_affine(
442456 p_height: i32,
443457 p_stride: i32,
444458 subsampling_x: i32,
445- subsampling_y: i32, fctx: &crate::decode::FrameCtx,
459+ subsampling_y: i32,
460+ fctx: &crate::decode::FrameCtx,
446461 ) {
447462 if crate::envflags::env_flag!("EC_MC_TRACE") {
448463 eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");
449464 }
450465 let bd = i32::from(crate::decode::bit_depth(fctx));
451- // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0`.
452- let reduce_bits_vert = 2 * FILTER_BITS - REDUCE_BITS_HORIZ;
466+ // `reduce_bits_vert`, non-compound: `2 * FILTER_BITS - round_0` (the
467+ // bumped `conv_params->round_0`, [`warp_round_0`]).
468+ let reduce_bits_vert = 2 * FILTER_BITS - warp_round_0(bd);
453469 warp_inner(
454- params, reference, width, height, stride, p_col, p_row, p_width, p_height,
455- subsampling_x, subsampling_y, bd, reduce_bits_vert,
470+ params,
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,
456483 |row, col, sum| {
457484 dst[row * p_stride as usize + col] =
458485 clip_pixel(sum - (1 << (bd - 1)) - (1 << bd), fctx);
@@ -471,8 +498,8 @@ pub(crate) fn warp_affine(
471498 /// both roundings exactly because both exceed their shift) and subtracts
472499 /// `(1 << (offset_bits - round_1)) + (1 << (offset_bits - round_1 - 1))`
473500 /// at the blend; this crate's intermediates are UNBIASED (see
474-/// [`mc::diffwtd_mask`]'s derivation), so the identical constant --
475-/// `(1 << (bd + 4)) + (1 << (bd + 3))` -- is removed here instead, making
501+/// [`mc::diffwtd_mask`]'s derivation), so the identical constant, derived
502+/// from the bumped `round_0` below, is removed here instead, making
476503 /// the output directly interchangeable with
477504 /// [`mc::predict_compound_intermediate`]'s for
478505 /// [`mc::combine_compound`]/[`mc::blend_masked_compound`].
@@ -490,27 +517,61 @@ pub(crate) fn warp_affine_compound(
490517 p_height: i32,
491518 p_stride: i32,
492519 subsampling_x: i32,
493- subsampling_y: i32, fctx: &crate::decode::FrameCtx,
520+ subsampling_y: i32,
521+ fctx: &crate::decode::FrameCtx,
494522 ) {
495523 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));
497533 warp_inner(
498- params, reference, width, height, stride, p_col, p_row, p_width, p_height,
499- subsampling_x, subsampling_y, bd, COMPOUND_ROUND1_BITS,
534+ params,
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,
500547 |row, col, sum| {
501548 dst[row * p_stride as usize + col] = sum - bias;
502549 },
503550 );
504551 }
505552
506-/// `conv_params->round_0` (`ROUND0_BITS`), the warp filter's horizontal
507-/// rounding -- `InterRound0`, bit-depth independent for 8/10-bit content
508-/// (libaom only raises it at `bd == 12`, which this decoder refuses).
509-const REDUCE_BITS_HORIZ: i32 = 3;
553+/// `ROUND0_BITS` (`convolve.h`): `conv_params->round_0` before
554+/// `get_conv_params_no_round`'s high-bitdepth buffer-range bump.
555+const ROUND0_BITS: i32 = 3;
510556 /// `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).
512560 const COMPOUND_ROUND1_BITS: i32 = 7;
513561
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+
514575 /// The shared body of [`warp_affine`]/[`warp_affine_compound`]
515576 /// (`av1_highbd_warp_affine_c`): everything up to and including the
516577 /// vertical `ROUND_POWER_OF_TWO(sum, reduce_bits_vert)`, with `store`
@@ -539,7 +600,7 @@ fn warp_inner(
539600 params.gamma as i64,
540601 params.delta as i64,
541602 );
542- let reduce_bits_horiz = REDUCE_BITS_HORIZ;
603+ let reduce_bits_horiz = warp_round_0(bd);
543604 let offset_bits_horiz = bd + FILTER_BITS - 1;
544605 let offset_bits_vert = bd + 2 * FILTER_BITS - reduce_bits_horiz;
545606
@@ -570,8 +631,8 @@ fn warp_inner(
570631 let mut sx = sx4 + beta * (k as i64 + 4);
571632 for l in -4..4i32 {
572633 let ix = ix4 + l - 3;
573- let offs =
574- (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize;
634+ let offs = (round2(sx, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS)
635+ as usize;
575636 let coeffs = &AV1_WARPED_FILTER[offs];
576637 let mut sum: i32 = 1 << offset_bits_horiz;
577638 for (m, &c) in coeffs.iter().enumerate() {
@@ -591,12 +652,13 @@ fn warp_inner(
591652 let l_hi = (4i32).min(p_col + p_width - j - 4);
592653 let mut l = -4i32;
593654 while l < l_hi {
594- let offs =
595- (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS) as usize;
655+ let offs = (round2(sy, WARPEDDIFF_PREC_BITS) as i32 + WARPEDPIXEL_PREC_SHIFTS)
656+ as usize;
596657 let coeffs = &AV1_WARPED_FILTER[offs];
597658 let mut sum: i32 = 1 << offset_bits_vert;
598659 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;
600662 }
601663 sum = round2(sum as i64, reduce_bits_vert as u32) as i32;
602664 store(
lanes/av112bitw.report.mdadded+139 -0
@@ -0,0 +1,139 @@
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+- **stream.rs, reviewer round (post-cbb3a9b9)** — Elif's FAIL: the
70+ compound witness pins `--min/--max-partition-size=32`, so it structurally
71+ cannot emit an 8x8 compound-warp LEAF, and it asserts
72+ `compound_warp_hits()`, not `compound_warp_hits_8()` — the 8x8 arm was
73+ unwitnessed (its only prior gate was 8-bit). The helper gained
74+ `min_part: u32` + `leaf8_assert: bool`; the new
75+ `a_real_compound_global_warp_12bit_8x8_leaf_stream_decodes_pixel_exact`
76+ drops the pin to min 8 and hard-asserts `compound_warp_hits_8() > 0`
77+ (only an 8x8 compound warp leaf bumps it).
78+
79+## The witnesses
80+
81+Encoder: the local aom oracle build (`~/.cache/aom-oracle/build/aomenc`,
82+libaom src `92d4c37fbdd08944a0e721bbaeb13318f10aebb0`); reference decode
83+ffmpeg 8.1.2 (`yuv420p12le` rawvideo). Gates encode live; the committed
84+fixtures are untouched (no new fixture needed).
85+
86+1. **Single-ref** `a_12bit_warped_motion_stream_decodes_pixel_exact` — the
87+ exact recipe that refused pre-lift, 6 frames, byte-exact vs ffmpeg on
88+ every plane of every frame. Engagement: `warp_selected_hits` 7 (16x16+
89+ WARPED_CAUSAL), `warp_hits_8` 1 (usable 8x8 local model),
90+ `affine_gm_hits` 0 (content fits no >TRANSLATION global model — the
91+ single-ref global-warp arm rides on the same filter + the composition
92+ argument, not its own stream). Hard counter assert so a warpless stream
93+ cannot pass vacuously.
94+2. **Compound** `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
95+ — the cwarp rotating-mandelbrot recipe at `--bit-depth=12`: **6/6
96+ attempts pixel-exact, 0 named refusals, compound_warp_hits = 28**, with
97+ the gate's own hard asserts (`hits > 0`, `matched > 0`, no refusal may
98+ contain "warp"). Pre-lift the same gate FAILED with the warp refusal on
99+ attempt 1 — non-vacuity both directions.
100+3. **8x8 compound-warp LEAF** (reviewer round)
101+ `a_real_compound_global_warp_12bit_8x8_leaf_stream_decodes_pixel_exact`
102+ — the same recipe with the partition pin dropped to min 8: **6/6
103+ pixel-exact, compound_warp_hits = 128, compound_warp_hits_8 = 81**, the
104+ leaf counter hard-asserted `> 0`. This closes the 8x8
105+ `decode_inter_block8` compound-warp arm at 12 bits.
106+
107+## Results
108+
109+- 12-bit battery: key, inter, compound (parent fixtures) all still
110+ byte-exact; `a_12bit_screen_content_stream_is_refused_by_name` and
111+ `a_12bit_film_grain_stream_is_refused_by_name` still refuse by name.
112+- Warp family: 8-bit and 10-bit cwarp gates green (the parameterisation is
113+ a no-op at bd <= 10, proven not just claimed), the 12-bit compound and
114+ 12-bit 8x8-leaf cwarp gates green, both fimv
115+ force-integer-mv warp-alphabet gates green, both 10-bit film fixture
116+ gates with warp green (`a_10bit_128sb_film_frames_with_warp_cdef_and_interintra...`,
117+ `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach...`).
118+- `refusal_inventory` + `gate_coverage` suites green.
119+- `cargo check -p ec-av1 --all-targets`: 0 warnings.
120+
121+## Open halves (recorded, not silently dropped)
122+
123+1. **Single-ref GLOBAL-warp at 12 bits has no stream of its own** (engagement
124+ 0 on this content): lifted on the composition argument — identical
125+ `warp_affine` filter, bit-depth-independent model source, both pieces
126+ witnessed. A stream whose single-ref blocks warp under a ROTZOOM global
127+ model would close it outright; the mandelbrot content produces those
128+ models only on compound blocks here. STAYS OPEN per Main.
129+2. **Grain and screen content stay refused by name** (untouched, per
130+ charter): `film grain synthesis at 12 bits ...` and
131+ `a 12-bit frame with screen content tools ...` with their real-stream
132+ refusal gates.
133+
134+## Create-list audit
135+
136+Exactly one new file: this report. Touched: `warp.rs` (the parameterisation),
137+`decode.rs` (three refusal deletions + header comment), `stream.rs` (witness
138+gate swap + gate generalisation + the 8x8-leaf arm), `refusal_inventory.rs`
139+(two row removals + notes). No fixture, no junk file.