Commit 3e34b8e8 authored by fbarchard@google.com's avatar fbarchard@google.com

hash funtion for comparing images

BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/380006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@166 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 8ae294e4
......@@ -18,39 +18,43 @@ namespace libyuv {
extern "C" {
#endif
static const int kMaxPsnr = 128;
double SumSquareErrorToPsnr(uint64 sse, uint64 count);
// Compute a hash for specified memory. Seed of 5381 recommended.
uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed);
uint64 ComputeSumSquareError(const uint8 *src_a,
const uint8 *src_b, int count);
// Sum Square Error - used to compute Mean Square Error or PSNR
uint64 ComputeSumSquareError(const uint8* src_a,
const uint8* src_b, int count);
uint64 ComputeSumSquareErrorPlane(const uint8 *src_a, int stride_a,
const uint8 *src_b, int stride_b,
uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
double CalcFramePsnr(const uint8 *src_a, int stride_a,
const uint8 *src_b, int stride_b,
int width, int height);
static const int kMaxPsnr = 128;
double CalcFrameSsim(const uint8 *src_a, int stride_a,
const uint8 *src_b, int stride_b,
double SumSquareErrorToPsnr(uint64 sse, uint64 count);
double CalcFramePsnr(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
double I420Psnr(const uint8 *src_y_a, int stride_y_a,
const uint8 *src_u_a, int stride_u_a,
const uint8 *src_v_a, int stride_v_a,
const uint8 *src_y_b, int stride_y_b,
const uint8 *src_u_b, int stride_u_b,
const uint8 *src_v_b, int stride_v_b,
double I420Psnr(const uint8* src_y_a, int stride_y_a,
const uint8* src_u_a, int stride_u_a,
const uint8* src_v_a, int stride_v_a,
const uint8* src_y_b, int stride_y_b,
const uint8* src_u_b, int stride_u_b,
const uint8* src_v_b, int stride_v_b,
int width, int height);
double I420Ssim(const uint8 *src_y_a, int stride_y_a,
const uint8 *src_u_a, int stride_u_a,
const uint8 *src_v_a, int stride_v_a,
const uint8 *src_y_b, int stride_y_b,
const uint8 *src_u_b, int stride_u_b,
const uint8 *src_v_b, int stride_v_b,
double CalcFrameSsim(const uint8* src_a, int stride_a,
const uint8* src_b, int stride_b,
int width, int height);
double I420Ssim(const uint8* src_y_a, int stride_y_a,
const uint8* src_u_a, int stride_u_a,
const uint8* src_v_a, int stride_v_a,
const uint8* src_y_b, int stride_y_b,
const uint8* src_u_b, int stride_u_b,
const uint8* src_v_b, int stride_v_b,
int width, int height);
#ifdef __cplusplus
......
......@@ -22,6 +22,17 @@ namespace libyuv {
extern "C" {
#endif
// hash seed of 5381 recommended.
uint32 HashDjb2(const uint8* src, size_t len, uint32 seed) {
uint32 hash = seed;
if (len > 0) {
do {
hash = hash * 33 + *src++;
} while (--len);
}
return hash;
}
#if defined(__ARM_NEON__) && !defined(YUV_DISABLE_ASM)
#define HAS_SUMSQUAREERROR_NEON
......@@ -181,21 +192,23 @@ uint64 ComputeSumSquareError(const uint8* src_a,
}
const int kBlockSize = 32768;
uint64 sse = 0;
while (count >= kBlockSize) {
sse += SumSquareError(src_a, src_b, kBlockSize);
src_a += kBlockSize;
src_b += kBlockSize;
count -= kBlockSize;
#ifdef _OPENMP
#pragma omp parallel for reduction(+: sse)
#endif
for (int i = 0; i < (count - (kBlockSize - 1)); i += kBlockSize) {
sse += SumSquareError(src_a + i, src_b + i, kBlockSize);
}
int remainder = count & ~15;
src_a += count & ~(kBlockSize - 1);
src_b += count & ~(kBlockSize - 1);
int remainder = count & (kBlockSize - 1) & ~15;
if (remainder) {
sse += SumSquareError(src_a, src_b, remainder);
src_a += remainder;
src_b += remainder;
count -= remainder;
}
if (count) {
sse += SumSquareError_C(src_a, src_b, count);
remainder = count & 15;
if (remainder) {
sse += SumSquareError_C(src_a, src_b, remainder);
}
return sse;
}
......
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