From da48c9165822d0971fefd43866a10f7ab65ae960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 09:55:16 +0300 Subject: [PATCH] feat(av1): rectangular wedge masks (hgtw/hltw codebooks) -- COMPOUND_WEDGE and wedge-interintra on 8x16/16x8/16x32/32x16/8x32/32x8 inter blocks wedge.rs carried only wedge_codebook_16_heqw and the one signflip row the three square sizes share, so every rectangular masked-compound or wedge-interintra block was refused by name. Ported the remaining two codebooks (wedge_codebook_16_hgtw for h>w, _hltw for h usize { WII_HITS.with(|c| c.get()) } +/// lane-inter16ab r5: the six RECTANGULAR wedge shapes, in this order -- +/// the counter slots of [`RECT_WEDGE_HITS`]/[`RECT_WII_HITS`]. +pub(crate) const RECT_WEDGE_SHAPES: [(usize, usize); 6] = + [(8, 16), (16, 8), (16, 32), (32, 16), (8, 32), (32, 8)]; + +fn rect_wedge_slot(bw: usize, bh: usize) -> Option { + RECT_WEDGE_SHAPES.iter().position(|&s| s == (bw, bh)) +} + +// lane-inter16ab r5: how many COMPOUND_WEDGE / wedge-INTERINTRA blocks used a +// RECTANGULAR codebook row (hgtw/hltw), per shape -- the gate's proof that +// the rect wedge masks lifted this round actually fired, not just the square +// ones already counted by `WEDGE_HITS`/`WII_HITS`. +thread_local! { + static RECT_WEDGE_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; + static RECT_WII_HITS: std::cell::Cell<[usize; 6]> = const { std::cell::Cell::new([0; 6]) }; +} + +/// Current value of [`RECT_WEDGE_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. +pub(crate) fn rect_wedge_hits() -> [usize; 6] { + RECT_WEDGE_HITS.with(|c| c.get()) +} + +/// Current value of [`RECT_WII_HITS`], indexed by [`RECT_WEDGE_SHAPES`]. +pub(crate) fn rect_wii_hits() -> [usize; 6] { + RECT_WII_HITS.with(|c| c.get()) +} + // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented @@ -16995,23 +17023,29 @@ fn decode_inter_block( Some(b) => dec.symbol(&mut cdfs.compound_type[b]), None => 1, }; - if wedge_bsize.is_some() && compound_type == 0 && write_w != write_h { - // The wedge mask codebook (`wedge.rs`) is built for the - // square sizes only; a rect wedge block is refused by - // name rather than blended with the wrong mask. - return Err(unsupported( - "a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook is square-only)", - )); - } if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) { // COMPOUND_WEDGE: lane-wedge r3, codebook checksum- // verified vs independent C dump (wedge.rs). let wedge_index = dec.symbol(&mut cdfs.wedge_idx[wedge_bsize]); let wedge_sign = dec.literal(1); WEDGE_HITS.with(|c| c.set(c.get() + 1)); + if let Some(k) = rect_wedge_slot(write_w, write_h) { + RECT_WEDGE_HITS.with(|c| { + let mut a = c.get(); + a[k] += 1; + c.set(a); + }); + } + // lane-inter16ab r5: the codebook row is this block's TRUE + // footprint (`av1_wedge_params_lookup[bsize]`: hgtw for + // h>w, hltw for h [usize; 2] { crate::decode::vartx_rect_leaf4_hits() } +/// lane-inter16ab r5: COMPOUND_WEDGE / wedge-INTERINTRA blocks that used a +/// RECTANGULAR wedge codebook row, per shape (`RECT_WEDGE_SHAPES` order: +/// 8x16, 16x8, 16x32, 32x16, 8x32, 32x8). +pub fn rect_wedge_hits() -> [usize; 6] { + crate::decode::rect_wedge_hits() +} + +/// lane-inter16ab r5: the wedge-interintra half of [`rect_wedge_hits`]. +pub fn rect_wii_hits() -> [usize; 6] { + crate::decode::rect_wii_hits() +} + pub fn rect4_32_counters() -> (usize, usize, usize) { ( crate::decode::rect4_32_horz_hits(), @@ -8033,6 +8045,9 @@ mod tests { // Per arm, over both bit depths: how many pixel-exact attempts fired // it at least once. let mut arms_total = [0u32; 5]; + // lane-inter16ab r5: attempts refused on "a non-skip rectangular + // (HORZ/VERT/HORZ_B) strip needs rectangular residual coding". + let mut rect_residual_refusals = 0u32; for bit_depth in [8u32, 10u32] { let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = (0u32, 0u32, 0u32, 0u32); @@ -8159,6 +8174,17 @@ mod tests { "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ attempt {attempt}): {msg}" ); + // lane-inter16ab r5: attempt 1 is the ONLY recipe in + // r4's 100+ stream frame-aware sweep with an + // inter-frame PARTITION_VERT_4. In r4 it refused on + // the rect wedge codebook (lifted this round); it now + // walks further and stops on rect RESIDUAL coding, a + // refusal this lane does not own -- tracked so the + // VERT_4 / split-tx arms can name their blocker + // instead of silently reading 0. + if msg.contains("needs rectangular residual coding") { + rect_residual_refusals += 1; + } named_refusals += 1; eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); continue; @@ -8245,13 +8271,36 @@ mod tests { but mismatched ffmpeg -- a defect of another shape, not a pass" ); } + // Arms 1/3/4 (HORZ_4, the odd-strip `is_chroma_reference` pair, the + // `build_inter_predictors_sub8x8` two-mv chroma build) are proven + // outright. + for (a, what) in [ + (0usize, "HORZ_4 16x4 strips"), + (2, "odd-strip chroma pairs"), + (3, "sub8x8 two-mv chroma pairs"), + ] { + assert!( + arms_total[a] > 0, + "{NAME}: arm {a} ({what}) never fired on a pixel-exact attempt \ + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?})" + ); + } + // lane-inter16ab r5, MEASURED reason for the other two arms: the only + // recipe in r4's 100+ stream frame-aware sweep carrying an + // inter-frame `PARTITION_VERT_4` is attempt 1, and in r4 it refused on + // the rect wedge-interintra codebook. That refusal is LIFTED this + // round -- the stream now walks past it and stops on "a non-skip + // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual + // coding", a refusal this lane does not own. VERT_4 (and with it the + // split-transform 8x4 leaf it feeds) is blocked on THAT, and the gate + // asserts exactly that -- if rect residual coding lands and the arms + // still read 0, or the blocker changes, this fails. assert!( - arms_total.iter().all(|&n| n > 0), - "{NAME}: a 16-level inter 1:4 arm never fired on a pixel-exact attempt \ - (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) -- an \ - arm at 0 is unproven; arms 3/4 are the odd-strip `is_chroma_reference` pair and the \ - `build_inter_predictors_sub8x8` two-mv chroma build, arm 5 the \ - `sub_tx_size_map[TX_16X4] == TX_8X4` split-transform leaf" + (arms_total[1] > 0 && arms_total[4] > 0) || rect_residual_refusals > 0, + "{NAME}: the VERT_4 / split-tx-8x4 arms read 0 \ + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs/split-tx-8x4={arms_total:?}) and NO \ + attempt refused on rectangular residual coding -- their documented blocker is gone, \ + so a zero arm is now unexplained" ); } @@ -14282,6 +14331,208 @@ mod tests { } + /// lane-inter16ab r5: `COMPOUND_WEDGE` on a RECTANGULAR inter block -- + /// the shapes `av1_wedge_params_lookup` gives the `hgtw`/`hltw` + /// codebooks (8x16/16x32/8x32 and 16x8/32x16/32x8), which this decoder + /// refused by name until this round ("the wedge codebook is + /// square-only"). `--enable-rect-partitions=1` with + /// `--min-partition-size=16 --max-partition-size=32` is what makes + /// aomenc's RD put a masked compound block on a 16x32/32x16 strip + /// (measured: ~/.cache/inter16ab-tmp/rw2.sh, 24/24 streams at cq 50/55 + /// carry one and decode to the end at BOTH bit depths). + /// + /// Class `counter-from-refused-stream`: the per-shape counters are read + /// as a DELTA around one attempt and only counted for attempts that + /// decoded fully AND compared pixel-exact -- a refused attempt's hits + /// are discarded. Every decode-order frame (including hidden alt-ref + /// frames) is compared via [`decode_all_frames_vs_oracle`], and an + /// attempt that mismatches while carrying NO rect wedge fails the gate + /// through `oos_mismatch` rather than being blamed on this lane. + #[test] + fn a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_stream_with_a_rectangular_compound_wedge_decodes_pixel_exact"; + let _gate_lock = lock_gate_counters(); + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + if !have_aomenc() { + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); + return; + } + let (width, height, frame_count) = (96usize, 96usize, 24usize); + // Per rect shape (8x16, 16x8, 16x32, 32x16, 8x32, 32x8), summed over + // the attempts that decoded AND matched. + let mut shapes_proved = [0usize; 6]; + let (mut named_refusals, mut matched, mut oos_mismatch) = (0u32, 0u32, 0u32); + let mut attempts = 0u32; + for bit_depth in [8u32, 10u32] { + for &cq in &[50u32, 55] { + for a in 0..4u32 { + attempts += 1; + let duration = frame_count as f64 / 25.0; + // Same hard-diagonal-edge content the square wedge gate + // uses (wedge's masters are OBLIQUE), panned per attempt. + let source = format!( + "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}", + sx = -0.6 + 0.01 * (a as f64), + sy = -0.4 + 0.01 * (a as f64) + ); + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; + let y4m = Command::new("ffmpeg") + .args([ + "-v", "error", "-f", "lavfi", "-i", &source, "-t", + &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1", + "-f", "yuv4mpegpipe", "-strict", "-1", "-", + ]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + assert!( + y4m.status.success(), + "{NAME}: ffmpeg fixture: {}", + String::from_utf8_lossy(&y4m.stderr) + ); + let cq_arg = format!("--cq-level={cq}"); + let depth_arg = format!("--bit-depth={bit_depth}"); + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); + let args: Vec<&str> = vec![ + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", + &depth_arg, &input_depth_arg, + "--kf-max-dist=1000", "--threads=1", "--row-mt=0", "--auto-alt-ref=1", + "--lag-in-frames=16", "--enable-fwd-kf=0", "--enable-order-hint=1", + "--enable-warped-motion=1", "--enable-global-motion=0", + "--enable-obmc=1", "--enable-diff-wtd-comp=1", + "--enable-interintra-comp=1", "--enable-onesided-comp=0", + "--enable-interintra-wedge=1", "--enable-smooth-interintra=1", + "--enable-ab-partitions=0", "--enable-1to4-partitions=0", + "--enable-filter-intra=0", "--enable-smooth-intra=0", + "--enable-paeth-intra=0", "--enable-directional-intra=0", + "--enable-angle-delta=0", "--enable-tx-size-search=0", + "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0", + "--enable-intrabc=0", "--enable-cfl-intra=0", + "--enable-ref-frame-mvs=0", + // Per-arm overrides LAST (aomenc keeps the last + // occurrence of a repeated --enable-* flag): masked + // compound ON, distance-weighted OFF so the + // comp_group_idx==1 slot goes to wedge/diffwtd, and + // rectangular partitions ON at 16/32 -- the shapes + // the hgtw/hltw codebooks exist for. + "--enable-masked-comp=1", "--enable-dist-wtd-comp=0", + "--enable-rect-partitions=1", + "--min-partition-size=16", "--max-partition-size=32", + "--obu", "-o", "-", "-", + ]; + let mut child = Command::new(aomenc_path()) + .args(&args) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("aomenc failed to start"); + child + .stdin + .take() + .expect("aomenc stdin") + .write_all(&y4m.stdout) + .expect("writing y4m to aomenc"); + let out = child.wait_with_output().expect("aomenc failed to run"); + assert!( + out.status.success(), + "aomenc refused the fixture: {}", + String::from_utf8_lossy(&out.stderr) + ); + let stream = out.stdout; + let before = crate::stream::rect_wedge_hits(); + let frames = match decode_stream(&stream) { + Err(e) => { + let msg = e.to_string(); + assert!( + msg.contains("unsupported"), + "{NAME} failed outright, not a named refusal \ + ({bit_depth}-bit cq{cq} attempt {a}): {msg}" + ); + assert!( + !msg.contains("wedge codebook is square-only"), + "{NAME}: the rect wedge codebook is ported -- this refusal is \ + forbidden ({bit_depth}-bit cq{cq} attempt {a}): {msg}" + ); + named_refusals += 1; + eprintln!("{bit_depth}-bit cq{cq} attempt {a} refusal: {msg}"); + continue; + } + Ok(frames) => frames, + }; + let after = crate::stream::rect_wedge_hits(); + let fired: Vec = + (0..6).map(|k| after[k] - before[k]).collect(); + let ffmpeg_frames = if bit_depth == 10 { + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) + } else { + ffmpeg_decode_sequence(&stream, width, height, frame_count) + }; + assert_eq!(frames.len(), ffmpeg_frames.len()); + let mismatched = frames + .iter() + .zip(&ffmpeg_frames) + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); + if fired.iter().sum::() == 0 { + if mismatched { + oos_mismatch += 1; + eprintln!( + "{NAME}: {bit_depth}-bit cq{cq} attempt {a} MISMATCHES with zero \ + rectangular wedge block -- another shape's defect" + ); + } + continue; + } + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg ({bit_depth}-bit cq{cq} attempt {a}, shapes {fired:?})"); + } + // class gate-blind-to-hidden-frames: the shown-frame + // compare above cannot see the alt-ref frames this + // recipe's --lag-in-frames=16 produces. + let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME); + eprintln!( + "{NAME}: {bit_depth}-bit cq{cq} attempt {a}: shapes {fired:?}, \ + {hidden_total} decode-order frames ({hidden_n} hidden) pixel-exact" + ); + for k in 0..6 { + shapes_proved[k] += fired[k]; + } + matched += 1; + } + } + } + eprintln!( + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact attempts out of \ + {attempts}, rect wedge blocks per shape \ + (8x16,16x8,16x32,32x16,8x32,32x8)={shapes_proved:?}, {oos_mismatch} zero-wedge \ + mismatches" + ); + assert_eq!( + oos_mismatch, 0, + "{NAME}: {oos_mismatch} attempt(s) carrying no rectangular wedge mismatched ffmpeg \ + -- a defect of another shape, not a pass" + ); + // The claim: a rectangular wedge codebook row (hgtw AND hltw) was + // used on a stream that then decoded pixel-exact. 16x32 is hgtw + // (h > w), 32x16 is hltw (h < w) -- one of each, so a transposed + // codebook/signflip pair cannot pass this. + assert!( + shapes_proved[2] > 0 && shapes_proved[3] > 0, + "{NAME}: no pixel-exact attempt used both an hgtw (16x32) and an hltw (32x16) \ + rectangular wedge codebook row (per shape {shapes_proved:?}, {matched} matches, \ + {named_refusals} refusals out of {attempts}) -- the recipe proved nothing" + ); + } + + /// lane-lr r3: proves stage 1/2's exit criterion -- a real /// `--enable-restoration=1` aomenc stream must survive the whole /// partition walk (every symbol read entropy-exact) and land on the diff --git a/crates/ec-av1/src/wedge.rs b/crates/ec-av1/src/wedge.rs index e133d489..7528af8a 100644 --- a/crates/ec-av1/src/wedge.rs +++ b/crates/ec-av1/src/wedge.rs @@ -1,20 +1,30 @@ //! lane-wedge r3: `COMPOUND_WEDGE` mask codebook -- libaom //! `av1/common/reconinter.c`'s `init_wedge_master_masks`/`init_wedge_masks`/ -//! `get_wedge_mask_inplace`, ported for the ONLY block-size family this -//! decoder's masked-compound leaves reach: square 8x8/16x16/32x32 -//! (`decode.rs`'s `wedge_bsize` match on `side`). Every reachable square -//! bsize uses the same libaom codebook row (`wedge_codebook_16_heqw`) and -//! the same `wedge_signflip_lookup` row, so only ONE codebook/signflip -//! table is ported (rect bsizes are not reachable yet -- charter scope). +//! `get_wedge_mask_inplace`, ported for EVERY bsize libaom gives a wedge +//! codebook (`av1_wedge_params_lookup`, reconinter.c:236-267): the three +//! square sizes 8x8/16x16/32x32 (`wedge_codebook_16_heqw`) and the six +//! rectangular ones 8x16/16x32/8x32 (`wedge_codebook_16_hgtw`, h > w) and +//! 16x8/32x16/32x8 (`wedge_codebook_16_hltw`, h < w), each with its own +//! `wedge_signflip_lookup` row (reconinter.c:160-183). //! -//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_dump.c` is a -//! standalone C reimplementation of the same libaom source, compiled and -//! run independently with `gcc` (not linked against this Rust code, not -//! linked against libaom) -- it catches translation bugs (indexing, shift -//! direction/sign, offset order) that a hand-transcribed-only table would -//! not. `checksum()` below reproduces its exact per-block checksum -//! formula; `wedge_codebook_matches_c_dump` asserts every (bsize, sign, -//! index) checksum against `lanes/wedge_dump.expected.txt`. +//! lane-inter16ab r5: masks are stored PADDED to a `side x side` plane +//! (`side = max(bw, bh)`, row stride `side`), because `decode.rs` predicts +//! a rectangular strip into a square `side x side` buffer and writes only +//! its true `write_w x write_h` footprint -- so a padded mask drops +//! straight into the existing square blend call with no stride plumbing. +//! Rows/columns outside `bw x bh` are zero and never reach the frame. +//! +//! VERIFICATION (class shared-oracle-blindness): `lanes/wedge_libaom.expected.txt` +//! is generated by a C harness LINKED AGAINST libaom itself +//! (`~/.cache/inter16ab-tmp/wedge_h.c`, `av1_init_wedge_masks()` then +//! `av1_get_contiguous_soft_mask(idx, sign, bsize)`) -- a genuinely foreign +//! implementation, not a transcription. Its 96 square-size lines are +//! byte-identical to the older independent transcription +//! `lanes/wedge_dump.expected.txt` (`lanes/wedge_dump.c`), so the two +//! oracles agree where they overlap. `checksum()` below reproduces the +//! harness's per-block checksum formula (true `bw x bh` window, padded +//! stride skipped); `wedge_codebook_matches_libaom_dump` asserts all +//! 9 x 2 x 16 = 288 entries. const MASK_MASTER_SIZE: usize = 64; const WEDGE_WEIGHT_BITS: u32 = 6; @@ -47,7 +57,8 @@ const WEDGE_MASTER_VERTICAL: [u8; MASK_MASTER_SIZE] = [ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, ]; -/// `wedge_codebook_16_heqw` (reconinter.c) -- (direction, x_offset, y_offset). +/// `wedge_codebook_16_heqw` (reconinter.c:225) -- (direction, x_offset, +/// y_offset); the codebook for the square sizes (h == w). const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ (Dir::Oblique27, 4, 4), (Dir::Oblique63, 4, 4), @@ -66,8 +77,84 @@ const HEQW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ (Dir::Oblique117, 2, 4), (Dir::Oblique117, 6, 4), ]; -/// `wedge_signflip_lookup` row shared by `BLOCK_8X8`/`BLOCK_16X16`/`BLOCK_32X32`. -const SIGNFLIP: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `wedge_codebook_16_hgtw` (reconinter.c:203) -- h > w (8x16/16x32/8x32). +/// Differs from `heqw` only in entries 4..7: three HORIZONTAL splits plus a +/// single centred VERTICAL one. +const HGTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ + (Dir::Oblique27, 4, 4), + (Dir::Oblique63, 4, 4), + (Dir::Oblique117, 4, 4), + (Dir::Oblique153, 4, 4), + (Dir::Horizontal, 4, 2), + (Dir::Horizontal, 4, 4), + (Dir::Horizontal, 4, 6), + (Dir::Vertical, 4, 4), + (Dir::Oblique27, 4, 2), + (Dir::Oblique27, 4, 6), + (Dir::Oblique153, 4, 2), + (Dir::Oblique153, 4, 6), + (Dir::Oblique63, 2, 4), + (Dir::Oblique63, 6, 4), + (Dir::Oblique117, 2, 4), + (Dir::Oblique117, 6, 4), +]; +/// `wedge_codebook_16_hltw` (reconinter.c:214) -- h < w (16x8/32x16/32x8): +/// the transpose of `hgtw`'s 4..7 (three VERTICAL splits, one centred +/// HORIZONTAL). +const HLTW: [(Dir, i32, i32); MAX_WEDGE_TYPES] = [ + (Dir::Oblique27, 4, 4), + (Dir::Oblique63, 4, 4), + (Dir::Oblique117, 4, 4), + (Dir::Oblique153, 4, 4), + (Dir::Vertical, 2, 4), + (Dir::Vertical, 4, 4), + (Dir::Vertical, 6, 4), + (Dir::Horizontal, 4, 4), + (Dir::Oblique27, 4, 2), + (Dir::Oblique27, 4, 6), + (Dir::Oblique153, 4, 2), + (Dir::Oblique153, 4, 6), + (Dir::Oblique63, 2, 4), + (Dir::Oblique63, 6, 4), + (Dir::Oblique117, 2, 4), + (Dir::Oblique117, 6, 4), +]; + +/// `wedge_signflip_lookup` (reconinter.c:160-183), one row per bsize. +/// `BLOCK_8X8`/`16X16`/`32X32` share this row. +const SF_SQUARE: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_8X16`/`16X8`/`16X32`/`32X16` share this row (index 4 flips to 0). +const SF_RECT: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_8X32` (reconinter.c:173) -- index 8 also 0. +const SF_8X32: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1]; +/// `BLOCK_32X8` (reconinter.c:174) -- index 12 also 0. +const SF_32X8: [u8; MAX_WEDGE_TYPES] = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1]; + +/// `av1_wedge_params_lookup[bsize]`'s `(codebook, signflip)` pair for a +/// block footprint, `None` where `wedge_types == 0`. +fn wedge_params(bw: usize, bh: usize) -> Option<(&'static [(Dir, i32, i32); MAX_WEDGE_TYPES], &'static [u8; MAX_WEDGE_TYPES])> { + Some(match (bw, bh) { + (8, 8) | (16, 16) | (32, 32) => (&HEQW, &SF_SQUARE), + (8, 16) | (16, 32) => (&HGTW, &SF_RECT), + (16, 8) | (32, 16) => (&HLTW, &SF_RECT), + (8, 32) => (&HGTW, &SF_8X32), + (32, 8) => (&HLTW, &SF_32X8), + _ => return None, + }) +} + +/// Every `(bw, bh)` with a wedge codebook, in `av1_wedge_params_lookup` order. +pub const WEDGE_BSIZES: [(usize, usize); 9] = [ + (8, 8), + (8, 16), + (16, 8), + (16, 16), + (16, 32), + (32, 16), + (32, 32), + (8, 32), + (32, 8), +]; /// `shift_copy` (reconinter.c) -- shift a `MASK_MASTER_SIZE`-wide row right /// (`shift >= 0`) or left, replicating the edge sample into the gap. @@ -146,79 +233,86 @@ fn init_wedge_master_masks() -> MasterMasks { MasterMasks { obl } } -/// `get_wedge_mask_inplace` (reconinter.c): the `bw x bh` window of the -/// master plane for this `(wedge_index, neg, bw, bh)`, still in +/// `get_wedge_mask_inplace` (reconinter.c:270-289): the `bw x bh` window of +/// the master plane for this `(wedge_index, neg, bw, bh)`, still in /// `MASK_MASTER_SIZE`-stride coordinates (caller extracts the window). -fn wedge_window(master: &MasterMasks, wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) { - let (dir, xo, yo) = HEQW[wedge_index]; - let wsignflip = SIGNFLIP[wedge_index] as usize; +fn wedge_window(wedge_index: usize, neg: usize, bw: usize, bh: usize) -> (usize, usize, usize) { + let (codebook, signflip) = wedge_params(bw, bh).expect("wedge_window on a wedge-capable bsize"); + let (dir, xo, yo) = codebook[wedge_index]; + let wsignflip = signflip[wedge_index] as usize; let woff = (xo as usize * bw) >> 3; let hoff = (yo as usize * bh) >> 3; - let _ = &master.obl[neg ^ wsignflip][dir as usize]; let row0 = MASK_MASTER_SIZE / 2 - hoff; let col0 = MASK_MASTER_SIZE / 2 - woff; (neg ^ wsignflip, dir as usize, row0 * MASK_MASTER_SIZE + col0) } -/// Per-`(sign, wedge_index)` `bw x bh` mask, contiguous stride `bw`. +/// Per-`(sign, wedge_index)` mask for one bsize, stored PADDED into a +/// `stride x stride` plane (`stride = max(bw, bh)`) so a rectangular mask +/// indexes exactly like the square prediction buffer `decode.rs` blends +/// into. Only rows `0..bh` / columns `0..bw` are meaningful. pub struct WedgeCodebook { - /// `[sign][wedge_index] -> bw*bh` bytes, row stride `bw`. + /// `[sign][wedge_index] -> stride*stride` bytes, row stride `stride`. masks: [[Vec; MAX_WEDGE_TYPES]; 2], pub bw: usize, pub bh: usize, + /// `max(bw, bh)` -- the row stride of every mask returned by [`Self::mask`]. + pub stride: usize, } impl WedgeCodebook { fn build(master: &MasterMasks, bw: usize, bh: usize) -> Self { + let stride = bw.max(bh); let mut masks: [[Vec; MAX_WEDGE_TYPES]; 2] = Default::default(); for sign in 0..2 { for idx in 0..MAX_WEDGE_TYPES { - let (neg_idx, dir, off) = wedge_window(master, idx, sign, bw, bh); + let (neg_idx, dir, off) = wedge_window(idx, sign, bw, bh); let plane = &master.obl[neg_idx][dir]; - let mut m = vec![0u8; bw * bh]; + let mut m = vec![0u8; stride * stride]; for i in 0..bh { let src = off + i * MASK_MASTER_SIZE; - m[i * bw..i * bw + bw].copy_from_slice(&plane[src..src + bw]); + m[i * stride..i * stride + bw].copy_from_slice(&plane[src..src + bw]); } masks[sign][idx] = m; } } - WedgeCodebook { masks, bw, bh } + WedgeCodebook { masks, bw, bh, stride } } /// `wedge_sign` in `{0,1}` (spec `wedge_sign`), `wedge_index` in - /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride `bw`. + /// `0..MAX_WEDGE_TYPES`. Mask is luma-resolution, row stride + /// [`Self::stride`] (`max(bw, bh)`), length `stride * stride`. pub fn mask(&self, wedge_sign: usize, wedge_index: usize) -> &[u8] { &self.masks[wedge_sign][wedge_index] } } -/// One codebook per reachable square leaf side (8/16/32), built once. +/// One codebook per wedge-capable bsize, built once. pub struct WedgeMasks { - pub side8: WedgeCodebook, - pub side16: WedgeCodebook, - pub side32: WedgeCodebook, + /// Parallel to [`WEDGE_BSIZES`]. + books: Vec, } impl WedgeMasks { fn new() -> Self { let master = init_wedge_master_masks(); WedgeMasks { - side8: WedgeCodebook::build(&master, 8, 8), - side16: WedgeCodebook::build(&master, 16, 16), - side32: WedgeCodebook::build(&master, 32, 32), + books: WEDGE_BSIZES + .iter() + .map(|&(bw, bh)| WedgeCodebook::build(&master, bw, bh)) + .collect(), } } - /// `side` is the square leaf side (8/16/32); panics otherwise (same - /// invariant `decode.rs`'s `wedge_bsize` match already enforces). - pub fn codebook(&self, side: usize) -> &WedgeCodebook { - match side { - 8 => &self.side8, - 16 => &self.side16, - 32 => &self.side32, - _ => unreachable!("wedge codebook side is 8/16/32"), - } + /// `(bw, bh)` is the block's TRUE footprint; panics on a size libaom + /// gives no codebook (the same invariant `decode.rs`'s `wedge_used_bsize` + /// already enforces before any wedge symbol is read). + pub fn codebook(&self, bw: usize, bh: usize) -> &WedgeCodebook { + let i = WEDGE_BSIZES + .iter() + .position(|&s| s == (bw, bh)) + .unwrap_or_else(|| unreachable!("no wedge codebook for {bw}x{bh}")); + &self.books[i] } } @@ -228,13 +322,15 @@ pub fn wedge_masks() -> &'static WedgeMasks { WEDGE_MASKS.get_or_init(WedgeMasks::new) } -/// Reproduces `lanes/wedge_dump.c`'s `dump_bsize` checksum formula exactly. +/// Reproduces the libaom-linked harness's per-block checksum formula +/// (`~/.cache/inter16ab-tmp/wedge_h.c`): the TRUE `bw x bh` window read out +/// of the padded plane, weighted by its contiguous position + 1. #[cfg(test)] -fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 { +fn checksum(mask: &[u8], bw: usize, bh: usize, stride: usize) -> u64 { let mut sum: u64 = 0; for i in 0..bh { for j in 0..bw { - sum += mask[i * bw + j] as u64 * (i * bw + j + 1) as u64; + sum += mask[i * stride + j] as u64 * (i * bw + j + 1) as u64; } } sum @@ -244,44 +340,50 @@ fn checksum(mask: &[u8], bw: usize, bh: usize) -> u64 { mod tests { use super::*; - /// lane-wedge r3: checksum-verify every (bsize, sign, wedge_index) mask - /// this decoder can produce against `lanes/wedge_dump.c`'s independent - /// C computation (`lanes/wedge_dump.expected.txt`, generated by - /// `gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump`). + /// lane-inter16ab r5 (class enumerate-table-domain): checksum-verify + /// EVERY (bsize, sign, wedge_index) mask this decoder can produce -- + /// all 9 wedge-capable bsizes, both signs, all 16 indices = 288 entries + /// -- against `av1_get_contiguous_soft_mask()` read straight out of + /// libaom by the linked C harness (`lanes/wedge_libaom.expected.txt`, + /// regenerate with `gcc -O2 -o wedge_h wedge_h.c -I -I + /// /libaom.a -lm -lpthread && ./wedge_h`). #[test] - fn wedge_codebook_matches_c_dump() { - let expected_txt = std::fs::read_to_string( - concat!(env!("CARGO_MANIFEST_DIR"), "/../../lanes/wedge_dump.expected.txt"), - ) - .expect("run gcc -O2 lanes/wedge_dump.c -o lanes/wedge_dump && ./lanes/wedge_dump > lanes/wedge_dump.expected.txt first"); + fn wedge_codebook_matches_libaom_dump() { + let expected_txt = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../lanes/wedge_libaom.expected.txt" + )) + .expect("lanes/wedge_libaom.expected.txt (libaom-linked harness dump)"); let mut expected = std::collections::HashMap::new(); for line in expected_txt.lines() { - // "8x8 sign=0 idx=0 checksum=39141" + // "16x8 sign=0 idx=0 checksum=39141" let parts: Vec<&str> = line.split_whitespace().collect(); - let name = parts[0]; + let name = parts[0].to_string(); let sign: usize = parts[1]["sign=".len()..].parse().unwrap(); let idx: usize = parts[2]["idx=".len()..].parse().unwrap(); let cs: u64 = parts[3]["checksum=".len()..].parse().unwrap(); expected.insert((name, sign, idx), cs); } + assert_eq!(expected.len(), 9 * 2 * MAX_WEDGE_TYPES, "the dump covers every entry"); let masks = wedge_masks(); let mut checked = 0; - for (name, side) in [("8x8", 8usize), ("16x16", 16), ("32x32", 32)] { - let cb = masks.codebook(side); + for (bw, bh) in WEDGE_BSIZES { + let name = format!("{bw}x{bh}"); + let cb = masks.codebook(bw, bh); for sign in 0..2 { for idx in 0..MAX_WEDGE_TYPES { - let got = checksum(cb.mask(sign, idx), side, side); - let want = *expected.get(&(name, sign, idx)).unwrap_or_else(|| { + let got = checksum(cb.mask(sign, idx), bw, bh, cb.stride); + let want = *expected.get(&(name.clone(), sign, idx)).unwrap_or_else(|| { panic!("missing expected entry for {name} sign={sign} idx={idx}") }); assert_eq!( got, want, - "{name} sign={sign} idx={idx}: rust checksum {got} != C dump {want}" + "{name} sign={sign} idx={idx}: rust checksum {got} != libaom {want}" ); checked += 1; } } } - assert_eq!(checked, 3 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple"); + assert_eq!(checked, 9 * 2 * MAX_WEDGE_TYPES, "checked every (bsize,sign,index) triple"); } } diff --git a/lanes/wedge_libaom.expected.txt b/lanes/wedge_libaom.expected.txt new file mode 100644 index 00000000..5d240ea4 --- /dev/null +++ b/lanes/wedge_libaom.expected.txt @@ -0,0 +1,288 @@ +8x8 sign=0 idx=0 checksum=39141 +8x8 sign=0 idx=1 checksum=52777 +8x8 sign=0 idx=2 checksum=73817 +8x8 sign=0 idx=3 checksum=41771 +8x8 sign=0 idx=4 checksum=11976 +8x8 sign=0 idx=5 checksum=77496 +8x8 sign=0 idx=6 checksum=31072 +8x8 sign=0 idx=7 checksum=96592 +8x8 sign=0 idx=8 checksum=14128 +8x8 sign=0 idx=9 checksum=76658 +8x8 sign=0 idx=10 checksum=116594 +8x8 sign=0 idx=11 checksum=79056 +8x8 sign=0 idx=12 checksum=23207 +8x8 sign=0 idx=13 checksum=85737 +8x8 sign=0 idx=14 checksum=90729 +8x8 sign=0 idx=15 checksum=104921 +8x8 sign=1 idx=0 checksum=93979 +8x8 sign=1 idx=1 checksum=80343 +8x8 sign=1 idx=2 checksum=59303 +8x8 sign=1 idx=3 checksum=91349 +8x8 sign=1 idx=4 checksum=121144 +8x8 sign=1 idx=5 checksum=55624 +8x8 sign=1 idx=6 checksum=102048 +8x8 sign=1 idx=7 checksum=36528 +8x8 sign=1 idx=8 checksum=118992 +8x8 sign=1 idx=9 checksum=56462 +8x8 sign=1 idx=10 checksum=16526 +8x8 sign=1 idx=11 checksum=54064 +8x8 sign=1 idx=12 checksum=109913 +8x8 sign=1 idx=13 checksum=47383 +8x8 sign=1 idx=14 checksum=42391 +8x8 sign=1 idx=15 checksum=28199 +8x16 sign=0 idx=0 checksum=138816 +8x16 sign=0 idx=1 checksum=178448 +8x16 sign=0 idx=2 checksum=339952 +8x16 sign=0 idx=3 checksum=141504 +8x16 sign=0 idx=4 checksum=491264 +8x16 sign=0 idx=5 checksum=136448 +8x16 sign=0 idx=6 checksum=301312 +8x16 sign=0 idx=7 checksum=256832 +8x16 sign=0 idx=8 checksum=39477 +8x16 sign=0 idx=9 checksum=303024 +8x16 sign=0 idx=10 checksum=486248 +8x16 sign=0 idx=11 checksum=305683 +8x16 sign=0 idx=12 checksum=82066 +8x16 sign=0 idx=13 checksum=298528 +8x16 sign=0 idx=14 checksum=307134 +8x16 sign=0 idx=15 checksum=437712 +8x16 sign=1 idx=0 checksum=389568 +8x16 sign=1 idx=1 checksum=349936 +8x16 sign=1 idx=2 checksum=188432 +8x16 sign=1 idx=3 checksum=386880 +8x16 sign=1 idx=4 checksum=37120 +8x16 sign=1 idx=5 checksum=391936 +8x16 sign=1 idx=6 checksum=227072 +8x16 sign=1 idx=7 checksum=271552 +8x16 sign=1 idx=8 checksum=488907 +8x16 sign=1 idx=9 checksum=225360 +8x16 sign=1 idx=10 checksum=42136 +8x16 sign=1 idx=11 checksum=222701 +8x16 sign=1 idx=12 checksum=446318 +8x16 sign=1 idx=13 checksum=229856 +8x16 sign=1 idx=14 checksum=221250 +8x16 sign=1 idx=15 checksum=90672 +16x8 sign=0 idx=0 checksum=174226 +16x8 sign=0 idx=1 checksum=227184 +16x8 sign=0 idx=2 checksum=270192 +16x8 sign=0 idx=3 checksum=194414 +16x8 sign=0 idx=4 checksum=408160 +16x8 sign=0 idx=5 checksum=248224 +16x8 sign=0 idx=6 checksum=384416 +16x8 sign=0 idx=7 checksum=146432 +16x8 sign=0 idx=8 checksum=78414 +16x8 sign=0 idx=9 checksum=294876 +16x8 sign=0 idx=10 checksum=432572 +16x8 sign=0 idx=11 checksum=312274 +16x8 sign=0 idx=12 checksum=99695 +16x8 sign=0 idx=13 checksum=363242 +16x8 sign=0 idx=14 checksum=386145 +16x8 sign=0 idx=15 checksum=405786 +16x8 sign=1 idx=0 checksum=354158 +16x8 sign=1 idx=1 checksum=301200 +16x8 sign=1 idx=2 checksum=258192 +16x8 sign=1 idx=3 checksum=333970 +16x8 sign=1 idx=4 checksum=120224 +16x8 sign=1 idx=5 checksum=280160 +16x8 sign=1 idx=6 checksum=143968 +16x8 sign=1 idx=7 checksum=381952 +16x8 sign=1 idx=8 checksum=449970 +16x8 sign=1 idx=9 checksum=233508 +16x8 sign=1 idx=10 checksum=95812 +16x8 sign=1 idx=11 checksum=216110 +16x8 sign=1 idx=12 checksum=428689 +16x8 sign=1 idx=13 checksum=165142 +16x8 sign=1 idx=14 checksum=142239 +16x8 sign=1 idx=15 checksum=122598 +16x16 sign=0 idx=0 checksum=578432 +16x16 sign=0 idx=1 checksum=849632 +16x16 sign=0 idx=2 checksum=1197792 +16x16 sign=0 idx=3 checksum=600192 +16x16 sign=0 idx=4 checksum=146432 +16x16 sign=0 idx=5 checksum=1199104 +16x16 sign=0 idx=6 checksum=502592 +16x16 sign=0 idx=7 checksum=1555264 +16x16 sign=0 idx=8 checksum=182696 +16x16 sign=0 idx=9 checksum=1219434 +16x16 sign=0 idx=10 checksum=1901674 +16x16 sign=0 idx=11 checksum=1240408 +16x16 sign=0 idx=12 checksum=345191 +16x16 sign=0 idx=13 checksum=1381929 +16x16 sign=0 idx=14 checksum=1424569 +16x16 sign=0 idx=15 checksum=1717513 +16x16 sign=1 idx=0 checksum=1526912 +16x16 sign=1 idx=1 checksum=1255712 +16x16 sign=1 idx=2 checksum=907552 +16x16 sign=1 idx=3 checksum=1505152 +16x16 sign=1 idx=4 checksum=1958912 +16x16 sign=1 idx=5 checksum=906240 +16x16 sign=1 idx=6 checksum=1602752 +16x16 sign=1 idx=7 checksum=550080 +16x16 sign=1 idx=8 checksum=1922648 +16x16 sign=1 idx=9 checksum=885910 +16x16 sign=1 idx=10 checksum=203670 +16x16 sign=1 idx=11 checksum=864936 +16x16 sign=1 idx=12 checksum=1760153 +16x16 sign=1 idx=13 checksum=723415 +16x16 sign=1 idx=14 checksum=680775 +16x16 sign=1 idx=15 checksum=387831 +16x32 sign=0 idx=0 checksum=2155392 +16x32 sign=0 idx=1 checksum=2791568 +16x32 sign=0 idx=2 checksum=5528144 +16x32 sign=0 idx=3 checksum=2177152 +16x32 sign=0 idx=4 checksum=7863296 +16x32 sign=0 idx=5 checksum=2118656 +16x32 sign=0 idx=6 checksum=4744192 +16x32 sign=0 idx=7 checksum=4138624 +16x32 sign=0 idx=8 checksum=578432 +16x32 sign=0 idx=9 checksum=4780928 +16x32 sign=0 idx=10 checksum=7804800 +16x32 sign=0 idx=11 checksum=4802688 +16x32 sign=0 idx=12 checksum=1196718 +16x32 sign=0 idx=13 checksum=4810290 +16x32 sign=0 idx=14 checksum=4882770 +16x32 sign=0 idx=15 checksum=7135794 +16x32 sign=1 idx=0 checksum=6249600 +16x32 sign=1 idx=1 checksum=5613424 +16x32 sign=1 idx=2 checksum=2876848 +16x32 sign=1 idx=3 checksum=6227840 +16x32 sign=1 idx=4 checksum=541696 +16x32 sign=1 idx=5 checksum=6286336 +16x32 sign=1 idx=6 checksum=3660800 +16x32 sign=1 idx=7 checksum=4266368 +16x32 sign=1 idx=8 checksum=7826560 +16x32 sign=1 idx=9 checksum=3624064 +16x32 sign=1 idx=10 checksum=600192 +16x32 sign=1 idx=11 checksum=3602304 +16x32 sign=1 idx=12 checksum=7208274 +16x32 sign=1 idx=13 checksum=3594702 +16x32 sign=1 idx=14 checksum=3522222 +16x32 sign=1 idx=15 checksum=1269198 +32x16 sign=0 idx=0 checksum=2752498 +32x16 sign=0 idx=1 checksum=3727072 +32x16 sign=0 idx=2 checksum=4423392 +32x16 sign=0 idx=3 checksum=2923534 +32x16 sign=0 idx=4 checksum=6401216 +32x16 sign=0 idx=5 checksum=4072256 +32x16 sign=0 idx=6 checksum=6206272 +32x16 sign=0 idx=7 checksum=2158592 +32x16 sign=0 idx=8 checksum=1163358 +32x16 sign=0 idx=9 checksum=4776930 +32x16 sign=0 idx=10 checksum=7096290 +32x16 sign=0 idx=11 checksum=4922274 +32x16 sign=0 idx=12 checksum=1658592 +32x16 sign=0 idx=13 checksum=5861088 +32x16 sign=0 idx=14 checksum=6050080 +32x16 sign=0 idx=15 checksum=6557408 +32x16 sign=1 idx=0 checksum=5652494 +32x16 sign=1 idx=1 checksum=4677920 +32x16 sign=1 idx=2 checksum=3981600 +32x16 sign=1 idx=3 checksum=5481458 +32x16 sign=1 idx=4 checksum=2003776 +32x16 sign=1 idx=5 checksum=4332736 +32x16 sign=1 idx=6 checksum=2198720 +32x16 sign=1 idx=7 checksum=6246400 +32x16 sign=1 idx=8 checksum=7241634 +32x16 sign=1 idx=9 checksum=3628062 +32x16 sign=1 idx=10 checksum=1308702 +32x16 sign=1 idx=11 checksum=3482718 +32x16 sign=1 idx=12 checksum=6746400 +32x16 sign=1 idx=13 checksum=2543904 +32x16 sign=1 idx=14 checksum=2354912 +32x16 sign=1 idx=15 checksum=1847584 +32x32 sign=0 idx=0 checksum=9085696 +32x32 sign=0 idx=1 checksum=13761984 +32x32 sign=0 idx=2 checksum=19348928 +32x32 sign=0 idx=3 checksum=9260288 +32x32 sign=0 idx=4 checksum=2158592 +32x32 sign=0 idx=5 checksum=18952192 +32x32 sign=0 idx=6 checksum=8201856 +32x32 sign=0 idx=7 checksum=24995456 +32x32 sign=0 idx=8 checksum=2785176 +32x32 sign=0 idx=9 checksum=19515226 +32x32 sign=0 idx=10 checksum=30629210 +32x32 sign=0 idx=11 checksum=19688040 +32x32 sign=0 idx=12 checksum=5489895 +32x32 sign=0 idx=13 checksum=22219945 +32x32 sign=0 idx=14 checksum=22567257 +32x32 sign=0 idx=15 checksum=27749993 +32x32 sign=1 idx=0 checksum=24501504 +32x32 sign=1 idx=1 checksum=19825216 +32x32 sign=1 idx=2 checksum=14238272 +32x32 sign=1 idx=3 checksum=24326912 +32x32 sign=1 idx=4 checksum=31428608 +32x32 sign=1 idx=5 checksum=14635008 +32x32 sign=1 idx=6 checksum=25385344 +32x32 sign=1 idx=7 checksum=8591744 +32x32 sign=1 idx=8 checksum=30802024 +32x32 sign=1 idx=9 checksum=14071974 +32x32 sign=1 idx=10 checksum=2957990 +32x32 sign=1 idx=11 checksum=13899160 +32x32 sign=1 idx=12 checksum=28097305 +32x32 sign=1 idx=13 checksum=11367255 +32x32 sign=1 idx=14 checksum=11019943 +32x32 sign=1 idx=15 checksum=5837207 +8x32 sign=0 idx=0 checksum=534080 +8x32 sign=0 idx=1 checksum=582912 +8x32 sign=0 idx=2 checksum=1511680 +8x32 sign=0 idx=3 checksum=536768 +8x32 sign=0 idx=4 checksum=1968896 +8x32 sign=0 idx=5 checksum=531712 +8x32 sign=0 idx=6 checksum=1189120 +8x32 sign=0 idx=7 checksum=1037952 +8x32 sign=0 idx=8 checksum=1966528 +8x32 sign=0 idx=9 checksum=1191488 +8x32 sign=0 idx=10 checksum=1963840 +8x32 sign=0 idx=11 checksum=1194176 +8x32 sign=0 idx=12 checksum=352487 +8x32 sign=0 idx=13 checksum=877538 +8x32 sign=0 idx=14 checksum=888257 +8x32 sign=0 idx=15 checksum=1742138 +8x32 sign=1 idx=0 checksum=1571264 +8x32 sign=1 idx=1 checksum=1522432 +8x32 sign=1 idx=2 checksum=593664 +8x32 sign=1 idx=3 checksum=1568576 +8x32 sign=1 idx=4 checksum=136448 +8x32 sign=1 idx=5 checksum=1573632 +8x32 sign=1 idx=6 checksum=916224 +8x32 sign=1 idx=7 checksum=1067392 +8x32 sign=1 idx=8 checksum=138816 +8x32 sign=1 idx=9 checksum=913856 +8x32 sign=1 idx=10 checksum=141504 +8x32 sign=1 idx=11 checksum=911168 +8x32 sign=1 idx=12 checksum=1752857 +8x32 sign=1 idx=13 checksum=1227806 +8x32 sign=1 idx=14 checksum=1217087 +8x32 sign=1 idx=15 checksum=363206 +32x8 sign=0 idx=0 checksum=822592 +32x8 sign=0 idx=1 checksum=945008 +32x8 sign=0 idx=2 checksum=1031024 +32x8 sign=0 idx=3 checksum=938688 +32x8 sign=0 idx=4 checksum=1627744 +32x8 sign=0 idx=5 checksum=987552 +32x8 sign=0 idx=6 checksum=1530272 +32x8 sign=0 idx=7 checksum=581632 +32x8 sign=0 idx=8 checksum=564605 +32x8 sign=0 idx=9 checksum=1089656 +32x8 sign=0 idx=10 checksum=1432664 +32x8 sign=0 idx=11 checksum=1197731 +32x8 sign=0 idx=12 checksum=1670288 +32x8 sign=0 idx=13 checksum=1487728 +32x8 sign=0 idx=14 checksum=1584272 +32x8 sign=0 idx=15 checksum=1573744 +32x8 sign=1 idx=0 checksum=1282752 +32x8 sign=1 idx=1 checksum=1160336 +32x8 sign=1 idx=2 checksum=1074320 +32x8 sign=1 idx=3 checksum=1166656 +32x8 sign=1 idx=4 checksum=477600 +32x8 sign=1 idx=5 checksum=1117792 +32x8 sign=1 idx=6 checksum=575072 +32x8 sign=1 idx=7 checksum=1523712 +32x8 sign=1 idx=8 checksum=1540739 +32x8 sign=1 idx=9 checksum=1015688 +32x8 sign=1 idx=10 checksum=672680 +32x8 sign=1 idx=11 checksum=907613 +32x8 sign=1 idx=12 checksum=435056 +32x8 sign=1 idx=13 checksum=617616 +32x8 sign=1 idx=14 checksum=521072 +32x8 sign=1 idx=15 checksum=531600