]> granicus.if.org Git - libvpx/commitdiff
Changing argument type of vp9_get_mv_joint from MV to MV*.
authorDmitry Kovalev <dkovalev@google.com>
Wed, 17 Apr 2013 18:21:28 +0000 (11:21 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Wed, 17 Apr 2013 18:21:28 +0000 (11:21 -0700)
Change-Id: I28c3026946fc1bde7074e6e0198da93bb0d75dfe

vp9/common/vp9_entropymv.c
vp9/common/vp9_entropymv.h
vp9/decoder/vp9_decodemv.c
vp9/encoder/vp9_encodemv.c
vp9/encoder/vp9_mcomp.c

index fe36677254a134e29692d382fa3eb4430c633735..0a81015cb21093be206f51a8ae4c10fb0e092f43 100644 (file)
@@ -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);
 }
 
index 715b5bb2b02e0da3110ed24d11868771a727b582..de1bd43839133e7e250d5b0288b69a234606f337 100644 (file)
@@ -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);
 
index aaa9b2ef0f5b0af85455d697bd7a932cee0e709c..abeb41c7c8ca41323db1c9fd5d04a404ee4df935 100644 (file)
@@ -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],
index 7c0b3ddeb7f1eea11e26b25394eedfce880df48a..553c69790b87c0612ebcbc7cfcab92c5b0ca4787 100644 (file)
@@ -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,
index 1649ccade648dc3d7fed1ebd7e8069dd5d601761..caba2ea85717e74654f8504f12fd605e746e6f0a 100644 (file)
@@ -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;
 }