forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-av1resid': NEWMV drl-index fix (round 2)

Browse files at this commit

caef4a8c1a1e774c60add83c7aa021b5ed370432Ahmet Kaan GümüşParent: 821ba2ff5ee53b
crates/ec-av1/src/decode.rsmodified+28 -6
@@ -3669,15 +3669,26 @@ fn decode_inter_block(
3669 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;3669 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
3670 let mut is_globalmv = false;3670 let mut is_globalmv = false;
3671 let (mv, is_new_mv) = if !not_new {3671 let (mv, is_new_mv) = if !not_new {
3672- if stack.entries.len() > 1 {3672+ // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
3673- dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[0]]);3673+ // read at most two `drl_mode` bits, one per stack entry past the
3674+ // first, stopping at the first `0`. The chosen index selects
3675+ // which stack entry `read_mv`'s base predictor comes from
3676+ // (spec 7.10.2.10 `assign_mv`'s `PredMv = RefStackMv[RefMvIdx]`)
3677+ // -- entry 0 (`stack.pred_mv`) only when the loop never advances.
3678+ let mut idx = 0usize;
3679+ while idx < 2 && stack.entries.len() > idx + 1 {
3680+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
3681+ break;
3682+ }
3683+ idx += 1;
3674 }3684 }
3685+ let base_mv = stack.entries.get(idx).map_or(stack.pred_mv, |e| e.mv);
3675 (3686 (
3676 read_mv(3687 read_mv(
3677 dec,3688 dec,
3678 &mut cdfs.mv_comp,3689 &mut cdfs.mv_comp,
3679 &mut cdfs.mv_joint,3690 &mut cdfs.mv_joint,
3680- stack.pred_mv,3691+ base_mv,
3681 allow_high_precision_mv,3692 allow_high_precision_mv,
3682 ),3693 ),
3683 true,3694 true,
@@ -4111,15 +4122,26 @@ fn decode_inter_block8(
4111 4122
4112 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;4123 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
4113 let (mv, is_new_mv) = if !not_new {4124 let (mv, is_new_mv) = if !not_new {
4114- if stack.entries.len() > 1 {4125+ // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
4115- dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[0]]);4126+ // read at most two `drl_mode` bits, one per stack entry past the
4127+ // first, stopping at the first `0`. The chosen index selects
4128+ // which stack entry `read_mv`'s base predictor comes from
4129+ // (spec 7.10.2.10 `assign_mv`'s `PredMv = RefStackMv[RefMvIdx]`)
4130+ // -- entry 0 (`stack.pred_mv`) only when the loop never advances.
4131+ let mut idx = 0usize;
4132+ while idx < 2 && stack.entries.len() > idx + 1 {
4133+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
4134+ break;
4135+ }
4136+ idx += 1;
4116 }4137 }
4138+ let base_mv = stack.entries.get(idx).map_or(stack.pred_mv, |e| e.mv);
4117 (4139 (
4118 read_mv(4140 read_mv(
4119 dec,4141 dec,
4120 &mut cdfs.mv_comp,4142 &mut cdfs.mv_comp,
4121 &mut cdfs.mv_joint,4143 &mut cdfs.mv_joint,
4122- stack.pred_mv,4144+ base_mv,
4123 allow_high_precision_mv,4145 allow_high_precision_mv,
4124 ),4146 ),
4125 true,4147 true,