forge
Explore
Log in

Don't you dare go Hollow

The pricer instrument charged a 64x64 root's residual nothing

Browse files at this commit

9e0b6a8e2fdab2e450aa5978fc13581cd77e8221Ahmet Kaan GümüşParent: 0d77e3f
  • fix
    • the pricer instrument charged a 64x64 root's residual nothing
Show full message
fix(av1): the pricer instrument charged a 64x64 root's residual nothing

predicted_coeff_bits's Whole64 arm returned 0.0 unconditionally -- right
while the root was skip-only, wrong the moment it could code a residual.
It made predicted_coeff_bits_track_the_tile_the_writer_wrote read a
+51.65% drift on frame 1 of its clip (predicted 1017 bits against 2104
written); with the three prices spelled out (Luma64 + two Chroma32, the
same triple predicted_coeff_bits_sb already took for a key frame's whole
superblock) it reads +9.94% and the gate passes.

Test-only accountant, so no coded byte moves -- the SEARCH always priced
this arm correctly, through code_from_prediction's own coeff_bits.

Swept the rest of the Whole64 sites: the two remaining skip-only claims
were stale doc comments, corrected here.
crates/ec-av1/src/tile.rsmodified+25 -8
@@ -1770,9 +1770,10 @@ pub enum Quadrant {
1770 /// and the other three carry [`Covered`](Quadrant::Covered), so the1770 /// and the other three carry [`Covered`](Quadrant::Covered), so the
1771 /// per-32x32-entry shape the inter writer takes is unchanged.1771 /// per-32x32-entry shape the inter writer takes is unchanged.
1772 ///1772 ///
1773- /// The block is coded SKIP and single-reference: a 64x64 residual needs1773+ /// The block is single-reference; the writer refuses a compound one. It
1774- /// the forward TX_64X64 the encoder does not have (`transform.rs` tops1774+ /// may be skipped or carry a real residual -- one TX_64X64 luma transform
1775- /// out at 32x32), and the writer refuses anything else.1775+ /// whose coded quarter is a 32x32 level grid, and one TX_32X32 per chroma
1776+ /// plane (lane-tx64, `crate::encode::b64_residual`).
1776 Whole64(BlockCoeffs),1777 Whole64(BlockCoeffs),
1777 /// A quadrant a [`Whole64`](Quadrant::Whole64) at its superblock's1778 /// A quadrant a [`Whole64`](Quadrant::Whole64) at its superblock's
1778 /// top-left already coded; it carries no block of its own.1779 /// top-left already coded; it carries no block of its own.
@@ -4365,9 +4366,24 @@ pub(crate) fn predicted_coeff_bits(blocks: &[Quadrant], base_q_idx: u8) -> f64 {
4365 let side = match q {4366 let side = match q {
4366 Quadrant::Whole(_) => 32,4367 Quadrant::Whole(_) => 32,
4367 Quadrant::Split(_) => 16,4368 Quadrant::Split(_) => 16,
4368- // A 64x64 root is skip-only, so it carries no coefficient4369+ // lane-tx64: a 64x64 root that codes a residual pays for one
4369- // bits to predict at all (`Quadrant::Whole64`).4370+ // TX_64X64 luma transform (only the top-left 32x32 carries
4370- Quadrant::Whole64(_) | Quadrant::Covered => return 0.0,4371+ // coefficients) and one TX_32X32 per chroma plane -- the same
4372+ // three prices `predicted_coeff_bits_sb` takes for a key
4373+ // frame's whole superblock, and the same sets the writer's
4374+ // `Whole64` arm codes. `block_bits`'s table has no 64 row, so
4375+ // it is spelled out here.
4376+ Quadrant::Whole64(block) => {
4377+ return match block.skip {
4378+ true => 0.0,
4379+ false => {
4380+ coeff_bits(&dense(&block.luma, 32), TxbSet::Luma64, q_ctx, 0, 0)
4381+ + coeff_bits(&dense(&block.u, 32), TxbSet::Chroma32, q_ctx, 0, 0)
4382+ + coeff_bits(&dense(&block.v, 32), TxbSet::Chroma32, q_ctx, 0, 0)
4383+ }
4384+ };
4385+ }
4386+ Quadrant::Covered => return 0.0,
4371 };4387 };
4372 q.blocks().iter().map(|b| block_bits(b, side, q_ctx)).sum::<f64>()4388 q.blocks().iter().map(|b| block_bits(b, side, q_ctx)).sum::<f64>()
4373 })4389 })
@@ -5599,8 +5615,9 @@ pub(crate) fn sb_coeff_inter_frame_tile_cdfs(
5599 );5615 );
5600 // lane-b64: a superblock the search left WHOLE — one 64x64 block5616 // lane-b64: a superblock the search left WHOLE — one 64x64 block
5601 // at `PARTITION_NONE`, carried by its top-left quadrant's entry5617 // at `PARTITION_NONE`, carried by its top-left quadrant's entry
5602- // ([`Quadrant::Whole64`]). Coded skip and single-reference: no5618+ // ([`Quadrant::Whole64`]). Single-reference; skipped, or with a
5603- // residual, so no TX_64X64 coefficients and no `cdef_idx`.5619+ // real residual through `TxbSet::Luma64` + two `Chroma32`
5620+ // (lane-tx64).
5604 let sb64 = ((sb_r * 2) < rows && (sb_c * 2) < cols)5621 let sb64 = ((sb_r * 2) < rows && (sb_c * 2) < cols)
5605 .then(|| &blocks[((sb_r * 2) * cols + sb_c * 2) as usize])5622 .then(|| &blocks[((sb_r * 2) * cols + sb_c * 2) as usize])
5606 .and_then(|q| match q {5623 .and_then(|q| match q {