Line data Source code
1 : /*
2 : * Copyright (c) 2017, 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 <stdlib.h>
13 : #include "aom_dsp_rtcd.h"
14 :
15 :
16 :
17 : // pre: predictor being evaluated
18 : // wsrc: target weighted prediction (has been *4096 to keep precision)
19 : // mask: 2d weights (scaled by 4096)
20 0 : static INLINE unsigned int obmc_sad(const uint8_t *pre, int pre_stride,
21 : const int32_t *wsrc, const int32_t *mask,
22 : int width, int height) {
23 : int y, x;
24 0 : unsigned int sad = 0;
25 :
26 0 : for (y = 0; y < height; y++) {
27 0 : for (x = 0; x < width; x++)
28 0 : sad += ROUND_POWER_OF_TWO(abs(wsrc[x] - pre[x] * mask[x]), 12);
29 :
30 0 : pre += pre_stride;
31 0 : wsrc += width;
32 0 : mask += width;
33 : }
34 :
35 0 : return sad;
36 : }
37 :
38 : #define OBMCSADMxN(m, n) \
39 : unsigned int aom_obmc_sad##m##x##n##_c(const uint8_t *ref, int ref_stride, \
40 : const int32_t *wsrc, \
41 : const int32_t *mask) { \
42 : return obmc_sad(ref, ref_stride, wsrc, mask, m, n); \
43 : }
44 :
45 : /* clang-format off */
46 0 : OBMCSADMxN(128, 128)
47 0 : OBMCSADMxN(128, 64)
48 0 : OBMCSADMxN(64, 128)
49 0 : OBMCSADMxN(64, 64)
50 0 : OBMCSADMxN(64, 32)
51 0 : OBMCSADMxN(32, 64)
52 0 : OBMCSADMxN(32, 32)
53 0 : OBMCSADMxN(32, 16)
54 0 : OBMCSADMxN(16, 32)
55 0 : OBMCSADMxN(16, 16)
56 0 : OBMCSADMxN(16, 8)
57 0 : OBMCSADMxN(8, 16)
58 0 : OBMCSADMxN(8, 8)
59 0 : OBMCSADMxN(8, 4)
60 0 : OBMCSADMxN(4, 8)
61 0 : OBMCSADMxN(4, 4)
62 0 : OBMCSADMxN(4, 16)
63 0 : OBMCSADMxN(16, 4)
64 0 : OBMCSADMxN(8, 32)
65 0 : OBMCSADMxN(32, 8)
66 0 : OBMCSADMxN(16, 64)
67 0 : OBMCSADMxN(64, 16)
68 : /* clang-format on */
69 :
|