filter.c 16.2 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4
5
6
7
8
9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Jingning Han's avatar
Jingning Han committed
10
11
12
13
 */

#include <assert.h>

14
#include "av1/common/filter.h"
Jingning Han's avatar
Jingning Han committed
15
16
17

DECLARE_ALIGNED(256, static const InterpKernel,
                bilinear_filters[SUBPEL_SHIFTS]) = {
clang-format's avatar
clang-format committed
18
19
20
21
22
23
24
25
  { 0, 0, 0, 128, 0, 0, 0, 0 },  { 0, 0, 0, 120, 8, 0, 0, 0 },
  { 0, 0, 0, 112, 16, 0, 0, 0 }, { 0, 0, 0, 104, 24, 0, 0, 0 },
  { 0, 0, 0, 96, 32, 0, 0, 0 },  { 0, 0, 0, 88, 40, 0, 0, 0 },
  { 0, 0, 0, 80, 48, 0, 0, 0 },  { 0, 0, 0, 72, 56, 0, 0, 0 },
  { 0, 0, 0, 64, 64, 0, 0, 0 },  { 0, 0, 0, 56, 72, 0, 0, 0 },
  { 0, 0, 0, 48, 80, 0, 0, 0 },  { 0, 0, 0, 40, 88, 0, 0, 0 },
  { 0, 0, 0, 32, 96, 0, 0, 0 },  { 0, 0, 0, 24, 104, 0, 0, 0 },
  { 0, 0, 0, 16, 112, 0, 0, 0 }, { 0, 0, 0, 8, 120, 0, 0, 0 }
Jingning Han's avatar
Jingning Han committed
26
27
};

28
#if USE_TEMPORALFILTER_12TAP
29
30
DECLARE_ALIGNED(16, static const int16_t,
                sub_pel_filters_temporalfilter_12[SUBPEL_SHIFTS][12]) = {
31
  // intfilt 0.8
clang-format's avatar
clang-format committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  { 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 },
  { 0, 1, -1, 3, -7, 127, 8, -4, 2, -1, 0, 0 },
  { 0, 1, -3, 5, -12, 124, 18, -8, 4, -2, 1, 0 },
  { -1, 2, -4, 8, -17, 120, 28, -11, 6, -3, 1, -1 },
  { -1, 2, -4, 10, -21, 114, 38, -15, 8, -4, 2, -1 },
  { -1, 3, -5, 11, -23, 107, 49, -18, 9, -5, 2, -1 },
  { -1, 3, -6, 12, -25, 99, 60, -21, 11, -6, 3, -1 },
  { -1, 3, -6, 12, -25, 90, 70, -23, 12, -6, 3, -1 },
  { -1, 3, -6, 12, -24, 80, 80, -24, 12, -6, 3, -1 },
  { -1, 3, -6, 12, -23, 70, 90, -25, 12, -6, 3, -1 },
  { -1, 3, -6, 11, -21, 60, 99, -25, 12, -6, 3, -1 },
  { -1, 2, -5, 9, -18, 49, 107, -23, 11, -5, 3, -1 },
  { -1, 2, -4, 8, -15, 38, 114, -21, 10, -4, 2, -1 },
  { -1, 1, -3, 6, -11, 28, 120, -17, 8, -4, 2, -1 },
  { 0, 1, -2, 4, -8, 18, 124, -12, 5, -3, 1, 0 },
  { 0, 0, -1, 2, -4, 8, 127, -7, 3, -1, 1, 0 },
48
};
49
#endif  // USE_TEMPORALFILTER_12TAP
50

51
#if USE_EXTRA_FILTER
Jingning Han's avatar
Jingning Han committed
52
53
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8[SUBPEL_SHIFTS]) = {
54
55
56
57
58
59
60
61
  { 0, 0, 0, 128, 0, 0, 0, 0 },      { 0, 2, -6, 126, 8, -2, 0, 0 },
  { 0, 2, -10, 122, 18, -4, 0, 0 },  { 0, 2, -12, 116, 28, -8, 2, 0 },
  { 0, 2, -14, 110, 38, -10, 2, 0 }, { 0, 2, -14, 102, 48, -12, 2, 0 },
  { 0, 2, -16, 94, 58, -12, 2, 0 },  { 0, 2, -14, 84, 66, -12, 2, 0 },
  { 0, 2, -14, 76, 76, -14, 2, 0 },  { 0, 2, -12, 66, 84, -14, 2, 0 },
  { 0, 2, -12, 58, 94, -16, 2, 0 },  { 0, 2, -12, 48, 102, -14, 2, 0 },
  { 0, 2, -10, 38, 110, -14, 2, 0 }, { 0, 2, -8, 28, 116, -12, 2, 0 },
  { 0, 0, -4, 18, 122, -10, 2, 0 },  { 0, 0, -2, 8, 126, -6, 2, 0 }
Jingning Han's avatar
Jingning Han committed
62
63
};

64
65
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_regular_uv[SUBPEL_SHIFTS]) = {
66
67
68
69
70
71
72
73
  { 0, 0, 0, 128, 0, 0, 0, 0 },      { 0, 2, -6, 126, 8, -2, 0, 0 },
  { 0, 2, -10, 122, 18, -4, 0, 0 },  { 0, 2, -12, 116, 28, -8, 2, 0 },
  { 0, 2, -14, 110, 38, -10, 2, 0 }, { 0, 2, -14, 102, 48, -12, 2, 0 },
  { 0, 2, -16, 94, 58, -12, 2, 0 },  { 0, 2, -14, 84, 66, -12, 2, 0 },
  { 0, 2, -14, 76, 76, -14, 2, 0 },  { 0, 2, -12, 66, 84, -14, 2, 0 },
  { 0, 2, -12, 58, 94, -16, 2, 0 },  { 0, 2, -12, 48, 102, -14, 2, 0 },
  { 0, 2, -10, 38, 110, -14, 2, 0 }, { 0, 2, -8, 28, 116, -12, 2, 0 },
  { 0, 0, -4, 18, 122, -10, 2, 0 },  { 0, 0, -2, 8, 126, -6, 2, 0 }
74
75
};

Jingning Han's avatar
Jingning Han committed
76
#if USE_12TAP_FILTER
Jingning Han's avatar
Jingning Han committed
77
DECLARE_ALIGNED(256, static const InterpKernel,
78
79
                sub_pel_filters_8sharp[SUBPEL_SHIFTS]) = {
  // intfilt 0.8
clang-format's avatar
clang-format committed
80
81
82
83
84
85
86
87
  { 0, 0, 0, 128, 0, 0, 0, 0 },         { -1, 2, -6, 127, 9, -4, 2, -1 },
  { -2, 5, -12, 124, 18, -7, 4, -2 },   { -2, 7, -16, 119, 28, -11, 5, -2 },
  { -3, 8, -19, 114, 38, -14, 7, -3 },  { -3, 9, -22, 107, 49, -17, 8, -3 },
  { -4, 10, -23, 99, 60, -20, 10, -4 }, { -4, 11, -23, 90, 70, -22, 10, -4 },
  { -4, 11, -23, 80, 80, -23, 11, -4 }, { -4, 10, -22, 70, 90, -23, 11, -4 },
  { -4, 10, -20, 60, 99, -23, 10, -4 }, { -3, 8, -17, 49, 107, -22, 9, -3 },
  { -3, 7, -14, 38, 114, -19, 8, -3 },  { -2, 5, -11, 28, 119, -16, 7, -2 },
  { -2, 4, -7, 18, 124, -12, 5, -2 },   { -1, 2, -4, 9, 127, -6, 2, -1 },
Jingning Han's avatar
Jingning Han committed
88
};
89

90
DECLARE_ALIGNED(256, static const int16_t,
Yaowu Xu's avatar
Yaowu Xu committed
91
                sub_pel_filters_10sharp[SUBPEL_SHIFTS][12]) = {
92
  // intfilt 0.85
Yaowu Xu's avatar
Yaowu Xu committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  { 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 },
  { 0, 1, -2, 3, -7, 127, 8, -4, 2, -1, 1, 0 },
  { 0, 1, -3, 6, -13, 124, 18, -8, 4, -2, 1, 0 },
  { 0, 2, -4, 8, -18, 120, 28, -12, 6, -4, 2, 0 },
  { 0, 2, -5, 10, -21, 114, 38, -15, 8, -5, 2, 0 },
  { 0, 3, -6, 11, -24, 107, 49, -19, 10, -6, 3, 0 },
  { 0, 3, -7, 12, -25, 99, 59, -21, 11, -6, 3, 0 },
  { 0, 3, -7, 12, -25, 90, 70, -23, 12, -7, 3, 0 },
  { 0, 3, -7, 12, -25, 81, 81, -25, 12, -7, 3, 0 },
  { 0, 3, -7, 12, -23, 70, 90, -25, 12, -7, 3, 0 },
  { 0, 3, -6, 11, -21, 59, 99, -25, 12, -7, 3, 0 },
  { 0, 3, -6, 10, -19, 49, 107, -24, 11, -6, 3, 0 },
  { 0, 2, -5, 8, -15, 38, 114, -21, 10, -5, 2, 0 },
  { 0, 2, -4, 6, -12, 28, 120, -18, 8, -4, 2, 0 },
  { 0, 1, -2, 4, -8, 18, 124, -13, 6, -3, 1, 0 },
  { 0, 1, -1, 2, -4, 8, 127, -7, 3, -2, 1, 0 },
109
};
Jingning Han's avatar
Jingning Han committed
110
111
112
113
114
115
116
117
118
119
120
121
122
#else
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8sharp[SUBPEL_SHIFTS]) = {
  { 0, 0, 0, 128, 0, 0, 0, 0 },         { -2, 2, -6, 126, 8, -2, 2, 0 },
  { -2, 6, -12, 124, 16, -6, 4, -2 },   { -2, 8, -18, 120, 26, -10, 6, -2 },
  { -4, 10, -22, 116, 38, -14, 6, -2 }, { -4, 10, -22, 108, 48, -18, 8, -2 },
  { -4, 10, -24, 100, 60, -20, 8, -2 }, { -4, 10, -24, 90, 70, -22, 10, -2 },
  { -4, 12, -24, 80, 80, -24, 12, -4 }, { -2, 10, -22, 70, 90, -24, 10, -4 },
  { -2, 8, -20, 60, 100, -24, 10, -4 }, { -2, 8, -18, 48, 108, -22, 10, -4 },
  { -2, 6, -14, 38, 116, -22, 10, -4 }, { -2, 6, -10, 26, 120, -18, 8, -2 },
  { -2, 4, -6, 16, 124, -12, 6, -2 },   { 0, 2, -2, 8, 126, -6, 2, -2 }
};
#endif
Jingning Han's avatar
Jingning Han committed
123
124

DECLARE_ALIGNED(256, static const InterpKernel,
125
                sub_pel_filters_8smooth2[SUBPEL_SHIFTS]) = {
126
127
128
129
130
131
132
133
134
  // freqmultiplier = 0.2
  { 0, 0, 0, 128, 0, 0, 0, 0 },   { 0, 9, 30, 44, 32, 11, 2, 0 },
  { 0, 8, 28, 44, 34, 12, 2, 0 }, { 0, 7, 27, 44, 35, 13, 2, 0 },
  { 0, 6, 26, 43, 37, 14, 2, 0 }, { 0, 5, 24, 43, 38, 16, 2, 0 },
  { 0, 5, 23, 42, 38, 17, 3, 0 }, { 0, 4, 21, 41, 40, 19, 3, 0 },
  { 0, 4, 20, 40, 40, 20, 4, 0 }, { 0, 3, 19, 40, 41, 21, 4, 0 },
  { 0, 3, 17, 38, 42, 23, 5, 0 }, { 0, 2, 16, 38, 43, 24, 5, 0 },
  { 0, 2, 14, 37, 43, 26, 6, 0 }, { 0, 2, 13, 35, 44, 27, 7, 0 },
  { 0, 2, 12, 34, 44, 28, 8, 0 }, { 0, 2, 11, 32, 44, 30, 9, 0 },
135
136
};

137
138
139
140
141
142
143
144
145
146
147
148
149
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_smooth2_uv[SUBPEL_SHIFTS]) = {
  // freqmultiplier = 0.2
  { 0, 0, 0, 128, 0, 0, 0, 0 },   { 0, 9, 30, 44, 32, 11, 2, 0 },
  { 0, 8, 28, 44, 34, 12, 2, 0 }, { 0, 7, 27, 44, 35, 13, 2, 0 },
  { 0, 6, 26, 43, 37, 14, 2, 0 }, { 0, 5, 24, 43, 38, 16, 2, 0 },
  { 0, 5, 23, 42, 38, 17, 3, 0 }, { 0, 4, 21, 41, 40, 19, 3, 0 },
  { 0, 4, 20, 40, 40, 20, 4, 0 }, { 0, 3, 19, 40, 41, 21, 4, 0 },
  { 0, 3, 17, 38, 42, 23, 5, 0 }, { 0, 2, 16, 38, 43, 24, 5, 0 },
  { 0, 2, 14, 37, 43, 26, 6, 0 }, { 0, 2, 13, 35, 44, 27, 7, 0 },
  { 0, 2, 12, 34, 44, 28, 8, 0 }, { 0, 2, 11, 32, 44, 30, 9, 0 },
};

150
151
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8smooth[SUBPEL_SHIFTS]) = {
152
153
154
155
156
157
158
159
  { 0, 0, 0, 128, 0, 0, 0, 0 },     { 0, 2, 28, 62, 34, 2, 0, 0 },
  { 0, 0, 26, 62, 36, 4, 0, 0 },    { 0, 0, 22, 62, 40, 4, 0, 0 },
  { 0, 0, 20, 60, 42, 6, 0, 0 },    { 0, 0, 18, 58, 44, 8, 0, 0 },
  { 0, 0, 16, 56, 46, 10, 0, 0 },   { 0, -2, 16, 54, 48, 12, 0, 0 },
  { 0, -2, 14, 52, 52, 14, -2, 0 }, { 0, 0, 12, 48, 54, 16, -2, 0 },
  { 0, 0, 10, 46, 56, 16, 0, 0 },   { 0, 0, 8, 44, 58, 18, 0, 0 },
  { 0, 0, 6, 42, 60, 20, 0, 0 },    { 0, 0, 4, 40, 62, 22, 0, 0 },
  { 0, 0, 4, 36, 62, 26, 0, 0 },    { 0, 0, 2, 34, 62, 28, 2, 0 }
160
};
161
162
163

DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_smooth_uv[SUBPEL_SHIFTS]) = {
164
165
166
167
168
169
170
171
  { 0, 0, 0, 128, 0, 0, 0, 0 },     { 0, 2, 28, 62, 34, 2, 0, 0 },
  { 0, 0, 26, 62, 36, 4, 0, 0 },    { 0, 0, 22, 62, 40, 4, 0, 0 },
  { 0, 0, 20, 60, 42, 6, 0, 0 },    { 0, 0, 18, 58, 44, 8, 0, 0 },
  { 0, 0, 16, 56, 46, 10, 0, 0 },   { 0, -2, 16, 54, 48, 12, 0, 0 },
  { 0, -2, 14, 52, 52, 14, -2, 0 }, { 0, 0, 12, 48, 54, 16, -2, 0 },
  { 0, 0, 10, 46, 56, 16, 0, 0 },   { 0, 0, 8, 44, 58, 18, 0, 0 },
  { 0, 0, 6, 42, 60, 20, 0, 0 },    { 0, 0, 4, 40, 62, 22, 0, 0 },
  { 0, 0, 4, 36, 62, 26, 0, 0 },    { 0, 0, 2, 34, 62, 28, 2, 0 }
172
};
173
#else   // USE_EXTRA_FILTER
174
175
176

DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8[SUBPEL_SHIFTS]) = {
Arild Fuldseth's avatar
Arild Fuldseth committed
177
178
179
180
181
182
183
184
  { 0, 0, 0, 128, 0, 0, 0, 0 },      { 0, 2, -6, 126, 8, -2, 0, 0 },
  { 0, 2, -10, 122, 18, -4, 0, 0 },  { 0, 2, -12, 116, 28, -8, 2, 0 },
  { 0, 2, -14, 110, 38, -10, 2, 0 }, { 0, 2, -14, 102, 48, -12, 2, 0 },
  { 0, 2, -16, 94, 58, -12, 2, 0 },  { 0, 2, -14, 84, 66, -12, 2, 0 },
  { 0, 2, -14, 76, 76, -14, 2, 0 },  { 0, 2, -12, 66, 84, -14, 2, 0 },
  { 0, 2, -12, 58, 94, -16, 2, 0 },  { 0, 2, -12, 48, 102, -14, 2, 0 },
  { 0, 2, -10, 38, 110, -14, 2, 0 }, { 0, 2, -8, 28, 116, -12, 2, 0 },
  { 0, 0, -4, 18, 122, -10, 2, 0 },  { 0, 0, -2, 8, 126, -6, 2, 0 }
185
186
187
188
};

DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8sharp[SUBPEL_SHIFTS]) = {
Arild Fuldseth's avatar
Arild Fuldseth committed
189
190
191
192
193
194
195
196
  { 0, 0, 0, 128, 0, 0, 0, 0 },         { -2, 2, -6, 126, 8, -2, 2, 0 },
  { -2, 6, -12, 124, 16, -6, 4, -2 },   { -2, 8, -18, 120, 26, -10, 6, -2 },
  { -4, 10, -22, 116, 38, -14, 6, -2 }, { -4, 10, -22, 108, 48, -18, 8, -2 },
  { -4, 10, -24, 100, 60, -20, 8, -2 }, { -4, 10, -24, 90, 70, -22, 10, -2 },
  { -4, 12, -24, 80, 80, -24, 12, -4 }, { -2, 10, -22, 70, 90, -24, 10, -4 },
  { -2, 8, -20, 60, 100, -24, 10, -4 }, { -2, 8, -18, 48, 108, -22, 10, -4 },
  { -2, 6, -14, 38, 116, -22, 10, -4 }, { -2, 6, -10, 26, 120, -18, 8, -2 },
  { -2, 4, -6, 16, 124, -12, 6, -2 },   { 0, 2, -2, 8, 126, -6, 2, -2 }
197
};
198
199
200

DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_8smooth[SUBPEL_SHIFTS]) = {
Arild Fuldseth's avatar
Arild Fuldseth committed
201
202
203
204
205
206
207
208
  { 0, 0, 0, 128, 0, 0, 0, 0 },     { 0, 2, 28, 62, 34, 2, 0, 0 },
  { 0, 0, 26, 62, 36, 4, 0, 0 },    { 0, 0, 22, 62, 40, 4, 0, 0 },
  { 0, 0, 20, 60, 42, 6, 0, 0 },    { 0, 0, 18, 58, 44, 8, 0, 0 },
  { 0, 0, 16, 56, 46, 10, 0, 0 },   { 0, -2, 16, 54, 48, 12, 0, 0 },
  { 0, -2, 14, 52, 52, 14, -2, 0 }, { 0, 0, 12, 48, 54, 16, -2, 0 },
  { 0, 0, 10, 46, 56, 16, 0, 0 },   { 0, 0, 8, 44, 58, 18, 0, 0 },
  { 0, 0, 6, 42, 60, 20, 0, 0 },    { 0, 0, 4, 40, 62, 22, 0, 0 },
  { 0, 0, 4, 36, 62, 26, 0, 0 },    { 0, 0, 2, 34, 62, 28, 2, 0 }
Jingning Han's avatar
Jingning Han committed
209
};
210
#endif  // USE_EXTRA_FILTER
Jingning Han's avatar
Jingning Han committed
211

212
#if USE_EXTRA_FILTER
213
static const InterpFilterParams
214
    av1_interp_filter_params_list[SWITCHABLE_FILTERS + EXTRA_FILTERS] = {
215
216
217
218
      { (const int16_t *)sub_pel_filters_8, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_REGULAR },
      { (const int16_t *)sub_pel_filters_8smooth, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_SMOOTH },
Jingning Han's avatar
Jingning Han committed
219
#if USE_12TAP_FILTER
Yaowu Xu's avatar
Yaowu Xu committed
220
      { (const int16_t *)sub_pel_filters_10sharp, 12, SUBPEL_SHIFTS,
221
        MULTITAP_SHARP },
Jingning Han's avatar
Jingning Han committed
222
223
224
225
#else
      { (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_SHARP },
#endif
226
227
228
      { (const int16_t *)sub_pel_filters_8smooth2, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_SMOOTH2 },
      { (const int16_t *)bilinear_filters, SUBPEL_TAPS, SUBPEL_SHIFTS,
229
230
231
        BILINEAR },
      { (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_SHARP },
232
233
234
235
      { (const int16_t *)sub_pel_filters_regular_uv, SUBPEL_TAPS, SUBPEL_SHIFTS,
        FILTER_REGULAR_UV },
      { (const int16_t *)sub_pel_filters_smooth_uv, SUBPEL_TAPS, SUBPEL_SHIFTS,
        FILTER_SMOOTH_UV },
236
      { (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS,
237
238
239
        FILTER_SHARP_UV },
      { (const int16_t *)sub_pel_filters_smooth2_uv, SUBPEL_TAPS, SUBPEL_SHIFTS,
        FILTER_SMOOTH2_UV },
clang-format's avatar
clang-format committed
240
    };
241
242
#else
static const InterpFilterParams
Yaowu Xu's avatar
Yaowu Xu committed
243
    av1_interp_filter_params_list[SWITCHABLE_FILTERS + 1] = {
244
245
246
247
248
249
250
251
      { (const int16_t *)sub_pel_filters_8, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_REGULAR },
      { (const int16_t *)sub_pel_filters_8smooth, SUBPEL_TAPS, SUBPEL_SHIFTS,
        EIGHTTAP_SMOOTH },
      { (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS,
        MULTITAP_SHARP },
      { (const int16_t *)bilinear_filters, SUBPEL_TAPS, SUBPEL_SHIFTS,
        BILINEAR }
clang-format's avatar
clang-format committed
252
    };
253
#endif  // USE_EXTRA_FILTER
254

255
#if USE_TEMPORALFILTER_12TAP
Yaowu Xu's avatar
Yaowu Xu committed
256
static const InterpFilterParams av1_interp_temporalfilter_12tap = {
257
258
  (const int16_t *)sub_pel_filters_temporalfilter_12, 12, SUBPEL_SHIFTS,
  TEMPORALFILTER_12TAP
259
};
260
#endif  // USE_TEMPORALFILTER_12TAP
261

Zhijie Yang's avatar
Zhijie Yang committed
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#if CONFIG_SHORT_FILTER

DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_4[SUBPEL_SHIFTS]) = {
  { 0, 0, 0, 128, 0, 0, 0, 0 },     { 0, 0, -4, 126, 8, -2, 0, 0 },
  { 0, 0, -8, 122, 18, -4, 0, 0 },  { 0, 0, -10, 116, 28, -6, 0, 0 },
  { 0, 0, -12, 110, 38, -8, 0, 0 }, { 0, 0, -12, 102, 48, -10, 0, 0 },
  { 0, 0, -14, 94, 58, -10, 0, 0 }, { 0, 0, -12, 84, 66, -10, 0, 0 },
  { 0, 0, -12, 76, 76, -12, 0, 0 }, { 0, 0, -10, 66, 84, -12, 0, 0 },
  { 0, 0, -10, 58, 94, -14, 0, 0 }, { 0, 0, -10, 48, 102, -12, 0, 0 },
  { 0, 0, -8, 38, 110, -12, 0, 0 }, { 0, 0, -6, 28, 116, -10, 0, 0 },
  { 0, 0, -4, 18, 122, -8, 0, 0 },  { 0, 0, -2, 8, 126, -4, 0, 0 }
};
DECLARE_ALIGNED(256, static const InterpKernel,
                sub_pel_filters_4smooth[SUBPEL_SHIFTS]) = {
  { 0, 0, 0, 128, 0, 0, 0, 0 },   { 0, 0, 30, 62, 34, 2, 0, 0 },
  { 0, 0, 26, 62, 36, 4, 0, 0 },  { 0, 0, 22, 62, 40, 4, 0, 0 },
  { 0, 0, 20, 60, 42, 6, 0, 0 },  { 0, 0, 18, 58, 44, 8, 0, 0 },
  { 0, 0, 16, 56, 46, 10, 0, 0 }, { 0, 0, 14, 54, 48, 12, 0, 0 },
  { 0, 0, 12, 52, 52, 12, 0, 0 }, { 0, 0, 12, 48, 54, 14, 0, 0 },
  { 0, 0, 10, 46, 56, 16, 0, 0 }, { 0, 0, 8, 44, 58, 18, 0, 0 },
  { 0, 0, 6, 42, 60, 20, 0, 0 },  { 0, 0, 4, 40, 62, 22, 0, 0 },
  { 0, 0, 4, 36, 62, 26, 0, 0 },  { 0, 0, 2, 34, 62, 30, 0, 0 }
};

static const InterpFilterParams av1_interp_4tap[2] = {
  { (const int16_t *)sub_pel_filters_4, SUBPEL_TAPS, SUBPEL_SHIFTS,
Zhijie Yang's avatar
Zhijie Yang committed
289
    EIGHTTAP_REGULAR },
Zhijie Yang's avatar
Zhijie Yang committed
290
  { (const int16_t *)sub_pel_filters_4smooth, SUBPEL_TAPS, SUBPEL_SHIFTS,
Zhijie Yang's avatar
Zhijie Yang committed
291
    EIGHTTAP_SMOOTH },
Zhijie Yang's avatar
Zhijie Yang committed
292
293
294
};
#endif

Yaowu Xu's avatar
Yaowu Xu committed
295
InterpFilterParams av1_get_interp_filter_params(
James Zern's avatar
James Zern committed
296
    const InterpFilter interp_filter) {
297
298
#if USE_TEMPORALFILTER_12TAP
  if (interp_filter == TEMPORALFILTER_12TAP)
Yaowu Xu's avatar
Yaowu Xu committed
299
    return av1_interp_temporalfilter_12tap;
300
#endif  // USE_TEMPORALFILTER_12TAP
Yaowu Xu's avatar
Yaowu Xu committed
301
  return av1_interp_filter_params_list[interp_filter];
302
}
303

Zhijie Yang's avatar
Zhijie Yang committed
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#if CONFIG_SHORT_FILTER
InterpFilterParams av1_get_interp_filter_params_with_block_size(
    const InterpFilter interp_filter, const int w) {
#if USE_TEMPORALFILTER_12TAP
  if (interp_filter == TEMPORALFILTER_12TAP)
    return av1_interp_temporalfilter_12tap;
#endif  // USE_TEMPORALFILTER_12TAP

  if (w <= 4 &&
      (interp_filter == MULTITAP_SHARP || interp_filter == EIGHTTAP_REGULAR))
    return av1_interp_4tap[0];
  else if (w <= 4 && interp_filter == EIGHTTAP_SMOOTH)
    return av1_interp_4tap[1];

  return av1_interp_filter_params_list[interp_filter];
}
#endif

James Zern's avatar
James Zern committed
322
const int16_t *av1_get_interp_filter_kernel(const InterpFilter interp_filter) {
323
324
#if USE_TEMPORALFILTER_12TAP
  if (interp_filter == TEMPORALFILTER_12TAP)
Yaowu Xu's avatar
Yaowu Xu committed
325
    return av1_interp_temporalfilter_12tap.filter_ptr;
326
#endif  // USE_TEMPORALFILTER_12TAP
Yaowu Xu's avatar
Yaowu Xu committed
327
  return (const int16_t *)av1_interp_filter_params_list[interp_filter]
clang-format's avatar
clang-format committed
328
      .filter_ptr;
329
}
330
331
332
333
334

#if CONFIG_DUAL_FILTER
InterpFilter av1_get_plane_interp_filter(InterpFilter interp_filter,
                                         int plane) {
#if USE_TEMPORALFILTER_12TAP
335
#if USE_EXTRA_FILTER
336
337
  assert(interp_filter <= EIGHTTAP_SHARP ||
         interp_filter == TEMPORALFILTER_12TAP);
338
339
340
341
#else   // USE_EXTRA_FILTER
  assert(interp_filter <= SWITCHABLE_FILTERS ||
         interp_filter == TEMPORALFILTER_12TAP);
#endif  // USE_EXTRA_FILTER
342
343
344
#else
  assert(interp_filter <= EIGHTTAP_SHARP);
#endif
345
#if USE_EXTRA_FILTER
346
347
348
349
350
351
352
353
354
355
356
  if (plane == 0) {
    return interp_filter;
  } else {
    switch (interp_filter) {
      case EIGHTTAP_REGULAR: return FILTER_REGULAR_UV;
      case EIGHTTAP_SMOOTH: return FILTER_SMOOTH_UV;
      case MULTITAP_SHARP: return FILTER_SHARP_UV;
      case EIGHTTAP_SMOOTH2: return FILTER_SMOOTH2_UV;
      default: return interp_filter;
    }
  }
357
358
359
360
#else   // USE_EXTRA_FILTER
  (void)plane;
  return interp_filter;
#endif  // USE_EXTRA_FILTER
361
362
}
#endif