sse.c (1616B)
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 /* 13 * Sum the square of the difference between every corresponding element of the 14 * buffers. 15 */ 16 17 #include <stdlib.h> 18 19 #include "config/aom_config.h" 20 #include "config/aom_dsp_rtcd.h" 21 22 #include "aom/aom_integer.h" 23 24 int64_t aom_sse_c(const uint8_t *a, int a_stride, const uint8_t *b, 25 int b_stride, int width, int height) { 26 int y, x; 27 int64_t sse = 0; 28 29 for (y = 0; y < height; y++) { 30 for (x = 0; x < width; x++) { 31 const int32_t diff = abs(a[x] - b[x]); 32 sse += diff * diff; 33 } 34 35 a += a_stride; 36 b += b_stride; 37 } 38 return sse; 39 } 40 41 #if CONFIG_AV1_HIGHBITDEPTH 42 int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8, 43 int b_stride, int width, int height) { 44 int y, x; 45 int64_t sse = 0; 46 uint16_t *a = CONVERT_TO_SHORTPTR(a8); 47 uint16_t *b = CONVERT_TO_SHORTPTR(b8); 48 for (y = 0; y < height; y++) { 49 for (x = 0; x < width; x++) { 50 const int32_t diff = (int32_t)(a[x]) - (int32_t)(b[x]); 51 sse += diff * diff; 52 } 53 54 a += a_stride; 55 b += b_stride; 56 } 57 return sse; 58 } 59 #endif