blob: c72461cd18aa2ed5555de7f2128ad662fb769c2b [file] [log] [blame]
Geza Loreabd00502016-02-12 16:04:35 +00001/*
2 * Copyright (c) 2015 The WebM 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 */
10
11#include <assert.h>
12
13#include "./vpx_dsp_rtcd.h"
14
15uint64_t vpx_sum_squares_2d_i16_c(const int16_t *src, int src_stride,
James Zern5e831c52016-06-09 23:38:31 -070016 int size) {
Geza Loreabd00502016-02-12 16:04:35 +000017 int r, c;
18 uint64_t ss = 0;
19
20 for (r = 0; r < size; r++) {
21 for (c = 0; c < size; c++) {
22 const int16_t v = src[c];
23 ss += v*v;
24 }
25 src += src_stride;
26 }
27
28 return ss;
29}
Geza Lore52141c92016-06-21 20:22:25 +010030
31uint64_t vpx_sum_squares_i16_c(const int16_t *src, uint32_t n) {
32 uint64_t ss = 0;
33 do {
34 const int16_t v = *src++;
35 ss += v*v;
36 } while (--n);
37
38 return ss;
39}