Switchable_interp compound-block ctx offset
Browse files at this commit3ab7e16cf3f5559e6092404870386b37147e5b8dParent: c806031- fix
- switchable_interp compound-block ctx offset
- re-pin second compound_idx defect
1 changed file +34 -11
- crates/ec-av1/src/decode.rs +34 -11
crates/ec-av1/src/decode.rsmodified+34 -11
| @@ -3644,11 +3644,17 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 3644 | 3644 | |
| 3645 | 3645 | /// `av1_get_pred_context_switchable_interp`'s context for `interp_filter[dir]` |
| 3646 | 3646 | /// -- `above`/`left` are the neighbour's own resolved index for this |
| 3647 | -/// direction (0..=2, or `3` = no info, spec `SWITCHABLE_FILTERS`). This | |
| 3648 | -/// decoder never codes a compound reference, so `INTER_FILTER_COMP_OFFSET` | |
| 3649 | -/// is always 0; only `dir`'s own `INTER_FILTER_DIR_OFFSET` (8) is folded in. | |
| 3650 | -fn switchable_interp_ctx(above: u8, left: u8, dir: usize) -> usize { | |
| 3651 | - let base = dir * 8; | |
| 3647 | +/// direction (0..=2, or `3` = no info, spec `SWITCHABLE_FILTERS`). | |
| 3648 | +/// `is_compound` folds in libaom `av1_get_pred_context_switchable_interp`'s | |
| 3649 | +/// own `ctx_offset` term (`INTER_FILTER_COMP_OFFSET` = 4, added when *this* | |
| 3650 | +/// block itself has a second reference) -- lane-av1idx: a stale "this | |
| 3651 | +/// decoder never codes a compound reference" assumption baked this to | |
| 3652 | +/// always-0, which desynced the CDF context bucket (not the decoded value | |
| 3653 | +/// outright, hence small pixel deltas rather than a hard desync) the moment | |
| 3654 | +/// lane-av1blend unmasked plain-average compound blocks on a Switchable- | |
| 3655 | +/// filter frame. | |
| 3656 | +fn switchable_interp_ctx(above: u8, left: u8, dir: usize, is_compound: bool) -> usize { | |
| 3657 | + let base = dir * 8 + if is_compound { 4 } else { 0 }; | |
| 3652 | 3658 | let term = if left == above { |
| 3653 | 3659 | left |
| 3654 | 3660 | } else if left == 3 { |
| @@ -3679,6 +3685,7 @@ fn resolve_interp_filter( | ||
| 3679 | 3685 | force_regular: bool, |
| 3680 | 3686 | above: [u8; 2], |
| 3681 | 3687 | left: [u8; 2], |
| 3688 | + is_compound: bool, | |
| 3682 | 3689 | ) -> (mc::InterpFilterKind, mc::InterpFilterKind, [u8; 2]) { |
| 3683 | 3690 | if let Some(kind) = interp_fixed { |
| 3684 | 3691 | return (kind, kind, [3, 3]); |
| @@ -3696,10 +3703,10 @@ fn resolve_interp_filter( | ||
| 3696 | 3703 | // "horizontal then vertical" despite `predict_with_filters`' own |
| 3697 | 3704 | // `h_kind`/`v_kind` argument order, which is why this function returns |
| 3698 | 3705 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). |
| 3699 | - let ctx0 = switchable_interp_ctx(above[0], left[0], 0); | |
| 3706 | + let ctx0 = switchable_interp_ctx(above[0], left[0], 0, is_compound); | |
| 3700 | 3707 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; |
| 3701 | 3708 | let sym1 = if enable_dual_filter { |
| 3702 | - let ctx1 = switchable_interp_ctx(above[1], left[1], 1); | |
| 3709 | + let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound); | |
| 3703 | 3710 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 |
| 3704 | 3711 | } else { |
| 3705 | 3712 | sym0 |
| @@ -4666,11 +4673,22 @@ fn decode_inter_block( | ||
| 4666 | 4673 | // 846 pixels not fitting the (9,7)-vs-plain-average hypothesis |
| 4667 | 4674 | // either) already flagged more than one bug here. Re-masking: |
| 4668 | 4675 | // do not ship a blend that is right only sometimes. |
| 4676 | + // lane-av1idx r1: fixed one real bug this round | |
| 4677 | + // (`switchable_interp_ctx` never folded in libaom's | |
| 4678 | + // `INTER_FILTER_COMP_OFFSET` for a compound block's own | |
| 4679 | + // interp_filter context -- kept). Pinned | |
| 4680 | + // `fixtures/av1idx-refsel-pin.obu` (seed 61, reference_select | |
| 4681 | + // gate) still mismatches after that fix (decode-order frame 8 | |
| 4682 | + // first, small deltas, worst 1-2, propagating through later | |
| 4683 | + // frames via DPB reference) -- a second, still-unfound bug. | |
| 4684 | + // Re-masking: see that fixture + `scratch_isolate_pinned_mismatch` | |
| 4685 | + // (`EC_AV1_PIN=fixtures/av1idx-refsel-pin.obu EC_AV1_PIN_N=20`) | |
| 4686 | + // for the next round's starting point. | |
| 4669 | 4687 | return Err(unsupported( |
| 4670 | 4688 | "a COMPOUND_REFERENCE 16x16 leaf using the plain/distance-weighted \ |
| 4671 | 4689 | average blend (comp_group_idx == 0) -- proven non-pixel-exact against \ |
| 4672 | - real aomenc streams beyond the one bug lane-av1blend r6/r7 fixed \ | |
| 4673 | - (lane-av1blend r7, wide gate sweep)", | |
| 4690 | + real aomenc streams beyond the bugs lane-av1blend r6/r7 and lane-av1idx \ | |
| 4691 | + r1 fixed (wide gate sweep, fixtures/av1idx-refsel-pin.obu)", | |
| 4674 | 4692 | )); |
| 4675 | 4693 | #[allow(unreachable_code)] |
| 4676 | 4694 | let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { |
| @@ -4740,6 +4758,7 @@ fn decode_inter_block( | ||
| 4740 | 4758 | is_globalmv, |
| 4741 | 4759 | above_filter_ctx, |
| 4742 | 4760 | left_filter_ctx, |
| 4761 | + true, | |
| 4743 | 4762 | ); |
| 4744 | 4763 | block_filter = resolved_filter; |
| 4745 | 4764 | |
| @@ -5063,6 +5082,7 @@ fn decode_inter_block( | ||
| 5063 | 5082 | is_globalmv, |
| 5064 | 5083 | above_filter_ctx, |
| 5065 | 5084 | left_filter_ctx, |
| 5085 | + false, | |
| 5066 | 5086 | ); |
| 5067 | 5087 | block_filter = resolved_filter; |
| 5068 | 5088 | globalmv_for_lf = is_globalmv; |
| @@ -5580,11 +5600,14 @@ fn decode_inter_block8( | ||
| 5580 | 5600 | // as the 16x16 leaf above -- one real bug found and fixed |
| 5581 | 5601 | // (mvstack.rs ref_ctx family), a second, still-unfound |
| 5582 | 5602 | // compound_idx defect surfaces on the wide gate sweep. |
| 5603 | + // lane-av1idx r1: same re-mask as the 16x16 leaf above -- | |
| 5604 | + // see that comment. | |
| 5583 | 5605 | return Err(unsupported( |
| 5584 | 5606 | "a COMPOUND_REFERENCE 8x8 leaf using the plain/distance-weighted \ |
| 5585 | 5607 | average blend (comp_group_idx == 0) -- proven non-pixel-exact \ |
| 5586 | - against real aomenc streams beyond the one bug lane-av1blend \ | |
| 5587 | - r6/r7 fixed (lane-av1blend r7, wide gate sweep)", | |
| 5608 | + against real aomenc streams beyond the bugs lane-av1blend r6/r7 \ | |
| 5609 | + and lane-av1idx r1 fixed (wide gate sweep, \ | |
| 5610 | + fixtures/av1idx-refsel-pin.obu)", | |
| 5588 | 5611 | )); |
| 5589 | 5612 | #[allow(unreachable_code)] |
| 5590 | 5613 | let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { |