shithub: libvpx

Download patch

ref: 5cf8eda308e0bd54343a954a5dc0597a4f4e98eb
parent: 256a4af4d11330e4c540095b4c44e904c3ff5aba
parent: b2542417cd4dc81c49faa242c3bfdacab853ba6c
author: James Zern <jzern@google.com>
date: Fri Jul 22 21:18:31 EDT 2016

Merge changes I0089e884,Icb0ecb9e

* changes:
  vp8/postproc: fix implicit float conversion
  blockiness_test: fix implicit float conversion

--- a/test/blockiness_test.cc
+++ b/test/blockiness_test.cc
@@ -152,7 +152,7 @@
   BlockinessVP9Test() : BlockinessTestBase(GET_PARAM(0), GET_PARAM(1)) {}
 
  protected:
-  int CheckBlockiness() {
+  double GetBlockiness() const {
     return vp9_get_blockiness(source_data_, source_stride_,
                               reference_data_, reference_stride_,
                               width_, height_);
@@ -168,9 +168,10 @@
   // Source is blockier than reference.
   FillRandomBlocky(source_data_, source_stride_);
   FillConstant(reference_data_, reference_stride_, 128);
-  int super_blocky = CheckBlockiness();
+  const double super_blocky = GetBlockiness();
 
-  EXPECT_EQ(0, super_blocky) << "Blocky source should produce 0 blockiness.";
+  EXPECT_DOUBLE_EQ(0.0, super_blocky)
+      << "Blocky source should produce 0 blockiness.";
 }
 
 TEST_P(BlockinessVP9Test, ReferenceBlockierThanSource) {
@@ -177,7 +178,7 @@
   // Source is blockier than reference.
   FillConstant(source_data_, source_stride_, 128);
   FillRandomBlocky(reference_data_, reference_stride_);
-  int super_blocky = CheckBlockiness();
+  const double super_blocky = GetBlockiness();
 
   EXPECT_GT(super_blocky, 0.0)
       << "Blocky reference should score high for blockiness.";
@@ -187,10 +188,10 @@
   // Source is blockier than reference.
   FillConstant(source_data_, source_stride_, 128);
   FillRandomBlocky(reference_data_, reference_stride_);
-  int super_blocky = CheckBlockiness();
+  const double super_blocky = GetBlockiness();
 
   Blur(reference_data_, reference_stride_, 4);
-  int less_blocky = CheckBlockiness();
+  const double less_blocky = GetBlockiness();
 
   EXPECT_GT(super_blocky, less_blocky)
       << "A straight blur should decrease blockiness.";
@@ -201,10 +202,10 @@
   FillConstant(source_data_, source_stride_, 128);
   FillCheckerboard(reference_data_, reference_stride_);
 
-  int super_blocky = CheckBlockiness();
+  const double super_blocky = GetBlockiness();
 
   Blur(reference_data_, reference_stride_, 4);
-  int less_blocky = CheckBlockiness();
+  const double less_blocky = GetBlockiness();
 
   EXPECT_GT(super_blocky, less_blocky)
       << "A straight blur should decrease blockiness.";
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -24,13 +24,16 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define RGB_TO_YUV(t)                                                   \
-  ((0.257 * (float)(t >> 16)) + (0.504 * (float)(t >> 8 & 0xff)) +      \
-   (0.098 * (float)(t & 0xff)) + 16),                                   \
-      (-(0.148 * (float)(t >> 16)) - (0.291 * (float)(t >> 8 & 0xff)) + \
-       (0.439 * (float)(t & 0xff)) + 128),                              \
-      ((0.439 * (float)(t >> 16)) - (0.368 * (float)(t >> 8 & 0xff)) -  \
-       (0.071 * (float)(t & 0xff)) + 128)
+#define RGB_TO_YUV(t)                                     \
+  (unsigned char)((0.257 * (float)(t >> 16)) +            \
+                  (0.504 * (float)(t >> 8 & 0xff)) +      \
+                  (0.098 * (float)(t & 0xff)) + 16),      \
+  (unsigned char)(-(0.148 * (float)(t >> 16)) -           \
+                  (0.291 * (float)(t >> 8 & 0xff)) +      \
+                  (0.439 * (float)(t & 0xff)) + 128),     \
+  (unsigned char)((0.439 * (float)(t >> 16)) -            \
+                  (0.368 * (float)(t >> 8 & 0xff)) -      \
+                  (0.071 * (float)(t & 0xff)) + 128)
 
 /* global constants */
 #if CONFIG_POSTPROC_VISUALIZER