shithub: libvpx

Download patch

ref: 9364fc04f1e4e46e3e4c51560b532aab6e1649bc
parent: 6a07d918d8c2b294d0328ee1a6a42a58b00fda01
parent: a01896354d3845bce18899cb31d1871e985c8483
author: James Zern <jzern@google.com>
date: Tue Jul 10 17:49:02 EDT 2018

Merge "vp9_encoder: only alloc tpl stats if enabled"

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2339,23 +2339,25 @@
   }
 #endif  // !CONFIG_REALTIME_ONLY
 
-  for (frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
-    int mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
-    int mi_rows = mi_cols_aligned_to_sb(cm->mi_rows);
-
-    CHECK_MEM_ERROR(cm, cpi->tpl_stats[frame].tpl_stats_ptr,
-                    vpx_calloc(mi_rows * mi_cols,
-                               sizeof(*cpi->tpl_stats[frame].tpl_stats_ptr)));
-    cpi->tpl_stats[frame].is_valid = 1;
-    cpi->tpl_stats[frame].width = mi_cols;
-    cpi->tpl_stats[frame].height = mi_rows;
-    cpi->tpl_stats[frame].stride = mi_cols;
-    cpi->tpl_stats[frame].mi_rows = cm->mi_rows;
-    cpi->tpl_stats[frame].mi_cols = cm->mi_cols;
-  }
-
   vp9_set_speed_features_framesize_independent(cpi);
   vp9_set_speed_features_framesize_dependent(cpi);
+
+  if (cpi->sf.enable_tpl_model) {
+    for (frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
+      int mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
+      int mi_rows = mi_cols_aligned_to_sb(cm->mi_rows);
+
+      CHECK_MEM_ERROR(cm, cpi->tpl_stats[frame].tpl_stats_ptr,
+                      vpx_calloc(mi_rows * mi_cols,
+                                 sizeof(*cpi->tpl_stats[frame].tpl_stats_ptr)));
+      cpi->tpl_stats[frame].is_valid = 1;
+      cpi->tpl_stats[frame].width = mi_cols;
+      cpi->tpl_stats[frame].height = mi_rows;
+      cpi->tpl_stats[frame].stride = mi_cols;
+      cpi->tpl_stats[frame].mi_rows = cm->mi_rows;
+      cpi->tpl_stats[frame].mi_cols = cm->mi_cols;
+    }
+  }
 
   // Allocate memory to store variances for a frame.
   CHECK_MEM_ERROR(cm, cpi->source_diff_var, vpx_calloc(cm->MBs, sizeof(diff)));