mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 17:26:49 +08:00
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
This commit is contained in:
parent
8ae294e440
commit
3e34b8e89d
@ -18,39 +18,43 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Compute a hash for specified memory. Seed of 5381 recommended.
|
||||
uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed);
|
||||
|
||||
// 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,
|
||||
int width, int height);
|
||||
|
||||
static const int kMaxPsnr = 128;
|
||||
|
||||
double SumSquareErrorToPsnr(uint64 sse, uint64 count);
|
||||
|
||||
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,
|
||||
int width, int height);
|
||||
|
||||
double CalcFramePsnr(const uint8 *src_a, int stride_a,
|
||||
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);
|
||||
|
||||
double CalcFrameSsim(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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user