Fix initialization of skip mode costs

Initialization of skip mode costs is done
after 'skip_mode_flag' is initialized. Also, code
related to the unused variable 'type_cost' in
'GlobalMotionInfo' structure is cleaned up.

Change-Id: I3205637d903575228a23ee27fbc0c2009d97c774
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 5c8d9a8..821a6cc 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1380,8 +1380,6 @@
   }
 
   av1_frame_init_quantizer(cpi);
-  av1_initialize_rd_consts(cpi);
-  av1_set_sad_per_bit(cpi, &x->sadperbit, quant_params->base_qindex);
 
   init_encode_frame_mb_context(cpi);
   set_default_interp_skip_flags(cm, &cpi->interp_search_flags);
@@ -1432,6 +1430,14 @@
   cm->current_frame.skip_mode_info.skip_mode_flag =
       check_skip_mode_enabled(cpi);
 
+  // Initialization of skip mode cost depends on the value of
+  // 'skip_mode_flag'. This initialization happens in the function
+  // av1_fill_mode_rates(), which is in turn called in
+  // av1_initialize_rd_consts(). Thus, av1_initialize_rd_consts()
+  // has to be called after 'skip_mode_flag' is initialized.
+  av1_initialize_rd_consts(cpi);
+  av1_set_sad_per_bit(cpi, &x->sadperbit, quant_params->base_qindex);
+
   enc_row_mt->sync_read_ptr = av1_row_mt_sync_read_dummy;
   enc_row_mt->sync_write_ptr = av1_row_mt_sync_write_dummy;
   mt_info->row_mt_enabled = 0;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 22a839f..69d3a27 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -1625,12 +1625,6 @@
  */
 typedef struct {
   /*!
-   * Array to store the cost for signalling each global motion model.
-   * gmtype_cost[i] stores the cost of signalling the ith Global Motion model.
-   */
-  int type_cost[TRANS_TYPES];
-
-  /*!
    * Flag to indicate if global motion search needs to be rerun.
    */
   bool search_done;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 067028d..c47bb70 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -619,16 +619,6 @@
     av1_build_nmv_cost_table(dv_costs->joint_mv, dvcost, &cm->fc->ndvc,
                              MV_SUBPEL_NONE);
   }
-
-  if (!is_stat_generation_stage(cpi)) {
-    for (int i = 0; i < TRANS_TYPES; ++i)
-      // IDENTITY: 1 bit
-      // TRANSLATION: 3 bits
-      // ROTZOOM: 2 bits
-      // AFFINE: 3 bits
-      cpi->gm_info.type_cost[i] = (1 + (i > 0 ? (i == ROTZOOM ? 1 : 2) : 0))
-                                  << AV1_PROB_COST_SHIFT;
-  }
 }
 
 static void model_rd_norm(int xsq_q10, int *r_q10, int *d_q10) {