forge
Explore
Log in

Don't you dare go Hollow

Revert "feat(av1): the 32x32 inter search's intra candidate gets a palette arm"

Browse files at this commit

530272b851048459b1596d41e6af351d637aedaeAhmet Kaan GümüşParent: d247d42
Measured dead work: with the arm on, the screen clip codes the SAME 1102
palette blocks and the same bytes at every rate point as with it off
(EC_AV1_PAL_MAXCOLORS=128 both sides), for +13% encode wall on that clip
(6.9s vs 6.1s) -- the trials run, and a 32x32 intra candidate inside an
inter frame never beats NEARESTMV plus a 1024-entry colour map.

This reverts commit 28397f14.
crates/ec-av1/src/encode.rsmodified+1 -62
@@ -4484,9 +4484,6 @@ fn search_inter_block(
4484 mode: u8,4484 mode: u8,
4485 skip: bool,4485 skip: bool,
4486 inter: Option<InterInfo>,4486 inter: Option<InterInfo>,
4487- /// The luma palette this candidate is predicted from, `None` for
4488- /// every ordinary intra/inter candidate (the palette arm below).
4489- palette: Option<crate::tile::PaletteY>,
4490 }4487 }
4491 let mut best: Option<Candidate> = None;4488 let mut best: Option<Candidate> = None;
4492 let mut consider = |candidate: Candidate| {4489 let mut consider = |candidate: Candidate| {
@@ -4581,65 +4578,9 @@ fn search_inter_block(
4581 mode,4578 mode,
4582 skip: false,4579 skip: false,
4583 inter: None,4580 inter: None,
4584- palette: None,
4585 });4581 });
4586 }4582 }
4587 4583
4588- // The palette arm of this search -- the corner-cut `code_square` closed
4589- // for an inter frame's 16/8 intra leaves but this hand-rolled 32x32 loop
4590- // did not. A 32x32 intra block inside an inter frame codes the same
4591- // `palette_mode_info` syntax a key frame's does (tile.rs writes it from
4592- // `block.palette` at every one of the three sides already), so the only
4593- // thing missing was a candidate. Priced against the same `DC_PRED`
4594- // chroma trials the ordinary intra candidates reuse, and a palette block
4595- // is `DC_PRED` with `tx_depth` 0 by construction (its prediction is the
4596- // colour map, not the DC of its neighbours).
4597- if search.screen && crate::decode::palette_bsize_ctx(BLOCK).is_some() {
4598- let source: Vec<u8> = (y..y + BLOCK)
4599- .flat_map(|row| luma.source[row * luma.width + x..][..BLOCK].to_vec())
4600- .collect();
4601- for pal in palette_candidates(&source) {
4602- let n = usize::from(pal.size);
4603- let prediction: Vec<u8> = pal
4604- .map
4605- .iter()
4606- .map(|&i| pal.colors[usize::from(i).min(n - 1)] as u8)
4607- .collect();
4608- let luma_trial = luma.code_from_prediction(
4609- x,
4610- y,
4611- BLOCK,
4612- &prediction,
4613- false,
4614- search.base_q_idx,
4615- search.deadzone,
4616- luma_set,
4617- );
4618- let (u, v) = (u_trial.clone(), v_trial.clone());
4619- let cost = luma_trial.sse
4620- + u.sse
4621- + v.sse
4622- + search.lambda
4623- * (luma_trial.bits
4624- + u.bits
4625- + v.bits
4626- + mode_bits[DC_PRED as usize]
4627- + crate::tile::palette_bits(&pal, BLOCK)
4628- + skip_bits(false)
4629- + intra_inter_bits(false));
4630- consider(Candidate {
4631- cost,
4632- luma: luma_trial,
4633- u,
4634- v,
4635- mode: DC_PRED,
4636- skip: false,
4637- inter: None,
4638- palette: Some(pal),
4639- });
4640- }
4641- }
4642-
4643 // The reference frame buffer a spec decoder holds is exactly the true4584 // The reference frame buffer a spec decoder holds is exactly the true
4644 // (unpadded) coded extent -- a superblock whose partition stops early at4585 // (unpadded) coded extent -- a superblock whose partition stops early at
4645 // `has_cols`/`has_rows` never codes syntax for the padding columns/rows4586 // `has_cols`/`has_rows` never codes syntax for the padding columns/rows
@@ -4988,7 +4929,6 @@ fn search_inter_block(
4988 mode: DC_PRED,4929 mode: DC_PRED,
4989 skip,4930 skip,
4990 inter: Some(info),4931 inter: Some(info),
4991- palette: None,
4992 });4932 });
4993 }4933 }
4994 }4934 }
@@ -5086,7 +5026,6 @@ fn search_inter_block(
5086 mode: DC_PRED,5026 mode: DC_PRED,
5087 skip,5027 skip,
5088 inter: Some(info),5028 inter: Some(info),
5089- palette: None,
5090 });5029 });
5091 }5030 }
5092 }5031 }
@@ -5105,7 +5044,7 @@ fn search_inter_block(
5105 skip: best.skip,5044 skip: best.skip,
5106 inter: best.inter,5045 inter: best.inter,
5107 eight: None,5046 eight: None,
5108- palette: best.palette,5047+ palette: None,
5109 tx_depth: 0,5048 tx_depth: 0,
5110 },5049 },
5111 best.cost,5050 best.cost,