Xing Jin | fcb97b6 | 2018-08-28 17:38:36 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Alliance for Open Media. All rights reserved |
| 3 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | /* Sum the difference between every corresponding element of the buffers. */ |
| 13 | |
| 14 | #include "config/aom_config.h" |
| 15 | #include "config/aom_dsp_rtcd.h" |
| 16 | |
| 17 | #include "aom/aom_integer.h" |
| 18 | |
| 19 | int64_t aom_sse_c(const uint8_t *a, int a_stride, const uint8_t *b, |
| 20 | int b_stride, int width, int height) { |
| 21 | int y, x; |
| 22 | int64_t sse = 0; |
| 23 | |
| 24 | for (y = 0; y < height; y++) { |
| 25 | for (x = 0; x < width; x++) { |
| 26 | const int32_t diff = abs(a[x] - b[x]); |
| 27 | sse += diff * diff; |
| 28 | } |
| 29 | |
| 30 | a += a_stride; |
| 31 | b += b_stride; |
| 32 | } |
| 33 | return sse; |
| 34 | } |
| 35 | |
| 36 | int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8, |
| 37 | int b_stride, int width, int height) { |
| 38 | int y, x; |
| 39 | int64_t sse = 0; |
| 40 | uint16_t *a = CONVERT_TO_SHORTPTR(a8); |
| 41 | uint16_t *b = CONVERT_TO_SHORTPTR(b8); |
| 42 | for (y = 0; y < height; y++) { |
| 43 | for (x = 0; x < width; x++) { |
| 44 | const int32_t diff = (int32_t)(a[x]) - (int32_t)(b[x]); |
| 45 | sse += diff * diff; |
| 46 | } |
| 47 | |
| 48 | a += a_stride; |
| 49 | b += b_stride; |
| 50 | } |
| 51 | return sse; |
| 52 | } |