shithub: libvpx

Download patch

ref: 6776bd62b578e59929017c1a935682253ee8fe45
parent: a5879f7c8167b3a09bfacae41df57386ab9f11e8
author: Scott LaVarnway <slavarnway@google.com>
date: Thu Feb 16 08:36:46 EST 2012

Simplify mb_to_x_edge calculation during mode decoding

Change-Id: Ibcb35c32bf24c1d241090e24c5e2320e4d3ba901

--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -334,8 +334,7 @@
     mbmi->partitioning = s;
 }
 
-static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
-                            int mb_col)
+static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi)
 {
     vp8_reader *const bc = & pbi->bc;
     mbmi->ref_frame = (MV_REFERENCE_FRAME) vp8_read(bc, pbi->prob_intra);
@@ -426,13 +425,6 @@
 
         if( vp8_read(bc, vp8_mode_contexts [cnt[CNT_INTRA]] [0]) )
         {
-            /* Distance of Mb to the various image edges.
-             * These specified to 8th pel as they are always compared to MV
-             * values that are in 1/8th pel units
-             */
-            pbi->mb.mb_to_left_edge =  -((mb_col * 16) << 3);
-            pbi->mb.mb_to_right_edge =
-                ((pbi->common.mb_cols - 1 - mb_col) * 16) << 3;
 
             /* If we have three distinct MV's ... */
             /* See if above-left MV can be merged with NEAREST */
@@ -593,7 +585,7 @@
 }
 
 static void decode_mb_mode_mvs(VP8D_COMP *pbi, MODE_INFO *mi,
-                               MB_MODE_INFO *mbmi, int mb_col)
+                               MB_MODE_INFO *mbmi)
 {
     /* Read the Macroblock segmentation map if it is being updated explicitly
      * this frame (reset to 0 above by default)
@@ -614,7 +606,7 @@
     if(pbi->common.frame_type == KEY_FRAME)
         read_kf_modes(pbi, mi);
     else
-        read_mb_modes_mv(pbi, mi, &mi->mbmi, mb_col);
+        read_mb_modes_mv(pbi, mi, &mi->mbmi);
 
 }
 
@@ -622,16 +614,20 @@
 {
     MODE_INFO *mi = pbi->common.mi;
     int mb_row = -1;
+    int mb_to_right_edge_start;
 
     mb_mode_mv_init(pbi);
 
+    pbi->mb.mb_to_top_edge = 0;
+    pbi->mb.mb_to_bottom_edge = ((pbi->common.mb_rows - 1) * 16) << 3;
+    mb_to_right_edge_start = ((pbi->common.mb_cols - 1) * 16) << 3;
+
     while (++mb_row < pbi->common.mb_rows)
     {
         int mb_col = -1;
 
-        pbi->mb.mb_to_top_edge =  -((mb_row * 16)) << 3;
-        pbi->mb.mb_to_bottom_edge =
-            ((pbi->common.mb_rows - 1 - mb_row) * 16) << 3;
+        pbi->mb.mb_to_left_edge =  0;
+        pbi->mb.mb_to_right_edge = mb_to_right_edge_start;
 
         while (++mb_col < pbi->common.mb_cols)
         {
@@ -639,7 +635,7 @@
             int mb_num = mb_row * pbi->common.mb_cols + mb_col;
 #endif
 
-            decode_mb_mode_mvs(pbi, mi, &mi->mbmi, mb_col);
+            decode_mb_mode_mvs(pbi, mi, &mi->mbmi);
 
 #if CONFIG_ERROR_CONCEALMENT
             /* look for corruption. set mvs_corrupt_from_mb to the current
@@ -654,8 +650,12 @@
             }
 #endif
 
+            pbi->mb.mb_to_left_edge -= (16 << 3);
+            pbi->mb.mb_to_right_edge -= (16 << 3);
             mi++;       /* next macroblock */
         }
+        pbi->mb.mb_to_top_edge -= (16 << 3);
+        pbi->mb.mb_to_bottom_edge -= (16 << 3);
 
         mi++;           /* skip left predictor each row */
     }