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::{
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 ///
@@ -29093,13 +29096,12 @@ fn decode_inter_block(
2909329096 let warp1 = compound_warp(ref1, is_global_mv1).filter(|_| ref_unscaled(ref1));
2909429097 if warp0.is_some() || warp1.is_some() {
2909529098 hit!(COMPOUND_WARP_HITS);
29096- // lane-av112bit: refused by name -- see `WARP_12BIT_REFUSAL`.
29097- if bit_depth(fctx) == 12 {
29098- return Err(Error::unsupported(
29099- "AV1 tile decode",
29100- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
29101- ));
29102- }
29099+ // lane-av112bitw: the 12-bit refusal that stood here is
29100+ // LIFTED with the compound-warp witness: the rotating-
29101+ // mandelbrot 12-bit recipe refused exactly here pre-lift and
29102+ // now decodes byte-exact vs ffmpeg through the same bumped
29103+ // `warp::warp_round_0` shifts
29104+ // (`a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`).
2910329105 }
2910429106 // spec `get_ref_filter_type`: matches when EITHER of the
2910529107 // neighbour's two references equals this block's own ref0 --
@@ -30676,15 +30678,13 @@ fn decode_inter_block(
3067630678 hit!(AFFINE_GM_HITS);
3067730679 }
3067830680 }
30679- // lane-av112bit: a local `WARPED_CAUSAL` projection (set above) or
30680- // a global warp model both land here with `warp_params` set --
30681- // refused by name at 12 bits (see `WARP_12BIT_REFUSAL`).
30682- if bit_depth(fctx) == 12 && warp_params.is_some() {
30683- return Err(Error::unsupported(
30684- "AV1 tile decode",
30685- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
30686- ));
30687- }
30681+ // lane-av112bitw: a local `WARPED_CAUSAL` projection (set above)
30682+ // or a global warp model both land here with `warp_params` set --
30683+ // the 12-bit refusal that used to stand here is LIFTED: warp.rs's
30684+ // rounding is parameterised on the bumped `conv_params->round_0`
30685+ // (`warp::warp_round_0`, 5 at 12 bits) and the six-frame 12-bit
30686+ // warp stream decodes byte-exact vs ffmpeg
30687+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`).
3068830688 if crate::envflags::env_flag!("EC_AV1_TELL") {
3068930689 eprintln!(
3069030690 "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}",
@@ -35527,15 +35527,11 @@ fn decode_inter_block8(
3552735527 hit!(AFFINE_GM_HITS);
3552835528 }
3552935529 }
35530- // lane-av112bit: same 12-bit refusal as the 16x16+ leaf -- a local
35530+ // lane-av112bitw: same lift as the 16x16+ leaf -- a local
3553135531 // `WARPED_CAUSAL` projection or a global model both leave
35532- // `warp_params` set here (see `WARP_12BIT_REFUSAL`).
35533- if bit_depth(fctx) == 12 && warp_params.is_some() {
35534- return Err(Error::unsupported(
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- }
35532+ // `warp_params` set here; the 12-bit refusal that stood here is
35533+ // lifted with the same witness (`warp::warp_round_0` moved the
35534+ // filter's shifts; the same stream decodes byte-exact vs ffmpeg).
3553935535 if crate::envflags::env_flag!("EC_TRACE_MODE") {
3554035536 eprintln!(
3554135537 "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] = &[
8080 // lane-av112bitc: compound joined the witnessed set (six-frame 12-bit
8181 // compound stream byte-exact vs ffmpeg; the combines already absorbed
8282 // 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.
8491 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",
8592 "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)",
8693 // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to
@@ -363,10 +370,11 @@ const PROVEN: &[(&str, &str)] = &[
363370 // lane-av112bitc: the compound pair left with its refusal -- the
364371 // six-frame compound stream now DECODES byte-exact
365372 // (`a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact`).
366- (
367- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)",
368- "a_12bit_warped_motion_stream_is_refused_by_name",
369- ),
373+ // lane-av112bitw: the warp pair left too -- its gate now WITNESSES
374+ // (`a_12bit_warped_motion_stream_decodes_pixel_exact`, the same recipe
375+ // that refused pre-lift) and the compound-warp arm witnesses through
376+ // `a_real_compound_global_warp_12bit_stream_decodes_pixel_exact`
377+ // (hard `compound_warp_hits > 0`).
370378 (
371379 "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)",
372380 "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 {
80378037 }
80388038 }
80398039
8040- /// The 12-bit warp refusal, exercised on a REAL stream: the same source
8041- /// and recipe with the warp tools ON -- aomenc picks a global warp model
8042- /// on this content (measured: the decode refuses at the first warped
8043- /// block) -- is refused by name.
8040+ /// The 12-bit WARP witness (lane-av112bitw): the same source and recipe
8041+ /// with the warp tools ON -- aomenc picks warp models on this content
8042+ /// (measured pre-lift: the warp model fires at the third frame, and the
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.
80448054 #[test]
8045- fn a_12bit_warped_motion_stream_is_refused_by_name() {
8046- const NAME: &str = "a_12bit_warped_motion_stream_is_refused_by_name";
8055+ fn a_12bit_warped_motion_stream_decodes_pixel_exact() {
8056+ const NAME: &str = "a_12bit_warped_motion_stream_decodes_pixel_exact";
80478057 let _gate_lock = lock_gate_counters();
8058+ if !have_ffmpeg() {
8059+ eprintln!("SKIP {NAME}: no ffmpeg");
8060+ return;
8061+ }
80488062 if !have_aomenc() {
80498063 eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
80508064 return;
80518065 }
80528066 let y4m = y4m_12bit_subpel_source(6);
8053- // Exactly the recipe measured to refuse at warp: warp ON, global
8054- // motion NOT spelled (spelling it ON makes a GLOBAL_GLOBALMV
8055- // compound block reach the compound refusal first), six frames --
8056- // the warp model fires at the third frame.
8067+ // Exactly the recipe measured to refuse at warp pre-lift: warp ON,
8068+ // global motion NOT spelled (spelling it ON drives a GLOBAL_GLOBALMV
8069+ // compound block into the compound-warp arm -- see the compound gate
8070+ // below), six frames -- the warp model fires at the third frame.
80578071 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+ );
80598091 assert!(
8060- err.contains(
8061- "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)"
8062- ),
8063- "{NAME}: expected the 12-bit warp refusal, got: {err}"
8092+ delta_selected + delta_warp8 + delta_affine > 0,
8093+ "{NAME}: no warp predictor was resolved -- the stream carries no \
8094+ warp model and the pixel compare would prove nothing"
80648095 );
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+ }
80658102 }
80668103
80678104 /// The 12-bit COMPOUND witness (lane-av112bitc): the parent's source
@@ -21181,7 +21218,7 @@ pub(crate) mod tests {
2118121218 /// `mc::predict_compound_intermediate`. `compound_warp_hits() > 0` is a
2118221219 /// hard assert: a run where the encoder never emitted one proves nothing.
2118321220 /// 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) {
2118521222 let _gate_lock = lock_gate_counters();
2118621223 assert!(have_ffmpeg(), "{name}: ffmpeg required");
2118721224 assert!(have_aomenc(), "{name}: no aomenc at {}", aomenc_path().display());
@@ -21204,7 +21241,11 @@ pub(crate) mod tests {
2120421241 h = height * 2,
2120521242 sx = -0.6 + 0.01 * (i as f64),
2120621243 );
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+ };
2120821249 let y4m = Command::new("ffmpeg")
2120921250 .args([
2121021251 "-v", "error", "-f", "lavfi", "-i", &source, "-t",
@@ -21222,6 +21263,8 @@ pub(crate) mod tests {
2122221263 String::from_utf8_lossy(&y4m.stderr)
2122321264 );
2122421265 let cq_arg = format!("--cq-level={cq}");
21266+ let (in_depth_arg, depth_arg) =
21267+ (format!("--input-bit-depth={bd}"), format!("--bit-depth={bd}"));
2122521268 let mut args: Vec<&str> = vec![
2122621269 "--codec=av1",
2122721270 "--passes=1",
@@ -21266,8 +21309,11 @@ pub(crate) mod tests {
2126621309 "--enable-cfl-intra=0",
2126721310 "--enable-ref-frame-mvs=0",
2126821311 ];
21269- if ten_bit {
21270- args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]);
21312+ if bd != 8 {
21313+ args.extend_from_slice(&[
21314+ in_depth_arg.as_str(),
21315+ depth_arg.as_str(),
21316+ ]);
2127121317 }
2127221318 args.extend_from_slice(&["--obu", "-o", "-", "-"]);
2127321319 let out = run_with_stdin(Command::new(aomenc_path())
@@ -21295,10 +21341,10 @@ pub(crate) mod tests {
2129521341 }
2129621342 Ok(frames) => frames,
2129721343 };
21298- let want = if ten_bit {
21299- ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
21300- } else {
21301- ffmpeg_decode_sequence(&stream, width, height, frame_count)
21344+ let want = match bd {
21345+ 8 => ffmpeg_decode_sequence(&stream, width, height, frame_count),
21346+ 10 => ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count),
21347+ _ => ffmpeg_decode_sequence_12bit(&stream, width, height, frame_count),
2130221348 };
2130321349 assert_eq!(frames.len(), frame_count);
2130421350 if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP")
@@ -21550,7 +21596,7 @@ pub(crate) mod tests {
2155021596 /// 8-bit arm of [`run_compound_global_warp_gate`].
2155121597 #[test]
2155221598 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);
2155421600 }
2155521601
2155621602 /// 10-bit arm of [`run_compound_global_warp_gate`] -- both of his films are
@@ -21569,7 +21615,22 @@ pub(crate) mod tests {
2156921615 fn a_real_compound_global_warp_10bit_stream_decodes_pixel_exact() {
2157021616 run_compound_global_warp_gate(
2157121617 "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,
2157321634 );
2157421635 }
2157521636
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+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.