Abstract b_calculate_psnr to AV1_PRIMARY

Moved b_calculate_psnr from AV1_COMP to AV1_PRIMARY.

Change-Id: I494302f5e55bee020a03895d4a73a940e13098d5
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 6f751cc..7f29e4b 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -2263,7 +2263,8 @@
 
   if (res == AOM_CODEC_OK) {
     // Set up internal flags
-    if (ctx->base.init_flags & AOM_CODEC_USE_PSNR) cpi->b_calculate_psnr = 1;
+    if (ctx->base.init_flags & AOM_CODEC_USE_PSNR)
+      cpi->ppi->b_calculate_psnr = 1;
 
     if (img != NULL) {
       if (!ctx->pts_offset_initialized) {
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index c9fa963..55706b1 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -849,6 +849,7 @@
   ppi->seq_params_locked = 0;
   ppi->lap_enabled = num_lap_buffers > 0;
   ppi->output_pkt_list = pkt_list_head;
+  ppi->b_calculate_psnr = CONFIG_INTERNAL_STATS;
   return ppi;
 }
 
@@ -935,7 +936,6 @@
 
   cpi->refresh_frame.alt_ref_frame = false;
 
-  cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS;
 #if CONFIG_INTERNAL_STATS
   cpi->b_calculate_blockiness = 1;
   cpi->b_calculate_consistency = 1;
@@ -952,7 +952,7 @@
   cpi->tx_search_count = 0;
 #endif  // CONFIG_SPEED_STATS
 
-  if (cpi->b_calculate_psnr) {
+  if (cpi->ppi->b_calculate_psnr) {
     cpi->total_sq_error[0] = 0;
     cpi->total_samples[0] = 0;
     cpi->total_sq_error[1] = 0;
@@ -1469,7 +1469,7 @@
           (double)cpi->oxcf.rc_cfg.target_bandwidth / 1000;
       const double rate_err = ((100.0 * (dr - target_rate)) / target_rate);
 
-      if (cpi->b_calculate_psnr) {
+      if (cpi->ppi->b_calculate_psnr) {
         const double total_psnr =
             aom_sse_to_psnr((double)cpi->total_samples[0], peak,
                             (double)cpi->total_sq_error[0]);
@@ -3593,7 +3593,7 @@
 
     cpi->count[0]++;
     cpi->count[1]++;
-    if (cpi->b_calculate_psnr) {
+    if (cpi->ppi->b_calculate_psnr) {
       PSNR_STATS psnr;
       double weight[2] = { 0.0, 0.0 };
       double frame_ssim2[2] = { 0.0, 0.0 };
@@ -3777,7 +3777,7 @@
   cpi->time_compress_data += aom_usec_timer_elapsed(&cmptimer);
 #endif  // CONFIG_INTERNAL_STATS
   // Note *size = 0 indicates a dropped frame for which psnr is not calculated
-  if (cpi->b_calculate_psnr && *size > 0) {
+  if (cpi->ppi->b_calculate_psnr && *size > 0) {
     if (cm->show_existing_frame ||
         (!is_stat_generation_stage(cpi) && cm->show_frame)) {
       generate_psnr_packet(cpi);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 823e712..b7e2248 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -2111,6 +2111,11 @@
    * Parameters for AV1 bitstream levels.
    */
   AV1LevelParams level_params;
+
+  /*!
+   * Calculates PSNR on each frame when set to 1.
+   */
+  int b_calculate_psnr;
 } AV1_PRIMARY;
 
 /*!
@@ -2433,11 +2438,6 @@
   /*!\endcond */
 #endif
 
-  /*!
-   * Calculates PSNR on each frame when set to 1.
-   */
-  int b_calculate_psnr;
-
 #if CONFIG_SPEED_STATS
   /*!
    * For debugging: number of transform searches we have performed.
@@ -3266,7 +3266,7 @@
 static AOM_INLINE int is_psnr_calc_enabled(const AV1_COMP *cpi) {
   const AV1_COMMON *const cm = &cpi->common;
 
-  return cpi->b_calculate_psnr && !is_stat_generation_stage(cpi) &&
+  return cpi->ppi->b_calculate_psnr && !is_stat_generation_stage(cpi) &&
          cm->show_frame;
 }