Coverage Report

Created: 2026-02-14 07:00

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