media/libyuv/source/compare_common.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     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
     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  */
    11 #include "libyuv/basic_types.h"
    13 #ifdef __cplusplus
    14 namespace libyuv {
    15 extern "C" {
    16 #endif
    18 uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) {
    19   uint32 sse = 0u;
    20   int i;
    21   for (i = 0; i < count; ++i) {
    22     int diff = src_a[i] - src_b[i];
    23     sse += (uint32)(diff * diff);
    24   }
    25   return sse;
    26 }
    28 // hash seed of 5381 recommended.
    29 // Internal C version of HashDjb2 with int sized count for efficiency.
    30 uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) {
    31   uint32 hash = seed;
    32   int i;
    33   for (i = 0; i < count; ++i) {
    34     hash += (hash << 5) + src[i];
    35   }
    36   return hash;
    37 }
    39 #ifdef __cplusplus
    40 }  // extern "C"
    41 }  // namespace libyuv
    42 #endif

mercurial