forge
Explore
Log in

Don't you dare go Hollow

Gate the tx_type search to screen frames -- seven BD points on the capture, both films lose without it

Browse files at this commit

d4cc317a7b195d47ddde9cf533ef8ddd2b6b99e9Ahmet Kaan GümüşParent: ef13e7f
  • feat
    • gate the tx_type search to screen frames -- seven BD points on the capture, both films lose without it
Show full message
feat(av1): gate the tx_type search to screen frames -- seven BD points on the capture, both films lose without it
crates/ec-av1/src/encode.rsmodified+12 -4
@@ -252,6 +252,14 @@ fn tx_select_inter() -> bool {
252252 ENV.unwrap_or_else(|| crate::speed::at(&crate::speed::TX_SELECT_INTER))
253253 }
254254
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+///
255263 /// The transform types an intra luma transform unit of `set` may be coded
256264 /// with -- exactly the alphabet the writer's `tx_type` symbol names for that
257265 /// set, so a searched type is always one the tile can express (lane-txset).
@@ -262,7 +270,7 @@ fn tx_select_inter() -> bool {
262270 /// [`TxType::from_symbol`] names; 32x32 and 64x64 luma code no symbol at all,
263271 /// and inter luma reads the two-type `TX_SET_INTER_3`, left at `DCT_DCT`
264272 /// 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] {
266274 const DCT: [TxType; 1] = [TxType::DctDct];
267275 const INTRA2: [TxType; 5] = [
268276 TxType::DctDct,
@@ -272,7 +280,7 @@ pub(crate) fn tx_type_candidates(set: TxbSet) -> &'static [TxType] {
272280 TxType::Idtx,
273281 ];
274282 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,
276284 _ => &DCT,
277285 }
278286 }
@@ -2453,7 +2461,7 @@ impl Plane<'_> {
24532461 // through the same RDOQ'd trial path (its `bits`
24542462 // already carry the `tx_type` symbol itself).
24552463 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) {
24572465 let candidate = self.trial_typed(
24582466 tu, mode, angle_delta, search.base_q_idx, search.deadzone,
24592467 tx_type, fctx,
@@ -2843,7 +2851,7 @@ impl Plane<'_> {
28432851 // and angle the trials above settled -- the same ordering the angle
28442852 // refinement uses, and the same RD terms.
28452853 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) {
28472855 let candidate = self.trial_typed(
28482856 at, mode, angle_delta, search.base_q_idx, search.deadzone, candidate_type, fctx,
28492857 );
crates/ec-av1/src/encoder.rsmodified+5 -1
@@ -3625,7 +3625,10 @@ mod tests {
36253625 /// the statement that the other four are REACHABLE at all.
36263626 #[test]
36273627 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));
36293632 let _gate_lock = crate::stream::tests::lock_gate_counters();
36303633 let (width, height) = (320usize, 192usize);
36313634 // Sharp horizontal and vertical steps: a vertical edge is what an
@@ -3703,6 +3706,7 @@ mod tests {
37033706 } else {
37043707 eprintln!("SKIP the ffmpeg half: no ffmpeg");
37053708 }
3709+ crate::encode::force_screen(None);
37063710 eprintln!("tx_type witness: hits {hits:?}, {} bytes", stream.len());
37073711 }
37083712