]> granicus.if.org Git - libvpx/commitdiff
fix a bug of tiny_ssim to handle odd frame sizes
authorLiu Peng <pengliu.mail@gmail.com>
Fri, 14 Sep 2018 21:25:44 +0000 (16:25 -0500)
committerpeng liu <pengliu.mail@gmail.com>
Fri, 14 Sep 2018 21:51:40 +0000 (21:51 +0000)
Change-Id: Id8ef0eb211517a8f8ec764ec398d16efb9320540

tools/tiny_ssim.c

index d6b213859584a17fd83b8661aaaadb0ba8790665..315d1c1f407f55ad5131bb0658dce7449d516af7 100644 (file)
@@ -121,7 +121,7 @@ static int open_input_file(const char *file_name, input_file_t *input, int w,
         input->w = w;
         input->h = h;
         // handle odd frame sizes
-        input->frame_size = w * h + ((w + 1) / 2 * (h + 1) / 2) * 2;
+        input->frame_size = w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2;
         if (bit_depth > 8) {
           input->frame_size *= 2;
         }
@@ -156,12 +156,12 @@ static size_t read_input_file(input_file_t *in, unsigned char **y,
         r1 = fread(in->buf, in->frame_size, 1, in->file);
         *y = in->buf;
         *u = in->buf + in->w * in->h;
-        *v = *u + (1 + in->w) / 2 * (1 + in->h) / 2;
+        *v = *u + ((1 + in->w) / 2) * ((1 + in->h) / 2);
       } else {
         r1 = fread(in->buf, in->frame_size, 1, in->file);
         *y = in->buf;
         *u = in->buf + (in->w * in->h) * 2;
-        *v = *u + 2 * ((1 + in->w) / 2 * (1 + in->h) / 2);
+        *v = *u + 2 * ((1 + in->w) / 2) * ((1 + in->h) / 2);
       }
       break;
   }