},
};
-MV_JOINT_TYPE vp9_get_mv_joint(MV mv) {
- if (mv.row == 0 && mv.col == 0)
+MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv) {
+ if (mv->row == 0 && mv->col == 0)
return MV_JOINT_ZERO;
- else if (mv.row == 0 && mv.col != 0)
+ else if (mv->row == 0 && mv->col != 0)
return MV_JOINT_HNZVZ;
- else if (mv.row != 0 && mv.col == 0)
+ else if (mv->row != 0 && mv->col == 0)
return MV_JOINT_HZVNZ;
else
return MV_JOINT_HNZVNZ;
void vp9_increment_nmv(const MV *mv, const MV *ref, nmv_context_counts *mvctx,
int usehp) {
- const MV_JOINT_TYPE type = vp9_get_mv_joint(*mv);
- mvctx->joints[type]++;
+ const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
+ mvctx->joints[j]++;
usehp = usehp && vp9_use_nmv_hp(ref);
- if (mv_joint_vertical(type))
+ if (mv_joint_vertical(j))
increment_nmv_component_count(mv->row, &mvctx->comps[0], 1, usehp);
- if (mv_joint_horizontal(type))
+ if (mv_joint_horizontal(j))
increment_nmv_component_count(mv->col, &mvctx->comps[1], 1, usehp);
}
nmv_component comps[2];
} nmv_context;
-MV_JOINT_TYPE vp9_get_mv_joint(MV mv);
+MV_JOINT_TYPE vp9_get_mv_joint(const MV *mv);
MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset);
int vp9_get_mv_mag(MV_CLASS_TYPE c, int offset);
static void read_nmv_fp(vp9_reader *r, MV *mv, const MV *ref,
const nmv_context *mvctx, int usehp) {
- const MV_JOINT_TYPE j = vp9_get_mv_joint(*mv);
+ const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
usehp = usehp && vp9_use_nmv_hp(ref);
if (mv_joint_vertical(j))
mv->row = read_nmv_component_fp(r, mv->row, ref->row, &mvctx->comps[0],
}
}
-void vp9_encode_nmv(vp9_writer* const bc, const MV* const mv,
+void vp9_encode_nmv(vp9_writer* w, const MV* const mv,
const MV* const ref, const nmv_context* const mvctx) {
- MV_JOINT_TYPE j = vp9_get_mv_joint(*mv);
- write_token(bc, vp9_mv_joint_tree, mvctx->joints,
- vp9_mv_joint_encodings + j);
- if (mv_joint_vertical(j)) {
- encode_nmv_component(bc, mv->row, ref->col, &mvctx->comps[0]);
- }
- if (mv_joint_horizontal(j)) {
- encode_nmv_component(bc, mv->col, ref->col, &mvctx->comps[1]);
- }
+ const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
+ write_token(w, vp9_mv_joint_tree, mvctx->joints, vp9_mv_joint_encodings + j);
+ if (mv_joint_vertical(j))
+ encode_nmv_component(w, mv->row, ref->col, &mvctx->comps[0]);
+
+ if (mv_joint_horizontal(j))
+ encode_nmv_component(w, mv->col, ref->col, &mvctx->comps[1]);
}
void vp9_encode_nmv_fp(vp9_writer* const bc, const MV* const mv,
const MV* const ref, const nmv_context* const mvctx,
int usehp) {
- MV_JOINT_TYPE j = vp9_get_mv_joint(*mv);
+ const MV_JOINT_TYPE j = vp9_get_mv_joint(mv);
usehp = usehp && vp9_use_nmv_hp(ref);
- if (mv_joint_vertical(j)) {
+ if (mv_joint_vertical(j))
encode_nmv_component_fp(bc, mv->row, ref->row, &mvctx->comps[0], usehp);
- }
- if (mv_joint_horizontal(j)) {
+
+ if (mv_joint_horizontal(j))
encode_nmv_component_fp(bc, mv->col, ref->col, &mvctx->comps[1], usehp);
- }
}
void vp9_build_nmv_cost_table(int *mvjoint,
MV v;
v.row = mv->as_mv.row - ref->as_mv.row;
v.col = mv->as_mv.col - ref->as_mv.col;
- return ((mvjcost[vp9_get_mv_joint(v)] +
- mvcost[0][v.row] + mvcost[1][v.col]) * weight) >> 7;
+ return ((mvjcost[vp9_get_mv_joint(&v)] +
+ mvcost[0][v.row] +
+ mvcost[1][v.col]) * weight) >> 7;
}
static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2],
MV v;
v.row = mv->as_mv.row - ref->as_mv.row;
v.col = mv->as_mv.col - ref->as_mv.col;
- return ((mvjcost[vp9_get_mv_joint(v)] +
- mvcost[0][v.row] + mvcost[1][v.col]) *
- error_per_bit + 4096) >> 13;
+ return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] +
+ mvcost[0][v.row] +
+ mvcost[1][v.col]) * error_per_bit, 13);
}
return 0;
}
MV v;
v.row = mv->as_mv.row - ref->as_mv.row;
v.col = mv->as_mv.col - ref->as_mv.col;
-
- return ROUND_POWER_OF_TWO((mvjsadcost[vp9_get_mv_joint(v)] +
- mvsadcost[0][v.row] + mvsadcost[1][v.col]) *
- error_per_bit, 8);
+ return ROUND_POWER_OF_TWO((mvjsadcost[vp9_get_mv_joint(&v)] +
+ mvsadcost[0][v.row] +
+ mvsadcost[1][v.col]) * error_per_bit, 8);
}
return 0;
}