Commit 3f338830 authored by Jingning Han's avatar Jingning Han

Pre-store the pred_diff for nmv context

Replace the int_mv storage in the ref_mv_stack struct with unit8_t
integer to indicate the prediction difference level.

Change-Id: I0bfbcab350a46ecdd5bc47bd918cce9614365227
parent 18d38f6c
......@@ -165,7 +165,7 @@ static INLINE void set_default_gmparams(WarpedMotionParams *wm) {
typedef struct candidate_mv {
int_mv this_mv;
int_mv comp_mv;
int_mv pred_mv[2];
uint8_t pred_diff[2];
int weight;
} CANDIDATE_MV;
#endif
......
......@@ -35,8 +35,8 @@ static uint8_t add_ref_mv_candidate(
// Add a new item to the list.
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv;
ref_mv_stack[index].pred_mv[0] =
get_sub_block_pred_mv(candidate_mi, ref, col, block);
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, ref, col, block), this_refmv);
ref_mv_stack[index].weight = 2 * len;
++(*refmv_count);
......@@ -61,8 +61,9 @@ static uint8_t add_ref_mv_candidate(
// Add a new item to the list.
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv;
ref_mv_stack[index].pred_mv[0] =
get_sub_block_pred_mv(candidate_mi, ref, col, alt_block);
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, ref, col, alt_block),
this_refmv);
ref_mv_stack[index].weight = len;
++(*refmv_count);
......@@ -97,10 +98,10 @@ static uint8_t add_ref_mv_candidate(
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv[0];
ref_mv_stack[index].comp_mv = this_refmv[1];
ref_mv_stack[index].pred_mv[0] =
get_sub_block_pred_mv(candidate_mi, 0, col, block);
ref_mv_stack[index].pred_mv[1] =
get_sub_block_pred_mv(candidate_mi, 1, col, block);
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, 0, col, block), this_refmv[0]);
ref_mv_stack[index].pred_diff[1] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, 1, col, block), this_refmv[1]);
ref_mv_stack[index].weight = 2 * len;
++(*refmv_count);
......@@ -131,10 +132,12 @@ static uint8_t add_ref_mv_candidate(
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv[0];
ref_mv_stack[index].comp_mv = this_refmv[1];
ref_mv_stack[index].pred_mv[0] =
get_sub_block_pred_mv(candidate_mi, 0, col, block);
ref_mv_stack[index].pred_mv[1] =
get_sub_block_pred_mv(candidate_mi, 1, col, block);
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, 0, col, block),
this_refmv[0]);
ref_mv_stack[index].pred_diff[0] = av1_get_pred_diff_ctx(
get_sub_block_pred_mv(candidate_mi, 1, col, block),
this_refmv[1]);
ref_mv_stack[index].weight = len;
++(*refmv_count);
......@@ -356,7 +359,8 @@ static int add_col_ref_mv(const AV1_COMMON *cm,
#if CONFIG_SIMP_MV_PRED
ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->mv[ref];
#else
ref_mv_stack[idx].pred_mv[0] = prev_frame_mvs->pred_mv[ref];
ref_mv_stack[idx].pred_diff[0] =
av1_get_pred_diff_ctx(prev_frame_mvs->pred_mv[ref], this_refmv);
#endif
ref_mv_stack[idx].weight = 2;
++(*refmv_count);
......
......@@ -362,24 +362,24 @@ static INLINE void lower_mv_precision(MV *mv, int allow_hp) {
}
#if CONFIG_REF_MV
static INLINE uint8_t av1_get_pred_diff_ctx(const int_mv pred_mv,
const int_mv this_mv) {
if (abs(this_mv.as_mv.row - pred_mv.as_mv.row) <= 4 &&
abs(this_mv.as_mv.col - pred_mv.as_mv.col) <= 4)
return 2;
else
return 1;
}
static INLINE int av1_nmv_ctx(const uint8_t ref_mv_count,
const CANDIDATE_MV *ref_mv_stack, int ref,
int ref_mv_idx) {
int_mv this_mv = (ref == 0) ? ref_mv_stack[ref_mv_idx].this_mv
: ref_mv_stack[ref_mv_idx].comp_mv;
#if CONFIG_EXT_INTER
return 0;
#endif
if (ref_mv_stack[ref_mv_idx].weight >= REF_CAT_LEVEL && ref_mv_count > 0) {
if (abs(this_mv.as_mv.row -
ref_mv_stack[ref_mv_idx].pred_mv[ref].as_mv.row) <= 4 &&
abs(this_mv.as_mv.col -
ref_mv_stack[ref_mv_idx].pred_mv[ref].as_mv.col) <= 4)
return 2;
else
return 1;
}
if (ref_mv_stack[ref_mv_idx].weight >= REF_CAT_LEVEL && ref_mv_count > 0)
return ref_mv_stack[ref_mv_idx].pred_diff[ref];
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment