]> granicus.if.org Git - libvpx/commitdiff
Unify motion vector cost system
authorJingning Han <jingning@google.com>
Fri, 19 Feb 2016 19:53:24 +0000 (11:53 -0800)
committerJingning Han <jingning@google.com>
Mon, 22 Feb 2016 06:21:28 +0000 (22:21 -0800)
This commit unifies the motion vector cost buffers for full pixel
and sub-pixel motion search. The new motion vector coding system
provides 0.5% coding gains for 720p and above sequences and 0.2%
for lower resolution sets.

Change-Id: I927ec81eadc39d11a3c12b375221a1ddd2e8bf24

vp10/encoder/block.h
vp10/encoder/encoder.c
vp10/encoder/mcomp.c
vp10/encoder/rd.c
vp10/encoder/temporal_filter.c

index aa91393985f369ef21801f3be370aa3c209920d2..0c3e48feacadbd78dac6077d5bf72270e79e0aa6 100644 (file)
@@ -113,15 +113,15 @@ struct macroblock {
   int *nmvcost[NMV_CONTEXTS][2];
   int *nmvcost_hp[NMV_CONTEXTS][2];
   int **mv_cost_stack[NMV_CONTEXTS];
+  int *nmvjointsadcost;
 #else
   int nmvjointcost[MV_JOINTS];
   int *nmvcost[2];
   int *nmvcost_hp[2];
+  int nmvjointsadcost[MV_JOINTS];
 #endif
 
   int **mvcost;
-
-  int nmvjointsadcost[MV_JOINTS];
   int *nmvsadcost[2];
   int *nmvsadcost_hp[2];
   int **mvsadcost;
index 1ecd668eef8838b1f27801688a9c27af52e05eec..cadd53b53fa64c07c868123d6d018abec98305c6 100644 (file)
@@ -1627,12 +1627,14 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) {
 #endif
 #define log2f(x) (log (x) / (float) M_LOG2_E)
 
+#if !CONFIG_REF_MV
 static void cal_nmvjointsadcost(int *mvjointsadcost) {
   mvjointsadcost[0] = 600;
   mvjointsadcost[1] = 300;
   mvjointsadcost[2] = 300;
   mvjointsadcost[3] = 300;
 }
+#endif
 
 static void cal_nmvsadcosts(int *mvsadcost[2]) {
   int i = 1;
@@ -1794,7 +1796,6 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf,
 
   cpi->first_time_stamp_ever = INT64_MAX;
 
-  cal_nmvjointsadcost(cpi->td.mb.nmvjointsadcost);
 #if CONFIG_REF_MV
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     cpi->td.mb.nmvcost[i][0] = &cpi->nmv_costs[i][0][MV_MAX];
@@ -1803,6 +1804,7 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf,
     cpi->td.mb.nmvcost_hp[i][1] = &cpi->nmv_costs_hp[i][1][MV_MAX];
   }
 #else
+  cal_nmvjointsadcost(cpi->td.mb.nmvjointsadcost);
   cpi->td.mb.nmvcost[0] = &cpi->nmvcosts[0][MV_MAX];
   cpi->td.mb.nmvcost[1] = &cpi->nmvcosts[1][MV_MAX];
   cpi->td.mb.nmvcost_hp[0] = &cpi->nmvcosts_hp[0][MV_MAX];
index dd19e029f75130e4add75ac7d05c99f86968a7de..6e3b06ab9cecb20d7b67576ccb04936ad461d517 100644 (file)
@@ -97,12 +97,22 @@ static int mv_err_cost(const MV *mv, const MV *ref, const int *mvjcost,
 
 static int mvsad_err_cost(const MACROBLOCK *x, const MV *mv, const MV *ref,
                           int sad_per_bit) {
+#if CONFIG_REF_MV
+  const MV diff = { (mv->row - ref->row) << 3,
+                    (mv->col - ref->col) << 3 };
+  return ROUND_POWER_OF_TWO(
+      (unsigned)mv_cost(&diff, x->nmvjointsadcost, x->mvsadcost) *
+          sad_per_bit,
+      VP9_PROB_COST_SHIFT);
+#else
   const MV diff = { mv->row - ref->row,
                     mv->col - ref->col };
+
   return ROUND_POWER_OF_TWO(
       (unsigned)mv_cost(&diff, x->nmvjointsadcost, x->nmvsadcost) *
           sad_per_bit,
       VP9_PROB_COST_SHIFT);
+#endif
 }
 
 void vp10_init_dsmotion_compensation(search_site_config *cfg, int stride) {
index 77fc1622814fcee36f3fe1dd7d7e04c5c176c4c6..299b7612b4dc90d04af8b5781f52a0195c68360b 100644 (file)
@@ -338,6 +338,8 @@ void vp10_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame) {
                              mbmi_ext->ref_mv_stack[ref_frame]);
   x->mvcost = x->mv_cost_stack[nmv_ctx];
   x->nmvjointcost = x->nmv_vec_cost[nmv_ctx];
+  x->mvsadcost = x->mvcost;
+  x->nmvjointsadcost = x->nmvjointcost;
 }
 #endif
 
@@ -382,6 +384,8 @@ void vp10_initialize_rd_consts(VP10_COMP *cpi) {
     }
     x->mvcost = x->mv_cost_stack[0];
     x->nmvjointcost = x->nmv_vec_cost[0];
+    x->mvsadcost = x->mvcost;
+    x->nmvjointsadcost = x->nmvjointcost;
 #else
     vp10_build_nmv_cost_table(x->nmvjointcost,
                              cm->allow_high_precision_mv ? x->nmvcost_hp
index 035b66abf129754d0313321a6f313f02f7bc8bd0..afe555d5af026428b7b06b7955d2e7d9333ee412 100644 (file)
@@ -293,6 +293,13 @@ static int temporal_filter_find_matching_mb_c(VP10_COMP *cpi,
   step_param = mv_sf->reduce_first_step_size;
   step_param = VPXMIN(step_param, MAX_MVSEARCH_STEPS - 2);
 
+#if CONFIG_REF_MV
+  x->mvcost = x->mv_cost_stack[0];
+  x->nmvjointcost = x->nmv_vec_cost[0];
+  x->mvsadcost = x->mvcost;
+  x->nmvjointsadcost = x->nmvjointcost;
+#endif
+
   // Ignore mv costing by sending NULL pointer instead of cost arrays
   vp10_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1,
                  cond_cost_list(cpi, cost_list),