Commit bef4e474 authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review

Merge "Changing argument type of vp9_get_mv_joint from MV to MV*." into experimental

parents 66c0d110 0db175ff
......@@ -87,12 +87,12 @@ const nmv_context vp9_default_nmv_context = {
},
};
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;
......@@ -209,13 +209,13 @@ static void counts_to_context(nmv_component_counts *mvcomp, int usehp) {
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);
}
......
......@@ -105,7 +105,7 @@ typedef struct {
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);
......
......@@ -269,7 +269,7 @@ static void read_nmv(vp9_reader *r, MV *mv, const MV *ref,
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],
......
......@@ -556,30 +556,27 @@ void vp9_write_nmv_probs(VP9_COMP* const cpi, int usehp, vp9_writer* const bc) {
}
}
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,
......
......@@ -56,8 +56,9 @@ int vp9_mv_bit_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]) * 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],
......@@ -66,9 +67,9 @@ 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;
}
......@@ -79,10 +80,9 @@ static int mvsad_err_cost(int_mv *mv, int_mv *ref, int *mvjsadcost,
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;
}
......
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