forge
Explore
Log in

Don't you dare go Hollow

The typed round trip covers 32x32 (IDTX)

Browse files at this commit

5c1d094f315e65c27d41af516d4014ca2a3f8699Ahmet Kaan GümüşParent: 044aeb2
  • test
    • the typed round trip covers 32x32 (IDTX)
    • an le16 arm for the inter search
Show full message
test(av1): the typed round trip covers 32x32 (IDTX); an le16 arm for the inter search

The unconditional inter arm loses 20+ BD points on both synthetic bars rows of
the 12-frame gate while film A gains 0.2; libaom's own census never codes IDTX
at 32x32, so EC_AV1_TXSET_INTER=le16 offers the two-type set at 16x16 and
below only.
crates/ec-av1/src/encode.rsmodified+12 -9
@@ -292,22 +292,22 @@ pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType]
292292 /// (`IDTX`, `DCT_DCT`) and 32x32 is `EXT_TX_SET_DCT_IDTX` -- the same two
293293 /// types, a symbol the writer already codes and never varied. 64x64 codes no
294294 /// `tx_type` symbol at all, so it is not offered one.
295-/// `EC_AV1_TXSET_INTER`: `0`/`off`, `screen` (screen frames only), anything
296-/// else on for every frame.
295+/// `EC_AV1_TXSET_INTER`: `0`/`off`, `screen` (screen frames only), `le16`
296+/// (16x16 and below, the sizes libaom's own census picks a non-`DCT_DCT`
297+/// inter type on -- it never takes `IDTX` at 32x32 on film B), anything else
298+/// on for every frame at every size.
297299 pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] {
298300 const DCT: [TxType; 1] = [TxType::DctDct];
299301 const INTER3: [TxType; 2] = [TxType::DctDct, TxType::Idtx];
300- let on = match inter_tx_type_search() {
302+ let mode = inter_tx_type_search();
303+ let on = match mode {
301304 InterTxSearch::Off => false,
302305 InterTxSearch::Screen => screen,
303- InterTxSearch::All => true,
306+ InterTxSearch::All | InterTxSearch::Le16 => true,
304307 };
305308 match set {
306- TxbSet::Luma32Inter | TxbSet::Luma16Inter | TxbSet::Luma8Inter | TxbSet::Luma4Inter
307- if on =>
308- {
309- &INTER3
310- }
309+ TxbSet::Luma32Inter if on && mode != InterTxSearch::Le16 => &INTER3,
310+ TxbSet::Luma16Inter | TxbSet::Luma8Inter | TxbSet::Luma4Inter if on => &INTER3,
311311 _ => &DCT,
312312 }
313313 }
@@ -316,6 +316,8 @@ pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [T
316316 pub(crate) enum InterTxSearch {
317317 Off,
318318 Screen,
319+ /// 16x16 and below only.
320+ Le16,
319321 All,
320322 }
321323
@@ -346,6 +348,7 @@ fn inter_tx_type_search() -> InterTxSearch {
346348 crate::envflags::var("EC_AV1_TXSET_INTER").ok().map(|v| match v.as_str() {
347349 "0" | "off" => InterTxSearch::Off,
348350 "screen" => InterTxSearch::Screen,
351+ "le16" => InterTxSearch::Le16,
349352 _ => InterTxSearch::All,
350353 })
351354 });
crates/ec-av1/src/transform.rsmodified+11 -3
@@ -2160,7 +2160,10 @@ mod tests {
21602160 /// and the mode search would read as a loss.
21612161 #[test]
21622162 fn a_typed_forward_round_trips_like_the_dct_one() {
2163- for side in [4usize, 8, 16] {
2163+ // lane-txset2: 32 too -- the INTER search offers `IDTX` at 32x32
2164+ // (`TxbSet::Luma32Inter`'s `EXT_TX_SET_DCT_IDTX`), a size the intra
2165+ // sets never name and this round trip never covered.
2166+ for side in [4usize, 8, 16, 32] {
21642167 let residual: Vec<i32> = noise(side * side, 7 + side as u64)
21652168 .iter()
21662169 .map(|&v| v / 4)
@@ -2180,7 +2183,10 @@ mod tests {
21802183 // the reduced set names -- the FLIPADST and 1D-ADST/DCT families
21812184 // reach the forward side through the mirrored residual, and a
21822185 // mirror on the wrong axis reads exactly as a blown-up rmse here.
2183- for tx in [
2186+ // At 32x32 the only types any set names are `DCT_DCT` and
2187+ // `IDTX` (`EXT_TX_SET_DCT_IDTX`; ADST is undefined above 16), and
2188+ // the inter search offers exactly those.
2189+ let all = [
21842190 TxType::AdstDct,
21852191 TxType::DctAdst,
21862192 TxType::AdstAdst,
@@ -2196,7 +2202,9 @@ mod tests {
21962202 TxType::FlipAdstFlipAdst,
21972203 TxType::AdstFlipAdst,
21982204 TxType::FlipAdstAdst,
2199- ] {
2205+ ];
2206+ let types: &[TxType] = if side > 16 { &[TxType::Idtx] } else { &all };
2207+ for &tx in types {
22002208 let e = rmse(tx);
22012209 assert!(
22022210 e < 2.0 * dct,
lanes/txset2.report.mdmodified+56 -0
@@ -30,3 +30,59 @@ Witness: `encoder::tests::an_inter_clip_codes_both_inter_set_tx_types_both_decod
3030 -- PASS, hits `[DCT_DCT 154 .., IDTX 1368 ..]`, ours == ffmpeg every sample.
3131
3232 Gate rows: see below (arms running).
33+
34+### The 12-frame gate (`encode::tests::bd_rate_screen_native`, 12 frames, gop 12)
35+
36+Control re-run on this head (`EC_AV1_TXSET_INTER=0`, which is also the
37+default): it REPRODUCES the charter's numbers to the digit, byte counts
38+included.
39+
40+| clip | control | arm: every frame, every size | delta | wall ctl -> arm |
41+|---|---|---|---|---|
42+| bars 1080p | -1.0% / -16.8% | **+23.1% / +3.3%** | +24.1 / +20.1 | 177.2s -> 182.0s |
43+| bars 2160p | +9.4% / -12.7% | **+31.2% / +3.7%** | +21.8 / +16.4 | 155.9s -> 160.7s |
44+| film A | +21.7% / -4.4% | +21.5% / -4.5% | -0.2 / -0.1 | 154.9s -> 167.7s |
45+| film B | +26.9% / -0.6% | +27.2% / -0.3% | +0.3 / +0.3 | 161.5s -> 167.6s |
46+| screen capture | +20.8% / -30.1% | +20.1% / -30.4% | -0.7 / -0.3 | 112.2s -> 109.5s |
47+
48+KEEP RULE on the unconditional arm: FAIL, and not marginally -- the two
49+synthetic bars rows lose TWENTY points (2 dB of luma PSNR at the same byte
50+count). Film A is 0.2/0.1 down, film B 0.3/0.3 up, the capture 0.7/0.3 down.
51+
52+The identity transform is not mis-scaled at 32x32: the typed round trip now
53+covers `side = 32` for the two types any set names there (`DCT_DCT`, `IDTX`;
54+ADST is undefined above 16) and `IDTX`'s rmse stays inside the DCT's 2x bound.
55+The bars collapse is the `local-rd-on-references` class again, at its loudest:
56+a flat synthetic frame is all 32x32 inter blocks whose residual `IDTX` prices
57+cheapest locally, and every later frame predicts from that reconstruction.
58+
59+## Step 3 -- what libaom actually picks (instrument, read off lane-libcen's census)
60+
61+`lanes/libcen.report.md`'s census files (`~/.cache/lc-libcen/cen-*.txt`,
62+`crates/ec-av1/examples/syntax_census.rs`) already carry the per-frame
63+`tx_type` histogram keyed by CDF row length, so no new run was needed. Film B,
64+libaom cpu-used 6 crf41 (48 pictures), row length -> set: 3 = the 2-symbol
65+inter `DCT_IDTX` (32x32), 6 = the 5-symbol `TX_SET_INTRA_2` (intra 16x16 and,
66+under `reduced_tx_set`, all intra), 8 = the 7-symbol `TX_SET_INTRA_1` (intra
67+8x8/4x4), 13 = the 12-symbol `TX_SET_INTER_2` (inter 16x16), 17 = ALL16
68+(inter 8x8/4x4).
69+
70+| frame | set3 (inter 32) | set6 (intra 16) | set8 (intra 8/4) | set13 (inter 16) | set17 (inter <=8) |
71+|---|---|---|---|---|---|
72+| key (718 symbols) | -- | 85.3% | 14.7% | -- | -- |
73+| arf hint 30 (1058) | 27.5% | 6.8% | 4.5% | 51.7% | 9.7% |
74+| arf hint 15 (364) | 34.1% | 1.7% | 1.6% | 46.8% | 15.7% |
75+| arf hint 7 (61) | 67.2% | 1.6% | -- | 19.7% | 11.5% |
76+| arf hint 3 (41) | 78.0% | -- | -- | 9.7% | 12.3% |
77+
78+Two readings, both decisions:
79+
80+1. **libaom never codes `IDTX` at 32x32 on film B.** Every one of its set3
81+ symbols is symbol 1 (`DCT_DCT`); symbol 0 does not appear in any frame of
82+ the stream. That is exactly the size our unconditional arm loses its twenty
83+ points on -- hence the `le16` arm below.
84+2. **41% of its inter `tx_type` symbols are in sets 13/17**, i.e. the alphabets
85+ `reduced_tx_set = 0` unlocks, and they are spread across nine or more
86+ distinct types (set13 symbols 3..11 at 1.5-14% each). Our own stream codes
87+ `set3/1` and `set6/1` only, 100% `DCT_DCT` in inter frames -- the gap step 2
88+ is aimed at.