Coverage Report

Created: 2025-12-31 06:49

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
19.5k
                                    v128 const2) {
28
19.5k
  v128 tmp;
29
  /* Reverse partial B. */
30
19.5k
  partialb = v128_shuffle_8(
31
19.5k
      partialb, v128_from_32(0x0f0e0100, 0x03020504, 0x07060908, 0x0b0a0d0c));
32
  /* Interleave the x and y values of identical indices and pair x8 with 0. */
33
19.5k
  tmp = partiala;
34
19.5k
  partiala = v128_ziplo_16(partialb, partiala);
35
19.5k
  partialb = v128_ziphi_16(partialb, tmp);
36
  /* Square and add the corresponding x and y values. */
37
19.5k
  partiala = v128_madd_s16(partiala, partiala);
38
19.5k
  partialb = v128_madd_s16(partialb, partialb);
39
  /* Multiply by constant. */
40
19.5k
  partiala = v128_mullo_s32(partiala, const1);
41
19.5k
  partialb = v128_mullo_s32(partialb, const2);
42
  /* Sum all results. */
43
19.5k
  partiala = v128_add_32(partiala, partialb);
44
19.5k
  return partiala;
45
19.5k
}
Unexecuted instantiation: cdef_block_sse4.c:fold_mul_and_sum
cdef_block_avx2.c:fold_mul_and_sum
Line
Count
Source
27
19.5k
                                    v128 const2) {
28
19.5k
  v128 tmp;
29
  /* Reverse partial B. */
30
19.5k
  partialb = v128_shuffle_8(
31
19.5k
      partialb, v128_from_32(0x0f0e0100, 0x03020504, 0x07060908, 0x0b0a0d0c));
32
  /* Interleave the x and y values of identical indices and pair x8 with 0. */
33
19.5k
  tmp = partiala;
34
19.5k
  partiala = v128_ziplo_16(partialb, partiala);
35
19.5k
  partialb = v128_ziphi_16(partialb, tmp);
36
  /* Square and add the corresponding x and y values. */
37
19.5k
  partiala = v128_madd_s16(partiala, partiala);
38
19.5k
  partialb = v128_madd_s16(partialb, partialb);
39
  /* Multiply by constant. */
40
19.5k
  partiala = v128_mullo_s32(partiala, const1);
41
19.5k
  partialb = v128_mullo_s32(partialb, const2);
42
  /* Sum all results. */
43
19.5k
  partiala = v128_add_32(partiala, partialb);
44
19.5k
  return partiala;
45
19.5k
}
46
47
6.53k
static inline v128 hsum4(v128 x0, v128 x1, v128 x2, v128 x3) {
48
6.53k
  v128 t0, t1, t2, t3;
49
6.53k
  t0 = v128_ziplo_32(x1, x0);
50
6.53k
  t1 = v128_ziplo_32(x3, x2);
51
6.53k
  t2 = v128_ziphi_32(x1, x0);
52
6.53k
  t3 = v128_ziphi_32(x3, x2);
53
6.53k
  x0 = v128_ziplo_64(t1, t0);
54
6.53k
  x1 = v128_ziphi_64(t1, t0);
55
6.53k
  x2 = v128_ziplo_64(t3, t2);
56
6.53k
  x3 = v128_ziphi_64(t3, t2);
57
6.53k
  return v128_add_32(v128_add_32(x0, x1), v128_add_32(x2, x3));
58
6.53k
}
Unexecuted instantiation: cdef_block_sse4.c:hsum4
cdef_block_avx2.c:hsum4
Line
Count
Source
47
6.53k
static inline v128 hsum4(v128 x0, v128 x1, v128 x2, v128 x3) {
48
6.53k
  v128 t0, t1, t2, t3;
49
6.53k
  t0 = v128_ziplo_32(x1, x0);
50
6.53k
  t1 = v128_ziplo_32(x3, x2);
51
6.53k
  t2 = v128_ziphi_32(x1, x0);
52
6.53k
  t3 = v128_ziphi_32(x3, x2);
53
6.53k
  x0 = v128_ziplo_64(t1, t0);
54
6.53k
  x1 = v128_ziphi_64(t1, t0);
55
6.53k
  x2 = v128_ziplo_64(t3, t2);
56
6.53k
  x3 = v128_ziphi_64(t3, t2);
57
6.53k
  return v128_add_32(v128_add_32(x0, x1), v128_add_32(x2, x3));
58
6.53k
}
59
60
/* Computes cost for directions 0, 5, 6 and 7. We can call this function again
61
   to compute the remaining directions. */
62
6.53k
static inline v128 compute_directions(v128 lines[8], int32_t tmp_cost1[4]) {
63
6.53k
  v128 partial4a, partial4b, partial5a, partial5b, partial7a, partial7b;
64
6.53k
  v128 partial6;
65
6.53k
  v128 tmp;
66
  /* Partial sums for lines 0 and 1. */
67
6.53k
  partial4a = v128_shl_n_byte(lines[0], 14);
68
6.53k
  partial4b = v128_shr_n_byte(lines[0], 2);
69
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[1], 12));
70
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[1], 4));
71
6.53k
  tmp = v128_add_16(lines[0], lines[1]);
72
6.53k
  partial5a = v128_shl_n_byte(tmp, 10);
73
6.53k
  partial5b = v128_shr_n_byte(tmp, 6);
74
6.53k
  partial7a = v128_shl_n_byte(tmp, 4);
75
6.53k
  partial7b = v128_shr_n_byte(tmp, 12);
76
6.53k
  partial6 = tmp;
77
78
  /* Partial sums for lines 2 and 3. */
79
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[2], 10));
80
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[2], 6));
81
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[3], 8));
82
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[3], 8));
83
6.53k
  tmp = v128_add_16(lines[2], lines[3]);
84
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 8));
85
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 8));
86
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 6));
87
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 10));
88
6.53k
  partial6 = v128_add_16(partial6, tmp);
89
90
  /* Partial sums for lines 4 and 5. */
91
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[4], 6));
92
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[4], 10));
93
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[5], 4));
94
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[5], 12));
95
6.53k
  tmp = v128_add_16(lines[4], lines[5]);
96
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 6));
97
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 10));
98
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 8));
99
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 8));
100
6.53k
  partial6 = v128_add_16(partial6, tmp);
101
102
  /* Partial sums for lines 6 and 7. */
103
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[6], 2));
104
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[6], 14));
105
6.53k
  partial4a = v128_add_16(partial4a, lines[7]);
106
6.53k
  tmp = v128_add_16(lines[6], lines[7]);
107
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 4));
108
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 12));
109
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 10));
110
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 6));
111
6.53k
  partial6 = v128_add_16(partial6, tmp);
112
113
  /* Compute costs in terms of partial sums. */
114
6.53k
  partial4a =
115
6.53k
      fold_mul_and_sum(partial4a, partial4b, v128_from_32(210, 280, 420, 840),
116
6.53k
                       v128_from_32(105, 120, 140, 168));
117
6.53k
  partial7a =
118
6.53k
      fold_mul_and_sum(partial7a, partial7b, v128_from_32(210, 420, 0, 0),
119
6.53k
                       v128_from_32(105, 105, 105, 140));
120
6.53k
  partial5a =
121
6.53k
      fold_mul_and_sum(partial5a, partial5b, v128_from_32(210, 420, 0, 0),
122
6.53k
                       v128_from_32(105, 105, 105, 140));
123
6.53k
  partial6 = v128_madd_s16(partial6, partial6);
124
6.53k
  partial6 = v128_mullo_s32(partial6, v128_dup_32(105));
125
126
6.53k
  partial4a = hsum4(partial4a, partial5a, partial6, partial7a);
127
6.53k
  v128_store_unaligned(tmp_cost1, partial4a);
128
6.53k
  return partial4a;
129
6.53k
}
Unexecuted instantiation: cdef_block_sse4.c:compute_directions
cdef_block_avx2.c:compute_directions
Line
Count
Source
62
6.53k
static inline v128 compute_directions(v128 lines[8], int32_t tmp_cost1[4]) {
63
6.53k
  v128 partial4a, partial4b, partial5a, partial5b, partial7a, partial7b;
64
6.53k
  v128 partial6;
65
6.53k
  v128 tmp;
66
  /* Partial sums for lines 0 and 1. */
67
6.53k
  partial4a = v128_shl_n_byte(lines[0], 14);
68
6.53k
  partial4b = v128_shr_n_byte(lines[0], 2);
69
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[1], 12));
70
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[1], 4));
71
6.53k
  tmp = v128_add_16(lines[0], lines[1]);
72
6.53k
  partial5a = v128_shl_n_byte(tmp, 10);
73
6.53k
  partial5b = v128_shr_n_byte(tmp, 6);
74
6.53k
  partial7a = v128_shl_n_byte(tmp, 4);
75
6.53k
  partial7b = v128_shr_n_byte(tmp, 12);
76
6.53k
  partial6 = tmp;
77
78
  /* Partial sums for lines 2 and 3. */
79
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[2], 10));
80
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[2], 6));
81
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[3], 8));
82
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[3], 8));
83
6.53k
  tmp = v128_add_16(lines[2], lines[3]);
84
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 8));
85
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 8));
86
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 6));
87
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 10));
88
6.53k
  partial6 = v128_add_16(partial6, tmp);
89
90
  /* Partial sums for lines 4 and 5. */
91
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[4], 6));
92
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[4], 10));
93
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[5], 4));
94
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[5], 12));
95
6.53k
  tmp = v128_add_16(lines[4], lines[5]);
96
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 6));
97
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 10));
98
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 8));
99
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 8));
100
6.53k
  partial6 = v128_add_16(partial6, tmp);
101
102
  /* Partial sums for lines 6 and 7. */
103
6.53k
  partial4a = v128_add_16(partial4a, v128_shl_n_byte(lines[6], 2));
104
6.53k
  partial4b = v128_add_16(partial4b, v128_shr_n_byte(lines[6], 14));
105
6.53k
  partial4a = v128_add_16(partial4a, lines[7]);
106
6.53k
  tmp = v128_add_16(lines[6], lines[7]);
107
6.53k
  partial5a = v128_add_16(partial5a, v128_shl_n_byte(tmp, 4));
108
6.53k
  partial5b = v128_add_16(partial5b, v128_shr_n_byte(tmp, 12));
109
6.53k
  partial7a = v128_add_16(partial7a, v128_shl_n_byte(tmp, 10));
110
6.53k
  partial7b = v128_add_16(partial7b, v128_shr_n_byte(tmp, 6));
111
6.53k
  partial6 = v128_add_16(partial6, tmp);
112
113
  /* Compute costs in terms of partial sums. */
114
6.53k
  partial4a =
115
6.53k
      fold_mul_and_sum(partial4a, partial4b, v128_from_32(210, 280, 420, 840),
116
6.53k
                       v128_from_32(105, 120, 140, 168));
117
6.53k
  partial7a =
118
6.53k
      fold_mul_and_sum(partial7a, partial7b, v128_from_32(210, 420, 0, 0),
119
6.53k
                       v128_from_32(105, 105, 105, 140));
120
6.53k
  partial5a =
121
6.53k
      fold_mul_and_sum(partial5a, partial5b, v128_from_32(210, 420, 0, 0),
122
6.53k
                       v128_from_32(105, 105, 105, 140));
123
6.53k
  partial6 = v128_madd_s16(partial6, partial6);
124
6.53k
  partial6 = v128_mullo_s32(partial6, v128_dup_32(105));
125
126
6.53k
  partial4a = hsum4(partial4a, partial5a, partial6, partial7a);
127
6.53k
  v128_store_unaligned(tmp_cost1, partial4a);
128
6.53k
  return partial4a;
129
6.53k
}
130
131
/* transpose and reverse the order of the lines -- equivalent to a 90-degree
132
   counter-clockwise rotation of the pixels. */
133
3.26k
static inline void array_reverse_transpose_8x8(v128 *in, v128 *res) {
134
3.26k
  const v128 tr0_0 = v128_ziplo_16(in[1], in[0]);
135
3.26k
  const v128 tr0_1 = v128_ziplo_16(in[3], in[2]);
136
3.26k
  const v128 tr0_2 = v128_ziphi_16(in[1], in[0]);
137
3.26k
  const v128 tr0_3 = v128_ziphi_16(in[3], in[2]);
138
3.26k
  const v128 tr0_4 = v128_ziplo_16(in[5], in[4]);
139
3.26k
  const v128 tr0_5 = v128_ziplo_16(in[7], in[6]);
140
3.26k
  const v128 tr0_6 = v128_ziphi_16(in[5], in[4]);
141
3.26k
  const v128 tr0_7 = v128_ziphi_16(in[7], in[6]);
142
143
3.26k
  const v128 tr1_0 = v128_ziplo_32(tr0_1, tr0_0);
144
3.26k
  const v128 tr1_1 = v128_ziplo_32(tr0_5, tr0_4);
145
3.26k
  const v128 tr1_2 = v128_ziphi_32(tr0_1, tr0_0);
146
3.26k
  const v128 tr1_3 = v128_ziphi_32(tr0_5, tr0_4);
147
3.26k
  const v128 tr1_4 = v128_ziplo_32(tr0_3, tr0_2);
148
3.26k
  const v128 tr1_5 = v128_ziplo_32(tr0_7, tr0_6);
149
3.26k
  const v128 tr1_6 = v128_ziphi_32(tr0_3, tr0_2);
150
3.26k
  const v128 tr1_7 = v128_ziphi_32(tr0_7, tr0_6);
151
152
3.26k
  res[7] = v128_ziplo_64(tr1_1, tr1_0);
153
3.26k
  res[6] = v128_ziphi_64(tr1_1, tr1_0);
154
3.26k
  res[5] = v128_ziplo_64(tr1_3, tr1_2);
155
3.26k
  res[4] = v128_ziphi_64(tr1_3, tr1_2);
156
3.26k
  res[3] = v128_ziplo_64(tr1_5, tr1_4);
157
3.26k
  res[2] = v128_ziphi_64(tr1_5, tr1_4);
158
3.26k
  res[1] = v128_ziplo_64(tr1_7, tr1_6);
159
3.26k
  res[0] = v128_ziphi_64(tr1_7, tr1_6);
160
3.26k
}
Unexecuted instantiation: cdef_block_sse4.c:array_reverse_transpose_8x8
cdef_block_avx2.c:array_reverse_transpose_8x8
Line
Count
Source
133
3.26k
static inline void array_reverse_transpose_8x8(v128 *in, v128 *res) {
134
3.26k
  const v128 tr0_0 = v128_ziplo_16(in[1], in[0]);
135
3.26k
  const v128 tr0_1 = v128_ziplo_16(in[3], in[2]);
136
3.26k
  const v128 tr0_2 = v128_ziphi_16(in[1], in[0]);
137
3.26k
  const v128 tr0_3 = v128_ziphi_16(in[3], in[2]);
138
3.26k
  const v128 tr0_4 = v128_ziplo_16(in[5], in[4]);
139
3.26k
  const v128 tr0_5 = v128_ziplo_16(in[7], in[6]);
140
3.26k
  const v128 tr0_6 = v128_ziphi_16(in[5], in[4]);
141
3.26k
  const v128 tr0_7 = v128_ziphi_16(in[7], in[6]);
142
143
3.26k
  const v128 tr1_0 = v128_ziplo_32(tr0_1, tr0_0);
144
3.26k
  const v128 tr1_1 = v128_ziplo_32(tr0_5, tr0_4);
145
3.26k
  const v128 tr1_2 = v128_ziphi_32(tr0_1, tr0_0);
146
3.26k
  const v128 tr1_3 = v128_ziphi_32(tr0_5, tr0_4);
147
3.26k
  const v128 tr1_4 = v128_ziplo_32(tr0_3, tr0_2);
148
3.26k
  const v128 tr1_5 = v128_ziplo_32(tr0_7, tr0_6);
149
3.26k
  const v128 tr1_6 = v128_ziphi_32(tr0_3, tr0_2);
150
3.26k
  const v128 tr1_7 = v128_ziphi_32(tr0_7, tr0_6);
151
152
3.26k
  res[7] = v128_ziplo_64(tr1_1, tr1_0);
153
3.26k
  res[6] = v128_ziphi_64(tr1_1, tr1_0);
154
3.26k
  res[5] = v128_ziplo_64(tr1_3, tr1_2);
155
3.26k
  res[4] = v128_ziphi_64(tr1_3, tr1_2);
156
3.26k
  res[3] = v128_ziplo_64(tr1_5, tr1_4);
157
3.26k
  res[2] = v128_ziphi_64(tr1_5, tr1_4);
158
3.26k
  res[1] = v128_ziplo_64(tr1_7, tr1_6);
159
3.26k
  res[0] = v128_ziphi_64(tr1_7, tr1_6);
160
3.26k
}
161
162
int SIMD_FUNC(cdef_find_dir)(const uint16_t *img, int stride, int32_t *var,
163
3.26k
                             int coeff_shift) {
164
3.26k
  int i;
165
3.26k
  int32_t cost[8];
166
3.26k
  int32_t best_cost = 0;
167
3.26k
  int best_dir = 0;
168
3.26k
  v128 lines[8];
169
29.3k
  for (i = 0; i < 8; i++) {
170
26.1k
    lines[i] = v128_load_unaligned(&img[i * stride]);
171
26.1k
    lines[i] =
172
26.1k
        v128_sub_16(v128_shr_s16(lines[i], coeff_shift), v128_dup_16(128));
173
26.1k
  }
174
175
  /* Compute "mostly vertical" directions. */
176
3.26k
  v128 dir47 = compute_directions(lines, cost + 4);
177
178
3.26k
  array_reverse_transpose_8x8(lines, lines);
179
180
  /* Compute "mostly horizontal" directions. */
181
3.26k
  v128 dir03 = compute_directions(lines, cost);
182
183
3.26k
  v128 max = v128_max_s32(dir03, dir47);
184
3.26k
  max = v128_max_s32(max, v128_align(max, max, 8));
185
3.26k
  max = v128_max_s32(max, v128_align(max, max, 4));
186
3.26k
  best_cost = v128_low_u32(max);
187
3.26k
  v128 t =
188
3.26k
      v128_pack_s32_s16(v128_cmpeq_32(max, dir47), v128_cmpeq_32(max, dir03));
189
3.26k
  best_dir = v128_movemask_8(v128_pack_s16_s8(t, t));
190
3.26k
  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
3.26k
  *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
3.26k
  *var >>= 10;
198
3.26k
  return best_dir;
199
3.26k
}
Unexecuted instantiation: cdef_find_dir_sse4_1
cdef_find_dir_avx2
Line
Count
Source
163
3.26k
                             int coeff_shift) {
164
3.26k
  int i;
165
3.26k
  int32_t cost[8];
166
3.26k
  int32_t best_cost = 0;
167
3.26k
  int best_dir = 0;
168
3.26k
  v128 lines[8];
169
29.3k
  for (i = 0; i < 8; i++) {
170
26.1k
    lines[i] = v128_load_unaligned(&img[i * stride]);
171
26.1k
    lines[i] =
172
26.1k
        v128_sub_16(v128_shr_s16(lines[i], coeff_shift), v128_dup_16(128));
173
26.1k
  }
174
175
  /* Compute "mostly vertical" directions. */
176
3.26k
  v128 dir47 = compute_directions(lines, cost + 4);
177
178
3.26k
  array_reverse_transpose_8x8(lines, lines);
179
180
  /* Compute "mostly horizontal" directions. */
181
3.26k
  v128 dir03 = compute_directions(lines, cost);
182
183
3.26k
  v128 max = v128_max_s32(dir03, dir47);
184
3.26k
  max = v128_max_s32(max, v128_align(max, max, 8));
185
3.26k
  max = v128_max_s32(max, v128_align(max, max, 4));
186
3.26k
  best_cost = v128_low_u32(max);
187
3.26k
  v128 t =
188
3.26k
      v128_pack_s32_s16(v128_cmpeq_32(max, dir47), v128_cmpeq_32(max, dir03));
189
3.26k
  best_dir = v128_movemask_8(v128_pack_s16_s8(t, t));
190
3.26k
  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
3.26k
  *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
3.26k
  *var >>= 10;
198
3.26k
  return best_dir;
199
3.26k
}
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
144M
                             unsigned int adjdamp) {
212
144M
  v256 diff = v256_sub_16(a, b);
213
144M
  const v256 sign = v256_shr_n_s16(diff, 15);
214
144M
  diff = v256_abs_s16(diff);
215
144M
  const v256 s =
216
144M
      v256_ssub_u16(v256_dup_16(threshold), v256_shr_u16(diff, adjdamp));
217
144M
  return v256_xor(v256_add_16(sign, v256_min_s16(diff, s)), sign);
218
144M
}
Unexecuted instantiation: cdef_block_sse4.c:constrain16
cdef_block_avx2.c:constrain16
Line
Count
Source
211
144M
                             unsigned int adjdamp) {
212
144M
  v256 diff = v256_sub_16(a, b);
213
144M
  const v256 sign = v256_shr_n_s16(diff, 15);
214
144M
  diff = v256_abs_s16(diff);
215
144M
  const v256 s =
216
144M
      v256_ssub_u16(v256_dup_16(threshold), v256_shr_u16(diff, adjdamp));
217
144M
  return v256_xor(v256_add_16(sign, v256_min_s16(diff, s)), sign);
218
144M
}
219
220
SIMD_INLINE v256 get_max_primary(const int is_lowbd, v256 *tap, v256 max,
221
19.0M
                                 v256 cdef_large_value_mask) {
222
19.0M
  if (is_lowbd) {
223
6.77M
    v256 max_u8;
224
6.77M
    max_u8 = tap[0];
225
6.77M
    max_u8 = v256_max_u8(max_u8, tap[1]);
226
6.77M
    max_u8 = v256_max_u8(max_u8, tap[2]);
227
6.77M
    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
6.77M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
233
12.2M
  } else {
234
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
235
12.2M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
236
12.2M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
237
12.2M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
238
12.2M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
239
12.2M
  }
240
19.0M
  return max;
241
19.0M
}
Unexecuted instantiation: cdef_block_sse4.c:get_max_primary
cdef_block_avx2.c:get_max_primary
Line
Count
Source
221
19.0M
                                 v256 cdef_large_value_mask) {
222
19.0M
  if (is_lowbd) {
223
6.77M
    v256 max_u8;
224
6.77M
    max_u8 = tap[0];
225
6.77M
    max_u8 = v256_max_u8(max_u8, tap[1]);
226
6.77M
    max_u8 = v256_max_u8(max_u8, tap[2]);
227
6.77M
    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
6.77M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
233
12.2M
  } else {
234
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
235
12.2M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
236
12.2M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
237
12.2M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
238
12.2M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
239
12.2M
  }
240
19.0M
  return max;
241
19.0M
}
242
243
SIMD_INLINE v256 get_max_secondary(const int is_lowbd, v256 *tap, v256 max,
244
19.3M
                                   v256 cdef_large_value_mask) {
245
19.3M
  if (is_lowbd) {
246
7.22M
    v256 max_u8;
247
7.22M
    max_u8 = tap[0];
248
7.22M
    max_u8 = v256_max_u8(max_u8, tap[1]);
249
7.22M
    max_u8 = v256_max_u8(max_u8, tap[2]);
250
7.22M
    max_u8 = v256_max_u8(max_u8, tap[3]);
251
7.22M
    max_u8 = v256_max_u8(max_u8, tap[4]);
252
7.22M
    max_u8 = v256_max_u8(max_u8, tap[5]);
253
7.22M
    max_u8 = v256_max_u8(max_u8, tap[6]);
254
7.22M
    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
7.22M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
260
12.1M
  } else {
261
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
262
12.1M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
263
12.1M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
264
12.1M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
265
12.1M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
266
12.1M
    max = v256_max_s16(max, v256_and(tap[4], cdef_large_value_mask));
267
12.1M
    max = v256_max_s16(max, v256_and(tap[5], cdef_large_value_mask));
268
12.1M
    max = v256_max_s16(max, v256_and(tap[6], cdef_large_value_mask));
269
12.1M
    max = v256_max_s16(max, v256_and(tap[7], cdef_large_value_mask));
270
12.1M
  }
271
19.3M
  return max;
272
19.3M
}
Unexecuted instantiation: cdef_block_sse4.c:get_max_secondary
cdef_block_avx2.c:get_max_secondary
Line
Count
Source
244
19.3M
                                   v256 cdef_large_value_mask) {
245
19.3M
  if (is_lowbd) {
246
7.22M
    v256 max_u8;
247
7.22M
    max_u8 = tap[0];
248
7.22M
    max_u8 = v256_max_u8(max_u8, tap[1]);
249
7.22M
    max_u8 = v256_max_u8(max_u8, tap[2]);
250
7.22M
    max_u8 = v256_max_u8(max_u8, tap[3]);
251
7.22M
    max_u8 = v256_max_u8(max_u8, tap[4]);
252
7.22M
    max_u8 = v256_max_u8(max_u8, tap[5]);
253
7.22M
    max_u8 = v256_max_u8(max_u8, tap[6]);
254
7.22M
    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
7.22M
    max = v256_max_s16(max, v256_and(max_u8, cdef_large_value_mask));
260
12.1M
  } else {
261
    /* Convert CDEF_VERY_LARGE to 0 before calculating max. */
262
12.1M
    max = v256_max_s16(max, v256_and(tap[0], cdef_large_value_mask));
263
12.1M
    max = v256_max_s16(max, v256_and(tap[1], cdef_large_value_mask));
264
12.1M
    max = v256_max_s16(max, v256_and(tap[2], cdef_large_value_mask));
265
12.1M
    max = v256_max_s16(max, v256_and(tap[3], cdef_large_value_mask));
266
12.1M
    max = v256_max_s16(max, v256_and(tap[4], cdef_large_value_mask));
267
12.1M
    max = v256_max_s16(max, v256_and(tap[5], cdef_large_value_mask));
268
12.1M
    max = v256_max_s16(max, v256_and(tap[6], cdef_large_value_mask));
269
12.1M
    max = v256_max_s16(max, v256_and(tap[7], cdef_large_value_mask));
270
12.1M
  }
271
19.3M
  return max;
272
19.3M
}
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
18.6M
                                  int enable_primary, int enable_secondary) {
285
18.6M
  uint8_t *dst8 = (uint8_t *)dest;
286
18.6M
  uint16_t *dst16 = (uint16_t *)dest;
287
18.6M
  const int clipping_required = enable_primary && enable_secondary;
288
18.6M
  v256 p0, p1, p2, p3;
289
18.6M
  v256 sum, row, res;
290
18.6M
  v256 max, min;
291
18.6M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
292
18.6M
  const int po1 = cdef_directions[dir][0];
293
18.6M
  const int po2 = cdef_directions[dir][1];
294
18.6M
  const int s1o1 = cdef_directions[dir + 2][0];
295
18.6M
  const int s1o2 = cdef_directions[dir + 2][1];
296
18.6M
  const int s2o1 = cdef_directions[dir - 2][0];
297
18.6M
  const int s2o2 = cdef_directions[dir - 2][1];
298
18.6M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
299
18.6M
  const int *sec_taps = cdef_sec_taps;
300
18.6M
  int i;
301
302
18.6M
  if (enable_primary && pri_strength)
303
18.7M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
304
18.8M
  if (enable_secondary && sec_strength)
305
19.1M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
306
307
49.9M
  for (i = 0; i < height; i += 4) {
308
31.2M
    sum = v256_zero();
309
31.2M
    row = v256_from_v64(v64_load_aligned(&in[(i + 0) * CDEF_BSTRIDE]),
310
31.2M
                        v64_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]),
311
31.2M
                        v64_load_aligned(&in[(i + 2) * CDEF_BSTRIDE]),
312
31.2M
                        v64_load_aligned(&in[(i + 3) * CDEF_BSTRIDE]));
313
31.2M
    max = min = row;
314
315
31.2M
    if (enable_primary) {
316
29.2M
      v256 tap[4];
317
      // Primary near taps
318
29.2M
      tap[0] =
319
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po1]),
320
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]),
321
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po1]),
322
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po1]));
323
29.2M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
324
29.2M
      tap[1] =
325
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po1]),
326
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]),
327
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po1]),
328
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po1]));
329
29.2M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
330
331
      // sum += pri_taps[0] * (p0 + p1)
332
29.2M
      sum = v256_add_16(
333
29.2M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
334
335
      // Primary far taps
336
29.2M
      tap[2] =
337
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po2]),
338
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]),
339
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po2]),
340
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po2]));
341
29.2M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
342
29.2M
      tap[3] =
343
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po2]),
344
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]),
345
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po2]),
346
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po2]));
347
29.2M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
348
349
      // sum += pri_taps[1] * (p0 + p1)
350
29.2M
      sum = v256_add_16(
351
29.2M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
352
29.2M
      if (clipping_required) {
353
14.2M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
354
355
14.2M
        min = v256_min_s16(min, tap[0]);
356
14.2M
        min = v256_min_s16(min, tap[1]);
357
14.2M
        min = v256_min_s16(min, tap[2]);
358
14.2M
        min = v256_min_s16(min, tap[3]);
359
14.2M
      }
360
29.2M
    }
361
362
31.2M
    if (enable_secondary) {
363
14.4M
      v256 tap[8];
364
      // Secondary near taps
365
14.4M
      tap[0] =
366
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o1]),
367
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]),
368
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o1]),
369
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o1]));
370
14.4M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
371
14.4M
      tap[1] =
372
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o1]),
373
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]),
374
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o1]),
375
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o1]));
376
14.4M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
377
14.4M
      tap[2] =
378
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o1]),
379
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]),
380
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o1]),
381
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o1]));
382
14.4M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
383
14.4M
      tap[3] =
384
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o1]),
385
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]),
386
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o1]),
387
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o1]));
388
14.4M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
389
390
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
391
14.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
392
14.4M
                                            v256_add_16(v256_add_16(p0, p1),
393
14.4M
                                                        v256_add_16(p2, p3))));
394
395
      // Secondary far taps
396
14.4M
      tap[4] =
397
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o2]),
398
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]),
399
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o2]),
400
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o2]));
401
14.4M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
402
14.4M
      tap[5] =
403
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o2]),
404
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]),
405
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o2]),
406
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o2]));
407
14.4M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
408
14.4M
      tap[6] =
409
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o2]),
410
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]),
411
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o2]),
412
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o2]));
413
14.4M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
414
14.4M
      tap[7] =
415
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o2]),
416
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]),
417
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o2]),
418
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o2]));
419
14.4M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
420
421
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
422
14.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
423
14.4M
                                            v256_add_16(v256_add_16(p0, p1),
424
14.4M
                                                        v256_add_16(p2, p3))));
425
426
14.4M
      if (clipping_required) {
427
14.4M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
428
429
14.4M
        min = v256_min_s16(min, tap[0]);
430
14.4M
        min = v256_min_s16(min, tap[1]);
431
14.4M
        min = v256_min_s16(min, tap[2]);
432
14.4M
        min = v256_min_s16(min, tap[3]);
433
14.4M
        min = v256_min_s16(min, tap[4]);
434
14.4M
        min = v256_min_s16(min, tap[5]);
435
14.4M
        min = v256_min_s16(min, tap[6]);
436
14.4M
        min = v256_min_s16(min, tap[7]);
437
14.4M
      }
438
14.4M
    }
439
440
    // res = row + ((sum - (sum < 0) + 8) >> 4)
441
31.2M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
442
31.2M
    res = v256_add_16(sum, v256_dup_16(8));
443
31.2M
    res = v256_shr_n_s16(res, 4);
444
31.2M
    res = v256_add_16(row, res);
445
31.2M
    if (clipping_required) {
446
14.4M
      res = v256_min_s16(v256_max_s16(res, min), max);
447
14.4M
    }
448
449
31.2M
    if (is_lowbd) {
450
5.91M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
451
5.91M
      u32_store_aligned(&dst8[(i + 0) * dstride],
452
5.91M
                        v64_high_u32(v128_high_v64(res_128)));
453
5.91M
      u32_store_aligned(&dst8[(i + 1) * dstride],
454
5.91M
                        v64_low_u32(v128_high_v64(res_128)));
455
5.91M
      u32_store_aligned(&dst8[(i + 2) * dstride],
456
5.91M
                        v64_high_u32(v128_low_v64(res_128)));
457
5.91M
      u32_store_aligned(&dst8[(i + 3) * dstride],
458
5.91M
                        v64_low_u32(v128_low_v64(res_128)));
459
25.3M
    } else {
460
25.3M
      v64_store_aligned(&dst16[(i + 0) * dstride],
461
25.3M
                        v128_high_v64(v256_high_v128(res)));
462
25.3M
      v64_store_aligned(&dst16[(i + 1) * dstride],
463
25.3M
                        v128_low_v64(v256_high_v128(res)));
464
25.3M
      v64_store_aligned(&dst16[(i + 2) * dstride],
465
25.3M
                        v128_high_v64(v256_low_v128(res)));
466
25.3M
      v64_store_aligned(&dst16[(i + 3) * dstride],
467
25.3M
                        v128_low_v64(v256_low_v128(res)));
468
25.3M
    }
469
31.2M
  }
470
18.6M
}
Unexecuted instantiation: cdef_block_sse4.c:filter_block_4x4
cdef_block_avx2.c:filter_block_4x4
Line
Count
Source
284
18.6M
                                  int enable_primary, int enable_secondary) {
285
18.6M
  uint8_t *dst8 = (uint8_t *)dest;
286
18.6M
  uint16_t *dst16 = (uint16_t *)dest;
287
18.6M
  const int clipping_required = enable_primary && enable_secondary;
288
18.6M
  v256 p0, p1, p2, p3;
289
18.6M
  v256 sum, row, res;
290
18.6M
  v256 max, min;
291
18.6M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
292
18.6M
  const int po1 = cdef_directions[dir][0];
293
18.6M
  const int po2 = cdef_directions[dir][1];
294
18.6M
  const int s1o1 = cdef_directions[dir + 2][0];
295
18.6M
  const int s1o2 = cdef_directions[dir + 2][1];
296
18.6M
  const int s2o1 = cdef_directions[dir - 2][0];
297
18.6M
  const int s2o2 = cdef_directions[dir - 2][1];
298
18.6M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
299
18.6M
  const int *sec_taps = cdef_sec_taps;
300
18.6M
  int i;
301
302
18.6M
  if (enable_primary && pri_strength)
303
18.7M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
304
18.8M
  if (enable_secondary && sec_strength)
305
19.1M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
306
307
49.9M
  for (i = 0; i < height; i += 4) {
308
31.2M
    sum = v256_zero();
309
31.2M
    row = v256_from_v64(v64_load_aligned(&in[(i + 0) * CDEF_BSTRIDE]),
310
31.2M
                        v64_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]),
311
31.2M
                        v64_load_aligned(&in[(i + 2) * CDEF_BSTRIDE]),
312
31.2M
                        v64_load_aligned(&in[(i + 3) * CDEF_BSTRIDE]));
313
31.2M
    max = min = row;
314
315
31.2M
    if (enable_primary) {
316
29.2M
      v256 tap[4];
317
      // Primary near taps
318
29.2M
      tap[0] =
319
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po1]),
320
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]),
321
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po1]),
322
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po1]));
323
29.2M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
324
29.2M
      tap[1] =
325
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po1]),
326
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]),
327
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po1]),
328
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po1]));
329
29.2M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
330
331
      // sum += pri_taps[0] * (p0 + p1)
332
29.2M
      sum = v256_add_16(
333
29.2M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
334
335
      // Primary far taps
336
29.2M
      tap[2] =
337
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + po2]),
338
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]),
339
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + po2]),
340
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + po2]));
341
29.2M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
342
29.2M
      tap[3] =
343
29.2M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - po2]),
344
29.2M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]),
345
29.2M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - po2]),
346
29.2M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - po2]));
347
29.2M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
348
349
      // sum += pri_taps[1] * (p0 + p1)
350
29.2M
      sum = v256_add_16(
351
29.2M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
352
29.2M
      if (clipping_required) {
353
14.2M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
354
355
14.2M
        min = v256_min_s16(min, tap[0]);
356
14.2M
        min = v256_min_s16(min, tap[1]);
357
14.2M
        min = v256_min_s16(min, tap[2]);
358
14.2M
        min = v256_min_s16(min, tap[3]);
359
14.2M
      }
360
29.2M
    }
361
362
31.2M
    if (enable_secondary) {
363
14.4M
      v256 tap[8];
364
      // Secondary near taps
365
14.4M
      tap[0] =
366
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o1]),
367
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]),
368
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o1]),
369
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o1]));
370
14.4M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
371
14.4M
      tap[1] =
372
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o1]),
373
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]),
374
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o1]),
375
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o1]));
376
14.4M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
377
14.4M
      tap[2] =
378
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o1]),
379
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]),
380
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o1]),
381
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o1]));
382
14.4M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
383
14.4M
      tap[3] =
384
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o1]),
385
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]),
386
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o1]),
387
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o1]));
388
14.4M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
389
390
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
391
14.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
392
14.4M
                                            v256_add_16(v256_add_16(p0, p1),
393
14.4M
                                                        v256_add_16(p2, p3))));
394
395
      // Secondary far taps
396
14.4M
      tap[4] =
397
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s1o2]),
398
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]),
399
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s1o2]),
400
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s1o2]));
401
14.4M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
402
14.4M
      tap[5] =
403
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s1o2]),
404
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]),
405
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s1o2]),
406
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s1o2]));
407
14.4M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
408
14.4M
      tap[6] =
409
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE + s2o2]),
410
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]),
411
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE + s2o2]),
412
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE + s2o2]));
413
14.4M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
414
14.4M
      tap[7] =
415
14.4M
          v256_from_v64(v64_load_unaligned(&in[(i + 0) * CDEF_BSTRIDE - s2o2]),
416
14.4M
                        v64_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]),
417
14.4M
                        v64_load_unaligned(&in[(i + 2) * CDEF_BSTRIDE - s2o2]),
418
14.4M
                        v64_load_unaligned(&in[(i + 3) * CDEF_BSTRIDE - s2o2]));
419
14.4M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
420
421
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
422
14.4M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
423
14.4M
                                            v256_add_16(v256_add_16(p0, p1),
424
14.4M
                                                        v256_add_16(p2, p3))));
425
426
14.4M
      if (clipping_required) {
427
14.4M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
428
429
14.4M
        min = v256_min_s16(min, tap[0]);
430
14.4M
        min = v256_min_s16(min, tap[1]);
431
14.4M
        min = v256_min_s16(min, tap[2]);
432
14.4M
        min = v256_min_s16(min, tap[3]);
433
14.4M
        min = v256_min_s16(min, tap[4]);
434
14.4M
        min = v256_min_s16(min, tap[5]);
435
14.4M
        min = v256_min_s16(min, tap[6]);
436
14.4M
        min = v256_min_s16(min, tap[7]);
437
14.4M
      }
438
14.4M
    }
439
440
    // res = row + ((sum - (sum < 0) + 8) >> 4)
441
31.2M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
442
31.2M
    res = v256_add_16(sum, v256_dup_16(8));
443
31.2M
    res = v256_shr_n_s16(res, 4);
444
31.2M
    res = v256_add_16(row, res);
445
31.2M
    if (clipping_required) {
446
14.4M
      res = v256_min_s16(v256_max_s16(res, min), max);
447
14.4M
    }
448
449
31.2M
    if (is_lowbd) {
450
5.91M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
451
5.91M
      u32_store_aligned(&dst8[(i + 0) * dstride],
452
5.91M
                        v64_high_u32(v128_high_v64(res_128)));
453
5.91M
      u32_store_aligned(&dst8[(i + 1) * dstride],
454
5.91M
                        v64_low_u32(v128_high_v64(res_128)));
455
5.91M
      u32_store_aligned(&dst8[(i + 2) * dstride],
456
5.91M
                        v64_high_u32(v128_low_v64(res_128)));
457
5.91M
      u32_store_aligned(&dst8[(i + 3) * dstride],
458
5.91M
                        v64_low_u32(v128_low_v64(res_128)));
459
25.3M
    } else {
460
25.3M
      v64_store_aligned(&dst16[(i + 0) * dstride],
461
25.3M
                        v128_high_v64(v256_high_v128(res)));
462
25.3M
      v64_store_aligned(&dst16[(i + 1) * dstride],
463
25.3M
                        v128_low_v64(v256_high_v128(res)));
464
25.3M
      v64_store_aligned(&dst16[(i + 2) * dstride],
465
25.3M
                        v128_high_v64(v256_low_v128(res)));
466
25.3M
      v64_store_aligned(&dst16[(i + 3) * dstride],
467
25.3M
                        v128_low_v64(v256_low_v128(res)));
468
25.3M
    }
469
31.2M
  }
470
18.6M
}
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
11.0M
                                  int enable_primary, int enable_secondary) {
477
11.0M
  uint8_t *dst8 = (uint8_t *)dest;
478
11.0M
  uint16_t *dst16 = (uint16_t *)dest;
479
11.0M
  const int clipping_required = enable_primary && enable_secondary;
480
11.0M
  int i;
481
11.0M
  v256 sum, p0, p1, p2, p3, row, res;
482
11.0M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
483
11.0M
  v256 max, min;
484
11.0M
  const int po1 = cdef_directions[dir][0];
485
11.0M
  const int po2 = cdef_directions[dir][1];
486
11.0M
  const int s1o1 = cdef_directions[dir + 2][0];
487
11.0M
  const int s1o2 = cdef_directions[dir + 2][1];
488
11.0M
  const int s2o1 = cdef_directions[dir - 2][0];
489
11.0M
  const int s2o2 = cdef_directions[dir - 2][1];
490
11.0M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
491
11.0M
  const int *sec_taps = cdef_sec_taps;
492
493
11.0M
  if (enable_primary && pri_strength)
494
8.36M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
495
11.0M
  if (enable_secondary && sec_strength)
496
9.43M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
497
498
39.1M
  for (i = 0; i < height; i += 2) {
499
28.0M
    v256 tap[8];
500
28.0M
    sum = v256_zero();
501
28.0M
    row = v256_from_v128(v128_load_aligned(&in[i * CDEF_BSTRIDE]),
502
28.0M
                         v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]));
503
504
28.0M
    min = max = row;
505
28.0M
    if (enable_primary) {
506
      // Primary near taps
507
20.5M
      tap[0] = v256_from_v128(
508
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po1]),
509
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]));
510
20.5M
      tap[1] = v256_from_v128(
511
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po1]),
512
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]));
513
20.5M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
514
20.5M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
515
516
      // sum += pri_taps[0] * (p0 + p1)
517
20.5M
      sum = v256_add_16(
518
20.5M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
519
520
      // Primary far taps
521
20.5M
      tap[2] = v256_from_v128(
522
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po2]),
523
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]));
524
20.5M
      tap[3] = v256_from_v128(
525
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po2]),
526
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]));
527
20.5M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
528
20.5M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
529
530
      // sum += pri_taps[1] * (p0 + p1)
531
20.5M
      sum = v256_add_16(
532
20.5M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
533
534
20.5M
      if (clipping_required) {
535
14.8M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
536
537
14.8M
        min = v256_min_s16(min, tap[0]);
538
14.8M
        min = v256_min_s16(min, tap[1]);
539
14.8M
        min = v256_min_s16(min, tap[2]);
540
14.8M
        min = v256_min_s16(min, tap[3]);
541
14.8M
      }
542
      // End primary
543
20.5M
    }
544
545
28.0M
    if (enable_secondary) {
546
      // Secondary near taps
547
22.7M
      tap[0] = v256_from_v128(
548
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o1]),
549
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]));
550
22.7M
      tap[1] = v256_from_v128(
551
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o1]),
552
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]));
553
22.7M
      tap[2] = v256_from_v128(
554
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o1]),
555
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]));
556
22.7M
      tap[3] = v256_from_v128(
557
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o1]),
558
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]));
559
22.7M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
560
22.7M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
561
22.7M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
562
22.7M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
563
564
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
565
22.7M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
566
22.7M
                                            v256_add_16(v256_add_16(p0, p1),
567
22.7M
                                                        v256_add_16(p2, p3))));
568
569
      // Secondary far taps
570
22.7M
      tap[4] = v256_from_v128(
571
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o2]),
572
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]));
573
22.7M
      tap[5] = v256_from_v128(
574
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o2]),
575
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]));
576
22.7M
      tap[6] = v256_from_v128(
577
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o2]),
578
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]));
579
22.7M
      tap[7] = v256_from_v128(
580
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o2]),
581
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]));
582
22.7M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
583
22.7M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
584
22.7M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
585
22.7M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
586
587
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
588
22.7M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
589
22.7M
                                            v256_add_16(v256_add_16(p0, p1),
590
22.7M
                                                        v256_add_16(p2, p3))));
591
592
22.7M
      if (clipping_required) {
593
14.6M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
594
595
14.6M
        min = v256_min_s16(min, tap[0]);
596
14.6M
        min = v256_min_s16(min, tap[1]);
597
14.6M
        min = v256_min_s16(min, tap[2]);
598
14.6M
        min = v256_min_s16(min, tap[3]);
599
14.6M
        min = v256_min_s16(min, tap[4]);
600
14.6M
        min = v256_min_s16(min, tap[5]);
601
14.6M
        min = v256_min_s16(min, tap[6]);
602
14.6M
        min = v256_min_s16(min, tap[7]);
603
14.6M
      }
604
      // End secondary
605
22.7M
    }
606
607
    // res = row + ((sum - (sum < 0) + 8) >> 4)
608
28.0M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
609
28.0M
    res = v256_add_16(sum, v256_dup_16(8));
610
28.0M
    res = v256_shr_n_s16(res, 4);
611
28.0M
    res = v256_add_16(row, res);
612
28.0M
    if (clipping_required) {
613
14.6M
      res = v256_min_s16(v256_max_s16(res, min), max);
614
14.6M
    }
615
616
28.0M
    if (is_lowbd) {
617
9.55M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
618
9.55M
      v64_store_aligned(&dst8[i * dstride], v128_high_v64(res_128));
619
9.55M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_low_v64(res_128));
620
18.4M
    } else {
621
18.4M
      v128_store_unaligned(&dst16[i * dstride], v256_high_v128(res));
622
18.4M
      v128_store_unaligned(&dst16[(i + 1) * dstride], v256_low_v128(res));
623
18.4M
    }
624
28.0M
  }
625
11.0M
}
Unexecuted instantiation: cdef_block_sse4.c:filter_block_8x8
cdef_block_avx2.c:filter_block_8x8
Line
Count
Source
476
11.0M
                                  int enable_primary, int enable_secondary) {
477
11.0M
  uint8_t *dst8 = (uint8_t *)dest;
478
11.0M
  uint16_t *dst16 = (uint16_t *)dest;
479
11.0M
  const int clipping_required = enable_primary && enable_secondary;
480
11.0M
  int i;
481
11.0M
  v256 sum, p0, p1, p2, p3, row, res;
482
11.0M
  const v256 cdef_large_value_mask = v256_dup_16((uint16_t)~CDEF_VERY_LARGE);
483
11.0M
  v256 max, min;
484
11.0M
  const int po1 = cdef_directions[dir][0];
485
11.0M
  const int po2 = cdef_directions[dir][1];
486
11.0M
  const int s1o1 = cdef_directions[dir + 2][0];
487
11.0M
  const int s1o2 = cdef_directions[dir + 2][1];
488
11.0M
  const int s2o1 = cdef_directions[dir - 2][0];
489
11.0M
  const int s2o2 = cdef_directions[dir - 2][1];
490
11.0M
  const int *pri_taps = cdef_pri_taps[(pri_strength >> coeff_shift) & 1];
491
11.0M
  const int *sec_taps = cdef_sec_taps;
492
493
11.0M
  if (enable_primary && pri_strength)
494
8.36M
    pri_damping = AOMMAX(0, pri_damping - get_msb(pri_strength));
495
11.0M
  if (enable_secondary && sec_strength)
496
9.43M
    sec_damping = AOMMAX(0, sec_damping - get_msb(sec_strength));
497
498
39.1M
  for (i = 0; i < height; i += 2) {
499
28.0M
    v256 tap[8];
500
28.0M
    sum = v256_zero();
501
28.0M
    row = v256_from_v128(v128_load_aligned(&in[i * CDEF_BSTRIDE]),
502
28.0M
                         v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]));
503
504
28.0M
    min = max = row;
505
28.0M
    if (enable_primary) {
506
      // Primary near taps
507
20.5M
      tap[0] = v256_from_v128(
508
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po1]),
509
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po1]));
510
20.5M
      tap[1] = v256_from_v128(
511
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po1]),
512
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po1]));
513
20.5M
      p0 = constrain16(tap[0], row, pri_strength, pri_damping);
514
20.5M
      p1 = constrain16(tap[1], row, pri_strength, pri_damping);
515
516
      // sum += pri_taps[0] * (p0 + p1)
517
20.5M
      sum = v256_add_16(
518
20.5M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[0]), v256_add_16(p0, p1)));
519
520
      // Primary far taps
521
20.5M
      tap[2] = v256_from_v128(
522
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + po2]),
523
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + po2]));
524
20.5M
      tap[3] = v256_from_v128(
525
20.5M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - po2]),
526
20.5M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - po2]));
527
20.5M
      p0 = constrain16(tap[2], row, pri_strength, pri_damping);
528
20.5M
      p1 = constrain16(tap[3], row, pri_strength, pri_damping);
529
530
      // sum += pri_taps[1] * (p0 + p1)
531
20.5M
      sum = v256_add_16(
532
20.5M
          sum, v256_mullo_s16(v256_dup_16(pri_taps[1]), v256_add_16(p0, p1)));
533
534
20.5M
      if (clipping_required) {
535
14.8M
        max = get_max_primary(is_lowbd, tap, max, cdef_large_value_mask);
536
537
14.8M
        min = v256_min_s16(min, tap[0]);
538
14.8M
        min = v256_min_s16(min, tap[1]);
539
14.8M
        min = v256_min_s16(min, tap[2]);
540
14.8M
        min = v256_min_s16(min, tap[3]);
541
14.8M
      }
542
      // End primary
543
20.5M
    }
544
545
28.0M
    if (enable_secondary) {
546
      // Secondary near taps
547
22.7M
      tap[0] = v256_from_v128(
548
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o1]),
549
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o1]));
550
22.7M
      tap[1] = v256_from_v128(
551
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o1]),
552
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o1]));
553
22.7M
      tap[2] = v256_from_v128(
554
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o1]),
555
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o1]));
556
22.7M
      tap[3] = v256_from_v128(
557
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o1]),
558
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o1]));
559
22.7M
      p0 = constrain16(tap[0], row, sec_strength, sec_damping);
560
22.7M
      p1 = constrain16(tap[1], row, sec_strength, sec_damping);
561
22.7M
      p2 = constrain16(tap[2], row, sec_strength, sec_damping);
562
22.7M
      p3 = constrain16(tap[3], row, sec_strength, sec_damping);
563
564
      // sum += sec_taps[0] * (p0 + p1 + p2 + p3)
565
22.7M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[0]),
566
22.7M
                                            v256_add_16(v256_add_16(p0, p1),
567
22.7M
                                                        v256_add_16(p2, p3))));
568
569
      // Secondary far taps
570
22.7M
      tap[4] = v256_from_v128(
571
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s1o2]),
572
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s1o2]));
573
22.7M
      tap[5] = v256_from_v128(
574
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s1o2]),
575
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s1o2]));
576
22.7M
      tap[6] = v256_from_v128(
577
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE + s2o2]),
578
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE + s2o2]));
579
22.7M
      tap[7] = v256_from_v128(
580
22.7M
          v128_load_unaligned(&in[i * CDEF_BSTRIDE - s2o2]),
581
22.7M
          v128_load_unaligned(&in[(i + 1) * CDEF_BSTRIDE - s2o2]));
582
22.7M
      p0 = constrain16(tap[4], row, sec_strength, sec_damping);
583
22.7M
      p1 = constrain16(tap[5], row, sec_strength, sec_damping);
584
22.7M
      p2 = constrain16(tap[6], row, sec_strength, sec_damping);
585
22.7M
      p3 = constrain16(tap[7], row, sec_strength, sec_damping);
586
587
      // sum += sec_taps[1] * (p0 + p1 + p2 + p3)
588
22.7M
      sum = v256_add_16(sum, v256_mullo_s16(v256_dup_16(sec_taps[1]),
589
22.7M
                                            v256_add_16(v256_add_16(p0, p1),
590
22.7M
                                                        v256_add_16(p2, p3))));
591
592
22.7M
      if (clipping_required) {
593
14.6M
        max = get_max_secondary(is_lowbd, tap, max, cdef_large_value_mask);
594
595
14.6M
        min = v256_min_s16(min, tap[0]);
596
14.6M
        min = v256_min_s16(min, tap[1]);
597
14.6M
        min = v256_min_s16(min, tap[2]);
598
14.6M
        min = v256_min_s16(min, tap[3]);
599
14.6M
        min = v256_min_s16(min, tap[4]);
600
14.6M
        min = v256_min_s16(min, tap[5]);
601
14.6M
        min = v256_min_s16(min, tap[6]);
602
14.6M
        min = v256_min_s16(min, tap[7]);
603
14.6M
      }
604
      // End secondary
605
22.7M
    }
606
607
    // res = row + ((sum - (sum < 0) + 8) >> 4)
608
28.0M
    sum = v256_add_16(sum, v256_cmplt_s16(sum, v256_zero()));
609
28.0M
    res = v256_add_16(sum, v256_dup_16(8));
610
28.0M
    res = v256_shr_n_s16(res, 4);
611
28.0M
    res = v256_add_16(row, res);
612
28.0M
    if (clipping_required) {
613
14.6M
      res = v256_min_s16(v256_max_s16(res, min), max);
614
14.6M
    }
615
616
28.0M
    if (is_lowbd) {
617
9.55M
      const v128 res_128 = v256_low_v128(v256_pack_s16_u8(res, res));
618
9.55M
      v64_store_aligned(&dst8[i * dstride], v128_high_v64(res_128));
619
9.55M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_low_v64(res_128));
620
18.4M
    } else {
621
18.4M
      v128_store_unaligned(&dst16[i * dstride], v256_high_v128(res));
622
18.4M
      v128_store_unaligned(&dst16[(i + 1) * dstride], v256_low_v128(res));
623
18.4M
    }
624
28.0M
  }
625
11.0M
}
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
3.55M
                                const uint16_t *in, int height) {
665
3.55M
  uint8_t *dst8 = (uint8_t *)dest;
666
3.55M
  uint16_t *dst16 = (uint16_t *)dest;
667
3.55M
  int i;
668
17.7M
  for (i = 0; i < height; i += 2) {
669
14.2M
    const v128 row0 = v128_load_aligned(&in[i * CDEF_BSTRIDE]);
670
14.2M
    const v128 row1 = v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]);
671
14.2M
    if (is_lowbd) {
672
      /* Note: v128_pack_s16_u8(). The parameter order is swapped internally */
673
4.97M
      const v128 res_128 = v128_pack_s16_u8(row1, row0);
674
4.97M
      v64_store_aligned(&dst8[i * dstride], v128_low_v64(res_128));
675
4.97M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_high_v64(res_128));
676
9.24M
    } else {
677
9.24M
      v128_store_unaligned(&dst16[i * dstride], row0);
678
9.24M
      v128_store_unaligned(&dst16[(i + 1) * dstride], row1);
679
9.24M
    }
680
14.2M
  }
681
3.55M
}
Unexecuted instantiation: cdef_block_sse4.c:copy_block_8xh
cdef_block_avx2.c:copy_block_8xh
Line
Count
Source
664
3.55M
                                const uint16_t *in, int height) {
665
3.55M
  uint8_t *dst8 = (uint8_t *)dest;
666
3.55M
  uint16_t *dst16 = (uint16_t *)dest;
667
3.55M
  int i;
668
17.7M
  for (i = 0; i < height; i += 2) {
669
14.2M
    const v128 row0 = v128_load_aligned(&in[i * CDEF_BSTRIDE]);
670
14.2M
    const v128 row1 = v128_load_aligned(&in[(i + 1) * CDEF_BSTRIDE]);
671
14.2M
    if (is_lowbd) {
672
      /* Note: v128_pack_s16_u8(). The parameter order is swapped internally */
673
4.97M
      const v128 res_128 = v128_pack_s16_u8(row1, row0);
674
4.97M
      v64_store_aligned(&dst8[i * dstride], v128_low_v64(res_128));
675
4.97M
      v64_store_aligned(&dst8[(i + 1) * dstride], v128_high_v64(res_128));
676
9.24M
    } else {
677
9.24M
      v128_store_unaligned(&dst16[i * dstride], row0);
678
9.24M
      v128_store_unaligned(&dst16[(i + 1) * dstride], row1);
679
9.24M
    }
680
14.2M
  }
681
3.55M
}
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
6.96M
                                int block_height) {
688
6.96M
  if (block_width == 8) {
689
2.12M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
690
2.12M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
691
2.12M
                     block_height, /*enable_primary=*/1,
692
2.12M
                     /*enable_secondary=*/1);
693
4.84M
  } else {
694
4.84M
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
695
4.84M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
696
4.84M
                     block_height, /*enable_primary=*/1,
697
4.84M
                     /*enable_secondary=*/1);
698
4.84M
  }
699
6.96M
}
Unexecuted instantiation: cdef_filter_8_0_sse4_1
cdef_filter_8_0_avx2
Line
Count
Source
687
6.96M
                                int block_height) {
688
6.96M
  if (block_width == 8) {
689
2.12M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
690
2.12M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
691
2.12M
                     block_height, /*enable_primary=*/1,
692
2.12M
                     /*enable_secondary=*/1);
693
4.84M
  } else {
694
4.84M
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
695
4.84M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
696
4.84M
                     block_height, /*enable_primary=*/1,
697
4.84M
                     /*enable_secondary=*/1);
698
4.84M
  }
699
6.96M
}
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
1.26M
                                int block_height) {
706
1.26M
  if (block_width == 8) {
707
922k
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
708
922k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
709
922k
                     block_height, /*enable_primary=*/1,
710
922k
                     /*enable_secondary=*/0);
711
922k
  } else {
712
341k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
713
341k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
714
341k
                     block_height, /*enable_primary=*/1,
715
341k
                     /*enable_secondary=*/0);
716
341k
  }
717
1.26M
}
Unexecuted instantiation: cdef_filter_8_1_sse4_1
cdef_filter_8_1_avx2
Line
Count
Source
705
1.26M
                                int block_height) {
706
1.26M
  if (block_width == 8) {
707
922k
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
708
922k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
709
922k
                     block_height, /*enable_primary=*/1,
710
922k
                     /*enable_secondary=*/0);
711
922k
  } else {
712
341k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
713
341k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
714
341k
                     block_height, /*enable_primary=*/1,
715
341k
                     /*enable_secondary=*/0);
716
341k
  }
717
1.26M
}
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
1.53M
                                int block_height) {
723
1.53M
  if (block_width == 8) {
724
1.42M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
725
1.42M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
726
1.42M
                     block_height, /*enable_primary=*/0,
727
1.42M
                     /*enable_secondary=*/1);
728
1.42M
  } else {
729
110k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
730
110k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
731
110k
                     block_height, /*enable_primary=*/0,
732
110k
                     /*enable_secondary=*/1);
733
110k
  }
734
1.53M
}
Unexecuted instantiation: cdef_filter_8_2_sse4_1
cdef_filter_8_2_avx2
Line
Count
Source
722
1.53M
                                int block_height) {
723
1.53M
  if (block_width == 8) {
724
1.42M
    filter_block_8x8(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
725
1.42M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
726
1.42M
                     block_height, /*enable_primary=*/0,
727
1.42M
                     /*enable_secondary=*/1);
728
1.42M
  } else {
729
110k
    filter_block_4x4(/*is_lowbd=*/1, dest, dstride, in, pri_strength,
730
110k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
731
110k
                     block_height, /*enable_primary=*/0,
732
110k
                     /*enable_secondary=*/1);
733
110k
  }
734
1.53M
}
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.24M
                                int block_height) {
741
1.24M
  (void)pri_strength;
742
1.24M
  (void)sec_strength;
743
1.24M
  (void)dir;
744
1.24M
  (void)pri_damping;
745
1.24M
  (void)sec_damping;
746
1.24M
  (void)coeff_shift;
747
1.24M
  (void)block_width;
748
749
1.24M
  if (block_width == 8) {
750
1.24M
    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.24M
}
Unexecuted instantiation: cdef_filter_8_3_sse4_1
cdef_filter_8_3_avx2
Line
Count
Source
740
1.24M
                                int block_height) {
741
1.24M
  (void)pri_strength;
742
1.24M
  (void)sec_strength;
743
1.24M
  (void)dir;
744
1.24M
  (void)pri_damping;
745
1.24M
  (void)sec_damping;
746
1.24M
  (void)coeff_shift;
747
1.24M
  (void)block_width;
748
749
1.24M
  if (block_width == 8) {
750
1.24M
    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.24M
}
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
13.3M
                                 int block_height) {
761
13.3M
  if (block_width == 8) {
762
4.46M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
763
4.46M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
764
4.46M
                     block_height, /*enable_primary=*/1,
765
4.46M
                     /*enable_secondary=*/1);
766
8.86M
  } else {
767
8.86M
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
768
8.86M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
769
8.86M
                     block_height, /*enable_primary=*/1,
770
8.86M
                     /*enable_secondary=*/1);
771
8.86M
  }
772
13.3M
}
Unexecuted instantiation: cdef_filter_16_0_sse4_1
cdef_filter_16_0_avx2
Line
Count
Source
760
13.3M
                                 int block_height) {
761
13.3M
  if (block_width == 8) {
762
4.46M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
763
4.46M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
764
4.46M
                     block_height, /*enable_primary=*/1,
765
4.46M
                     /*enable_secondary=*/1);
766
8.86M
  } else {
767
8.86M
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
768
8.86M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
769
8.86M
                     block_height, /*enable_primary=*/1,
770
8.86M
                     /*enable_secondary=*/1);
771
8.86M
  }
772
13.3M
}
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.14M
                                 int block_height) {
779
2.14M
  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
407k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
786
407k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
787
407k
                     block_height, /*enable_primary=*/1,
788
407k
                     /*enable_secondary=*/0);
789
407k
  }
790
2.14M
}
Unexecuted instantiation: cdef_filter_16_1_sse4_1
cdef_filter_16_1_avx2
Line
Count
Source
778
2.14M
                                 int block_height) {
779
2.14M
  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
407k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
786
407k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
787
407k
                     block_height, /*enable_primary=*/1,
788
407k
                     /*enable_secondary=*/0);
789
407k
  }
790
2.14M
}
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
1.90M
                                 int block_height) {
796
1.90M
  if (block_width == 8) {
797
1.89M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
798
1.89M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
799
1.89M
                     block_height, /*enable_primary=*/0,
800
1.89M
                     /*enable_secondary=*/1);
801
1.89M
  } else {
802
7.63k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
803
7.63k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
804
7.63k
                     block_height, /*enable_primary=*/0,
805
7.63k
                     /*enable_secondary=*/1);
806
7.63k
  }
807
1.90M
}
Unexecuted instantiation: cdef_filter_16_2_sse4_1
cdef_filter_16_2_avx2
Line
Count
Source
795
1.90M
                                 int block_height) {
796
1.90M
  if (block_width == 8) {
797
1.89M
    filter_block_8x8(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
798
1.89M
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
799
1.89M
                     block_height, /*enable_primary=*/0,
800
1.89M
                     /*enable_secondary=*/1);
801
1.89M
  } else {
802
7.63k
    filter_block_4x4(/*is_lowbd=*/0, dest, dstride, in, pri_strength,
803
7.63k
                     sec_strength, dir, pri_damping, sec_damping, coeff_shift,
804
7.63k
                     block_height, /*enable_primary=*/0,
805
7.63k
                     /*enable_secondary=*/1);
806
7.63k
  }
807
1.90M
}
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.30M
                                 int block_height) {
814
2.30M
  (void)pri_strength;
815
2.30M
  (void)sec_strength;
816
2.30M
  (void)dir;
817
2.30M
  (void)pri_damping;
818
2.30M
  (void)sec_damping;
819
2.30M
  (void)coeff_shift;
820
2.30M
  (void)block_width;
821
2.31M
  if (block_width == 8) {
822
2.31M
    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.30M
}
Unexecuted instantiation: cdef_filter_16_3_sse4_1
cdef_filter_16_3_avx2
Line
Count
Source
813
2.30M
                                 int block_height) {
814
2.30M
  (void)pri_strength;
815
2.30M
  (void)sec_strength;
816
2.30M
  (void)dir;
817
2.30M
  (void)pri_damping;
818
2.30M
  (void)sec_damping;
819
2.30M
  (void)coeff_shift;
820
2.30M
  (void)block_width;
821
2.31M
  if (block_width == 8) {
822
2.31M
    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.30M
}
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
604k
                                               int width, int height) {
832
604k
  int i, j;
833
23.1M
  for (i = 0; i < height; i++) {
834
185M
    for (j = 0; j < (width & ~0x7); j += 8) {
835
162M
      v128 row = v128_load_unaligned(&src[i * sstride + j]);
836
162M
      v128_store_unaligned(&dst[i * dstride + j], row);
837
162M
    }
838
23.6M
    for (; j < width; j++) {
839
1.09M
      dst[i * dstride + j] = src[i * sstride + j];
840
1.09M
    }
841
22.5M
  }
842
604k
}
Unexecuted instantiation: cdef_copy_rect8_16bit_to_16bit_sse4_1
cdef_copy_rect8_16bit_to_16bit_avx2
Line
Count
Source
831
604k
                                               int width, int height) {
832
604k
  int i, j;
833
23.1M
  for (i = 0; i < height; i++) {
834
185M
    for (j = 0; j < (width & ~0x7); j += 8) {
835
162M
      v128 row = v128_load_unaligned(&src[i * sstride + j]);
836
162M
      v128_store_unaligned(&dst[i * dstride + j], row);
837
162M
    }
838
23.6M
    for (; j < width; j++) {
839
1.09M
      dst[i * dstride + j] = src[i * sstride + j];
840
1.09M
    }
841
22.5M
  }
842
604k
}
843
#endif  // CONFIG_AV1_HIGHBITDEPTH
844
845
#undef CDEF_INLINE
846
847
#endif  // AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_