1 /*
2  * Copyright (c) 2018, 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 "av1/encoder/x86/av1_txfm1d_sse4.h"
13 
av1_fdct32_sse4_1(__m128i * input,__m128i * output,int cos_bit,const int stride)14 void av1_fdct32_sse4_1(__m128i *input, __m128i *output, int cos_bit,
15                        const int stride) {
16   __m128i buf0[32];
17   __m128i buf1[32];
18   const int32_t *cospi;
19 
20   int startidx = 0 * stride;
21   int endidx = 31 * stride;
22   // stage 0
23   // stage 1
24   buf1[0] = _mm_add_epi32(input[startidx], input[endidx]);
25   buf1[31] = _mm_sub_epi32(input[startidx], input[endidx]);
26   startidx += stride;
27   endidx -= stride;
28   buf1[1] = _mm_add_epi32(input[startidx], input[endidx]);
29   buf1[30] = _mm_sub_epi32(input[startidx], input[endidx]);
30   startidx += stride;
31   endidx -= stride;
32   buf1[2] = _mm_add_epi32(input[startidx], input[endidx]);
33   buf1[29] = _mm_sub_epi32(input[startidx], input[endidx]);
34   startidx += stride;
35   endidx -= stride;
36   buf1[3] = _mm_add_epi32(input[startidx], input[endidx]);
37   buf1[28] = _mm_sub_epi32(input[startidx], input[endidx]);
38   startidx += stride;
39   endidx -= stride;
40   buf1[4] = _mm_add_epi32(input[startidx], input[endidx]);
41   buf1[27] = _mm_sub_epi32(input[startidx], input[endidx]);
42   startidx += stride;
43   endidx -= stride;
44   buf1[5] = _mm_add_epi32(input[startidx], input[endidx]);
45   buf1[26] = _mm_sub_epi32(input[startidx], input[endidx]);
46   startidx += stride;
47   endidx -= stride;
48   buf1[6] = _mm_add_epi32(input[startidx], input[endidx]);
49   buf1[25] = _mm_sub_epi32(input[startidx], input[endidx]);
50   startidx += stride;
51   endidx -= stride;
52   buf1[7] = _mm_add_epi32(input[startidx], input[endidx]);
53   buf1[24] = _mm_sub_epi32(input[startidx], input[endidx]);
54   startidx += stride;
55   endidx -= stride;
56   buf1[8] = _mm_add_epi32(input[startidx], input[endidx]);
57   buf1[23] = _mm_sub_epi32(input[startidx], input[endidx]);
58   startidx += stride;
59   endidx -= stride;
60   buf1[9] = _mm_add_epi32(input[startidx], input[endidx]);
61   buf1[22] = _mm_sub_epi32(input[startidx], input[endidx]);
62   startidx += stride;
63   endidx -= stride;
64   buf1[10] = _mm_add_epi32(input[startidx], input[endidx]);
65   buf1[21] = _mm_sub_epi32(input[startidx], input[endidx]);
66   startidx += stride;
67   endidx -= stride;
68   buf1[11] = _mm_add_epi32(input[startidx], input[endidx]);
69   buf1[20] = _mm_sub_epi32(input[startidx], input[endidx]);
70   startidx += stride;
71   endidx -= stride;
72   buf1[12] = _mm_add_epi32(input[startidx], input[endidx]);
73   buf1[19] = _mm_sub_epi32(input[startidx], input[endidx]);
74   startidx += stride;
75   endidx -= stride;
76   buf1[13] = _mm_add_epi32(input[startidx], input[endidx]);
77   buf1[18] = _mm_sub_epi32(input[startidx], input[endidx]);
78   startidx += stride;
79   endidx -= stride;
80   buf1[14] = _mm_add_epi32(input[startidx], input[endidx]);
81   buf1[17] = _mm_sub_epi32(input[startidx], input[endidx]);
82   startidx += stride;
83   endidx -= stride;
84   buf1[15] = _mm_add_epi32(input[startidx], input[endidx]);
85   buf1[16] = _mm_sub_epi32(input[startidx], input[endidx]);
86 
87   // stage 2
88   cospi = cospi_arr(cos_bit);
89   buf0[0] = _mm_add_epi32(buf1[0], buf1[15]);
90   buf0[15] = _mm_sub_epi32(buf1[0], buf1[15]);
91   buf0[1] = _mm_add_epi32(buf1[1], buf1[14]);
92   buf0[14] = _mm_sub_epi32(buf1[1], buf1[14]);
93   buf0[2] = _mm_add_epi32(buf1[2], buf1[13]);
94   buf0[13] = _mm_sub_epi32(buf1[2], buf1[13]);
95   buf0[3] = _mm_add_epi32(buf1[3], buf1[12]);
96   buf0[12] = _mm_sub_epi32(buf1[3], buf1[12]);
97   buf0[4] = _mm_add_epi32(buf1[4], buf1[11]);
98   buf0[11] = _mm_sub_epi32(buf1[4], buf1[11]);
99   buf0[5] = _mm_add_epi32(buf1[5], buf1[10]);
100   buf0[10] = _mm_sub_epi32(buf1[5], buf1[10]);
101   buf0[6] = _mm_add_epi32(buf1[6], buf1[9]);
102   buf0[9] = _mm_sub_epi32(buf1[6], buf1[9]);
103   buf0[7] = _mm_add_epi32(buf1[7], buf1[8]);
104   buf0[8] = _mm_sub_epi32(buf1[7], buf1[8]);
105   buf0[16] = buf1[16];
106   buf0[17] = buf1[17];
107   buf0[18] = buf1[18];
108   buf0[19] = buf1[19];
109   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf1[20], buf1[27], buf0[20],
110                       buf0[27], cos_bit);
111   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf1[21], buf1[26], buf0[21],
112                       buf0[26], cos_bit);
113   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf1[22], buf1[25], buf0[22],
114                       buf0[25], cos_bit);
115   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf1[23], buf1[24], buf0[23],
116                       buf0[24], cos_bit);
117   buf0[28] = buf1[28];
118   buf0[29] = buf1[29];
119   buf0[30] = buf1[30];
120   buf0[31] = buf1[31];
121 
122   // stage 3
123   cospi = cospi_arr(cos_bit);
124   buf1[0] = _mm_add_epi32(buf0[0], buf0[7]);
125   buf1[7] = _mm_sub_epi32(buf0[0], buf0[7]);
126   buf1[1] = _mm_add_epi32(buf0[1], buf0[6]);
127   buf1[6] = _mm_sub_epi32(buf0[1], buf0[6]);
128   buf1[2] = _mm_add_epi32(buf0[2], buf0[5]);
129   buf1[5] = _mm_sub_epi32(buf0[2], buf0[5]);
130   buf1[3] = _mm_add_epi32(buf0[3], buf0[4]);
131   buf1[4] = _mm_sub_epi32(buf0[3], buf0[4]);
132   buf1[8] = buf0[8];
133   buf1[9] = buf0[9];
134   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf0[10], buf0[13], buf1[10],
135                       buf1[13], cos_bit);
136   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf0[11], buf0[12], buf1[11],
137                       buf1[12], cos_bit);
138   buf1[14] = buf0[14];
139   buf1[15] = buf0[15];
140   buf1[16] = _mm_add_epi32(buf0[16], buf0[23]);
141   buf1[23] = _mm_sub_epi32(buf0[16], buf0[23]);
142   buf1[17] = _mm_add_epi32(buf0[17], buf0[22]);
143   buf1[22] = _mm_sub_epi32(buf0[17], buf0[22]);
144   buf1[18] = _mm_add_epi32(buf0[18], buf0[21]);
145   buf1[21] = _mm_sub_epi32(buf0[18], buf0[21]);
146   buf1[19] = _mm_add_epi32(buf0[19], buf0[20]);
147   buf1[20] = _mm_sub_epi32(buf0[19], buf0[20]);
148   buf1[24] = _mm_sub_epi32(buf0[31], buf0[24]);
149   buf1[31] = _mm_add_epi32(buf0[31], buf0[24]);
150   buf1[25] = _mm_sub_epi32(buf0[30], buf0[25]);
151   buf1[30] = _mm_add_epi32(buf0[30], buf0[25]);
152   buf1[26] = _mm_sub_epi32(buf0[29], buf0[26]);
153   buf1[29] = _mm_add_epi32(buf0[29], buf0[26]);
154   buf1[27] = _mm_sub_epi32(buf0[28], buf0[27]);
155   buf1[28] = _mm_add_epi32(buf0[28], buf0[27]);
156 
157   // stage 4
158   cospi = cospi_arr(cos_bit);
159   buf0[0] = _mm_add_epi32(buf1[0], buf1[3]);
160   buf0[3] = _mm_sub_epi32(buf1[0], buf1[3]);
161   buf0[1] = _mm_add_epi32(buf1[1], buf1[2]);
162   buf0[2] = _mm_sub_epi32(buf1[1], buf1[2]);
163   buf0[4] = buf1[4];
164   btf_32_sse4_1_type0(-cospi[32], cospi[32], buf1[5], buf1[6], buf0[5], buf0[6],
165                       cos_bit);
166   buf0[7] = buf1[7];
167   buf0[8] = _mm_add_epi32(buf1[8], buf1[11]);
168   buf0[11] = _mm_sub_epi32(buf1[8], buf1[11]);
169   buf0[9] = _mm_add_epi32(buf1[9], buf1[10]);
170   buf0[10] = _mm_sub_epi32(buf1[9], buf1[10]);
171   buf0[12] = _mm_sub_epi32(buf1[15], buf1[12]);
172   buf0[15] = _mm_add_epi32(buf1[15], buf1[12]);
173   buf0[13] = _mm_sub_epi32(buf1[14], buf1[13]);
174   buf0[14] = _mm_add_epi32(buf1[14], buf1[13]);
175   buf0[16] = buf1[16];
176   buf0[17] = buf1[17];
177   btf_32_sse4_1_type0(-cospi[16], cospi[48], buf1[18], buf1[29], buf0[18],
178                       buf0[29], cos_bit);
179   btf_32_sse4_1_type0(-cospi[16], cospi[48], buf1[19], buf1[28], buf0[19],
180                       buf0[28], cos_bit);
181   btf_32_sse4_1_type0(-cospi[48], -cospi[16], buf1[20], buf1[27], buf0[20],
182                       buf0[27], cos_bit);
183   btf_32_sse4_1_type0(-cospi[48], -cospi[16], buf1[21], buf1[26], buf0[21],
184                       buf0[26], cos_bit);
185   buf0[22] = buf1[22];
186   buf0[23] = buf1[23];
187   buf0[24] = buf1[24];
188   buf0[25] = buf1[25];
189   buf0[30] = buf1[30];
190   buf0[31] = buf1[31];
191 
192   // stage 5
193   cospi = cospi_arr(cos_bit);
194   btf_32_sse4_1_type0(cospi[32], cospi[32], buf0[0], buf0[1], buf1[0], buf1[1],
195                       cos_bit);
196   btf_32_sse4_1_type1(cospi[48], cospi[16], buf0[2], buf0[3], buf1[2], buf1[3],
197                       cos_bit);
198   buf1[4] = _mm_add_epi32(buf0[4], buf0[5]);
199   buf1[5] = _mm_sub_epi32(buf0[4], buf0[5]);
200   buf1[6] = _mm_sub_epi32(buf0[7], buf0[6]);
201   buf1[7] = _mm_add_epi32(buf0[7], buf0[6]);
202   buf1[8] = buf0[8];
203   btf_32_sse4_1_type0(-cospi[16], cospi[48], buf0[9], buf0[14], buf1[9],
204                       buf1[14], cos_bit);
205   btf_32_sse4_1_type0(-cospi[48], -cospi[16], buf0[10], buf0[13], buf1[10],
206                       buf1[13], cos_bit);
207   buf1[11] = buf0[11];
208   buf1[12] = buf0[12];
209   buf1[15] = buf0[15];
210   buf1[16] = _mm_add_epi32(buf0[16], buf0[19]);
211   buf1[19] = _mm_sub_epi32(buf0[16], buf0[19]);
212   buf1[17] = _mm_add_epi32(buf0[17], buf0[18]);
213   buf1[18] = _mm_sub_epi32(buf0[17], buf0[18]);
214   buf1[20] = _mm_sub_epi32(buf0[23], buf0[20]);
215   buf1[23] = _mm_add_epi32(buf0[23], buf0[20]);
216   buf1[21] = _mm_sub_epi32(buf0[22], buf0[21]);
217   buf1[22] = _mm_add_epi32(buf0[22], buf0[21]);
218   buf1[24] = _mm_add_epi32(buf0[24], buf0[27]);
219   buf1[27] = _mm_sub_epi32(buf0[24], buf0[27]);
220   buf1[25] = _mm_add_epi32(buf0[25], buf0[26]);
221   buf1[26] = _mm_sub_epi32(buf0[25], buf0[26]);
222   buf1[28] = _mm_sub_epi32(buf0[31], buf0[28]);
223   buf1[31] = _mm_add_epi32(buf0[31], buf0[28]);
224   buf1[29] = _mm_sub_epi32(buf0[30], buf0[29]);
225   buf1[30] = _mm_add_epi32(buf0[30], buf0[29]);
226 
227   // stage 6
228   cospi = cospi_arr(cos_bit);
229   buf0[0] = buf1[0];
230   buf0[1] = buf1[1];
231   buf0[2] = buf1[2];
232   buf0[3] = buf1[3];
233   btf_32_sse4_1_type1(cospi[56], cospi[8], buf1[4], buf1[7], buf0[4], buf0[7],
234                       cos_bit);
235   btf_32_sse4_1_type1(cospi[24], cospi[40], buf1[5], buf1[6], buf0[5], buf0[6],
236                       cos_bit);
237   buf0[8] = _mm_add_epi32(buf1[8], buf1[9]);
238   buf0[9] = _mm_sub_epi32(buf1[8], buf1[9]);
239   buf0[10] = _mm_sub_epi32(buf1[11], buf1[10]);
240   buf0[11] = _mm_add_epi32(buf1[11], buf1[10]);
241   buf0[12] = _mm_add_epi32(buf1[12], buf1[13]);
242   buf0[13] = _mm_sub_epi32(buf1[12], buf1[13]);
243   buf0[14] = _mm_sub_epi32(buf1[15], buf1[14]);
244   buf0[15] = _mm_add_epi32(buf1[15], buf1[14]);
245   buf0[16] = buf1[16];
246   btf_32_sse4_1_type0(-cospi[8], cospi[56], buf1[17], buf1[30], buf0[17],
247                       buf0[30], cos_bit);
248   btf_32_sse4_1_type0(-cospi[56], -cospi[8], buf1[18], buf1[29], buf0[18],
249                       buf0[29], cos_bit);
250   buf0[19] = buf1[19];
251   buf0[20] = buf1[20];
252   btf_32_sse4_1_type0(-cospi[40], cospi[24], buf1[21], buf1[26], buf0[21],
253                       buf0[26], cos_bit);
254   btf_32_sse4_1_type0(-cospi[24], -cospi[40], buf1[22], buf1[25], buf0[22],
255                       buf0[25], cos_bit);
256   buf0[23] = buf1[23];
257   buf0[24] = buf1[24];
258   buf0[27] = buf1[27];
259   buf0[28] = buf1[28];
260   buf0[31] = buf1[31];
261 
262   // stage 7
263   cospi = cospi_arr(cos_bit);
264   buf1[0] = buf0[0];
265   buf1[1] = buf0[1];
266   buf1[2] = buf0[2];
267   buf1[3] = buf0[3];
268   buf1[4] = buf0[4];
269   buf1[5] = buf0[5];
270   buf1[6] = buf0[6];
271   buf1[7] = buf0[7];
272   btf_32_sse4_1_type1(cospi[60], cospi[4], buf0[8], buf0[15], buf1[8], buf1[15],
273                       cos_bit);
274   btf_32_sse4_1_type1(cospi[28], cospi[36], buf0[9], buf0[14], buf1[9],
275                       buf1[14], cos_bit);
276   btf_32_sse4_1_type1(cospi[44], cospi[20], buf0[10], buf0[13], buf1[10],
277                       buf1[13], cos_bit);
278   btf_32_sse4_1_type1(cospi[12], cospi[52], buf0[11], buf0[12], buf1[11],
279                       buf1[12], cos_bit);
280   buf1[16] = _mm_add_epi32(buf0[16], buf0[17]);
281   buf1[17] = _mm_sub_epi32(buf0[16], buf0[17]);
282   buf1[18] = _mm_sub_epi32(buf0[19], buf0[18]);
283   buf1[19] = _mm_add_epi32(buf0[19], buf0[18]);
284   buf1[20] = _mm_add_epi32(buf0[20], buf0[21]);
285   buf1[21] = _mm_sub_epi32(buf0[20], buf0[21]);
286   buf1[22] = _mm_sub_epi32(buf0[23], buf0[22]);
287   buf1[23] = _mm_add_epi32(buf0[23], buf0[22]);
288   buf1[24] = _mm_add_epi32(buf0[24], buf0[25]);
289   buf1[25] = _mm_sub_epi32(buf0[24], buf0[25]);
290   buf1[26] = _mm_sub_epi32(buf0[27], buf0[26]);
291   buf1[27] = _mm_add_epi32(buf0[27], buf0[26]);
292   buf1[28] = _mm_add_epi32(buf0[28], buf0[29]);
293   buf1[29] = _mm_sub_epi32(buf0[28], buf0[29]);
294   buf1[30] = _mm_sub_epi32(buf0[31], buf0[30]);
295   buf1[31] = _mm_add_epi32(buf0[31], buf0[30]);
296 
297   // stage 8
298   cospi = cospi_arr(cos_bit);
299   buf0[0] = buf1[0];
300   buf0[1] = buf1[1];
301   buf0[2] = buf1[2];
302   buf0[3] = buf1[3];
303   buf0[4] = buf1[4];
304   buf0[5] = buf1[5];
305   buf0[6] = buf1[6];
306   buf0[7] = buf1[7];
307   buf0[8] = buf1[8];
308   buf0[9] = buf1[9];
309   buf0[10] = buf1[10];
310   buf0[11] = buf1[11];
311   buf0[12] = buf1[12];
312   buf0[13] = buf1[13];
313   buf0[14] = buf1[14];
314   buf0[15] = buf1[15];
315   btf_32_sse4_1_type1(cospi[62], cospi[2], buf1[16], buf1[31], buf0[16],
316                       buf0[31], cos_bit);
317   btf_32_sse4_1_type1(cospi[30], cospi[34], buf1[17], buf1[30], buf0[17],
318                       buf0[30], cos_bit);
319   btf_32_sse4_1_type1(cospi[46], cospi[18], buf1[18], buf1[29], buf0[18],
320                       buf0[29], cos_bit);
321   btf_32_sse4_1_type1(cospi[14], cospi[50], buf1[19], buf1[28], buf0[19],
322                       buf0[28], cos_bit);
323   btf_32_sse4_1_type1(cospi[54], cospi[10], buf1[20], buf1[27], buf0[20],
324                       buf0[27], cos_bit);
325   btf_32_sse4_1_type1(cospi[22], cospi[42], buf1[21], buf1[26], buf0[21],
326                       buf0[26], cos_bit);
327   btf_32_sse4_1_type1(cospi[38], cospi[26], buf1[22], buf1[25], buf0[22],
328                       buf0[25], cos_bit);
329   btf_32_sse4_1_type1(cospi[6], cospi[58], buf1[23], buf1[24], buf0[23],
330                       buf0[24], cos_bit);
331 
332   startidx = 0 * stride;
333   endidx = 31 * stride;
334   // stage 9
335   output[startidx] = buf0[0];
336   output[endidx] = buf0[31];
337   startidx += stride;
338   endidx -= stride;
339   output[startidx] = buf0[16];
340   output[endidx] = buf0[15];
341   startidx += stride;
342   endidx -= stride;
343   output[startidx] = buf0[8];
344   output[endidx] = buf0[23];
345   startidx += stride;
346   endidx -= stride;
347   output[startidx] = buf0[24];
348   output[endidx] = buf0[7];
349   startidx += stride;
350   endidx -= stride;
351   output[startidx] = buf0[4];
352   output[endidx] = buf0[27];
353   startidx += stride;
354   endidx -= stride;
355   output[startidx] = buf0[20];
356   output[endidx] = buf0[11];
357   startidx += stride;
358   endidx -= stride;
359   output[startidx] = buf0[12];
360   output[endidx] = buf0[19];
361   startidx += stride;
362   endidx -= stride;
363   output[startidx] = buf0[28];
364   output[endidx] = buf0[3];
365   startidx += stride;
366   endidx -= stride;
367   output[startidx] = buf0[2];
368   output[endidx] = buf0[29];
369   startidx += stride;
370   endidx -= stride;
371   output[startidx] = buf0[18];
372   output[endidx] = buf0[13];
373   startidx += stride;
374   endidx -= stride;
375   output[startidx] = buf0[10];
376   output[endidx] = buf0[21];
377   startidx += stride;
378   endidx -= stride;
379   output[startidx] = buf0[26];
380   output[endidx] = buf0[5];
381   startidx += stride;
382   endidx -= stride;
383   output[startidx] = buf0[6];
384   output[endidx] = buf0[25];
385   startidx += stride;
386   endidx -= stride;
387   output[startidx] = buf0[22];
388   output[endidx] = buf0[9];
389   startidx += stride;
390   endidx -= stride;
391   output[startidx] = buf0[14];
392   output[endidx] = buf0[17];
393   startidx += stride;
394   endidx -= stride;
395   output[startidx] = buf0[30];
396   output[endidx] = buf0[1];
397 }
398 
av1_fadst4_sse4_1(const __m128i * input,__m128i * output,const int8_t cos_bit,const int8_t * stage_range)399 void av1_fadst4_sse4_1(const __m128i *input, __m128i *output,
400                        const int8_t cos_bit, const int8_t *stage_range) {
401   const int txfm_size = 4;
402   const int num_per_128 = 4;
403   const int32_t *cospi;
404   __m128i buf0[4];
405   __m128i buf1[4];
406   int col_num = txfm_size / num_per_128;
407   int col;
408   (void)stage_range;
409   for (col = 0; col < col_num; col++) {
410     // stage 0;
411     int32_t stage_idx = 0;
412     int j;
413     for (j = 0; j < 4; ++j) {
414       buf0[j] = input[j * col_num + col];
415     }
416 
417     // stage 1
418     stage_idx++;
419     buf1[0] = buf0[3];
420     buf1[1] = buf0[0];
421     buf1[2] = buf0[1];
422     buf1[3] = buf0[2];
423 
424     // stage 2
425     stage_idx++;
426 
427     cospi = cospi_arr(cos_bit);
428     btf_32_sse4_1_type0(cospi[8], cospi[56], buf1[0], buf1[1], buf0[0], buf0[1],
429                         cos_bit);
430     btf_32_sse4_1_type0(cospi[40], cospi[24], buf1[2], buf1[3], buf0[2],
431                         buf0[3], cos_bit);
432 
433     // stage 3
434     stage_idx++;
435     buf1[0] = _mm_add_epi32(buf0[0], buf0[2]);
436     buf1[2] = _mm_sub_epi32(buf0[0], buf0[2]);
437     buf1[1] = _mm_add_epi32(buf0[1], buf0[3]);
438     buf1[3] = _mm_sub_epi32(buf0[1], buf0[3]);
439 
440     // stage 4
441     stage_idx++;
442 
443     cospi = cospi_arr(cos_bit);
444     buf0[0] = buf1[0];
445     buf0[1] = buf1[1];
446     btf_32_sse4_1_type0(cospi[32], cospi[32], buf1[2], buf1[3], buf0[2],
447                         buf0[3], cos_bit);
448 
449     // stage 5
450     stage_idx++;
451     buf1[0] = buf0[0];
452     buf1[1] = _mm_sub_epi32(_mm_setzero_si128(), buf0[2]);
453     buf1[2] = buf0[3];
454     buf1[3] = _mm_sub_epi32(_mm_setzero_si128(), buf0[1]);
455 
456     for (j = 0; j < 4; ++j) {
457       output[j * col_num + col] = buf1[j];
458     }
459   }
460 }
461 
av1_fdct64_sse4_1(__m128i * input,__m128i * output,int8_t cos_bit,const int instride,const int outstride)462 void av1_fdct64_sse4_1(__m128i *input, __m128i *output, int8_t cos_bit,
463                        const int instride, const int outstride) {
464   const int32_t *cospi = cospi_arr(cos_bit);
465   const __m128i __rounding = _mm_set1_epi32(1 << (cos_bit - 1));
466 
467   __m128i cospi_m32 = _mm_set1_epi32(-cospi[32]);
468   __m128i cospi_p32 = _mm_set1_epi32(cospi[32]);
469   __m128i cospi_m16 = _mm_set1_epi32(-cospi[16]);
470   __m128i cospi_p48 = _mm_set1_epi32(cospi[48]);
471   __m128i cospi_m48 = _mm_set1_epi32(-cospi[48]);
472   __m128i cospi_p16 = _mm_set1_epi32(cospi[16]);
473   __m128i cospi_m08 = _mm_set1_epi32(-cospi[8]);
474   __m128i cospi_p56 = _mm_set1_epi32(cospi[56]);
475   __m128i cospi_m56 = _mm_set1_epi32(-cospi[56]);
476   __m128i cospi_m40 = _mm_set1_epi32(-cospi[40]);
477   __m128i cospi_p24 = _mm_set1_epi32(cospi[24]);
478   __m128i cospi_m24 = _mm_set1_epi32(-cospi[24]);
479   __m128i cospi_p08 = _mm_set1_epi32(cospi[8]);
480   __m128i cospi_p40 = _mm_set1_epi32(cospi[40]);
481   __m128i cospi_p60 = _mm_set1_epi32(cospi[60]);
482   __m128i cospi_p04 = _mm_set1_epi32(cospi[4]);
483   __m128i cospi_p28 = _mm_set1_epi32(cospi[28]);
484   __m128i cospi_p36 = _mm_set1_epi32(cospi[36]);
485   __m128i cospi_p44 = _mm_set1_epi32(cospi[44]);
486   __m128i cospi_p20 = _mm_set1_epi32(cospi[20]);
487   __m128i cospi_p12 = _mm_set1_epi32(cospi[12]);
488   __m128i cospi_p52 = _mm_set1_epi32(cospi[52]);
489   __m128i cospi_m04 = _mm_set1_epi32(-cospi[4]);
490   __m128i cospi_m60 = _mm_set1_epi32(-cospi[60]);
491   __m128i cospi_m36 = _mm_set1_epi32(-cospi[36]);
492   __m128i cospi_m28 = _mm_set1_epi32(-cospi[28]);
493   __m128i cospi_m20 = _mm_set1_epi32(-cospi[20]);
494   __m128i cospi_m44 = _mm_set1_epi32(-cospi[44]);
495   __m128i cospi_m52 = _mm_set1_epi32(-cospi[52]);
496   __m128i cospi_m12 = _mm_set1_epi32(-cospi[12]);
497   __m128i cospi_p62 = _mm_set1_epi32(cospi[62]);
498   __m128i cospi_p02 = _mm_set1_epi32(cospi[2]);
499   __m128i cospi_p30 = _mm_set1_epi32(cospi[30]);
500   __m128i cospi_p34 = _mm_set1_epi32(cospi[34]);
501   __m128i cospi_p46 = _mm_set1_epi32(cospi[46]);
502   __m128i cospi_p18 = _mm_set1_epi32(cospi[18]);
503   __m128i cospi_p14 = _mm_set1_epi32(cospi[14]);
504   __m128i cospi_p50 = _mm_set1_epi32(cospi[50]);
505   __m128i cospi_p54 = _mm_set1_epi32(cospi[54]);
506   __m128i cospi_p10 = _mm_set1_epi32(cospi[10]);
507   __m128i cospi_p22 = _mm_set1_epi32(cospi[22]);
508   __m128i cospi_p42 = _mm_set1_epi32(cospi[42]);
509   __m128i cospi_p38 = _mm_set1_epi32(cospi[38]);
510   __m128i cospi_p26 = _mm_set1_epi32(cospi[26]);
511   __m128i cospi_p06 = _mm_set1_epi32(cospi[6]);
512   __m128i cospi_p58 = _mm_set1_epi32(cospi[58]);
513   __m128i cospi_p63 = _mm_set1_epi32(cospi[63]);
514   __m128i cospi_p01 = _mm_set1_epi32(cospi[1]);
515   __m128i cospi_p31 = _mm_set1_epi32(cospi[31]);
516   __m128i cospi_p33 = _mm_set1_epi32(cospi[33]);
517   __m128i cospi_p47 = _mm_set1_epi32(cospi[47]);
518   __m128i cospi_p17 = _mm_set1_epi32(cospi[17]);
519   __m128i cospi_p15 = _mm_set1_epi32(cospi[15]);
520   __m128i cospi_p49 = _mm_set1_epi32(cospi[49]);
521   __m128i cospi_p55 = _mm_set1_epi32(cospi[55]);
522   __m128i cospi_p09 = _mm_set1_epi32(cospi[9]);
523   __m128i cospi_p23 = _mm_set1_epi32(cospi[23]);
524   __m128i cospi_p41 = _mm_set1_epi32(cospi[41]);
525   __m128i cospi_p39 = _mm_set1_epi32(cospi[39]);
526   __m128i cospi_p25 = _mm_set1_epi32(cospi[25]);
527   __m128i cospi_p07 = _mm_set1_epi32(cospi[7]);
528   __m128i cospi_p57 = _mm_set1_epi32(cospi[57]);
529   __m128i cospi_p59 = _mm_set1_epi32(cospi[59]);
530   __m128i cospi_p05 = _mm_set1_epi32(cospi[5]);
531   __m128i cospi_p27 = _mm_set1_epi32(cospi[27]);
532   __m128i cospi_p37 = _mm_set1_epi32(cospi[37]);
533   __m128i cospi_p43 = _mm_set1_epi32(cospi[43]);
534   __m128i cospi_p21 = _mm_set1_epi32(cospi[21]);
535   __m128i cospi_p11 = _mm_set1_epi32(cospi[11]);
536   __m128i cospi_p53 = _mm_set1_epi32(cospi[53]);
537   __m128i cospi_p51 = _mm_set1_epi32(cospi[51]);
538   __m128i cospi_p13 = _mm_set1_epi32(cospi[13]);
539   __m128i cospi_p19 = _mm_set1_epi32(cospi[19]);
540   __m128i cospi_p45 = _mm_set1_epi32(cospi[45]);
541   __m128i cospi_p35 = _mm_set1_epi32(cospi[35]);
542   __m128i cospi_p29 = _mm_set1_epi32(cospi[29]);
543   __m128i cospi_p03 = _mm_set1_epi32(cospi[3]);
544   __m128i cospi_p61 = _mm_set1_epi32(cospi[61]);
545 
546   int startidx = 0 * instride;
547   int endidx = 63 * instride;
548   // stage 1
549   __m128i x1[64];
550   x1[0] = _mm_add_epi32(input[startidx], input[endidx]);
551   x1[63] = _mm_sub_epi32(input[startidx], input[endidx]);
552   startidx += instride;
553   endidx -= instride;
554   x1[1] = _mm_add_epi32(input[startidx], input[endidx]);
555   x1[62] = _mm_sub_epi32(input[startidx], input[endidx]);
556   startidx += instride;
557   endidx -= instride;
558   x1[2] = _mm_add_epi32(input[startidx], input[endidx]);
559   x1[61] = _mm_sub_epi32(input[startidx], input[endidx]);
560   startidx += instride;
561   endidx -= instride;
562   x1[3] = _mm_add_epi32(input[startidx], input[endidx]);
563   x1[60] = _mm_sub_epi32(input[startidx], input[endidx]);
564   startidx += instride;
565   endidx -= instride;
566   x1[4] = _mm_add_epi32(input[startidx], input[endidx]);
567   x1[59] = _mm_sub_epi32(input[startidx], input[endidx]);
568   startidx += instride;
569   endidx -= instride;
570   x1[5] = _mm_add_epi32(input[startidx], input[endidx]);
571   x1[58] = _mm_sub_epi32(input[startidx], input[endidx]);
572   startidx += instride;
573   endidx -= instride;
574   x1[6] = _mm_add_epi32(input[startidx], input[endidx]);
575   x1[57] = _mm_sub_epi32(input[startidx], input[endidx]);
576   startidx += instride;
577   endidx -= instride;
578   x1[7] = _mm_add_epi32(input[startidx], input[endidx]);
579   x1[56] = _mm_sub_epi32(input[startidx], input[endidx]);
580   startidx += instride;
581   endidx -= instride;
582   x1[8] = _mm_add_epi32(input[startidx], input[endidx]);
583   x1[55] = _mm_sub_epi32(input[startidx], input[endidx]);
584   startidx += instride;
585   endidx -= instride;
586   x1[9] = _mm_add_epi32(input[startidx], input[endidx]);
587   x1[54] = _mm_sub_epi32(input[startidx], input[endidx]);
588   startidx += instride;
589   endidx -= instride;
590   x1[10] = _mm_add_epi32(input[startidx], input[endidx]);
591   x1[53] = _mm_sub_epi32(input[startidx], input[endidx]);
592   startidx += instride;
593   endidx -= instride;
594   x1[11] = _mm_add_epi32(input[startidx], input[endidx]);
595   x1[52] = _mm_sub_epi32(input[startidx], input[endidx]);
596   startidx += instride;
597   endidx -= instride;
598   x1[12] = _mm_add_epi32(input[startidx], input[endidx]);
599   x1[51] = _mm_sub_epi32(input[startidx], input[endidx]);
600   startidx += instride;
601   endidx -= instride;
602   x1[13] = _mm_add_epi32(input[startidx], input[endidx]);
603   x1[50] = _mm_sub_epi32(input[startidx], input[endidx]);
604   startidx += instride;
605   endidx -= instride;
606   x1[14] = _mm_add_epi32(input[startidx], input[endidx]);
607   x1[49] = _mm_sub_epi32(input[startidx], input[endidx]);
608   startidx += instride;
609   endidx -= instride;
610   x1[15] = _mm_add_epi32(input[startidx], input[endidx]);
611   x1[48] = _mm_sub_epi32(input[startidx], input[endidx]);
612   startidx += instride;
613   endidx -= instride;
614   x1[16] = _mm_add_epi32(input[startidx], input[endidx]);
615   x1[47] = _mm_sub_epi32(input[startidx], input[endidx]);
616   startidx += instride;
617   endidx -= instride;
618   x1[17] = _mm_add_epi32(input[startidx], input[endidx]);
619   x1[46] = _mm_sub_epi32(input[startidx], input[endidx]);
620   startidx += instride;
621   endidx -= instride;
622   x1[18] = _mm_add_epi32(input[startidx], input[endidx]);
623   x1[45] = _mm_sub_epi32(input[startidx], input[endidx]);
624   startidx += instride;
625   endidx -= instride;
626   x1[19] = _mm_add_epi32(input[startidx], input[endidx]);
627   x1[44] = _mm_sub_epi32(input[startidx], input[endidx]);
628   startidx += instride;
629   endidx -= instride;
630   x1[20] = _mm_add_epi32(input[startidx], input[endidx]);
631   x1[43] = _mm_sub_epi32(input[startidx], input[endidx]);
632   startidx += instride;
633   endidx -= instride;
634   x1[21] = _mm_add_epi32(input[startidx], input[endidx]);
635   x1[42] = _mm_sub_epi32(input[startidx], input[endidx]);
636   startidx += instride;
637   endidx -= instride;
638   x1[22] = _mm_add_epi32(input[startidx], input[endidx]);
639   x1[41] = _mm_sub_epi32(input[startidx], input[endidx]);
640   startidx += instride;
641   endidx -= instride;
642   x1[23] = _mm_add_epi32(input[startidx], input[endidx]);
643   x1[40] = _mm_sub_epi32(input[startidx], input[endidx]);
644   startidx += instride;
645   endidx -= instride;
646   x1[24] = _mm_add_epi32(input[startidx], input[endidx]);
647   x1[39] = _mm_sub_epi32(input[startidx], input[endidx]);
648   startidx += instride;
649   endidx -= instride;
650   x1[25] = _mm_add_epi32(input[startidx], input[endidx]);
651   x1[38] = _mm_sub_epi32(input[startidx], input[endidx]);
652   startidx += instride;
653   endidx -= instride;
654   x1[26] = _mm_add_epi32(input[startidx], input[endidx]);
655   x1[37] = _mm_sub_epi32(input[startidx], input[endidx]);
656   startidx += instride;
657   endidx -= instride;
658   x1[27] = _mm_add_epi32(input[startidx], input[endidx]);
659   x1[36] = _mm_sub_epi32(input[startidx], input[endidx]);
660   startidx += instride;
661   endidx -= instride;
662   x1[28] = _mm_add_epi32(input[startidx], input[endidx]);
663   x1[35] = _mm_sub_epi32(input[startidx], input[endidx]);
664   startidx += instride;
665   endidx -= instride;
666   x1[29] = _mm_add_epi32(input[startidx], input[endidx]);
667   x1[34] = _mm_sub_epi32(input[startidx], input[endidx]);
668   startidx += instride;
669   endidx -= instride;
670   x1[30] = _mm_add_epi32(input[startidx], input[endidx]);
671   x1[33] = _mm_sub_epi32(input[startidx], input[endidx]);
672   startidx += instride;
673   endidx -= instride;
674   x1[31] = _mm_add_epi32(input[startidx], input[endidx]);
675   x1[32] = _mm_sub_epi32(input[startidx], input[endidx]);
676 
677   // stage 2
678   __m128i x2[64];
679   x2[0] = _mm_add_epi32(x1[0], x1[31]);
680   x2[31] = _mm_sub_epi32(x1[0], x1[31]);
681   x2[1] = _mm_add_epi32(x1[1], x1[30]);
682   x2[30] = _mm_sub_epi32(x1[1], x1[30]);
683   x2[2] = _mm_add_epi32(x1[2], x1[29]);
684   x2[29] = _mm_sub_epi32(x1[2], x1[29]);
685   x2[3] = _mm_add_epi32(x1[3], x1[28]);
686   x2[28] = _mm_sub_epi32(x1[3], x1[28]);
687   x2[4] = _mm_add_epi32(x1[4], x1[27]);
688   x2[27] = _mm_sub_epi32(x1[4], x1[27]);
689   x2[5] = _mm_add_epi32(x1[5], x1[26]);
690   x2[26] = _mm_sub_epi32(x1[5], x1[26]);
691   x2[6] = _mm_add_epi32(x1[6], x1[25]);
692   x2[25] = _mm_sub_epi32(x1[6], x1[25]);
693   x2[7] = _mm_add_epi32(x1[7], x1[24]);
694   x2[24] = _mm_sub_epi32(x1[7], x1[24]);
695   x2[8] = _mm_add_epi32(x1[8], x1[23]);
696   x2[23] = _mm_sub_epi32(x1[8], x1[23]);
697   x2[9] = _mm_add_epi32(x1[9], x1[22]);
698   x2[22] = _mm_sub_epi32(x1[9], x1[22]);
699   x2[10] = _mm_add_epi32(x1[10], x1[21]);
700   x2[21] = _mm_sub_epi32(x1[10], x1[21]);
701   x2[11] = _mm_add_epi32(x1[11], x1[20]);
702   x2[20] = _mm_sub_epi32(x1[11], x1[20]);
703   x2[12] = _mm_add_epi32(x1[12], x1[19]);
704   x2[19] = _mm_sub_epi32(x1[12], x1[19]);
705   x2[13] = _mm_add_epi32(x1[13], x1[18]);
706   x2[18] = _mm_sub_epi32(x1[13], x1[18]);
707   x2[14] = _mm_add_epi32(x1[14], x1[17]);
708   x2[17] = _mm_sub_epi32(x1[14], x1[17]);
709   x2[15] = _mm_add_epi32(x1[15], x1[16]);
710   x2[16] = _mm_sub_epi32(x1[15], x1[16]);
711   x2[32] = x1[32];
712   x2[33] = x1[33];
713   x2[34] = x1[34];
714   x2[35] = x1[35];
715   x2[36] = x1[36];
716   x2[37] = x1[37];
717   x2[38] = x1[38];
718   x2[39] = x1[39];
719   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[40], x1[55], x2[40], x2[55],
720                           __rounding, cos_bit);
721   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[41], x1[54], x2[41], x2[54],
722                           __rounding, cos_bit);
723   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[42], x1[53], x2[42], x2[53],
724                           __rounding, cos_bit);
725   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[43], x1[52], x2[43], x2[52],
726                           __rounding, cos_bit);
727   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[44], x1[51], x2[44], x2[51],
728                           __rounding, cos_bit);
729   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[45], x1[50], x2[45], x2[50],
730                           __rounding, cos_bit);
731   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[46], x1[49], x2[46], x2[49],
732                           __rounding, cos_bit);
733   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x1[47], x1[48], x2[47], x2[48],
734                           __rounding, cos_bit);
735   x2[56] = x1[56];
736   x2[57] = x1[57];
737   x2[58] = x1[58];
738   x2[59] = x1[59];
739   x2[60] = x1[60];
740   x2[61] = x1[61];
741   x2[62] = x1[62];
742   x2[63] = x1[63];
743 
744   // stage 3
745   __m128i x3[64];
746   x3[0] = _mm_add_epi32(x2[0], x2[15]);
747   x3[15] = _mm_sub_epi32(x2[0], x2[15]);
748   x3[1] = _mm_add_epi32(x2[1], x2[14]);
749   x3[14] = _mm_sub_epi32(x2[1], x2[14]);
750   x3[2] = _mm_add_epi32(x2[2], x2[13]);
751   x3[13] = _mm_sub_epi32(x2[2], x2[13]);
752   x3[3] = _mm_add_epi32(x2[3], x2[12]);
753   x3[12] = _mm_sub_epi32(x2[3], x2[12]);
754   x3[4] = _mm_add_epi32(x2[4], x2[11]);
755   x3[11] = _mm_sub_epi32(x2[4], x2[11]);
756   x3[5] = _mm_add_epi32(x2[5], x2[10]);
757   x3[10] = _mm_sub_epi32(x2[5], x2[10]);
758   x3[6] = _mm_add_epi32(x2[6], x2[9]);
759   x3[9] = _mm_sub_epi32(x2[6], x2[9]);
760   x3[7] = _mm_add_epi32(x2[7], x2[8]);
761   x3[8] = _mm_sub_epi32(x2[7], x2[8]);
762   x3[16] = x2[16];
763   x3[17] = x2[17];
764   x3[18] = x2[18];
765   x3[19] = x2[19];
766   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x2[20], x2[27], x3[20], x3[27],
767                           __rounding, cos_bit);
768   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x2[21], x2[26], x3[21], x3[26],
769                           __rounding, cos_bit);
770   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x2[22], x2[25], x3[22], x3[25],
771                           __rounding, cos_bit);
772   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x2[23], x2[24], x3[23], x3[24],
773                           __rounding, cos_bit);
774   x3[28] = x2[28];
775   x3[29] = x2[29];
776   x3[30] = x2[30];
777   x3[31] = x2[31];
778   x3[32] = _mm_add_epi32(x2[32], x2[47]);
779   x3[47] = _mm_sub_epi32(x2[32], x2[47]);
780   x3[33] = _mm_add_epi32(x2[33], x2[46]);
781   x3[46] = _mm_sub_epi32(x2[33], x2[46]);
782   x3[34] = _mm_add_epi32(x2[34], x2[45]);
783   x3[45] = _mm_sub_epi32(x2[34], x2[45]);
784   x3[35] = _mm_add_epi32(x2[35], x2[44]);
785   x3[44] = _mm_sub_epi32(x2[35], x2[44]);
786   x3[36] = _mm_add_epi32(x2[36], x2[43]);
787   x3[43] = _mm_sub_epi32(x2[36], x2[43]);
788   x3[37] = _mm_add_epi32(x2[37], x2[42]);
789   x3[42] = _mm_sub_epi32(x2[37], x2[42]);
790   x3[38] = _mm_add_epi32(x2[38], x2[41]);
791   x3[41] = _mm_sub_epi32(x2[38], x2[41]);
792   x3[39] = _mm_add_epi32(x2[39], x2[40]);
793   x3[40] = _mm_sub_epi32(x2[39], x2[40]);
794   x3[48] = _mm_sub_epi32(x2[63], x2[48]);
795   x3[63] = _mm_add_epi32(x2[63], x2[48]);
796   x3[49] = _mm_sub_epi32(x2[62], x2[49]);
797   x3[62] = _mm_add_epi32(x2[62], x2[49]);
798   x3[50] = _mm_sub_epi32(x2[61], x2[50]);
799   x3[61] = _mm_add_epi32(x2[61], x2[50]);
800   x3[51] = _mm_sub_epi32(x2[60], x2[51]);
801   x3[60] = _mm_add_epi32(x2[60], x2[51]);
802   x3[52] = _mm_sub_epi32(x2[59], x2[52]);
803   x3[59] = _mm_add_epi32(x2[59], x2[52]);
804   x3[53] = _mm_sub_epi32(x2[58], x2[53]);
805   x3[58] = _mm_add_epi32(x2[58], x2[53]);
806   x3[54] = _mm_sub_epi32(x2[57], x2[54]);
807   x3[57] = _mm_add_epi32(x2[57], x2[54]);
808   x3[55] = _mm_sub_epi32(x2[56], x2[55]);
809   x3[56] = _mm_add_epi32(x2[56], x2[55]);
810 
811   // stage 4
812   __m128i x4[64];
813   x4[0] = _mm_add_epi32(x3[0], x3[7]);
814   x4[7] = _mm_sub_epi32(x3[0], x3[7]);
815   x4[1] = _mm_add_epi32(x3[1], x3[6]);
816   x4[6] = _mm_sub_epi32(x3[1], x3[6]);
817   x4[2] = _mm_add_epi32(x3[2], x3[5]);
818   x4[5] = _mm_sub_epi32(x3[2], x3[5]);
819   x4[3] = _mm_add_epi32(x3[3], x3[4]);
820   x4[4] = _mm_sub_epi32(x3[3], x3[4]);
821   x4[8] = x3[8];
822   x4[9] = x3[9];
823   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x3[10], x3[13], x4[10], x4[13],
824                           __rounding, cos_bit);
825   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x3[11], x3[12], x4[11], x4[12],
826                           __rounding, cos_bit);
827   x4[14] = x3[14];
828   x4[15] = x3[15];
829   x4[16] = _mm_add_epi32(x3[16], x3[23]);
830   x4[23] = _mm_sub_epi32(x3[16], x3[23]);
831   x4[17] = _mm_add_epi32(x3[17], x3[22]);
832   x4[22] = _mm_sub_epi32(x3[17], x3[22]);
833   x4[18] = _mm_add_epi32(x3[18], x3[21]);
834   x4[21] = _mm_sub_epi32(x3[18], x3[21]);
835   x4[19] = _mm_add_epi32(x3[19], x3[20]);
836   x4[20] = _mm_sub_epi32(x3[19], x3[20]);
837   x4[24] = _mm_sub_epi32(x3[31], x3[24]);
838   x4[31] = _mm_add_epi32(x3[31], x3[24]);
839   x4[25] = _mm_sub_epi32(x3[30], x3[25]);
840   x4[30] = _mm_add_epi32(x3[30], x3[25]);
841   x4[26] = _mm_sub_epi32(x3[29], x3[26]);
842   x4[29] = _mm_add_epi32(x3[29], x3[26]);
843   x4[27] = _mm_sub_epi32(x3[28], x3[27]);
844   x4[28] = _mm_add_epi32(x3[28], x3[27]);
845   x4[32] = x3[32];
846   x4[33] = x3[33];
847   x4[34] = x3[34];
848   x4[35] = x3[35];
849   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x3[36], x3[59], x4[36], x4[59],
850                           __rounding, cos_bit);
851   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x3[37], x3[58], x4[37], x4[58],
852                           __rounding, cos_bit);
853   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x3[38], x3[57], x4[38], x4[57],
854                           __rounding, cos_bit);
855   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x3[39], x3[56], x4[39], x4[56],
856                           __rounding, cos_bit);
857   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x3[40], x3[55], x4[40], x4[55],
858                           __rounding, cos_bit);
859   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x3[41], x3[54], x4[41], x4[54],
860                           __rounding, cos_bit);
861   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x3[42], x3[53], x4[42], x4[53],
862                           __rounding, cos_bit);
863   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x3[43], x3[52], x4[43], x4[52],
864                           __rounding, cos_bit);
865   x4[44] = x3[44];
866   x4[45] = x3[45];
867   x4[46] = x3[46];
868   x4[47] = x3[47];
869   x4[48] = x3[48];
870   x4[49] = x3[49];
871   x4[50] = x3[50];
872   x4[51] = x3[51];
873   x4[60] = x3[60];
874   x4[61] = x3[61];
875   x4[62] = x3[62];
876   x4[63] = x3[63];
877 
878   // stage 5
879   __m128i x5[64];
880   x5[0] = _mm_add_epi32(x4[0], x4[3]);
881   x5[3] = _mm_sub_epi32(x4[0], x4[3]);
882   x5[1] = _mm_add_epi32(x4[1], x4[2]);
883   x5[2] = _mm_sub_epi32(x4[1], x4[2]);
884   x5[4] = x4[4];
885   btf_32_type0_sse4_1_new(cospi_m32, cospi_p32, x4[5], x4[6], x5[5], x5[6],
886                           __rounding, cos_bit);
887   x5[7] = x4[7];
888   x5[8] = _mm_add_epi32(x4[8], x4[11]);
889   x5[11] = _mm_sub_epi32(x4[8], x4[11]);
890   x5[9] = _mm_add_epi32(x4[9], x4[10]);
891   x5[10] = _mm_sub_epi32(x4[9], x4[10]);
892   x5[12] = _mm_sub_epi32(x4[15], x4[12]);
893   x5[15] = _mm_add_epi32(x4[15], x4[12]);
894   x5[13] = _mm_sub_epi32(x4[14], x4[13]);
895   x5[14] = _mm_add_epi32(x4[14], x4[13]);
896   x5[16] = x4[16];
897   x5[17] = x4[17];
898   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x4[18], x4[29], x5[18], x5[29],
899                           __rounding, cos_bit);
900   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x4[19], x4[28], x5[19], x5[28],
901                           __rounding, cos_bit);
902   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x4[20], x4[27], x5[20], x5[27],
903                           __rounding, cos_bit);
904   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x4[21], x4[26], x5[21], x5[26],
905                           __rounding, cos_bit);
906   x5[22] = x4[22];
907   x5[23] = x4[23];
908   x5[24] = x4[24];
909   x5[25] = x4[25];
910   x5[30] = x4[30];
911   x5[31] = x4[31];
912   x5[32] = _mm_add_epi32(x4[32], x4[39]);
913   x5[39] = _mm_sub_epi32(x4[32], x4[39]);
914   x5[33] = _mm_add_epi32(x4[33], x4[38]);
915   x5[38] = _mm_sub_epi32(x4[33], x4[38]);
916   x5[34] = _mm_add_epi32(x4[34], x4[37]);
917   x5[37] = _mm_sub_epi32(x4[34], x4[37]);
918   x5[35] = _mm_add_epi32(x4[35], x4[36]);
919   x5[36] = _mm_sub_epi32(x4[35], x4[36]);
920   x5[40] = _mm_sub_epi32(x4[47], x4[40]);
921   x5[47] = _mm_add_epi32(x4[47], x4[40]);
922   x5[41] = _mm_sub_epi32(x4[46], x4[41]);
923   x5[46] = _mm_add_epi32(x4[46], x4[41]);
924   x5[42] = _mm_sub_epi32(x4[45], x4[42]);
925   x5[45] = _mm_add_epi32(x4[45], x4[42]);
926   x5[43] = _mm_sub_epi32(x4[44], x4[43]);
927   x5[44] = _mm_add_epi32(x4[44], x4[43]);
928   x5[48] = _mm_add_epi32(x4[48], x4[55]);
929   x5[55] = _mm_sub_epi32(x4[48], x4[55]);
930   x5[49] = _mm_add_epi32(x4[49], x4[54]);
931   x5[54] = _mm_sub_epi32(x4[49], x4[54]);
932   x5[50] = _mm_add_epi32(x4[50], x4[53]);
933   x5[53] = _mm_sub_epi32(x4[50], x4[53]);
934   x5[51] = _mm_add_epi32(x4[51], x4[52]);
935   x5[52] = _mm_sub_epi32(x4[51], x4[52]);
936   x5[56] = _mm_sub_epi32(x4[63], x4[56]);
937   x5[63] = _mm_add_epi32(x4[63], x4[56]);
938   x5[57] = _mm_sub_epi32(x4[62], x4[57]);
939   x5[62] = _mm_add_epi32(x4[62], x4[57]);
940   x5[58] = _mm_sub_epi32(x4[61], x4[58]);
941   x5[61] = _mm_add_epi32(x4[61], x4[58]);
942   x5[59] = _mm_sub_epi32(x4[60], x4[59]);
943   x5[60] = _mm_add_epi32(x4[60], x4[59]);
944 
945   // stage 6
946   __m128i x6[64];
947   btf_32_type0_sse4_1_new(cospi_p32, cospi_p32, x5[0], x5[1], x6[0], x6[1],
948                           __rounding, cos_bit);
949   btf_32_type1_sse4_1_new(cospi_p48, cospi_p16, x5[2], x5[3], x6[2], x6[3],
950                           __rounding, cos_bit);
951   x6[4] = _mm_add_epi32(x5[4], x5[5]);
952   x6[5] = _mm_sub_epi32(x5[4], x5[5]);
953   x6[6] = _mm_sub_epi32(x5[7], x5[6]);
954   x6[7] = _mm_add_epi32(x5[7], x5[6]);
955   x6[8] = x5[8];
956   btf_32_type0_sse4_1_new(cospi_m16, cospi_p48, x5[9], x5[14], x6[9], x6[14],
957                           __rounding, cos_bit);
958   btf_32_type0_sse4_1_new(cospi_m48, cospi_m16, x5[10], x5[13], x6[10], x6[13],
959                           __rounding, cos_bit);
960   x6[11] = x5[11];
961   x6[12] = x5[12];
962   x6[15] = x5[15];
963   x6[16] = _mm_add_epi32(x5[16], x5[19]);
964   x6[19] = _mm_sub_epi32(x5[16], x5[19]);
965   x6[17] = _mm_add_epi32(x5[17], x5[18]);
966   x6[18] = _mm_sub_epi32(x5[17], x5[18]);
967   x6[20] = _mm_sub_epi32(x5[23], x5[20]);
968   x6[23] = _mm_add_epi32(x5[23], x5[20]);
969   x6[21] = _mm_sub_epi32(x5[22], x5[21]);
970   x6[22] = _mm_add_epi32(x5[22], x5[21]);
971   x6[24] = _mm_add_epi32(x5[24], x5[27]);
972   x6[27] = _mm_sub_epi32(x5[24], x5[27]);
973   x6[25] = _mm_add_epi32(x5[25], x5[26]);
974   x6[26] = _mm_sub_epi32(x5[25], x5[26]);
975   x6[28] = _mm_sub_epi32(x5[31], x5[28]);
976   x6[31] = _mm_add_epi32(x5[31], x5[28]);
977   x6[29] = _mm_sub_epi32(x5[30], x5[29]);
978   x6[30] = _mm_add_epi32(x5[30], x5[29]);
979   x6[32] = x5[32];
980   x6[33] = x5[33];
981   btf_32_type0_sse4_1_new(cospi_m08, cospi_p56, x5[34], x5[61], x6[34], x6[61],
982                           __rounding, cos_bit);
983   btf_32_type0_sse4_1_new(cospi_m08, cospi_p56, x5[35], x5[60], x6[35], x6[60],
984                           __rounding, cos_bit);
985   btf_32_type0_sse4_1_new(cospi_m56, cospi_m08, x5[36], x5[59], x6[36], x6[59],
986                           __rounding, cos_bit);
987   btf_32_type0_sse4_1_new(cospi_m56, cospi_m08, x5[37], x5[58], x6[37], x6[58],
988                           __rounding, cos_bit);
989   x6[38] = x5[38];
990   x6[39] = x5[39];
991   x6[40] = x5[40];
992   x6[41] = x5[41];
993   btf_32_type0_sse4_1_new(cospi_m40, cospi_p24, x5[42], x5[53], x6[42], x6[53],
994                           __rounding, cos_bit);
995   btf_32_type0_sse4_1_new(cospi_m40, cospi_p24, x5[43], x5[52], x6[43], x6[52],
996                           __rounding, cos_bit);
997   btf_32_type0_sse4_1_new(cospi_m24, cospi_m40, x5[44], x5[51], x6[44], x6[51],
998                           __rounding, cos_bit);
999   btf_32_type0_sse4_1_new(cospi_m24, cospi_m40, x5[45], x5[50], x6[45], x6[50],
1000                           __rounding, cos_bit);
1001   x6[46] = x5[46];
1002   x6[47] = x5[47];
1003   x6[48] = x5[48];
1004   x6[49] = x5[49];
1005   x6[54] = x5[54];
1006   x6[55] = x5[55];
1007   x6[56] = x5[56];
1008   x6[57] = x5[57];
1009   x6[62] = x5[62];
1010   x6[63] = x5[63];
1011 
1012   // stage 7
1013   __m128i x7[64];
1014   x7[0] = x6[0];
1015   x7[1] = x6[1];
1016   x7[2] = x6[2];
1017   x7[3] = x6[3];
1018   btf_32_type1_sse4_1_new(cospi_p56, cospi_p08, x6[4], x6[7], x7[4], x7[7],
1019                           __rounding, cos_bit);
1020   btf_32_type1_sse4_1_new(cospi_p24, cospi_p40, x6[5], x6[6], x7[5], x7[6],
1021                           __rounding, cos_bit);
1022   x7[8] = _mm_add_epi32(x6[8], x6[9]);
1023   x7[9] = _mm_sub_epi32(x6[8], x6[9]);
1024   x7[10] = _mm_sub_epi32(x6[11], x6[10]);
1025   x7[11] = _mm_add_epi32(x6[11], x6[10]);
1026   x7[12] = _mm_add_epi32(x6[12], x6[13]);
1027   x7[13] = _mm_sub_epi32(x6[12], x6[13]);
1028   x7[14] = _mm_sub_epi32(x6[15], x6[14]);
1029   x7[15] = _mm_add_epi32(x6[15], x6[14]);
1030   x7[16] = x6[16];
1031   btf_32_type0_sse4_1_new(cospi_m08, cospi_p56, x6[17], x6[30], x7[17], x7[30],
1032                           __rounding, cos_bit);
1033   btf_32_type0_sse4_1_new(cospi_m56, cospi_m08, x6[18], x6[29], x7[18], x7[29],
1034                           __rounding, cos_bit);
1035   x7[19] = x6[19];
1036   x7[20] = x6[20];
1037   btf_32_type0_sse4_1_new(cospi_m40, cospi_p24, x6[21], x6[26], x7[21], x7[26],
1038                           __rounding, cos_bit);
1039   btf_32_type0_sse4_1_new(cospi_m24, cospi_m40, x6[22], x6[25], x7[22], x7[25],
1040                           __rounding, cos_bit);
1041   x7[23] = x6[23];
1042   x7[24] = x6[24];
1043   x7[27] = x6[27];
1044   x7[28] = x6[28];
1045   x7[31] = x6[31];
1046   x7[32] = _mm_add_epi32(x6[32], x6[35]);
1047   x7[35] = _mm_sub_epi32(x6[32], x6[35]);
1048   x7[33] = _mm_add_epi32(x6[33], x6[34]);
1049   x7[34] = _mm_sub_epi32(x6[33], x6[34]);
1050   x7[36] = _mm_sub_epi32(x6[39], x6[36]);
1051   x7[39] = _mm_add_epi32(x6[39], x6[36]);
1052   x7[37] = _mm_sub_epi32(x6[38], x6[37]);
1053   x7[38] = _mm_add_epi32(x6[38], x6[37]);
1054   x7[40] = _mm_add_epi32(x6[40], x6[43]);
1055   x7[43] = _mm_sub_epi32(x6[40], x6[43]);
1056   x7[41] = _mm_add_epi32(x6[41], x6[42]);
1057   x7[42] = _mm_sub_epi32(x6[41], x6[42]);
1058   x7[44] = _mm_sub_epi32(x6[47], x6[44]);
1059   x7[47] = _mm_add_epi32(x6[47], x6[44]);
1060   x7[45] = _mm_sub_epi32(x6[46], x6[45]);
1061   x7[46] = _mm_add_epi32(x6[46], x6[45]);
1062   x7[48] = _mm_add_epi32(x6[48], x6[51]);
1063   x7[51] = _mm_sub_epi32(x6[48], x6[51]);
1064   x7[49] = _mm_add_epi32(x6[49], x6[50]);
1065   x7[50] = _mm_sub_epi32(x6[49], x6[50]);
1066   x7[52] = _mm_sub_epi32(x6[55], x6[52]);
1067   x7[55] = _mm_add_epi32(x6[55], x6[52]);
1068   x7[53] = _mm_sub_epi32(x6[54], x6[53]);
1069   x7[54] = _mm_add_epi32(x6[54], x6[53]);
1070   x7[56] = _mm_add_epi32(x6[56], x6[59]);
1071   x7[59] = _mm_sub_epi32(x6[56], x6[59]);
1072   x7[57] = _mm_add_epi32(x6[57], x6[58]);
1073   x7[58] = _mm_sub_epi32(x6[57], x6[58]);
1074   x7[60] = _mm_sub_epi32(x6[63], x6[60]);
1075   x7[63] = _mm_add_epi32(x6[63], x6[60]);
1076   x7[61] = _mm_sub_epi32(x6[62], x6[61]);
1077   x7[62] = _mm_add_epi32(x6[62], x6[61]);
1078 
1079   // stage 8
1080   __m128i x8[64];
1081   x8[0] = x7[0];
1082   x8[1] = x7[1];
1083   x8[2] = x7[2];
1084   x8[3] = x7[3];
1085   x8[4] = x7[4];
1086   x8[5] = x7[5];
1087   x8[6] = x7[6];
1088   x8[7] = x7[7];
1089   btf_32_type1_sse4_1_new(cospi_p60, cospi_p04, x7[8], x7[15], x8[8], x8[15],
1090                           __rounding, cos_bit);
1091   btf_32_type1_sse4_1_new(cospi_p28, cospi_p36, x7[9], x7[14], x8[9], x8[14],
1092                           __rounding, cos_bit);
1093   btf_32_type1_sse4_1_new(cospi_p44, cospi_p20, x7[10], x7[13], x8[10], x8[13],
1094                           __rounding, cos_bit);
1095   btf_32_type1_sse4_1_new(cospi_p12, cospi_p52, x7[11], x7[12], x8[11], x8[12],
1096                           __rounding, cos_bit);
1097   x8[16] = _mm_add_epi32(x7[16], x7[17]);
1098   x8[17] = _mm_sub_epi32(x7[16], x7[17]);
1099   x8[18] = _mm_sub_epi32(x7[19], x7[18]);
1100   x8[19] = _mm_add_epi32(x7[19], x7[18]);
1101   x8[20] = _mm_add_epi32(x7[20], x7[21]);
1102   x8[21] = _mm_sub_epi32(x7[20], x7[21]);
1103   x8[22] = _mm_sub_epi32(x7[23], x7[22]);
1104   x8[23] = _mm_add_epi32(x7[23], x7[22]);
1105   x8[24] = _mm_add_epi32(x7[24], x7[25]);
1106   x8[25] = _mm_sub_epi32(x7[24], x7[25]);
1107   x8[26] = _mm_sub_epi32(x7[27], x7[26]);
1108   x8[27] = _mm_add_epi32(x7[27], x7[26]);
1109   x8[28] = _mm_add_epi32(x7[28], x7[29]);
1110   x8[29] = _mm_sub_epi32(x7[28], x7[29]);
1111   x8[30] = _mm_sub_epi32(x7[31], x7[30]);
1112   x8[31] = _mm_add_epi32(x7[31], x7[30]);
1113   x8[32] = x7[32];
1114   btf_32_type0_sse4_1_new(cospi_m04, cospi_p60, x7[33], x7[62], x8[33], x8[62],
1115                           __rounding, cos_bit);
1116   btf_32_type0_sse4_1_new(cospi_m60, cospi_m04, x7[34], x7[61], x8[34], x8[61],
1117                           __rounding, cos_bit);
1118   x8[35] = x7[35];
1119   x8[36] = x7[36];
1120   btf_32_type0_sse4_1_new(cospi_m36, cospi_p28, x7[37], x7[58], x8[37], x8[58],
1121                           __rounding, cos_bit);
1122   btf_32_type0_sse4_1_new(cospi_m28, cospi_m36, x7[38], x7[57], x8[38], x8[57],
1123                           __rounding, cos_bit);
1124   x8[39] = x7[39];
1125   x8[40] = x7[40];
1126   btf_32_type0_sse4_1_new(cospi_m20, cospi_p44, x7[41], x7[54], x8[41], x8[54],
1127                           __rounding, cos_bit);
1128   btf_32_type0_sse4_1_new(cospi_m44, cospi_m20, x7[42], x7[53], x8[42], x8[53],
1129                           __rounding, cos_bit);
1130   x8[43] = x7[43];
1131   x8[44] = x7[44];
1132   btf_32_type0_sse4_1_new(cospi_m52, cospi_p12, x7[45], x7[50], x8[45], x8[50],
1133                           __rounding, cos_bit);
1134   btf_32_type0_sse4_1_new(cospi_m12, cospi_m52, x7[46], x7[49], x8[46], x8[49],
1135                           __rounding, cos_bit);
1136   x8[47] = x7[47];
1137   x8[48] = x7[48];
1138   x8[51] = x7[51];
1139   x8[52] = x7[52];
1140   x8[55] = x7[55];
1141   x8[56] = x7[56];
1142   x8[59] = x7[59];
1143   x8[60] = x7[60];
1144   x8[63] = x7[63];
1145 
1146   // stage 9
1147   __m128i x9[64];
1148   x9[0] = x8[0];
1149   x9[1] = x8[1];
1150   x9[2] = x8[2];
1151   x9[3] = x8[3];
1152   x9[4] = x8[4];
1153   x9[5] = x8[5];
1154   x9[6] = x8[6];
1155   x9[7] = x8[7];
1156   x9[8] = x8[8];
1157   x9[9] = x8[9];
1158   x9[10] = x8[10];
1159   x9[11] = x8[11];
1160   x9[12] = x8[12];
1161   x9[13] = x8[13];
1162   x9[14] = x8[14];
1163   x9[15] = x8[15];
1164   btf_32_type1_sse4_1_new(cospi_p62, cospi_p02, x8[16], x8[31], x9[16], x9[31],
1165                           __rounding, cos_bit);
1166   btf_32_type1_sse4_1_new(cospi_p30, cospi_p34, x8[17], x8[30], x9[17], x9[30],
1167                           __rounding, cos_bit);
1168   btf_32_type1_sse4_1_new(cospi_p46, cospi_p18, x8[18], x8[29], x9[18], x9[29],
1169                           __rounding, cos_bit);
1170   btf_32_type1_sse4_1_new(cospi_p14, cospi_p50, x8[19], x8[28], x9[19], x9[28],
1171                           __rounding, cos_bit);
1172   btf_32_type1_sse4_1_new(cospi_p54, cospi_p10, x8[20], x8[27], x9[20], x9[27],
1173                           __rounding, cos_bit);
1174   btf_32_type1_sse4_1_new(cospi_p22, cospi_p42, x8[21], x8[26], x9[21], x9[26],
1175                           __rounding, cos_bit);
1176   btf_32_type1_sse4_1_new(cospi_p38, cospi_p26, x8[22], x8[25], x9[22], x9[25],
1177                           __rounding, cos_bit);
1178   btf_32_type1_sse4_1_new(cospi_p06, cospi_p58, x8[23], x8[24], x9[23], x9[24],
1179                           __rounding, cos_bit);
1180   x9[32] = _mm_add_epi32(x8[32], x8[33]);
1181   x9[33] = _mm_sub_epi32(x8[32], x8[33]);
1182   x9[34] = _mm_sub_epi32(x8[35], x8[34]);
1183   x9[35] = _mm_add_epi32(x8[35], x8[34]);
1184   x9[36] = _mm_add_epi32(x8[36], x8[37]);
1185   x9[37] = _mm_sub_epi32(x8[36], x8[37]);
1186   x9[38] = _mm_sub_epi32(x8[39], x8[38]);
1187   x9[39] = _mm_add_epi32(x8[39], x8[38]);
1188   x9[40] = _mm_add_epi32(x8[40], x8[41]);
1189   x9[41] = _mm_sub_epi32(x8[40], x8[41]);
1190   x9[42] = _mm_sub_epi32(x8[43], x8[42]);
1191   x9[43] = _mm_add_epi32(x8[43], x8[42]);
1192   x9[44] = _mm_add_epi32(x8[44], x8[45]);
1193   x9[45] = _mm_sub_epi32(x8[44], x8[45]);
1194   x9[46] = _mm_sub_epi32(x8[47], x8[46]);
1195   x9[47] = _mm_add_epi32(x8[47], x8[46]);
1196   x9[48] = _mm_add_epi32(x8[48], x8[49]);
1197   x9[49] = _mm_sub_epi32(x8[48], x8[49]);
1198   x9[50] = _mm_sub_epi32(x8[51], x8[50]);
1199   x9[51] = _mm_add_epi32(x8[51], x8[50]);
1200   x9[52] = _mm_add_epi32(x8[52], x8[53]);
1201   x9[53] = _mm_sub_epi32(x8[52], x8[53]);
1202   x9[54] = _mm_sub_epi32(x8[55], x8[54]);
1203   x9[55] = _mm_add_epi32(x8[55], x8[54]);
1204   x9[56] = _mm_add_epi32(x8[56], x8[57]);
1205   x9[57] = _mm_sub_epi32(x8[56], x8[57]);
1206   x9[58] = _mm_sub_epi32(x8[59], x8[58]);
1207   x9[59] = _mm_add_epi32(x8[59], x8[58]);
1208   x9[60] = _mm_add_epi32(x8[60], x8[61]);
1209   x9[61] = _mm_sub_epi32(x8[60], x8[61]);
1210   x9[62] = _mm_sub_epi32(x8[63], x8[62]);
1211   x9[63] = _mm_add_epi32(x8[63], x8[62]);
1212 
1213   // stage 10
1214   __m128i x10[64];
1215   x10[0] = x9[0];
1216   x10[1] = x9[1];
1217   x10[2] = x9[2];
1218   x10[3] = x9[3];
1219   x10[4] = x9[4];
1220   x10[5] = x9[5];
1221   x10[6] = x9[6];
1222   x10[7] = x9[7];
1223   x10[8] = x9[8];
1224   x10[9] = x9[9];
1225   x10[10] = x9[10];
1226   x10[11] = x9[11];
1227   x10[12] = x9[12];
1228   x10[13] = x9[13];
1229   x10[14] = x9[14];
1230   x10[15] = x9[15];
1231   x10[16] = x9[16];
1232   x10[17] = x9[17];
1233   x10[18] = x9[18];
1234   x10[19] = x9[19];
1235   x10[20] = x9[20];
1236   x10[21] = x9[21];
1237   x10[22] = x9[22];
1238   x10[23] = x9[23];
1239   x10[24] = x9[24];
1240   x10[25] = x9[25];
1241   x10[26] = x9[26];
1242   x10[27] = x9[27];
1243   x10[28] = x9[28];
1244   x10[29] = x9[29];
1245   x10[30] = x9[30];
1246   x10[31] = x9[31];
1247   btf_32_type1_sse4_1_new(cospi_p63, cospi_p01, x9[32], x9[63], x10[32],
1248                           x10[63], __rounding, cos_bit);
1249   btf_32_type1_sse4_1_new(cospi_p31, cospi_p33, x9[33], x9[62], x10[33],
1250                           x10[62], __rounding, cos_bit);
1251   btf_32_type1_sse4_1_new(cospi_p47, cospi_p17, x9[34], x9[61], x10[34],
1252                           x10[61], __rounding, cos_bit);
1253   btf_32_type1_sse4_1_new(cospi_p15, cospi_p49, x9[35], x9[60], x10[35],
1254                           x10[60], __rounding, cos_bit);
1255   btf_32_type1_sse4_1_new(cospi_p55, cospi_p09, x9[36], x9[59], x10[36],
1256                           x10[59], __rounding, cos_bit);
1257   btf_32_type1_sse4_1_new(cospi_p23, cospi_p41, x9[37], x9[58], x10[37],
1258                           x10[58], __rounding, cos_bit);
1259   btf_32_type1_sse4_1_new(cospi_p39, cospi_p25, x9[38], x9[57], x10[38],
1260                           x10[57], __rounding, cos_bit);
1261   btf_32_type1_sse4_1_new(cospi_p07, cospi_p57, x9[39], x9[56], x10[39],
1262                           x10[56], __rounding, cos_bit);
1263   btf_32_type1_sse4_1_new(cospi_p59, cospi_p05, x9[40], x9[55], x10[40],
1264                           x10[55], __rounding, cos_bit);
1265   btf_32_type1_sse4_1_new(cospi_p27, cospi_p37, x9[41], x9[54], x10[41],
1266                           x10[54], __rounding, cos_bit);
1267   btf_32_type1_sse4_1_new(cospi_p43, cospi_p21, x9[42], x9[53], x10[42],
1268                           x10[53], __rounding, cos_bit);
1269   btf_32_type1_sse4_1_new(cospi_p11, cospi_p53, x9[43], x9[52], x10[43],
1270                           x10[52], __rounding, cos_bit);
1271   btf_32_type1_sse4_1_new(cospi_p51, cospi_p13, x9[44], x9[51], x10[44],
1272                           x10[51], __rounding, cos_bit);
1273   btf_32_type1_sse4_1_new(cospi_p19, cospi_p45, x9[45], x9[50], x10[45],
1274                           x10[50], __rounding, cos_bit);
1275   btf_32_type1_sse4_1_new(cospi_p35, cospi_p29, x9[46], x9[49], x10[46],
1276                           x10[49], __rounding, cos_bit);
1277   btf_32_type1_sse4_1_new(cospi_p03, cospi_p61, x9[47], x9[48], x10[47],
1278                           x10[48], __rounding, cos_bit);
1279 
1280   startidx = 0 * outstride;
1281   endidx = 63 * outstride;
1282   // stage 11
1283   output[startidx] = x10[0];
1284   output[endidx] = x10[63];
1285   startidx += outstride;
1286   endidx -= outstride;
1287   output[startidx] = x10[32];
1288   output[endidx] = x10[31];
1289   startidx += outstride;
1290   endidx -= outstride;
1291   output[startidx] = x10[16];
1292   output[endidx] = x10[47];
1293   startidx += outstride;
1294   endidx -= outstride;
1295   output[startidx] = x10[48];
1296   output[endidx] = x10[15];
1297   startidx += outstride;
1298   endidx -= outstride;
1299   output[startidx] = x10[8];
1300   output[endidx] = x10[55];
1301   startidx += outstride;
1302   endidx -= outstride;
1303   output[startidx] = x10[40];
1304   output[endidx] = x10[23];
1305   startidx += outstride;
1306   endidx -= outstride;
1307   output[startidx] = x10[24];
1308   output[endidx] = x10[39];
1309   startidx += outstride;
1310   endidx -= outstride;
1311   output[startidx] = x10[56];
1312   output[endidx] = x10[7];
1313   startidx += outstride;
1314   endidx -= outstride;
1315   output[startidx] = x10[4];
1316   output[endidx] = x10[59];
1317   startidx += outstride;
1318   endidx -= outstride;
1319   output[startidx] = x10[36];
1320   output[endidx] = x10[27];
1321   startidx += outstride;
1322   endidx -= outstride;
1323   output[startidx] = x10[20];
1324   output[endidx] = x10[43];
1325   startidx += outstride;
1326   endidx -= outstride;
1327   output[startidx] = x10[52];
1328   output[endidx] = x10[11];
1329   startidx += outstride;
1330   endidx -= outstride;
1331   output[startidx] = x10[12];
1332   output[endidx] = x10[51];
1333   startidx += outstride;
1334   endidx -= outstride;
1335   output[startidx] = x10[44];
1336   output[endidx] = x10[19];
1337   startidx += outstride;
1338   endidx -= outstride;
1339   output[startidx] = x10[28];
1340   output[endidx] = x10[35];
1341   startidx += outstride;
1342   endidx -= outstride;
1343   output[startidx] = x10[60];
1344   output[endidx] = x10[3];
1345   startidx += outstride;
1346   endidx -= outstride;
1347   output[startidx] = x10[2];
1348   output[endidx] = x10[61];
1349   startidx += outstride;
1350   endidx -= outstride;
1351   output[startidx] = x10[34];
1352   output[endidx] = x10[29];
1353   startidx += outstride;
1354   endidx -= outstride;
1355   output[startidx] = x10[18];
1356   output[endidx] = x10[45];
1357   startidx += outstride;
1358   endidx -= outstride;
1359   output[startidx] = x10[50];
1360   output[endidx] = x10[13];
1361   startidx += outstride;
1362   endidx -= outstride;
1363   output[startidx] = x10[10];
1364   output[endidx] = x10[53];
1365   startidx += outstride;
1366   endidx -= outstride;
1367   output[startidx] = x10[42];
1368   output[endidx] = x10[21];
1369   startidx += outstride;
1370   endidx -= outstride;
1371   output[startidx] = x10[26];
1372   output[endidx] = x10[37];
1373   startidx += outstride;
1374   endidx -= outstride;
1375   output[startidx] = x10[58];
1376   output[endidx] = x10[5];
1377   startidx += outstride;
1378   endidx -= outstride;
1379   output[startidx] = x10[6];
1380   output[endidx] = x10[57];
1381   startidx += outstride;
1382   endidx -= outstride;
1383   output[startidx] = x10[38];
1384   output[endidx] = x10[25];
1385   startidx += outstride;
1386   endidx -= outstride;
1387   output[startidx] = x10[22];
1388   output[endidx] = x10[41];
1389   startidx += outstride;
1390   endidx -= outstride;
1391   output[startidx] = x10[54];
1392   output[endidx] = x10[9];
1393   startidx += outstride;
1394   endidx -= outstride;
1395   output[startidx] = x10[14];
1396   output[endidx] = x10[49];
1397   startidx += outstride;
1398   endidx -= outstride;
1399   output[startidx] = x10[46];
1400   output[endidx] = x10[17];
1401   startidx += outstride;
1402   endidx -= outstride;
1403   output[startidx] = x10[30];
1404   output[endidx] = x10[33];
1405   startidx += outstride;
1406   endidx -= outstride;
1407   output[startidx] = x10[62];
1408   output[endidx] = x10[1];
1409 }
1410 
av1_idtx32_sse4_1(__m128i * input,__m128i * output,int cos_bit,const int col_num)1411 void av1_idtx32_sse4_1(__m128i *input, __m128i *output, int cos_bit,
1412                        const int col_num) {
1413   (void)cos_bit;
1414   for (int i = 0; i < 32; i++) {
1415     output[i * col_num] = _mm_slli_epi32(input[i * col_num], 2);
1416   }
1417 }
1418