/src/libvpx/vpx_dsp/sse.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023 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 | | /* |
12 | | * Sum the square of the difference between every corresponding element of the |
13 | | * buffers. |
14 | | */ |
15 | | |
16 | | #include <stdlib.h> |
17 | | |
18 | | #include "./vpx_config.h" |
19 | | #include "./vpx_dsp_rtcd.h" |
20 | | |
21 | | #include "vpx/vpx_integer.h" |
22 | | #include "vpx_ports/mem.h" |
23 | | |
24 | | int64_t vpx_sse_c(const uint8_t *a, int a_stride, const uint8_t *b, |
25 | 0 | int b_stride, int width, int height) { |
26 | 0 | int y, x; |
27 | 0 | int64_t sse = 0; |
28 | |
|
29 | 0 | for (y = 0; y < height; y++) { |
30 | 0 | for (x = 0; x < width; x++) { |
31 | 0 | const int32_t diff = abs(a[x] - b[x]); |
32 | 0 | sse += diff * diff; |
33 | 0 | } |
34 | |
|
35 | 0 | a += a_stride; |
36 | 0 | b += b_stride; |
37 | 0 | } |
38 | 0 | return sse; |
39 | 0 | } |
40 | | |
41 | | #if CONFIG_VP9_HIGHBITDEPTH |
42 | | int64_t vpx_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8, |
43 | 0 | int b_stride, int width, int height) { |
44 | 0 | int y, x; |
45 | 0 | int64_t sse = 0; |
46 | 0 | uint16_t *a = CONVERT_TO_SHORTPTR(a8); |
47 | 0 | uint16_t *b = CONVERT_TO_SHORTPTR(b8); |
48 | 0 | for (y = 0; y < height; y++) { |
49 | 0 | for (x = 0; x < width; x++) { |
50 | 0 | const int32_t diff = (int32_t)(a[x]) - (int32_t)(b[x]); |
51 | 0 | sse += diff * diff; |
52 | 0 | } |
53 | |
|
54 | 0 | a += a_stride; |
55 | 0 | b += b_stride; |
56 | 0 | } |
57 | 0 | return sse; |
58 | 0 | } |
59 | | #endif |