blob: d1b76bd5a7a43046bbef080afe0bcafd3ab4e954 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
James Zernb7c05bd2024-06-11 19:15:10 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AV1_COMMON_FILTER_H_
13#define AOM_AV1_COMMON_FILTER_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Rupert Swarbrick27e90292017-09-28 17:46:50 +010015#include <assert.h>
16
Tom Finegan60e653d2018-05-22 11:34:58 -070017#include "config/aom_config.h"
18
Yaowu Xuf883b422016-08-30 14:01:10 -070019#include "aom/aom_integer.h"
20#include "aom_dsp/aom_filter.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070021#include "aom_ports/mem.h"
Satish Kumar Suman8487e952019-07-22 12:55:08 +053022#include "av1/common/enums.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070023
24#ifdef __cplusplus
25extern "C" {
26#endif
27
Visheshcf97e602020-12-16 12:47:21 +053028#define MAX_FILTER_TAP 12
Jingning Hanb14c1792017-04-20 15:10:29 -070029
Urvang Joshif5f5c842017-10-19 16:17:54 -070030typedef enum ATTRIBUTE_PACKED {
Urvang Joshia9b174b2017-02-17 11:50:12 -080031 EIGHTTAP_REGULAR,
32 EIGHTTAP_SMOOTH,
Thomas Daviesec92c112017-09-25 11:03:58 +010033 MULTITAP_SHARP,
Urvang Joshia9b174b2017-02-17 11:50:12 -080034 BILINEAR,
Yunqing Wang144a9412020-10-16 01:25:46 -070035 // Encoder side only filters
36 MULTITAP_SHARP2,
37
Urvang Joshia9b174b2017-02-17 11:50:12 -080038 INTERP_FILTERS_ALL,
39 SWITCHABLE_FILTERS = BILINEAR,
40 SWITCHABLE = SWITCHABLE_FILTERS + 1, /* the last switchable one */
41 EXTRA_FILTERS = INTERP_FILTERS_ALL - SWITCHABLE_FILTERS,
Sachin Kumar Gargf0381102019-06-18 19:17:20 +053042 INTERP_INVALID = 0xff,
Urvang Joshia9b174b2017-02-17 11:50:12 -080043} InterpFilter;
Yaowu Xuc27fc142016-08-22 16:08:15 -070044
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053045enum {
Yunqing Wang91c9b2e2018-09-11 16:13:49 -070046 USE_2_TAPS_ORIG = 0, // This is used in temporal filtering.
47 USE_2_TAPS,
48 USE_4_TAPS,
49 USE_8_TAPS,
Satish Kumar Suman4667aa12018-12-14 18:28:19 +053050} UENUM1BYTE(SUBPEL_SEARCH_TYPE);
Yunqing Wang91c9b2e2018-09-11 16:13:49 -070051
Venkatbf0b45a2019-07-05 10:09:35 +053052enum {
53 INTERP_EVAL_LUMA_EVAL_CHROMA = 0,
54 INTERP_SKIP_LUMA_EVAL_CHROMA,
55 INTERP_EVAL_INVALID,
56 INTERP_SKIP_LUMA_SKIP_CHROMA,
57} UENUM1BYTE(INTERP_EVAL_PLANE);
58
Venkatdc2fe7f2019-07-16 19:24:55 +053059enum {
60 INTERP_HORZ_NEQ_VERT_NEQ = 0,
61 INTERP_HORZ_EQ_VERT_NEQ,
62 INTERP_HORZ_NEQ_VERT_EQ,
63 INTERP_HORZ_EQ_VERT_EQ,
Satish Kumar Suman8487e952019-07-22 12:55:08 +053064 INTERP_PRED_TYPE_ALL,
Venkatdc2fe7f2019-07-16 19:24:55 +053065} UENUM1BYTE(INTERP_PRED_TYPE);
Yue Chene6fefb52018-10-24 16:23:39 -070066// Pack two InterpFilter's into a uint32_t: since there are at most 10 filters,
67// we can use 16 bits for each and have more than enough space. This reduces
68// argument passing and unifies the operation of setting a (pair of) filters.
Ravi Chaudhary1e4f94b2019-06-20 16:19:49 +053069typedef struct InterpFilters {
70 uint16_t y_filter;
71 uint16_t x_filter;
72} InterpFilters;
73
74typedef union int_interpfilters {
75 uint32_t as_int;
76 InterpFilters as_filters;
77} int_interpfilters;
78
Wan-Teh Chang12c64e82024-08-08 16:02:19 -070079static inline InterpFilter av1_extract_interp_filter(int_interpfilters filters,
Ravi Chaudhary1e4f94b2019-06-20 16:19:49 +053080 int dir) {
81 return (InterpFilter)((dir) ? filters.as_filters.x_filter
82 : filters.as_filters.y_filter);
Rupert Swarbrick27e90292017-09-28 17:46:50 +010083}
84
Wan-Teh Chang12c64e82024-08-08 16:02:19 -070085static inline int_interpfilters av1_broadcast_interp_filter(
86 InterpFilter filter) {
Ravi Chaudhary1e4f94b2019-06-20 16:19:49 +053087 int_interpfilters filters;
88 filters.as_filters.x_filter = filter;
89 filters.as_filters.y_filter = filter;
90 return filters;
Rupert Swarbrick27e90292017-09-28 17:46:50 +010091}
Rupert Swarbrick27e90292017-09-28 17:46:50 +010092
Wan-Teh Chang12c64e82024-08-08 16:02:19 -070093static inline InterpFilter av1_unswitchable_filter(InterpFilter filter) {
Rupert Swarbrick27e90292017-09-28 17:46:50 +010094 return filter == SWITCHABLE ? EIGHTTAP_REGULAR : filter;
95}
96
Peng Bin3a0c2ed2018-07-19 16:24:00 +080097/* (1 << LOG_SWITCHABLE_FILTERS) > SWITCHABLE_FILTERS */
98#define LOG_SWITCHABLE_FILTERS 2
Frederic Barbier7b35d733e2017-07-11 17:32:39 +020099
Angie Chiang1733f6b2017-01-05 09:52:20 -0800100#define SWITCHABLE_FILTER_CONTEXTS ((SWITCHABLE_FILTERS + 1) * 4)
101#define INTER_FILTER_COMP_OFFSET (SWITCHABLE_FILTERS + 1)
102#define INTER_FILTER_DIR_OFFSET ((SWITCHABLE_FILTERS + 1) * 2)
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530103#define ALLOW_ALL_INTERP_FILT_MASK (0x01ff)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700104
Yaowu Xuc27fc142016-08-22 16:08:15 -0700105typedef struct InterpFilterParams {
106 const int16_t *filter_ptr;
107 uint16_t taps;
Angie Chiangb9ba5c22016-10-03 16:39:27 -0700108 InterpFilter interp_filter;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700109} InterpFilterParams;
110
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800111DECLARE_ALIGNED(256, static const InterpKernel,
112 av1_bilinear_filters[SUBPEL_SHIFTS]) = {
113 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, 0, 120, 8, 0, 0, 0 },
114 { 0, 0, 0, 112, 16, 0, 0, 0 }, { 0, 0, 0, 104, 24, 0, 0, 0 },
115 { 0, 0, 0, 96, 32, 0, 0, 0 }, { 0, 0, 0, 88, 40, 0, 0, 0 },
116 { 0, 0, 0, 80, 48, 0, 0, 0 }, { 0, 0, 0, 72, 56, 0, 0, 0 },
117 { 0, 0, 0, 64, 64, 0, 0, 0 }, { 0, 0, 0, 56, 72, 0, 0, 0 },
118 { 0, 0, 0, 48, 80, 0, 0, 0 }, { 0, 0, 0, 40, 88, 0, 0, 0 },
119 { 0, 0, 0, 32, 96, 0, 0, 0 }, { 0, 0, 0, 24, 104, 0, 0, 0 },
120 { 0, 0, 0, 16, 112, 0, 0, 0 }, { 0, 0, 0, 8, 120, 0, 0, 0 }
121};
Yaowu Xuc27fc142016-08-22 16:08:15 -0700122
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800123DECLARE_ALIGNED(256, static const InterpKernel,
124 av1_sub_pel_filters_8[SUBPEL_SHIFTS]) = {
125 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 2, -6, 126, 8, -2, 0, 0 },
126 { 0, 2, -10, 122, 18, -4, 0, 0 }, { 0, 2, -12, 116, 28, -8, 2, 0 },
127 { 0, 2, -14, 110, 38, -10, 2, 0 }, { 0, 2, -14, 102, 48, -12, 2, 0 },
128 { 0, 2, -16, 94, 58, -12, 2, 0 }, { 0, 2, -14, 84, 66, -12, 2, 0 },
129 { 0, 2, -14, 76, 76, -14, 2, 0 }, { 0, 2, -12, 66, 84, -14, 2, 0 },
130 { 0, 2, -12, 58, 94, -16, 2, 0 }, { 0, 2, -12, 48, 102, -14, 2, 0 },
131 { 0, 2, -10, 38, 110, -14, 2, 0 }, { 0, 2, -8, 28, 116, -12, 2, 0 },
132 { 0, 0, -4, 18, 122, -10, 2, 0 }, { 0, 0, -2, 8, 126, -6, 2, 0 }
133};
134
135DECLARE_ALIGNED(256, static const InterpKernel,
136 av1_sub_pel_filters_8sharp[SUBPEL_SHIFTS]) = {
137 { 0, 0, 0, 128, 0, 0, 0, 0 }, { -2, 2, -6, 126, 8, -2, 2, 0 },
138 { -2, 6, -12, 124, 16, -6, 4, -2 }, { -2, 8, -18, 120, 26, -10, 6, -2 },
139 { -4, 10, -22, 116, 38, -14, 6, -2 }, { -4, 10, -22, 108, 48, -18, 8, -2 },
140 { -4, 10, -24, 100, 60, -20, 8, -2 }, { -4, 10, -24, 90, 70, -22, 10, -2 },
141 { -4, 12, -24, 80, 80, -24, 12, -4 }, { -2, 10, -22, 70, 90, -24, 10, -4 },
142 { -2, 8, -20, 60, 100, -24, 10, -4 }, { -2, 8, -18, 48, 108, -22, 10, -4 },
143 { -2, 6, -14, 38, 116, -22, 10, -4 }, { -2, 6, -10, 26, 120, -18, 8, -2 },
144 { -2, 4, -6, 16, 124, -12, 6, -2 }, { 0, 2, -2, 8, 126, -6, 2, -2 }
145};
146
147DECLARE_ALIGNED(256, static const InterpKernel,
148 av1_sub_pel_filters_8smooth[SUBPEL_SHIFTS]) = {
149 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 2, 28, 62, 34, 2, 0, 0 },
150 { 0, 0, 26, 62, 36, 4, 0, 0 }, { 0, 0, 22, 62, 40, 4, 0, 0 },
151 { 0, 0, 20, 60, 42, 6, 0, 0 }, { 0, 0, 18, 58, 44, 8, 0, 0 },
152 { 0, 0, 16, 56, 46, 10, 0, 0 }, { 0, -2, 16, 54, 48, 12, 0, 0 },
153 { 0, -2, 14, 52, 52, 14, -2, 0 }, { 0, 0, 12, 48, 54, 16, -2, 0 },
154 { 0, 0, 10, 46, 56, 16, 0, 0 }, { 0, 0, 8, 44, 58, 18, 0, 0 },
155 { 0, 0, 6, 42, 60, 20, 0, 0 }, { 0, 0, 4, 40, 62, 22, 0, 0 },
156 { 0, 0, 4, 36, 62, 26, 0, 0 }, { 0, 0, 2, 34, 62, 28, 2, 0 }
157};
158
Yunqing Wang144a9412020-10-16 01:25:46 -0700159DECLARE_ALIGNED(256, static const int16_t,
160 av1_sub_pel_filters_12sharp[SUBPEL_SHIFTS][12]) = {
161 { 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 },
162 { 0, 1, -2, 3, -7, 127, 8, -4, 2, -1, 1, 0 },
163 { -1, 2, -3, 6, -13, 124, 18, -8, 4, -2, 2, -1 },
164 { -1, 3, -4, 8, -18, 120, 28, -12, 7, -4, 2, -1 },
165 { -1, 3, -6, 10, -21, 115, 38, -15, 8, -5, 3, -1 },
166 { -2, 4, -6, 12, -24, 108, 49, -18, 10, -6, 3, -2 },
167 { -2, 4, -7, 13, -25, 100, 60, -21, 11, -7, 4, -2 },
168 { -2, 4, -7, 13, -26, 91, 71, -24, 13, -7, 4, -2 },
169 { -2, 4, -7, 13, -25, 81, 81, -25, 13, -7, 4, -2 },
170 { -2, 4, -7, 13, -24, 71, 91, -26, 13, -7, 4, -2 },
171 { -2, 4, -7, 11, -21, 60, 100, -25, 13, -7, 4, -2 },
172 { -2, 3, -6, 10, -18, 49, 108, -24, 12, -6, 4, -2 },
173 { -1, 3, -5, 8, -15, 38, 115, -21, 10, -6, 3, -1 },
174 { -1, 2, -4, 7, -12, 28, 120, -18, 8, -4, 3, -1 },
175 { -1, 2, -2, 4, -8, 18, 124, -13, 6, -3, 2, -1 },
176 { 0, 1, -1, 2, -4, 8, 127, -7, 3, -2, 1, 0 }
177};
178
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800179static const InterpFilterParams
Yunqing Wang144a9412020-10-16 01:25:46 -0700180 av1_interp_filter_params_list[INTERP_FILTERS_ALL] = {
Elliott Karpilovsky62967242020-04-20 18:01:59 -0700181 { (const int16_t *)av1_sub_pel_filters_8, SUBPEL_TAPS, EIGHTTAP_REGULAR },
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800182 { (const int16_t *)av1_sub_pel_filters_8smooth, SUBPEL_TAPS,
Elliott Karpilovsky62967242020-04-20 18:01:59 -0700183 EIGHTTAP_SMOOTH },
184 { (const int16_t *)av1_sub_pel_filters_8sharp, SUBPEL_TAPS,
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800185 MULTITAP_SHARP },
Yunqing Wang144a9412020-10-16 01:25:46 -0700186 { (const int16_t *)av1_bilinear_filters, SUBPEL_TAPS, BILINEAR },
187
188 // The following filters are for encoder only, and now they are used in
189 // temporal filtering. The predictor block size >= 16 in temporal filter.
190 { (const int16_t *)av1_sub_pel_filters_12sharp, 12, MULTITAP_SHARP2 },
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800191 };
192
Hui Sud547fa62018-09-06 16:13:58 -0700193// A special 2-tap bilinear filter for IntraBC chroma. IntraBC uses full pixel
194// MV for luma. If sub-sampling exists, chroma may possibly use half-pel MV.
James Zern406ed722022-09-23 14:00:11 -0700195DECLARE_ALIGNED(256, static const int16_t,
196 av1_intrabc_bilinear_filter[2 * SUBPEL_SHIFTS]) = {
197 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
198 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Hui Sud547fa62018-09-06 16:13:58 -0700199};
200
201static const InterpFilterParams av1_intrabc_filter_params = {
James Zern406ed722022-09-23 14:00:11 -0700202 av1_intrabc_bilinear_filter, 2, BILINEAR
Hui Sud547fa62018-09-06 16:13:58 -0700203};
204
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800205DECLARE_ALIGNED(256, static const InterpKernel,
206 av1_sub_pel_filters_4[SUBPEL_SHIFTS]) = {
207 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, -4, 126, 8, -2, 0, 0 },
208 { 0, 0, -8, 122, 18, -4, 0, 0 }, { 0, 0, -10, 116, 28, -6, 0, 0 },
209 { 0, 0, -12, 110, 38, -8, 0, 0 }, { 0, 0, -12, 102, 48, -10, 0, 0 },
210 { 0, 0, -14, 94, 58, -10, 0, 0 }, { 0, 0, -12, 84, 66, -10, 0, 0 },
211 { 0, 0, -12, 76, 76, -12, 0, 0 }, { 0, 0, -10, 66, 84, -12, 0, 0 },
212 { 0, 0, -10, 58, 94, -14, 0, 0 }, { 0, 0, -10, 48, 102, -12, 0, 0 },
213 { 0, 0, -8, 38, 110, -12, 0, 0 }, { 0, 0, -6, 28, 116, -10, 0, 0 },
214 { 0, 0, -4, 18, 122, -8, 0, 0 }, { 0, 0, -2, 8, 126, -4, 0, 0 }
215};
216DECLARE_ALIGNED(256, static const InterpKernel,
217 av1_sub_pel_filters_4smooth[SUBPEL_SHIFTS]) = {
218 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, 30, 62, 34, 2, 0, 0 },
219 { 0, 0, 26, 62, 36, 4, 0, 0 }, { 0, 0, 22, 62, 40, 4, 0, 0 },
220 { 0, 0, 20, 60, 42, 6, 0, 0 }, { 0, 0, 18, 58, 44, 8, 0, 0 },
221 { 0, 0, 16, 56, 46, 10, 0, 0 }, { 0, 0, 14, 54, 48, 12, 0, 0 },
222 { 0, 0, 12, 52, 52, 12, 0, 0 }, { 0, 0, 12, 48, 54, 14, 0, 0 },
223 { 0, 0, 10, 46, 56, 16, 0, 0 }, { 0, 0, 8, 44, 58, 18, 0, 0 },
224 { 0, 0, 6, 42, 60, 20, 0, 0 }, { 0, 0, 4, 40, 62, 22, 0, 0 },
225 { 0, 0, 4, 36, 62, 26, 0, 0 }, { 0, 0, 2, 34, 62, 30, 0, 0 }
226};
227
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530228static const uint16_t
229 av1_interp_dual_filt_mask[INTERP_PRED_TYPE_ALL - 2][SWITCHABLE_FILTERS] = {
230 { (1 << REG_REG) | (1 << SMOOTH_REG) | (1 << SHARP_REG),
231 (1 << REG_SMOOTH) | (1 << SMOOTH_SMOOTH) | (1 << SHARP_SMOOTH),
232 (1 << REG_SHARP) | (1 << SMOOTH_SHARP) | (1 << SHARP_SHARP) },
233 { (1 << REG_REG) | (1 << REG_SMOOTH) | (1 << REG_SHARP),
234 (1 << SMOOTH_REG) | (1 << SMOOTH_SMOOTH) | (1 << SMOOTH_SHARP),
235 (1 << SHARP_REG) | (1 << SHARP_SMOOTH) | (1 << SHARP_SHARP) }
236 };
237
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800238// For w<=4, MULTITAP_SHARP is the same as EIGHTTAP_REGULAR
239static const InterpFilterParams av1_interp_4tap[SWITCHABLE_FILTERS + 1] = {
Elliott Karpilovsky62967242020-04-20 18:01:59 -0700240 { (const int16_t *)av1_sub_pel_filters_4, SUBPEL_TAPS, EIGHTTAP_REGULAR },
241 { (const int16_t *)av1_sub_pel_filters_4smooth, SUBPEL_TAPS,
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800242 EIGHTTAP_SMOOTH },
Elliott Karpilovsky62967242020-04-20 18:01:59 -0700243 { (const int16_t *)av1_sub_pel_filters_4, SUBPEL_TAPS, EIGHTTAP_REGULAR },
244 { (const int16_t *)av1_bilinear_filters, SUBPEL_TAPS, BILINEAR },
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800245};
246
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700247static inline const InterpFilterParams *
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800248av1_get_interp_filter_params_with_block_size(const InterpFilter interp_filter,
249 const int w) {
Vishesh2ceec5a2020-12-02 13:05:12 +0530250 if (w <= 4 && interp_filter != MULTITAP_SHARP2)
251 return &av1_interp_4tap[interp_filter];
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800252 return &av1_interp_filter_params_list[interp_filter];
253}
254
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700255static inline const int16_t *av1_get_interp_filter_kernel(
Sachin Kumar Garg8048e8c2018-10-10 18:48:44 +0530256 const InterpFilter interp_filter, int subpel_search) {
257 assert(subpel_search >= USE_2_TAPS);
258 return (subpel_search == USE_2_TAPS)
259 ? av1_interp_4tap[BILINEAR].filter_ptr
260 : ((subpel_search == USE_4_TAPS)
261 ? av1_interp_4tap[interp_filter].filter_ptr
262 : av1_interp_filter_params_list[interp_filter].filter_ptr);
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800263}
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700264
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700265static inline const int16_t *av1_get_interp_filter_subpel_kernel(
Peng Bin3a0c2ed2018-07-19 16:24:00 +0800266 const InterpFilterParams *const filter_params, const int subpel) {
267 return filter_params->filter_ptr + filter_params->taps * subpel;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700268}
269
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700270static inline const InterpFilterParams *av1_get_filter(int subpel_search) {
Yunqing Wang91c9b2e2018-09-11 16:13:49 -0700271 assert(subpel_search >= USE_2_TAPS);
Yunqing Wangdca41c02018-10-29 15:39:07 -0700272
273 switch (subpel_search) {
Yunqing Wang65d659932020-04-01 12:26:00 -0700274 case USE_2_TAPS: return &av1_interp_4tap[BILINEAR];
275 case USE_4_TAPS: return &av1_interp_4tap[EIGHTTAP_REGULAR];
Yunqing Wangdca41c02018-10-29 15:39:07 -0700276 case USE_8_TAPS: return &av1_interp_filter_params_list[EIGHTTAP_REGULAR];
277 default: assert(0); return NULL;
278 }
Yunqing Wang91c9b2e2018-09-11 16:13:49 -0700279}
280
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700281static inline void reset_interp_filter_allowed_mask(
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530282 uint16_t *allow_interp_mask, DUAL_FILTER_TYPE filt_type) {
Hien Hof08b1a52019-08-29 13:50:01 -0700283 uint16_t tmp = (~(1 << filt_type)) & 0xffff;
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530284 *allow_interp_mask &= (tmp & ALLOW_ALL_INTERP_FILT_MASK);
285}
286
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700287static inline void set_interp_filter_allowed_mask(uint16_t *allow_interp_mask,
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530288 DUAL_FILTER_TYPE filt_type) {
289 *allow_interp_mask |= (1 << filt_type);
290}
291
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700292static inline uint8_t get_interp_filter_allowed_mask(
Satish Kumar Suman8487e952019-07-22 12:55:08 +0530293 uint16_t allow_interp_mask, DUAL_FILTER_TYPE filt_type) {
294 return (allow_interp_mask >> filt_type) & 1;
295}
296
Wan-Teh Chang94534432024-08-08 20:29:57 -0700297static inline int get_filter_tap(const InterpFilterParams *const filter_params,
298 int subpel_qn) {
chiyotsai59719602022-09-07 13:16:54 -0700299 const int16_t *const filter = av1_get_interp_filter_subpel_kernel(
300 filter_params, subpel_qn & SUBPEL_MASK);
301 if (filter_params->taps == 12) {
302 return 12;
303 }
304 if (filter[0] | filter[7]) {
305 return 8;
306 }
307 if (filter[1] | filter[6]) {
308 return 6;
309 }
Wan-Teh Changdc8a6892024-08-13 15:48:28 -0700310#if CONFIG_SVT_AV1
chiyotsai59719602022-09-07 13:16:54 -0700311 if (filter[2] | filter[5]) {
312 return 4;
313 }
314 return 2;
Wan-Teh Changdc8a6892024-08-13 15:48:28 -0700315#else
316 return 4;
317#endif
chiyotsai59719602022-09-07 13:16:54 -0700318}
319
Yaowu Xuc27fc142016-08-22 16:08:15 -0700320#ifdef __cplusplus
321} // extern "C"
322#endif
323
James Zerne1cbb132018-08-22 14:10:36 -0700324#endif // AOM_AV1_COMMON_FILTER_H_