1 /*
2  *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "./vpx_dsp_rtcd.h"
12 #include "vpx_dsp/mips/inv_txfm_msa.h"
13 
vpx_idct16_1d_rows_msa(const int16_t * input,int16_t * output)14 void vpx_idct16_1d_rows_msa(const int16_t *input, int16_t *output) {
15   v8i16 loc0, loc1, loc2, loc3;
16   v8i16 reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14;
17   v8i16 reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15;
18   v8i16 tmp5, tmp6, tmp7;
19 
20   LD_SH8(input, 16, reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7);
21   input += 8;
22   LD_SH8(input, 16, reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15);
23 
24   TRANSPOSE8x8_SH_SH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg0, reg1,
25                      reg2, reg3, reg4, reg5, reg6, reg7);
26   TRANSPOSE8x8_SH_SH(reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15, reg8,
27                      reg9, reg10, reg11, reg12, reg13, reg14, reg15);
28   DOTP_CONST_PAIR(reg2, reg14, cospi_28_64, cospi_4_64, reg2, reg14);
29   DOTP_CONST_PAIR(reg10, reg6, cospi_12_64, cospi_20_64, reg10, reg6);
30   BUTTERFLY_4(reg2, reg14, reg6, reg10, loc0, loc1, reg14, reg2);
31   DOTP_CONST_PAIR(reg14, reg2, cospi_16_64, cospi_16_64, loc2, loc3);
32   DOTP_CONST_PAIR(reg0, reg8, cospi_16_64, cospi_16_64, reg0, reg8);
33   DOTP_CONST_PAIR(reg4, reg12, cospi_24_64, cospi_8_64, reg4, reg12);
34   BUTTERFLY_4(reg8, reg0, reg4, reg12, reg2, reg6, reg10, reg14);
35   SUB4(reg2, loc1, reg14, loc0, reg6, loc3, reg10, loc2, reg0, reg12, reg4,
36        reg8);
37   ADD4(reg2, loc1, reg14, loc0, reg6, loc3, reg10, loc2, reg2, reg14, reg6,
38        reg10);
39 
40   /* stage 2 */
41   DOTP_CONST_PAIR(reg1, reg15, cospi_30_64, cospi_2_64, reg1, reg15);
42   DOTP_CONST_PAIR(reg9, reg7, cospi_14_64, cospi_18_64, loc2, loc3);
43 
44   reg9 = reg1 - loc2;
45   reg1 = reg1 + loc2;
46   reg7 = reg15 - loc3;
47   reg15 = reg15 + loc3;
48 
49   DOTP_CONST_PAIR(reg5, reg11, cospi_22_64, cospi_10_64, reg5, reg11);
50   DOTP_CONST_PAIR(reg13, reg3, cospi_6_64, cospi_26_64, loc0, loc1);
51   BUTTERFLY_4(loc0, loc1, reg11, reg5, reg13, reg3, reg11, reg5);
52 
53   loc1 = reg15 + reg3;
54   reg3 = reg15 - reg3;
55   loc2 = reg2 + loc1;
56   reg15 = reg2 - loc1;
57 
58   loc1 = reg1 + reg13;
59   reg13 = reg1 - reg13;
60   loc0 = reg0 + loc1;
61   loc1 = reg0 - loc1;
62   tmp6 = loc0;
63   tmp7 = loc1;
64   reg0 = loc2;
65 
66   DOTP_CONST_PAIR(reg7, reg9, cospi_24_64, cospi_8_64, reg7, reg9);
67   DOTP_CONST_PAIR((-reg5), (-reg11), cospi_8_64, cospi_24_64, reg5, reg11);
68 
69   loc0 = reg9 + reg5;
70   reg5 = reg9 - reg5;
71   reg2 = reg6 + loc0;
72   reg1 = reg6 - loc0;
73 
74   loc0 = reg7 + reg11;
75   reg11 = reg7 - reg11;
76   loc1 = reg4 + loc0;
77   loc2 = reg4 - loc0;
78   tmp5 = loc1;
79 
80   DOTP_CONST_PAIR(reg5, reg11, cospi_16_64, cospi_16_64, reg5, reg11);
81   BUTTERFLY_4(reg8, reg10, reg11, reg5, loc0, reg4, reg9, loc1);
82 
83   reg10 = loc0;
84   reg11 = loc1;
85 
86   DOTP_CONST_PAIR(reg3, reg13, cospi_16_64, cospi_16_64, reg3, reg13);
87   BUTTERFLY_4(reg12, reg14, reg13, reg3, reg8, reg6, reg7, reg5);
88 
89   reg13 = loc2;
90 
91   /* Transpose and store the output */
92   reg12 = tmp5;
93   reg14 = tmp6;
94   reg3 = tmp7;
95 
96   /* transpose block */
97   TRANSPOSE8x8_SH_SH(reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14, reg0,
98                      reg2, reg4, reg6, reg8, reg10, reg12, reg14);
99   ST_SH8(reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14, output, 16);
100 
101   /* transpose block */
102   TRANSPOSE8x8_SH_SH(reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15, reg3,
103                      reg13, reg11, reg5, reg7, reg9, reg1, reg15);
104   ST_SH8(reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15, (output + 8), 16);
105 }
106 
vpx_idct16_1d_columns_addblk_msa(int16_t * input,uint8_t * dst,int32_t dst_stride)107 void vpx_idct16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst,
108                                       int32_t dst_stride) {
109   v8i16 loc0, loc1, loc2, loc3;
110   v8i16 reg0, reg2, reg4, reg6, reg8, reg10, reg12, reg14;
111   v8i16 reg3, reg13, reg11, reg5, reg7, reg9, reg1, reg15;
112   v8i16 tmp5, tmp6, tmp7;
113 
114   /* load up 8x8 */
115   LD_SH8(input, 16, reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7);
116   input += 8 * 16;
117   /* load bottom 8x8 */
118   LD_SH8(input, 16, reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15);
119 
120   DOTP_CONST_PAIR(reg2, reg14, cospi_28_64, cospi_4_64, reg2, reg14);
121   DOTP_CONST_PAIR(reg10, reg6, cospi_12_64, cospi_20_64, reg10, reg6);
122   BUTTERFLY_4(reg2, reg14, reg6, reg10, loc0, loc1, reg14, reg2);
123   DOTP_CONST_PAIR(reg14, reg2, cospi_16_64, cospi_16_64, loc2, loc3);
124   DOTP_CONST_PAIR(reg0, reg8, cospi_16_64, cospi_16_64, reg0, reg8);
125   DOTP_CONST_PAIR(reg4, reg12, cospi_24_64, cospi_8_64, reg4, reg12);
126   BUTTERFLY_4(reg8, reg0, reg4, reg12, reg2, reg6, reg10, reg14);
127 
128   reg0 = reg2 - loc1;
129   reg2 = reg2 + loc1;
130   reg12 = reg14 - loc0;
131   reg14 = reg14 + loc0;
132   reg4 = reg6 - loc3;
133   reg6 = reg6 + loc3;
134   reg8 = reg10 - loc2;
135   reg10 = reg10 + loc2;
136 
137   /* stage 2 */
138   DOTP_CONST_PAIR(reg1, reg15, cospi_30_64, cospi_2_64, reg1, reg15);
139   DOTP_CONST_PAIR(reg9, reg7, cospi_14_64, cospi_18_64, loc2, loc3);
140 
141   reg9 = reg1 - loc2;
142   reg1 = reg1 + loc2;
143   reg7 = reg15 - loc3;
144   reg15 = reg15 + loc3;
145 
146   DOTP_CONST_PAIR(reg5, reg11, cospi_22_64, cospi_10_64, reg5, reg11);
147   DOTP_CONST_PAIR(reg13, reg3, cospi_6_64, cospi_26_64, loc0, loc1);
148   BUTTERFLY_4(loc0, loc1, reg11, reg5, reg13, reg3, reg11, reg5);
149 
150   loc1 = reg15 + reg3;
151   reg3 = reg15 - reg3;
152   loc2 = reg2 + loc1;
153   reg15 = reg2 - loc1;
154 
155   loc1 = reg1 + reg13;
156   reg13 = reg1 - reg13;
157   loc0 = reg0 + loc1;
158   loc1 = reg0 - loc1;
159   tmp6 = loc0;
160   tmp7 = loc1;
161   reg0 = loc2;
162 
163   DOTP_CONST_PAIR(reg7, reg9, cospi_24_64, cospi_8_64, reg7, reg9);
164   DOTP_CONST_PAIR((-reg5), (-reg11), cospi_8_64, cospi_24_64, reg5, reg11);
165 
166   loc0 = reg9 + reg5;
167   reg5 = reg9 - reg5;
168   reg2 = reg6 + loc0;
169   reg1 = reg6 - loc0;
170 
171   loc0 = reg7 + reg11;
172   reg11 = reg7 - reg11;
173   loc1 = reg4 + loc0;
174   loc2 = reg4 - loc0;
175   tmp5 = loc1;
176 
177   DOTP_CONST_PAIR(reg5, reg11, cospi_16_64, cospi_16_64, reg5, reg11);
178   BUTTERFLY_4(reg8, reg10, reg11, reg5, loc0, reg4, reg9, loc1);
179 
180   reg10 = loc0;
181   reg11 = loc1;
182 
183   DOTP_CONST_PAIR(reg3, reg13, cospi_16_64, cospi_16_64, reg3, reg13);
184   BUTTERFLY_4(reg12, reg14, reg13, reg3, reg8, reg6, reg7, reg5);
185   reg13 = loc2;
186 
187   /* Transpose and store the output */
188   reg12 = tmp5;
189   reg14 = tmp6;
190   reg3 = tmp7;
191 
192   SRARI_H4_SH(reg0, reg2, reg4, reg6, 6);
193   VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg0, reg2, reg4, reg6);
194   dst += (4 * dst_stride);
195   SRARI_H4_SH(reg8, reg10, reg12, reg14, 6);
196   VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg8, reg10, reg12, reg14);
197   dst += (4 * dst_stride);
198   SRARI_H4_SH(reg3, reg13, reg11, reg5, 6);
199   VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg3, reg13, reg11, reg5);
200   dst += (4 * dst_stride);
201   SRARI_H4_SH(reg7, reg9, reg1, reg15, 6);
202   VP9_ADDBLK_ST8x4_UB(dst, dst_stride, reg7, reg9, reg1, reg15);
203 }
204 
vpx_idct16x16_256_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)205 void vpx_idct16x16_256_add_msa(const int16_t *input, uint8_t *dst,
206                                int32_t dst_stride) {
207   int32_t i;
208   DECLARE_ALIGNED(32, int16_t, out_arr[16 * 16]);
209   int16_t *out = out_arr;
210 
211   /* transform rows */
212   for (i = 0; i < 2; ++i) {
213     /* process 16 * 8 block */
214     vpx_idct16_1d_rows_msa((input + (i << 7)), (out + (i << 7)));
215   }
216 
217   /* transform columns */
218   for (i = 0; i < 2; ++i) {
219     /* process 8 * 16 block */
220     vpx_idct16_1d_columns_addblk_msa((out + (i << 3)), (dst + (i << 3)),
221                                      dst_stride);
222   }
223 }
224 
vpx_idct16x16_10_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)225 void vpx_idct16x16_10_add_msa(const int16_t *input, uint8_t *dst,
226                               int32_t dst_stride) {
227   uint8_t i;
228   DECLARE_ALIGNED(32, int16_t, out_arr[16 * 16]);
229   int16_t *out = out_arr;
230 
231   /* process 16 * 8 block */
232   vpx_idct16_1d_rows_msa(input, out);
233 
234   /* short case just considers top 4 rows as valid output */
235   out += 4 * 16;
236   for (i = 12; i--;) {
237     __asm__ __volatile__(
238         "sw     $zero,   0(%[out])     \n\t"
239         "sw     $zero,   4(%[out])     \n\t"
240         "sw     $zero,   8(%[out])     \n\t"
241         "sw     $zero,  12(%[out])     \n\t"
242         "sw     $zero,  16(%[out])     \n\t"
243         "sw     $zero,  20(%[out])     \n\t"
244         "sw     $zero,  24(%[out])     \n\t"
245         "sw     $zero,  28(%[out])     \n\t"
246 
247         :
248         : [out] "r"(out));
249 
250     out += 16;
251   }
252 
253   out = out_arr;
254 
255   /* transform columns */
256   for (i = 0; i < 2; ++i) {
257     /* process 8 * 16 block */
258     vpx_idct16_1d_columns_addblk_msa((out + (i << 3)), (dst + (i << 3)),
259                                      dst_stride);
260   }
261 }
262 
vpx_idct16x16_1_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)263 void vpx_idct16x16_1_add_msa(const int16_t *input, uint8_t *dst,
264                              int32_t dst_stride) {
265   uint8_t i;
266   int16_t out;
267   v8i16 vec, res0, res1, res2, res3, res4, res5, res6, res7;
268   v16u8 dst0, dst1, dst2, dst3, tmp0, tmp1, tmp2, tmp3;
269 
270   out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), DCT_CONST_BITS);
271   out = ROUND_POWER_OF_TWO((out * cospi_16_64), DCT_CONST_BITS);
272   out = ROUND_POWER_OF_TWO(out, 6);
273 
274   vec = __msa_fill_h(out);
275 
276   for (i = 4; i--;) {
277     LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
278     UNPCK_UB_SH(dst0, res0, res4);
279     UNPCK_UB_SH(dst1, res1, res5);
280     UNPCK_UB_SH(dst2, res2, res6);
281     UNPCK_UB_SH(dst3, res3, res7);
282     ADD4(res0, vec, res1, vec, res2, vec, res3, vec, res0, res1, res2, res3);
283     ADD4(res4, vec, res5, vec, res6, vec, res7, vec, res4, res5, res6, res7);
284     CLIP_SH4_0_255(res0, res1, res2, res3);
285     CLIP_SH4_0_255(res4, res5, res6, res7);
286     PCKEV_B4_UB(res4, res0, res5, res1, res6, res2, res7, res3, tmp0, tmp1,
287                 tmp2, tmp3);
288     ST_UB4(tmp0, tmp1, tmp2, tmp3, dst, dst_stride);
289     dst += (4 * dst_stride);
290   }
291 }
292 
vpx_iadst16_1d_rows_msa(const int16_t * input,int16_t * output)293 void vpx_iadst16_1d_rows_msa(const int16_t *input, int16_t *output) {
294   v8i16 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15;
295   v8i16 l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15;
296 
297   /* load input data */
298   LD_SH16(input, 8, l0, l8, l1, l9, l2, l10, l3, l11, l4, l12, l5, l13, l6, l14,
299           l7, l15);
300   TRANSPOSE8x8_SH_SH(l0, l1, l2, l3, l4, l5, l6, l7, l0, l1, l2, l3, l4, l5, l6,
301                      l7);
302   TRANSPOSE8x8_SH_SH(l8, l9, l10, l11, l12, l13, l14, l15, l8, l9, l10, l11,
303                      l12, l13, l14, l15);
304 
305   /* ADST in horizontal */
306   VP9_IADST8x16_1D(l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13,
307                    l14, l15, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
308                    r12, r13, r14, r15);
309 
310   l1 = -r8;
311   l3 = -r4;
312   l13 = -r13;
313   l15 = -r1;
314 
315   TRANSPOSE8x8_SH_SH(r0, l1, r12, l3, r6, r14, r10, r2, l0, l1, l2, l3, l4, l5,
316                      l6, l7);
317   ST_SH8(l0, l1, l2, l3, l4, l5, l6, l7, output, 16);
318   TRANSPOSE8x8_SH_SH(r3, r11, r15, r7, r5, l13, r9, l15, l8, l9, l10, l11, l12,
319                      l13, l14, l15);
320   ST_SH8(l8, l9, l10, l11, l12, l13, l14, l15, (output + 8), 16);
321 }
322 
vpx_iadst16_1d_columns_addblk_msa(int16_t * input,uint8_t * dst,int32_t dst_stride)323 void vpx_iadst16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst,
324                                        int32_t dst_stride) {
325   v8i16 v0, v2, v4, v6, k0, k1, k2, k3;
326   v8i16 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15;
327   v8i16 out0, out1, out2, out3, out4, out5, out6, out7;
328   v8i16 out8, out9, out10, out11, out12, out13, out14, out15;
329   v8i16 g0, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15;
330   v8i16 h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
331   v8i16 res0, res1, res2, res3, res4, res5, res6, res7;
332   v8i16 res8, res9, res10, res11, res12, res13, res14, res15;
333   v16u8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7;
334   v16u8 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15;
335   v16i8 zero = { 0 };
336 
337   r0 = LD_SH(input + 0 * 16);
338   r3 = LD_SH(input + 3 * 16);
339   r4 = LD_SH(input + 4 * 16);
340   r7 = LD_SH(input + 7 * 16);
341   r8 = LD_SH(input + 8 * 16);
342   r11 = LD_SH(input + 11 * 16);
343   r12 = LD_SH(input + 12 * 16);
344   r15 = LD_SH(input + 15 * 16);
345 
346   /* stage 1 */
347   k0 = VP9_SET_COSPI_PAIR(cospi_1_64, cospi_31_64);
348   k1 = VP9_SET_COSPI_PAIR(cospi_31_64, -cospi_1_64);
349   k2 = VP9_SET_COSPI_PAIR(cospi_17_64, cospi_15_64);
350   k3 = VP9_SET_COSPI_PAIR(cospi_15_64, -cospi_17_64);
351   MADD_BF(r15, r0, r7, r8, k0, k1, k2, k3, g0, g1, g2, g3);
352   k0 = VP9_SET_COSPI_PAIR(cospi_9_64, cospi_23_64);
353   k1 = VP9_SET_COSPI_PAIR(cospi_23_64, -cospi_9_64);
354   k2 = VP9_SET_COSPI_PAIR(cospi_25_64, cospi_7_64);
355   k3 = VP9_SET_COSPI_PAIR(cospi_7_64, -cospi_25_64);
356   MADD_BF(r11, r4, r3, r12, k0, k1, k2, k3, g8, g9, g10, g11);
357   BUTTERFLY_4(g0, g2, g10, g8, h8, h9, v2, v0);
358   k0 = VP9_SET_COSPI_PAIR(cospi_4_64, cospi_28_64);
359   k1 = VP9_SET_COSPI_PAIR(cospi_28_64, -cospi_4_64);
360   k2 = VP9_SET_COSPI_PAIR(-cospi_28_64, cospi_4_64);
361   MADD_BF(g1, g3, g9, g11, k0, k1, k2, k0, h0, h1, h2, h3);
362 
363   r1 = LD_SH(input + 1 * 16);
364   r2 = LD_SH(input + 2 * 16);
365   r5 = LD_SH(input + 5 * 16);
366   r6 = LD_SH(input + 6 * 16);
367   r9 = LD_SH(input + 9 * 16);
368   r10 = LD_SH(input + 10 * 16);
369   r13 = LD_SH(input + 13 * 16);
370   r14 = LD_SH(input + 14 * 16);
371 
372   k0 = VP9_SET_COSPI_PAIR(cospi_5_64, cospi_27_64);
373   k1 = VP9_SET_COSPI_PAIR(cospi_27_64, -cospi_5_64);
374   k2 = VP9_SET_COSPI_PAIR(cospi_21_64, cospi_11_64);
375   k3 = VP9_SET_COSPI_PAIR(cospi_11_64, -cospi_21_64);
376   MADD_BF(r13, r2, r5, r10, k0, k1, k2, k3, g4, g5, g6, g7);
377   k0 = VP9_SET_COSPI_PAIR(cospi_13_64, cospi_19_64);
378   k1 = VP9_SET_COSPI_PAIR(cospi_19_64, -cospi_13_64);
379   k2 = VP9_SET_COSPI_PAIR(cospi_29_64, cospi_3_64);
380   k3 = VP9_SET_COSPI_PAIR(cospi_3_64, -cospi_29_64);
381   MADD_BF(r9, r6, r1, r14, k0, k1, k2, k3, g12, g13, g14, g15);
382   BUTTERFLY_4(g4, g6, g14, g12, h10, h11, v6, v4);
383   BUTTERFLY_4(h8, h9, h11, h10, out0, out1, h11, h10);
384   out1 = -out1;
385   SRARI_H2_SH(out0, out1, 6);
386   dst0 = LD_UB(dst + 0 * dst_stride);
387   dst1 = LD_UB(dst + 15 * dst_stride);
388   ILVR_B2_SH(zero, dst0, zero, dst1, res0, res1);
389   ADD2(res0, out0, res1, out1, res0, res1);
390   CLIP_SH2_0_255(res0, res1);
391   PCKEV_B2_SH(res0, res0, res1, res1, res0, res1);
392   ST8x1_UB(res0, dst);
393   ST8x1_UB(res1, dst + 15 * dst_stride);
394 
395   k0 = VP9_SET_COSPI_PAIR(cospi_12_64, cospi_20_64);
396   k1 = VP9_SET_COSPI_PAIR(-cospi_20_64, cospi_12_64);
397   k2 = VP9_SET_COSPI_PAIR(cospi_20_64, -cospi_12_64);
398   MADD_BF(g7, g5, g15, g13, k0, k1, k2, k0, h4, h5, h6, h7);
399   BUTTERFLY_4(h0, h2, h6, h4, out8, out9, out11, out10);
400   out8 = -out8;
401 
402   SRARI_H2_SH(out8, out9, 6);
403   dst8 = LD_UB(dst + 1 * dst_stride);
404   dst9 = LD_UB(dst + 14 * dst_stride);
405   ILVR_B2_SH(zero, dst8, zero, dst9, res8, res9);
406   ADD2(res8, out8, res9, out9, res8, res9);
407   CLIP_SH2_0_255(res8, res9);
408   PCKEV_B2_SH(res8, res8, res9, res9, res8, res9);
409   ST8x1_UB(res8, dst + dst_stride);
410   ST8x1_UB(res9, dst + 14 * dst_stride);
411 
412   k0 = VP9_SET_COSPI_PAIR(cospi_8_64, cospi_24_64);
413   k1 = VP9_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64);
414   k2 = VP9_SET_COSPI_PAIR(-cospi_24_64, cospi_8_64);
415   MADD_BF(v0, v2, v4, v6, k0, k1, k2, k0, out4, out6, out5, out7);
416   out4 = -out4;
417   SRARI_H2_SH(out4, out5, 6);
418   dst4 = LD_UB(dst + 3 * dst_stride);
419   dst5 = LD_UB(dst + 12 * dst_stride);
420   ILVR_B2_SH(zero, dst4, zero, dst5, res4, res5);
421   ADD2(res4, out4, res5, out5, res4, res5);
422   CLIP_SH2_0_255(res4, res5);
423   PCKEV_B2_SH(res4, res4, res5, res5, res4, res5);
424   ST8x1_UB(res4, dst + 3 * dst_stride);
425   ST8x1_UB(res5, dst + 12 * dst_stride);
426 
427   MADD_BF(h1, h3, h5, h7, k0, k1, k2, k0, out12, out14, out13, out15);
428   out13 = -out13;
429   SRARI_H2_SH(out12, out13, 6);
430   dst12 = LD_UB(dst + 2 * dst_stride);
431   dst13 = LD_UB(dst + 13 * dst_stride);
432   ILVR_B2_SH(zero, dst12, zero, dst13, res12, res13);
433   ADD2(res12, out12, res13, out13, res12, res13);
434   CLIP_SH2_0_255(res12, res13);
435   PCKEV_B2_SH(res12, res12, res13, res13, res12, res13);
436   ST8x1_UB(res12, dst + 2 * dst_stride);
437   ST8x1_UB(res13, dst + 13 * dst_stride);
438 
439   k0 = VP9_SET_COSPI_PAIR(cospi_16_64, cospi_16_64);
440   k3 = VP9_SET_COSPI_PAIR(-cospi_16_64, cospi_16_64);
441   MADD_SHORT(out6, out7, k0, k3, out6, out7);
442   SRARI_H2_SH(out6, out7, 6);
443   dst6 = LD_UB(dst + 4 * dst_stride);
444   dst7 = LD_UB(dst + 11 * dst_stride);
445   ILVR_B2_SH(zero, dst6, zero, dst7, res6, res7);
446   ADD2(res6, out6, res7, out7, res6, res7);
447   CLIP_SH2_0_255(res6, res7);
448   PCKEV_B2_SH(res6, res6, res7, res7, res6, res7);
449   ST8x1_UB(res6, dst + 4 * dst_stride);
450   ST8x1_UB(res7, dst + 11 * dst_stride);
451 
452   MADD_SHORT(out10, out11, k0, k3, out10, out11);
453   SRARI_H2_SH(out10, out11, 6);
454   dst10 = LD_UB(dst + 6 * dst_stride);
455   dst11 = LD_UB(dst + 9 * dst_stride);
456   ILVR_B2_SH(zero, dst10, zero, dst11, res10, res11);
457   ADD2(res10, out10, res11, out11, res10, res11);
458   CLIP_SH2_0_255(res10, res11);
459   PCKEV_B2_SH(res10, res10, res11, res11, res10, res11);
460   ST8x1_UB(res10, dst + 6 * dst_stride);
461   ST8x1_UB(res11, dst + 9 * dst_stride);
462 
463   k1 = VP9_SET_COSPI_PAIR(-cospi_16_64, -cospi_16_64);
464   k2 = VP9_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64);
465   MADD_SHORT(h10, h11, k1, k2, out2, out3);
466   SRARI_H2_SH(out2, out3, 6);
467   dst2 = LD_UB(dst + 7 * dst_stride);
468   dst3 = LD_UB(dst + 8 * dst_stride);
469   ILVR_B2_SH(zero, dst2, zero, dst3, res2, res3);
470   ADD2(res2, out2, res3, out3, res2, res3);
471   CLIP_SH2_0_255(res2, res3);
472   PCKEV_B2_SH(res2, res2, res3, res3, res2, res3);
473   ST8x1_UB(res2, dst + 7 * dst_stride);
474   ST8x1_UB(res3, dst + 8 * dst_stride);
475 
476   MADD_SHORT(out14, out15, k1, k2, out14, out15);
477   SRARI_H2_SH(out14, out15, 6);
478   dst14 = LD_UB(dst + 5 * dst_stride);
479   dst15 = LD_UB(dst + 10 * dst_stride);
480   ILVR_B2_SH(zero, dst14, zero, dst15, res14, res15);
481   ADD2(res14, out14, res15, out15, res14, res15);
482   CLIP_SH2_0_255(res14, res15);
483   PCKEV_B2_SH(res14, res14, res15, res15, res14, res15);
484   ST8x1_UB(res14, dst + 5 * dst_stride);
485   ST8x1_UB(res15, dst + 10 * dst_stride);
486 }
487