1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libyuv/source/compare_common.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +/* 1.5 + * Copyright 2012 The LibYuv Project Authors. All rights reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#include "libyuv/basic_types.h" 1.15 + 1.16 +#ifdef __cplusplus 1.17 +namespace libyuv { 1.18 +extern "C" { 1.19 +#endif 1.20 + 1.21 +uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { 1.22 + uint32 sse = 0u; 1.23 + int i; 1.24 + for (i = 0; i < count; ++i) { 1.25 + int diff = src_a[i] - src_b[i]; 1.26 + sse += (uint32)(diff * diff); 1.27 + } 1.28 + return sse; 1.29 +} 1.30 + 1.31 +// hash seed of 5381 recommended. 1.32 +// Internal C version of HashDjb2 with int sized count for efficiency. 1.33 +uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { 1.34 + uint32 hash = seed; 1.35 + int i; 1.36 + for (i = 0; i < count; ++i) { 1.37 + hash += (hash << 5) + src[i]; 1.38 + } 1.39 + return hash; 1.40 +} 1.41 + 1.42 +#ifdef __cplusplus 1.43 +} // extern "C" 1.44 +} // namespace libyuv 1.45 +#endif