blob: b9155fdc05d705008a34da0a3e31e9b62a7c74fa [file] [log] [blame]
Geza Loreabd00502016-02-12 16:04:35 +00001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Geza Loreabd00502016-02-12 16:04:35 +00003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Geza Loreabd00502016-02-12 16:04:35 +000010 */
11
12#include <assert.h>
13
Yaowu Xuf883b422016-08-30 14:01:10 -070014#include "./aom_dsp_rtcd.h"
Geza Loreabd00502016-02-12 16:04:35 +000015
Alex Converse4c5b0202017-03-29 15:48:40 -070016uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int src_stride, int width,
17 int height) {
Geza Loreabd00502016-02-12 16:04:35 +000018 int r, c;
19 uint64_t ss = 0;
20
Alex Converse4c5b0202017-03-29 15:48:40 -070021 for (r = 0; r < height; r++) {
22 for (c = 0; c < width; c++) {
Geza Loreabd00502016-02-12 16:04:35 +000023 const int16_t v = src[c];
clang-format1214cee2016-08-08 22:59:08 -070024 ss += v * v;
Geza Loreabd00502016-02-12 16:04:35 +000025 }
clang-format1214cee2016-08-08 22:59:08 -070026 src += src_stride;
Geza Loreabd00502016-02-12 16:04:35 +000027 }
28
29 return ss;
30}
Geza Lore52141c92016-06-21 20:22:25 +010031
Yaowu Xuf883b422016-08-30 14:01:10 -070032uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t n) {
Geza Lore52141c92016-06-21 20:22:25 +010033 uint64_t ss = 0;
34 do {
35 const int16_t v = *src++;
clang-format1214cee2016-08-08 22:59:08 -070036 ss += v * v;
Geza Lore52141c92016-06-21 20:22:25 +010037 } while (--n);
38
39 return ss;
40}