Encoder memory reduction: avoid the allocation of tip_frame buffer during LAP stage

The allocation of buffers corresponding to 'tip_frame' and 'tmp_tip_frame' occurs during both the LAP and ENCODE stages. However, these buffers remain unused during the LAP stage. Therefore, This patch avoids their allocation during the LAP stage.

Heap Memory Savings (%):

2.8% for 4k, 1.8% for 1080p, 2.1% for 720p, 1 - 2% for 360p, and 0.6 - 1.6% for 270p.

This change is verified to be bit-exact with no impact on encode-time.
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 5fb06dd..35bc024 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -1285,7 +1285,9 @@
   cm->superres_upscaled_height = oxcf->frm_dim_cfg.height;
   av1_loop_restoration_precal();
 
-  init_tip_ref_frame(cm);
+  // The buffers related to TIP are not used during LAP stage. Hence,
+  // the allocation is limited to encode stage.
+  if (cpi->compressor_stage == ENCODE_STAGE) init_tip_ref_frame(cm);
 #if CONFIG_OPTFLOW_ON_TIP
   init_optflow_bufs(cm);
 #endif  // CONFIG_OPTFLOW_ON_TIP
@@ -1525,7 +1527,7 @@
   cpi->ssim_vars = NULL;
 #endif  // CONFIG_INTERNAL_STATS
 
-  free_tip_ref_frame(cm);
+  if (cpi->compressor_stage == ENCODE_STAGE) free_tip_ref_frame(cm);
 #if CONFIG_OPTFLOW_ON_TIP
   free_optflow_bufs(cm);
 #endif  // CONFIG_OPTFLOW_ON_TIP
@@ -2201,7 +2203,7 @@
     }
   }
 
-  if (cm->seq_params.enable_tip) {
+  if (!is_stat_generation_stage(cpi) && cm->seq_params.enable_tip) {
     RefCntBuffer *buf = get_ref_frame_buf(cm, TIP_FRAME);
     if (buf == NULL || (buf->buf.y_crop_width != cm->width ||
                         buf->buf.y_crop_height != cm->height)) {