forge
Explore
Log in

Don't you dare go Hollow

RDOQ walked the 2D zigzag's tail on a 1-D transform unit

Browse files at this commit

fd6f585ccec1aee2ba997f0653da19b72c138c38Ahmet Kaan GümüşParent: dab7a9c
  • fix
    • RDOQ walked the 2D zigzag's tail on a 1-D transform unit
Show full message
fix(av1): RDOQ walked the 2D zigzag's tail on a 1-D transform unit

Every candidate was already priced through the class-aware writer, so no
decision was wrong; but the pass spends its budget from the tail of the
scan backwards, and for a V_DCT/H_DCT unit the tail of the 2D zigzag is
not the tail of the Mrow/Mcol scan its eob is measured in. It now walks
the unit's own scan.
crates/ec-av1/src/tile.rsmodified+13 -1
@@ -4959,7 +4959,19 @@ pub(crate) fn rdoq(
49594959 // cannot cost two hundred re-codings.
49604960 let mut budget = rdoq_budget();
49614961 let max_level = rdoq_max_level();
4962- for &position in scan_of(coded).iter().rev() {
4962+ // lane-txw: the tail this walks back from is the tail of the unit's OWN
4963+ // scan -- a `V_DCT`/`H_DCT` unit is coded in `Mrow_Scan`/`Mcol_Scan`, so
4964+ // the 2D zigzag's last positions are not the ones whose removal shortens
4965+ // its eob. Every candidate is still priced through the class-aware writer
4966+ // ([`write_coeffs`]), so this changes which positions the budget reaches,
4967+ // never whether a decision is right.
4968+ let class = crate::decode::TxClass::of(tx_type);
4969+ let order: &[u16] = if class == crate::decode::TxClass::TwoD {
4970+ scan_of(coded)
4971+ } else {
4972+ class_scan_of(coded, class)
4973+ };
4974+ for &position in order.iter().rev() {
49634975 if budget == 0 {
49644976 break;
49654977 }