Removing find_seg_id and using vp9_get_pred_mi_segid instead.
authorDmitry Kovalev <dkovalev@google.com>
Thu, 20 Jun 2013 22:52:47 +0000 (15:52 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Fri, 21 Jun 2013 20:05:10 +0000 (13:05 -0700)
Change-Id: Ia40229903c08f14020e90e94cfdf494aba1be827

vp9/common/vp9_pred_common.c
vp9/common/vp9_pred_common.h
vp9/decoder/vp9_decodemv.c
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_segmentation.c

index 17da4f2..d921a11 100644 (file)
@@ -501,7 +501,7 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
 
 // Macroblock segment id prediction function
 int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
-                          int mi_row, int mi_col) {
+                          uint8_t *segment_ids, int mi_row, int mi_col) {
   const int mi_index = mi_row * cm->mi_cols + mi_col;
   const int bw = 1 << mi_width_log2(sb_type);
   const int bh = 1 << mi_height_log2(sb_type);
@@ -513,7 +513,7 @@ int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
   for (y = 0; y < ymis; y++) {
     for (x = 0; x < xmis; x++) {
       const int index = mi_index + (y * cm->mi_cols + x);
-      segment_id = MIN(segment_id, cm->last_frame_seg_map[index]);
+      segment_id = MIN(segment_id, segment_ids[index]);
     }
   }
   return segment_id;
index b728724..100102b 100644 (file)
@@ -48,6 +48,6 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
 
 
 int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
-                          int mi_row, int mi_col);
+                          uint8_t *segment_ids, int mi_row, int mi_col);
 
 #endif  // VP9_COMMON_VP9_PRED_COMMON_H_
index d8836c9..ac97e5c 100644 (file)
@@ -428,6 +428,7 @@ static int read_mb_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
       // If the value is flagged as correctly predicted
       // then use the predicted value, otherwise decode it explicitly
       segment_id = pred_flag ? vp9_get_pred_mi_segid(cm, mbmi->sb_type,
+                                                     cm->last_frame_seg_map,
                                                      mi_row, mi_col)
                              : read_mb_segid(r, xd);
     } else {
@@ -437,7 +438,8 @@ static int read_mb_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
     set_segment_id(cm, mbmi, mi_row, mi_col, segment_id);  // Side effect
     return segment_id;
   } else {
-    return vp9_get_pred_mi_segid(cm, mbmi->sb_type, mi_row, mi_col);
+    return vp9_get_pred_mi_segid(cm, mbmi->sb_type, cm->last_frame_seg_map,
+                                 mi_row, mi_col);
   }
 }
 
index 35e1d64..e7b5476 100644 (file)
@@ -455,25 +455,6 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
   }
 }
 
-static unsigned find_seg_id(VP9_COMMON *cm, uint8_t *buf, BLOCK_SIZE_TYPE bsize,
-                            int start_y, int height, int start_x, int width) {
-  const int bw = 1 << mi_width_log2(bsize), bh = 1 << mi_height_log2(bsize);
-  const int end_x = MIN(start_x + bw, width);
-  const int end_y = MIN(start_y + bh, height);
-  int x, y;
-  unsigned seg_id = -1;
-
-  buf += width * start_y;
-  assert(start_y < cm->mi_rows && start_x < cm->cur_tile_mi_col_end);
-  for (y = start_y; y < end_y; y++, buf += width) {
-    for (x = start_x; x < end_x; x++) {
-      seg_id = MIN(seg_id, buf[x]);
-    }
-  }
-
-  return seg_id;
-}
-
 void vp9_setup_src_planes(MACROBLOCK *x, const YV12_BUFFER_CONFIG *src,
                           int mb_row, int mb_col) {
   uint8_t *buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer, src
@@ -551,11 +532,9 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
 
   /* segment ID */
   if (xd->segmentation_enabled) {
-    uint8_t *map =
-        xd->update_mb_segmentation_map ?
-            cpi->segmentation_map : cm->last_frame_seg_map;
-    mbmi->segment_id = find_seg_id(cm, map, bsize, mi_row, cm->mi_rows, mi_col,
-                                   cm->mi_cols);
+    uint8_t *map = xd->update_mb_segmentation_map ? cpi->segmentation_map
+                                                  : cm->last_frame_seg_map;
+    mbmi->segment_id = vp9_get_pred_mi_segid(cm, bsize, map, mi_row, mi_col);
 
     assert(mbmi->segment_id <= (MAX_MB_SEGMENTS-1));
     vp9_mb_init_quantizer(cpi, x);
index fe995ad..af218b7 100644 (file)
@@ -139,6 +139,7 @@ static void count_segs(VP9_COMP *cpi,
   if (cm->frame_type != KEY_FRAME) {
     // Test to see if the segment id matches the predicted value.
     const int pred_seg_id = vp9_get_pred_mi_segid(cm, mi->mbmi.sb_type,
+                                                  cm->last_frame_seg_map,
                                                   mi_row, mi_col);
     const int seg_predicted = (segment_id == pred_seg_id);