forge
Explore
Log in

Don't you dare go Hollow

Lane-av1444edge -- the two 4:4:4 lossy cells the chroma-format sweep left unassigned

Browse files at this commit

5aa9f3df2e466e7b2ada33d47f9f334bd2eab59fAhmet Kaan GümüşParent: 84fa44c
  • test
    • lane-av1444edge -- the two 4:4:4 lossy cells the chroma-format sweep left unassigned
Show full message
test(av1): lane-av1444edge -- the two 4:4:4 lossy cells the chroma-format sweep left unassigned

`lanes/av1formatsweep.report.md` §6.2 closed the "not measured" list and
handed over two cells verbatim: "4:4:4 superres 8-bit" (DIVERGENT from
frame 2, first wrong Y(192,0)) and "4:4:4 odd coded dims 130x122"
(DIVERGENT from frame 3, first wrong Y(128,16)), with the note that
"neither reduces to a known class on the evidence here, and neither has a
discriminator run". This is that run.

They are ONE class, and it is lane-av1444rect's H1 (f92776ba, cherry-
picked here): a 1:4 (HORZ_4 / VERT_4) inter strip's chroma coefficient
context gathered at the 4:2:0 PAIR extent at ss (0,0), where
`is_chroma_reference` (av1_common_int.h:1454) reduces both parity clauses
to `!subsampling_y` / `!subsampling_x`, so every block is its own chroma
reference and no pair exists. What the two new geometries add is reach:
the existing H1 gate is 128x96, so neither a partial-frame right edge nor
a 256x128 frame with CDEF and loop restoration both live was covered, and
the sweep's own odd-dimension gate is 4:2:0 only.

Localizing, because the discriminator is the part worth keeping:

* The pre-loop-filter RECONSTRUCTION already carries the identical first
  wrong sample as the final output on both cells (130x122 frame 3 at
  Y(128,16); 256x128 frame 2 at Y(192,0)), so no filter is involved and
  the stage ladder is not where this lives. That rung did not exist on
  the inter path -- fixed in the previous commit.
* Order the wrong superblocks by DECODE order and the first one in 256x128
  frame 2 is SBcol2/SBrow0, first wrong pixel (128,48) = mi(12,32), whose
  mode, ref0 and mv0 are IDENTICAL on both sides. The arithmetic fork
  lands on the very next block, mi(13,32), where the oracle reads
  ref0 = LAST (1) and we read GOLDEN (4). A pixel error cannot cause a
  mode fork, so one bsize/footprint error has to feed both: it is upstream
  of the pixels, not a consequence of them.
* `EC_MODE`'s print carries no bsize, so the mode ladder cannot see a
  partition fork at all. What localizes is the per-superblock decode-order
  pixel map of the pre-filter dump, plus the observation that the
  divergence count is identical with and without 4e151813 (that commit
  patches only `decode_rect4_16_strip`'s two `tu_reach` call sites, and
  both sit inside its `if lossless_pair {` arm -- the lossy path is the
  `} else if skip {` further down, so the class is lossless-only and these
  two lossy cells are not it).

Fixtures (the sweep's recipes, byte-reproduced; the truncated sha256
prefixes it recorded, `c87ac65b...` and `06621606...`, both match):

  444_lossy_rect4_odd_130x122.obu    8945 B  sha256 c87ac65b77579afd2938669b0cbe3ec44c3abf775c0223cacb9d14b8c2eee27c
  444_lossy_rect4_wide_256x128.obu  15239 B  sha256 06621606c11ae805f784a1c9736db6301a925a4fa3154e2fc38db1df7ad9b826

Gate `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries`
asserts per arm: the pinned bytes (length + FNV-1a), a non-zero DELTA of
1:4 inter strips (these counters are process-wide with no reset, so an
absolute count would pass on residue from another stream), a non-zero
`rect4_inter_own_chroma444_hits()` so the corrected route demonstrably
ran, the 4:4:4 full-resolution chroma shape, and every decode-order frame
byte-exact through `decode_all_frames_vs_oracle`.

Measured green: 4/4 decode-order frames per arm, 12 and 24 own-extent
1:4 chroma gathers, 28 and 76 1:4 inter strips. Red before, by mutation on
this gate's own arms with the counter left firing (the ss_x-0 own-extent
arm pointed back at the 4:2:0 `(16, 8)` pair extent): decode-order frame
3 of 130x122 differs at byte 4260 (ours 0 vs oracle 38), 9203 bytes.

Identity: the whole 4:4:4 family (4 gates, both H1 gates among them), the
lossless 4:4:4 family, the superres family (8 gates) and the rect-strip
family (5 gates) all green on this decode.rs. One pre-existing SKIP, not
mine: `a_real_aomenc_lossless_444_key_frame_decodes_sample_exact` has no
pinned `fixtures/ll444-lossless-key.obu` in the tree and never has.

Matrix correction for the sweep, in the report: the "4:4:4 superres"
cell is not a superres cell. `--superres-mode=1` without
`--superres-denominator` leaves the denominator to the encoder's energy
heuristic, which chose 8 on that source, so all four frame headers carry
`use_superres=false` and nothing was ever scaled. With an explicit
denominator the cell is real (256x128, denom 12, coded 171x128) and
byte-exact 4/4 here.
crates/ec-av1/fixtures/444_lossy_rect4_odd_130x122.obuadded+0 -0

Binary file changed

crates/ec-av1/fixtures/444_lossy_rect4_wide_256x128.obuadded+0 -0

Binary file changed

crates/ec-av1/src/stream.rsmodified+142 -0
@@ -7108,6 +7108,148 @@ pub(crate) mod tests {
7108 eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers");7108 eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers");
7109 }7109 }
7110 7110
7111+ /// lane-av1444edge: the two 4:4:4 lossy cells the chroma-format sweep
7112+ /// (§6.2) left as "unassigned, neither reduces to a known class". They
7113+ /// are one class, and it is the sibling gate's: a 1:4 (HORZ_4 / VERT_4)
7114+ /// inter strip's chroma coefficient context gathered at the 4:2:0 PAIR
7115+ /// extent at ss (0,0), where `is_chroma_reference`
7116+ /// (av1_common_int.h:1454) makes every block its own chroma reference so
7117+ /// no pair exists. What these two add is the geometry and the depth the
7118+ /// sibling's 128x96 gate does not reach.
7119+ ///
7120+ /// **Arm A -- partial-frame right edge, 130x122.** Neither dimension is a
7121+ /// multiple of 8 (the sweep's own odd-dimension gate covers 4:2:0 only, so
7122+ /// the 4:4:4 partial-column walk had no exactness evidence), and 66x66 is
7123+ /// EXACT at the same settings, so the walk is right at one odd geometry
7124+ /// and wrong at another. Arm B -- 256x128, 4 frames, with CDEF and loop
7125+ /// restoration both live on the last two frames.
7126+ ///
7127+ /// **The recipes** (the sweep's, byte-reproduced -- the truncated sha256
7128+ /// prefixes it recorded, `c87ac65b…` and `06621606…`, match):
7129+ /// ```text
7130+ /// ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \
7131+ /// -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \
7132+ /// aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \
7133+ /// --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \
7134+ /// --limit=4 --obu -o - -
7135+ /// ```
7136+ /// (`rate=25` is load-bearing for the same reason as the sibling gate:
7137+ /// `testsrc2`'s pattern is time-parameterised.)
7138+ ///
7139+ /// Red before the fix, both arms: arm A frame 3, 11521 samples, first at
7140+ /// Y(128,16) (ours 134, oracle 170); arm B frame 2, 25296 samples, first
7141+ /// at Y(192,0) (ours 92, oracle 106), frame 3 51108 more. The
7142+ /// pre-loop-filter reconstruction already carries the identical first
7143+ /// wrong sample on both, so no filter is involved; in arm B the first
7144+ /// wrong superblock in DECODE order is SBcol2/SBrow0 (first wrong pixel
7145+ /// (128,48) = mi(12,32), whose mode/ref/mv are identical on both sides),
7146+ /// and the arithmetic fork lands on the very next block, mi(13,32), where
7147+ /// the oracle reads ref0 = LAST and we read GOLDEN.
7148+ ///
7149+ /// Non-vacuity, three ways per arm: the pinned bytes (length + FNV-1a);
7150+ /// the decoded chroma planes are full resolution, which is the ss (0,0)
7151+ /// shape claim; and `decode::rect4_inter_own_chroma444_hits()` must be
7152+ /// non-zero AND `inter16_rect4_counters()` must report 1:4 inter strips,
7153+ /// so the corrected route is known to have run rather than the gate
7154+ /// passing on a stream that never reached it.
7155+ #[test]
7156+ fn a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries() {
7157+ const NAME: &str =
7158+ "a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries";
7159+ // (fixture, len, fnv1a64, width, height, strips HORZ_4 + VERT_4)
7160+ const ARMS: [(&str, usize, u64, usize, usize, usize); 2] = [
7161+ (
7162+ "fixtures/444_lossy_rect4_odd_130x122.obu",
7163+ 8945,
7164+ 0x5125_0554_751c_bf12,
7165+ 130,
7166+ 122,
7167+ 28, // measured 8 HORZ_4 + 20 VERT_4
7168+ ),
7169+ (
7170+ "fixtures/444_lossy_rect4_wide_256x128.obu",
7171+ 15239,
7172+ 0xf94a_0218_bb34_4f9e,
7173+ 256,
7174+ 128,
7175+ 76, // measured 60 HORZ_4 + 16 VERT_4
7176+ ),
7177+ ];
7178+ let _guard = lock_gate_counters();
7179+ for (fixture, len, fnv, w, h, min_strips) in ARMS {
7180+ let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture);
7181+ let stream = std::fs::read(&obu).unwrap_or_else(|e| {
7182+ panic!(
7183+ "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot \
7184+ run, which is a failure, not a skip",
7185+ obu.display()
7186+ )
7187+ });
7188+ assert_eq!(stream.len(), len, "{NAME}: {fixture} length moved");
7189+ assert_eq!(fnv1a64(&stream), fnv, "{NAME}: {fixture} bytes moved");
7190+
7191+ // The 1:4-strip counters are process-wide with no reset, so read
7192+ // them as a DELTA: a full-suite run has already put 1:4 strips
7193+ // through the decoder by the time this test starts, and an
7194+ // absolute count would be a non-vacuity assertion that passes on
7195+ // residue from another stream.
7196+ let before_strips = {
7197+ let (h, v, _, _) = crate::decode::inter16_rect4_counters();
7198+ h + v
7199+ };
7200+ crate::decode::reset_rect4_inter_own_chroma444_hits();
7201+ let frames = decode_stream(&stream).unwrap_or_else(|e| {
7202+ panic!("{NAME}: {fixture} no longer decodes cleanly: {e}")
7203+ });
7204+ let own_chroma = crate::decode::rect4_inter_own_chroma444_hits();
7205+ let strips = {
7206+ let (h, v, _, _) = crate::decode::inter16_rect4_counters();
7207+ h + v - before_strips
7208+ };
7209+ assert!(
7210+ strips >= min_strips,
7211+ "{NAME}: {fixture} coded only {strips} 1:4 inter strips \
7212+ (HORZ_4 + VERT_4), expected about {min_strips} -- the stream \
7213+ moved, and the route this gate witnesses may no longer be on it"
7214+ );
7215+ assert!(
7216+ own_chroma > 0,
7217+ "{NAME}: {fixture} ran no 1:4 inter strip over its own chroma \
7218+ extent -- the corrected route never ran (class \
7219+ gate-blind-to-feature)"
7220+ );
7221+ assert_eq!(frames.len(), 4, "{NAME}: {fixture} frame count");
7222+ for (i, f) in frames.iter().enumerate() {
7223+ assert_eq!(
7224+ (f.width, f.height),
7225+ (w, h),
7226+ "{NAME}: {fixture} frame {i} dimensions"
7227+ );
7228+ // At 4:4:4 the chroma planes are full resolution; a decoder
7229+ // that kept the 4:2:0 extent would hand quarter-size chroma
7230+ // planes to the byte compare, which cannot pass. Say it here
7231+ // rather than let the compare stand in for the shape claim.
7232+ assert_eq!(
7233+ f.u.len(),
7234+ w * h,
7235+ "{NAME}: {fixture} frame {i} chroma plane is {} samples; at \
7236+ 4:4:4 it must be full resolution ({w}x{h})",
7237+ f.u.len()
7238+ );
7239+ }
7240+ if aomdec_path().is_file() {
7241+ let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME);
7242+ eprintln!(
7243+ "{NAME}: {fixture} {decoded} decode-order frame(s) \
7244+ ({hidden} hidden) byte-exact vs aomdec, {own_chroma} own-extent \
7245+ 1:4 chroma gather(s), {strips} 1:4 inter strip(s)"
7246+ );
7247+ } else {
7248+ eprintln!("{NAME}: {fixture}: no oracle aomdec, pixel arm skipped");
7249+ }
7250+ }
7251+ }
7252+
7111 /// lane-av1lrflush: the pipelined loop-restoration band release flushes7253 /// lane-av1lrflush: the pipelined loop-restoration band release flushes
7112 /// RU row 0 on the inter frame whose top superblock row carries a7254 /// RU row 0 on the inter frame whose top superblock row carries a
7113 /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as7255 /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as