Consume the interintra symbol behind enable_interintra_compound
Browse files at this commitc06aac0f882107b2663576cd54037829b62e6efaParent: 35abdb5- fix
- consume the interintra symbol behind enable_interintra_compound
3 changed files +58 -0
- crates/ec-av1/src/cdf_state.rs +1 -0
- crates/ec-av1/src/decode.rs +51 -0
- crates/ec-av1/src/stream.rs +6 -0
crates/ec-av1/src/cdf_state.rsmodified+1 -0
| @@ -561,6 +561,7 @@ impl Cdfs { | ||
| 561 | 561 | reset2(&mut self.comp_mode); |
| 562 | 562 | reset2(&mut self.skip_mode); |
| 563 | 563 | reset2(&mut self.obmc); |
| 564 | + reset2(&mut self.interintra); | |
| 564 | 565 | reset2(&mut self.inter_compound_mode); |
| 565 | 566 | reset2(&mut self.comp_ref_type); |
| 566 | 567 | reset3(&mut self.uni_comp_ref); |
crates/ec-av1/src/decode.rsmodified+51 -0
| @@ -4570,6 +4570,16 @@ fn decode_inter_block( | ||
| 4570 | 4570 | // compound blend weights need this frame's own order hint regardless |
| 4571 | 4571 | // of `use_ref_frame_mvs`. |
| 4572 | 4572 | enable_masked_compound: bool, |
| 4573 | + // lane-sb128 r4: this sequence header's own `enable_interintra_compound` | |
| 4574 | + // bit (spec 5.11.24's `interintra` read, libaom `decodemv.c` | |
| 4575 | + // read_inter_block_mode_info ~1490-1510) -- read right after `assign_mv` | |
| 4576 | + // and before `read_motion_mode` on the single-ref path below, gated by | |
| 4577 | + // `is_interintra_allowed` (single-ref, `BLOCK_8X8..=BLOCK_32X32`, and | |
| 4578 | + // every mode this single-ref branch can produce is already in | |
| 4579 | + // `SINGLE_INTER_MODE_START..END`); `interintra == 1` is a named refusal | |
| 4580 | + // (inter+intra blended prediction unimplemented) rather than a | |
| 4581 | + // mis-decode. | |
| 4582 | + enable_interintra_compound: bool, | |
| 4573 | 4583 | enable_jnt_comp: bool, |
| 4574 | 4584 | order_hint_bits: u32, |
| 4575 | 4585 | order_hint: u32, |
| @@ -5294,6 +5304,27 @@ fn decode_inter_block( | ||
| 5294 | 5304 | }; |
| 5295 | 5305 | (mv, false) |
| 5296 | 5306 | }; |
| 5307 | + // lane-sb128 r4: `interintra` (spec 5.11.24; libaom | |
| 5308 | + // `decodemv.c` read_inter_block_mode_info ~1490-1510), placed | |
| 5309 | + // right after `assign_mv` and before `read_motion_mode` below -- | |
| 5310 | + // libaom's own sequential order. `is_interintra_allowed_bsize` | |
| 5311 | + // (`BLOCK_8X8..=BLOCK_32X32`) is the only real gate on this | |
| 5312 | + // single-ref path: `is_interintra_allowed_ref` always holds here | |
| 5313 | + // (single ref, `ref_frame[1]` not yet `INTRA_FRAME`) and | |
| 5314 | + // `is_interintra_allowed_mode` always holds (every mode this | |
| 5315 | + // branch produces -- NEARESTMV/NEARMV/GLOBALMV/NEWMV -- is | |
| 5316 | + // `SINGLE_INTER_MODE_START..END` by construction). | |
| 5317 | + // `size_group_lookup`: BLOCK_16X16 -> 2, BLOCK_32X32 -> 3. | |
| 5318 | + if enable_interintra_compound && !skip_mode && (side == 16 || side == 32) { | |
| 5319 | + let bsize_group = if side == 16 { 2 } else { 3 }; | |
| 5320 | + let interintra = dec.symbol(&mut cdfs.interintra[bsize_group]) == 1; | |
| 5321 | + if interintra { | |
| 5322 | + return Err(unsupported( | |
| 5323 | + "an interintra-compound block (interintra == 1, inter+intra \ | |
| 5324 | + blended prediction unimplemented)", | |
| 5325 | + )); | |
| 5326 | + } | |
| 5327 | + } | |
| 5297 | 5328 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; |
| 5298 | 5329 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), |
| 5299 | 5330 | // placed right after MV assignment and before the switchable |
| @@ -5757,6 +5788,10 @@ fn decode_inter_block8( | ||
| 5757 | 5788 | // context uses that same approximation. |
| 5758 | 5789 | reference_select: bool, |
| 5759 | 5790 | enable_masked_compound: bool, |
| 5791 | + // lane-sb128 r4: see [`decode_inter_block`]'s own doc -- `BLOCK_8X8` is | |
| 5792 | + // always `is_interintra_allowed_bsize`-eligible, so this leaf's own gate | |
| 5793 | + // drops the `side` check entirely. | |
| 5794 | + enable_interintra_compound: bool, | |
| 5760 | 5795 | enable_jnt_comp: bool, |
| 5761 | 5796 | order_hint_bits: u32, |
| 5762 | 5797 | order_hint: u32, |
| @@ -6229,6 +6264,20 @@ fn decode_inter_block8( | ||
| 6229 | 6264 | }; |
| 6230 | 6265 | (mv, false) |
| 6231 | 6266 | }; |
| 6267 | + // lane-sb128 r4: `interintra` (spec 5.11.24) at the 8x8 leaf too -- | |
| 6268 | + // see [`decode_inter_block`]'s own doc; `BLOCK_8X8` is always | |
| 6269 | + // `is_interintra_allowed_bsize`-eligible, single-ref-only branch | |
| 6270 | + // (compound already returned above), GLOBALMV already refused | |
| 6271 | + // (round 3), so the only real gate left is the header enable bit. | |
| 6272 | + if enable_interintra_compound && !skip_mode { | |
| 6273 | + let interintra = dec.symbol(&mut cdfs.interintra[SIZE_GROUP_8]) == 1; | |
| 6274 | + if interintra { | |
| 6275 | + return Err(unsupported( | |
| 6276 | + "an interintra-compound block (interintra == 1, inter+intra \ | |
| 6277 | + blended prediction unimplemented)", | |
| 6278 | + )); | |
| 6279 | + } | |
| 6280 | + } | |
| 6232 | 6281 | // lane-motionmode round 3: `read_motion_mode` (spec 5.11.24) at the |
| 6233 | 6282 | // 8x8 leaf too -- `motion_mode_allowed` still holds here (BLOCK_8X8 |
| 6234 | 6283 | // is the spec's own minimum eligible size, single-ref-only branch, |
| @@ -6619,6 +6668,7 @@ pub fn decode_inter_frame_tile( | ||
| 6619 | 6668 | false, |
| 6620 | 6669 | false, |
| 6621 | 6670 | false, |
| 6671 | + false, | |
| 6622 | 6672 | [0; 2], |
| 6623 | 6673 | true, |
| 6624 | 6674 | false, |
| @@ -7803,6 +7853,7 @@ mod tests { | ||
| 7803 | 7853 | false, |
| 7804 | 7854 | false, |
| 7805 | 7855 | false, |
| 7856 | + false, | |
| 7806 | 7857 | 0, |
| 7807 | 7858 | 0, |
| 7808 | 7859 | [0; 7], |
crates/ec-av1/src/stream.rsmodified+6 -0
| @@ -255,6 +255,11 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 255 | 255 | let enable_jnt_comp = parser |
| 256 | 256 | .sequence_header() |
| 257 | 257 | .is_some_and(|seq| seq.enable_jnt_comp); |
| 258 | + // lane-sb128 r4: `interintra`'s own gating bit -- see decode.rs's | |
| 259 | + // read site doc. | |
| 260 | + let enable_interintra_compound = parser | |
| 261 | + .sequence_header() | |
| 262 | + .is_some_and(|seq| seq.enable_interintra_compound); | |
| 258 | 263 | let interp_fixed = match header.interpolation_filter { |
| 259 | 264 | ec_av1_syntax::InterpolationFilter::Switchable => None, |
| 260 | 265 | fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)), |
| @@ -375,6 +380,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 375 | 380 | tpl_field.as_ref(), |
| 376 | 381 | header.reference_select, |
| 377 | 382 | enable_masked_compound, |
| 383 | + enable_interintra_compound, | |
| 378 | 384 | enable_jnt_comp, |
| 379 | 385 | header.skip_mode_present, |
| 380 | 386 | header.skip_mode_frame, |