blob: a7e67ea4ad88fbd2a6b6b6297a58975930e573a8 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -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
12#include <assert.h>
13
14#include "av1/common/filter.h"
15
16DECLARE_ALIGNED(256, static const InterpKernel,
17 bilinear_filters[SUBPEL_SHIFTS]) = {
18 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, 0, 120, 8, 0, 0, 0 },
19 { 0, 0, 0, 112, 16, 0, 0, 0 }, { 0, 0, 0, 104, 24, 0, 0, 0 },
20 { 0, 0, 0, 96, 32, 0, 0, 0 }, { 0, 0, 0, 88, 40, 0, 0, 0 },
21 { 0, 0, 0, 80, 48, 0, 0, 0 }, { 0, 0, 0, 72, 56, 0, 0, 0 },
22 { 0, 0, 0, 64, 64, 0, 0, 0 }, { 0, 0, 0, 56, 72, 0, 0, 0 },
23 { 0, 0, 0, 48, 80, 0, 0, 0 }, { 0, 0, 0, 40, 88, 0, 0, 0 },
24 { 0, 0, 0, 32, 96, 0, 0, 0 }, { 0, 0, 0, 24, 104, 0, 0, 0 },
25 { 0, 0, 0, 16, 112, 0, 0, 0 }, { 0, 0, 0, 8, 120, 0, 0, 0 }
26};
27
Yaowu Xuc27fc142016-08-22 16:08:15 -070028DECLARE_ALIGNED(256, static const InterpKernel,
29 sub_pel_filters_8[SUBPEL_SHIFTS]) = {
Arild Fuldseth7acfabb2016-08-26 14:08:58 +020030 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 2, -6, 126, 8, -2, 0, 0 },
31 { 0, 2, -10, 122, 18, -4, 0, 0 }, { 0, 2, -12, 116, 28, -8, 2, 0 },
32 { 0, 2, -14, 110, 38, -10, 2, 0 }, { 0, 2, -14, 102, 48, -12, 2, 0 },
33 { 0, 2, -16, 94, 58, -12, 2, 0 }, { 0, 2, -14, 84, 66, -12, 2, 0 },
34 { 0, 2, -14, 76, 76, -14, 2, 0 }, { 0, 2, -12, 66, 84, -14, 2, 0 },
35 { 0, 2, -12, 58, 94, -16, 2, 0 }, { 0, 2, -12, 48, 102, -14, 2, 0 },
36 { 0, 2, -10, 38, 110, -14, 2, 0 }, { 0, 2, -8, 28, 116, -12, 2, 0 },
37 { 0, 0, -4, 18, 122, -10, 2, 0 }, { 0, 0, -2, 8, 126, -6, 2, 0 }
Yaowu Xuc27fc142016-08-22 16:08:15 -070038};
39
40DECLARE_ALIGNED(256, static const InterpKernel,
41 sub_pel_filters_8sharp[SUBPEL_SHIFTS]) = {
Arild Fuldseth7acfabb2016-08-26 14:08:58 +020042 { 0, 0, 0, 128, 0, 0, 0, 0 }, { -2, 2, -6, 126, 8, -2, 2, 0 },
43 { -2, 6, -12, 124, 16, -6, 4, -2 }, { -2, 8, -18, 120, 26, -10, 6, -2 },
44 { -4, 10, -22, 116, 38, -14, 6, -2 }, { -4, 10, -22, 108, 48, -18, 8, -2 },
45 { -4, 10, -24, 100, 60, -20, 8, -2 }, { -4, 10, -24, 90, 70, -22, 10, -2 },
46 { -4, 12, -24, 80, 80, -24, 12, -4 }, { -2, 10, -22, 70, 90, -24, 10, -4 },
47 { -2, 8, -20, 60, 100, -24, 10, -4 }, { -2, 8, -18, 48, 108, -22, 10, -4 },
48 { -2, 6, -14, 38, 116, -22, 10, -4 }, { -2, 6, -10, 26, 120, -18, 8, -2 },
49 { -2, 4, -6, 16, 124, -12, 6, -2 }, { 0, 2, -2, 8, 126, -6, 2, -2 }
Yaowu Xuc27fc142016-08-22 16:08:15 -070050};
51
52DECLARE_ALIGNED(256, static const InterpKernel,
53 sub_pel_filters_8smooth[SUBPEL_SHIFTS]) = {
Arild Fuldseth7acfabb2016-08-26 14:08:58 +020054 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 2, 28, 62, 34, 2, 0, 0 },
55 { 0, 0, 26, 62, 36, 4, 0, 0 }, { 0, 0, 22, 62, 40, 4, 0, 0 },
56 { 0, 0, 20, 60, 42, 6, 0, 0 }, { 0, 0, 18, 58, 44, 8, 0, 0 },
57 { 0, 0, 16, 56, 46, 10, 0, 0 }, { 0, -2, 16, 54, 48, 12, 0, 0 },
58 { 0, -2, 14, 52, 52, 14, -2, 0 }, { 0, 0, 12, 48, 54, 16, -2, 0 },
59 { 0, 0, 10, 46, 56, 16, 0, 0 }, { 0, 0, 8, 44, 58, 18, 0, 0 },
60 { 0, 0, 6, 42, 60, 20, 0, 0 }, { 0, 0, 4, 40, 62, 22, 0, 0 },
61 { 0, 0, 4, 36, 62, 26, 0, 0 }, { 0, 0, 2, 34, 62, 28, 2, 0 }
Yaowu Xuc27fc142016-08-22 16:08:15 -070062};
Yaowu Xuc27fc142016-08-22 16:08:15 -070063
Yaowu Xuc27fc142016-08-22 16:08:15 -070064static const InterpFilterParams
Yaowu Xuf883b422016-08-30 14:01:10 -070065 av1_interp_filter_params_list[SWITCHABLE_FILTERS + 1] = {
Angie Chiangb9ba5c22016-10-03 16:39:27 -070066 { (const int16_t *)sub_pel_filters_8, SUBPEL_TAPS, SUBPEL_SHIFTS,
67 EIGHTTAP_REGULAR },
68 { (const int16_t *)sub_pel_filters_8smooth, SUBPEL_TAPS, SUBPEL_SHIFTS,
69 EIGHTTAP_SMOOTH },
70 { (const int16_t *)sub_pel_filters_8sharp, SUBPEL_TAPS, SUBPEL_SHIFTS,
71 MULTITAP_SHARP },
72 { (const int16_t *)bilinear_filters, SUBPEL_TAPS, SUBPEL_SHIFTS,
73 BILINEAR }
Yaowu Xuc27fc142016-08-22 16:08:15 -070074 };
Yaowu Xuc27fc142016-08-22 16:08:15 -070075
Zhijie Yangf02f8ae2017-10-26 17:58:29 -070076DECLARE_ALIGNED(256, static const InterpKernel,
77 sub_pel_filters_4[SUBPEL_SHIFTS]) = {
78 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, -4, 126, 8, -2, 0, 0 },
79 { 0, 0, -8, 122, 18, -4, 0, 0 }, { 0, 0, -10, 116, 28, -6, 0, 0 },
80 { 0, 0, -12, 110, 38, -8, 0, 0 }, { 0, 0, -12, 102, 48, -10, 0, 0 },
81 { 0, 0, -14, 94, 58, -10, 0, 0 }, { 0, 0, -12, 84, 66, -10, 0, 0 },
82 { 0, 0, -12, 76, 76, -12, 0, 0 }, { 0, 0, -10, 66, 84, -12, 0, 0 },
83 { 0, 0, -10, 58, 94, -14, 0, 0 }, { 0, 0, -10, 48, 102, -12, 0, 0 },
84 { 0, 0, -8, 38, 110, -12, 0, 0 }, { 0, 0, -6, 28, 116, -10, 0, 0 },
85 { 0, 0, -4, 18, 122, -8, 0, 0 }, { 0, 0, -2, 8, 126, -4, 0, 0 }
86};
87DECLARE_ALIGNED(256, static const InterpKernel,
88 sub_pel_filters_4smooth[SUBPEL_SHIFTS]) = {
89 { 0, 0, 0, 128, 0, 0, 0, 0 }, { 0, 0, 30, 62, 34, 2, 0, 0 },
90 { 0, 0, 26, 62, 36, 4, 0, 0 }, { 0, 0, 22, 62, 40, 4, 0, 0 },
91 { 0, 0, 20, 60, 42, 6, 0, 0 }, { 0, 0, 18, 58, 44, 8, 0, 0 },
92 { 0, 0, 16, 56, 46, 10, 0, 0 }, { 0, 0, 14, 54, 48, 12, 0, 0 },
93 { 0, 0, 12, 52, 52, 12, 0, 0 }, { 0, 0, 12, 48, 54, 14, 0, 0 },
94 { 0, 0, 10, 46, 56, 16, 0, 0 }, { 0, 0, 8, 44, 58, 18, 0, 0 },
95 { 0, 0, 6, 42, 60, 20, 0, 0 }, { 0, 0, 4, 40, 62, 22, 0, 0 },
96 { 0, 0, 4, 36, 62, 26, 0, 0 }, { 0, 0, 2, 34, 62, 30, 0, 0 }
97};
98
99static const InterpFilterParams av1_interp_4tap[2] = {
100 { (const int16_t *)sub_pel_filters_4, SUBPEL_TAPS, SUBPEL_SHIFTS,
Zhijie Yang728cdbe2017-11-13 17:08:48 -0800101 EIGHTTAP_REGULAR },
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700102 { (const int16_t *)sub_pel_filters_4smooth, SUBPEL_TAPS, SUBPEL_SHIFTS,
Zhijie Yang728cdbe2017-11-13 17:08:48 -0800103 EIGHTTAP_SMOOTH },
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700104};
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700105
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700106InterpFilterParams av1_get_interp_filter_params_with_block_size(
107 const InterpFilter interp_filter, const int w) {
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700108 if (w <= 4 &&
109 (interp_filter == MULTITAP_SHARP || interp_filter == EIGHTTAP_REGULAR))
110 return av1_interp_4tap[0];
111 else if (w <= 4 && interp_filter == EIGHTTAP_SMOOTH)
112 return av1_interp_4tap[1];
113
114 return av1_interp_filter_params_list[interp_filter];
115}
Zhijie Yangf02f8ae2017-10-26 17:58:29 -0700116
James Zern7b9407a2016-05-18 23:48:05 -0700117const int16_t *av1_get_interp_filter_kernel(const InterpFilter interp_filter) {
Yaowu Xuf883b422016-08-30 14:01:10 -0700118 return (const int16_t *)av1_interp_filter_params_list[interp_filter]
Yaowu Xuc27fc142016-08-22 16:08:15 -0700119 .filter_ptr;
120}