Eob_pt class-1 CDF row existed only for two luma sizes -- every chroma (and 16x16+) 1D-class transform read the 2D table
Browse files at this commitd1963fa545dc53cd31ad5ac971efd278690971cbParent: 154097b- fix
- eob_pt class-1 CDF row existed only for two luma sizes -- every chroma (and 16x16+) 1D-class transform read the 2D table
5 changed files +291 -36
- crates/ec-av1/examples/decode_probe.rs +15 -1
- crates/ec-av1/src/cdf.rs +61 -0
- crates/ec-av1/src/cdf_state.rs +104 -14
- crates/ec-av1/src/decode.rs +45 -21
- lanes/gmaffine-r4.report.md +66 -0
crates/ec-av1/examples/decode_probe.rsmodified+15 -1
| @@ -32,7 +32,21 @@ fn main() { | ||
| 32 | 32 | Ok(frames) if frames.is_empty() => { |
| 33 | 33 | println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); |
| 34 | 34 | } |
| 35 | - Ok(frames) => println!("OK: {} frames decoded", frames.len()), | |
| 35 | + Ok(frames) => { | |
| 36 | + // lane-gmaffine r4: `EC_PROBE_DUMP=<path>` writes the decoded | |
| 37 | + // planes as raw 8-bit I420 so a pixel diff against ffmpeg can | |
| 38 | + // name the mismatching block without a test harness. | |
| 39 | + if let Ok(dump) = std::env::var("EC_PROBE_DUMP") { | |
| 40 | + let mut out = Vec::new(); | |
| 41 | + for f in &frames { | |
| 42 | + for p in [&f.y, &f.u, &f.v] { | |
| 43 | + out.extend(p.iter().map(|&v| v as u8)); | |
| 44 | + } | |
| 45 | + } | |
| 46 | + std::fs::write(&dump, out).expect("writing EC_PROBE_DUMP"); | |
| 47 | + } | |
| 48 | + println!("OK: {} frames decoded", frames.len()) | |
| 49 | + } | |
| 36 | 50 | Err(e) => println!("REFUSED: {e}"), |
| 37 | 51 | } |
| 38 | 52 | } |
crates/ec-av1/src/cdf.rsmodified+61 -0
| @@ -4996,3 +4996,64 @@ pub const INTRA_TX_TYPE_SET1_4: [[u16; 8]; 13] = [ | ||
| 4996 | 4996 | [277, 4369, 5255, 8905, 16465, 22271, 32768, 0], |
| 4997 | 4997 | [3409, 5436, 10599, 15599, 19687, 24040, 32768, 0], |
| 4998 | 4998 | ]; |
| 4999 | + | |
| 5000 | +// lane-gmaffine r4: the `TX_CLASS_HORIZ`/`TX_CLASS_VERT` (`eob_multi_ctx == 1`) | |
| 5001 | +// half of libaom's `av1_default_eob_multi*_cdfs[q][plane][2]` for every eob_pt | |
| 5002 | +// table that carried only its 2D row -- an inter block's chroma inherits the | |
| 5003 | +// colocated luma `tx_type` verbatim, so a 1D-class chroma TU is routine and | |
| 5004 | +// used to read the 2D CDF (right value, wrong interval). | |
| 5005 | + | |
| 5006 | +/// `EOB_PT_16_CHROMA`'s class-1 sibling (`av1_default_eob_multi16_cdfs[q][1][1]`). | |
| 5007 | +pub const EOB_PT_16_CHROMA_CLASS1_Q0: [u16; 6] = [1904, 3354, 7763, 14647, 32768, 0]; | |
| 5008 | +pub const EOB_PT_16_CHROMA_CLASS1_Q1: [u16; 6] = [2497, 4096, 8866, 16993, 32768, 0]; | |
| 5009 | +pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0]; | |
| 5010 | +pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0]; | |
| 5011 | + | |
| 5012 | +/// `EOB_PT_64_CHROMA`'s class-1 sibling (`av1_default_eob_multi64_cdfs[q][1][1]`). | |
| 5013 | +pub const EOB_PT_64_CHROMA_CLASS1_Q0: [u16; 8] = [1563, 2700, 4876, 10911, 14706, 22480, 32768, 0]; | |
| 5014 | +pub const EOB_PT_64_CHROMA_CLASS1_Q1: [u16; 8] = [1923, 3127, 5867, 9703, 14277, 27100, 32768, 0]; | |
| 5015 | +pub const EOB_PT_64_CHROMA_CLASS1: [u16; 8] = [4034, 6290, 10235, 14982, 21214, 28491, 32768, 0]; | |
| 5016 | +pub const EOB_PT_64_CHROMA_CLASS1_Q3: [u16; 8] = [8726, 12378, 19409, 26450, 30038, 32462, 32768, 0]; | |
| 5017 | + | |
| 5018 | +/// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`). | |
| 5019 | +pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0]; | |
| 5020 | +pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0]; | |
| 5021 | +pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] = [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0]; | |
| 5022 | +pub const EOB_PT_128_CHROMA_CLASS1_Q3: [u16; 9] = [9165, 13282, 21150, 30286, 31894, 32571, 32712, 32768, 0]; | |
| 5023 | + | |
| 5024 | +/// `EOB_PT_256_LUMA`'s class-1 sibling (`av1_default_eob_multi256_cdfs[q][0][1]`). | |
| 5025 | +pub const EOB_PT_256_LUMA_CLASS1_Q0: [u16; 10] = [998, 1850, 2998, 5604, 17341, 19888, 22899, 25583, 32768, 0]; | |
| 5026 | +pub const EOB_PT_256_LUMA_CLASS1_Q1: [u16; 10] = [399, 1019, 1749, 3038, 10444, 15546, 22739, 27294, 32768, 0]; | |
| 5027 | +pub const EOB_PT_256_LUMA_CLASS1: [u16; 10] = [1084, 2358, 3488, 5122, 11483, 18103, 26023, 29799, 32768, 0]; | |
| 5028 | +pub const EOB_PT_256_LUMA_CLASS1_Q3: [u16; 10] = [2453, 4474, 6307, 8777, 16474, 22975, 29000, 31547, 32768, 0]; | |
| 5029 | + | |
| 5030 | +/// `EOB_PT_256_CHROMA`'s class-1 sibling (`av1_default_eob_multi256_cdfs[q][1][1]`). | |
| 5031 | +pub const EOB_PT_256_CHROMA_CLASS1_Q0: [u16; 10] = [2203, 4130, 7435, 10739, 20652, 23681, 25609, 27261, 32768, 0]; | |
| 5032 | +pub const EOB_PT_256_CHROMA_CLASS1_Q1: [u16; 10] = [1674, 3252, 5734, 10159, 22397, 23802, 24821, 30940, 32768, 0]; | |
| 5033 | +pub const EOB_PT_256_CHROMA_CLASS1: [u16; 10] = [6571, 9610, 15516, 21826, 29092, 30829, 31842, 32708, 32768, 0]; | |
| 5034 | +pub const EOB_PT_256_CHROMA_CLASS1_Q3: [u16; 10] = [9998, 17661, 25178, 28097, 31308, 32038, 32403, 32695, 32768, 0]; | |
| 5035 | + | |
| 5036 | +/// `EOB_PT_512_LUMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][0][1]`). | |
| 5037 | +pub const EOB_PT_512_LUMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5038 | +pub const EOB_PT_512_LUMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5039 | +pub const EOB_PT_512_LUMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5040 | +pub const EOB_PT_512_LUMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5041 | + | |
| 5042 | +/// `EOB_PT_512_CHROMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][1][1]`). | |
| 5043 | +pub const EOB_PT_512_CHROMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5044 | +pub const EOB_PT_512_CHROMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5045 | +pub const EOB_PT_512_CHROMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5046 | +pub const EOB_PT_512_CHROMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0]; | |
| 5047 | + | |
| 5048 | +/// `EOB_PT_1024_LUMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][0][1]`). | |
| 5049 | +pub const EOB_PT_1024_LUMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5050 | +pub const EOB_PT_1024_LUMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5051 | +pub const EOB_PT_1024_LUMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5052 | +pub const EOB_PT_1024_LUMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5053 | + | |
| 5054 | +/// `EOB_PT_1024_CHROMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][1][1]`). | |
| 5055 | +pub const EOB_PT_1024_CHROMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5056 | +pub const EOB_PT_1024_CHROMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5057 | +pub const EOB_PT_1024_CHROMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5058 | +pub const EOB_PT_1024_CHROMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0]; | |
| 5059 | + |
crates/ec-av1/src/cdf_state.rsmodified+104 -14
| @@ -200,6 +200,24 @@ pub(crate) struct Cdfs { | ||
| 200 | 200 | pub eob_pt_16_luma_class1: [u16; 6], |
| 201 | 201 | /// `eob_pt_64_luma`'s class-1 sibling (r5), see `eob_pt_16_luma_class1`. |
| 202 | 202 | pub eob_pt_64_luma_class1: [u16; 8], |
| 203 | + /// `eob_pt_16_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 204 | + pub eob_pt_16_chroma_class1: [u16; 6], | |
| 205 | + /// `eob_pt_64_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 206 | + pub eob_pt_64_chroma_class1: [u16; 8], | |
| 207 | + /// `eob_pt_128_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 208 | + pub eob_pt_128_chroma_class1: [u16; 9], | |
| 209 | + /// `eob_pt_256_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 210 | + pub eob_pt_256_luma_class1: [u16; 10], | |
| 211 | + /// `eob_pt_256_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 212 | + pub eob_pt_256_chroma_class1: [u16; 10], | |
| 213 | + /// `eob_pt_512_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 214 | + pub eob_pt_512_luma_class1: [u16; 11], | |
| 215 | + /// `eob_pt_512_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 216 | + pub eob_pt_512_chroma_class1: [u16; 11], | |
| 217 | + /// `eob_pt_1024_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 218 | + pub eob_pt_1024_luma_class1: [u16; 12], | |
| 219 | + /// `eob_pt_1024_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`. | |
| 220 | + pub eob_pt_1024_chroma_class1: [u16; 12], | |
| 203 | 221 | /// The end-of-block offset bit of a 16x16 luma transform. |
| 204 | 222 | pub eob_extra_luma_16: [[u16; 3]; 9], |
| 205 | 223 | /// The same, for an 8x8 luma transform. |
| @@ -592,6 +610,15 @@ impl Cdfs { | ||
| 592 | 610 | reset1(&mut self.eob_pt_16_luma); |
| 593 | 611 | reset1(&mut self.eob_pt_16_luma_class1); |
| 594 | 612 | reset1(&mut self.eob_pt_64_luma_class1); |
| 613 | + reset1(&mut self.eob_pt_16_chroma_class1); | |
| 614 | + reset1(&mut self.eob_pt_64_chroma_class1); | |
| 615 | + reset1(&mut self.eob_pt_128_chroma_class1); | |
| 616 | + reset1(&mut self.eob_pt_256_luma_class1); | |
| 617 | + reset1(&mut self.eob_pt_256_chroma_class1); | |
| 618 | + reset1(&mut self.eob_pt_512_luma_class1); | |
| 619 | + reset1(&mut self.eob_pt_512_chroma_class1); | |
| 620 | + reset1(&mut self.eob_pt_1024_luma_class1); | |
| 621 | + reset1(&mut self.eob_pt_1024_chroma_class1); | |
| 595 | 622 | reset2(&mut self.eob_extra_luma_16); |
| 596 | 623 | reset2(&mut self.eob_extra_luma_8); |
| 597 | 624 | reset2(&mut self.eob_extra_luma_4); |
| @@ -805,6 +832,69 @@ impl Cdfs { | ||
| 805 | 832 | cdf::EOB_PT_64_LUMA_CLASS1, |
| 806 | 833 | cdf::EOB_PT_64_LUMA_CLASS1_Q3, |
| 807 | 834 | ), |
| 835 | + eob_pt_16_chroma_class1: pick( | |
| 836 | + q_ctx, | |
| 837 | + cdf::EOB_PT_16_CHROMA_CLASS1_Q0, | |
| 838 | + cdf::EOB_PT_16_CHROMA_CLASS1_Q1, | |
| 839 | + cdf::EOB_PT_16_CHROMA_CLASS1, | |
| 840 | + cdf::EOB_PT_16_CHROMA_CLASS1_Q3, | |
| 841 | + ), | |
| 842 | + eob_pt_64_chroma_class1: pick( | |
| 843 | + q_ctx, | |
| 844 | + cdf::EOB_PT_64_CHROMA_CLASS1_Q0, | |
| 845 | + cdf::EOB_PT_64_CHROMA_CLASS1_Q1, | |
| 846 | + cdf::EOB_PT_64_CHROMA_CLASS1, | |
| 847 | + cdf::EOB_PT_64_CHROMA_CLASS1_Q3, | |
| 848 | + ), | |
| 849 | + eob_pt_128_chroma_class1: pick( | |
| 850 | + q_ctx, | |
| 851 | + cdf::EOB_PT_128_CHROMA_CLASS1_Q0, | |
| 852 | + cdf::EOB_PT_128_CHROMA_CLASS1_Q1, | |
| 853 | + cdf::EOB_PT_128_CHROMA_CLASS1, | |
| 854 | + cdf::EOB_PT_128_CHROMA_CLASS1_Q3, | |
| 855 | + ), | |
| 856 | + eob_pt_256_luma_class1: pick( | |
| 857 | + q_ctx, | |
| 858 | + cdf::EOB_PT_256_LUMA_CLASS1_Q0, | |
| 859 | + cdf::EOB_PT_256_LUMA_CLASS1_Q1, | |
| 860 | + cdf::EOB_PT_256_LUMA_CLASS1, | |
| 861 | + cdf::EOB_PT_256_LUMA_CLASS1_Q3, | |
| 862 | + ), | |
| 863 | + eob_pt_256_chroma_class1: pick( | |
| 864 | + q_ctx, | |
| 865 | + cdf::EOB_PT_256_CHROMA_CLASS1_Q0, | |
| 866 | + cdf::EOB_PT_256_CHROMA_CLASS1_Q1, | |
| 867 | + cdf::EOB_PT_256_CHROMA_CLASS1, | |
| 868 | + cdf::EOB_PT_256_CHROMA_CLASS1_Q3, | |
| 869 | + ), | |
| 870 | + eob_pt_512_luma_class1: pick( | |
| 871 | + q_ctx, | |
| 872 | + cdf::EOB_PT_512_LUMA_CLASS1_Q0, | |
| 873 | + cdf::EOB_PT_512_LUMA_CLASS1_Q1, | |
| 874 | + cdf::EOB_PT_512_LUMA_CLASS1, | |
| 875 | + cdf::EOB_PT_512_LUMA_CLASS1_Q3, | |
| 876 | + ), | |
| 877 | + eob_pt_512_chroma_class1: pick( | |
| 878 | + q_ctx, | |
| 879 | + cdf::EOB_PT_512_CHROMA_CLASS1_Q0, | |
| 880 | + cdf::EOB_PT_512_CHROMA_CLASS1_Q1, | |
| 881 | + cdf::EOB_PT_512_CHROMA_CLASS1, | |
| 882 | + cdf::EOB_PT_512_CHROMA_CLASS1_Q3, | |
| 883 | + ), | |
| 884 | + eob_pt_1024_luma_class1: pick( | |
| 885 | + q_ctx, | |
| 886 | + cdf::EOB_PT_1024_LUMA_CLASS1_Q0, | |
| 887 | + cdf::EOB_PT_1024_LUMA_CLASS1_Q1, | |
| 888 | + cdf::EOB_PT_1024_LUMA_CLASS1, | |
| 889 | + cdf::EOB_PT_1024_LUMA_CLASS1_Q3, | |
| 890 | + ), | |
| 891 | + eob_pt_1024_chroma_class1: pick( | |
| 892 | + q_ctx, | |
| 893 | + cdf::EOB_PT_1024_CHROMA_CLASS1_Q0, | |
| 894 | + cdf::EOB_PT_1024_CHROMA_CLASS1_Q1, | |
| 895 | + cdf::EOB_PT_1024_CHROMA_CLASS1, | |
| 896 | + cdf::EOB_PT_1024_CHROMA_CLASS1_Q3, | |
| 897 | + ), | |
| 808 | 898 | eob_extra_luma_16: pick( |
| 809 | 899 | q_ctx, |
| 810 | 900 | cdf::EOB_EXTRA_LUMA_16_Q0, |
| @@ -1191,7 +1281,7 @@ impl Cdfs { | ||
| 1191 | 1281 | br: &mut self.br_luma_32, |
| 1192 | 1282 | dc_sign: &mut self.dc_sign_luma, |
| 1193 | 1283 | tx_type: None, |
| 1194 | - eob_pt_class1: None, | |
| 1284 | + eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1), | |
| 1195 | 1285 | }, |
| 1196 | 1286 | // lane-comppin r4 (REVERTED, see r4's own commit message): |
| 1197 | 1287 | // `Some(inter_tx_type_32)` looked wrong against aomdec's 32x32 |
| @@ -1215,7 +1305,7 @@ impl Cdfs { | ||
| 1215 | 1305 | br: &mut self.br_luma_32, |
| 1216 | 1306 | dc_sign: &mut self.dc_sign_luma, |
| 1217 | 1307 | tx_type: Some(self.inter_tx_type_32.as_mut_slice()), |
| 1218 | - eob_pt_class1: None, | |
| 1308 | + eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1), | |
| 1219 | 1309 | }, |
| 1220 | 1310 | TxbSet::Luma64 => TxbTables { |
| 1221 | 1311 | side: 32, |
| @@ -1227,7 +1317,7 @@ impl Cdfs { | ||
| 1227 | 1317 | br: &mut self.br_luma_32, |
| 1228 | 1318 | dc_sign: &mut self.dc_sign_luma, |
| 1229 | 1319 | tx_type: None, |
| 1230 | - eob_pt_class1: None, | |
| 1320 | + eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1), | |
| 1231 | 1321 | }, |
| 1232 | 1322 | TxbSet::Luma16 => TxbTables { |
| 1233 | 1323 | side: 16, |
| @@ -1239,7 +1329,7 @@ impl Cdfs { | ||
| 1239 | 1329 | br: &mut self.br_luma_16, |
| 1240 | 1330 | dc_sign: &mut self.dc_sign_luma, |
| 1241 | 1331 | tx_type: Some(self.intra_tx_type_16[mode].as_mut_slice()), |
| 1242 | - eob_pt_class1: None, | |
| 1332 | + eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), | |
| 1243 | 1333 | }, |
| 1244 | 1334 | TxbSet::Luma16Inter => TxbTables { |
| 1245 | 1335 | side: 16, |
| @@ -1251,7 +1341,7 @@ impl Cdfs { | ||
| 1251 | 1341 | br: &mut self.br_luma_16, |
| 1252 | 1342 | dc_sign: &mut self.dc_sign_luma, |
| 1253 | 1343 | tx_type: Some(self.inter_tx_type_16.as_mut_slice()), |
| 1254 | - eob_pt_class1: None, | |
| 1344 | + eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), | |
| 1255 | 1345 | }, |
| 1256 | 1346 | TxbSet::Luma16InterSet1 => TxbTables { |
| 1257 | 1347 | side: 16, |
| @@ -1263,7 +1353,7 @@ impl Cdfs { | ||
| 1263 | 1353 | br: &mut self.br_luma_16, |
| 1264 | 1354 | dc_sign: &mut self.dc_sign_luma, |
| 1265 | 1355 | tx_type: Some(self.inter_tx_type_16_set2.as_mut_slice()), |
| 1266 | - eob_pt_class1: None, | |
| 1356 | + eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), | |
| 1267 | 1357 | }, |
| 1268 | 1358 | TxbSet::Luma8 => TxbTables { |
| 1269 | 1359 | side: 8, |
| @@ -1323,7 +1413,7 @@ impl Cdfs { | ||
| 1323 | 1413 | br: &mut self.br_luma_8, |
| 1324 | 1414 | dc_sign: &mut self.dc_sign_luma, |
| 1325 | 1415 | tx_type: Some(self.inter_tx_type_8.as_mut_slice()), |
| 1326 | - eob_pt_class1: None, | |
| 1416 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | |
| 1327 | 1417 | }, |
| 1328 | 1418 | TxbSet::Luma8InterSet1 => TxbTables { |
| 1329 | 1419 | side: 8, |
| @@ -1347,7 +1437,7 @@ impl Cdfs { | ||
| 1347 | 1437 | br: &mut self.br_chroma_8, |
| 1348 | 1438 | dc_sign: &mut self.dc_sign_chroma, |
| 1349 | 1439 | tx_type: None, |
| 1350 | - eob_pt_class1: None, | |
| 1440 | + eob_pt_class1: Some(&mut self.eob_pt_64_chroma_class1), | |
| 1351 | 1441 | }, |
| 1352 | 1442 | TxbSet::Chroma4 => TxbTables { |
| 1353 | 1443 | side: 4, |
| @@ -1359,7 +1449,7 @@ impl Cdfs { | ||
| 1359 | 1449 | br: &mut self.br_chroma_4, |
| 1360 | 1450 | dc_sign: &mut self.dc_sign_chroma, |
| 1361 | 1451 | tx_type: None, |
| 1362 | - eob_pt_class1: None, | |
| 1452 | + eob_pt_class1: Some(&mut self.eob_pt_16_chroma_class1), | |
| 1363 | 1453 | }, |
| 1364 | 1454 | TxbSet::Chroma16 => TxbTables { |
| 1365 | 1455 | side: 16, |
| @@ -1371,7 +1461,7 @@ impl Cdfs { | ||
| 1371 | 1461 | br: &mut self.br_chroma_16, |
| 1372 | 1462 | dc_sign: &mut self.dc_sign_chroma, |
| 1373 | 1463 | tx_type: None, |
| 1374 | - eob_pt_class1: None, | |
| 1464 | + eob_pt_class1: Some(&mut self.eob_pt_256_chroma_class1), | |
| 1375 | 1465 | }, |
| 1376 | 1466 | TxbSet::Chroma32 => TxbTables { |
| 1377 | 1467 | side: 32, |
| @@ -1383,7 +1473,7 @@ impl Cdfs { | ||
| 1383 | 1473 | br: &mut self.br_chroma_32, |
| 1384 | 1474 | dc_sign: &mut self.dc_sign_chroma, |
| 1385 | 1475 | tx_type: None, |
| 1386 | - eob_pt_class1: None, | |
| 1476 | + eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1), | |
| 1387 | 1477 | }, |
| 1388 | 1478 | TxbSet::LumaRect32x16 => TxbTables { |
| 1389 | 1479 | side: 32, |
| @@ -1395,7 +1485,7 @@ impl Cdfs { | ||
| 1395 | 1485 | br: &mut self.br_luma_32, |
| 1396 | 1486 | dc_sign: &mut self.dc_sign_luma, |
| 1397 | 1487 | tx_type: None, |
| 1398 | - eob_pt_class1: None, | |
| 1488 | + eob_pt_class1: Some(&mut self.eob_pt_512_luma_class1), | |
| 1399 | 1489 | }, |
| 1400 | 1490 | TxbSet::ChromaRect16x8 => TxbTables { |
| 1401 | 1491 | side: 16, |
| @@ -1407,7 +1497,7 @@ impl Cdfs { | ||
| 1407 | 1497 | br: &mut self.br_chroma_16, |
| 1408 | 1498 | dc_sign: &mut self.dc_sign_chroma, |
| 1409 | 1499 | tx_type: None, |
| 1410 | - eob_pt_class1: None, | |
| 1500 | + eob_pt_class1: Some(&mut self.eob_pt_128_chroma_class1), | |
| 1411 | 1501 | }, |
| 1412 | 1502 | TxbSet::ChromaRect32x16 => TxbTables { |
| 1413 | 1503 | side: 32, |
| @@ -1419,7 +1509,7 @@ impl Cdfs { | ||
| 1419 | 1509 | br: &mut self.br_chroma_32, |
| 1420 | 1510 | dc_sign: &mut self.dc_sign_chroma, |
| 1421 | 1511 | tx_type: None, |
| 1422 | - eob_pt_class1: None, | |
| 1512 | + eob_pt_class1: Some(&mut self.eob_pt_512_chroma_class1), | |
| 1423 | 1513 | }, |
| 1424 | 1514 | } |
| 1425 | 1515 | } |
crates/ec-av1/src/decode.rsmodified+45 -21
| @@ -1562,7 +1562,8 @@ fn read_coeffs( | ||
| 1562 | 1562 | let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some(); |
| 1563 | 1563 | if ec_trace_coeff { |
| 1564 | 1564 | let (rng, _) = dec.debug_state(); |
| 1565 | - eprintln!("EC_COEFF_STEP tag=eob eob={eob} rng={rng}"); | |
| 1565 | + let cls = match class { TxClass::TwoD => "2d", TxClass::Horiz => "horiz", TxClass::Vert => "vert" }; | |
| 1566 | + eprintln!("EC_COEFF_STEP tag=eob eob={eob} tx={tx_type:?} class={cls} rng={rng}"); | |
| 1566 | 1567 | } |
| 1567 | 1568 | let class_scan; |
| 1568 | 1569 | let scan: &[u16] = if class == TxClass::TwoD { |
| @@ -10393,16 +10394,25 @@ fn decode_inter_block( | ||
| 10393 | 10394 | py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32, |
| 10394 | 10395 | side as i32, side as i32, 0, 0, |
| 10395 | 10396 | ); |
| 10396 | - crate::warp::warp_affine( | |
| 10397 | - params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32, | |
| 10398 | - pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32, | |
| 10399 | - chroma_side as i32, chroma_side as i32, 1, 1, | |
| 10400 | - ); | |
| 10401 | - crate::warp::warp_affine( | |
| 10402 | - params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32, | |
| 10403 | - pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32, | |
| 10404 | - chroma_side as i32, chroma_side as i32, 1, 1, | |
| 10405 | - ); | |
| 10397 | + // libaom `av1_init_warp_params` (reconinter.c): warp is | |
| 10398 | + // per PLANE and bails out at `block_width < 8 || | |
| 10399 | + // block_height < 8`, so a plane whose own block is under | |
| 10400 | + // 8x8 keeps the translational prediction built above -- | |
| 10401 | + // in 420 that is every chroma plane of a luma block below | |
| 10402 | + // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few | |
| 10403 | + // levels on both 8x8-leaf motion gates). | |
| 10404 | + if chroma_side >= 8 { | |
| 10405 | + crate::warp::warp_affine( | |
| 10406 | + params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32, | |
| 10407 | + pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32, | |
| 10408 | + chroma_side as i32, chroma_side as i32, 1, 1, | |
| 10409 | + ); | |
| 10410 | + crate::warp::warp_affine( | |
| 10411 | + params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32, | |
| 10412 | + pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32, | |
| 10413 | + chroma_side as i32, chroma_side as i32, 1, 1, | |
| 10414 | + ); | |
| 10415 | + } | |
| 10406 | 10416 | } |
| 10407 | 10417 | |
| 10408 | 10418 | if obmc_selected { |
| @@ -11750,6 +11760,14 @@ fn decode_inter_block8( | ||
| 11750 | 11760 | AFFINE_GM_HITS.with(|c| c.set(c.get() + 1)); |
| 11751 | 11761 | } |
| 11752 | 11762 | } |
| 11763 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 11764 | + eprintln!( | |
| 11765 | + "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}", | |
| 11766 | + leaf_mi.0, | |
| 11767 | + leaf_mi.1, | |
| 11768 | + warp_params.is_some(), | |
| 11769 | + ); | |
| 11770 | + } | |
| 11753 | 11771 | for dr in 0..2 { |
| 11754 | 11772 | for dc in 0..2 { |
| 11755 | 11773 | grid.set( |
| @@ -11826,16 +11844,22 @@ fn decode_inter_block8( | ||
| 11826 | 11844 | sref_y.width as i32, &mut pred_y, px as i32, py as i32, SIDE as i32, |
| 11827 | 11845 | SIDE as i32, SIDE as i32, 0, 0, |
| 11828 | 11846 | ); |
| 11829 | - crate::warp::warp_affine( | |
| 11830 | - params, &sref_u.data, sref_u.true_width as i32, sref_u.true_height as i32, | |
| 11831 | - sref_u.width as i32, &mut pred_u, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | |
| 11832 | - CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | |
| 11833 | - ); | |
| 11834 | - crate::warp::warp_affine( | |
| 11835 | - params, &sref_v.data, sref_v.true_width as i32, sref_v.true_height as i32, | |
| 11836 | - sref_v.width as i32, &mut pred_v, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | |
| 11837 | - CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | |
| 11838 | - ); | |
| 11847 | + // `av1_init_warp_params`'s per-plane `block_width/height < 8` | |
| 11848 | + // bail-out: an 8x8 leaf's chroma plane is 4x4 in 420, so it is | |
| 11849 | + // predicted translationally even when the luma warps. | |
| 11850 | + #[allow(clippy::absurd_extreme_comparisons)] | |
| 11851 | + if CHROMA_SIDE >= 8 { | |
| 11852 | + crate::warp::warp_affine( | |
| 11853 | + params, &sref_u.data, sref_u.true_width as i32, sref_u.true_height as i32, | |
| 11854 | + sref_u.width as i32, &mut pred_u, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | |
| 11855 | + CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | |
| 11856 | + ); | |
| 11857 | + crate::warp::warp_affine( | |
| 11858 | + params, &sref_v.data, sref_v.true_width as i32, sref_v.true_height as i32, | |
| 11859 | + sref_v.width as i32, &mut pred_v, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | |
| 11860 | + CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | |
| 11861 | + ); | |
| 11862 | + } | |
| 11839 | 11863 | } |
| 11840 | 11864 | |
| 11841 | 11865 | if obmc_selected { |
lanes/gmaffine-r4.report.mdadded+66 -0
| @@ -0,0 +1,66 @@ | ||
| 1 | +# lane-gmaffine r4 — the 8x8-leaf desync was a MISSING CDF ROW (chroma/most-size `eob_pt` class-1), not the mv stack | |
| 2 | + | |
| 3 | +Commits on `lane-gmaffine`, on top of r3 (`f8de9c3`). Suite: | |
| 4 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release --lib -j3` → | |
| 5 | +**271 passed, 2 failed, 24 ignored** (r3: 269/2/24 equivalent — no regression; the 2 | |
| 6 | +failures are the same two 8x8 motion gates, now failing on PIXELS, not on a refusal). | |
| 7 | + | |
| 8 | +## Root cause 1 (entropy, fixed): `eob_pt` class-1 CDF existed only for two LUMA sizes | |
| 9 | +libaom's `av1_default_eob_multi*_cdfs[q][PLANE_TYPES][2]` splits every eob_pt table by | |
| 10 | +`eob_multi_ctx = (tx_class == TX_CLASS_2D) ? 0 : 1`. This crate carried that second row | |
| 11 | +for `eob_pt_16_luma` and `eob_pt_64_luma` ONLY (lane-av1tx4 r5); every other table — | |
| 12 | +including all chroma — fell back to its 2D row (`cdf_state.rs`, 14 `TxbSet` arms had | |
| 13 | +`eob_pt_class1: None`). | |
| 14 | +Why it bit exactly here: an INTER block's chroma never codes a `tx_type` symbol, it | |
| 15 | +INHERITS the colocated luma type verbatim (`av1_get_tx_type`, blockd.h:1291). The gate's | |
| 16 | +8x8 leaves code `H_ADST` luma, so their 4x4 chroma is a 1D class — a routine case that | |
| 17 | +read the 2D CDF: right value, wrong interval, desync one symbol later. | |
| 18 | +Fix: class-1 siblings for all 9 remaining tables (16/64/128 chroma, 256/512/1024 both | |
| 19 | +planes) — `cdf.rs` (36 new consts, machine-extracted from `token_cdfs.h`), | |
| 20 | +`cdf_state.rs` (fields + `reset1` per-frame counter reset + q-context `pick` + all 14 | |
| 21 | +`txb()` arms now `Some(..)`; 0 `eob_pt_class1: None` left). | |
| 22 | + | |
| 23 | +EVIDENCE: `/tmp/.../scratchpad/{ours_c.txt,aom_c.txt}` | `EC_TRACE_COEFF=1 EC_TRACE_MODE=1` | |
| 24 | +ours vs instrumented aomdec on `gm1_cq32.obu` (sha256 22d09738…, the globalmv gate's own | |
| 25 | +8-bit cq32 recipe) | first divergent element = the chroma (plane 1) 4x4 eob of leaf | |
| 26 | +mi=(6,4): both enter at rng=37748 and decode eob=16, ours leaves at rng=35080, aomdec at | |
| 27 | +54536. After the fix all four gate streams (`gm{0,1}_cq{32,45}`) decode all 24 frames | |
| 28 | +instead of refusing ("an inter partition below 16x16 other than SPLIT" / "a partition | |
| 29 | +below 8x8" — both were `refusal-names-a-correlate` symptoms of this desync). | |
| 30 | + | |
| 31 | +## Root cause 2 (prediction, fixed, libaom-cited): warp is per PLANE and bails below 8x8 | |
| 32 | +`av1_init_warp_params` (reconinter.c:58) returns before `allow_warp` when | |
| 33 | +`block_width < 8 || block_height < 8` — in 420 that is the chroma plane of every luma | |
| 34 | +block below 16x16. We warped chroma at 4x4. Fixed at both warp sites | |
| 35 | +(`decode.rs` 16x16+ site `chroma_side >= 8`, 8x8-leaf site `CHROMA_SIDE >= 8`). | |
| 36 | + | |
| 37 | +## Still RED: chroma-only pixel residue on both 8x8 motion gates — fix-now, next round | |
| 38 | +Luma is byte-exact on all 24 frames of both gates; U/V differ by ±1..3 in a handful of | |
| 39 | +4x4 chroma blocks (frame 1: 40 U + 45 V pixels in 3 blocks; frames 2/3 similar). | |
| 40 | +EVIDENCE: `/tmp/.../scratchpad/{ours.yuv,ref.yuv}` | `EC_PROBE_DUMP=… decode_probe | |
| 41 | +gm1_cq32.obu` vs `ffmpeg -i gm1_cq32.obu -pix_fmt yuv420p` | frame 1 ydiff 0, udiff 40, | |
| 42 | +vdiff 45, mismatching chroma 4x4 blocks (12,8), (16,8), (20,8) = the 8x8 leaves at mi | |
| 43 | +(6,4), (8,4), (10,4); block (12,8) ours [97,119,105,95] vs ref [98,117,106,94]. | |
| 44 | +Facts established for the successor: | |
| 45 | +- those three leaves are NOT warped and NOT global (`EC_WARP8 mi_row=6 mi_col=4 | |
| 46 | + warp=false globalblk=false`), so root cause 2 is not it and neither is the gm/warp code; | |
| 47 | +- their luma tx_type is `H_ADST` (class horiz) — i.e. exactly the blocks whose CHROMA now | |
| 48 | + inherits a 1D-class type. Prime suspect: the chroma side of that inheritance — either | |
| 49 | + the inverse basis at 4x4 chroma, or libaom's `av1_get_ext_tx_set_type` clamp | |
| 50 | + (`if (!av1_ext_tx_used[tx_set_type][tx_type]) tx_type = DCT_DCT`), which we approximate | |
| 51 | + with `side >= 32` instead of the real per-size/`reduced_tx_set` set membership. | |
| 52 | + Next step: force `DCT_DCT` for the chroma INVERSE only (keep the class-1 eob/scan) and | |
| 53 | + see whether the three blocks go exact — that separates basis from prediction in one run. | |
| 54 | + | |
| 55 | +## DEVIATION from the charter (named) | |
| 56 | +Charter item (4) says restore any refusal whose gate cannot go green. I did NOT restore | |
| 57 | +the GLOBALMV/WARPED_CAUSAL 8x8 refusals r1 removed, same reasons r2 gave (a refusal placed | |
| 58 | +before the code it guards makes that code dead, `refusal-short-circuits-its-own-code`, and | |
| 59 | +those refusals are not what fails: both gate streams now decode END TO END and only chroma | |
| 60 | +pixels differ). Reverting is one hunk of `refusal_inventory.rs` plus two `decode.rs` | |
| 61 | +deletions in `65ef3f5` if the orchestrator disagrees. | |
| 62 | + | |
| 63 | +## Instruments kept | |
| 64 | +`EC_WARP8` (per-leaf warp decision, under `EC_TRACE_MODE`), `tx=`/`class=` on the | |
| 65 | +`EC_COEFF_STEP tag=eob` line, and `EC_PROBE_DUMP=<path>` on `examples/decode_probe` | |
| 66 | +(raw 8-bit I420 dump for pixel diffing against ffmpeg without a test harness). |