2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
13 #include "./vp9_rtcd.h"
14 #include "./vpx_config.h"
16 #include "vpx/vpx_integer.h"
17 #include "vp9/encoder/vp9_variance.h"
19 static INLINE unsigned int sad(const uint8_t *a, int a_stride,
20 const uint8_t *b, int b_stride,
21 int width, int height) {
25 for (y = 0; y < height; y++) {
26 for (x = 0; x < width; x++)
27 sad += abs(a[x] - b[x]);
36 #define sadMxN(m, n) \
37 unsigned int vp9_sad##m##x##n##_c(const uint8_t *src, int src_stride, \
38 const uint8_t *ref, int ref_stride, \
39 unsigned int max_sad) { \
40 return sad(src, src_stride, ref, ref_stride, m, n); \
42 unsigned int vp9_sad##m##x##n##_avg_c(const uint8_t *src, int src_stride, \
43 const uint8_t *ref, int ref_stride, \
44 const uint8_t *second_pred, \
45 unsigned int max_sad) { \
46 uint8_t comp_pred[m * n]; \
47 vp9_comp_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \
48 return sad(src, src_stride, comp_pred, m, m, n); \
51 #define sadMxNxK(m, n, k) \
52 void vp9_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \
53 const uint8_t *ref, int ref_stride, \
54 unsigned int *sads) { \
56 for (i = 0; i < k; ++i) \
57 sads[i] = vp9_sad##m##x##n##_c(src, src_stride, &ref[i], ref_stride, \
61 #define sadMxNx4D(m, n) \
62 void vp9_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
63 const uint8_t *const refs[], int ref_stride, \
64 unsigned int *sads) { \
66 for (i = 0; i < 4; ++i) \
67 sads[i] = vp9_sad##m##x##n##_c(src, src_stride, refs[i], ref_stride, \