shithub: libvpx

Download patch

ref: d1b65c6bda3ea8ccaf4e052c34a4723fa76d865d
parent: 41ff8d7aaadd6cddad99dbb36bc4be5fc165d7f9
author: Dmitry Kovalev <dkovalev@google.com>
date: Mon Oct 21 06:12:14 EDT 2013

Moving allow_high_precision_mv from MACROBLOCKD to VP9_COMMON.

This value is a global frame-level flag, not a macroblock-level.

Change-Id: Ie8c5790a931150741c2167c00c3e3dd2cf26744d

--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -222,8 +222,6 @@
 
   struct subpix_fn_table  subpix;
 
-  int allow_high_precision_mv;
-
   int corrupted;
 
   unsigned char sb_index;   // index of 32x32 block inside the 64x64 block
--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -22,14 +22,12 @@
 }
 
 
-void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
-                           int_mv *mvlist,
-                           int_mv *nearest,
-                           int_mv *near) {
+void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
+                           int_mv *mvlist, int_mv *nearest, int_mv *near) {
   int i;
   // Make sure all the candidates are properly clamped etc
   for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
-    lower_mv_precision(&mvlist[i].as_mv, xd->allow_high_precision_mv);
+    lower_mv_precision(&mvlist[i].as_mv, allow_hp);
     clamp_mv2(&mvlist[i].as_mv, xd);
   }
   *nearest = mvlist[0];
--- a/vp9/common/vp9_findnearmv.h
+++ b/vp9/common/vp9_findnearmv.h
@@ -23,10 +23,8 @@
 // check a list of motion vectors by sad score using a number rows of pixels
 // above and a number cols of pixels in the left to select the one with best
 // score to use as ref motion vector
-void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
-                           int_mv *mvlist,
-                           int_mv *nearest,
-                           int_mv *near);
+void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
+                           int_mv *mvlist, int_mv *nearest, int_mv *near);
 
 // TODO(jingning): this mv clamping function should be block size dependent.
 static void clamp_mv2(MV *mv, const MACROBLOCKD *xd) {
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -129,6 +129,8 @@
   // Flag signaling that the frame is encoded using only INTRA modes.
   int intra_only;
 
+  int allow_high_precision_mv;
+
   // Flag signaling that the frame context should be reset to default values.
   // 0 or 1 implies don't reset, 2 reset just the context specified in the
   // frame header, 3 reset all contexts.
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -487,7 +487,7 @@
                                        int mi_row, int mi_col, vp9_reader *r) {
   MB_MODE_INFO *const mbmi = &mi->mbmi;
   const BLOCK_SIZE bsize = mbmi->sb_type;
-  const int allow_hp = xd->allow_high_precision_mv;
+  const int allow_hp = cm->allow_high_precision_mv;
 
   int_mv nearest[2], nearmv[2], best[2];
   uint8_t inter_mode_ctx;
@@ -518,7 +518,8 @@
 
   // nearest, nearby
   if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) {
-    vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref0], &nearest[0], &nearmv[0]);
+    vp9_find_best_ref_mvs(xd, allow_hp,
+                          mbmi->ref_mvs[ref0], &nearest[0], &nearmv[0]);
     best[0].as_int = nearest[0].as_int;
   }
 
@@ -528,7 +529,8 @@
                      ref1, mbmi->ref_mvs[ref1], mi_row, mi_col);
 
     if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) {
-      vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref1], &nearest[1], &nearmv[1]);
+      vp9_find_best_ref_mvs(xd, allow_hp,
+                            mbmi->ref_mvs[ref1], &nearest[1], &nearmv[1]);
       best[1].as_int = nearest[1].as_int;
     }
   }
@@ -630,8 +632,7 @@
       vp9_diff_update_prob(r, &cm->fc.comp_ref_prob[i]);
 }
 
-void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) {
-  VP9_COMMON *const cm = &pbi->common;
+void vp9_prepare_read_mode_info(VP9_COMMON *cm, vp9_reader *r) {
   int k;
 
   // TODO(jkoleszar): does this clear more than MBSKIP_CONTEXTS? Maybe remove.
@@ -640,8 +641,7 @@
     vp9_diff_update_prob(r, &cm->fc.mbskip_probs[k]);
 
   if (!frame_is_intra_only(cm)) {
-    nmv_context *const nmvc = &pbi->common.fc.nmvc;
-    MACROBLOCKD *const xd = &pbi->mb;
+    nmv_context *const nmvc = &cm->fc.nmvc;
     int i, j;
 
     read_inter_mode_probs(&cm->fc, r);
@@ -662,7 +662,7 @@
       for (i = 0; i < PARTITION_TYPES - 1; ++i)
         vp9_diff_update_prob(r, &cm->fc.partition_prob[INTER_FRAME][j][i]);
 
-    read_mv_probs(r, nmvc, xd->allow_high_precision_mv);
+    read_mv_probs(r, nmvc, cm->allow_high_precision_mv);
   }
 }
 
--- a/vp9/decoder/vp9_decodemv.h
+++ b/vp9/decoder/vp9_decodemv.h
@@ -14,7 +14,7 @@
 #include "vp9/decoder/vp9_onyxd_int.h"
 #include "vp9/decoder/vp9_dboolhuff.h"
 
-void vp9_prepare_read_mode_info(VP9D_COMP *pbi, vp9_reader *r);
+void vp9_prepare_read_mode_info(VP9_COMMON* cm, vp9_reader *r);
 
 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
                         int mi_row, int mi_col, vp9_reader *r);
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -796,7 +796,6 @@
 static size_t read_uncompressed_header(VP9D_COMP *pbi,
                                        struct vp9_read_bit_buffer *rb) {
   VP9_COMMON *const cm = &pbi->common;
-  MACROBLOCKD *const xd = &pbi->mb;
   size_t sz;
   int i;
 
@@ -875,7 +874,7 @@
 
       setup_frame_size_with_refs(pbi, rb);
 
-      xd->allow_high_precision_mv = vp9_rb_read_bit(rb);
+      cm->allow_high_precision_mv = vp9_rb_read_bit(rb);
       cm->mcomp_filter_type = read_interp_filter_type(rb);
 
       for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i)
@@ -925,7 +924,7 @@
     read_tx_probs(&cm->fc.tx_probs, &r);
   read_coef_probs(&cm->fc, cm->tx_mode, &r);
 
-  vp9_prepare_read_mode_info(pbi, &r);
+  vp9_prepare_read_mode_info(cm, &r);
 
   return vp9_reader_has_error(&r);
 }
@@ -1030,7 +1029,7 @@
 
     if (!frame_is_intra_only(cm)) {
       vp9_adapt_mode_probs(cm);
-      vp9_adapt_mv_probs(cm, xd->allow_high_precision_mv);
+      vp9_adapt_mv_probs(cm, cm->allow_high_precision_mv);
     }
   }
 
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -402,7 +402,7 @@
   const int segment_id = mi->segment_id;
   int skip_coeff;
   const BLOCK_SIZE bsize = mi->sb_type;
-  const int allow_hp = xd->allow_high_precision_mv;
+  const int allow_hp = cm->allow_high_precision_mv;
 
 #ifdef ENTROPY_STATS
   active_section = 9;
@@ -1309,7 +1309,6 @@
 static void write_uncompressed_header(VP9_COMP *cpi,
                                       struct vp9_write_bit_buffer *wb) {
   VP9_COMMON *const cm = &cpi->common;
-  MACROBLOCKD *const xd = &cpi->mb.e_mbd;
 
   // frame marker bits
   vp9_wb_write_literal(wb, 0x2, 2);
@@ -1374,7 +1373,7 @@
 
       write_frame_size_with_refs(cpi, wb);
 
-      vp9_wb_write_bit(wb, xd->allow_high_precision_mv);
+      vp9_wb_write_bit(wb, cm->allow_high_precision_mv);
 
       fix_mcomp_filter_type(cpi);
       write_interp_filter_type(cm->mcomp_filter_type, wb);
@@ -1472,7 +1471,7 @@
                   (unsigned int *)cpi->partition_count[i]);
     }
 
-    vp9_write_nmv_probs(cpi, xd->allow_high_precision_mv, &header_bc);
+    vp9_write_nmv_probs(cpi, cm->allow_high_precision_mv, &header_bc);
   }
 
   vp9_stop_encode(&header_bc);
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -61,7 +61,7 @@
     best_err = cpi->find_fractional_mv_step(
         x,
         &dst_mv->as_mv, &ref_mv->as_mv,
-        xd->allow_high_precision_mv,
+        cpi->common.allow_high_precision_mv,
         x->errorperbit, &v_fn_ptr,
         0, cpi->sf.subpel_iters_per_step, NULL, NULL,
         & distortion, &sse);
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -237,8 +237,9 @@
   return active_best_quality;
 }
 
-static void set_mvcost(MACROBLOCK *mb) {
-  if (mb->e_mbd.allow_high_precision_mv) {
+static void set_mvcost(VP9_COMP *cpi) {
+  MACROBLOCK *const mb = &cpi->mb;
+  if (cpi->common.allow_high_precision_mv) {
     mb->mvcost = mb->nmvcost_hp;
     mb->mvsadcost = mb->nmvsadcost_hp;
   } else {
@@ -1261,8 +1262,8 @@
   cm->reset_frame_context = 0;
 
   setup_features(cm);
-  cpi->mb.e_mbd.allow_high_precision_mv = 0;  // Default mv precision
-  set_mvcost(&cpi->mb);
+  cpi->common.allow_high_precision_mv = 0;  // Default mv precision
+  set_mvcost(cpi);
 
   {
     int i;
@@ -2818,7 +2819,6 @@
                                       unsigned char *dest,
                                       unsigned int *frame_flags) {
   VP9_COMMON *const cm = &cpi->common;
-  MACROBLOCKD *const xd = &cpi->mb.e_mbd;
   TX_SIZE t;
   int q;
   int frame_over_shoot_limit;
@@ -2987,8 +2987,8 @@
   if (!frame_is_intra_only(cm)) {
     cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
     /* TODO: Decide this more intelligently */
-    xd->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH;
-    set_mvcost(&cpi->mb);
+    cm->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH;
+    set_mvcost(cpi);
   }
 
 #if CONFIG_VP9_POSTPROC
@@ -3277,7 +3277,7 @@
     if (!cpi->common.error_resilient_mode &&
         !cpi->common.frame_parallel_decoding_mode) {
       vp9_adapt_mode_probs(&cpi->common);
-      vp9_adapt_mv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv);
+      vp9_adapt_mv_probs(&cpi->common, cpi->common.allow_high_precision_mv);
     }
   }
 
@@ -3601,8 +3601,8 @@
 
   cpi->source = NULL;
 
-  cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
-  set_mvcost(&cpi->mb);
+  cpi->common.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
+  set_mvcost(cpi);
 
   // Should we code an alternate reference frame.
   if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -261,10 +261,10 @@
   if (!frame_is_intra_only(&cpi->common)) {
     vp9_build_nmv_cost_table(
         cpi->mb.nmvjointcost,
-        cpi->mb.e_mbd.allow_high_precision_mv ?
+        cpi->common.allow_high_precision_mv ?
         cpi->mb.nmvcost_hp : cpi->mb.nmvcost,
         &cpi->common.fc.nmvc,
-        cpi->mb.e_mbd.allow_high_precision_mv, 1, 1);
+        cpi->common.allow_high_precision_mv, 1, 1);
 
     for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
       MB_PREDICTION_MODE m;
@@ -1860,7 +1860,7 @@
             cpi->find_fractional_mv_step(x,
                                          &mode_mv[NEWMV].as_mv,
                                          &bsi->ref_mv->as_mv,
-                                         x->e_mbd.allow_high_precision_mv,
+                                         cpi->common.allow_high_precision_mv,
                                          x->errorperbit, v_fn_ptr,
                                          0, cpi->sf.subpel_iters_per_step,
                                          x->nmvjointcost, x->mvcost,
@@ -2293,7 +2293,7 @@
                    mbmi->ref_mvs[frame_type], mi_row, mi_col);
 
   // Candidate refinement carried out at encoder and decoder
-  vp9_find_best_ref_mvs(xd,
+  vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv,
                         mbmi->ref_mvs[frame_type],
                         &frame_nearest_mv[frame_type],
                         &frame_near_mv[frame_type]);
@@ -2441,7 +2441,7 @@
     int dis;  /* TODO: use dis in distortion calculation later. */
     unsigned int sse;
     cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv.as_mv,
-                                 xd->allow_high_precision_mv,
+                                 cm->allow_high_precision_mv,
                                  x->errorperbit,
                                  &cpi->fn_ptr[block_size],
                                  0, cpi->sf.subpel_iters_per_step,
@@ -2577,7 +2577,7 @@
       bestsme = cpi->find_fractional_mv_step_comp(
           x, &tmp_mv.as_mv,
           &ref_mv[id].as_mv,
-          xd->allow_high_precision_mv,
+          cpi->common.allow_high_precision_mv,
           x->errorperbit,
           &cpi->fn_ptr[block_size],
           0, cpi->sf.subpel_iters_per_step,
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -166,7 +166,7 @@
     // Ignore mv costing by sending NULL pointer instead of cost array
     bestsme = cpi->find_fractional_mv_step(x, &ref_mv->as_mv,
                                            &best_ref_mv1.as_mv,
-                                           xd->allow_high_precision_mv,
+                                           cpi->common.allow_high_precision_mv,
                                            x->errorperbit,
                                            &cpi->fn_ptr[BLOCK_16X16],
                                            0, cpi->sf.subpel_iters_per_step,