Merge "vp9-rtc: tx_size selection for intra mode in nonrd"
diff --git a/build/make/ads2gas_apple.pl b/build/make/ads2gas_apple.pl
index 51248f7..848872f 100755
--- a/build/make/ads2gas_apple.pl
+++ b/build/make/ads2gas_apple.pl
@@ -20,8 +20,6 @@
 
 print "@ This file was created from a .asm file\n";
 print "@  using the ads2gas_apple.pl script.\n\n";
-print "\t.set WIDE_REFERENCE, 0\n";
-print "\t.set ARCHITECTURE, 5\n";
 print "\t.syntax unified\n";
 
 my %register_aliases;
diff --git a/build/make/configure.sh b/build/make/configure.sh
index 00214c9..ce3ba55 100644
--- a/build/make/configure.sh
+++ b/build/make/configure.sh
@@ -1016,9 +1016,6 @@
               EXE_SFX=.exe
               enable_feature thumb
               ;;
-            *)
-              check_add_asflags --defsym ARCHITECTURE=${arch_int}
-              ;;
           esac
 
           if enabled thumb; then
@@ -1090,7 +1087,6 @@
           fi
           arch_int=${tgt_isa##armv}
           arch_int=${arch_int%%te}
-          check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
           enabled debug && add_asflags -g
           add_cflags --gnu
           add_cflags --enum_is_int
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 8d35ac3..a5d59b6 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -270,6 +270,7 @@
   const int index = row * num_cols + col;
 
   assert(cpi->oxcf.tuning == VP8_TUNE_SSIM);
+  vpx_clear_system_state();
   return cpi->mi_ssim_rdmult_scaling_factors[index];
 }
 
@@ -312,6 +313,7 @@
     const double ssim_factor =
         get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
     x->rdmult = (int)(ssim_factor * x->rdmult);
+    vpx_clear_system_state();
   }
 
   // required by vp9_append_sub8x8_mvs_for_idx() and vp9_find_best_ref_mvs()
@@ -1963,6 +1965,7 @@
     const double ssim_factor =
         get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
     x->rdmult = (int)(ssim_factor * x->rdmult);
+    vpx_clear_system_state();
   }
 }
 
@@ -2208,6 +2211,7 @@
       const double ssim_factor =
           get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
       x->rdmult = (int)(ssim_factor * x->rdmult);
+      vpx_clear_system_state();
     }
   }
 
@@ -3823,6 +3827,7 @@
     const double ssim_factor =
         get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
     partition_mul = (int)(ssim_factor * partition_mul);
+    vpx_clear_system_state();
   }
 
   (void)*tp_orig;
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index f7e3237..34c30c8 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5816,13 +5816,6 @@
   int frame_idx;
   for (frame_idx = 0; frame_idx < MAX_ARF_GOP_SIZE; ++frame_idx) {
     TplDepFrame *tpl_frame = &cpi->tpl_stats[frame_idx];
-#if CONFIG_NON_GREEDY_MV
-    int rf_idx;
-    for (rf_idx = 0; rf_idx < 3; ++rf_idx) {
-      tpl_frame->mv_dist_sum[rf_idx] = 0;
-      tpl_frame->mv_cost_sum[rf_idx] = 0;
-    }
-#endif
     memset(tpl_frame->tpl_stats_ptr, 0,
            tpl_frame->height * tpl_frame->width *
                sizeof(*tpl_frame->tpl_stats_ptr));
@@ -5834,7 +5827,7 @@
 static uint32_t motion_compensated_prediction(
     VP9_COMP *cpi, ThreadData *td, int frame_idx, uint8_t *cur_frame_buf,
     uint8_t *ref_frame_buf, int stride, BLOCK_SIZE bsize, int mi_row,
-    int mi_col, MV *mv, int rf_idx, double *mv_dist, double *mv_cost) {
+    int mi_col, MV *mv, int rf_idx) {
 #else   // CONFIG_NON_GREEDY_MV
 static uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
                                               int frame_idx,
@@ -5859,6 +5852,8 @@
   // TODO(angiebird): Figure out lambda's proper value.
   double lambda = cpi->tpl_stats[frame_idx].lambda;
   int_mv nb_full_mvs[NB_MVS_NUM];
+  double mv_dist;
+  double mv_cost;
 #endif
 
   MV best_ref_mv1 = { 0, 0 };
@@ -5885,7 +5880,7 @@
                           bsize, nb_full_mvs);
   vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda, 1,
                              &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, mv,
-                             mv_dist, mv_cost);
+                             &mv_dist, &mv_cost);
 #else
   (void)frame_idx;
   (void)mi_row;
@@ -6239,24 +6234,12 @@
     inter_cost = vpx_satd(coeff, pix_num);
 #endif
 
-#if CONFIG_NON_GREEDY_MV
-    tpl_stats->inter_cost_arr[rf_idx] = inter_cost;
-    get_quantize_error(x, 0, coeff, qcoeff, dqcoeff, tx_size,
-                       &tpl_stats->recon_error_arr[rf_idx],
-                       &tpl_stats->sse_arr[rf_idx]);
-#endif
-
     if (inter_cost < best_inter_cost) {
       best_rf_idx = rf_idx;
       best_inter_cost = inter_cost;
       best_mv.as_int = mv.as_int;
-#if CONFIG_NON_GREEDY_MV
-      *recon_error = tpl_stats->recon_error_arr[rf_idx];
-      *sse = tpl_stats->sse_arr[rf_idx];
-#else
       get_quantize_error(x, 0, coeff, qcoeff, dqcoeff, tx_size, recon_error,
                          sse);
-#endif
     }
   }
   best_intra_cost = VPXMAX(best_intra_cost, 1);
@@ -6676,14 +6659,12 @@
     motion_compensated_prediction(
         cpi, td, frame_idx, xd->cur_buf->y_buffer + mb_y_offset,
         ref_frame[rf_idx]->y_buffer + mb_y_offset, xd->cur_buf->y_stride, bsize,
-        mi_row, mi_col, &mv->as_mv, rf_idx, &tpl_stats->mv_dist[rf_idx],
-        &tpl_stats->mv_cost[rf_idx]);
+        mi_row, mi_col, &mv->as_mv, rf_idx);
   }
 }
 
 #define CHANGE_MV_SEARCH_ORDER 1
 #define USE_PQSORT 1
-#define RE_COMPUTE_MV_INCONSISTENCY 1
 
 #if CHANGE_MV_SEARCH_ORDER
 #if USE_PQSORT
@@ -6945,29 +6926,6 @@
 
       tpl_model_update(cpi->tpl_stats, tpl_frame->tpl_stats_ptr, mi_row, mi_col,
                        bsize);
-#if CONFIG_NON_GREEDY_MV
-      {
-        int rf_idx;
-        TplDepStats *this_tpl_stats =
-            &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
-        for (rf_idx = 0; rf_idx < 3; ++rf_idx) {
-#if RE_COMPUTE_MV_INCONSISTENCY
-          MV this_mv =
-              get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row, mi_col)->as_mv;
-          MV full_mv;
-          int_mv nb_full_mvs[NB_MVS_NUM];
-          vp9_prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize,
-                                  nb_full_mvs);
-          full_mv.row = this_mv.row >> 3;
-          full_mv.col = this_mv.col >> 3;
-          this_tpl_stats->mv_cost[rf_idx] =
-              vp9_nb_mvs_inconsistency(&full_mv, nb_full_mvs, NB_MVS_NUM);
-#endif  // RE_COMPUTE_MV_INCONSISTENCY
-          tpl_frame->mv_dist_sum[rf_idx] += this_tpl_stats->mv_dist[rf_idx];
-          tpl_frame->mv_cost_sum[rf_idx] += this_tpl_stats->mv_cost[rf_idx];
-        }
-      }
-#endif  // CONFIG_NON_GREEDY_MV
     }
   }
 }
diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h
index 5eec17d..6289647 100644
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -293,10 +293,6 @@
 
 #if CONFIG_NON_GREEDY_MV
   int ready[3];
-  double mv_dist[3];
-  double mv_cost[3];
-  int64_t inter_cost_arr[3];
-  int64_t recon_error_arr[3];
   int64_t sse_arr[3];
   double feature_score;
 #endif
@@ -323,8 +319,6 @@
   int base_qindex;
 #if CONFIG_NON_GREEDY_MV
   double lambda;
-  double mv_dist_sum[3];
-  double mv_cost_sum[3];
   int_mv *pyramid_mv_arr[3][SQUARE_BLOCK_SIZES];
   int *mv_mode_arr[3];
   double *rd_diff_arr[3];