Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 4 | * 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 Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <assert.h> |
| 13 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | #include "./aom_dsp_rtcd.h" |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 15 | |
Alex Converse | 4c5b020 | 2017-03-29 15:48:40 -0700 | [diff] [blame] | 16 | uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int src_stride, int width, |
| 17 | int height) { |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 18 | int r, c; |
| 19 | uint64_t ss = 0; |
| 20 | |
Alex Converse | 4c5b020 | 2017-03-29 15:48:40 -0700 | [diff] [blame] | 21 | for (r = 0; r < height; r++) { |
| 22 | for (c = 0; c < width; c++) { |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 23 | const int16_t v = src[c]; |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 24 | ss += v * v; |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 25 | } |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 26 | src += src_stride; |
Geza Lore | abd0050 | 2016-02-12 16:04:35 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | return ss; |
| 30 | } |
Geza Lore | 52141c9 | 2016-06-21 20:22:25 +0100 | [diff] [blame] | 31 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 32 | uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t n) { |
Geza Lore | 52141c9 | 2016-06-21 20:22:25 +0100 | [diff] [blame] | 33 | uint64_t ss = 0; |
| 34 | do { |
| 35 | const int16_t v = *src++; |
clang-format | 1214cee | 2016-08-08 22:59:08 -0700 | [diff] [blame] | 36 | ss += v * v; |
Geza Lore | 52141c9 | 2016-06-21 20:22:25 +0100 | [diff] [blame] | 37 | } while (--n); |
| 38 | |
| 39 | return ss; |
| 40 | } |