Commit 9c6e5279 authored by fbarchard@google.com's avatar fbarchard@google.com

Port compare to C89 / Visual C.

BUG=303
TESTED=cl /c /TC /Iinclude source/compare.cc
R=tpsiaki@google.com

Review URL: https://webrtc-codereview.appspot.com/7019006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@966 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 70bc4995
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 965 Version: 966
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 965 #define LIBYUV_VERSION 966
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -229,8 +229,10 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a, ...@@ -229,8 +229,10 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a,
int64 sum_sq_b = 0; int64 sum_sq_b = 0;
int64 sum_axb = 0; int64 sum_axb = 0;
for (int i = 0; i < 8; ++i) { int i;
for (int j = 0; j < 8; ++j) { for (i = 0; i < 8; ++i) {
int j;
for (j = 0; j < 8; ++j) {
sum_a += src_a[j]; sum_a += src_a[j];
sum_b += src_b[j]; sum_b += src_b[j];
sum_sq_a += src_a[j] * src_a[j]; sum_sq_a += src_a[j] * src_a[j];
...@@ -242,6 +244,7 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a, ...@@ -242,6 +244,7 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a,
src_b += stride_b; src_b += stride_b;
} }
{
const int64 count = 64; const int64 count = 64;
// scale the constants by number of pixels // scale the constants by number of pixels
const int64 c1 = (cc1 * count * count) >> 12; const int64 c1 = (cc1 * count * count) >> 12;
...@@ -259,9 +262,11 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a, ...@@ -259,9 +262,11 @@ static double Ssim8x8_C(const uint8* src_a, int stride_a,
(count * sum_sq_a - sum_a_sq + (count * sum_sq_a - sum_a_sq +
count * sum_sq_b - sum_b_sq + c2); count * sum_sq_b - sum_b_sq + c2);
if (ssim_d == 0.0) if (ssim_d == 0.0) {
return DBL_MAX; return DBL_MAX;
}
return ssim_n * 1.0 / ssim_d; return ssim_n * 1.0 / ssim_d;
}
} }
// We are using a 8x8 moving window with starting location of each 8x8 window // We are using a 8x8 moving window with starting location of each 8x8 window
...@@ -273,15 +278,14 @@ double CalcFrameSsim(const uint8* src_a, int stride_a, ...@@ -273,15 +278,14 @@ double CalcFrameSsim(const uint8* src_a, int stride_a,
int width, int height) { int width, int height) {
int samples = 0; int samples = 0;
double ssim_total = 0; double ssim_total = 0;
double (*Ssim8x8)(const uint8* src_a, int stride_a, double (*Ssim8x8)(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b); const uint8* src_b, int stride_b) = Ssim8x8_C;
Ssim8x8 = Ssim8x8_C;
// sample point start with each 4x4 location // sample point start with each 4x4 location
for (int i = 0; i < height - 8; i += 4) { int i;
for (int j = 0; j < width - 8; j += 4) { for (i = 0; i < height - 8; i += 4) {
int j;
for (j = 0; j < width - 8; j += 4) {
ssim_total += Ssim8x8(src_a + j, stride_a, src_b + j, stride_b); ssim_total += Ssim8x8(src_a + j, stride_a, src_b + j, stride_b);
samples++; samples++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment