Sync ref-mv experiment between aom and nextgenv2
Change-Id: I134d276234b3b8aa7df1ab647892b5d739647f4c
This commit is contained in:
@@ -42,12 +42,7 @@ const aom_tree_index av1_mv_fp_tree[TREE_SIZE(MV_FP_SIZE)] = { -0, 2, -1,
|
|||||||
4, -2, -3 };
|
4, -2, -3 };
|
||||||
|
|
||||||
static const nmv_context default_nmv_context = {
|
static const nmv_context default_nmv_context = {
|
||||||
#if CONFIG_REF_MV
|
|
||||||
{ 1, 64, 96 },
|
|
||||||
128,
|
|
||||||
#else
|
|
||||||
{ 32, 64, 96 },
|
{ 32, 64, 96 },
|
||||||
#endif
|
|
||||||
{ {
|
{ {
|
||||||
// Vertical component
|
// Vertical component
|
||||||
128, // sign
|
128, // sign
|
||||||
@@ -175,11 +170,6 @@ static void inc_mv_component(int v, nmv_component_counts *comp_counts, int incr,
|
|||||||
void av1_inc_mv(const MV *mv, nmv_context_counts *counts, const int usehp) {
|
void av1_inc_mv(const MV *mv, nmv_context_counts *counts, const int usehp) {
|
||||||
if (counts != NULL) {
|
if (counts != NULL) {
|
||||||
const MV_JOINT_TYPE j = av1_get_mv_joint(mv);
|
const MV_JOINT_TYPE j = av1_get_mv_joint(mv);
|
||||||
|
|
||||||
#if CONFIG_REF_MV
|
|
||||||
++counts->zero_rmv[j == MV_JOINT_ZERO];
|
|
||||||
if (j == MV_JOINT_ZERO) return;
|
|
||||||
#endif
|
|
||||||
++counts->joints[j];
|
++counts->joints[j];
|
||||||
|
|
||||||
if (mv_joint_vertical(j))
|
if (mv_joint_vertical(j))
|
||||||
@@ -202,8 +192,6 @@ void av1_adapt_mv_probs(AV1_COMMON *cm, int allow_hp) {
|
|||||||
|
|
||||||
aom_tree_merge_probs(av1_mv_joint_tree, pre_fc->joints, counts->joints,
|
aom_tree_merge_probs(av1_mv_joint_tree, pre_fc->joints, counts->joints,
|
||||||
fc->joints);
|
fc->joints);
|
||||||
fc->zero_rmv = av1_mode_mv_merge_probs(pre_fc->zero_rmv, counts->zero_rmv);
|
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
nmv_component *comp = &fc->comps[i];
|
nmv_component *comp = &fc->comps[i];
|
||||||
const nmv_component *pre_comp = &pre_fc->comps[i];
|
const nmv_component *pre_comp = &pre_fc->comps[i];
|
||||||
|
@@ -95,9 +95,6 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
aom_prob joints[MV_JOINTS - 1];
|
aom_prob joints[MV_JOINTS - 1];
|
||||||
#if CONFIG_REF_MV
|
|
||||||
aom_prob zero_rmv;
|
|
||||||
#endif
|
|
||||||
nmv_component comps[2];
|
nmv_component comps[2];
|
||||||
} nmv_context;
|
} nmv_context;
|
||||||
|
|
||||||
@@ -124,9 +121,6 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int joints[MV_JOINTS];
|
unsigned int joints[MV_JOINTS];
|
||||||
#if CONFIG_REF_MV
|
|
||||||
unsigned int zero_rmv[2];
|
|
||||||
#endif
|
|
||||||
nmv_component_counts comps[2];
|
nmv_component_counts comps[2];
|
||||||
} nmv_context_counts;
|
} nmv_context_counts;
|
||||||
|
|
||||||
|
@@ -197,10 +197,6 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
|
|||||||
|
|
||||||
update_mv_probs(ctx->joints, MV_JOINTS - 1, r);
|
update_mv_probs(ctx->joints, MV_JOINTS - 1, r);
|
||||||
|
|
||||||
#if CONFIG_REF_MV
|
|
||||||
av1_diff_update_prob(r, &ctx->zero_rmv);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
nmv_component *const comp_ctx = &ctx->comps[i];
|
nmv_component *const comp_ctx = &ctx->comps[i];
|
||||||
update_mv_probs(&comp_ctx->sign, 1, r);
|
update_mv_probs(&comp_ctx->sign, 1, r);
|
||||||
|
@@ -686,35 +686,12 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref,
|
static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref,
|
||||||
#if CONFIG_REF_MV
|
|
||||||
int is_compound,
|
|
||||||
#endif
|
|
||||||
const nmv_context *ctx, nmv_context_counts *counts,
|
const nmv_context *ctx, nmv_context_counts *counts,
|
||||||
int allow_hp) {
|
int allow_hp) {
|
||||||
MV_JOINT_TYPE joint_type;
|
MV_JOINT_TYPE joint_type;
|
||||||
const int use_hp = allow_hp && av1_use_mv_hp(ref);
|
const int use_hp = allow_hp && av1_use_mv_hp(ref);
|
||||||
MV diff = { 0, 0 };
|
MV diff = { 0, 0 };
|
||||||
|
|
||||||
#if CONFIG_REF_MV && !CONFIG_EXT_INTER
|
|
||||||
if (is_compound) {
|
|
||||||
int is_zero_rmv = aom_read(r, ctx->zero_rmv);
|
|
||||||
if (is_zero_rmv) {
|
|
||||||
joint_type = MV_JOINT_ZERO;
|
|
||||||
} else {
|
|
||||||
joint_type =
|
|
||||||
(MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
joint_type =
|
|
||||||
(MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
joint_type = (MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints);
|
joint_type = (MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_REF_MV && CONFIG_EXT_INTER
|
|
||||||
(void)is_compound;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mv_joint_vertical(joint_type))
|
if (mv_joint_vertical(joint_type))
|
||||||
diff.row = read_mv_component(r, &ctx->comps[0], use_hp);
|
diff.row = read_mv_component(r, &ctx->comps[0], use_hp);
|
||||||
@@ -971,8 +948,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
mbmi->ref_mv_idx);
|
mbmi->ref_mv_idx);
|
||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, is_compound,
|
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
|
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
|
||||||
allow_hp);
|
allow_hp);
|
||||||
@@ -1038,8 +1015,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
mbmi->ref_mv_idx);
|
mbmi->ref_mv_idx);
|
||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, is_compound,
|
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
|
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
|
||||||
allow_hp);
|
allow_hp);
|
||||||
@@ -1080,8 +1057,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
|
xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
|
||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, is_compound,
|
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
||||||
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc, mv_counts,
|
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc, mv_counts,
|
||||||
@@ -1101,8 +1078,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
mv[0].as_int = nearest_mv[0].as_int;
|
mv[0].as_int = nearest_mv[0].as_int;
|
||||||
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, is_compound,
|
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
||||||
mv[0].as_int = nearest_mv[0].as_int;
|
mv[0].as_int = nearest_mv[0].as_int;
|
||||||
@@ -1122,8 +1099,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
mv[0].as_int = near_mv[0].as_int;
|
mv[0].as_int = near_mv[0].as_int;
|
||||||
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, is_compound,
|
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
||||||
mv[0].as_int = near_mv[0].as_int;
|
mv[0].as_int = near_mv[0].as_int;
|
||||||
@@ -1143,8 +1120,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
|
xd->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
|
||||||
nmv_context_counts *const mv_counts =
|
nmv_context_counts *const mv_counts =
|
||||||
counts ? &counts->mv[nmv_ctx] : NULL;
|
counts ? &counts->mv[nmv_ctx] : NULL;
|
||||||
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, is_compound,
|
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], mv_counts, allow_hp);
|
mv_counts, allow_hp);
|
||||||
#else
|
#else
|
||||||
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
nmv_context_counts *const mv_counts = counts ? &counts->mv : NULL;
|
||||||
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc, mv_counts,
|
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc->nmvc, mv_counts,
|
||||||
|
@@ -116,8 +116,6 @@ struct macroblock {
|
|||||||
int *nmvcost_hp[NMV_CONTEXTS][2];
|
int *nmvcost_hp[NMV_CONTEXTS][2];
|
||||||
int **mv_cost_stack[NMV_CONTEXTS];
|
int **mv_cost_stack[NMV_CONTEXTS];
|
||||||
int *nmvjointsadcost;
|
int *nmvjointsadcost;
|
||||||
int zero_rmv_cost[NMV_CONTEXTS][2];
|
|
||||||
int comp_rmv_cost[2];
|
|
||||||
#else
|
#else
|
||||||
int nmvjointcost[MV_JOINTS];
|
int nmvjointcost[MV_JOINTS];
|
||||||
int *nmvcost[2];
|
int *nmvcost[2];
|
||||||
|
@@ -164,8 +164,6 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
|
|||||||
write_mv_update(av1_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS,
|
write_mv_update(av1_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS,
|
||||||
w);
|
w);
|
||||||
|
|
||||||
av1_cond_prob_diff_update(w, &mvc->zero_rmv, counts->zero_rmv);
|
|
||||||
|
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
nmv_component *comp = &mvc->comps[i];
|
nmv_component *comp = &mvc->comps[i];
|
||||||
nmv_component_counts *comp_counts = &counts->comps[i];
|
nmv_component_counts *comp_counts = &counts->comps[i];
|
||||||
@@ -242,20 +240,9 @@ void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref,
|
|||||||
const MV diff = { mv->row - ref->row, mv->col - ref->col };
|
const MV diff = { mv->row - ref->row, mv->col - ref->col };
|
||||||
const MV_JOINT_TYPE j = av1_get_mv_joint(&diff);
|
const MV_JOINT_TYPE j = av1_get_mv_joint(&diff);
|
||||||
usehp = usehp && av1_use_mv_hp(ref);
|
usehp = usehp && av1_use_mv_hp(ref);
|
||||||
|
#if CONFIG_REF_MV
|
||||||
#if CONFIG_REF_MV && !CONFIG_EXT_INTER
|
|
||||||
if (is_compound) {
|
|
||||||
aom_write(w, (j == MV_JOINT_ZERO), mvctx->zero_rmv);
|
|
||||||
if (j == MV_JOINT_ZERO) return;
|
|
||||||
} else {
|
|
||||||
if (j == MV_JOINT_ZERO) assert(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_REF_MV && CONFIG_EXT_INTER
|
|
||||||
(void)is_compound;
|
(void)is_compound;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
av1_write_token(w, av1_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]);
|
av1_write_token(w, av1_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]);
|
||||||
if (mv_joint_vertical(j))
|
if (mv_joint_vertical(j))
|
||||||
encode_mv_component(w, diff.row, &mvctx->comps[0], usehp);
|
encode_mv_component(w, diff.row, &mvctx->comps[0], usehp);
|
||||||
|
@@ -346,9 +346,6 @@ void av1_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int ref,
|
|||||||
x->nmvjointcost = x->nmv_vec_cost[nmv_ctx];
|
x->nmvjointcost = x->nmv_vec_cost[nmv_ctx];
|
||||||
x->mvsadcost = x->mvcost;
|
x->mvsadcost = x->mvcost;
|
||||||
x->nmvjointsadcost = x->nmvjointcost;
|
x->nmvjointsadcost = x->nmvjointcost;
|
||||||
|
|
||||||
x->nmv_vec_cost[nmv_ctx][MV_JOINT_ZERO] =
|
|
||||||
x->zero_rmv_cost[nmv_ctx][1] - x->zero_rmv_cost[nmv_ctx][0];
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -372,21 +369,11 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) {
|
|||||||
int nmv_ctx;
|
int nmv_ctx;
|
||||||
|
|
||||||
for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) {
|
for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) {
|
||||||
aom_prob tmp_prob = cm->fc->nmvc[nmv_ctx].joints[MV_JOINT_ZERO];
|
|
||||||
cm->fc->nmvc[nmv_ctx].joints[MV_JOINT_ZERO] = 1;
|
|
||||||
|
|
||||||
av1_build_nmv_cost_table(
|
av1_build_nmv_cost_table(
|
||||||
x->nmv_vec_cost[nmv_ctx],
|
x->nmv_vec_cost[nmv_ctx],
|
||||||
cm->allow_high_precision_mv ? x->nmvcost_hp[nmv_ctx]
|
cm->allow_high_precision_mv ? x->nmvcost_hp[nmv_ctx]
|
||||||
: x->nmvcost[nmv_ctx],
|
: x->nmvcost[nmv_ctx],
|
||||||
&cm->fc->nmvc[nmv_ctx], cm->allow_high_precision_mv);
|
&cm->fc->nmvc[nmv_ctx], cm->allow_high_precision_mv);
|
||||||
cm->fc->nmvc[nmv_ctx].joints[MV_JOINT_ZERO] = tmp_prob;
|
|
||||||
|
|
||||||
x->nmv_vec_cost[nmv_ctx][MV_JOINT_ZERO] = 0;
|
|
||||||
x->zero_rmv_cost[nmv_ctx][0] =
|
|
||||||
av1_cost_bit(cm->fc->nmvc[nmv_ctx].zero_rmv, 0);
|
|
||||||
x->zero_rmv_cost[nmv_ctx][1] =
|
|
||||||
av1_cost_bit(cm->fc->nmvc[nmv_ctx].zero_rmv, 1);
|
|
||||||
}
|
}
|
||||||
x->mvcost = x->mv_cost_stack[0];
|
x->mvcost = x->mv_cost_stack[0];
|
||||||
x->nmvjointcost = x->nmv_vec_cost[0];
|
x->nmvjointcost = x->nmv_vec_cost[0];
|
||||||
|
Reference in New Issue
Block a user