Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #include "libyuv/basic_types.h" |
michael@0 | 12 | |
michael@0 | 13 | #ifdef __cplusplus |
michael@0 | 14 | namespace libyuv { |
michael@0 | 15 | extern "C" { |
michael@0 | 16 | #endif |
michael@0 | 17 | |
michael@0 | 18 | uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { |
michael@0 | 19 | uint32 sse = 0u; |
michael@0 | 20 | int i; |
michael@0 | 21 | for (i = 0; i < count; ++i) { |
michael@0 | 22 | int diff = src_a[i] - src_b[i]; |
michael@0 | 23 | sse += (uint32)(diff * diff); |
michael@0 | 24 | } |
michael@0 | 25 | return sse; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // hash seed of 5381 recommended. |
michael@0 | 29 | // Internal C version of HashDjb2 with int sized count for efficiency. |
michael@0 | 30 | uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { |
michael@0 | 31 | uint32 hash = seed; |
michael@0 | 32 | int i; |
michael@0 | 33 | for (i = 0; i < count; ++i) { |
michael@0 | 34 | hash += (hash << 5) + src[i]; |
michael@0 | 35 | } |
michael@0 | 36 | return hash; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | #ifdef __cplusplus |
michael@0 | 40 | } // extern "C" |
michael@0 | 41 | } // namespace libyuv |
michael@0 | 42 | #endif |