Avoid underflow in exp()

Too small negative values will cause underflow in exp().
Here we only care the value that can be accumulated.
So the clamp has no effect on final result.
exp(-15)*1000*255 = 0.07
exp(-20)*1000*65535 = 0.13

BUG=aomedia:2433

Change-Id: I00d171822cbcc45c30e5c38987c900fb5cfba7d8
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index 8941760..e755595 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -693,7 +693,10 @@
       }
       diff_sse /= WINDOW_SIZE;
 
-      double w = exp(-diff_sse / (2 * beta * h * h));
+      double scaled_diff = -diff_sse / (2 * beta * h * h);
+      // clamp the value to avoid underflow in exp()
+      if (scaled_diff < -15) scaled_diff = -15;
+      double w = exp(scaled_diff);
       const int weight = (int)(w * SCALE);
 
       count[k] += weight;
@@ -736,7 +739,10 @@
       }
       diff_sse /= WINDOW_SIZE;
 
-      double w = exp(-diff_sse / (2 * beta * h * h));
+      double scaled_diff = -diff_sse / (2 * beta * h * h);
+      // clamp the value to avoid underflow in exp()
+      if (scaled_diff < -20) scaled_diff = -20;
+      double w = exp(scaled_diff);
       const int weight = (int)(w * SCALE);
 
       count[k] += weight;