]> granicus.if.org Git - libvpx/commitdiff
vp9: Reduce stack usage of choose_partioning.
authorJerome Jiang <jianj@google.com>
Mon, 30 Oct 2017 20:24:29 +0000 (13:24 -0700)
committerJerome Jiang <jianj@google.com>
Mon, 30 Oct 2017 20:53:20 +0000 (13:53 -0700)
Change type of sum_square_error from int64_t to uint32_t.
Change type of sum_error from int64_t to int32_t.

This reduces the stack usage from ~131K to ~87K.

BUG=b/68362457

Change-Id: I147d7c7b226bceb4f0817bb86848e1fa9d9ac149

vp9/encoder/vp9_encodeframe.c

index aa298acdf8703fa0f49745778fd81d3e91d38be3..51c4f6abfbb89bcac33bf87732c5b35ae3223719 100644 (file)
@@ -287,8 +287,12 @@ static void set_block_size(VP9_COMP *const cpi, MACROBLOCK *const x,
 }
 
 typedef struct {
-  int64_t sum_square_error;
-  int64_t sum_error;
+  // This struct is used for computing variance in choose_partitioning(), where
+  // the max number of samples within a superblock is 16x16 (with 4x4 avg). Even
+  // in high bitdepth, uint32_t is enough for sum_square_error (2^12 * 2^12 * 16
+  // * 16 = 2^32).
+  uint32_t sum_square_error;
+  int32_t sum_error;
   int log2_count;
   int variance;
 } var;
@@ -381,7 +385,7 @@ static void tree_to_node(void *data, BLOCK_SIZE bsize, variance_node *node) {
 }
 
 // Set variance values given sum square error, sum error, count.
-static void fill_variance(int64_t s2, int64_t s, int c, var *v) {
+static void fill_variance(uint32_t s2, int32_t s, int c, var *v) {
   v->sum_square_error = s2;
   v->sum_error = s;
   v->log2_count = c;