]> granicus.if.org Git - libvpx/commitdiff
Merge two similar functions into one
authorYaowu Xu <yaowu@google.com>
Fri, 19 Apr 2013 23:28:20 +0000 (16:28 -0700)
committerYaowu Xu <yaowu@google.com>
Wed, 24 Apr 2013 22:58:03 +0000 (15:58 -0700)
Function set_mb_row() and set_mb_col() do similar work and are always
called together, this commit merged them into a single function for
clarity and easy maintainence.  This was a TODO item.

Change-Id: I956bd9ed6afb8b2b0469b20fd8bc893b26f8a0f3

vp9/common/vp9_onyxc_int.h
vp9/decoder/vp9_decodemv.c
vp9/decoder/vp9_decodframe.c
vp9/encoder/vp9_bitstream.c
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_segmentation.c

index 3e09c864c93511f9d8e0a8cee13a35c5ffac0188..eea0894c4a57e83eba81872494c76dbfa110e167 100644 (file)
@@ -341,24 +341,18 @@ static int mb_cols_aligned_to_sb(VP9_COMMON *cm) {
   return (cm->mb_cols + 3) & ~3;
 }
 
-// TODO(debargha): merge the two functions
-static void set_mb_row(VP9_COMMON *cm, MACROBLOCKD *xd,
-                       int mb_row, int block_size) {
+static void set_mb_row_col(VP9_COMMON *cm, MACROBLOCKD *xd,
+                       int mb_row, int bh,
+                       int mb_col, int bw) {
   xd->mb_to_top_edge    = -((mb_row * 16) << 3);
-  xd->mb_to_bottom_edge = ((cm->mb_rows - block_size - mb_row) * 16) << 3;
-
-  // Are edges available for intra prediction?
-  xd->up_available    = (mb_row != 0);
-}
-
-static void set_mb_col(VP9_COMMON *cm, MACROBLOCKD *xd,
-                       int mb_col, int block_size) {
+  xd->mb_to_bottom_edge = ((cm->mb_rows - bh - mb_row) * 16) << 3;
   xd->mb_to_left_edge   = -((mb_col * 16) << 3);
-  xd->mb_to_right_edge  = ((cm->mb_cols - block_size - mb_col) * 16) << 3;
+  xd->mb_to_right_edge  = ((cm->mb_cols - bw - mb_col) * 16) << 3;
 
   // Are edges available for intra prediction?
+  xd->up_available    = (mb_row != 0);
   xd->left_available  = (mb_col > cm->cur_tile_mb_col_start);
-  xd->right_available = (mb_col + block_size < cm->cur_tile_mb_col_end);
+  xd->right_available = (mb_col + bw < cm->cur_tile_mb_col_end);
 }
 
 static int get_mb_row(const MACROBLOCKD *xd) {
index a0733524d61c4201bb26a5a230d984102ca8d86a..65e81b997caba1bae2fe3d465ea4179d662f0f81 100644 (file)
@@ -620,8 +620,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
   // 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
-  set_mb_row(cm, xd, mb_row, bh);
-  set_mb_col(cm, xd, mb_col, bw);
+  set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
 
   mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
   mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
index a3445c03afca0d0196f92c0c7177a21354cf6038..a51c82853aba4363b9fc6ea50422f35fcdf07fc1 100644 (file)
@@ -801,8 +801,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
 
   // Distance of Mb to the various image edges. These are specified to 8th pel
   // as they are always compared to values that are in 1/8th pel units
-  set_mb_row(cm, xd, mb_row, bh);
-  set_mb_col(cm, xd, mb_col, bw);
+  set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
 
   xd->plane[0].dst.buf = dst_fb->y_buffer + recon_yoffset;
   xd->plane[1].dst.buf = dst_fb->u_buffer + recon_uvoffset;
index 978fdcdfecd0b6ddbcb4224eaa8e6a9e3ac90278..df58a911371ec98a19d1b0f7deaafb501b463f4d 100644 (file)
@@ -710,8 +710,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
   // These specified to 8th pel as they are always compared to MV
   // values that are in 1/8th pel units
 
-  set_mb_row(pc, xd, mb_row, bh);
-  set_mb_col(pc, xd, mb_col, bw);
+  set_mb_row_col(pc, xd, mb_row, bh, mb_col, bw);
 
 #ifdef ENTROPY_STATS
   active_section = 9;
@@ -1151,8 +1150,9 @@ static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
   MACROBLOCKD *const xd = &cpi->mb.e_mbd;
 
   xd->mode_info_context = m;
-  set_mb_row(&cpi->common, xd, mb_row, 1 << mb_height_log2(m->mbmi.sb_type));
-  set_mb_col(&cpi->common, xd, mb_col, 1 << mb_width_log2(m->mbmi.sb_type));
+  set_mb_row_col(&cpi->common, xd, mb_row,
+                 1 << mb_height_log2(m->mbmi.sb_type),
+                 mb_col, 1 << mb_width_log2(m->mbmi.sb_type));
   if (cm->frame_type == KEY_FRAME) {
     write_mb_modes_kf(cpi, m, bc,
                       cm->mb_rows - mb_row, cm->mb_cols - mb_col);
index 5bc1644001c57bfb5694b39c58b075d22ce4f5cb..7dc77d91f35a01e37a6c306944d221003ec12d17 100644 (file)
@@ -579,8 +579,7 @@ static void set_offsets(VP9_COMP *cpi,
 
   // Set up distance of MB to edge of frame in 1/8th pel units
   assert(!(mb_col & (bw - 1)) && !(mb_row & (bh - 1)));
-  set_mb_row(cm, xd, mb_row, bh);
-  set_mb_col(cm, xd, mb_col, bw);
+  set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
 
   /* set up source buffers */
   setup_pred_block(&x->src, cpi->Source, mb_row, mb_col, NULL, NULL);
index e441107e7a8ee1b6600a761ae238819ceaa77093..6e61250d4a350b752b14c330470666278ec3a634 100644 (file)
@@ -524,15 +524,15 @@ void vp9_first_pass(VP9_COMP *cpi) {
     x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16)
                     + (VP9BORDERINPIXELS - 16);
 
-    set_mb_row(cm, xd, mb_row, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
-
     // for each macroblock col in image
     for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
       int this_error;
       int gf_motion_error = INT_MAX;
       int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
 
-      set_mb_col(cm, xd, mb_col, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
+      set_mb_row_col(cm, xd,
+                     mb_row, 1 << mb_height_log2(BLOCK_SIZE_MB16X16),
+                     mb_col, 1 << mb_height_log2(BLOCK_SIZE_MB16X16));
       xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
       xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
       xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
index 56484e6936aa11f6c534c794677e2ed3f86e700b..40b18797510cf605c2ab0e13b102f364e50fa5c0 100644 (file)
@@ -133,8 +133,7 @@ static void count_segs(VP9_COMP *cpi,
   const int segment_id = mi->mbmi.segment_id;
 
   xd->mode_info_context = mi;
-  set_mb_row(cm, xd, mb_row, bh);
-  set_mb_col(cm, xd, mb_col, bw);
+  set_mb_row_col(cm, xd, mb_row, bh, mb_col, bw);
 
   // Count the number of hits on each segment with no prediction
   no_pred_segcounts[segment_id]++;