The typed round trip covers 32x32 (IDTX)
Browse files at this commit5c1d094f315e65c27d41af516d4014ca2a3f8699Parent: 044aeb2- test
- the typed round trip covers 32x32 (IDTX)
- an le16 arm for the inter search
3 changed files +79 -12
- crates/ec-av1/src/encode.rs +12 -9
- crates/ec-av1/src/transform.rs +11 -3
- lanes/txset2.report.md +56 -0
crates/ec-av1/src/encode.rsmodified+12 -9
| @@ -292,22 +292,22 @@ pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] | ||
| 292 | 292 | /// (`IDTX`, `DCT_DCT`) and 32x32 is `EXT_TX_SET_DCT_IDTX` -- the same two |
| 293 | 293 | /// types, a symbol the writer already codes and never varied. 64x64 codes no |
| 294 | 294 | /// `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. | |
| 297 | 299 | pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { |
| 298 | 300 | const DCT: [TxType; 1] = [TxType::DctDct]; |
| 299 | 301 | 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 { | |
| 301 | 304 | InterTxSearch::Off => false, |
| 302 | 305 | InterTxSearch::Screen => screen, |
| 303 | - InterTxSearch::All => true, | |
| 306 | + InterTxSearch::All | InterTxSearch::Le16 => true, | |
| 304 | 307 | }; |
| 305 | 308 | 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, | |
| 311 | 311 | _ => &DCT, |
| 312 | 312 | } |
| 313 | 313 | } |
| @@ -316,6 +316,8 @@ pub(crate) fn inter_tx_type_candidates(set: TxbSet, screen: bool) -> &'static [T | ||
| 316 | 316 | pub(crate) enum InterTxSearch { |
| 317 | 317 | Off, |
| 318 | 318 | Screen, |
| 319 | + /// 16x16 and below only. | |
| 320 | + Le16, | |
| 319 | 321 | All, |
| 320 | 322 | } |
| 321 | 323 | |
| @@ -346,6 +348,7 @@ fn inter_tx_type_search() -> InterTxSearch { | ||
| 346 | 348 | crate::envflags::var("EC_AV1_TXSET_INTER").ok().map(|v| match v.as_str() { |
| 347 | 349 | "0" | "off" => InterTxSearch::Off, |
| 348 | 350 | "screen" => InterTxSearch::Screen, |
| 351 | + "le16" => InterTxSearch::Le16, | |
| 349 | 352 | _ => InterTxSearch::All, |
| 350 | 353 | }) |
| 351 | 354 | }); |
crates/ec-av1/src/transform.rsmodified+11 -3
| @@ -2160,7 +2160,10 @@ mod tests { | ||
| 2160 | 2160 | /// and the mode search would read as a loss. |
| 2161 | 2161 | #[test] |
| 2162 | 2162 | 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] { | |
| 2164 | 2167 | let residual: Vec<i32> = noise(side * side, 7 + side as u64) |
| 2165 | 2168 | .iter() |
| 2166 | 2169 | .map(|&v| v / 4) |
| @@ -2180,7 +2183,10 @@ mod tests { | ||
| 2180 | 2183 | // the reduced set names -- the FLIPADST and 1D-ADST/DCT families |
| 2181 | 2184 | // reach the forward side through the mirrored residual, and a |
| 2182 | 2185 | // 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 = [ | |
| 2184 | 2190 | TxType::AdstDct, |
| 2185 | 2191 | TxType::DctAdst, |
| 2186 | 2192 | TxType::AdstAdst, |
| @@ -2196,7 +2202,9 @@ mod tests { | ||
| 2196 | 2202 | TxType::FlipAdstFlipAdst, |
| 2197 | 2203 | TxType::AdstFlipAdst, |
| 2198 | 2204 | TxType::FlipAdstAdst, |
| 2199 | - ] { | |
| 2205 | + ]; | |
| 2206 | + let types: &[TxType] = if side > 16 { &[TxType::Idtx] } else { &all }; | |
| 2207 | + for &tx in types { | |
| 2200 | 2208 | let e = rmse(tx); |
| 2201 | 2209 | assert!( |
| 2202 | 2210 | 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 | ||
| 30 | 30 | -- PASS, hits `[DCT_DCT 154 .., IDTX 1368 ..]`, ours == ffmpeg every sample. |
| 31 | 31 | |
| 32 | 32 | 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. |