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 #include <assert.h>
13
14 #include "config/aom_dsp_rtcd.h"
15
16 #include "aom_dsp/mips/aom_convolve_msa.h"
17
common_vt_8t_4w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)18 static void common_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride,
19 uint8_t *dst, int32_t dst_stride,
20 int8_t *filter, int32_t height) {
21 uint32_t loop_cnt;
22 v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
23 v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r;
24 v16i8 src65_r, src87_r, src109_r, src2110, src4332, src6554, src8776;
25 v16i8 src10998, filt0, filt1, filt2, filt3;
26 v16u8 out;
27 v8i16 filt, out10, out32;
28
29 src -= (3 * src_stride);
30
31 filt = LD_SH(filter);
32 SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3);
33
34 LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6);
35 src += (7 * src_stride);
36
37 ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r,
38 src54_r, src21_r);
39 ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r);
40 ILVR_D3_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src2110,
41 src4332, src6554);
42 XORI_B3_128_SB(src2110, src4332, src6554);
43
44 for (loop_cnt = (height >> 2); loop_cnt--;) {
45 LD_SB4(src, src_stride, src7, src8, src9, src10);
46 src += (4 * src_stride);
47
48 ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r,
49 src87_r, src98_r, src109_r);
50 ILVR_D2_SB(src87_r, src76_r, src109_r, src98_r, src8776, src10998);
51 XORI_B2_128_SB(src8776, src10998);
52 out10 = FILT_8TAP_DPADD_S_H(src2110, src4332, src6554, src8776, filt0,
53 filt1, filt2, filt3);
54 out32 = FILT_8TAP_DPADD_S_H(src4332, src6554, src8776, src10998, filt0,
55 filt1, filt2, filt3);
56 SRARI_H2_SH(out10, out32, FILTER_BITS);
57 SAT_SH2_SH(out10, out32, 7);
58 out = PCKEV_XORI128_UB(out10, out32);
59 ST4x4_UB(out, out, 0, 1, 2, 3, dst, dst_stride);
60 dst += (4 * dst_stride);
61
62 src2110 = src6554;
63 src4332 = src8776;
64 src6554 = src10998;
65 src6 = src10;
66 }
67 }
68
common_vt_8t_8w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)69 static void common_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride,
70 uint8_t *dst, int32_t dst_stride,
71 int8_t *filter, int32_t height) {
72 uint32_t loop_cnt;
73 v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
74 v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r;
75 v16i8 src65_r, src87_r, src109_r, filt0, filt1, filt2, filt3;
76 v16u8 tmp0, tmp1;
77 v8i16 filt, out0_r, out1_r, out2_r, out3_r;
78
79 src -= (3 * src_stride);
80
81 filt = LD_SH(filter);
82 SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3);
83
84 LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6);
85 XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6);
86 src += (7 * src_stride);
87 ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r,
88 src54_r, src21_r);
89 ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r);
90
91 for (loop_cnt = (height >> 2); loop_cnt--;) {
92 LD_SB4(src, src_stride, src7, src8, src9, src10);
93 XORI_B4_128_SB(src7, src8, src9, src10);
94 src += (4 * src_stride);
95
96 ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r,
97 src87_r, src98_r, src109_r);
98 out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0,
99 filt1, filt2, filt3);
100 out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0,
101 filt1, filt2, filt3);
102 out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0,
103 filt1, filt2, filt3);
104 out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0,
105 filt1, filt2, filt3);
106 SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, FILTER_BITS);
107 SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
108 tmp0 = PCKEV_XORI128_UB(out0_r, out1_r);
109 tmp1 = PCKEV_XORI128_UB(out2_r, out3_r);
110 ST8x4_UB(tmp0, tmp1, dst, dst_stride);
111 dst += (4 * dst_stride);
112
113 src10_r = src54_r;
114 src32_r = src76_r;
115 src54_r = src98_r;
116 src21_r = src65_r;
117 src43_r = src87_r;
118 src65_r = src109_r;
119 src6 = src10;
120 }
121 }
122
common_vt_8t_16w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)123 static void common_vt_8t_16w_msa(const uint8_t *src, int32_t src_stride,
124 uint8_t *dst, int32_t dst_stride,
125 int8_t *filter, int32_t height) {
126 uint32_t loop_cnt;
127 v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
128 v16i8 filt0, filt1, filt2, filt3;
129 v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r;
130 v16i8 src65_r, src87_r, src109_r, src10_l, src32_l, src54_l, src76_l;
131 v16i8 src98_l, src21_l, src43_l, src65_l, src87_l, src109_l;
132 v16u8 tmp0, tmp1, tmp2, tmp3;
133 v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l;
134
135 src -= (3 * src_stride);
136
137 filt = LD_SH(filter);
138 SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3);
139
140 LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6);
141 XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6);
142 src += (7 * src_stride);
143 ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r,
144 src54_r, src21_r);
145 ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r);
146 ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_l, src32_l,
147 src54_l, src21_l);
148 ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l);
149
150 for (loop_cnt = (height >> 2); loop_cnt--;) {
151 LD_SB4(src, src_stride, src7, src8, src9, src10);
152 XORI_B4_128_SB(src7, src8, src9, src10);
153 src += (4 * src_stride);
154
155 ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r,
156 src87_r, src98_r, src109_r);
157 ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l,
158 src87_l, src98_l, src109_l);
159 out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0,
160 filt1, filt2, filt3);
161 out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0,
162 filt1, filt2, filt3);
163 out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0,
164 filt1, filt2, filt3);
165 out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0,
166 filt1, filt2, filt3);
167 out0_l = FILT_8TAP_DPADD_S_H(src10_l, src32_l, src54_l, src76_l, filt0,
168 filt1, filt2, filt3);
169 out1_l = FILT_8TAP_DPADD_S_H(src21_l, src43_l, src65_l, src87_l, filt0,
170 filt1, filt2, filt3);
171 out2_l = FILT_8TAP_DPADD_S_H(src32_l, src54_l, src76_l, src98_l, filt0,
172 filt1, filt2, filt3);
173 out3_l = FILT_8TAP_DPADD_S_H(src43_l, src65_l, src87_l, src109_l, filt0,
174 filt1, filt2, filt3);
175 SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, FILTER_BITS);
176 SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, FILTER_BITS);
177 SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
178 SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7);
179 PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l, out3_r,
180 tmp0, tmp1, tmp2, tmp3);
181 XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3);
182 ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride);
183 dst += (4 * dst_stride);
184
185 src10_r = src54_r;
186 src32_r = src76_r;
187 src54_r = src98_r;
188 src21_r = src65_r;
189 src43_r = src87_r;
190 src65_r = src109_r;
191 src10_l = src54_l;
192 src32_l = src76_l;
193 src54_l = src98_l;
194 src21_l = src65_l;
195 src43_l = src87_l;
196 src65_l = src109_l;
197 src6 = src10;
198 }
199 }
200
common_vt_8t_16w_mult_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height,int32_t width)201 static void common_vt_8t_16w_mult_msa(const uint8_t *src, int32_t src_stride,
202 uint8_t *dst, int32_t dst_stride,
203 int8_t *filter, int32_t height,
204 int32_t width) {
205 const uint8_t *src_tmp;
206 uint8_t *dst_tmp;
207 uint32_t loop_cnt, cnt;
208 v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
209 v16i8 filt0, filt1, filt2, filt3;
210 v16i8 src10_r, src32_r, src54_r, src76_r, src98_r, src21_r, src43_r;
211 v16i8 src65_r, src87_r, src109_r, src10_l, src32_l, src54_l, src76_l;
212 v16i8 src98_l, src21_l, src43_l, src65_l, src87_l, src109_l;
213 v16u8 tmp0, tmp1, tmp2, tmp3;
214 v8i16 filt, out0_r, out1_r, out2_r, out3_r, out0_l, out1_l, out2_l, out3_l;
215
216 src -= (3 * src_stride);
217
218 filt = LD_SH(filter);
219 SPLATI_H4_SB(filt, 0, 1, 2, 3, filt0, filt1, filt2, filt3);
220
221 for (cnt = (width >> 4); cnt--;) {
222 src_tmp = src;
223 dst_tmp = dst;
224
225 LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6);
226 XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6);
227 src_tmp += (7 * src_stride);
228 ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r,
229 src54_r, src21_r);
230 ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r);
231 ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_l, src32_l,
232 src54_l, src21_l);
233 ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l);
234
235 for (loop_cnt = (height >> 2); loop_cnt--;) {
236 LD_SB4(src_tmp, src_stride, src7, src8, src9, src10);
237 XORI_B4_128_SB(src7, src8, src9, src10);
238 src_tmp += (4 * src_stride);
239 ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r,
240 src87_r, src98_r, src109_r);
241 ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l,
242 src87_l, src98_l, src109_l);
243 out0_r = FILT_8TAP_DPADD_S_H(src10_r, src32_r, src54_r, src76_r, filt0,
244 filt1, filt2, filt3);
245 out1_r = FILT_8TAP_DPADD_S_H(src21_r, src43_r, src65_r, src87_r, filt0,
246 filt1, filt2, filt3);
247 out2_r = FILT_8TAP_DPADD_S_H(src32_r, src54_r, src76_r, src98_r, filt0,
248 filt1, filt2, filt3);
249 out3_r = FILT_8TAP_DPADD_S_H(src43_r, src65_r, src87_r, src109_r, filt0,
250 filt1, filt2, filt3);
251 out0_l = FILT_8TAP_DPADD_S_H(src10_l, src32_l, src54_l, src76_l, filt0,
252 filt1, filt2, filt3);
253 out1_l = FILT_8TAP_DPADD_S_H(src21_l, src43_l, src65_l, src87_l, filt0,
254 filt1, filt2, filt3);
255 out2_l = FILT_8TAP_DPADD_S_H(src32_l, src54_l, src76_l, src98_l, filt0,
256 filt1, filt2, filt3);
257 out3_l = FILT_8TAP_DPADD_S_H(src43_l, src65_l, src87_l, src109_l, filt0,
258 filt1, filt2, filt3);
259 SRARI_H4_SH(out0_r, out1_r, out2_r, out3_r, FILTER_BITS);
260 SRARI_H4_SH(out0_l, out1_l, out2_l, out3_l, FILTER_BITS);
261 SAT_SH4_SH(out0_r, out1_r, out2_r, out3_r, 7);
262 SAT_SH4_SH(out0_l, out1_l, out2_l, out3_l, 7);
263 PCKEV_B4_UB(out0_l, out0_r, out1_l, out1_r, out2_l, out2_r, out3_l,
264 out3_r, tmp0, tmp1, tmp2, tmp3);
265 XORI_B4_128_UB(tmp0, tmp1, tmp2, tmp3);
266 ST_UB4(tmp0, tmp1, tmp2, tmp3, dst_tmp, dst_stride);
267 dst_tmp += (4 * dst_stride);
268
269 src10_r = src54_r;
270 src32_r = src76_r;
271 src54_r = src98_r;
272 src21_r = src65_r;
273 src43_r = src87_r;
274 src65_r = src109_r;
275 src10_l = src54_l;
276 src32_l = src76_l;
277 src54_l = src98_l;
278 src21_l = src65_l;
279 src43_l = src87_l;
280 src65_l = src109_l;
281 src6 = src10;
282 }
283
284 src += 16;
285 dst += 16;
286 }
287 }
288
common_vt_8t_32w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)289 static void common_vt_8t_32w_msa(const uint8_t *src, int32_t src_stride,
290 uint8_t *dst, int32_t dst_stride,
291 int8_t *filter, int32_t height) {
292 common_vt_8t_16w_mult_msa(src, src_stride, dst, dst_stride, filter, height,
293 32);
294 }
295
common_vt_8t_64w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)296 static void common_vt_8t_64w_msa(const uint8_t *src, int32_t src_stride,
297 uint8_t *dst, int32_t dst_stride,
298 int8_t *filter, int32_t height) {
299 common_vt_8t_16w_mult_msa(src, src_stride, dst, dst_stride, filter, height,
300 64);
301 }
302
common_vt_2t_4x4_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter)303 static void common_vt_2t_4x4_msa(const uint8_t *src, int32_t src_stride,
304 uint8_t *dst, int32_t dst_stride,
305 int8_t *filter) {
306 v16i8 src0, src1, src2, src3, src4;
307 v16i8 src10_r, src32_r, src21_r, src43_r, src2110, src4332;
308 v16u8 filt0;
309 v8i16 filt;
310 v8u16 tmp0, tmp1;
311
312 filt = LD_SH(filter);
313 filt0 = (v16u8)__msa_splati_h(filt, 0);
314
315 LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
316
317 ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
318 src32_r, src43_r);
319 ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332);
320 DOTP_UB2_UH(src2110, src4332, filt0, filt0, tmp0, tmp1);
321 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
322 src2110 = __msa_pckev_b((v16i8)tmp1, (v16i8)tmp0);
323 ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride);
324 }
325
common_vt_2t_4x8_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter)326 static void common_vt_2t_4x8_msa(const uint8_t *src, int32_t src_stride,
327 uint8_t *dst, int32_t dst_stride,
328 int8_t *filter) {
329 v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
330 v16i8 src10_r, src32_r, src54_r, src76_r, src21_r, src43_r;
331 v16i8 src65_r, src87_r, src2110, src4332, src6554, src8776;
332 v8u16 tmp0, tmp1, tmp2, tmp3;
333 v16u8 filt0;
334 v8i16 filt;
335
336 filt = LD_SH(filter);
337 filt0 = (v16u8)__msa_splati_h(filt, 0);
338
339 LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7);
340 src += (8 * src_stride);
341
342 src8 = LD_SB(src);
343
344 ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
345 src32_r, src43_r);
346 ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r,
347 src76_r, src87_r);
348 ILVR_D4_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src87_r,
349 src76_r, src2110, src4332, src6554, src8776);
350 DOTP_UB4_UH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, filt0,
351 tmp0, tmp1, tmp2, tmp3);
352 SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, FILTER_BITS);
353 PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, src2110, src4332);
354 ST4x4_UB(src2110, src2110, 0, 1, 2, 3, dst, dst_stride);
355 ST4x4_UB(src4332, src4332, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
356 }
357
common_vt_2t_4w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)358 static void common_vt_2t_4w_msa(const uint8_t *src, int32_t src_stride,
359 uint8_t *dst, int32_t dst_stride,
360 int8_t *filter, int32_t height) {
361 if (4 == height) {
362 common_vt_2t_4x4_msa(src, src_stride, dst, dst_stride, filter);
363 } else if (8 == height) {
364 common_vt_2t_4x8_msa(src, src_stride, dst, dst_stride, filter);
365 }
366 }
367
common_vt_2t_8x4_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter)368 static void common_vt_2t_8x4_msa(const uint8_t *src, int32_t src_stride,
369 uint8_t *dst, int32_t dst_stride,
370 int8_t *filter) {
371 v16u8 src0, src1, src2, src3, src4, vec0, vec1, vec2, vec3, filt0;
372 v16i8 out0, out1;
373 v8u16 tmp0, tmp1, tmp2, tmp3;
374 v8i16 filt;
375
376 /* rearranging filter_y */
377 filt = LD_SH(filter);
378 filt0 = (v16u8)__msa_splati_h(filt, 0);
379
380 LD_UB5(src, src_stride, src0, src1, src2, src3, src4);
381 ILVR_B2_UB(src1, src0, src2, src1, vec0, vec1);
382 ILVR_B2_UB(src3, src2, src4, src3, vec2, vec3);
383 DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, tmp0, tmp1,
384 tmp2, tmp3);
385 SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, FILTER_BITS);
386 PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
387 ST8x4_UB(out0, out1, dst, dst_stride);
388 }
389
common_vt_2t_8x8mult_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)390 static void common_vt_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride,
391 uint8_t *dst, int32_t dst_stride,
392 int8_t *filter, int32_t height) {
393 uint32_t loop_cnt;
394 v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
395 v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
396 v16i8 out0, out1;
397 v8u16 tmp0, tmp1, tmp2, tmp3;
398 v8i16 filt;
399
400 /* rearranging filter_y */
401 filt = LD_SH(filter);
402 filt0 = (v16u8)__msa_splati_h(filt, 0);
403
404 src0 = LD_UB(src);
405 src += src_stride;
406
407 for (loop_cnt = (height >> 3); loop_cnt--;) {
408 LD_UB8(src, src_stride, src1, src2, src3, src4, src5, src6, src7, src8);
409 src += (8 * src_stride);
410
411 ILVR_B4_UB(src1, src0, src2, src1, src3, src2, src4, src3, vec0, vec1, vec2,
412 vec3);
413 ILVR_B4_UB(src5, src4, src6, src5, src7, src6, src8, src7, vec4, vec5, vec6,
414 vec7);
415 DOTP_UB4_UH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, tmp0, tmp1,
416 tmp2, tmp3);
417 SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, FILTER_BITS);
418 PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
419 ST8x4_UB(out0, out1, dst, dst_stride);
420 dst += (4 * dst_stride);
421
422 DOTP_UB4_UH(vec4, vec5, vec6, vec7, filt0, filt0, filt0, filt0, tmp0, tmp1,
423 tmp2, tmp3);
424 SRARI_H4_UH(tmp0, tmp1, tmp2, tmp3, FILTER_BITS);
425 PCKEV_B2_SB(tmp1, tmp0, tmp3, tmp2, out0, out1);
426 ST8x4_UB(out0, out1, dst, dst_stride);
427 dst += (4 * dst_stride);
428
429 src0 = src8;
430 }
431 }
432
common_vt_2t_8w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)433 static void common_vt_2t_8w_msa(const uint8_t *src, int32_t src_stride,
434 uint8_t *dst, int32_t dst_stride,
435 int8_t *filter, int32_t height) {
436 if (4 == height) {
437 common_vt_2t_8x4_msa(src, src_stride, dst, dst_stride, filter);
438 } else {
439 common_vt_2t_8x8mult_msa(src, src_stride, dst, dst_stride, filter, height);
440 }
441 }
442
common_vt_2t_16w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)443 static void common_vt_2t_16w_msa(const uint8_t *src, int32_t src_stride,
444 uint8_t *dst, int32_t dst_stride,
445 int8_t *filter, int32_t height) {
446 uint32_t loop_cnt;
447 v16u8 src0, src1, src2, src3, src4;
448 v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
449 v8u16 tmp0, tmp1, tmp2, tmp3;
450 v8i16 filt;
451
452 /* rearranging filter_y */
453 filt = LD_SH(filter);
454 filt0 = (v16u8)__msa_splati_h(filt, 0);
455
456 src0 = LD_UB(src);
457 src += src_stride;
458
459 for (loop_cnt = (height >> 2); loop_cnt--;) {
460 LD_UB4(src, src_stride, src1, src2, src3, src4);
461 src += (4 * src_stride);
462
463 ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2);
464 ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3);
465 DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
466 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
467 PCKEV_ST_SB(tmp0, tmp1, dst);
468 dst += dst_stride;
469
470 ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6);
471 ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7);
472 DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
473 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
474 PCKEV_ST_SB(tmp2, tmp3, dst);
475 dst += dst_stride;
476
477 DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1);
478 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
479 PCKEV_ST_SB(tmp0, tmp1, dst);
480 dst += dst_stride;
481
482 DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3);
483 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
484 PCKEV_ST_SB(tmp2, tmp3, dst);
485 dst += dst_stride;
486
487 src0 = src4;
488 }
489 }
490
common_vt_2t_32w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)491 static void common_vt_2t_32w_msa(const uint8_t *src, int32_t src_stride,
492 uint8_t *dst, int32_t dst_stride,
493 int8_t *filter, int32_t height) {
494 uint32_t loop_cnt;
495 v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9;
496 v16u8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
497 v8u16 tmp0, tmp1, tmp2, tmp3;
498 v8i16 filt;
499
500 /* rearranging filter_y */
501 filt = LD_SH(filter);
502 filt0 = (v16u8)__msa_splati_h(filt, 0);
503
504 src0 = LD_UB(src);
505 src5 = LD_UB(src + 16);
506 src += src_stride;
507
508 for (loop_cnt = (height >> 2); loop_cnt--;) {
509 LD_UB4(src, src_stride, src1, src2, src3, src4);
510 ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2);
511 ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3);
512
513 LD_UB4(src + 16, src_stride, src6, src7, src8, src9);
514 src += (4 * src_stride);
515
516 DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
517 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
518 PCKEV_ST_SB(tmp0, tmp1, dst);
519 DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
520 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
521 PCKEV_ST_SB(tmp2, tmp3, dst + dst_stride);
522
523 ILVR_B2_UB(src3, src2, src4, src3, vec4, vec6);
524 ILVL_B2_UB(src3, src2, src4, src3, vec5, vec7);
525 DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1);
526 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
527 PCKEV_ST_SB(tmp0, tmp1, dst + 2 * dst_stride);
528
529 DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3);
530 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
531 PCKEV_ST_SB(tmp2, tmp3, dst + 3 * dst_stride);
532
533 ILVR_B2_UB(src6, src5, src7, src6, vec0, vec2);
534 ILVL_B2_UB(src6, src5, src7, src6, vec1, vec3);
535 DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
536 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
537 PCKEV_ST_SB(tmp0, tmp1, dst + 16);
538
539 DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
540 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
541 PCKEV_ST_SB(tmp2, tmp3, dst + 16 + dst_stride);
542
543 ILVR_B2_UB(src8, src7, src9, src8, vec4, vec6);
544 ILVL_B2_UB(src8, src7, src9, src8, vec5, vec7);
545 DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp0, tmp1);
546 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
547 PCKEV_ST_SB(tmp0, tmp1, dst + 16 + 2 * dst_stride);
548
549 DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp2, tmp3);
550 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
551 PCKEV_ST_SB(tmp2, tmp3, dst + 16 + 3 * dst_stride);
552 dst += (4 * dst_stride);
553
554 src0 = src4;
555 src5 = src9;
556 }
557 }
558
common_vt_2t_64w_msa(const uint8_t * src,int32_t src_stride,uint8_t * dst,int32_t dst_stride,int8_t * filter,int32_t height)559 static void common_vt_2t_64w_msa(const uint8_t *src, int32_t src_stride,
560 uint8_t *dst, int32_t dst_stride,
561 int8_t *filter, int32_t height) {
562 uint32_t loop_cnt;
563 v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
564 v16u8 src11, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, filt0;
565 v8u16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
566 v8i16 filt;
567
568 /* rearranging filter_y */
569 filt = LD_SH(filter);
570 filt0 = (v16u8)__msa_splati_h(filt, 0);
571
572 LD_UB4(src, 16, src0, src3, src6, src9);
573 src += src_stride;
574
575 for (loop_cnt = (height >> 1); loop_cnt--;) {
576 LD_UB2(src, src_stride, src1, src2);
577 LD_UB2(src + 16, src_stride, src4, src5);
578 LD_UB2(src + 32, src_stride, src7, src8);
579 LD_UB2(src + 48, src_stride, src10, src11);
580 src += (2 * src_stride);
581
582 ILVR_B2_UB(src1, src0, src2, src1, vec0, vec2);
583 ILVL_B2_UB(src1, src0, src2, src1, vec1, vec3);
584 DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
585 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
586 PCKEV_ST_SB(tmp0, tmp1, dst);
587
588 DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
589 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
590 PCKEV_ST_SB(tmp2, tmp3, dst + dst_stride);
591
592 ILVR_B2_UB(src4, src3, src5, src4, vec4, vec6);
593 ILVL_B2_UB(src4, src3, src5, src4, vec5, vec7);
594 DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5);
595 SRARI_H2_UH(tmp4, tmp5, FILTER_BITS);
596 PCKEV_ST_SB(tmp4, tmp5, dst + 16);
597
598 DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7);
599 SRARI_H2_UH(tmp6, tmp7, FILTER_BITS);
600 PCKEV_ST_SB(tmp6, tmp7, dst + 16 + dst_stride);
601
602 ILVR_B2_UB(src7, src6, src8, src7, vec0, vec2);
603 ILVL_B2_UB(src7, src6, src8, src7, vec1, vec3);
604 DOTP_UB2_UH(vec0, vec1, filt0, filt0, tmp0, tmp1);
605 SRARI_H2_UH(tmp0, tmp1, FILTER_BITS);
606 PCKEV_ST_SB(tmp0, tmp1, dst + 32);
607
608 DOTP_UB2_UH(vec2, vec3, filt0, filt0, tmp2, tmp3);
609 SRARI_H2_UH(tmp2, tmp3, FILTER_BITS);
610 PCKEV_ST_SB(tmp2, tmp3, dst + 32 + dst_stride);
611
612 ILVR_B2_UB(src10, src9, src11, src10, vec4, vec6);
613 ILVL_B2_UB(src10, src9, src11, src10, vec5, vec7);
614 DOTP_UB2_UH(vec4, vec5, filt0, filt0, tmp4, tmp5);
615 SRARI_H2_UH(tmp4, tmp5, FILTER_BITS);
616 PCKEV_ST_SB(tmp4, tmp5, dst + 48);
617
618 DOTP_UB2_UH(vec6, vec7, filt0, filt0, tmp6, tmp7);
619 SRARI_H2_UH(tmp6, tmp7, FILTER_BITS);
620 PCKEV_ST_SB(tmp6, tmp7, dst + 48 + dst_stride);
621 dst += (2 * dst_stride);
622
623 src0 = src2;
624 src3 = src5;
625 src6 = src8;
626 src9 = src11;
627 }
628 }
629
aom_convolve8_vert_msa(const uint8_t * src,ptrdiff_t src_stride,uint8_t * dst,ptrdiff_t dst_stride,const int16_t * filter_x,int x_step_q4,const int16_t * filter_y,int y_step_q4,int w,int h)630 void aom_convolve8_vert_msa(const uint8_t *src, ptrdiff_t src_stride,
631 uint8_t *dst, ptrdiff_t dst_stride,
632 const int16_t *filter_x, int x_step_q4,
633 const int16_t *filter_y, int y_step_q4, int w,
634 int h) {
635 int8_t cnt, filt_ver[8];
636
637 assert(y_step_q4 == 16);
638 assert(((const int32_t *)filter_y)[1] != 0x800000);
639
640 for (cnt = 8; cnt--;) {
641 filt_ver[cnt] = filter_y[cnt];
642 }
643
644 if (((const int32_t *)filter_y)[0] == 0) {
645 switch (w) {
646 case 4:
647 common_vt_2t_4w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
648 &filt_ver[3], h);
649 break;
650 case 8:
651 common_vt_2t_8w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
652 &filt_ver[3], h);
653 break;
654 case 16:
655 common_vt_2t_16w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
656 &filt_ver[3], h);
657 break;
658 case 32:
659 common_vt_2t_32w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
660 &filt_ver[3], h);
661 break;
662 case 64:
663 common_vt_2t_64w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
664 &filt_ver[3], h);
665 break;
666 default:
667 aom_convolve8_vert_c(src, src_stride, dst, dst_stride, filter_x,
668 x_step_q4, filter_y, y_step_q4, w, h);
669 break;
670 }
671 } else {
672 switch (w) {
673 case 4:
674 common_vt_8t_4w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
675 filt_ver, h);
676 break;
677 case 8:
678 common_vt_8t_8w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
679 filt_ver, h);
680 break;
681 case 16:
682 common_vt_8t_16w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
683 filt_ver, h);
684 break;
685 case 32:
686 common_vt_8t_32w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
687 filt_ver, h);
688 break;
689 case 64:
690 common_vt_8t_64w_msa(src, (int32_t)src_stride, dst, (int32_t)dst_stride,
691 filt_ver, h);
692 break;
693 default:
694 aom_convolve8_vert_c(src, src_stride, dst, dst_stride, filter_x,
695 x_step_q4, filter_y, y_step_q4, w, h);
696 break;
697 }
698 }
699 }
700