EOB_PT_512_CHROMA table + TxbSet::ChromaRect32x16 (lane-sbpart prep)
Browse files at this commit086ca56d064fa42b4e1107b4cc1fceeaa22b3568Parent: 84bcd82- feat
- EOB_PT_512_CHROMA table + TxbSet::ChromaRect32x16 (lane-sbpart prep)
2 changed files +46 -0
- crates/ec-av1/src/cdf.rs +14 -0
- crates/ec-av1/src/cdf_state.rs +32 -0
crates/ec-av1/src/cdf.rsmodified+14 -0
| @@ -266,6 +266,20 @@ pub const EOB_PT_128_CHROMA_Q3: [u16; 9] = [ | ||
| 266 | 266 | 24313, 26062, 28385, 30107, 31217, 31898, 32345, 32768, 0, |
| 267 | 267 | ]; |
| 268 | 268 | |
| 269 | +/// `av1_default_eob_multi512_cdfs[*][1][*]` (`token_cdfs.h:874-901`, | |
| 270 | +/// lane-sbpart): the end-of-block group of a CHROMA transform with 512 coded | |
| 271 | +/// positions -- what a 32x16/16x32 chroma transform has (the chroma plane of | |
| 272 | +/// an intra `PARTITION_HORZ`/`VERT` 64x32/32x64 superblock strip, whose luma | |
| 273 | +/// coefficients truncate to the 64x64-superblock's own 32x32 corner-scan | |
| 274 | +/// (`TxbSet::Luma64`) but whose *chroma* plane, at 32x16, is small enough | |
| 275 | +/// that no truncation applies). Unlike every other `EOB_PT_*` table here, | |
| 276 | +/// libaom's default is the exact same flat distribution at all four | |
| 277 | +/// q-contexts and both `eob_multi_size` selectors (`token_cdfs.h` rows), so | |
| 278 | +/// one constant covers every q-context -- no `_Q0`/`_Q1`/`_Q3` siblings. | |
| 279 | +pub const EOB_PT_512_CHROMA: [u16; 11] = [ | |
| 280 | + 3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0, | |
| 281 | +]; | |
| 282 | + | |
| 269 | 283 | /// `Default_Dc_Sign_Cdf[2][0]` (spec 9.4): the sign of a luma DC coefficient, |
| 270 | 284 | /// indexed by whether the neighbouring blocks' DC signs lean negative (1), |
| 271 | 285 | /// positive (2) or neither (0). |
crates/ec-av1/src/cdf_state.rsmodified+32 -0
| @@ -104,6 +104,19 @@ pub(crate) enum TxbSet { | ||
| 104 | 104 | /// the true 128-position [`crate::cdf::EOB_PT_128_CHROMA`] instead of |
| 105 | 105 | /// `Chroma16`'s 256-position one. |
| 106 | 106 | ChromaRect16x8, |
| 107 | + /// The chroma 32x16/16x32 transform of an intra `PARTITION_HORZ`/`VERT` | |
| 108 | + /// 64x32/32x64 SUPERBLOCK strip (lane-sbpart): `get_txsize_entropy_ctx` | |
| 109 | + /// (`(txsize_sqr_map + txsize_sqr_up_map + 1) >> 1`) resolves `TX_32X16` | |
| 110 | + /// to `TX_32X32`, so this shares every table | |
| 111 | + /// [`Chroma32`](TxbSet::Chroma32) does except `eob_pt`, which reads the | |
| 112 | + /// true 512-position [`crate::cdf::EOB_PT_512_CHROMA`] instead of | |
| 113 | + /// `Chroma32`'s 1024-position one. The SIBLING luma plane of this same | |
| 114 | + /// strip is genuinely truncated (64/32 > 32), so it reads | |
| 115 | + /// [`Luma64`](TxbSet::Luma64) instead -- `get_txsize_entropy_ctx(TX_64X32)` | |
| 116 | + /// resolves to `TX_64X64`, not `TX_32X32`, the two axes landing on | |
| 117 | + /// different existing sets is why this variant exists at all rather than | |
| 118 | + /// reusing [`LumaRect32x16`](TxbSet::LumaRect32x16)'s chroma sibling. | |
| 119 | + ChromaRect32x16, | |
| 107 | 120 | } |
| 108 | 121 | |
| 109 | 122 | /// The tables one transform block is coded with, borrowed from the state for |
| @@ -253,6 +266,9 @@ pub(crate) struct Cdfs { | ||
| 253 | 266 | /// The end-of-block group of a true 16x8/8x16 rect chroma transform |
| 254 | 267 | /// (lane-rectwire), see [`TxbSet::ChromaRect16x8`]. |
| 255 | 268 | pub eob_pt_128_chroma: [u16; 9], |
| 269 | + /// The end-of-block group of a true 32x16/16x32 rect CHROMA transform | |
| 270 | + /// (lane-sbpart), see [`TxbSet::ChromaRect32x16`]. | |
| 271 | + pub eob_pt_512_chroma: [u16; 11], | |
| 256 | 272 | /// The end-of-block offset bit, per table set. |
| 257 | 273 | pub eob_extra_luma_32: [[u16; 3]; 9], |
| 258 | 274 | /// The same, for a 64x64 luma transform. |
| @@ -582,6 +598,7 @@ impl Cdfs { | ||
| 582 | 598 | reset1(&mut self.eob_pt_256_chroma); |
| 583 | 599 | reset1(&mut self.eob_pt_512_luma); |
| 584 | 600 | reset1(&mut self.eob_pt_128_chroma); |
| 601 | + reset1(&mut self.eob_pt_512_chroma); | |
| 585 | 602 | reset2(&mut self.eob_extra_luma_32); |
| 586 | 603 | reset2(&mut self.eob_extra_luma_64); |
| 587 | 604 | reset2(&mut self.eob_extra_chroma_16); |
| @@ -960,6 +977,9 @@ impl Cdfs { | ||
| 960 | 977 | cdf::EOB_PT_128_CHROMA, |
| 961 | 978 | cdf::EOB_PT_128_CHROMA_Q3, |
| 962 | 979 | ), |
| 980 | + // Flat default at every q-context (see the constant's own doc | |
| 981 | + // comment) -- no `pick()` needed. | |
| 982 | + eob_pt_512_chroma: cdf::EOB_PT_512_CHROMA, | |
| 963 | 983 | eob_extra_luma_32: pick( |
| 964 | 984 | q_ctx, |
| 965 | 985 | cdf::EOB_EXTRA_LUMA_32_Q0, |
| @@ -1348,6 +1368,18 @@ impl Cdfs { | ||
| 1348 | 1368 | tx_type: None, |
| 1349 | 1369 | eob_pt_class1: None, |
| 1350 | 1370 | }, |
| 1371 | + TxbSet::ChromaRect32x16 => TxbTables { | |
| 1372 | + side: 32, | |
| 1373 | + txb_skip: &mut self.txb_skip_chroma_32, | |
| 1374 | + eob_pt: &mut self.eob_pt_512_chroma, | |
| 1375 | + eob_extra: &mut self.eob_extra_chroma_32, | |
| 1376 | + base: &mut self.base_chroma_32, | |
| 1377 | + base_eob: &mut self.base_eob_chroma_32, | |
| 1378 | + br: &mut self.br_chroma_32, | |
| 1379 | + dc_sign: &mut self.dc_sign_chroma, | |
| 1380 | + tx_type: None, | |
| 1381 | + eob_pt_class1: None, | |
| 1382 | + }, | |
| 1351 | 1383 | } |
| 1352 | 1384 | } |
| 1353 | 1385 | } |