Apply active map

active map isn't applied even when enabled.

Change-Id: I1107de63869f7716a04d0a2f3921191ac9d403e6
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index ef4cd7d..cff3918 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -136,30 +136,27 @@
                        int cols) {
   const CommonModeInfoParams *const mi_params = &cpi->common.mi_params;
   if (rows == mi_params->mb_rows && cols == mi_params->mb_cols) {
-    unsigned char *const active_map_8x8 = cpi->active_map.map;
+    unsigned char *const active_map_4x4 = cpi->active_map.map;
     const int mi_rows = mi_params->mi_rows;
     const int mi_cols = mi_params->mi_cols;
     const int row_scale = mi_size_high[BLOCK_16X16] == 2 ? 1 : 2;
     const int col_scale = mi_size_wide[BLOCK_16X16] == 2 ? 1 : 2;
-    cpi->active_map.update = 1;
+    cpi->active_map.update = 0;
     if (new_map_16x16) {
-      int r, c;
-      for (r = 0; r < mi_rows; ++r) {
-        for (c = 0; c < mi_cols; ++c) {
-          active_map_8x8[r * mi_cols + c] =
+      for (int r = 0; r < mi_rows; ++r) {
+        for (int c = 0; c < mi_cols; ++c) {
+          active_map_4x4[r * mi_cols + c] =
               new_map_16x16[(r >> row_scale) * cols + (c >> col_scale)]
                   ? AM_SEGMENT_ID_ACTIVE
                   : AM_SEGMENT_ID_INACTIVE;
         }
       }
       cpi->active_map.enabled = 1;
-    } else {
-      cpi->active_map.enabled = 0;
     }
     return 0;
-  } else {
-    return -1;
   }
+
+  return -1;
 }
 
 int av1_get_active_map(AV1_COMP *cpi, unsigned char *new_map_16x16, int rows,
@@ -175,9 +172,8 @@
 
     memset(new_map_16x16, !cpi->active_map.enabled, rows * cols);
     if (cpi->active_map.enabled) {
-      int r, c;
-      for (r = 0; r < mi_rows; ++r) {
-        for (c = 0; c < mi_cols; ++c) {
+      for (int r = 0; r < mi_rows; ++r) {
+        for (int c = 0; c < mi_cols; ++c) {
           // Cyclic refresh segments are considered active despite not having
           // AM_SEGMENT_ID_ACTIVE
           new_map_16x16[(r >> row_scale) * cols + (c >> col_scale)] |=
@@ -186,9 +182,9 @@
       }
     }
     return 0;
-  } else {
-    return -1;
   }
+
+  return -1;
 }
 
 void av1_initialize_enc(unsigned int usage, enum aom_rc_mode end_usage) {
@@ -2448,8 +2444,8 @@
   if (q_cfg->aq_mode == CYCLIC_REFRESH_AQ) {
     suppress_active_map(cpi);
     av1_cyclic_refresh_setup(cpi);
-    av1_apply_active_map(cpi);
   }
+  av1_apply_active_map(cpi);
   if (cm->seg.enabled) {
     if (!cm->seg.update_data && cm->prev_frame) {
       segfeatures_copy(&cm->seg, &cm->prev_frame->seg);
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index 5bbb7a4..8132085 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -430,6 +430,8 @@
     cpi->active_map.update = 1;
   }
 
+  if (!cpi->active_map.enabled) return;
+
   if (cpi->active_map.update) {
     if (cpi->active_map.enabled) {
       for (i = 0;