Gate the tx_type search to screen frames -- seven BD points on the capture, both films lose without it
Browse files at this commitd4cc317a7b195d47ddde9cf533ef8ddd2b6b99e9Parent: ef13e7f- feat
- gate the tx_type search to screen frames -- seven BD points on the capture, both films lose without it
2 changed files +17 -5
crates/ec-av1/src/encode.rsmodified+12 -4
| @@ -252,6 +252,14 @@ fn tx_select_inter() -> bool { | ||
| 252 | 252 | ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::TX_SELECT_INTER)) |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | +/// SCREEN CONTENT ONLY, measured (12-frame `bd_rate_screen_native`, control | |
| 256 | +/// vs arm): the capture row goes +27.8/-26.0 -> +20.8/-30.1 -- seven points | |
| 257 | +/// against libaom -- while BOTH film rows LOSE (film A +21.7/-4.4 -> | |
| 258 | +/// +22.1/-4.0, film B +26.9/-0.6 -> +28.1/+0.7) and 2160p bars lose 0.8/1.1. | |
| 259 | +/// The keep rule wants both films down, so this takes the same content gate | |
| 260 | +/// palette, intrabc and the angle-delta refinement already stand behind: a | |
| 261 | +/// non-screen frame is byte-identical to the encoder before the lane. | |
| 262 | +/// | |
| 255 | 263 | /// The transform types an intra luma transform unit of `set` may be coded |
| 256 | 264 | /// with -- exactly the alphabet the writer's `tx_type` symbol names for that |
| 257 | 265 | /// set, so a searched type is always one the tile can express (lane-txset). |
| @@ -262,7 +270,7 @@ fn tx_select_inter() -> bool { | ||
| 262 | 270 | /// [`TxType::from_symbol`] names; 32x32 and 64x64 luma code no symbol at all, |
| 263 | 271 | /// and inter luma reads the two-type `TX_SET_INTER_3`, left at `DCT_DCT` |
| 264 | 272 | /// here. |
| 265 | -pub(crate) fn tx_type_candidates(set: TxbSet) -> &'static [TxType] { | |
| 273 | +pub(crate) fn tx_type_candidates(set: TxbSet, screen: bool) -> &'static [TxType] { | |
| 266 | 274 | const DCT: [TxType; 1] = [TxType::DctDct]; |
| 267 | 275 | const INTRA2: [TxType; 5] = [ |
| 268 | 276 | TxType::DctDct, |
| @@ -272,7 +280,7 @@ pub(crate) fn tx_type_candidates(set: TxbSet) -> &'static [TxType] { | ||
| 272 | 280 | TxType::Idtx, |
| 273 | 281 | ]; |
| 274 | 282 | match set { |
| 275 | - TxbSet::Luma16 | TxbSet::Luma8 | TxbSet::Luma4 if tx_type_search() => &INTRA2, | |
| 283 | + TxbSet::Luma16 | TxbSet::Luma8 | TxbSet::Luma4 if screen && tx_type_search() => &INTRA2, | |
| 276 | 284 | _ => &DCT, |
| 277 | 285 | } |
| 278 | 286 | } |
| @@ -2453,7 +2461,7 @@ impl Plane<'_> { | ||
| 2453 | 2461 | // through the same RDOQ'd trial path (its `bits` |
| 2454 | 2462 | // already carry the `tx_type` symbol itself). |
| 2455 | 2463 | let mut best: Option<(f64, TxType, Trial)> = None; |
| 2456 | - for &tx_type in tx_type_candidates(set) { | |
| 2464 | + for &tx_type in tx_type_candidates(set, search.screen) { | |
| 2457 | 2465 | let candidate = self.trial_typed( |
| 2458 | 2466 | tu, mode, angle_delta, search.base_q_idx, search.deadzone, |
| 2459 | 2467 | tx_type, fctx, |
| @@ -2843,7 +2851,7 @@ impl Plane<'_> { | ||
| 2843 | 2851 | // and angle the trials above settled -- the same ordering the angle |
| 2844 | 2852 | // refinement uses, and the same RD terms. |
| 2845 | 2853 | let mut tx_type = TxType::DctDct; |
| 2846 | - for &candidate_type in tx_type_candidates(at.set).iter().skip(1) { | |
| 2854 | + for &candidate_type in tx_type_candidates(at.set, search.screen).iter().skip(1) { | |
| 2847 | 2855 | let candidate = self.trial_typed( |
| 2848 | 2856 | at, mode, angle_delta, search.base_q_idx, search.deadzone, candidate_type, fctx, |
| 2849 | 2857 | ); |
crates/ec-av1/src/encoder.rsmodified+5 -1
| @@ -3625,7 +3625,10 @@ mod tests { | ||
| 3625 | 3625 | /// the statement that the other four are REACHABLE at all. |
| 3626 | 3626 | #[test] |
| 3627 | 3627 | fn an_edge_clip_codes_every_reduced_set_tx_type_both_decoders_read_exactly() { |
| 3628 | - let _knobs = crate::speed::knob_read(); | |
| 3628 | + // `knob_write`: the screen override below is process-global, and the | |
| 3629 | + // type search is SCREEN-ONLY (`encode::tx_type_candidates`). | |
| 3630 | + let _knobs = crate::speed::knob_write(); | |
| 3631 | + crate::encode::force_screen(Some(true)); | |
| 3629 | 3632 | let _gate_lock = crate::stream::tests::lock_gate_counters(); |
| 3630 | 3633 | let (width, height) = (320usize, 192usize); |
| 3631 | 3634 | // Sharp horizontal and vertical steps: a vertical edge is what an |
| @@ -3703,6 +3706,7 @@ mod tests { | ||
| 3703 | 3706 | } else { |
| 3704 | 3707 | eprintln!("SKIP the ffmpeg half: no ffmpeg"); |
| 3705 | 3708 | } |
| 3709 | + crate::encode::force_screen(None); | |
| 3706 | 3710 | eprintln!("tx_type witness: hits {hits:?}, {} bytes", stream.len()); |
| 3707 | 3711 | } |
| 3708 | 3712 |