Add values in TplParams to store gop bitrate.

These values store the estimated and actual GOP
bitrate for the CONFIG_BITRATE_ACCURACY experiment.

Change-Id: I97e5cc08c195d475322126a54f8743aae8e81a15
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 4eeb2c0..a416b6c 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2660,8 +2660,10 @@
       rc->projected_frame_size = (int)(*size) << 3;
 
 #if CONFIG_BITRATE_ACCURACY
-      printf("\nframe: %d, projected frame size: %d\n", cpi->gf_frame_index,
-             rc->projected_frame_size);
+      cpi->ppi->tpl_data.actual_gop_bitrate += rc->projected_frame_size;
+      printf("\nframe: %d, projected frame size: %d, total: %f\n",
+             cpi->gf_frame_index, rc->projected_frame_size,
+             cpi->ppi->tpl_data.actual_gop_bitrate);
 #endif
     }
 
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 2729949..f8889a4 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -1502,6 +1502,10 @@
     TplDepFrame *tpl_frame = &tpl_data->tpl_stats_buffer[frame_idx];
     av1_tpl_stats_init_txfm_stats(tpl_frame, tpl_data->tpl_bsize_1d);
   }
+#if CONFIG_BITRATE_ACCURACY
+  tpl_data->estimated_gop_bitrate = 0;
+  tpl_data->actual_gop_bitrate = 0;
+#endif
 }
 
 static AOM_INLINE int eval_gop_length(double *beta, int gop_eval) {
@@ -1631,9 +1635,12 @@
   }
 
 #if CONFIG_BITRATE_ACCURACY
-  double gop_bitrate = av1_estimate_gop_bitrate(gf_group->q_val, gf_group->size,
-                                                tpl_data->txfm_stats_list);
-  printf("\nestimated bitrate: %f\n", gop_bitrate);
+  tpl_data->estimated_gop_bitrate = av1_estimate_gop_bitrate(
+      gf_group->q_val, gf_group->size, tpl_data->txfm_stats_list);
+  if (gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE &&
+      gop_eval == 0) {
+    printf("\nestimated bitrate: %f\n", tpl_data->estimated_gop_bitrate);
+  }
 #endif
 
   for (int frame_idx = tpl_gf_group_frames - 1;
diff --git a/av1/encoder/tpl_model.h b/av1/encoder/tpl_model.h
index 1d3b310..64a765d 100644
--- a/av1/encoder/tpl_model.h
+++ b/av1/encoder/tpl_model.h
@@ -215,6 +215,14 @@
    * Frame border for tpl frame.
    */
   int border_in_pixels;
+
+#if CONFIG_BITRATE_ACCURACY
+  /*
+   * Estimated and actual GOP bitrate.
+   */
+  double estimated_gop_bitrate;
+  double actual_gop_bitrate;
+#endif
 } TplParams;
 
 /*!\brief Allocate buffers used by tpl model