Coverage Report

Created: 2026-01-18 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavif/ext/aom/aom_dsp/sum_squares.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2016, 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
#include <assert.h>
13
14
#include "config/aom_config.h"
15
#include "config/aom_dsp_rtcd.h"
16
17
uint64_t aom_sum_squares_2d_i16_c(const int16_t *src, int src_stride, int width,
18
55.7k
                                  int height) {
19
55.7k
  int r, c;
20
55.7k
  uint64_t ss = 0;
21
22
2.46M
  for (r = 0; r < height; r++) {
23
91.1M
    for (c = 0; c < width; c++) {
24
88.7M
      const int16_t v = src[c];
25
88.7M
      ss += v * v;
26
88.7M
    }
27
2.40M
    src += src_stride;
28
2.40M
  }
29
30
55.7k
  return ss;
31
55.7k
}
32
33
0
uint64_t aom_sum_squares_i16_c(const int16_t *src, uint32_t n) {
34
0
  uint64_t ss = 0;
35
0
  do {
36
0
    const int16_t v = *src++;
37
0
    ss += v * v;
38
0
  } while (--n);
39
40
0
  return ss;
41
0
}
42
43
0
uint64_t aom_var_2d_u8_c(uint8_t *src, int src_stride, int width, int height) {
44
0
  int r, c;
45
0
  uint64_t ss = 0, s = 0;
46
47
0
  for (r = 0; r < height; r++) {
48
0
    for (c = 0; c < width; c++) {
49
0
      const uint8_t v = src[c];
50
0
      ss += v * v;
51
0
      s += v;
52
0
    }
53
0
    src += src_stride;
54
0
  }
55
56
0
  return (ss - s * s / (width * height));
57
0
}
58
59
#if CONFIG_AV1_HIGHBITDEPTH
60
0
uint64_t aom_var_2d_u16_c(uint8_t *src, int src_stride, int width, int height) {
61
0
  uint16_t *srcp = CONVERT_TO_SHORTPTR(src);
62
0
  int r, c;
63
0
  uint64_t ss = 0, s = 0;
64
65
0
  for (r = 0; r < height; r++) {
66
0
    for (c = 0; c < width; c++) {
67
0
      const uint16_t v = srcp[c];
68
0
      ss += v * v;
69
0
      s += v;
70
0
    }
71
0
    srcp += src_stride;
72
0
  }
73
74
0
  return (ss - s * s / (width * height));
75
0
}
76
#endif  // CONFIG_AV1_HIGHBITDEPTH
77
78
uint64_t aom_sum_sse_2d_i16_c(const int16_t *src, int src_stride, int width,
79
225k
                              int height, int *sum) {
80
225k
  int r, c;
81
225k
  int16_t *srcp = (int16_t *)src;
82
225k
  int64_t ss = 0;
83
84
5.70M
  for (r = 0; r < height; r++) {
85
124M
    for (c = 0; c < width; c++) {
86
118M
      const int16_t v = srcp[c];
87
118M
      ss += v * v;
88
118M
      *sum += v;
89
118M
    }
90
5.48M
    srcp += src_stride;
91
5.48M
  }
92
225k
  return ss;
93
225k
}