forge
Explore
Log in

Don't you dare go Hollow

Size_group_wh gave group 1 to every 4-px-side block (libaom size_group_lookup says 0)

Browse files at this commit

54f8c61846b28dd55ff3078dcab34b13b22a13ebAhmet Kaan GümüşParent: 3c024bf
  • fix
    • size_group_wh gave group 1 to every 4-px-side block (libaom size_group_lookup says 0)
Show full message
fix(av1): size_group_wh gave group 1 to every 4-px-side block (libaom size_group_lookup says 0)

4x4/4x8/8x4/4x16/16x4 select size group 0 in libaom (common_data.h:60), so every
sub-8 leaf was reading the wrong y_mode / interintra / interintra_mode CDF row.
Pinned by a unit test enumerating all 22 BLOCK_SIZES_ALL entries.

Also: decode_probe prints the rect_inter tu/txsplit/obmc_leaf counters (the sweep
that measured the rect var-tx SPLIT and 10-bit rect TU paths as unexercised, now
recorded in the gate comment), and cdf.rs gets EOB_PT_128_CHROMA_CLASS1_Q0's doc
comment back after r3's LUMA block displaced it.
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
@@ -31,6 +31,8 @@ fn main() {
31 let report = || {31 let report = || {
32 let (h, v, c) = ec_av1::stream::rect4_32_counters();32 let (h, v, c) = ec_av1::stream::rect4_32_counters();
33 println!("rect4_32: horz={h} vert={v} coded={c}");33 println!("rect4_32: horz={h} vert={v} coded={c}");
34+ let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters();
35+ println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}");
34 let ir = ec_av1::stream::inter_rect_counters();36 let ir = ec_av1::stream::inter_rect_counters();
35 println!(37 println!(
36 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",38 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/cdf.rsmodified+1 -1
@@ -5221,7 +5221,6 @@ pub const EOB_PT_16_CHROMA_CLASS1_Q1: [u16; 6] = [2497, 4096, 8866, 16993, 32768
5221 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];5221 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];
5222 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];5222 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];
5223 5223
5224-/// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).
5225 /// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`,5224 /// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`,
5226 /// token_cdfs.h:830-848) -- the `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/5225 /// token_cdfs.h:830-848) -- the `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`V_DCT`/
5227 /// `H_DCT`) eob group of a 128-position LUMA transform, i.e. a true 16x8/8x165226 /// `H_DCT`) eob group of a 128-position LUMA transform, i.e. a true 16x8/8x16
@@ -5247,6 +5246,7 @@ pub const EOB_PT_32_CHROMA_CLASS1: [u16; 7] = [3542, 5502, 10415, 16760, 25644,
5247 /// [`EOB_PT_32_CHROMA_CLASS1_Q0`]'s q-context 3 sibling.5246 /// [`EOB_PT_32_CHROMA_CLASS1_Q0`]'s q-context 3 sibling.
5248 pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];5247 pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];
5249 5248
5249+/// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).
5250 pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];5250 pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];
5251 pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];5251 pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];
5252 pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] = [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0];5252 pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] = [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0];
crates/ec-av1/src/decode.rsmodified+21 -1
@@ -9124,13 +9124,33 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> TxbSet {
9124 /// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2,9124 /// square `side` corner-cut: 8x8/8x16/16x8 -> 1, 16x16/16x32/32x16 -> 2,
9125 /// everything 32 and above -> 3.9125 /// everything 32 and above -> 3.
9126 fn size_group_wh(w: usize, h: usize) -> usize {9126 fn size_group_wh(w: usize, h: usize) -> usize {
9127+ // lane-inter4 r4: `size_group_lookup[BLOCK_SIZES_ALL]` (libaom
9128+ // `common_data.h:60`) is 0 for every block with a 4-px side
9129+ // (4x4/4x8/8x4/4x16/16x4), 1 for min side 8, 2 for 16, 3 above -- the old
9130+ // `0..=8 => 1` row gave a sub-8 leaf group 1 where libaom says 0.
9127 match w.min(h) {9131 match w.min(h) {
9128- 0..=8 => 1,9132+ 0..=4 => 0,
9133+ 8 => 1,
9129 16 => 2,9134 16 => 2,
9130 _ => 3,9135 _ => 3,
9131 }9136 }
9132 }9137 }
9133 9138
9139+#[test]
9140+fn size_group_wh_matches_libaom_size_group_lookup() {
9141+ // `BLOCK_SIZES_ALL` in libaom's own order, with `size_group_lookup`'s
9142+ // transcribed values (common_data.h:60-62).
9143+ const TABLE: [((usize, usize), usize); 22] = [
9144+ ((4, 4), 0), ((4, 8), 0), ((8, 4), 0), ((8, 8), 1), ((8, 16), 1), ((16, 8), 1),
9145+ ((16, 16), 2), ((16, 32), 2), ((32, 16), 2), ((32, 32), 3), ((32, 64), 3),
9146+ ((64, 32), 3), ((64, 64), 3), ((64, 128), 3), ((128, 64), 3), ((128, 128), 3),
9147+ ((4, 16), 0), ((16, 4), 0), ((8, 32), 1), ((32, 8), 1), ((16, 64), 2), ((64, 16), 2),
9148+ ];
9149+ for ((w, h), want) in TABLE {
9150+ assert_eq!(size_group_wh(w, h), want, "size_group_wh({w}, {h})");
9151+ }
9152+}
9153+
9134 /// The default (2D) coefficient scan of a rectangular transform.9154 /// The default (2D) coefficient scan of a rectangular transform.
9135 fn rect_scan(w: usize, h: usize) -> &'static [u16] {9155 fn rect_scan(w: usize, h: usize) -> &'static [u16] {
9136 match (w, h) {9156 match (w, h) {
crates/ec-av1/src/stream.rsmodified+20 -0
@@ -76,6 +76,17 @@ pub fn rect4_32_counters() -> (usize, usize, usize) {
76 )76 )
77 }77 }
78 78
79+/// lane-inter4 r4: rectangular inter transform units coded whole, rect
80+/// var-tx trees that split, and OBMC blends run on a 16x8/8x16 leaf -- the
81+/// three counters a recipe sweep needs to see from outside the crate.
82+pub fn rect_inter_tu_counters() -> (usize, usize, usize) {
83+ (
84+ crate::decode::rect_inter_tu_hits(),
85+ crate::decode::rect_inter_txsplit_hits(),
86+ crate::decode::obmc_rect_leaf_hits(),
87+ )
88+}
89+
79 /// Decode every frame in a raw AV1 OBU stream, in coding order.90 /// Decode every frame in a raw AV1 OBU stream, in coding order.
80 ///91 ///
81 /// A key frame becomes the reference for the inter frames that follow it,92 /// A key frame becomes the reference for the inter frames that follow it,
@@ -5097,6 +5108,15 @@ mod tests {
5097 (0u32, 0u32, 0u32, 0u32);5108 (0u32, 0u32, 0u32, 0u32);
5098 let (mut tu_proved, mut split_proved) = (0usize, 0usize);5109 let (mut tu_proved, mut split_proved) = (0usize, 0usize);
5099 let (mut horz_proved, mut vert_proved, mut sub16_split) = (0u32, 0u32, 0usize);5110 let (mut horz_proved, mut vert_proved, mut sub16_split) = (0u32, 0u32, 0usize);
5111+ // lane-inter4 r4, measured residue of this recipe family (sweep
5112+ // over cq {8,12,16,22} x {both axes} x both depths, tx-size-search
5113+ // on, via `decode_probe`'s `rect_inter:` counters): the rect
5114+ // var-tx SPLIT arm never fires (txsplit=0 everywhere) and a 10-bit
5115+ // rect leaf is always `skip` (tu=0 at every cq that decodes) --
5116+ // below cq 22 every attempt stops at another lane's intra refusal
5117+ // ("a HORZ/VERT intra strip below 16x16 with a split transform").
5118+ // Both are asserted here only where they DO fire (8-bit tu>0);
5119+ // shipped-but-unexercised, see lanes/inter4-r4.report.md.
5100 // lane-inter4 r4: attempts 16..32 repeat the same sweep with5120 // lane-inter4 r4: attempts 16..32 repeat the same sweep with
5101 // `--enable-obmc=1`. r3 refused OBMC on this shape; r4's5121 // `--enable-obmc=1`. r3 refused OBMC on this shape; r4's
5102 // instrumented-aomdec comparison showed the neighbour list AND5122 // instrumented-aomdec comparison showed the neighbour list AND
lanes/inter4-r4.report.mdmodified+37 -0
@@ -67,6 +67,40 @@ EVIDENCE: scratchpad/{ours.obmc,ref.obmc,ours.yuv.f0-5,ref.yuv.f0-5} | EC_OBMC +
67 67
68 EVIDENCE: $HOME/.cache/inter4-g4.log | 64 aomenc encodes (32 attempts x 2 depths), every decoded frame Y/U/V vs ffmpeg | test result: ok. 1 passed; 0 failed; OBMC-on-rect-leaf blends 10 (8-bit) / 4 (10-bit), 0 mismatches68 EVIDENCE: $HOME/.cache/inter4-g4.log | 64 aomenc encodes (32 attempts x 2 depths), every decoded frame Y/U/V vs ffmpeg | test result: ok. 1 passed; 0 failed; OBMC-on-rect-leaf blends 10 (8-bit) / 4 (10-bit), 0 mismatches
69 69
70+## Verifier findings folded in (r4, after the OBMC commit)
71+
72+1. **`size_group_wh` was wrong for a 4-px side** (decode.rs ~9126): libaom
73+ `size_group_lookup[BLOCK_SIZES_ALL]` (`common_data.h:60`) is **0** for
74+ BLOCK_4X4/4X8/8X4/4X16/16X4, and our `0..=8 => 1` row gave those group 1 --
75+ the `y_mode` / `interintra` / `interintra_mode` CDF row of every sub-8 leaf.
76+ Fixed, and pinned by a new unit test `size_group_wh_matches_libaom_size_group_lookup`
77+ that enumerates all 22 `BLOCK_SIZES_ALL` entries against the transcribed table
78+ (class enumerate-the-table-domain).
79+
80+ cargo test -p ec-av1 --lib size_group_wh_matches -- --nocapture
81+
82+2. **rect var-tx SPLIT and the 10-bit coded rect TU are shipped unexercised.**
83+ Swept cq {8,12,16,22} x both source axes x both depths with tx-size-search on,
84+ reading `decode_probe`'s new `rect_inter: tu=.. txsplit=.. obmc_leaf=..` line:
85+ `txsplit=0` in every single decoding attempt, and every 10-bit rect leaf is
86+ `skip` (`tu=0`) at every cq that decodes at all. Below cq 22 the attempts stop
87+ at another lane's refusal -- mostly `"a HORZ/VERT intra strip below 16x16 with
88+ a split transform (per-unit rect prediction is not ported)"`, plus the sub-16
89+ `HORZ_A/HORZ_B/VERT_A` and 32-level 1:4 ones. Deviation from the verifier's
90+ ask, stated: I did NOT add an `#[ignore]`d pin -- an ignored test that runs
91+ nothing carries the same information as the measurement now written into the
92+ gate's own comment (stream.rs ~5097) and into the residue below, at less code.
93+ The asserts stay where the feature does fire (8-bit `tu_total > 0`).
94+
95+3. `stream.rs` "aomenc keeps the last occurrence of a repeated `--enable-*` flag"
96+ is CORRECT (class aomenc-first-flag-wins is about `--enable-*` repeats resolving
97+ to the last one, and it is what the r4 obmc arm relies on) -- left unchanged.
98+
99+4. `cdf.rs` doc slip fixed: `EOB_PT_128_CHROMA_CLASS1_Q0` had lost its doc comment
100+ to the `EOB_PT_128_LUMA_CLASS1_Q0` block added in r3; moved back.
101+
102+EVIDENCE: sweep output in this round's transcript | 16 aomenc encodes (cq 8/12/16/22 x 2 axes x 8/10-bit) decoded through release decode_probe | txsplit=0 in all 7 decoding attempts, 10-bit tu=0 in all 4, 8-bit cq22 tu=1 txsplit=0 obmc_leaf=1
103+
70 ## Refusals104 ## Refusals
71 105
72 Lifted: `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)"`.106 Lifted: `"OBMC on a 16x8/8x16 inter leaf (blend mismatches the reference on this shape)"`.
@@ -94,5 +128,8 @@ EVIDENCE: scratchpad/hg-head.obu | release decode_probe under a 6G scope | REFUS
94 - accepted: which change fixed r3's OBMC mismatch is not bisected (interbis merge is the128 - accepted: which change fixed r3's OBMC mismatch is not bisected (interbis merge is the
95 only candidate); the shape is now proven exact against an instrumented aomdec, so the129 only candidate); the shape is now proven exact against an instrumented aomdec, so the
96 question is archaeology, not a defect.130 question is archaeology, not a defect.
131+- deferred: the rect var-tx SPLIT path and a coded 10-bit rect TU are unexercised --
132+ unblocked by the sub-16 intra-rect-strip refusal landing (every lower-cq attempt
133+ stops there before a rect inter leaf can carry a split tree).
97 - accepted: `16x16 SPLITs=0` under this recipe (aomenc picks NONE/HORZ/VERT at 16);134 - accepted: `16x16 SPLITs=0` under this recipe (aomenc picks NONE/HORZ/VERT at 16);
98 covered by the 8x8-leaf sibling gate.135 covered by the 8x8-leaf sibling gate.