blob: ab587d08171b9681d068e6982dfbf6dae60ead1d [file] [log] [blame]
fbarchard@google.com3f467452012-10-20 01:23:27 +00001/*
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
fbarchard@google.comcde58702013-01-28 00:02:35 +00007 * in the file PATENTS. All contributing project authors may
fbarchard@google.com3f467452012-10-20 01:23:27 +00008 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "libyuv/basic_types.h"
12
13#ifdef __cplusplus
14namespace libyuv {
15extern "C" {
16#endif
17
18uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) {
19 uint32 sse = 0u;
20 for (int i = 0; i < count; ++i) {
21 int diff = src_a[i] - src_b[i];
22 sse += static_cast<uint32>(diff * diff);
23 }
24 return sse;
25}
26
fbarchard@google.com66fe0972012-10-22 16:18:53 +000027// hash seed of 5381 recommended.
28// Internal C version of HashDjb2 with int sized count for efficiency.
29uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) {
30 uint32 hash = seed;
31 for (int i = 0; i < count; ++i) {
32 hash += (hash << 5) + src[i];
33 }
34 return hash;
35}
36
fbarchard@google.com3f467452012-10-20 01:23:27 +000037#ifdef __cplusplus
38} // extern "C"
39} // namespace libyuv
40#endif