forge
Explore
Log in

Don't you dare go Hollow

Correct the r4 chroma-granularity assumption for 8x8 leaves

Browse files at this commit

b91e4ecf7a2ec70e9d36330272eccbe02cad3cb9Ahmet Kaan GümüşParent: dc6d790
  • fix
    • correct the r4 chroma-granularity assumption for 8x8 leaves
Show full message
fix(av1): correct the r4 chroma-granularity assumption for 8x8 leaves

libaom's is_chroma_reference (av1_common_int.h) is unconditionally true
for bsize >= BLOCK_8X8 (4:2:0 or not), so a split 16x16's 8x8 children
each code their own chroma at 4x4 -- chroma does not stay at the
parent's 8x8 granularity as the r4 doc comments claimed (never checked
against a real decoder). Corrects TxbSet::Chroma4's doc and flips
code_square's still-unreached side==8 branch to the chroma set a real
caller will need, so the next lane does not inherit a wrong premise.

No behavior change (134/0/9, unchanged): the branch has no caller yet.
crates/ec-av1/src/cdf_state.rsmodified+9 -4
@@ -42,10 +42,15 @@ pub(crate) enum TxbSet {
4242 Luma8,
4343 /// The 8x8 transform of a chroma plane of a 16x16 block.
4444 Chroma8,
45- /// The 4x4 transform of a chroma plane of an 8x8 leaf (lane-av1-rect):
46- /// per `get_tx_size` for chroma, this stays 8x8 at the *parent* 16x16's
47- /// granularity today (see `Chroma8`), so this variant is currently unused
48- /// but shipped for when a chroma-follows-luma split is wired.
45+ /// The 4x4 transform of a chroma plane of an 8x8 leaf (lane-av1-rect).
46+ /// r5 correction: libaom's `is_chroma_reference` (`av1_common_int.h`) is
47+ /// unconditionally true for `bsize >= BLOCK_8X8`, so chroma *does* follow
48+ /// luma all the way down to 8x8 — it is coded once per 8x8 leaf, not once
49+ /// per parent 16x16 (that "stays at the parent's Chroma8 granularity"
50+ /// framing this doc carried through r4 was never checked against a real
51+ /// decoder and is wrong; only `BLOCK_4X4`/`4X8`/`8X4`, one mi-unit wide or
52+ /// high, get the "last sub-block only" chroma-merge treatment). A real
53+ /// writer for the straddling-16x16 case must use this variant per leaf.
4954 Chroma4,
5055 /// The 16x16 transform of a chroma plane of a 32x32 block.
5156 Chroma16,
crates/ec-av1/src/encode.rsmodified+8 -5
@@ -1058,11 +1058,14 @@ fn code_square(
10581058 let (luma_set, chroma_set) = if side == BLOCK {
10591059 (TxbSet::Luma32, TxbSet::Chroma16)
10601060 } else if side == 8 {
1061- // An 8x8 leaf under a straddling 16x16 (lane-av1-rect): chroma of an
1062- // 8x8 luma leaf still codes at its parent 16x16's granularity (see
1063- // `TxbSet::Chroma4`'s doc comment), so the chroma set stays Chroma8
1064- // even though luma has split down to 8x8.
1065- (TxbSet::Luma8, TxbSet::Chroma8)
1061+ // An 8x8 leaf under a straddling 16x16 (lane-av1-rect). r5 correction:
1062+ // `TxbSet::Chroma4`'s doc now has the checked spec fact -- chroma is
1063+ // `is_chroma_reference` at every BLOCK_8X8, so it is coded per leaf at
1064+ // 4x4, not once at the parent's 8x8. No caller passes `side == 8` yet
1065+ // (this branch is still unreached), so leaving `Chroma8` here would
1066+ // silently wire the wrong table the moment one does; `Chroma4` is
1067+ // what a real caller needs.
1068+ (TxbSet::Luma8, TxbSet::Chroma4)
10661069 } else {
10671070 (TxbSet::Luma16, TxbSet::Chroma8)
10681071 };