forge
Explore
Log in

Don't you dare go Hollow

Pin the first stream that codes a 128-root HORZ/VERT half INTRA inside an inter frame

Browse files at this commit

afb49c493e99b6ca3b19853fff43df9fb7259153Ahmet Kaan GümüşParent: f5d348d
  • test
    • pin the first stream that codes a 128-root HORZ/VERT half INTRA inside an inter frame
Show full message
test(av1): pin the first stream that codes a 128-root HORZ/VERT half INTRA inside an inter frame

Adds crates/ec-av1/fixtures/intra128_in_inter_witness.obu (13066 B, 10-bit
512x512, 10 frames) -- 128-wide horizontal bands in the left two superblock
columns and 64-wide vertical bands in the right two, with two hard scene cuts
and --kf-max-dist=9999, so the cuts must be coded as inter frames whose
content no reference holds. It is the first recipe found that fires the
intra128_in_inter arm at all: 1x 128x64 + 2x 64x128.

The EC_INTRA128_IN_INTER opt-in is NOT lifted. All three hits land in a frame
this decoder does not decode exactly, and a counter read out of a desynced
frame proves nothing. The blocker is measured and separate from this arm: the
same source with every optional tool disabled fires the arm 0 times and
desyncs on exactly the same frames, and the same source at --sb-size=64
decodes all 10 frames byte-exact. First bad, from the coefficient ladder
against instrumented aomdec: decode-order frame 1, the 128x128 is_inter=1
skip=0 block at mi(32,64), its first luma TU (TX_64X64, bc=0 br=0) -- aomdec
reads txb_skip ctx 1 (top == 0 && left == 0) and gets all_zero=1, we read
ctx 2 and get all_zero=0, with the entry range equal on both. So the defect is
in the luma entropy levels the preceding 128x128 inter block publishes into
above/left, not in the intra arm.

The gate is #[ignore]d with those coordinates in its doc comment; decode.rs
gains an EC_INTRA128 trace line (under the existing coefficient-trace switch)
that prints the arm's mi position, which is what proved the hits sit in a
desynced frame.
crates/ec-av1/fixtures/intra128_in_inter_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+7 -0
@@ -7731,6 +7731,13 @@ fn decode_intra_rect_in_inter(
7731 is consumed for square blocks only)",7731 is consumed for square blocks only)",
7732 ));7732 ));
7733 }7733 }
7734+ if coeff_trace_on() {
7735+ // lane-t900 r16: which decode-order frame this arm fires in --
7736+ // interleaved with the `EC_COEFF_FRAME` markers, this is what
7737+ // proves the hit is counted out of a frame that compares exact
7738+ // (class `counter-from-refused-stream`).
7739+ eprintln!("EC_INTRA128 mi_row={r} mi_col={c} bw={bw} bh={bh}");
7740+ }
7734 INTRA_IN_INTER_MODE.with(|c| c.set(Some((3, skip))));7741 INTRA_IN_INTER_MODE.with(|c| c.set(Some((3, skip))));
7735 let res = decode_block_128rect(7742 let res = decode_block_128rect(
7736 dec,7743 dec,
crates/ec-av1/src/stream.rsmodified+111 -0
@@ -30637,6 +30637,117 @@ mod tests {
30637 );30637 );
30638 }30638 }
30639 30639
30640+ /// lane-t900 r16: the intra-coded 128x64 / 64x128 INTER-frame witness --
30641+ /// IGNORED, and it is the `EC_INTRA128_IN_INTER` opt-in's blocker, not its
30642+ /// lift. Run it with
30643+ /// `EC_INTRA128_IN_INTER=1 cargo test -p ec-av1 intra_coded_128x64 -- --ignored`.
30644+ ///
30645+ /// `crates/ec-av1/fixtures/intra128_in_inter_witness.obu`, 13066 bytes,
30646+ /// sha256 `dd41fc39367a3d38bf8a8a8106dc30d91b716b2a9123fdfa4716930f4f98caf9`,
30647+ /// produced by this repository's aomenc oracle:
30648+ ///
30649+ /// ```text
30650+ /// aomenc --codec=av1 -w 512 -h 512 --input-bit-depth=10 --bit-depth=10 \
30651+ /// --sb-size=128 --min-partition-size=64 --max-partition-size=128 \
30652+ /// --enable-rect-partitions=1 --kf-max-dist=9999 --lag-in-frames=0 \
30653+ /// --cpu-used=1 --end-usage=q --cq-level=24 --threads=1 --obu -o s.obu src.y4m
30654+ /// ```
30655+ ///
30656+ /// The source is 10 frames of 10-bit 512x512 whose left two superblock
30657+ /// columns carry 128-wide bands 64 rows apart (so the 128 root's cheapest
30658+ /// split is `PARTITION_HORZ`) and whose right two carry 64-wide vertical
30659+ /// bands (`PARTITION_VERT`), with two hard scene cuts at frames 4 and 7 and
30660+ /// `--kf-max-dist=9999` so those cuts must be coded as INTER frames whose
30661+ /// content no reference holds. It is the first stream found in this
30662+ /// repository that makes the encoder code a 128-root HORZ/VERT half INTRA
30663+ /// inside an inter frame at all: `intra128_in_inter` fires 1x 128x64 +
30664+ /// 2x 64x128. Three recipes that do NOT fire it, so the shape matters: a
30665+ /// small new patch on a static background (the frame costs 80 bytes, the
30666+ /// encoder skips), unstructured texture (the 128 root always SPLITs), and
30667+ /// cyclically repeating phases (GOLDEN holds an earlier phase, so the cut
30668+ /// is predicted rather than coded intra).
30669+ ///
30670+ /// It does NOT yet lift the opt-in, because the three hits land in a frame
30671+ /// this decoder does not decode exactly, and a counter read out of a
30672+ /// desynced frame proves nothing (class `counter-from-refused-stream`).
30673+ /// The blocking defect is measured, separate, and NOT this arm -- the same
30674+ /// source re-encoded with `--enable-intrabc=0 --enable-palette=0
30675+ /// --enable-obmc=0 --enable-warped-motion=0 --enable-global-motion=0
30676+ /// --enable-interintra-comp=0 --enable-masked-comp=0
30677+ /// --enable-filter-intra=0 --enable-ab-partitions=0
30678+ /// --enable-1to4-partitions=0` fires the arm 0 times and desyncs on
30679+ /// exactly the same frames, and the same source at `--sb-size=64` decodes
30680+ /// all 10 frames byte-exact. First-bad, measured against ffmpeg and
30681+ /// against this repository's instrumented aomdec:
30682+ ///
30683+ /// * pixels: decode-order frame 1, luma (row 122, col 354), 160285
30684+ /// differing samples (Y 146713 / U 5936 / V 7636), max |delta| 738.
30685+ /// Frames 0, 4 and 7 -- the key frame and the two all-intra scene cuts --
30686+ /// are byte-exact on every plane; every other frame is not.
30687+ /// * entropy (`EC_TRACE_COEFF` on both decoders, prefiltered to the
30688+ /// `all_zero`/`eob`/`after_bases` tags): frame 1, the 128x128
30689+ /// `is_inter=1 skip=0` block at mi(32,64) (pixel 128,256), its FIRST
30690+ /// luma TU (`bc=0 br=0`, a TX_64X64 unit, `coding.side=32`). aomdec
30691+ /// reads `txb_skip` ctx 1 (`top == 0 && left == 0`) and gets
30692+ /// `all_zero=1`; we read ctx 2 and get `all_zero=0`. Entry range is
30693+ /// equal on both, so this is the txb_skip CONTEXT -- i.e. the luma
30694+ /// entropy levels the PRECEDING 128x128 inter block published into
30695+ /// `above`/`left` -- and not the symbol's own alphabet.
30696+ /// * `EC_TRACE_MODE` confirms the same point from the other side: the
30697+ /// first differing `EC_MODE` range is at the ENTRY of mi(32,96), i.e.
30698+ /// inside mi(32,64); every 128-root block before it matches exactly.
30699+ ///
30700+ /// The arm's own three hits are at mi(8,24) 128x64 and mi(16,16) /
30701+ /// mi(16,20) 64x128 (`EC_INTRA128` trace, decode.rs).
30702+ #[ignore = "lane-t900 r16: needs EC_INTRA128_IN_INTER=1, and the stream carries a separate 128x128-inter txb_skip-context desync at frame 1 mi(32,64)"]
30703+ #[test]
30704+ fn an_intra_coded_128x64_block_inside_an_inter_frame_decodes_pixel_exact() {
30705+ const NAME: &str = "an_intra_coded_128x64_block_inside_an_inter_frame_decodes_pixel_exact";
30706+ if !have_ffmpeg() {
30707+ eprintln!("SKIP {NAME}: no ffmpeg");
30708+ return;
30709+ }
30710+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
30711+ .join("fixtures/intra128_in_inter_witness.obu");
30712+ let stream = std::fs::read(&path)
30713+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
30714+ let (width, height) = (512usize, 512usize);
30715+ let before = intra128_in_inter_counters();
30716+ let frames = match decode_stream(&stream) {
30717+ Ok(frames) => frames,
30718+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
30719+ };
30720+ let now = intra128_in_inter_counters();
30721+ let fired = [now[0] - before[0], now[1] - before[1]];
30722+ for (what, n) in [("128x64", fired[0]), ("64x128", fired[1])] {
30723+ assert!(
30724+ n > 0,
30725+ "{NAME}: an intra {what} block on the inter path never fired -- \
30726+ the gate would be vacuous for it"
30727+ );
30728+ }
30729+ assert_eq!(frames.len(), 10, "{NAME}: 10 shown frames");
30730+ assert_eq!((frames[0].width, frames[0].height), (width, height));
30731+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len());
30732+ assert_eq!(
30733+ ffmpeg_frames.len(),
30734+ frames.len(),
30735+ "{NAME}: ffmpeg returned {} frames, we decoded {}",
30736+ ffmpeg_frames.len(),
30737+ frames.len()
30738+ );
30739+ for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
30740+ assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
30741+ assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
30742+ assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
30743+ }
30744+ eprintln!(
30745+ "{NAME}: 10 shown frames pixel-exact on every plane; \
30746+ intra128_in_inter 128x64={} 64x128={}",
30747+ fired[0], fired[1]
30748+ );
30749+ }
30750+
30640 /// lane-t900 r10: the small-side GLOBALMV / rect warp-reach witness.30751 /// lane-t900 r10: the small-side GLOBALMV / rect warp-reach witness.
30641 /// `crates/ec-av1/fixtures/gm_small_side_witness.obu`, 1158066 bytes,30752 /// `crates/ec-av1/fixtures/gm_small_side_witness.obu`, 1158066 bytes,
30642 /// sha256 `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca`:30753 /// sha256 `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca`: