forge
Explore
Log in

Don't you dare go Hollow

Pin the 10-bit 1920x792 128-superblock inter witness and lift the intra 16x4/4x16-in-inter opt-in

Browse files at this commit

27cd69814e888baea4062c3f1b2cb600929467deAhmet Kaan GümüşParent: 798ed37
  • test
    • pin the 10-bit 1920x792 128-superblock inter witness and lift the intra 16x4/4x16-in-inter opt-in
Show full message
test(av1): pin the 10-bit 1920x792 128-superblock inter witness and lift the intra 16x4/4x16-in-inter opt-in

`fixtures/reelc_sb128_inter_witness.obu` (166303 bytes, sha256
1191ce80e2c6c5855eaf7a8f5e8cda2cdf809f467b0dbc5e26df96dfa6b2c8bd) is the first
19 frame-carrying OBUs of a 2 s cut of a 10-bit 1920x792 AV1 stream with
`use_128x128_superblock=1`: 14 decode-order frames, 12 shown. Cut twice
independently from the source; both cuts hash identically.

All 14 decode-order frames are byte-exact against instrumented aomdec
(`EC_AV1_FINAL_DUMP`) and all 12 shown frames pixel-exact on every plane against
ffmpeg. It is the first stream here that decodes exactly while the paths of the
five defects this lane found in r2-r5 all fire, so the gate
`a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact`
hard-asserts every one: warp_plane_suppress=15, cdef_idx=763,
inter_sb128_vert=68, interintra_rect=118, non_chroma_ref_ctx_skip=163,
intra_in_inter_txctx=1946, edge_filter_mi_fix=195. Three of those counters are
new (the r2 in-inter tx-depth context, the r3 non-chroma-reference context skip
and the r4 mi-exact intra-edge-filter neighbour pair shipped with none).

REFUSAL LIFTED: the `EC_INTRA16X4_DECODE` opt-in over an intra 16x4/4x16 strip
in an inter 1:4 partition is gone. lane-wit16x4 r1 re-widened that refusal
because r3's witness counters were phantoms of a desync
(`counter-from-refused-stream`); here the arm fires 78x 16x4 + 149x 4x16 (108
chroma-paired) inside frames that are decoded AND compared exact. The named
refusal itself stays for a strip with no chroma-pair record. The
128x64/64x128 intra-in-inter arm fires 0 times on this stream, so its opt-in is
untouched.
crates/ec-av1/fixtures/reelc_sb128_inter_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+46 -3
@@ -294,6 +294,32 @@ pub(crate) fn cdef_idx_hits() -> usize {
294 CDEF_IDX_HITS.with(|c| c.get())294 CDEF_IDX_HITS.with(|c| c.get())
295 }295 }
296 296
297+// lane-t900 r6: gate proof for the three r2-r4 root causes that shipped with no
298+// counter -- the in-inter tx-depth context (`tx_size_context_txfm_rect`), the
299+// non-chroma-reference block that must LEAVE its neighbours' chroma coefficient
300+// contexts alone, and the intra-edge filter neighbour pair taken mi-exact
301+// instead of from the coarse 16x16 cell.
302+thread_local! {
303+ static INTRA_IN_INTER_TXCTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
304+ static NON_CHROMA_REF_CTX_SKIP_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
305+ static EDGE_FILTER_MI_FIX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
306+}
307+
308+/// Current value of [`INTRA_IN_INTER_TXCTX_HITS`].
309+pub(crate) fn intra_in_inter_txctx_hits() -> usize {
310+ INTRA_IN_INTER_TXCTX_HITS.with(|c| c.get())
311+}
312+
313+/// Current value of [`NON_CHROMA_REF_CTX_SKIP_HITS`].
314+pub(crate) fn non_chroma_ref_ctx_skip_hits() -> usize {
315+ NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.get())
316+}
317+
318+/// Current value of [`EDGE_FILTER_MI_FIX_HITS`].
319+pub(crate) fn edge_filter_mi_fix_hits() -> usize {
320+ EDGE_FILTER_MI_FIX_HITS.with(|c| c.get())
321+}
322+
297 // lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its323 // lane-realworld r4: this frame's `delta.q_present` (spec 5.9.17) and its
298 // actual step (`1 << delta.q_res`, already the real multiplier, not the raw324 // actual step (`1 << delta.q_res`, already the real multiplier, not the raw
299 // 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a325 // 2-bit field). `false`/`1` (the defaults) make [`maybe_read_delta_q`] a
@@ -7698,8 +7724,11 @@ fn decode_intra_rect_in_inter(
7698 // (`mi[-mi_stride]` / `mi[-1]`) -- take the mi-exact pair over the coarse7724 // (`mi[-mi_stride]` / `mi[-1]`) -- take the mi-exact pair over the coarse
7699 // one exactly as [`decode_leaf8`] already does (class7725 // one exactly as [`decode_leaf8`] already does (class
7700 // context-read-from-one-cell).7726 // context-read-from-one-cell).
7701- let (nb_above_mode, nb_left_mode) =7727+ let coarse_pair = neighbours.modes_above_left(r, c);
7702- neighbours.modes_above_left_mi(mi_r, mi_c, neighbours.modes_above_left(r, c));7728+ let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left_mi(mi_r, mi_c, coarse_pair);
7729+ if (nb_above_mode, nb_left_mode) != coarse_pair {
7730+ EDGE_FILTER_MI_FIX_HITS.with(|c| c.set(c.get() + 1));
7731+ }
7703 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);7732 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
7704 if smooth_neighbor {7733 if smooth_neighbor {
7705 SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));7734 SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1));
@@ -13685,6 +13714,7 @@ fn tx_size_context_txfm_rect(
13685 own_w: usize,13714 own_w: usize,
13686 own_h: usize,13715 own_h: usize,
13687 ) -> usize {13716 ) -> usize {
13717+ INTRA_IN_INTER_TXCTX_HITS.with(|c| c.set(c.get() + 1));
13688 let has_above = mi_r > n.tile_row0_mi;13718 let has_above = mi_r > n.tile_row0_mi;
13689 let has_left = mi_c > n.tile_col0_mi;13719 let has_left = mi_c > n.tile_col0_mi;
13690 let mut above = usize::from(n.above_txfm[mi_c]) >= own_w;13720 let mut above = usize::from(n.above_txfm[mi_c]) >= own_w;
@@ -22417,9 +22447,21 @@ fn decode_inter_block(
22417 // witness is a capability claim (class `refusal-lifted-without-a-gate`),22447 // witness is a capability claim (class `refusal-lifted-without-a-gate`),
22418 // so the decode path stays behind `EC_INTRA16X4_DECODE` for the round22448 // so the decode path stays behind `EC_INTRA16X4_DECODE` for the round
22419 // that finds a witness.22449 // that finds a witness.
22450+ //
22451+ // lane-t900 r6: THAT WITNESS EXISTS, so `EC_INTRA16X4_DECODE` is gone
22452+ // and the refusal is narrowed back to "no chroma-pair record". The
22453+ // witness is a REAL 10-bit 1920x792 128-superblock film stream, not an
22454+ // aomenc recipe: `fixtures/reelc_sb128_inter_witness.obu` (166303 bytes,
22455+ // 19 frame-carrying OBUs, 14 decode-order frames) decodes all 14
22456+ // decode-order frames byte-exact against instrumented aomdec
22457+ // (`EC_AV1_FINAL_DUMP`) and all 12 shown frames pixel-exact against
22458+ // ffmpeg, while this arm fires 78x 16x4 + 149x 4x16 (108 of them
22459+ // chroma-paired). Unlike lane-sub8x4 r3's phantom (class
22460+ // `counter-from-refused-stream`) every one of those hits lies inside a
22461+ // frame that was decoded AND compared exact. Gate
22462+ // `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact`.
22420 let strip16 = strip_chroma22463 let strip16 = strip_chroma
22421 .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16)22464 .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16)
22422- .filter(|_| std::env::var_os("EC_INTRA16X4_DECODE").is_some())
22423 .map(|s| (s.horz, s.has_chroma));22465 .map(|s| (s.horz, s.has_chroma));
22424 if write_w.min(write_h) < 8 && strip16.is_none() {22466 if write_w.min(write_h) < 8 && strip16.is_none() {
22425 if std::env::var_os("EC_INTRA16X4").is_some() {22467 if std::env::var_os("EC_INTRA16X4").is_some() {
@@ -23012,6 +23054,7 @@ fn decode_inter_block(
23012 // equivalent to not writing them, without threading a flag through both23054 // equivalent to not writing them, without threading a flag through both
23013 // recorders.23055 // recorders.
23014 let saved_chroma_ctx = (!has_chroma).then(|| {23056 let saved_chroma_ctx = (!has_chroma).then(|| {
23057+ NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.set(c.get() + 1));
23015 let (w_mi, h_mi) = (write_w / MI, write_h / MI);23058 let (w_mi, h_mi) = (write_w / MI, write_h / MI);
23016 let left: Vec<[Neighbour; 2]> = (0..h_mi)23059 let left: Vec<[Neighbour; 2]> = (0..h_mi)
23017 .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]]))23060 .filter_map(|k| neighbours.left.get(at.0 + k).map(|s| [s[1], s[2]]))
crates/ec-av1/src/refusal_inventory.rsmodified+10 -5
@@ -86,11 +86,16 @@ const REFUSALS: &[&str] = &[
86 // halved footprint, which for a 16x4 strip is an 8x2 transform libaom86 // halved footprint, which for a 16x4 strip is an 8x2 transform libaom
87 // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip).87 // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip).
88 // lane-sub8x4 r3 narrowed this to "a strip with no chroma-pair record";88 // lane-sub8x4 r3 narrowed this to "a strip with no chroma-pair record";
89- // lane-wit16x4 r1 put it back at FULL width: r3's witness counters were89+ // lane-wit16x4 r1 put it back at FULL width (r3's witness counters were
90- // phantoms of a desync, no stream on this tree decodes pixel-exact while90+ // phantoms of a desync, class `refusal-lifted-without-a-gate`) behind
91- // the arm fires, and the decode path now needs `EC_INTRA16X4_DECODE`91+ // `EC_INTRA16X4_DECODE`. lane-t900 r6 NARROWED it again -- the opt-in is
92- // (class `refusal-lifted-without-a-gate`; numbers in decode.rs's `strip16`92+ // gone -- on a real 10-bit 1920x792 128-superblock film witness that
93- // note and lanes/wit16x4-r1.report.md).93+ // decodes 14/14 decode-order frames exact vs aomdec and 12/12 shown frames
94+ // exact vs ffmpeg while the arm fires 78 16x4 + 149 4x16 (108 chroma-
95+ // paired): gate
96+ // `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact`.
97+ // What still refuses is a 16x4/4x16 strip with NO chroma-pair record and
98+ // every other sub-8 shape.
94 "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)",99 "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)",
95 "an intra mode this decoder does not code (round 2)",100 "an intra mode this decoder does not code (round 2)",
96 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the101 // lane-intrarect r1 lifted the whole-shape refusal that stood here (the
crates/ec-av1/src/stream.rsmodified+127 -3
@@ -11192,9 +11192,10 @@ mod tests {
11192 mismatched)`; attempts 1..3 mismatch ffmpeg from frame 1 or 2 (max |delta| \11192 mismatched)`; attempts 1..3 mismatch ffmpeg from frame 1 or 2 (max |delta| \
11193 up to 248) and attempts 0/4 mismatch while carrying NO 1:4 strip at all -- \11193 up to 248) and attempts 0/4 mismatch while carrying NO 1:4 strip at all -- \
11194 another shape's defect, unchanged since r2. The 16x4/4x16-in-inter refusal \11194 another shape's defect, unchanged since r2. The 16x4/4x16-in-inter refusal \
11195- is re-added this round, so the shape now refuses by name unless \11195+ was lifted in lane-t900 r6 by a FILM witness (gate \
11196- `EC_INTRA16X4_DECODE` is set: un-ignore only together with a witness \11196+ `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact`), \
11197- (lanes/wit16x4-r1.report.md)"]11197+ so what is unproven here is only this aomenc RECIPE: un-ignore once one \
11198+ of its arms decodes exactly while the arm fires"]
11198 // lane-intra16x4 r1: an INTRA-coded 16x4 / 4x16 strip inside an INTER11199 // lane-intra16x4 r1: an INTRA-coded 16x4 / 4x16 strip inside an INTER
11199 // frame's 16x16-level 1:4 partition -- the wall all six of his film cuts11200 // frame's 16x16-level 1:4 partition -- the wall all six of his film cuts
11200 // stopped at once lane-rectres landed. The shape's chroma is the pair's:11201 // stopped at once lane-rectres landed. The shape's chroma is the pair's:
@@ -30280,6 +30281,129 @@ mod tests {
30280 );30281 );
30281 }30282 }
30282 30283
30284+ /// lane-t900 r6: the 128-superblock INTER witness.
30285+ /// `crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 166303 bytes,
30286+ /// sha256 `1191ce80e2c6c5855eaf7a8f5e8cda2cdf809f467b0dbc5e26df96dfa6b2c8bd`:
30287+ /// the first 19 frame-carrying OBUs of a 2 s cut taken 900 s into a 10-bit
30288+ /// 1920x792 AV1 stream with `use_128x128_superblock=1`, 14 decode-order
30289+ /// frames, 12 shown. Cut twice independently from the source (`-ss 900 -t 2
30290+ /// -c:v copy` then the OBU truncation) -- both cuts hash identically.
30291+ ///
30292+ /// It is the first stream in this repository that decodes exactly while
30293+ /// five separately-found defects' paths all fire, which is why the asserts
30294+ /// below are on all of them:
30295+ ///
30296+ /// * `warp_plane_suppress_hits` (r5) -- `av1_init_warp_params` bails out at
30297+ /// `block_width < 8 || block_height < 8` on the PLANE's own block, so the
30298+ /// 4x8 chroma of an 8x16 luma block is predicted translationally while its
30299+ /// luma warps. Gated on the square side before r5.
30300+ /// * `inter_sb128_vert_hits` + `cdef_idx_hits` (r5) -- the second half of a
30301+ /// 128-root HORZ/VERT inter block must read its OWN `cdef_idx` literal
30302+ /// (libaom `cdef_transmitted[4]`, one flag per 64x64 CDEF unit).
30303+ /// * `interintra_rect_hits` (r4) -- interintra on a RECTANGULAR block built
30304+ /// a square intra predictor before.
30305+ /// * `non_chroma_ref_ctx_skip_hits` (r3) -- a block that is not the chroma
30306+ /// reference of its 4:2:0 pair leaves its neighbours' chroma coefficient
30307+ /// contexts untouched (`nplanes = 1 + (num_planes - 1) * is_chroma_ref`).
30308+ /// * `intra_in_inter_txctx_hits` (r2) -- an intra strip in an INTER frame
30309+ /// takes its `tx_depth` row from the real `TXFM_CONTEXT` bands, not the
30310+ /// key frame's deblock grid.
30311+ /// * `edge_filter_mi_fix_hits` (r4) -- both halves of a split intra block
30312+ /// read their OWN mi-exact intra-edge-filter neighbours.
30313+ ///
30314+ /// It is ALSO the witness that lifts the `EC_INTRA16X4_DECODE` opt-in:
30315+ /// `intra16x4_in_inter` fires 78x 16x4 + 149x 4x16 (108 chroma-paired)
30316+ /// inside frames that are decoded AND compared exact -- not counted out of
30317+ /// a refused or desynced stream the way lane-sub8x4 r3's phantom was
30318+ /// (class `counter-from-refused-stream`). The 128x64/64x128 intra-in-inter
30319+ /// arm fires 0 times here, so THAT refusal is untouched.
30320+ ///
30321+ /// All 14 decode-order frames (including the 2 no-show frames ffmpeg never
30322+ /// hands back) were compared byte-exact against instrumented aomdec with
30323+ /// `EC_AV1_FINAL_DUMP` -- see the lane report's EVIDENCE line; the gate
30324+ /// itself compares the 12 shown frames on every plane.
30325+ #[test]
30326+ fn a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact() {
30327+ const NAME: &str =
30328+ "a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact";
30329+ if !have_ffmpeg() {
30330+ eprintln!("SKIP {NAME}: no ffmpeg");
30331+ return;
30332+ }
30333+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
30334+ .join("fixtures/reelc_sb128_inter_witness.obu");
30335+ let stream = std::fs::read(&path)
30336+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
30337+ let (width, height) = (1920usize, 792usize);
30338+ let before = (
30339+ crate::decode::warp_plane_suppress_hits(),
30340+ crate::decode::cdef_idx_hits(),
30341+ crate::decode::inter_sb128_vert_hits(),
30342+ crate::decode::interintra_rect_hits(),
30343+ crate::decode::non_chroma_ref_ctx_skip_hits(),
30344+ crate::decode::intra_in_inter_txctx_hits(),
30345+ crate::decode::edge_filter_mi_fix_hits(),
30346+ );
30347+ let i16_before = crate::decode::intra16x4_in_inter_hits();
30348+ let frames = match decode_stream(&stream) {
30349+ Ok(frames) => frames,
30350+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
30351+ };
30352+ let fired = (
30353+ crate::decode::warp_plane_suppress_hits() - before.0,
30354+ crate::decode::cdef_idx_hits() - before.1,
30355+ crate::decode::inter_sb128_vert_hits() - before.2,
30356+ crate::decode::interintra_rect_hits() - before.3,
30357+ crate::decode::non_chroma_ref_ctx_skip_hits() - before.4,
30358+ crate::decode::intra_in_inter_txctx_hits() - before.5,
30359+ crate::decode::edge_filter_mi_fix_hits() - before.6,
30360+ );
30361+ let i16_now = crate::decode::intra16x4_in_inter_hits();
30362+ let i16 = (
30363+ i16_now.0 - i16_before.0,
30364+ i16_now.1 - i16_before.1,
30365+ i16_now.2 - i16_before.2,
30366+ );
30367+ for (what, n) in [
30368+ ("warp_plane_suppress", fired.0),
30369+ ("cdef_idx", fired.1),
30370+ ("inter_sb128_vert", fired.2),
30371+ ("interintra_rect", fired.3),
30372+ ("non_chroma_ref_ctx_skip", fired.4),
30373+ ("intra_in_inter_txctx", fired.5),
30374+ ("edge_filter_mi_fix", fired.6),
30375+ ("intra16x4_in_inter 16x4", i16.0),
30376+ ("intra16x4_in_inter 4x16", i16.1),
30377+ ("intra16x4_in_inter chroma_ref", i16.2),
30378+ ] {
30379+ assert!(
30380+ n > 0,
30381+ "{NAME}: {what} never fired on this stream -- the gate would be vacuous for it"
30382+ );
30383+ }
30384+ assert_eq!(frames.len(), 12, "{NAME}: 12 shown frames");
30385+ assert_eq!((frames[0].width, frames[0].height), (width, height));
30386+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len());
30387+ assert_eq!(
30388+ ffmpeg_frames.len(),
30389+ frames.len(),
30390+ "{NAME}: ffmpeg returned {} frames, we decoded {}",
30391+ ffmpeg_frames.len(),
30392+ frames.len()
30393+ );
30394+ for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
30395+ assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
30396+ assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
30397+ assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
30398+ }
30399+ eprintln!(
30400+ "{NAME}: 12 shown frames pixel-exact on every plane; warp_plane_suppress={} \
30401+ cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \
30402+ intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?}",
30403+ fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16
30404+ );
30405+ }
30406+
30283 30407
30284 /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an30408 /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an
30285 /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra30409 /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra