]> granicus.if.org Git - libvpx/commitdiff
Adds a zero check in model_rd function
authorDeb Mukherjee <debargha@google.com>
Tue, 11 Jun 2013 00:02:49 +0000 (17:02 -0700)
committerDeb Mukherjee <debargha@google.com>
Tue, 11 Jun 2013 00:04:47 +0000 (17:04 -0700)
Avoids divide-by-zero when variance is 0.

Change-Id: I3c7f526979046ff7d17714ce960fe81d6e1442a0

vp9/encoder/vp9_rdopt.c

index 1b222429b3bb50799049bd6b93804e2b39f31260..7eff2d04d0c7aec2677e2eaf695ff1a15d0beae4 100644 (file)
@@ -1803,7 +1803,10 @@ static void model_rd_from_var_lapndz(int var, int n, int qstep,
   // TODO(debargha): Implement the functions by interpolating from a
   // look-up table
   vp9_clear_system_state();
-  {
+  if (var == 0 || n == 0) {
+    *rate = 0;
+    *dist = 0;
+  } else {
     double D, R;
     double s2 = (double) var / n;
     double s = sqrt(s2);