Remove CONFIG_SEGMENT_PRED_LAST config flag

This tool is fully adopted.

Change-Id: Iddcd0150a018fa5f18f532fe0dd3cceb95ecea16
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index 0de5683..f692366 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -48,41 +48,6 @@
   cm->MBs = cm->mb_rows * cm->mb_cols;
 }
 
-#if !CONFIG_SEGMENT_PRED_LAST
-static int alloc_seg_map(AV1_COMMON *cm, int rows, int cols) {
-  int i;
-  int seg_map_size = rows * cols;
-
-  for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
-    cm->seg_map_array[i] = (uint8_t *)aom_calloc(seg_map_size, 1);
-    if (cm->seg_map_array[i] == NULL) return 1;
-  }
-  cm->seg_map_alloc_size = seg_map_size;
-
-  // Init the index.
-  cm->seg_map_idx = 0;
-  cm->prev_seg_map_idx = 1;
-
-  cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
-  cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];
-
-  return 0;
-}
-
-static void free_seg_map(AV1_COMMON *cm) {
-  int i;
-
-  for (i = 0; i < NUM_PING_PONG_BUFFERS; ++i) {
-    aom_free(cm->seg_map_array[i]);
-    cm->seg_map_array[i] = NULL;
-  }
-
-  cm->current_frame_seg_map = NULL;
-  cm->last_frame_seg_map = NULL;
-  cm->seg_map_alloc_size = 0;
-}
-#endif
-
 void av1_free_ref_frame_buffers(BufferPool *pool) {
   int i;
 
@@ -94,10 +59,8 @@
     }
     aom_free(pool->frame_bufs[i].mvs);
     pool->frame_bufs[i].mvs = NULL;
-#if CONFIG_SEGMENT_PRED_LAST
     aom_free(pool->frame_bufs[i].seg_map);
     pool->frame_bufs[i].seg_map = NULL;
-#endif
     aom_free_frame_buffer(&pool->frame_bufs[i].buf);
   }
 }
@@ -215,9 +178,6 @@
   cm->boundary_info_alloc_size = 0;
   cm->boundary_info = NULL;
 
-#if !CONFIG_SEGMENT_PRED_LAST
-  free_seg_map(cm);
-#endif
   for (i = 0; i < MAX_MB_PLANE; i++) {
     aom_free(cm->above_context[i]);
     cm->above_context[i] = NULL;
@@ -262,14 +222,6 @@
     cm->boundary_info_alloc_size = new_boundary_info_alloc_size;
   }
 
-#if !CONFIG_SEGMENT_PRED_LAST
-  if (cm->seg_map_alloc_size < cm->mi_rows * cm->mi_cols) {
-    // Create the segmentation map structure and set to 0.
-    free_seg_map(cm);
-    if (alloc_seg_map(cm, cm->mi_rows, cm->mi_cols)) goto fail;
-  }
-#endif
-
   if (cm->above_context_alloc_cols < cm->mi_cols) {
     // TODO(geza.lore): These are bigger than they need to be.
     // cm->tile_width would be enough but it complicates indexing a
@@ -329,21 +281,4 @@
   cm->frame_contexts = NULL;
 }
 
-void av1_init_context_buffers(AV1_COMMON *cm) {
-  cm->setup_mi(cm);
-#if !CONFIG_SEGMENT_PRED_LAST
-  if (cm->last_frame_seg_map)
-    memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols);
-#endif
-}
-#if !CONFIG_SEGMENT_PRED_LAST
-void av1_swap_current_and_last_seg_map(AV1_COMMON *cm) {
-  // Swap indices.
-  const int tmp = cm->seg_map_idx;
-  cm->seg_map_idx = cm->prev_seg_map_idx;
-  cm->prev_seg_map_idx = tmp;
-
-  cm->current_frame_seg_map = cm->seg_map_array[cm->seg_map_idx];
-  cm->last_frame_seg_map = cm->seg_map_array[cm->prev_seg_map_idx];
-}
-#endif
+void av1_init_context_buffers(AV1_COMMON *cm) { cm->setup_mi(cm); }
diff --git a/av1/common/alloccommon.h b/av1/common/alloccommon.h
index a3a6270..4a86dff 100644
--- a/av1/common/alloccommon.h
+++ b/av1/common/alloccommon.h
@@ -37,10 +37,6 @@
 void av1_set_mb_mi(struct AV1Common *cm, int width, int height);
 int av1_get_MBs(int width, int height);
 
-#if !CONFIG_SEGMENT_PRED_LAST
-void av1_swap_current_and_last_seg_map(struct AV1Common *cm);
-#endif
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 6d04efd..fe44290 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1180,14 +1180,7 @@
 
   av1_clearall_segfeatures(&cm->seg);
 
-#if CONFIG_SEGMENT_PRED_LAST
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
-#endif
-
-#if !CONFIG_SEGMENT_PRED_LAST
-  if (cm->last_frame_seg_map)
-    memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
-#endif
 
   if (cm->current_frame_seg_map)
     memset(cm->current_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index fa233e6..067bfd1 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -120,10 +120,8 @@
   unsigned int ref_frame_offset[INTER_REFS_PER_FRAME];
 
   MV_REF *mvs;
-#if CONFIG_SEGMENT_PRED_LAST
   uint8_t *seg_map;
   struct segmentation seg;
-#endif
   int mi_rows;
   int mi_cols;
   // Width and height give the size of the buffer (before any upscaling, unlike
@@ -386,13 +384,6 @@
   // Whether to use previous frame's motion vectors for prediction.
   int use_ref_frame_mvs;
 
-#if !CONFIG_SEGMENT_PRED_LAST
-  // Persistent mb segment id map used in prediction.
-  int seg_map_idx;
-  int prev_seg_map_idx;
-
-  uint8_t *seg_map_array[NUM_PING_PONG_BUFFERS];
-#endif
   uint8_t *last_frame_seg_map;
   uint8_t *current_frame_seg_map;
   int seg_map_alloc_size;
@@ -671,12 +662,10 @@
                     (MV_REF *)aom_calloc(
                         ((cm->mi_rows + 1) >> 1) * ((cm->mi_cols + 1) >> 1),
                         sizeof(*buf->mvs)));
-#if CONFIG_SEGMENT_PRED_LAST
     aom_free(buf->seg_map);
     CHECK_MEM_ERROR(cm, buf->seg_map,
                     (uint8_t *)aom_calloc(cm->mi_rows * cm->mi_cols,
                                           sizeof(*buf->seg_map)));
-#endif
   }
 
   const int mem_size =
diff --git a/av1/common/seg_common.h b/av1/common/seg_common.h
index 8c6849a..b1ac760 100644
--- a/av1/common/seg_common.h
+++ b/av1/common/seg_common.h
@@ -69,7 +69,6 @@
   return seg->enabled && (seg->feature_mask[segment_id] & (1 << feature_id));
 }
 
-#if CONFIG_SEGMENT_PRED_LAST
 static INLINE void segfeatures_copy(struct segmentation *dst,
                                     struct segmentation *src) {
   int i, j;
@@ -92,7 +91,6 @@
     }
   }
 }
-#endif
 
 void av1_clearall_segfeatures(struct segmentation *seg);
 
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 85cea50..75c999ab 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -823,16 +823,13 @@
 
   seg->enabled = aom_rb_read_bit(rb);
   if (!seg->enabled) {
-#if CONFIG_SEGMENT_PRED_LAST
     if (cm->cur_frame->seg_map)
       memset(cm->cur_frame->seg_map, 0, (cm->mi_rows * cm->mi_cols));
 
     memset(seg, 0, sizeof(*seg));
     segfeatures_copy(&cm->cur_frame->seg, seg);
-#endif  // CONFIG_SEGMENT_PRED_LAST
     return;
   }
-#if CONFIG_SEGMENT_PRED_LAST
   if (cm->seg.enabled && cm->prev_frame &&
       (cm->mi_rows == cm->prev_frame->mi_rows) &&
       (cm->mi_cols == cm->prev_frame->mi_cols)) {
@@ -840,7 +837,6 @@
   } else {
     cm->last_frame_seg_map = NULL;
   }
-#endif
   // Read update flags
   if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
     // These frames can't use previous frames, so must signal map + features
@@ -857,10 +853,6 @@
     seg->update_data = aom_rb_read_bit(rb);
   }
 
-#if !CONFIG_SEGMENT_PRED_LAST && CONFIG_SPATIAL_SEGMENTATION
-  seg->preskip_segid = 0;
-#endif
-
   // Segmentation data update
   if (seg->update_data) {
     av1_clearall_segfeatures(seg);
@@ -870,10 +862,6 @@
         int data = 0;
         const int feature_enabled = aom_rb_read_bit(rb);
         if (feature_enabled) {
-#if !CONFIG_SEGMENT_PRED_LAST && CONFIG_SPATIAL_SEGMENTATION
-          seg->preskip_segid |= j >= SEG_LVL_REF_FRAME;
-          seg->last_active_segid = i;
-#endif
           av1_enable_segfeature(seg, i, j);
 
           const int data_max = av1_seg_feature_data_max(j);
@@ -891,11 +879,9 @@
         av1_set_segdata(seg, i, j, data);
       }
     }
-#if CONFIG_SEGMENT_PRED_LAST
     segfeatures_copy(&cm->cur_frame->seg, seg);
   } else if (cm->prev_frame) {
     segfeatures_copy(seg, &cm->prev_frame->seg);
-#endif
   }
 }
 
@@ -3403,9 +3389,7 @@
 
   cm->setup_mi(cm);
 
-#if CONFIG_SEGMENT_PRED_LAST
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
-#endif
 
   av1_setup_motion_field(cm);
 
diff --git a/av1/decoder/decoder.c b/av1/decoder/decoder.c
index 2838da7..b0245b9 100644
--- a/av1/decoder/decoder.c
+++ b/av1/decoder/decoder.c
@@ -380,16 +380,12 @@
     cm->last_show_frame = cm->show_frame;
 
     if (cm->seg.enabled) {
-#if CONFIG_SEGMENT_PRED_LAST
       if (cm->prev_frame && (cm->mi_rows == cm->prev_frame->mi_rows) &&
           (cm->mi_cols == cm->prev_frame->mi_cols)) {
         cm->last_frame_seg_map = cm->prev_frame->seg_map;
       } else {
         cm->last_frame_seg_map = NULL;
       }
-#else
-      av1_swap_current_and_last_seg_map(cm);
-#endif
     }
   }
 
diff --git a/av1/encoder/aq_complexity.c b/av1/encoder/aq_complexity.c
index 633c4ad..94d04e2 100644
--- a/av1/encoder/aq_complexity.c
+++ b/av1/encoder/aq_complexity.c
@@ -48,23 +48,19 @@
 void av1_setup_in_frame_q_adj(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   struct segmentation *const seg = &cm->seg;
-#if CONFIG_SEGMENT_PRED_LAST
   int resolution_change =
       (cm->width != cm->last_width || cm->height != cm->last_height) &&
       cm->prev_frame;
-#endif
 
   // Make SURE use of floating point in this function is safe.
   aom_clear_system_state();
 
-#if CONFIG_SEGMENT_PRED_LAST
   if (resolution_change) {
     memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
     av1_clearall_segfeatures(seg);
     av1_disable_segmentation(seg);
     return;
   }
-#endif
 
   if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
       cpi->refresh_alt_ref_frame ||
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index 8d27068..6b2b091 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -481,7 +481,6 @@
   CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
   struct segmentation *const seg = &cm->seg;
   const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc);
-#if CONFIG_SEGMENT_PRED_LAST
   int resolution_change =
       (cm->width != cm->last_width || cm->height != cm->last_height) &&
       cm->prev_frame;
@@ -492,7 +491,6 @@
     av1_disable_segmentation(seg);
     return;
   }
-#endif
   if (cm->current_video_frame == 0) cr->low_content_avg = 0.0;
   // Don't apply refresh on key frame or enhancement layer frames.
   if (!apply_cyclic_refresh || cm->frame_type == KEY_FRAME) {
diff --git a/av1/encoder/aq_variance.c b/av1/encoder/aq_variance.c
index fc7e295..d73ebdb 100644
--- a/av1/encoder/aq_variance.c
+++ b/av1/encoder/aq_variance.c
@@ -47,7 +47,6 @@
   struct segmentation *seg = &cm->seg;
   int i;
 
-#if CONFIG_SEGMENT_PRED_LAST
   int resolution_change =
       (cm->width != cm->last_width || cm->height != cm->last_height) &&
       cm->prev_frame;
@@ -58,7 +57,6 @@
     av1_disable_segmentation(seg);
     return;
   }
-#endif
   if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
       cpi->refresh_alt_ref_frame ||
       (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index afe2d9d..20d8b4b 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2135,10 +2135,6 @@
     aom_wb_write_bit(wb, seg->update_data);
   }
 
-#if !CONFIG_SEGMENT_PRED_LAST && CONFIG_SPATIAL_SEGMENTATION
-  seg->preskip_segid = 0;
-#endif
-
   // Segmentation data
   if (seg->update_data) {
     for (i = 0; i < MAX_SEGMENTS; i++) {
@@ -2146,10 +2142,6 @@
         const int active = segfeature_active(seg, i, j);
         aom_wb_write_bit(wb, active);
         if (active) {
-#if !CONFIG_SEGMENT_PRED_LAST && CONFIG_SPATIAL_SEGMENTATION
-          seg->preskip_segid |= j >= SEG_LVL_REF_FRAME;
-          seg->last_active_segid = i;
-#endif
           const int data_max = av1_seg_feature_data_max(j);
           const int data_min = -data_max;
           const int ubits = get_unsigned_bits(data_max);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index b6a927c..f139898 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4231,13 +4231,11 @@
   av1_initialize_me_consts(cpi, x, cm->base_qindex);
   init_encode_frame_mb_context(cpi);
 
-#if CONFIG_SEGMENT_PRED_LAST
   if (cm->prev_frame)
     cm->last_frame_seg_map = cm->prev_frame->seg_map;
   else
     cm->last_frame_seg_map = NULL;
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
-#endif
 
   // Special case: set prev_mi to NULL when the previous mode info
   // context cannot be used.
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index e3741a4..ec164bf 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -365,13 +365,11 @@
   cm->prev_frame = get_prev_frame(cm);
   cpi->vaq_refresh = 0;
 
-#if CONFIG_SEGMENT_PRED_LAST
   if (cm->prev_frame)
     cm->last_frame_seg_map = cm->prev_frame->seg_map;
   else
     cm->last_frame_seg_map = NULL;
   cm->current_frame_seg_map = cm->cur_frame->seg_map;
-#endif
 }
 
 static void enc_setup_mi(AV1_COMMON *cm) {
@@ -720,11 +718,7 @@
 static void update_reference_segmentation_map(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   MODE_INFO **mi_8x8_ptr = cm->mi_grid_visible;
-#if CONFIG_SEGMENT_PRED_LAST
   uint8_t *cache_ptr = cm->current_frame_seg_map;
-#else
-  uint8_t *cache_ptr = cm->last_frame_seg_map;
-#endif
   int row, col;
 
   for (row = 0; row < cm->mi_rows; row++) {
@@ -4335,7 +4329,6 @@
     av1_cyclic_refresh_setup(cpi);
   }
   apply_active_map(cpi);
-#if CONFIG_SEGMENT_PRED_LAST
   if (cm->seg.enabled) {
     if (cm->seg.update_data) {
       segfeatures_copy(&cm->cur_frame->seg, &cm->seg);
@@ -4343,7 +4336,6 @@
       segfeatures_copy(&cm->seg, &cm->prev_frame->seg);
     }
   }
-#endif
 
   // transform / motion compensation build reconstruction frame
   av1_encode_frame(cpi);
@@ -4444,7 +4436,6 @@
     } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) {
       av1_setup_in_frame_q_adj(cpi);
     }
-#if CONFIG_SEGMENT_PRED_LAST
     if (cm->seg.enabled) {
       if (cm->seg.update_data) {
         segfeatures_copy(&cm->cur_frame->seg, &cm->seg);
@@ -4452,7 +4443,6 @@
         segfeatures_copy(&cm->seg, &cm->prev_frame->seg);
       }
     }
-#endif
 
     // transform / motion compensation build reconstruction frame
     save_coding_context(cpi);
@@ -5169,7 +5159,6 @@
   dump_filtered_recon_frames(cpi);
 #endif  // DUMP_RECON_FRAMES
 
-#if CONFIG_SEGMENT_PRED_LAST
   if (cm->seg.enabled) {
     if (cm->seg.update_map) {
       update_reference_segmentation_map(cpi);
@@ -5178,9 +5167,6 @@
              cm->mi_cols * cm->mi_rows * sizeof(uint8_t));
     }
   }
-#else
-  if (cm->seg.update_map) update_reference_segmentation_map(cpi);
-#endif
 
   if (frame_is_intra_only(cm) == 0) {
     release_scaled_references(cpi);
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 83fb26a..ac657c8 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -114,7 +114,6 @@
 set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SCALABILITY 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SEGMENT_GLOBALMV 1 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_SEGMENT_PRED_LAST 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SHORT_FILTER 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SKIP_SGR 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SPATIAL_SEGMENTATION 1 CACHE NUMBER "AV1 experiment flag.")