Coverage Report

Created: 2026-05-16 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aom/av1/common/cdef_block_simd.h
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
#ifndef AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
13
#define AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
14
15
#include "config/aom_config.h"
16
#include "config/av1_rtcd.h"
17
18
#include "av1/common/cdef_block.h"
19
20
/* partial A is a 16-bit vector of the form:
21
   [x8 x7 x6 x5 x4 x3 x2 x1] and partial B has the form:
22
   [0  y1 y2 y3 y4 y5 y6 y7].
23
   This function computes (x1^2+y1^2)*C1 + (x2^2+y2^2)*C2 + ...
24
   (x7^2+y2^7)*C7 + (x8^2+0^2)*C8 where the C1..C8 constants are in const1
25
   and const2. */
26
static inline v128 fold_mul_and_sum(v128 partiala, v128 partialb, v128 const1,
27
33.3k
                                    v128 const2) {
28
33.3k
  v128 tmp;
29
  /* Reverse partial B. */
30
33.3k
  partialb = v128_shuffle_8(
31
33.3k
      partialb, v128_from_32(0x0f0e0100, 0x03020504, 0x07060908, 0x0b0a0d0c));
32
  /* Interleave the x and y values of identical indices and pair x8 with 0. */
33
33.3k
  tmp = partiala;
34
33.3k
  partiala = v128_ziplo_16(partialb, partiala);
35
33.3k
  partialb = v128_ziphi_16(partialb, tmp);
36
  /* Square and add the corresponding x and y values. */
37
33.3k
  partiala = v128_madd_s16(partiala, partiala);
38
33.3k
  partialb = v128_madd_s16(partialb, partialb);
39
  /* Multiply by constant. */
40
33.3k
  partiala = v128_mullo_s32(partiala, const1);
41
33.3k
  partialb = v128_mullo_s32(partialb, const2);
42
  /* Sum all results. */
43
33.3k
  partiala = v128_add_32(partiala, partialb);
44
33.3k
  return partiala;
45
33.3k
}
Unexecuted instantiation: cdef_block_sse4.c:fold_mul_and_sum
cdef_block_avx2.c:fold_mul_and_sum
Line
Count
Source
27
33.3k
                                    v128 const2) {
28
33.3k
  v128 tmp;
29
  /* Reverse partial B. */
30
33.3k
  partialb = v128_shuffle_8(
31
33.3k
      partialb, v128_from_32(0x0f0e0100, 0x03020504, 0x07060908, 0x0b0a0d0c));
32
  /* Interleave the x and y values of identical indices and pair x8 with 0. */
33
33.3k
  tmp = partiala;
34
33.3k
  partiala = v128_ziplo_16(partialb, partiala);
35
33.3k
  partialb = v128_ziphi_16(partialb, tmp);
36
  /* Square and add the corresponding x and y values. */
37
33.3k
  partiala = v128_madd_s16(partiala, partiala);
38
33.3k
  partialb = v128_madd_s16(partialb, partialb);
39
  /* Multiply by constant. */
40
33.3k
  partiala = v128_mullo_s32(partiala, const1);
41
33.3k
  partialb = v128_mullo_s32(partialb, const2);
42
  /* Sum all results. */
43
33.3k
  partiala = v128_add_32(partiala, partialb);
44
33.3k
  return partiala;
45
33.3k
}
46
47
11.1k
static inline v128 hsum4(v128 x0, v128 x1, v128 x2, v128 x3) {
48
11.1k
  v128 t0, t1, t2, t3;
49
11.1k
  t0 = v128_ziplo_32(x1, x0);
50
11.1k
  t1 = v128_ziplo_32(x3, x2);
51
11.1k
  t2 = v128_ziphi_32(x1, x0);
52
11.1k
  t3 = v128_ziphi_32(x3, x2);
53
11.1k
  x0 = v128_ziplo_64(t1, t0);
54
11.1k
  x1 = v128_ziphi_64(t1, t0);
55
11.1k
  x2 = v128_ziplo_64(t3, t2);
56
11.1k
  x3 = v128_ziphi_64(t3, t2);
57
11.1k
  return v128_add_32(v128_add_32(x0, x1), v128_add_32(x2, x3));
58
11.1k
}
Unexecuted instantiation: cdef_block_sse4.c:hsum4
cdef_block_avx2.c:hsum4
Line
Count
Source
47
11.1k
static inline v128 hsum4(v128 x0, v128 x1, v128 x2, v128 x3) {
48
11.1k
  v128 t0, t1, t2, t3;
49
11.1k
  t0 = v128_ziplo_32(x1, x0);
50
11.1k
  t1 = v128_ziplo_32(x3, x2);
51
11.1k
  t2 = v128_ziphi_32(x1, x0);
52
11.1k
  t3 = v128_ziphi_32(x3, x2);
53
11.1k
  x0 = v128_ziplo_64(t1, t0);
54
11.1k
  x1 = v128_ziphi_64(t1, t0);
55
11.1k
  x2 = v128_ziplo_64(t3, t2);
56
11.1k
  x3 = v128_ziphi_64(t3, t2);
57
11.1k
  return v128_add_32(v128_add_32(x0, x1), v128_add_32(x2, x3));
58
11.1k
}
59
60
/* Computes cost for directions 0, 5, 6 and 7. We can call this function again
61
   to compute the remaining directions. */
62
11.1k
static inline v128 compute_directions(v128 lines[8], int32_t tmp_cost1[4]) {
63
11.1k
  v128 partial4a, partial4b, partial5a, partial5b, partial7a, partial7b;
64
11.1k
  v128 partial6;
65
11.1k
  v128 tmp;
66
  /* Partial sums for lines 0 and 1. */
67
11.1k
  partial4a = v128_shl_n_byte(lines[0], 14);
68
11.1k
  partial4b = v128_shr_n_byte(lines[0], 2);
69
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[1], 12));
70
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[1], 4));
71
11.1k
  tmp = v128_add_16(lines[0], lines[1]);
72
11.1k
  partial5a = v128_shl_n_byte(tmp, 10);
73
11.1k
  partial5b = v128_shr_n_byte(tmp, 6);
74
11.1k
  partial7a = v128_shl_n_byte(tmp, 4);
75
11.1k
  partial7b = v128_shr_n_byte(tmp, 12);
76
11.1k
  partial6 = tmp;
77
78
  /* Partial sums for lines 2 and 3. */
79
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[2], 10));
80
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[2], 6));
81
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[3], 8));
82
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[3], 8));
83
11.1k
  tmp = v128_add_16(lines[2], lines[3]);
84
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 8));
85
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 8));
86
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 6));
87
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 10));
88
11.1k
  partial6 = v128_add_16(partial6, tmp);
89
90
  /* Partial sums for lines 4 and 5. */
91
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[4], 6));
92
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[4], 10));
93
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[5], 4));
94
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[5], 12));
95
11.1k
  tmp = v128_add_16(lines[4], lines[5]);
96
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 6));
97
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 10));
98
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 8));
99
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 8));
100
11.1k
  partial6 = v128_add_16(partial6, tmp);
101
102
  /* Partial sums for lines 6 and 7. */
103
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[6], 2));
104
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[6], 14));
105
11.1k
  partial4a = v128_add_16(partial4a, lines[7]);
106
11.1k
  tmp = v128_add_16(lines[6], lines[7]);
107
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 4));
108
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 12));
109
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 10));
110
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 6));
111
11.1k
  partial6 = v128_add_16(partial6, tmp);
112
113
  /* Compute costs in terms of partial sums. */
114
11.1k
  partial4a =
115
11.1k
      fold_mul_and_sum(partial4a, partial4b, v128_from_32(210, 280, 420, 840),
116
11.1k
                       v128_from_32(105, 120, 140, 168));
117
11.1k
  partial7a =
118
11.1k
      fold_mul_and_sum(partial7a, partial7b, v128_from_32(210, 420, 0, 0),
119
11.1k
                       v128_from_32(105, 105, 105, 140));
120
11.1k
  partial5a =
121
11.1k
      fold_mul_and_sum(partial5a, partial5b, v128_from_32(210, 420, 0, 0),
122
11.1k
                       v128_from_32(105, 105, 105, 140));
123
11.1k
  partial6 = v128_madd_s16(partial6, partial6);
124
11.1k
  partial6 = v128_mullo_s32(partial6, v128_dup_32(105));
125
126
11.1k
  partial4a = hsum4(partial4a, partial5a, partial6, partial7a);
127
11.1k
  v128_store_unaligned(tmp_cost1, partial4a);
128
11.1k
  return partial4a;
129
11.1k
}
Unexecuted instantiation: cdef_block_sse4.c:compute_directions
cdef_block_avx2.c:compute_directions
Line
Count
Source
62
11.1k
static inline v128 compute_directions(v128 lines[8], int32_t tmp_cost1[4]) {
63
11.1k
  v128 partial4a, partial4b, partial5a, partial5b, partial7a, partial7b;
64
11.1k
  v128 partial6;
65
11.1k
  v128 tmp;
66
  /* Partial sums for lines 0 and 1. */
67
11.1k
  partial4a = v128_shl_n_byte(lines[0], 14);
68
11.1k
  partial4b = v128_shr_n_byte(lines[0], 2);
69
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[1], 12));
70
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[1], 4));
71
11.1k
  tmp = v128_add_16(lines[0], lines[1]);
72
11.1k
  partial5a = v128_shl_n_byte(tmp, 10);
73
11.1k
  partial5b = v128_shr_n_byte(tmp, 6);
74
11.1k
  partial7a = v128_shl_n_byte(tmp, 4);
75
11.1k
  partial7b = v128_shr_n_byte(tmp, 12);
76
11.1k
  partial6 = tmp;
77
78
  /* Partial sums for lines 2 and 3. */
79
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[2], 10));
80
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[2], 6));
81
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[3], 8));
82
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[3], 8));
83
11.1k
  tmp = v128_add_16(lines[2], lines[3]);
84
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 8));
85
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 8));
86
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 6));
87
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 10));
88
11.1k
  partial6 = v128_add_16(partial6, tmp);
89
90
  /* Partial sums for lines 4 and 5. */
91
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[4], 6));
92
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[4], 10));
93
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[5], 4));
94
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[5], 12));
95
11.1k
  tmp = v128_add_16(lines[4], lines[5]);
96
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 6));
97
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 10));
98
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 8));
99
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 8));
100
11.1k
  partial6 = v128_add_16(partial6, tmp);
101
102
  /* Partial sums for lines 6 and 7. */
103
11.1k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[6], 2));
104
11.1k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[6], 14));
105
11.1k
  partial4a = v128_add_16(partial4a, lines[7]);
106
11.1k
  tmp = v128_add_16(lines[6], lines[7]);
107
11.1k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 4));
108
11.1k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 12));
109
11.1k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 10));
110
11.1k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 6));
111
11.1k
  partial6 = v128_add_16(partial6, tmp);
112
113
  /* Compute costs in terms of partial sums. */
114
11.1k
  partial4a =
115
11.1k
      fold_mul_and_sum(partial4a, partial4b, v128_from_32(210, 280, 420, 840),
116
11.1k
                       v128_from_32(105, 120, 140, 168));
117
11.1k
  partial7a =
118
11.1k
      fold_mul_and_sum(partial7a, partial7b, v128_from_32(210, 420, 0, 0),
119
11.1k
                       v128_from_32(105, 105, 105, 140));
120
11.1k
  partial5a =
121
11.1k
      fold_mul_and_sum(partial5a, partial5b, v128_from_32(210, 420, 0, 0),
122
11.1k
                       v128_from_32(105, 105, 105, 140));
123
11.1k
  partial6 = v128_madd_s16(partial6, partial6);
124
11.1k
  partial6 = v128_mullo_s32(partial6, v128_dup_32(105));
125
126
11.1k
  partial4a = hsum4(partial4a, partial5a, partial6, partial7a);
127
11.1k
  v128_store_unaligned(tmp_cost1, partial4a);
128
11.1k
  return partial4a;
129
11.1k
}
130
131
/* transpose and reverse the order of the lines -- equivalent to a 90-degree
132
   counter-clockwise rotation of the pixels. */
133
5.56k
static inline void array_reverse_transpose_8x8(v128 *in, v128 *res) {
134
5.56k
  const v128 tr0_0 = v128_ziplo_16(in[1], in[0]);
135
5.56k
  const v128 tr0_1 = v128_ziplo_16(in[3], in[2]);
136
5.56k
  const v128 tr0_2 = v128_ziphi_16(in[1], in[0]);
137
5.56k
  const v128 tr0_3 = v128_ziphi_16(in[3], in[2]);
138
5.56k
  const v128 tr0_4 = v128_ziplo_16(in[5], in[4]);
139
5.56k
  const v128 tr0_5 = v128_ziplo_16(in[7], in[6]);
140
5.56k
  const v128 tr0_6 = v128_ziphi_16(in[5], in[4]);
141
5.56k
  const v128 tr0_7 = v128_ziphi_16(in[7], in[6]);
142
143
5.56k
  const v128 tr1_0 = v128_ziplo_32(tr0_1, tr0_0);
144
5.56k
  const v128 tr1_1 = v128_ziplo_32(tr0_5, tr0_4);
145
5.56k
  const v128 tr1_2 = v128_ziphi_32(tr0_1, tr0_0);
146
5.56k
  const v128 tr1_3 = v128_ziphi_32(tr0_5, tr0_4);
147
5.56k
  const v128 tr1_4 = v128_ziplo_32(tr0_3, tr0_2);
148
5.56k
  const v128 tr1_5 = v128_ziplo_32(tr0_7, tr0_6);
149
5.56k
  const v128 tr1_6 = v128_ziphi_32(tr0_3, tr0_2);
150
5.56k
  const v128 tr1_7 = v128_ziphi_32(tr0_7, tr0_6);
151
152
5.56k
  res[7] = v128_ziplo_64(tr1_1, tr1_0);
153
5.56k
  res[6] = v128_ziphi_64(tr1_1, tr1_0);
154
5.56k
  res[5] = v128_ziplo_64(tr1_3, tr1_2);
155
5.56k
  res[4] = v128_ziphi_64(tr1_3, tr1_2);
156
5.56k
  res[3] = v128_ziplo_64(tr1_5, tr1_4);
157
5.56k
  res[2] = v128_ziphi_64(tr1_5, tr1_4);
158
5.56k
  res[1] = v128_ziplo_64(tr1_7, tr1_6);
159
5.56k
  res[0] = v128_ziphi_64(tr1_7, tr1_6);
160
5.56k
}
Unexecuted instantiation: cdef_block_sse4.c:array_reverse_transpose_8x8
cdef_block_avx2.c:array_reverse_transpose_8x8
Line
Count
Source
133
5.56k
static inline void array_reverse_transpose_8x8(v128 *in, v128 *res) {
134
5.56k
  const v128 tr0_0 = v128_ziplo_16(in[1], in[0]);
135
5.56k
  const v128 tr0_1 = v128_ziplo_16(in[3], in[2]);
136
5.56k
  const v128 tr0_2 = v128_ziphi_16(in[1], in[0]);
137
5.56k
  const v128 tr0_3 = v128_ziphi_16(in[3], in[2]);
138
5.56k
  const v128 tr0_4 = v128_ziplo_16(in[5], in[4]);
139
5.56k
  const v128 tr0_5 = v128_ziplo_16(in[7], in[6]);
140
5.56k
  const v128 tr0_6 = v128_ziphi_16(in[5], in[4]);
141
5.56k
  const v128 tr0_7 = v128_ziphi_16(in[7], in[6]);
142
143
5.56k
  const v128 tr1_0 = v128_ziplo_32(tr0_1, tr0_0);
144
5.56k
  const v128 tr1_1 = v128_ziplo_32(tr0_5, tr0_4);
145
5.56k
  const v128 tr1_2 = v128_ziphi_32(tr0_1, tr0_0);
146
5.56k
  const v128 tr1_3 = v128_ziphi_32(tr0_5, tr0_4);
147
5.56k
  const v128 tr1_4 = v128_ziplo_32(tr0_3, tr0_2);
148
5.56k
  const v128 tr1_5 = v128_ziplo_32(tr0_7, tr0_6);
149
5.56k
  const v128 tr1_6 = v128_ziphi_32(tr0_3, tr0_2);
150
5.56k
  const v128 tr1_7 = v128_ziphi_32(tr0_7, tr0_6);
151
152
5.56k
  res[7] = v128_ziplo_64(tr1_1, tr1_0);
153
5.56k
  res[6] = v128_ziphi_64(tr1_1, tr1_0);
154
5.56k
  res[5] = v128_ziplo_64(tr1_3, tr1_2);
155
5.56k
  res[4] = v128_ziphi_64(tr1_3, tr1_2);
156
5.56k
  res[3] = v128_ziplo_64(tr1_5, tr1_4);
157
5.56k
  res[2] = v128_ziphi_64(tr1_5, tr1_4);
158
5.56k
  res[1] = v128_ziplo_64(tr1_7, tr1_6);
159
5.56k
  res[0] = v128_ziphi_64(tr1_7, tr1_6);
160
5.56k
}
161
162
int SIMD_FUNC(cdef_find_dir)(const uint16_t *img, int stride, int32_t *var,
163
5.56k
                             int coeff_shift) {
164
5.56k
  int i;
165
5.56k
  int32_t cost[8];
166
5.56k
  int32_t best_cost = 0;
167
5.56k
  int best_dir = 0;
168
5.56k
  v128 lines[8];
169
50.0k
  for (i = 0; i < 8; i++) {
170
44.5k
    lines[i] = v128_load_unaligned(&img[i * stride]);
171
44.5k
    lines[i] =
172
44.5k
        v128_sub_16(v128_shr_s16(lines[i], coeff_shift), v128_dup_16(128));
173
44.5k
  }
174
175
  /* Compute "mostly vertical" directions. */
176
5.56k
  v128 dir47 = compute_directions(lines, cost + 4);
177
178
5.56k
  array_reverse_transpose_8x8(lines, lines);
179
180
  /* Compute "mostly horizontal" directions. */
181
5.56k
  v128 dir03 = compute_directions(lines, cost);
182
183
5.56k
  v128 max = v128_max_s32(dir03, dir47);
184
5.56k
  max = v128_max_s32(max, v128_align(max, max, 8));
185
5.56k
  max = v128_max_s32(max, v128_align(max, max, 4));
186
5.56k
  best_cost = v128_low_u32(max);
187
5.56k
  v128 t =
188
5.56k
      v128_pack_s32_s16(v128_cmpeq_32(max, dir47), v128_cmpeq_32(max, dir03));
189
5.56k
  best_dir = v128_movemask_8(v128_pack_s16_s8(t, t));
190
5.56k
  best_dir = get_msb(best_dir ^ (best_dir - 1));  // Count trailing zeros
191
192
  /* Difference between the optimal variance and the variance along the
193
     orthogonal direction. Again, the sum(x^2) terms cancel out. */
194
5.56k
  *var = best_cost - cost[(best_dir + 4) & 7];
195
  /* We'd normally divide by 840, but dividing by 1024 is close enough
196
     for what we're going to do with this. */
197
5.56k
  *var >>= 10;
198
5.56k
  return best_dir;
199
5.56k
}
Unexecuted instantiation: cdef_find_dir_sse4_1
cdef_find_dir_avx2
Line
Count
Source
163
5.56k
                             int coeff_shift) {
164
5.56k
  int i;
165
5.56k
  int32_t cost[8];
166
5.56k
  int32_t best_cost = 0;
167
5.56k
  int best_dir = 0;
168
5.56k
  v128 lines[8];
169
50.0k
  for (i = 0; i < 8; i++) {
170
44.5k
    lines[i] = v128_load_unaligned(&img[i * stride]);
171
44.5k
    lines[i] =
172
44.5k
        v128_sub_16(v128_shr_s16(lines[i], coeff_shift), v128_dup_16(128));
173
44.5k
  }
174
175
  /* Compute "mostly vertical" directions. */
176
5.56k
  v128 dir47 = compute_directions(lines, cost + 4);
177
178
5.56k
  array_reverse_transpose_8x8(lines, lines);
179
180
  /* Compute "mostly horizontal" directions. */
181
5.56k
  v128 dir03 = compute_directions(lines, cost);
182
183
5.56k
  v128 max = v128_max_s32(dir03, dir47);
184
5.56k
  max = v128_max_s32(max, v128_align(max, max, 8));
185
5.56k
  max = v128_max_s32(max, v128_align(max, max, 4));
186
5.56k
  best_cost = v128_low_u32(max);
187
5.56k
  v128 t =
188
5.56k
      v128_pack_s32_s16(v128_cmpeq_32(max, dir47), v128_cmpeq_32(max, dir03));
189
5.56k
  best_dir = v128_movemask_8(v128_pack_s16_s8(t, t));
190
5.56k
  best_dir = get_msb(best_dir ^ (best_dir - 1));  // Count trailing zeros
191
192
  /* Difference between the optimal variance and the variance along the
193
     orthogonal direction. Again, the sum(x^2) terms cancel out. */
194
5.56k
  *var = best_cost - cost[(best_dir + 4) & 7];
195
  /* We'd normally divide by 840, but dividing by 1024 is close enough
196
     for what we're going to do with this. */
197
5.56k
  *var >>= 10;
198
5.56k
  return best_dir;
199
5.56k
}
200
201
// Work around compiler out of memory issues with Win32 builds. This issue has
202
// been observed with Visual Studio 2017, 2019, and 2022 (version 17.10.3).
203
#if defined(_MSC_VER) && defined(_M_IX86)
204
#define CDEF_INLINE static inline
205
#else
206
#define CDEF_INLINE SIMD_INLINE
207
#endif
208
209
// sign(a-b) * min(abs(a-b), max(0, threshold - (abs(a-b) >> adjdamp)))
210
CDEF_INLINE v256 constrain16(v256 a, v256 b, unsigned int threshold,
211
196M
                             unsigned int adjdamp) {
212
196M
  v256 diff = v256_sub_16(a, b);
213
196M
  const v256 sign = v256_shr_n_s16(diff, 15);
214
196M
  diff = v256_abs_s16(diff);
215
196M
  const v256 s =
216
196M
      v256_ssub_u16(v256_dup_16(threshold), v256_shr_u16(diff, adjdamp));
217
196M
  return v256_xor(v256_add_16(sign, v256_min_s16(diff, s)), sign);
218
196M
}
Unexecuted instantiation: cdef_block_sse4.c:constrain16
cdef_block_avx2.c:constrain16
Line
Count
Source
211
196M
                             unsigned int adjdamp) {
212
196M
  v256 diff = v256_sub_16(a, b);
213
196M
  const v256 sign = v256_shr_n_s16(diff, 15);
214
196M
  diff = v256_abs_s16(diff);
215
196M
  const v256 s =
216
196M
      v256_ssub_u16(v256_dup_16(threshold), v256_shr_u16(diff, adjdamp));
217
196M
  return v256_xor(v256_add_16(sign, v256_min_s16(diff, s)), sign);
218
196M
}
219
220
SIMD_INLINE v256 get_max_primary(const int is_lowbd, v256 *tap, v256 max,
221
23.1M
                                 v256 cdef_large_value_mask) {
222
23.1M
  if (is_lowbd) {
223
11.2M
    v256 max_u8;
224
11.2M
    max_u8 = tap[0];
225
11.2M
    max_u8 = v256_max_u8(max_u8, tap[1]);
226
11.2M
    max_u8 = v256_max_u8(max_u8, tap[2]);
227
11.2M
    max_u8 = v256_max_u8(max_u8, tap[3]);
228
    /* The source is 16 bits, however, we only really care about the lower
229
    8 bits.  The upper 8 bits contain the "large" flag.  After the final
230
    primary max has been calculated, zero out the upper 8 bits.  Use this
231
    to find the "16 bit" max. */
232
11.2M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
233
11.9M
  } else {
234
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
235
11.9M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
236
11.9M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
237
11.9M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
238
11.9M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
239
11.9M
  }
240
23.1M
  return max;
241
23.1M
}
Unexecuted instantiation: cdef_block_sse4.c:get_max_primary
cdef_block_avx2.c:get_max_primary
Line
Count
Source
221
23.1M
                                 v256 cdef_large_value_mask) {
222
23.1M
  if (is_lowbd) {
223
11.2M
    v256 max_u8;
224
11.2M
    max_u8 = tap[0];
225
11.2M
    max_u8 = v256_max_u8(max_u8, tap[1]);
226
11.2M
    max_u8 = v256_max_u8(max_u8, tap[2]);
227
11.2M
    max_u8 = v256_max_u8(max_u8, tap[3]);
228
    /* The source is 16 bits, however, we only really care about the lower
229
    8 bits.  The upper 8 bits contain the "large" flag.  After the final
230
    primary max has been calculated, zero out the upper 8 bits.  Use this
231
    to find the "16 bit" max. */
232
11.2M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
233
11.9M
  } else {
234
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
235
11.9M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
236
11.9M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
237
11.9M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
238
11.9M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
239
11.9M
  }
240
23.1M
  return max;
241
23.1M
}
242
243
SIMD_INLINE v256 get_max_secondary(const int is_lowbd, v256 *tap, v256 max,
244
23.6M
                                   v256 cdef_large_value_mask) {
245
23.6M
  if (is_lowbd) {
246
9.41M
    v256 max_u8;
247
9.41M
    max_u8 = tap[0];
248
9.41M
    max_u8 = v256_max_u8(max_u8, tap[1]);
249
9.41M
    max_u8 = v256_max_u8(max_u8, tap[2]);
250
9.41M
    max_u8 = v256_max_u8(max_u8, tap[3]);
251
9.41M
    max_u8 = v256_max_u8(max_u8, tap[4]);
252
9.41M
    max_u8 = v256_max_u8(max_u8, tap[5]);
253
9.41M
    max_u8 = v256_max_u8(max_u8, tap[6]);
254
9.41M
    max_u8 = v256_max_u8(max_u8, tap[7]);
255
    /* The source is 16 bits, however, we only really care about the lower
256
    8 bits.  The upper 8 bits contain the "large" flag.  After the final
257
    primary max has been calculated, zero out the upper 8 bits.  Use this
258
    to find the "16 bit" max. */
259
9.41M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
260
14.2M
  } else {
261
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
262
14.2M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
263
14.2M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
264
14.2M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
265
14.2M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
266
14.2M
    max = v256_max_s16(max, v256_and(tap[4], cdef_large_value_mask));
267
14.2M
    max = v256_max_s16(max, v256_and(tap[5], cdef_large_value_mask));
268
14.2M
    max = v256_max_s16(max, v256_and(tap[6], cdef_large_value_mask));
269
14.2M
    max = v256_max_s16(max, v256_and(tap[7], cdef_large_value_mask));
270
14.2M
  }
271
23.6M
  return max;
272
23.6M
}
Unexecuted instantiation: cdef_block_sse4.c:get_max_secondary
cdef_block_avx2.c:get_max_secondary
Line
Count
Source
244
23.6M
                                   v256 cdef_large_value_mask) {
245
23.6M
  if (is_lowbd) {
246
9.41M
    v256 max_u8;
247
9.41M
    max_u8 = tap[0];
248
9.41M
    max_u8 = v256_max_u8(max_u8, tap[1]);
249
9.41M
    max_u8 = v256_max_u8(max_u8, tap[2]);
250
9.41M
    max_u8 = v256_max_u8(max_u8, tap[3]);
251
9.41M
    max_u8 = v256_max_u8(max_u8, tap[4]);
252
9.41M
    max_u8 = v256_max_u8(max_u8, tap[5]);
253
9.41M
    max_u8 = v256_max_u8(max_u8, tap[6]);
254
9.41M
    max_u8 = v256_max_u8(max_u8, tap[7]);
255
    /* The source is 16 bits, however, we only really care about the lower
256
    8 bits.  The upper 8 bits contain the "large" flag.  After the final
257
    primary max has been calculated, zero out the upper 8 bits.  Use this
258
    to find the "16 bit" max. */
259
9.41M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
260
14.2M
  } else {
261
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
262
14.2M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
263
14.2M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
264
14.2M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
265
14.2M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
266
14.2M
    max = v256_max_s16(max, v256_and(tap[4], cdef_large_value_mask));
267
14.2M
    max = v256_max_s16(max, v256_and(tap[5], cdef_large_value_mask));
268
14.2M
    max = v256_max_s16(max, v256_and(tap[6], cdef_large_value_mask));
269
14.2M
    max = v256_max_s16(max, v256_and(tap[7], cdef_large_value_mask));
270
14.2M
  }
271
23.6M
  return max;
272
23.6M
}
273
274
// MSVC takes far too much time optimizing these.
275
// https://bugs.chromium.org/p/aomedia/issues/detail?id=3395
276
#if defined(_MSC_VER) && !defined(__clang__)
277
#pragma optimize("", off)
278
#endif
279
280
CDEF_INLINE void filter_block_4x4(const int is_lowbd, void *dest, int dstride,
281
                                  const uint16_t *in, int pri_strength,
282
                                  int sec_strength, int dir, int pri_damping,
283
                                  int sec_damping, int coeff_shift, int height,
284
36.5M
                                  int enable_primary, int enable_secondary) {
285
36.5M
  uint8_t *dst8 = (uint8_t *)dest;
286
36.5M
  uint16_t *dst16 = (uint16_t *)dest;
287
36.5M
  const int clipping_required = enable_primary && enable_secondary;
288
36.5M
  v256 p0, p1, p2, p3;
289
36.5M
  v256 sum, row, res;
290
36.5M
  v256 max, min;
291
36.5M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
292
36.5M
  const int po1 = cdef_directions[dir][0];
293
36.5M
  const int po2 = cdef_directions[dir][1];
294
36.5M
  const int s1o1 = cdef_directions[dir + 2][0];
295
36.5M
  const int s1o2 = cdef_directions[dir + 2][1];
296
36.5M
  const int s2o1 = cdef_directions[dir - 2][0];
297
36.5M
  const int s2o2 = cdef_directions[dir - 2][1];
298
36.5M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
299
36.5M
  const int *sec_taps = cdef_sec_taps;
300
36.5M
  int i;
301
302
36.5M
  if (enable_primary && pri_strength)
303
36.4M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
304
36.5M
  if (enable_secondary && sec_strength)
305
35.3M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
306
307
73.5M
  for (i = 0; i < height; i += 4) {
308
36.9M
    sum = v256_zero();
309
36.9M
    row = v256_from_v64(v64_load_aligned(&in[(i + 0) * CDEF_BSTRIDE]),
310
36.9M
                        v64_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]),
311
36.9M
                        v64_load_aligned(&in[(i + 2) * CDEF_BSTRIDE]),
312
36.9M
                        v64_load_aligned(&in[(i + 3) * CDEF_BSTRIDE]));
313
36.9M
    max = min = row;
314
315
36.9M
    if (enable_primary) {
316
36.1M
      v256 tap[4];
317
      // Primary near taps
318
36.1M
      tap[0] =
319
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po1]),
320
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]),
321
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po1]),
322
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po1]));
323
36.1M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
324
36.1M
      tap[1] =
325
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po1]),
326
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]),
327
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po1]),
328
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po1]));
329
36.1M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
330
331
      // sum += pri_taps[0] * (p0 + p1)
332
36.1M
      sum = v256_add_16(
333
36.1M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
334
335
      // Primary far taps
336
36.1M
      tap[2] =
337
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po2]),
338
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]),
339
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po2]),
340
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po2]));
341
36.1M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
342
36.1M
      tap[3] =
343
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po2]),
344
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]),
345
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po2]),
346
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po2]));
347
36.1M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
348
349
      // sum += pri_taps[1] * (p0 + p1)
350
36.1M
      sum = v256_add_16(
351
36.1M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
352
36.1M
      if (clipping_required) {
353
19.6M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
354
355
19.6M
        min = v256_min_s16(min, tap[0]);
356
19.6M
        min = v256_min_s16(min, tap[1]);
357
19.6M
        min = v256_min_s16(min, tap[2]);
358
19.6M
        min = v256_min_s16(min, tap[3]);
359
19.6M
      }
360
36.1M
    }
361
362
36.9M
    if (enable_secondary) {
363
19.9M
      v256 tap[8];
364
      // Secondary near taps
365
19.9M
      tap[0] =
366
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o1]),
367
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]),
368
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o1]),
369
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o1]));
370
19.9M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
371
19.9M
      tap[1] =
372
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o1]),
373
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]),
374
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o1]),
375
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o1]));
376
19.9M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
377
19.9M
      tap[2] =
378
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o1]),
379
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]),
380
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o1]),
381
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o1]));
382
19.9M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
383
19.9M
      tap[3] =
384
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o1]),
385
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]),
386
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o1]),
387
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o1]));
388
19.9M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
389
390
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
391
19.9M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
392
19.9M
                                            v256_add_16(v256_add_16(p0, p1),
393
19.9M
                                                        v256_add_16(p2, p3))));
394
395
      // Secondary far taps
396
19.9M
      tap[4] =
397
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o2]),
398
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]),
399
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o2]),
400
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o2]));
401
19.9M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
402
19.9M
      tap[5] =
403
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o2]),
404
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]),
405
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o2]),
406
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o2]));
407
19.9M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
408
19.9M
      tap[6] =
409
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o2]),
410
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]),
411
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o2]),
412
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o2]));
413
19.9M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
414
19.9M
      tap[7] =
415
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o2]),
416
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]),
417
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o2]),
418
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o2]));
419
19.9M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
420
421
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
422
19.9M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
423
19.9M
                                            v256_add_16(v256_add_16(p0, p1),
424
19.9M
                                                        v256_add_16(p2, p3))));
425
426
20.3M
      if (clipping_required) {
427
20.3M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
428
429
20.3M
        min = v256_min_s16(min, tap[0]);
430
20.3M
        min = v256_min_s16(min, tap[1]);
431
20.3M
        min = v256_min_s16(min, tap[2]);
432
20.3M
        min = v256_min_s16(min, tap[3]);
433
20.3M
        min = v256_min_s16(min, tap[4]);
434
20.3M
        min = v256_min_s16(min, tap[5]);
435
20.3M
        min = v256_min_s16(min, tap[6]);
436
20.3M
        min = v256_min_s16(min, tap[7]);
437
20.3M
      }
438
19.9M
    }
439
440
    // res = row + ((sum - (sum < 0) + 8) >> 4)
441
36.9M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
442
36.9M
    res = v256_add_16(sum, v256_dup_16(8));
443
36.9M
    res = v256_shr_n_s16(res, 4);
444
36.9M
    res = v256_add_16(row, res);
445
36.9M
    if (clipping_required) {
446
20.3M
      res = v256_min_s16(v256_max_s16(res, min), max);
447
20.3M
    }
448
449
36.9M
    if (is_lowbd) {
450
10.5M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
451
10.5M
      u32_store_aligned(&dst8[(i + 0) * dstride],
452
10.5M
                        v64_high_u32(v128_high_v64(res_128)));
453
10.5M
      u32_store_aligned(&dst8[(i + 1) * dstride],
454
10.5M
                        v64_low_u32(v128_high_v64(res_128)));
455
10.5M
      u32_store_aligned(&dst8[(i + 2) * dstride],
456
10.5M
                        v64_high_u32(v128_low_v64(res_128)));
457
10.5M
      u32_store_aligned(&dst8[(i + 3) * dstride],
458
10.5M
                        v64_low_u32(v128_low_v64(res_128)));
459
26.4M
    } else {
460
26.4M
      v64_store_aligned(&dst16[(i + 0) * dstride],
461
26.4M
                        v128_high_v64(v256_high_v128(res)));
462
26.4M
      v64_store_aligned(&dst16[(i + 1) * dstride],
463
26.4M
                        v128_low_v64(v256_high_v128(res)));
464
26.4M
      v64_store_aligned(&dst16[(i + 2) * dstride],
465
26.4M
                        v128_high_v64(v256_low_v128(res)));
466
26.4M
      v64_store_aligned(&dst16[(i + 3) * dstride],
467
26.4M
                        v128_low_v64(v256_low_v128(res)));
468
26.4M
    }
469
36.9M
  }
470
36.5M
}
Unexecuted instantiation: cdef_block_sse4.c:filter_block_4x4
cdef_block_avx2.c:filter_block_4x4
Line
Count
Source
284
36.5M
                                  int enable_primary, int enable_secondary) {
285
36.5M
  uint8_t *dst8 = (uint8_t *)dest;
286
36.5M
  uint16_t *dst16 = (uint16_t *)dest;
287
36.5M
  const int clipping_required = enable_primary && enable_secondary;
288
36.5M
  v256 p0, p1, p2, p3;
289
36.5M
  v256 sum, row, res;
290
36.5M
  v256 max, min;
291
36.5M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
292
36.5M
  const int po1 = cdef_directions[dir][0];
293
36.5M
  const int po2 = cdef_directions[dir][1];
294
36.5M
  const int s1o1 = cdef_directions[dir + 2][0];
295
36.5M
  const int s1o2 = cdef_directions[dir + 2][1];
296
36.5M
  const int s2o1 = cdef_directions[dir - 2][0];
297
36.5M
  const int s2o2 = cdef_directions[dir - 2][1];
298
36.5M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
299
36.5M
  const int *sec_taps = cdef_sec_taps;
300
36.5M
  int i;
301
302
36.5M
  if (enable_primary && pri_strength)
303
36.4M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
304
36.5M
  if (enable_secondary && sec_strength)
305
35.3M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
306
307
73.5M
  for (i = 0; i < height; i += 4) {
308
36.9M
    sum = v256_zero();
309
36.9M
    row = v256_from_v64(v64_load_aligned(&in[(i + 0) * CDEF_BSTRIDE]),
310
36.9M
                        v64_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]),
311
36.9M
                        v64_load_aligned(&in[(i + 2) * CDEF_BSTRIDE]),
312
36.9M
                        v64_load_aligned(&in[(i + 3) * CDEF_BSTRIDE]));
313
36.9M
    max = min = row;
314
315
36.9M
    if (enable_primary) {
316
36.1M
      v256 tap[4];
317
      // Primary near taps
318
36.1M
      tap[0] =
319
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po1]),
320
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]),
321
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po1]),
322
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po1]));
323
36.1M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
324
36.1M
      tap[1] =
325
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po1]),
326
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]),
327
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po1]),
328
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po1]));
329
36.1M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
330
331
      // sum += pri_taps[0] * (p0 + p1)
332
36.1M
      sum = v256_add_16(
333
36.1M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
334
335
      // Primary far taps
336
36.1M
      tap[2] =
337
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po2]),
338
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]),
339
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po2]),
340
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po2]));
341
36.1M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
342
36.1M
      tap[3] =
343
36.1M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po2]),
344
36.1M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]),
345
36.1M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po2]),
346
36.1M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po2]));
347
36.1M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
348
349
      // sum += pri_taps[1] * (p0 + p1)
350
36.1M
      sum = v256_add_16(
351
36.1M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
352
36.1M
      if (clipping_required) {
353
19.6M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
354
355
19.6M
        min = v256_min_s16(min, tap[0]);
356
19.6M
        min = v256_min_s16(min, tap[1]);
357
19.6M
        min = v256_min_s16(min, tap[2]);
358
19.6M
        min = v256_min_s16(min, tap[3]);
359
19.6M
      }
360
36.1M
    }
361
362
36.9M
    if (enable_secondary) {
363
19.9M
      v256 tap[8];
364
      // Secondary near taps
365
19.9M
      tap[0] =
366
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o1]),
367
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]),
368
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o1]),
369
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o1]));
370
19.9M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
371
19.9M
      tap[1] =
372
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o1]),
373
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]),
374
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o1]),
375
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o1]));
376
19.9M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
377
19.9M
      tap[2] =
378
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o1]),
379
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]),
380
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o1]),
381
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o1]));
382
19.9M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
383
19.9M
      tap[3] =
384
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o1]),
385
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]),
386
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o1]),
387
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o1]));
388
19.9M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
389
390
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
391
19.9M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
392
19.9M
                                            v256_add_16(v256_add_16(p0, p1),
393
19.9M
                                                        v256_add_16(p2, p3))));
394
395
      // Secondary far taps
396
19.9M
      tap[4] =
397
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o2]),
398
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]),
399
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o2]),
400
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o2]));
401
19.9M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
402
19.9M
      tap[5] =
403
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o2]),
404
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]),
405
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o2]),
406
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o2]));
407
19.9M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
408
19.9M
      tap[6] =
409
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o2]),
410
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]),
411
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o2]),
412
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o2]));
413
19.9M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
414
19.9M
      tap[7] =
415
19.9M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o2]),
416
19.9M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]),
417
19.9M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o2]),
418
19.9M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o2]));
419
19.9M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
420
421
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
422
19.9M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
423
19.9M
                                            v256_add_16(v256_add_16(p0, p1),
424
19.9M
                                                        v256_add_16(p2, p3))));
425
426
20.3M
      if (clipping_required) {
427
20.3M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
428
429
20.3M
        min = v256_min_s16(min, tap[0]);
430
20.3M
        min = v256_min_s16(min, tap[1]);
431
20.3M
        min = v256_min_s16(min, tap[2]);
432
20.3M
        min = v256_min_s16(min, tap[3]);
433
20.3M
        min = v256_min_s16(min, tap[4]);
434
20.3M
        min = v256_min_s16(min, tap[5]);
435
20.3M
        min = v256_min_s16(min, tap[6]);
436
20.3M
        min = v256_min_s16(min, tap[7]);
437
20.3M
      }
438
19.9M
    }
439
440
    // res = row + ((sum - (sum < 0) + 8) >> 4)
441
36.9M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
442
36.9M
    res = v256_add_16(sum, v256_dup_16(8));
443
36.9M
    res = v256_shr_n_s16(res, 4);
444
36.9M
    res = v256_add_16(row, res);
445
36.9M
    if (clipping_required) {
446
20.3M
      res = v256_min_s16(v256_max_s16(res, min), max);
447
20.3M
    }
448
449
36.9M
    if (is_lowbd) {
450
10.5M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
451
10.5M
      u32_store_aligned(&dst8[(i + 0) * dstride],
452
10.5M
                        v64_high_u32(v128_high_v64(res_128)));
453
10.5M
      u32_store_aligned(&dst8[(i + 1) * dstride],
454
10.5M
                        v64_low_u32(v128_high_v64(res_128)));
455
10.5M
      u32_store_aligned(&dst8[(i + 2) * dstride],
456
10.5M
                        v64_high_u32(v128_low_v64(res_128)));
457
10.5M
      u32_store_aligned(&dst8[(i + 3) * dstride],
458
10.5M
                        v64_low_u32(v128_low_v64(res_128)));
459
26.4M
    } else {
460
26.4M
      v64_store_aligned(&dst16[(i + 0) * dstride],
461
26.4M
                        v128_high_v64(v256_high_v128(res)));
462
26.4M
      v64_store_aligned(&dst16[(i + 1) * dstride],
463
26.4M
                        v128_low_v64(v256_high_v128(res)));
464
26.4M
      v64_store_aligned(&dst16[(i + 2) * dstride],
465
26.4M
                        v128_high_v64(v256_low_v128(res)));
466
26.4M
      v64_store_aligned(&dst16[(i + 3) * dstride],
467
26.4M
                        v128_low_v64(v256_low_v128(res)));
468
26.4M
    }
469
36.9M
  }
470
36.5M
}
471
472
CDEF_INLINE void filter_block_8x8(const int is_lowbd, void *dest, int dstride,
473
                                  const uint16_t *in, int pri_strength,
474
                                  int sec_strength, int dir, int pri_damping,
475
                                  int sec_damping, int coeff_shift, int height,
476
14.3M
                                  int enable_primary, int enable_secondary) {
477
14.3M
  uint8_t *dst8 = (uint8_t *)dest;
478
14.3M
  uint16_t *dst16 = (uint16_t *)dest;
479
14.3M
  const int clipping_required = enable_primary && enable_secondary;
480
14.3M
  int i;
481
14.3M
  v256 sum, p0, p1, p2, p3, row, res;
482
14.3M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
483
14.3M
  v256 max, min;
484
14.3M
  const int po1 = cdef_directions[dir][0];
485
14.3M
  const int po2 = cdef_directions[dir][1];
486
14.3M
  const int s1o1 = cdef_directions[dir + 2][0];
487
14.3M
  const int s1o2 = cdef_directions[dir + 2][1];
488
14.3M
  const int s2o1 = cdef_directions[dir - 2][0];
489
14.3M
  const int s2o2 = cdef_directions[dir - 2][1];
490
14.3M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
491
14.3M
  const int *sec_taps = cdef_sec_taps;
492
493
14.3M
  if (enable_primary && pri_strength)
494
10.3M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
495
14.3M
  if (enable_secondary && sec_strength)
496
12.3M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
497
498
53.2M
  for (i = 0; i < height; i += 2) {
499
38.8M
    v256 tap[8];
500
38.8M
    sum = v256_zero();
501
38.8M
    row = v256_from_v128(v128_load_aligned(&in[i * CDEF_BSTRIDE]),
502
38.8M
                         v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]));
503
504
38.8M
    min = max = row;
505
38.8M
    if (enable_primary) {
506
      // Primary near taps
507
26.7M
      tap[0] = v256_from_v128(
508
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po1]),
509
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]));
510
26.7M
      tap[1] = v256_from_v128(
511
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po1]),
512
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]));
513
26.7M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
514
26.7M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
515
516
      // sum += pri_taps[0] * (p0 + p1)
517
26.7M
      sum = v256_add_16(
518
26.7M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
519
520
      // Primary far taps
521
26.7M
      tap[2] = v256_from_v128(
522
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po2]),
523
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]));
524
26.7M
      tap[3] = v256_from_v128(
525
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po2]),
526
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]));
527
26.7M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
528
26.7M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
529
530
      // sum += pri_taps[1] * (p0 + p1)
531
26.7M
      sum = v256_add_16(
532
26.7M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
533
534
26.7M
      if (clipping_required) {
535
18.0M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
536
537
18.0M
        min = v256_min_s16(min, tap[0]);
538
18.0M
        min = v256_min_s16(min, tap[1]);
539
18.0M
        min = v256_min_s16(min, tap[2]);
540
18.0M
        min = v256_min_s16(min, tap[3]);
541
18.0M
      }
542
      // End primary
543
26.7M
    }
544
545
38.8M
    if (enable_secondary) {
546
      // Secondary near taps
547
31.4M
      tap[0] = v256_from_v128(
548
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o1]),
549
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]));
550
31.4M
      tap[1] = v256_from_v128(
551
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o1]),
552
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]));
553
31.4M
      tap[2] = v256_from_v128(
554
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o1]),
555
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]));
556
31.4M
      tap[3] = v256_from_v128(
557
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o1]),
558
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]));
559
31.4M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
560
31.4M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
561
31.4M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
562
31.4M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
563
564
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
565
31.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
566
31.4M
                                            v256_add_16(v256_add_16(p0, p1),
567
31.4M
                                                        v256_add_16(p2, p3))));
568
569
      // Secondary far taps
570
31.4M
      tap[4] = v256_from_v128(
571
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o2]),
572
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]));
573
31.4M
      tap[5] = v256_from_v128(
574
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o2]),
575
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]));
576
31.4M
      tap[6] = v256_from_v128(
577
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o2]),
578
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]));
579
31.4M
      tap[7] = v256_from_v128(
580
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o2]),
581
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]));
582
31.4M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
583
31.4M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
584
31.4M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
585
31.4M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
586
587
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
588
31.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
589
31.4M
                                            v256_add_16(v256_add_16(p0, p1),
590
31.4M
                                                        v256_add_16(p2, p3))));
591
592
31.4M
      if (clipping_required) {
593
18.4M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
594
595
18.4M
        min = v256_min_s16(min, tap[0]);
596
18.4M
        min = v256_min_s16(min, tap[1]);
597
18.4M
        min = v256_min_s16(min, tap[2]);
598
18.4M
        min = v256_min_s16(min, tap[3]);
599
18.4M
        min = v256_min_s16(min, tap[4]);
600
18.4M
        min = v256_min_s16(min, tap[5]);
601
18.4M
        min = v256_min_s16(min, tap[6]);
602
18.4M
        min = v256_min_s16(min, tap[7]);
603
18.4M
      }
604
      // End secondary
605
31.4M
    }
606
607
    // res = row + ((sum - (sum < 0) + 8) >> 4)
608
38.8M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
609
38.8M
    res = v256_add_16(sum, v256_dup_16(8));
610
38.8M
    res = v256_shr_n_s16(res, 4);
611
38.8M
    res = v256_add_16(row, res);
612
38.8M
    if (clipping_required) {
613
18.4M
      res = v256_min_s16(v256_max_s16(res, min), max);
614
18.4M
    }
615
616
38.8M
    if (is_lowbd) {
617
16.0M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
618
16.0M
      v64_store_aligned(&dst8[i * dstride], v128_high_v64(res_128));
619
16.0M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_low_v64(res_128));
620
22.8M
    } else {
621
22.8M
      v128_store_unaligned(&dst16[i * dstride], v256_high_v128(res));
622
22.8M
      v128_store_unaligned(&dst16[(i + 1) * dstride], v256_low_v128(res));
623
22.8M
    }
624
38.8M
  }
625
14.3M
}
Unexecuted instantiation: cdef_block_sse4.c:filter_block_8x8
cdef_block_avx2.c:filter_block_8x8
Line
Count
Source
476
14.3M
                                  int enable_primary, int enable_secondary) {
477
14.3M
  uint8_t *dst8 = (uint8_t *)dest;
478
14.3M
  uint16_t *dst16 = (uint16_t *)dest;
479
14.3M
  const int clipping_required = enable_primary && enable_secondary;
480
14.3M
  int i;
481
14.3M
  v256 sum, p0, p1, p2, p3, row, res;
482
14.3M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
483
14.3M
  v256 max, min;
484
14.3M
  const int po1 = cdef_directions[dir][0];
485
14.3M
  const int po2 = cdef_directions[dir][1];
486
14.3M
  const int s1o1 = cdef_directions[dir + 2][0];
487
14.3M
  const int s1o2 = cdef_directions[dir + 2][1];
488
14.3M
  const int s2o1 = cdef_directions[dir - 2][0];
489
14.3M
  const int s2o2 = cdef_directions[dir - 2][1];
490
14.3M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
491
14.3M
  const int *sec_taps = cdef_sec_taps;
492
493
14.3M
  if (enable_primary && pri_strength)
494
10.3M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
495
14.3M
  if (enable_secondary && sec_strength)
496
12.3M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
497
498
53.2M
  for (i = 0; i < height; i += 2) {
499
38.8M
    v256 tap[8];
500
38.8M
    sum = v256_zero();
501
38.8M
    row = v256_from_v128(v128_load_aligned(&in[i * CDEF_BSTRIDE]),
502
38.8M
                         v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]));
503
504
38.8M
    min = max = row;
505
38.8M
    if (enable_primary) {
506
      // Primary near taps
507
26.7M
      tap[0] = v256_from_v128(
508
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po1]),
509
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]));
510
26.7M
      tap[1] = v256_from_v128(
511
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po1]),
512
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]));
513
26.7M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
514
26.7M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
515
516
      // sum += pri_taps[0] * (p0 + p1)
517
26.7M
      sum = v256_add_16(
518
26.7M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
519
520
      // Primary far taps
521
26.7M
      tap[2] = v256_from_v128(
522
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po2]),
523
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]));
524
26.7M
      tap[3] = v256_from_v128(
525
26.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po2]),
526
26.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]));
527
26.7M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
528
26.7M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
529
530
      // sum += pri_taps[1] * (p0 + p1)
531
26.7M
      sum = v256_add_16(
532
26.7M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
533
534
26.7M
      if (clipping_required) {
535
18.0M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
536
537
18.0M
        min = v256_min_s16(min, tap[0]);
538
18.0M
        min = v256_min_s16(min, tap[1]);
539
18.0M
        min = v256_min_s16(min, tap[2]);
540
18.0M
        min = v256_min_s16(min, tap[3]);
541
18.0M
      }
542
      // End primary
543
26.7M
    }
544
545
38.8M
    if (enable_secondary) {
546
      // Secondary near taps
547
31.4M
      tap[0] = v256_from_v128(
548
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o1]),
549
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]));
550
31.4M
      tap[1] = v256_from_v128(
551
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o1]),
552
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]));
553
31.4M
      tap[2] = v256_from_v128(
554
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o1]),
555
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]));
556
31.4M
      tap[3] = v256_from_v128(
557
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o1]),
558
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]));
559
31.4M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
560
31.4M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
561
31.4M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
562
31.4M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
563
564
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
565
31.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
566
31.4M
                                            v256_add_16(v256_add_16(p0, p1),
567
31.4M
                                                        v256_add_16(p2, p3))));
568
569
      // Secondary far taps
570
31.4M
      tap[4] = v256_from_v128(
571
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o2]),
572
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]));
573
31.4M
      tap[5] = v256_from_v128(
574
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o2]),
575
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]));
576
31.4M
      tap[6] = v256_from_v128(
577
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o2]),
578
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]));
579
31.4M
      tap[7] = v256_from_v128(
580
31.4M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o2]),
581
31.4M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]));
582
31.4M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
583
31.4M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
584
31.4M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
585
31.4M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
586
587
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
588
31.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
589
31.4M
                                            v256_add_16(v256_add_16(p0, p1),
590
31.4M
                                                        v256_add_16(p2, p3))));
591
592
31.4M
      if (clipping_required) {
593
18.4M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
594
595
18.4M
        min = v256_min_s16(min, tap[0]);
596
18.4M
        min = v256_min_s16(min, tap[1]);
597
18.4M
        min = v256_min_s16(min, tap[2]);
598
18.4M
        min = v256_min_s16(min, tap[3]);
599
18.4M
        min = v256_min_s16(min, tap[4]);
600
18.4M
        min = v256_min_s16(min, tap[5]);
601
18.4M
        min = v256_min_s16(min, tap[6]);
602
18.4M
        min = v256_min_s16(min, tap[7]);
603
18.4M
      }
604
      // End secondary
605
31.4M
    }
606
607
    // res = row + ((sum - (sum < 0) + 8) >> 4)
608
38.8M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
609
38.8M
    res = v256_add_16(sum, v256_dup_16(8));
610
38.8M
    res = v256_shr_n_s16(res, 4);
611
38.8M
    res = v256_add_16(row, res);
612
38.8M
    if (clipping_required) {
613
18.4M
      res = v256_min_s16(v256_max_s16(res, min), max);
614
18.4M
    }
615
616
38.8M
    if (is_lowbd) {
617
16.0M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
618
16.0M
      v64_store_aligned(&dst8[i * dstride], v128_high_v64(res_128));
619
16.0M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_low_v64(res_128));
620
22.8M
    } else {
621
22.8M
      v128_store_unaligned(&dst16[i * dstride], v256_high_v128(res));
622
22.8M
      v128_store_unaligned(&dst16[(i + 1) * dstride], v256_low_v128(res));
623
22.8M
    }
624
38.8M
  }
625
14.3M
}
626
627
#if defined(_MSC_VER) && !defined(__clang__)
628
#pragma optimize("", on)
629
#endif
630
631
SIMD_INLINE void copy_block_4xh(const int is_lowbd, void *dest, int dstride,
632
0
                                const uint16_t *in, int height) {
633
0
  uint8_t *dst8 = (uint8_t *)dest;
634
0
  uint16_t *dst16 = (uint16_t *)dest;
635
0
  int i;
636
0
  for (i = 0; i < height; i += 4) {
637
0
    const v128 row0 =
638
0
        v128_from_v64(v64_load_aligned(&in[(i + 0) * CDEF_BSTRIDE]),
639
0
                      v64_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]));
640
0
    const v128 row1 =
641
0
        v128_from_v64(v64_load_aligned(&in[(i + 2) * CDEF_BSTRIDE]),
642
0
                      v64_load_aligned(&in[(i + 3) * CDEF_BSTRIDE]));
643
0
    if (is_lowbd) {
644
      /* Note: v128_pack_s16_u8(). The parameter order is swapped internally */
645
0
      const v128 res_128 = v128_pack_s16_u8(row1, row0);
646
0
      u32_store_aligned(&dst8[(i + 0) * dstride],
647
0
                        v64_high_u32(v128_low_v64(res_128)));
648
0
      u32_store_aligned(&dst8[(i + 1) * dstride],
649
0
                        v64_low_u32(v128_low_v64(res_128)));
650
0
      u32_store_aligned(&dst8[(i + 2) * dstride],
651
0
                        v64_high_u32(v128_high_v64(res_128)));
652
0
      u32_store_aligned(&dst8[(i + 3) * dstride],
653
0
                        v64_low_u32(v128_high_v64(res_128)));
654
0
    } else {
655
0
      v64_store_aligned(&dst16[(i + 0) * dstride], v128_high_v64(row0));
656
0
      v64_store_aligned(&dst16[(i + 1) * dstride], v128_low_v64(row0));
657
0
      v64_store_aligned(&dst16[(i + 2) * dstride], v128_high_v64(row1));
658
0
      v64_store_aligned(&dst16[(i + 3) * dstride], v128_low_v64(row1));
659
0
    }
660
0
  }
661
0
}
Unexecuted instantiation: cdef_block_sse4.c:copy_block_4xh
Unexecuted instantiation: cdef_block_avx2.c:copy_block_4xh
662
663
SIMD_INLINE void copy_block_8xh(const int is_lowbd, void *dest, int dstride,
664
4.42M
                                const uint16_t *in, int height) {
665
4.42M
  uint8_t *dst8 = (uint8_t *)dest;
666
4.42M
  uint16_t *dst16 = (uint16_t *)dest;
667
4.42M
  int i;
668
22.0M
  for (i = 0; i < height; i += 2) {
669
17.5M
    const v128 row0 = v128_load_aligned(&in[i * CDEF_BSTRIDE]);
670
17.5M
    const v128 row1 = v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]);
671
17.5M
    if (is_lowbd) {
672
      /* Note: v128_pack_s16_u8(). The parameter order is swapped internally */
673
7.53M
      const v128 res_128 = v128_pack_s16_u8(row1, row0);
674
7.53M
      v64_store_aligned(&dst8[i * dstride], v128_low_v64(res_128));
675
7.53M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_high_v64(res_128));
676
10.0M
    } else {
677
10.0M
      v128_store_unaligned(&dst16[i * dstride], row0);
678
10.0M
      v128_store_unaligned(&dst16[(i + 1) * dstride], row1);
679
10.0M
    }
680
17.5M
  }
681
4.42M
}
Unexecuted instantiation: cdef_block_sse4.c:copy_block_8xh
cdef_block_avx2.c:copy_block_8xh
Line
Count
Source
664
4.42M
                                const uint16_t *in, int height) {
665
4.42M
  uint8_t *dst8 = (uint8_t *)dest;
666
4.42M
  uint16_t *dst16 = (uint16_t *)dest;
667
4.42M
  int i;
668
22.0M
  for (i = 0; i < height; i += 2) {
669
17.5M
    const v128 row0 = v128_load_aligned(&in[i * CDEF_BSTRIDE]);
670
17.5M
    const v128 row1 = v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]);
671
17.5M
    if (is_lowbd) {
672
      /* Note: v128_pack_s16_u8(). The parameter order is swapped internally */
673
7.53M
      const v128 res_128 = v128_pack_s16_u8(row1, row0);
674
7.53M
      v64_store_aligned(&dst8[i * dstride], v128_low_v64(res_128));
675
7.53M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_high_v64(res_128));
676
10.0M
    } else {
677
10.0M
      v128_store_unaligned(&dst16[i * dstride], row0);
678
10.0M
      v128_store_unaligned(&dst16[(i + 1) * dstride], row1);
679
10.0M
    }
680
17.5M
  }
681
4.42M
}
682
683
void SIMD_FUNC(cdef_filter_8_0)(void *dest, int dstride, const uint16_t *in,
684
                                int pri_strength, int sec_strength, int dir,
685
                                int pri_damping, int sec_damping,
686
                                int coeff_shift, int block_width,
687
16.8M
                                int block_height) {
688
16.8M
  if (block_width == 8) {
689
3.12M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
690
3.12M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
691
3.12M
                     block_height, /*enable_primary=*/1,
692
3.12M
                     /*enable_secondary=*/1);
693
13.6M
  } else {
694
13.6M
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
695
13.6M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
696
13.6M
                     block_height, /*enable_primary=*/1,
697
13.6M
                     /*enable_secondary=*/1);
698
13.6M
  }
699
16.8M
}
Unexecuted instantiation: cdef_filter_8_0_sse4_1
cdef_filter_8_0_avx2
Line
Count
Source
687
16.8M
                                int block_height) {
688
16.8M
  if (block_width == 8) {
689
3.12M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
690
3.12M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
691
3.12M
                     block_height, /*enable_primary=*/1,
692
3.12M
                     /*enable_secondary=*/1);
693
13.6M
  } else {
694
13.6M
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
695
13.6M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
696
13.6M
                     block_height, /*enable_primary=*/1,
697
13.6M
                     /*enable_secondary=*/1);
698
13.6M
  }
699
16.8M
}
700
701
void SIMD_FUNC(cdef_filter_8_1)(void *dest, int dstride, const uint16_t *in,
702
                                int pri_strength, int sec_strength, int dir,
703
                                int pri_damping, int sec_damping,
704
                                int coeff_shift, int block_width,
705
2.10M
                                int block_height) {
706
2.10M
  if (block_width == 8) {
707
1.30M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
708
1.30M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
709
1.30M
                     block_height, /*enable_primary=*/1,
710
1.30M
                     /*enable_secondary=*/0);
711
1.30M
  } else {
712
806k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
713
806k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
714
806k
                     block_height, /*enable_primary=*/1,
715
806k
                     /*enable_secondary=*/0);
716
806k
  }
717
2.10M
}
Unexecuted instantiation: cdef_filter_8_1_sse4_1
cdef_filter_8_1_avx2
Line
Count
Source
705
2.10M
                                int block_height) {
706
2.10M
  if (block_width == 8) {
707
1.30M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
708
1.30M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
709
1.30M
                     block_height, /*enable_primary=*/1,
710
1.30M
                     /*enable_secondary=*/0);
711
1.30M
  } else {
712
806k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
713
806k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
714
806k
                     block_height, /*enable_primary=*/1,
715
806k
                     /*enable_secondary=*/0);
716
806k
  }
717
2.10M
}
718
void SIMD_FUNC(cdef_filter_8_2)(void *dest, int dstride, const uint16_t *in,
719
                                int pri_strength, int sec_strength, int dir,
720
                                int pri_damping, int sec_damping,
721
                                int coeff_shift, int block_width,
722
2.77M
                                int block_height) {
723
2.77M
  if (block_width == 8) {
724
2.64M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
725
2.64M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
726
2.64M
                     block_height, /*enable_primary=*/0,
727
2.64M
                     /*enable_secondary=*/1);
728
2.64M
  } else {
729
131k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
730
131k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
731
131k
                     block_height, /*enable_primary=*/0,
732
131k
                     /*enable_secondary=*/1);
733
131k
  }
734
2.77M
}
Unexecuted instantiation: cdef_filter_8_2_sse4_1
cdef_filter_8_2_avx2
Line
Count
Source
722
2.77M
                                int block_height) {
723
2.77M
  if (block_width == 8) {
724
2.64M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
725
2.64M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
726
2.64M
                     block_height, /*enable_primary=*/0,
727
2.64M
                     /*enable_secondary=*/1);
728
2.64M
  } else {
729
131k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
730
131k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
731
131k
                     block_height, /*enable_primary=*/0,
732
131k
                     /*enable_secondary=*/1);
733
131k
  }
734
2.77M
}
735
736
void SIMD_FUNC(cdef_filter_8_3)(void *dest, int dstride, const uint16_t *in,
737
                                int pri_strength, int sec_strength, int dir,
738
                                int pri_damping, int sec_damping,
739
                                int coeff_shift, int block_width,
740
1.91M
                                int block_height) {
741
1.91M
  (void)pri_strength;
742
1.91M
  (void)sec_strength;
743
1.91M
  (void)dir;
744
1.91M
  (void)pri_damping;
745
1.91M
  (void)sec_damping;
746
1.91M
  (void)coeff_shift;
747
1.91M
  (void)block_width;
748
749
1.91M
  if (block_width == 8) {
750
1.91M
    copy_block_8xh(/*is_lowbd=*/1, dest, dstride, in, block_height);
751
18.4E
  } else {
752
18.4E
    copy_block_4xh(/*is_lowbd=*/1, dest, dstride, in, block_height);
753
18.4E
  }
754
1.91M
}
Unexecuted instantiation: cdef_filter_8_3_sse4_1
cdef_filter_8_3_avx2
Line
Count
Source
740
1.91M
                                int block_height) {
741
1.91M
  (void)pri_strength;
742
1.91M
  (void)sec_strength;
743
1.91M
  (void)dir;
744
1.91M
  (void)pri_damping;
745
1.91M
  (void)sec_damping;
746
1.91M
  (void)coeff_shift;
747
1.91M
  (void)block_width;
748
749
1.91M
  if (block_width == 8) {
750
1.91M
    copy_block_8xh(/*is_lowbd=*/1, dest, dstride, in, block_height);
751
18.4E
  } else {
752
18.4E
    copy_block_4xh(/*is_lowbd=*/1, dest, dstride, in, block_height);
753
18.4E
  }
754
1.91M
}
755
756
void SIMD_FUNC(cdef_filter_16_0)(void *dest, int dstride, const uint16_t *in,
757
                                 int pri_strength, int sec_strength, int dir,
758
                                 int pri_damping, int sec_damping,
759
                                 int coeff_shift, int block_width,
760
22.7M
                                 int block_height) {
761
22.7M
  if (block_width == 8) {
762
4.60M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
763
4.60M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
764
4.60M
                     block_height, /*enable_primary=*/1,
765
4.60M
                     /*enable_secondary=*/1);
766
18.1M
  } else {
767
18.1M
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
768
18.1M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
769
18.1M
                     block_height, /*enable_primary=*/1,
770
18.1M
                     /*enable_secondary=*/1);
771
18.1M
  }
772
22.7M
}
Unexecuted instantiation: cdef_filter_16_0_sse4_1
cdef_filter_16_0_avx2
Line
Count
Source
760
22.7M
                                 int block_height) {
761
22.7M
  if (block_width == 8) {
762
4.60M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
763
4.60M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
764
4.60M
                     block_height, /*enable_primary=*/1,
765
4.60M
                     /*enable_secondary=*/1);
766
18.1M
  } else {
767
18.1M
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
768
18.1M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
769
18.1M
                     block_height, /*enable_primary=*/1,
770
18.1M
                     /*enable_secondary=*/1);
771
18.1M
  }
772
22.7M
}
773
774
void SIMD_FUNC(cdef_filter_16_1)(void *dest, int dstride, const uint16_t *in,
775
                                 int pri_strength, int sec_strength, int dir,
776
                                 int pri_damping, int sec_damping,
777
                                 int coeff_shift, int block_width,
778
2.28M
                                 int block_height) {
779
2.28M
  if (block_width == 8) {
780
1.73M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
781
1.73M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
782
1.73M
                     block_height, /*enable_primary=*/1,
783
1.73M
                     /*enable_secondary=*/0);
784
1.73M
  } else {
785
550k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
786
550k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
787
550k
                     block_height, /*enable_primary=*/1,
788
550k
                     /*enable_secondary=*/0);
789
550k
  }
790
2.28M
}
Unexecuted instantiation: cdef_filter_16_1_sse4_1
cdef_filter_16_1_avx2
Line
Count
Source
778
2.28M
                                 int block_height) {
779
2.28M
  if (block_width == 8) {
780
1.73M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
781
1.73M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
782
1.73M
                     block_height, /*enable_primary=*/1,
783
1.73M
                     /*enable_secondary=*/0);
784
1.73M
  } else {
785
550k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
786
550k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
787
550k
                     block_height, /*enable_primary=*/1,
788
550k
                     /*enable_secondary=*/0);
789
550k
  }
790
2.28M
}
791
void SIMD_FUNC(cdef_filter_16_2)(void *dest, int dstride, const uint16_t *in,
792
                                 int pri_strength, int sec_strength, int dir,
793
                                 int pri_damping, int sec_damping,
794
                                 int coeff_shift, int block_width,
795
2.27M
                                 int block_height) {
796
2.27M
  if (block_width == 8) {
797
2.10M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
798
2.10M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
799
2.10M
                     block_height, /*enable_primary=*/0,
800
2.10M
                     /*enable_secondary=*/1);
801
2.10M
  } else {
802
169k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
803
169k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
804
169k
                     block_height, /*enable_primary=*/0,
805
169k
                     /*enable_secondary=*/1);
806
169k
  }
807
2.27M
}
Unexecuted instantiation: cdef_filter_16_2_sse4_1
cdef_filter_16_2_avx2
Line
Count
Source
795
2.27M
                                 int block_height) {
796
2.27M
  if (block_width == 8) {
797
2.10M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
798
2.10M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
799
2.10M
                     block_height, /*enable_primary=*/0,
800
2.10M
                     /*enable_secondary=*/1);
801
2.10M
  } else {
802
169k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
803
169k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
804
169k
                     block_height, /*enable_primary=*/0,
805
169k
                     /*enable_secondary=*/1);
806
169k
  }
807
2.27M
}
808
809
void SIMD_FUNC(cdef_filter_16_3)(void *dest, int dstride, const uint16_t *in,
810
                                 int pri_strength, int sec_strength, int dir,
811
                                 int pri_damping, int sec_damping,
812
                                 int coeff_shift, int block_width,
813
2.51M
                                 int block_height) {
814
2.51M
  (void)pri_strength;
815
2.51M
  (void)sec_strength;
816
2.51M
  (void)dir;
817
2.51M
  (void)pri_damping;
818
2.51M
  (void)sec_damping;
819
2.51M
  (void)coeff_shift;
820
2.51M
  (void)block_width;
821
2.51M
  if (block_width == 8) {
822
2.51M
    copy_block_8xh(/*is_lowbd=*/0, dest, dstride, in, block_height);
823
18.4E
  } else {
824
18.4E
    copy_block_4xh(/*is_lowbd=*/0, dest, dstride, in, block_height);
825
18.4E
  }
826
2.51M
}
Unexecuted instantiation: cdef_filter_16_3_sse4_1
cdef_filter_16_3_avx2
Line
Count
Source
813
2.51M
                                 int block_height) {
814
2.51M
  (void)pri_strength;
815
2.51M
  (void)sec_strength;
816
2.51M
  (void)dir;
817
2.51M
  (void)pri_damping;
818
2.51M
  (void)sec_damping;
819
2.51M
  (void)coeff_shift;
820
2.51M
  (void)block_width;
821
2.51M
  if (block_width == 8) {
822
2.51M
    copy_block_8xh(/*is_lowbd=*/0, dest, dstride, in, block_height);
823
18.4E
  } else {
824
18.4E
    copy_block_4xh(/*is_lowbd=*/0, dest, dstride, in, block_height);
825
18.4E
  }
826
2.51M
}
827
828
#if CONFIG_AV1_HIGHBITDEPTH
829
void SIMD_FUNC(cdef_copy_rect8_16bit_to_16bit)(uint16_t *dst, int dstride,
830
                                               const uint16_t *src, int sstride,
831
662k
                                               int width, int height) {
832
662k
  int i, j;
833
23.7M
  for (i = 0; i < height; i++) {
834
189M
    for (j = 0; j < (width & ~0x7); j += 8) {
835
166M
      v128 row = v128_load_unaligned(&src[i * sstride + j]);
836
166M
      v128_store_unaligned(&dst[i * dstride + j], row);
837
166M
    }
838
24.4M
    for (; j < width; j++) {
839
1.39M
      dst[i * dstride + j] = src[i * sstride + j];
840
1.39M
    }
841
23.0M
  }
842
662k
}
Unexecuted instantiation: cdef_copy_rect8_16bit_to_16bit_sse4_1
cdef_copy_rect8_16bit_to_16bit_avx2
Line
Count
Source
831
662k
                                               int width, int height) {
832
662k
  int i, j;
833
23.7M
  for (i = 0; i < height; i++) {
834
189M
    for (j = 0; j < (width & ~0x7); j += 8) {
835
166M
      v128 row = v128_load_unaligned(&src[i * sstride + j]);
836
166M
      v128_store_unaligned(&dst[i * dstride + j], row);
837
166M
    }
838
24.4M
    for (; j < width; j++) {
839
1.39M
      dst[i * dstride + j] = src[i * sstride + j];
840
1.39M
    }
841
23.0M
  }
842
662k
}
843
#endif  // CONFIG_AV1_HIGHBITDEPTH
844
845
#undef CDEF_INLINE
846
847
#endif  // AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_