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