shithub: libvpx

Download patch

ref: bef4e474e75c5e0cf0e847133a51149b211ae7cb
parent: 66c0d1100babdb1ec17f2e9243666eeb713ce67b
parent: 0db175ffed7f82c3b2216081f5a180b914c14309
author: Dmitry Kovalev <dkovalev@google.com>
date: Thu Apr 18 10:27:44 EDT 2013

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

--- a/vp9/common/vp9_entropymv.c
+++ b/vp9/common/vp9_entropymv.c
@@ -87,12 +87,12 @@
   },
 };
 
-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 @@
 
 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);
 }
 
--- a/vp9/common/vp9_entropymv.h
+++ b/vp9/common/vp9_entropymv.h
@@ -105,7 +105,7 @@
   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);
 
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -269,7 +269,7 @@
 
 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],
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -556,30 +556,27 @@
   }
 }
 
-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,
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -56,8 +56,9 @@
   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 @@
     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 @@
     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;
 }
--