Re-enable av1_nmv_ctx() when ext-inter is enabled
Currently, mbmi->ref_mv_idx can be set to a nonzero value
on the encoder side if mbmi->mode is one of NEARMV, NEWMV,
NEAR_NEARMV, or NEW_NEWMV. But it can only be nonzero on the
decoder side if the mode is NEARMV or NEWMV. Hence av1_nmv_ctx
has previously been disabled when ext-inter is enabled, to
prevent a mismatch due to this.
This patch changes the encoder behaviour to match the decoder
behaviour.
Change-Id: Icfe41fb72e76731ae373fe8c6065f5e003f6414f
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index e3843a5..3b06151 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -10489,18 +10489,11 @@
}
#if CONFIG_REF_MV
-// TODO(jingning): This needs some refactoring to improve code quality
-// and reduce redundant steps.
-#if CONFIG_EXT_INTER
- if (((mbmi->mode == NEARMV || mbmi->mode == NEAR_NEARMV) &&
- mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
- ((mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) &&
- mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
-#else
+ // TODO(jingning): This needs some refactoring to improve code quality
+ // and reduce redundant steps.
if ((mbmi->mode == NEARMV &&
mbmi_ext->ref_mv_count[ref_frame_type] > 2) ||
(mbmi->mode == NEWMV && mbmi_ext->ref_mv_count[ref_frame_type] > 1)) {
-#endif // CONFIG_EXT_INTER
int_mv backup_mv = frame_mv[NEARMV][ref_frame];
MB_MODE_INFO backup_mbmi = *mbmi;
int backup_skip = x->skip;
@@ -11322,6 +11315,13 @@
#endif // CONFIG_REF_MV
}
+ // Make sure that the ref_mv_idx is only nonzero when we're
+ // using a mode which can support ref_mv_idx
+ if (best_mbmode.ref_mv_idx != 0 &&
+ !(best_mbmode.mode == NEARMV || best_mbmode.mode == NEWMV)) {
+ best_mbmode.ref_mv_idx = 0;
+ }
+
#if CONFIG_REF_MV
{
int8_t ref_frame_type = av1_ref_frame_type(best_mbmode.ref_frame);