Re-design drl index coding to remove ctx parsing dep
Re-design the dynamic motion vector index coding system to remove
the context parsing dependency on the reconstructed motion vectors.
Change-Id: I01dd6eda239a0bed32d8dc98f0f10f18249a76d4
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 69783b6..c8e30a4 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -757,6 +757,7 @@
nearest_match = ref_match_count;
nearest_refmv_count = *refmv_count;
+ ref_mv_stack[0].weight = 0;
for (idx = 0; idx < nearest_refmv_count; ++idx)
ref_mv_stack[idx].weight += REF_CAT_LEVEL;
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index e74b8c3..d80bdf4 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -367,6 +367,13 @@
static INLINE uint8_t av1_drl_ctx(const CANDIDATE_MV *ref_mv_stack,
int ref_idx) {
+#if CONFIG_OPT_REF_MV
+ if (ref_mv_stack[0].weight >= REF_CAT_LEVEL)
+ return 0;
+ else
+ return 2;
+#endif
+
if (ref_mv_stack[ref_idx].weight >= REF_CAT_LEVEL &&
ref_mv_stack[ref_idx + 1].weight >= REF_CAT_LEVEL)
return 0;
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index bec48e3..577640c 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -257,7 +257,7 @@
if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV) {
int idx;
for (idx = 0; idx < 2; ++idx) {
- if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
+ if (xd->ref_mv_count[ref_frame_type] > idx + 1 || CONFIG_OPT_REF_MV) {
uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
mbmi->ref_mv_idx = idx + drl_idx;
@@ -272,7 +272,7 @@
// TODO(jingning): Unify the two syntax decoding loops after the NEARESTMV
// mode is factored in.
for (idx = 1; idx < 3; ++idx) {
- if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
+ if (xd->ref_mv_count[ref_frame_type] > idx + 1 || CONFIG_OPT_REF_MV) {
uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
mbmi->ref_mv_idx = idx + drl_idx - 1;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 078eb3f..2f05da8 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -149,7 +149,8 @@
if (new_mv) {
int idx;
for (idx = 0; idx < 2; ++idx) {
- if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
+ if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1 ||
+ CONFIG_OPT_REF_MV) {
uint8_t drl_ctx =
av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
@@ -165,7 +166,8 @@
int idx;
// TODO(jingning): Temporary solution to compensate the NEARESTMV offset.
for (idx = 1; idx < 3; ++idx) {
- if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
+ if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1 ||
+ CONFIG_OPT_REF_MV) {
uint8_t drl_ctx =
av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
aom_write_symbol(w, mbmi->ref_mv_idx != (idx - 1),