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 | reset2(&mut self.comp_mode); | 561 | reset2(&mut self.comp_mode); |
| 562 | reset2(&mut self.skip_mode); | 562 | reset2(&mut self.skip_mode); |
| 563 | reset2(&mut self.obmc); | 563 | reset2(&mut self.obmc); |
| 564 | + reset2(&mut self.interintra); | ||
| 564 | reset2(&mut self.inter_compound_mode); | 565 | reset2(&mut self.inter_compound_mode); |
| 565 | reset2(&mut self.comp_ref_type); | 566 | reset2(&mut self.comp_ref_type); |
| 566 | reset3(&mut self.uni_comp_ref); | 567 | reset3(&mut self.uni_comp_ref); |
crates/ec-av1/src/decode.rsmodified+51 -0
| @@ -4570,6 +4570,16 @@ fn decode_inter_block( | |||
| 4570 | // compound blend weights need this frame's own order hint regardless | 4570 | // compound blend weights need this frame's own order hint regardless |
| 4571 | // of `use_ref_frame_mvs`. | 4571 | // of `use_ref_frame_mvs`. |
| 4572 | enable_masked_compound: bool, | 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 | enable_jnt_comp: bool, | 4583 | enable_jnt_comp: bool, |
| 4574 | order_hint_bits: u32, | 4584 | order_hint_bits: u32, |
| 4575 | order_hint: u32, | 4585 | order_hint: u32, |
| @@ -5294,6 +5304,27 @@ fn decode_inter_block( | |||
| 5294 | }; | 5304 | }; |
| 5295 | (mv, false) | 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 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; | 5328 | // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; |
| 5298 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), | 5329 | // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), |
| 5299 | // placed right after MV assignment and before the switchable | 5330 | // placed right after MV assignment and before the switchable |
| @@ -5757,6 +5788,10 @@ fn decode_inter_block8( | |||
| 5757 | // context uses that same approximation. | 5788 | // context uses that same approximation. |
| 5758 | reference_select: bool, | 5789 | reference_select: bool, |
| 5759 | enable_masked_compound: bool, | 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 | enable_jnt_comp: bool, | 5795 | enable_jnt_comp: bool, |
| 5761 | order_hint_bits: u32, | 5796 | order_hint_bits: u32, |
| 5762 | order_hint: u32, | 5797 | order_hint: u32, |
| @@ -6229,6 +6264,20 @@ fn decode_inter_block8( | |||
| 6229 | }; | 6264 | }; |
| 6230 | (mv, false) | 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 | // lane-motionmode round 3: `read_motion_mode` (spec 5.11.24) at the | 6281 | // lane-motionmode round 3: `read_motion_mode` (spec 5.11.24) at the |
| 6233 | // 8x8 leaf too -- `motion_mode_allowed` still holds here (BLOCK_8X8 | 6282 | // 8x8 leaf too -- `motion_mode_allowed` still holds here (BLOCK_8X8 |
| 6234 | // is the spec's own minimum eligible size, single-ref-only branch, | 6283 | // is the spec's own minimum eligible size, single-ref-only branch, |
| @@ -6619,6 +6668,7 @@ pub fn decode_inter_frame_tile( | |||
| 6619 | false, | 6668 | false, |
| 6620 | false, | 6669 | false, |
| 6621 | false, | 6670 | false, |
| 6671 | + false, | ||
| 6622 | [0; 2], | 6672 | [0; 2], |
| 6623 | true, | 6673 | true, |
| 6624 | false, | 6674 | false, |
| @@ -7803,6 +7853,7 @@ mod tests { | |||
| 7803 | false, | 7853 | false, |
| 7804 | false, | 7854 | false, |
| 7805 | false, | 7855 | false, |
| 7856 | + false, | ||
| 7806 | 0, | 7857 | 0, |
| 7807 | 0, | 7858 | 0, |
| 7808 | [0; 7], | 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 | let enable_jnt_comp = parser | 255 | let enable_jnt_comp = parser |
| 256 | .sequence_header() | 256 | .sequence_header() |
| 257 | .is_some_and(|seq| seq.enable_jnt_comp); | 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 | let interp_fixed = match header.interpolation_filter { | 263 | let interp_fixed = match header.interpolation_filter { |
| 259 | ec_av1_syntax::InterpolationFilter::Switchable => None, | 264 | ec_av1_syntax::InterpolationFilter::Switchable => None, |
| 260 | fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)), | 265 | fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)), |
| @@ -375,6 +380,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 375 | tpl_field.as_ref(), | 380 | tpl_field.as_ref(), |
| 376 | header.reference_select, | 381 | header.reference_select, |
| 377 | enable_masked_compound, | 382 | enable_masked_compound, |
| 383 | + enable_interintra_compound, | ||
| 378 | enable_jnt_comp, | 384 | enable_jnt_comp, |
| 379 | header.skip_mode_present, | 385 | header.skip_mode_present, |
| 380 | header.skip_mode_frame, | 386 | header.skip_mode_frame, |