| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "libyuv/basic_types.h" |
| 12 |
| 13 | #include "libyuv/compare_row.h" |
| 14 |
| 15 | #ifdef __cplusplus |
| 16 | namespace libyuv { |
| 17 | extern "C" { |
| 18 | #endif |
| 19 |
| 20 | uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { |
| 21 | uint32 sse = 0u; |
| 22 | int i; |
| 23 | for (i = 0; i < count; ++i) { |
| 24 | int diff = src_a[i] - src_b[i]; |
| 25 | sse += (uint32)(diff * diff); |
| 26 | } |
| 27 | return sse; |
| 28 | } |
| 29 |
| 30 | // hash seed of 5381 recommended. |
| 31 | // Internal C version of HashDjb2 with int sized count for efficiency. |
| 32 | uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { |
| 33 | uint32 hash = seed; |
| 34 | int i; |
| 35 | for (i = 0; i < count; ++i) { |
| 36 | hash += (hash << 5) + src[i]; |
| 37 | } |
| 38 | return hash; |
| 39 | } |
| 40 |
| 41 | #ifdef __cplusplus |
| 42 | } // extern "C" |
| 43 | } // namespace libyuv |
| 44 | #endif |
| 45 |