michael@0: /* michael@0: * Copyright 2012 The LibYuv Project Authors. All rights reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #include "libyuv/basic_types.h" michael@0: michael@0: #ifdef __cplusplus michael@0: namespace libyuv { michael@0: extern "C" { michael@0: #endif michael@0: michael@0: uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { michael@0: uint32 sse = 0u; michael@0: int i; michael@0: for (i = 0; i < count; ++i) { michael@0: int diff = src_a[i] - src_b[i]; michael@0: sse += (uint32)(diff * diff); michael@0: } michael@0: return sse; michael@0: } michael@0: michael@0: // hash seed of 5381 recommended. michael@0: // Internal C version of HashDjb2 with int sized count for efficiency. michael@0: uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { michael@0: uint32 hash = seed; michael@0: int i; michael@0: for (i = 0; i < count; ++i) { michael@0: hash += (hash << 5) + src[i]; michael@0: } michael@0: return hash; michael@0: } michael@0: michael@0: #ifdef __cplusplus michael@0: } // extern "C" michael@0: } // namespace libyuv michael@0: #endif