Coverage Report

Created: 2026-11-12 08:20

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