FFmpeg
mpegaudiodsp_mips_fixed.c
Go to the documentation of this file.
1  /*
2  * Copyright (c) 2012
3  * MIPS Technologies, Inc., California.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * Author: Bojan Zivkovic (bojan@mips.com)
30  *
31  * MPEG Audio decoder optimized for MIPS fixed-point architecture
32  *
33  * This file is part of FFmpeg.
34  *
35  * FFmpeg is free software; you can redistribute it and/or
36  * modify it under the terms of the GNU Lesser General Public
37  * License as published by the Free Software Foundation; either
38  * version 2.1 of the License, or (at your option) any later version.
39  *
40  * FFmpeg is distributed in the hope that it will be useful,
41  * but WITHOUT ANY WARRANTY; without even the implied warranty of
42  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43  * Lesser General Public License for more details.
44  *
45  * You should have received a copy of the GNU Lesser General Public
46  * License along with FFmpeg; if not, write to the Free Software
47  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48  */
49 
50 /**
51  * @file
52  * Reference: libavcodec/mpegaudiodsp_template.c
53  */
54 
55 #include <string.h>
56 
57 #include "libavutil/mips/asmdefs.h"
59 
60 #if HAVE_INLINE_ASM
61 #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
62 
63 static void ff_mpadsp_apply_window_mips_fixed(int32_t *synth_buf, int32_t *window,
64  int *dither_state, int16_t *samples, ptrdiff_t incr)
65 {
66  register const int32_t *w, *w2, *p;
67  int j;
68  int16_t *samples2;
69  int w_asm, p_asm, w_asm1, p_asm1, w_asm2, p_asm2;
70  int w2_asm, w2_asm1, *p_temp1, *p_temp2;
71  int sum1 = 0;
72  int const min_asm = -32768, max_asm = 32767;
73  int temp1, temp2 = 0, temp3 = 0;
74  int64_t sum;
75 
76  /* copy to avoid wrap */
77  memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
78  samples2 = samples + 31 * incr;
79  w = window;
80  w2 = window + 31;
81  sum = *dither_state;
82  p = synth_buf + 16;
83  p_temp1 = synth_buf + 16;
84  p_temp2 = synth_buf + 48;
85  temp1 = sum;
86 
87  /**
88  * use of round_sample function from the original code is eliminated,
89  * changed with appropriate assembly instructions.
90  */
91  __asm__ volatile (
92  "mthi $zero \n\t"
93  "mtlo %[temp1] \n\t"
94  "lw %[w_asm], 0(%[w]) \n\t"
95  "lw %[p_asm], 0(%[p]) \n\t"
96  "lw %[w_asm1], 64*4(%[w]) \n\t"
97  "lw %[p_asm1], 64*4(%[p]) \n\t"
98  "lw %[w_asm2], 128*4(%[w]) \n\t"
99  "lw %[p_asm2], 128*4(%[p]) \n\t"
100  "madd %[w_asm], %[p_asm] \n\t"
101  "madd %[w_asm1], %[p_asm1] \n\t"
102  "madd %[w_asm2], %[p_asm2] \n\t"
103  "lw %[w_asm], 192*4(%[w]) \n\t"
104  "lw %[p_asm], 192*4(%[p]) \n\t"
105  "lw %[w_asm1], 256*4(%[w]) \n\t"
106  "lw %[p_asm1], 256*4(%[p]) \n\t"
107  "lw %[w_asm2], 320*4(%[w]) \n\t"
108  "lw %[p_asm2], 320*4(%[p]) \n\t"
109  "madd %[w_asm], %[p_asm] \n\t"
110  "madd %[w_asm1], %[p_asm1] \n\t"
111  "madd %[w_asm2], %[p_asm2] \n\t"
112  "lw %[w_asm], 384*4(%[w]) \n\t"
113  "lw %[p_asm], 384*4(%[p]) \n\t"
114  "lw %[w_asm1], 448*4(%[w]) \n\t"
115  "lw %[p_asm1], 448*4(%[p]) \n\t"
116  "lw %[w_asm2], 32*4(%[w]) \n\t"
117  "lw %[p_asm2], 32*4(%[p]) \n\t"
118  "madd %[w_asm], %[p_asm] \n\t"
119  "madd %[w_asm1], %[p_asm1] \n\t"
120  "msub %[w_asm2], %[p_asm2] \n\t"
121  "lw %[w_asm], 96*4(%[w]) \n\t"
122  "lw %[p_asm], 96*4(%[p]) \n\t"
123  "lw %[w_asm1], 160*4(%[w]) \n\t"
124  "lw %[p_asm1], 160*4(%[p]) \n\t"
125  "lw %[w_asm2], 224*4(%[w]) \n\t"
126  "lw %[p_asm2], 224*4(%[p]) \n\t"
127  "msub %[w_asm], %[p_asm] \n\t"
128  "msub %[w_asm1], %[p_asm1] \n\t"
129  "msub %[w_asm2], %[p_asm2] \n\t"
130  "lw %[w_asm], 288*4(%[w]) \n\t"
131  "lw %[p_asm], 288*4(%[p]) \n\t"
132  "lw %[w_asm1], 352*4(%[w]) \n\t"
133  "lw %[p_asm1], 352*4(%[p]) \n\t"
134  "msub %[w_asm], %[p_asm] \n\t"
135  "lw %[w_asm], 480*4(%[w]) \n\t"
136  "lw %[p_asm], 480*4(%[p]) \n\t"
137  "lw %[w_asm2], 416*4(%[w]) \n\t"
138  "lw %[p_asm2], 416*4(%[p]) \n\t"
139  "msub %[w_asm], %[p_asm] \n\t"
140  "msub %[w_asm1], %[p_asm1] \n\t"
141  "msub %[w_asm2], %[p_asm2] \n\t"
142 
143  /*round_sample function from the original code is eliminated,
144  * changed with appropriate assembly instructions
145  * code example:
146 
147  "extr.w %[sum1],$ac0,24 \n\t"
148  "mflo %[temp3], $ac0 \n\t"
149  "and %[temp1], %[temp3], 0x00ffffff \n\t"
150  "slt %[temp2], %[sum1], %[min_asm] \n\t"
151  "movn %[sum1], %[min_asm],%[temp2] \n\t"
152  "slt %[temp2], %[max_asm],%[sum1] \n\t"
153  "movn %[sum1], %[max_asm],%[temp2] \n\t"
154  "sh %[sum1], 0(%[samples]) \n\t"
155  */
156 
157  "extr.w %[sum1], $ac0, 24 \n\t"
158  "mflo %[temp3] \n\t"
159  PTR_ADDIU "%[w], %[w], 4 \n\t"
160  "and %[temp1], %[temp3], 0x00ffffff \n\t"
161  "slt %[temp2], %[sum1], %[min_asm] \n\t"
162  "movn %[sum1], %[min_asm], %[temp2] \n\t"
163  "slt %[temp2], %[max_asm], %[sum1] \n\t"
164  "movn %[sum1], %[max_asm], %[temp2] \n\t"
165  "sh %[sum1], 0(%[samples]) \n\t"
166 
167  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
168  [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
169  [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2),
170  [sum1] "+r" (sum1), [w] "+r" (w), [temp3] "+r" (temp3)
171  : [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
172  [max_asm] "r" (max_asm)
173  : "memory", "hi","lo"
174  );
175 
176  samples += incr;
177 
178  /* we calculate two samples at the same time to avoid one memory
179  access per two sample */
180 
181  for(j = 1; j < 16; j++) {
182  __asm__ volatile (
183  "mthi $0, $ac1 \n\t"
184  "mtlo $0, $ac1 \n\t"
185  "mthi $0 \n\t"
186  "mtlo %[temp1] \n\t"
187  PTR_ADDIU "%[p_temp1], %[p_temp1], 4 \n\t"
188  "lw %[w_asm], 0(%[w]) \n\t"
189  "lw %[p_asm], 0(%[p_temp1]) \n\t"
190  "lw %[w2_asm], 0(%[w2]) \n\t"
191  "lw %[w_asm1], 64*4(%[w]) \n\t"
192  "lw %[p_asm1], 64*4(%[p_temp1]) \n\t"
193  "lw %[w2_asm1], 64*4(%[w2]) \n\t"
194  "madd %[w_asm], %[p_asm] \n\t"
195  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
196  "madd %[w_asm1], %[p_asm1] \n\t"
197  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
198  "lw %[w_asm], 128*4(%[w]) \n\t"
199  "lw %[p_asm], 128*4(%[p_temp1]) \n\t"
200  "lw %[w2_asm], 128*4(%[w2]) \n\t"
201  "lw %[w_asm1], 192*4(%[w]) \n\t"
202  "lw %[p_asm1], 192*4(%[p_temp1]) \n\t"
203  "lw %[w2_asm1], 192*4(%[w2]) \n\t"
204  "madd %[w_asm], %[p_asm] \n\t"
205  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
206  "madd %[w_asm1], %[p_asm1] \n\t"
207  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
208  "lw %[w_asm], 256*4(%[w]) \n\t"
209  "lw %[p_asm], 256*4(%[p_temp1]) \n\t"
210  "lw %[w2_asm], 256*4(%[w2]) \n\t"
211  "lw %[w_asm1], 320*4(%[w]) \n\t"
212  "lw %[p_asm1], 320*4(%[p_temp1]) \n\t"
213  "lw %[w2_asm1], 320*4(%[w2]) \n\t"
214  "madd %[w_asm], %[p_asm] \n\t"
215  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
216  "madd %[w_asm1], %[p_asm1] \n\t"
217  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
218  "lw %[w_asm], 384*4(%[w]) \n\t"
219  "lw %[p_asm], 384*4(%[p_temp1]) \n\t"
220  "lw %[w2_asm], 384*4(%[w2]) \n\t"
221  "lw %[w_asm1], 448*4(%[w]) \n\t"
222  "lw %[p_asm1], 448*4(%[p_temp1]) \n\t"
223  "lw %[w2_asm1], 448*4(%[w2]) \n\t"
224  "madd %[w_asm], %[p_asm] \n\t"
225  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
226  "madd %[w_asm1], %[p_asm1] \n\t"
227  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
228  PTR_ADDIU "%[p_temp2], %[p_temp2], -4 \n\t"
229  "lw %[w_asm], 32*4(%[w]) \n\t"
230  "lw %[p_asm], 0(%[p_temp2]) \n\t"
231  "lw %[w2_asm], 32*4(%[w2]) \n\t"
232  "lw %[w_asm1], 96*4(%[w]) \n\t"
233  "lw %[p_asm1], 64*4(%[p_temp2]) \n\t"
234  "lw %[w2_asm1], 96*4(%[w2]) \n\t"
235  "msub %[w_asm], %[p_asm] \n\t"
236  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
237  "msub %[w_asm1], %[p_asm1] \n\t"
238  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
239  "lw %[w_asm], 160*4(%[w]) \n\t"
240  "lw %[p_asm], 128*4(%[p_temp2]) \n\t"
241  "lw %[w2_asm], 160*4(%[w2]) \n\t"
242  "lw %[w_asm1], 224*4(%[w]) \n\t"
243  "lw %[p_asm1], 192*4(%[p_temp2]) \n\t"
244  "lw %[w2_asm1], 224*4(%[w2]) \n\t"
245  "msub %[w_asm], %[p_asm] \n\t"
246  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
247  "msub %[w_asm1], %[p_asm1] \n\t"
248  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
249  "lw %[w_asm], 288*4(%[w]) \n\t"
250  "lw %[p_asm], 256*4(%[p_temp2]) \n\t"
251  "lw %[w2_asm], 288*4(%[w2]) \n\t"
252  "lw %[w_asm1], 352*4(%[w]) \n\t"
253  "lw %[p_asm1], 320*4(%[p_temp2]) \n\t"
254  "lw %[w2_asm1], 352*4(%[w2]) \n\t"
255  "msub %[w_asm], %[p_asm] \n\t"
256  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
257  "msub %[w_asm1], %[p_asm1] \n\t"
258  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
259  "lw %[w_asm], 416*4(%[w]) \n\t"
260  "lw %[p_asm], 384*4(%[p_temp2]) \n\t"
261  "lw %[w2_asm], 416*4(%[w2]) \n\t"
262  "lw %[w_asm1], 480*4(%[w]) \n\t"
263  "lw %[p_asm1], 448*4(%[p_temp2]) \n\t"
264  "lw %[w2_asm1], 480*4(%[w2]) \n\t"
265  "msub %[w_asm], %[p_asm] \n\t"
266  "msub %[w_asm1], %[p_asm1] \n\t"
267  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
268  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
269  PTR_ADDIU "%[w], %[w], 4 \n\t"
270  PTR_ADDIU "%[w2], %[w2], -4 \n\t"
271  "mflo %[temp2] \n\t"
272  "extr.w %[sum1], $ac0, 24 \n\t"
273  "li %[temp3], 1 \n\t"
274  "and %[temp1], %[temp2], 0x00ffffff \n\t"
275  "madd $ac1, %[temp1], %[temp3] \n\t"
276  "slt %[temp2], %[sum1], %[min_asm] \n\t"
277  "movn %[sum1], %[min_asm], %[temp2] \n\t"
278  "slt %[temp2], %[max_asm], %[sum1] \n\t"
279  "movn %[sum1], %[max_asm], %[temp2] \n\t"
280  "sh %[sum1], 0(%[samples]) \n\t"
281  "mflo %[temp3], $ac1 \n\t"
282  "extr.w %[sum1], $ac1, 24 \n\t"
283  "and %[temp1], %[temp3], 0x00ffffff \n\t"
284  "slt %[temp2], %[sum1], %[min_asm] \n\t"
285  "movn %[sum1], %[min_asm], %[temp2] \n\t"
286  "slt %[temp2], %[max_asm], %[sum1] \n\t"
287  "movn %[sum1], %[max_asm], %[temp2] \n\t"
288  "sh %[sum1], 0(%[samples2]) \n\t"
289 
290  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
291  [p_asm1] "=&r" (p_asm1), [w2_asm1] "=&r" (w2_asm1),
292  [w2_asm] "=&r" (w2_asm), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
293  [p_temp1] "+r" (p_temp1), [p_temp2] "+r" (p_temp2), [sum1] "+r" (sum1),
294  [w] "+r" (w), [w2] "+r" (w2), [samples] "+r" (samples),
295  [samples2] "+r" (samples2), [temp3] "+r" (temp3)
296  : [min_asm] "r" (min_asm), [max_asm] "r" (max_asm)
297  : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
298  );
299 
300  samples += incr;
301  samples2 -= incr;
302  }
303 
304  p = synth_buf + 32;
305 
306  __asm__ volatile (
307  "mthi $0 \n\t"
308  "mtlo %[temp1] \n\t"
309  "lw %[w_asm], 32*4(%[w]) \n\t"
310  "lw %[p_asm], 0(%[p]) \n\t"
311  "lw %[w_asm1], 96*4(%[w]) \n\t"
312  "lw %[p_asm1], 64*4(%[p]) \n\t"
313  "lw %[w_asm2], 160*4(%[w]) \n\t"
314  "lw %[p_asm2], 128*4(%[p]) \n\t"
315  "msub %[w_asm], %[p_asm] \n\t"
316  "msub %[w_asm1], %[p_asm1] \n\t"
317  "msub %[w_asm2], %[p_asm2] \n\t"
318  "lw %[w_asm], 224*4(%[w]) \n\t"
319  "lw %[p_asm], 192*4(%[p]) \n\t"
320  "lw %[w_asm1], 288*4(%[w]) \n\t"
321  "lw %[p_asm1], 256*4(%[p]) \n\t"
322  "lw %[w_asm2], 352*4(%[w]) \n\t"
323  "lw %[p_asm2], 320*4(%[p]) \n\t"
324  "msub %[w_asm], %[p_asm] \n\t"
325  "msub %[w_asm1], %[p_asm1] \n\t"
326  "msub %[w_asm2], %[p_asm2] \n\t"
327  "lw %[w_asm], 416*4(%[w]) \n\t"
328  "lw %[p_asm], 384*4(%[p]) \n\t"
329  "lw %[w_asm1], 480*4(%[w]) \n\t"
330  "lw %[p_asm1], 448*4(%[p]) \n\t"
331  "msub %[w_asm], %[p_asm] \n\t"
332  "msub %[w_asm1], %[p_asm1] \n\t"
333  "extr.w %[sum1], $ac0, 24 \n\t"
334  "mflo %[temp2] \n\t"
335  "and %[temp1], %[temp2], 0x00ffffff \n\t"
336  "slt %[temp2], %[sum1], %[min_asm] \n\t"
337  "movn %[sum1], %[min_asm], %[temp2] \n\t"
338  "slt %[temp2], %[max_asm], %[sum1] \n\t"
339  "movn %[sum1], %[max_asm], %[temp2] \n\t"
340  "sh %[sum1], 0(%[samples]) \n\t"
341 
342  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
343  [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
344  [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2), [sum1] "+r" (sum1)
345  : [w] "r" (w), [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
346  [max_asm] "r" (max_asm)
347  : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
348  );
349 
350  *dither_state= temp1;
351 }
352 
353 static void imdct36_mips_fixed(int *out, int *buf, int *in, int *win)
354 {
355  int j;
356  int t0, t1, t2, t3, s0, s1, s2, s3;
357  int tmp[18], *tmp1, *in1;
358  /* temporary variables */
359  int temp_reg1, temp_reg2, temp_reg3, temp_reg4, temp_reg5, temp_reg6;
360  int t4, t5, t6, t8, t7;
361 
362  /* values defined in macros and tables are
363  * eliminated - they are directly loaded in appropriate variables
364  */
365  int const C_1 = 4229717092; /* cos(pi*1/18)*2 */
366  int const C_2 = 4035949074; /* cos(pi*2/18)*2 */
367  int const C_3 = 575416510; /* -cos(pi*3/18)*2 */
368  int const C_3A = 3719550786; /* cos(pi*3/18)*2 */
369  int const C_4 = 1004831466; /* -cos(pi*4/18)*2 */
370  int const C_5 = 1534215534; /* -cos(pi*5/18)*2 */
371  int const C_7 = -1468965330; /* -cos(pi*7/18)*2 */
372  int const C_8 = -745813244; /* -cos(pi*8/18)*2 */
373 
374  /*
375  * instructions of the first two loops are reorganized and loops are unrolled,
376  * in order to eliminate unnecessary readings and writings in array
377  */
378 
379  __asm__ volatile (
380  "lw %[t1], 17*4(%[in]) \n\t"
381  "lw %[t2], 16*4(%[in]) \n\t"
382  "lw %[t3], 15*4(%[in]) \n\t"
383  "lw %[t4], 14*4(%[in]) \n\t"
384  "addu %[t1], %[t1], %[t2] \n\t"
385  "addu %[t2], %[t2], %[t3] \n\t"
386  "addu %[t3], %[t3], %[t4] \n\t"
387  "lw %[t5], 13*4(%[in]) \n\t"
388  "addu %[t1], %[t1], %[t3] \n\t"
389  "sw %[t2], 16*4(%[in]) \n\t"
390  "lw %[t6], 12*4(%[in]) \n\t"
391  "sw %[t1], 17*4(%[in]) \n\t"
392  "addu %[t4], %[t4], %[t5] \n\t"
393  "addu %[t5], %[t5], %[t6] \n\t"
394  "lw %[t7], 11*4(%[in]) \n\t"
395  "addu %[t3], %[t3], %[t5] \n\t"
396  "sw %[t4], 14*4(%[in]) \n\t"
397  "lw %[t8], 10*4(%[in]) \n\t"
398  "sw %[t3], 15*4(%[in]) \n\t"
399  "addu %[t6], %[t6], %[t7] \n\t"
400  "addu %[t7], %[t7], %[t8] \n\t"
401  "sw %[t6], 12*4(%[in]) \n\t"
402  "addu %[t5], %[t5], %[t7] \n\t"
403  "lw %[t1], 9*4(%[in]) \n\t"
404  "lw %[t2], 8*4(%[in]) \n\t"
405  "sw %[t5], 13*4(%[in]) \n\t"
406  "addu %[t8], %[t8], %[t1] \n\t"
407  "addu %[t1], %[t1], %[t2] \n\t"
408  "sw %[t8], 10*4(%[in]) \n\t"
409  "addu %[t7], %[t7], %[t1] \n\t"
410  "lw %[t3], 7*4(%[in]) \n\t"
411  "lw %[t4], 6*4(%[in]) \n\t"
412  "sw %[t7], 11*4(%[in]) \n\t"
413  "addu %[t2], %[t2], %[t3] \n\t"
414  "addu %[t3], %[t3], %[t4] \n\t"
415  "sw %[t2], 8*4(%[in]) \n\t"
416  "addu %[t1], %[t1], %[t3] \n\t"
417  "lw %[t5], 5*4(%[in]) \n\t"
418  "lw %[t6], 4*4(%[in]) \n\t"
419  "sw %[t1], 9*4(%[in]) \n\t"
420  "addu %[t4], %[t4], %[t5] \n\t"
421  "addu %[t5], %[t5], %[t6] \n\t"
422  "sw %[t4], 6*4(%[in]) \n\t"
423  "addu %[t3], %[t3], %[t5] \n\t"
424  "lw %[t7], 3*4(%[in]) \n\t"
425  "lw %[t8], 2*4(%[in]) \n\t"
426  "sw %[t3], 7*4(%[in]) \n\t"
427  "addu %[t6], %[t6], %[t7] \n\t"
428  "addu %[t7], %[t7], %[t8] \n\t"
429  "sw %[t6], 4*4(%[in]) \n\t"
430  "addu %[t5], %[t5], %[t7] \n\t"
431  "lw %[t1], 1*4(%[in]) \n\t"
432  "lw %[t2], 0*4(%[in]) \n\t"
433  "sw %[t5], 5*4(%[in]) \n\t"
434  "addu %[t8], %[t8], %[t1] \n\t"
435  "addu %[t1], %[t1], %[t2] \n\t"
436  "sw %[t8], 2*4(%[in]) \n\t"
437  "addu %[t7], %[t7], %[t1] \n\t"
438  "sw %[t7], 3*4(%[in]) \n\t"
439  "sw %[t1], 1*4(%[in]) \n\t"
440 
441  : [in] "+r" (in), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
442  [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r" (t6),
443  [t7] "=&r" (t7), [t8] "=&r" (t8)
444  :
445  : "memory"
446  );
447 
448  for(j = 0; j < 2; j++) {
449 
450  tmp1 = tmp + j;
451  in1 = in + j;
452 
453  /**
454  * Original constants are multiplied by two in advanced
455  * for assembly optimization (e.g. C_2 = 2 * C2).
456  * That can lead to overflow in operations where they are used.
457  *
458  * Example of the solution:
459  *
460  * in original code:
461  * t0 = ((int64_t)(in1[2*2] + in1[2*4]) * (int64_t)(2*C2))>>32
462  *
463  * in assembly:
464  * C_2 = 2 * C2;
465  * .
466  * .
467  * "lw %[t7], 4*4(%[in1]) \n\t"
468  * "lw %[t8], 8*4(%[in1]) \n\t"
469  * "addu %[temp_reg2],%[t7], %[t8] \n\t"
470  * "multu %[C_2], %[temp_reg2] \n\t"
471  * "mfhi %[temp_reg1] \n\t"
472  * "sra %[temp_reg2],%[temp_reg2],31 \n\t"
473  * "move %[t0], $0 \n\t"
474  * "movn %[t0], %[C_2], %[temp_reg2] \n\t"
475  * "sub %[t0], %[temp_reg1],%[t0] \n\t"
476  */
477 
478  __asm__ volatile (
479  "lw %[t7], 4*4(%[in1]) \n\t"
480  "lw %[t8], 8*4(%[in1]) \n\t"
481  "lw %[t6], 16*4(%[in1]) \n\t"
482  "lw %[t4], 0*4(%[in1]) \n\t"
483  "addu %[temp_reg2], %[t7], %[t8] \n\t"
484  "addu %[t2], %[t6], %[t8] \n\t"
485  "multu %[C_2], %[temp_reg2] \n\t"
486  "lw %[t5], 12*4(%[in1]) \n\t"
487  "sub %[t2], %[t2], %[t7] \n\t"
488  "sub %[t1], %[t4], %[t5] \n\t"
489  "sra %[t3], %[t5], 1 \n\t"
490  "sra %[temp_reg1], %[t2], 1 \n\t"
491  "addu %[t3], %[t3], %[t4] \n\t"
492  "sub %[temp_reg1], %[t1], %[temp_reg1] \n\t"
493  "sra %[temp_reg2], %[temp_reg2], 31 \n\t"
494  "sw %[temp_reg1], 6*4(%[tmp1]) \n\t"
495  "move %[t0], $0 \n\t"
496  "movn %[t0], %[C_2], %[temp_reg2] \n\t"
497  "mfhi %[temp_reg1] \n\t"
498  "addu %[t1], %[t1], %[t2] \n\t"
499  "sw %[t1], 16*4(%[tmp1]) \n\t"
500  "sub %[temp_reg4], %[t8], %[t6] \n\t"
501  "add %[temp_reg2], %[t7], %[t6] \n\t"
502  "mult $ac1, %[C_8], %[temp_reg4] \n\t"
503  "multu $ac2, %[C_4], %[temp_reg2] \n\t"
504  "sub %[t0], %[temp_reg1], %[t0] \n\t"
505  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
506  "move %[t2], $0 \n\t"
507  "movn %[t2], %[C_4], %[temp_reg1] \n\t"
508  "mfhi %[t1], $ac1 \n\t"
509  "mfhi %[temp_reg1], $ac2 \n\t"
510  "lw %[t6], 10*4(%[in1]) \n\t"
511  "lw %[t8], 14*4(%[in1]) \n\t"
512  "lw %[t7], 2*4(%[in1]) \n\t"
513  "lw %[t4], 6*4(%[in1]) \n\t"
514  "sub %[temp_reg3], %[t3], %[t0] \n\t"
515  "add %[temp_reg4], %[t3], %[t0] \n\t"
516  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
517  "add %[temp_reg4], %[temp_reg4], %[t1] \n\t"
518  "sub %[t2], %[temp_reg1], %[t2] \n\t"
519  "sw %[temp_reg4], 2*4(%[tmp1]) \n\t"
520  "sub %[temp_reg3], %[temp_reg3], %[t2] \n\t"
521  "add %[temp_reg1], %[t3], %[t2] \n\t"
522  "sw %[temp_reg3], 10*4(%[tmp1]) \n\t"
523  "sub %[temp_reg1], %[temp_reg1], %[t1] \n\t"
524  "addu %[temp_reg2], %[t6], %[t8] \n\t"
525  "sw %[temp_reg1], 14*4(%[tmp1]) \n\t"
526  "sub %[temp_reg2], %[temp_reg2], %[t7] \n\t"
527  "addu %[temp_reg3], %[t7], %[t6] \n\t"
528  "multu $ac3, %[C_3], %[temp_reg2] \n\t"
529  "multu %[C_1], %[temp_reg3] \n\t"
530  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
531  "move %[t1], $0 \n\t"
532  "sra %[temp_reg3], %[temp_reg3], 31 \n\t"
533  "movn %[t1], %[C_3], %[temp_reg1] \n\t"
534  "mfhi %[temp_reg1], $ac3 \n\t"
535  "mfhi %[temp_reg4] \n\t"
536  "move %[t2], $0 \n\t"
537  "movn %[t2], %[C_1], %[temp_reg3] \n\t"
538  "sub %[temp_reg3], %[t6], %[t8] \n\t"
539  "sub %[t2], %[temp_reg4], %[t2] \n\t"
540  "multu $ac1, %[C_7], %[temp_reg3] \n\t"
541  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
542  "sra %[temp_reg4], %[temp_reg3], 31 \n\t"
543  "sub %[t1], %[temp_reg1], %[t1] \n\t"
544  "move %[t3], $0 \n\t"
545  "sw %[t1], 4*4(%[tmp1]) \n\t"
546  "movn %[t3], %[C_7], %[temp_reg4] \n\t"
547  "multu $ac2, %[C_3A], %[t4] \n\t"
548  "add %[temp_reg2], %[t7], %[t8] \n\t"
549  "move %[t1], $0 \n\t"
550  "mfhi %[temp_reg4], $ac1 \n\t"
551  "multu $ac3,%[C_5], %[temp_reg2] \n\t"
552  "move %[t0], $0 \n\t"
553  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
554  "movn %[t1],%[C_5], %[temp_reg1] \n\t"
555  "sub %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
556  "mfhi %[temp_reg1], $ac3 \n\t"
557  "sra %[temp_reg3], %[t4], 31 \n\t"
558  "movn %[t0], %[C_3A], %[temp_reg3] \n\t"
559  "mfhi %[temp_reg3], $ac2 \n\t"
560  "sub %[t3], %[temp_reg4], %[t3] \n\t"
561  "add %[temp_reg4], %[t3], %[t2] \n\t"
562  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
563  "sub %[t1], %[temp_reg1], %[t1] \n\t"
564  "sub %[t0], %[temp_reg3], %[t0] \n\t"
565  "add %[temp_reg1], %[t2], %[t1] \n\t"
566  "add %[temp_reg4], %[temp_reg4], %[t0] \n\t"
567  "sub %[temp_reg2], %[t3], %[t1] \n\t"
568  "sw %[temp_reg4], 0*4(%[tmp1]) \n\t"
569  "sub %[temp_reg1], %[temp_reg1], %[t0] \n\t"
570  "sub %[temp_reg2], %[temp_reg2], %[t0] \n\t"
571  "sw %[temp_reg1], 12*4(%[tmp1]) \n\t"
572  "sw %[temp_reg2], 8*4(%[tmp1]) \n\t"
573 
574  : [t7] "=&r" (t7), [temp_reg1] "=&r" (temp_reg1),
575  [temp_reg2] "=&r" (temp_reg2), [temp_reg4] "=&r" (temp_reg4),
576  [temp_reg3] "=&r" (temp_reg3), [t8] "=&r" (t8), [t0] "=&r" (t0),
577  [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r"(t6), [t2] "=&r" (t2),
578  [t3] "=&r" (t3), [t1] "=&r" (t1)
579  : [C_2] "r" (C_2), [in1] "r" (in1), [tmp1] "r" (tmp1), [C_8] "r" (C_8),
580  [C_4] "r" (C_4), [C_3] "r" (C_3), [C_1] "r" (C_1), [C_7] "r" (C_7),
581  [C_3A] "r" (C_3A), [C_5] "r" (C_5)
582  : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
583  "$ac3hi", "$ac3lo"
584  );
585  }
586 
587  /**
588  * loop is unrolled four times
589  *
590  * values defined in tables(icos36[] and icos36h[]) are not loaded from
591  * these tables - they are directly loaded in appropriate registers
592  *
593  */
594 
595  __asm__ volatile (
596  "lw %[t2], 1*4(%[tmp]) \n\t"
597  "lw %[t3], 3*4(%[tmp]) \n\t"
598  "lw %[t0], 0*4(%[tmp]) \n\t"
599  "lw %[t1], 2*4(%[tmp]) \n\t"
600  "addu %[temp_reg1], %[t3], %[t2] \n\t"
601  "li %[temp_reg2], 0x807D2B1E \n\t"
602  "move %[s1], $0 \n\t"
603  "multu %[temp_reg2], %[temp_reg1] \n\t"
604  "sra %[temp_reg1], %[temp_reg1], 31 \n\t"
605  "movn %[s1], %[temp_reg2], %[temp_reg1] \n\t"
606  "sub %[temp_reg3], %[t3], %[t2] \n\t"
607  "li %[temp_reg4], 0x2de5151 \n\t"
608  "mfhi %[temp_reg2] \n\t"
609  "addu %[s0], %[t1], %[t0] \n\t"
610  "lw %[temp_reg5], 9*4(%[win]) \n\t"
611  "mult $ac1, %[temp_reg4], %[temp_reg3] \n\t"
612  "lw %[temp_reg6], 4*9*4(%[buf]) \n\t"
613  "sub %[s2], %[t1], %[t0] \n\t"
614  "lw %[temp_reg3], 29*4(%[win]) \n\t"
615  "subu %[s1], %[temp_reg2], %[s1] \n\t"
616  "lw %[temp_reg4], 28*4(%[win]) \n\t"
617  "add %[t0], %[s0], %[s1] \n\t"
618  "extr.w %[s3], $ac1,23 \n\t"
619  "mult $ac2, %[t0], %[temp_reg3] \n\t"
620  "sub %[t1], %[s0], %[s1] \n\t"
621  "lw %[temp_reg1], 4*8*4(%[buf]) \n\t"
622  "mult %[t1], %[temp_reg5] \n\t"
623  "lw %[temp_reg2], 8*4(%[win]) \n\t"
624  "mfhi %[temp_reg3], $ac2 \n\t"
625  "mult $ac3, %[t0], %[temp_reg4] \n\t"
626  "add %[t0], %[s2], %[s3] \n\t"
627  "mfhi %[temp_reg5] \n\t"
628  "mult $ac1, %[t1], %[temp_reg2] \n\t"
629  "sub %[t1], %[s2], %[s3] \n\t"
630  "sw %[temp_reg3], 4*9*4(%[buf]) \n\t"
631  "mfhi %[temp_reg4], $ac3 \n\t"
632  "lw %[temp_reg3], 37*4(%[win]) \n\t"
633  "mfhi %[temp_reg2], $ac1 \n\t"
634  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
635  "lw %[temp_reg6], 17*4(%[win]) \n\t"
636  "sw %[temp_reg5], 32*9*4(%[out]) \n\t"
637  "sw %[temp_reg4], 4*8*4(%[buf]) \n\t"
638  "mult %[t1], %[temp_reg6] \n\t"
639  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
640  "lw %[temp_reg2], 0*4(%[win]) \n\t"
641  "lw %[temp_reg5], 4*17*4(%[buf]) \n\t"
642  "sw %[temp_reg1], 8*32*4(%[out]) \n\t"
643  "mfhi %[temp_reg6] \n\t"
644  "mult $ac1, %[t1], %[temp_reg2] \n\t"
645  "lw %[temp_reg4], 20*4(%[win]) \n\t"
646  "lw %[temp_reg1], 0(%[buf]) \n\t"
647  "mult $ac2, %[t0], %[temp_reg3] \n\t"
648  "mult %[t0], %[temp_reg4] \n\t"
649  "mfhi %[temp_reg2], $ac1 \n\t"
650  "lw %[t0], 4*4(%[tmp]) \n\t"
651  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
652  "mfhi %[temp_reg3], $ac2 \n\t"
653  "mfhi %[temp_reg4] \n\t"
654  "sw %[temp_reg5], 17*32*4(%[out]) \n\t"
655  "lw %[t1], 6*4(%[tmp]) \n\t"
656  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
657  "lw %[t2], 5*4(%[tmp]) \n\t"
658  "sw %[temp_reg1], 0*32*4(%[out]) \n\t"
659  "addu %[s0], %[t1], %[t0] \n\t"
660  "sw %[temp_reg3], 4*17*4(%[buf]) \n\t"
661  "lw %[t3], 7*4(%[tmp]) \n\t"
662  "sub %[s2], %[t1], %[t0] \n\t"
663  "sw %[temp_reg4], 0(%[buf]) \n\t"
664  "addu %[temp_reg5], %[t3], %[t2] \n\t"
665  "li %[temp_reg6], 0x8483EE0C \n\t"
666  "move %[s1], $0 \n\t"
667  "multu %[temp_reg6], %[temp_reg5] \n\t"
668  "sub %[temp_reg1], %[t3], %[t2] \n\t"
669  "li %[temp_reg2], 0xf746ea \n\t"
670  "sra %[temp_reg5], %[temp_reg5], 31 \n\t"
671  "mult $ac1, %[temp_reg2], %[temp_reg1] \n\t"
672  "movn %[s1], %[temp_reg6], %[temp_reg5] \n\t"
673  "mfhi %[temp_reg5] \n\t"
674  "lw %[temp_reg3], 10*4(%[win]) \n\t"
675  "lw %[temp_reg4], 4*10*4(%[buf]) \n\t"
676  "extr.w %[s3], $ac1, 23 \n\t"
677  "lw %[temp_reg1], 4*7*4(%[buf]) \n\t"
678  "lw %[temp_reg2], 7*4(%[win]) \n\t"
679  "lw %[temp_reg6], 30*4(%[win]) \n\t"
680  "subu %[s1], %[temp_reg5], %[s1] \n\t"
681  "sub %[t1], %[s0], %[s1] \n\t"
682  "add %[t0], %[s0], %[s1] \n\t"
683  "mult $ac2, %[t1], %[temp_reg3] \n\t"
684  "mult $ac3, %[t1], %[temp_reg2] \n\t"
685  "mult %[t0], %[temp_reg6] \n\t"
686  "lw %[temp_reg5], 27*4(%[win]) \n\t"
687  "mult $ac1, %[t0], %[temp_reg5] \n\t"
688  "mfhi %[temp_reg3], $ac2 \n\t"
689  "mfhi %[temp_reg2], $ac3 \n\t"
690  "mfhi %[temp_reg6] \n\t"
691  "add %[t0], %[s2], %[s3] \n\t"
692  "sub %[t1], %[s2], %[s3] \n\t"
693  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
694  "lw %[temp_reg4], 16*4(%[win]) \n\t"
695  "mfhi %[temp_reg5], $ac1 \n\t"
696  "sw %[temp_reg3], 32*10*4(%[out]) \n\t"
697  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
698  "lw %[temp_reg3], 4*16*4(%[buf]) \n\t"
699  "sw %[temp_reg6], 4*10*4(%[buf]) \n\t"
700  "sw %[temp_reg1], 7*32*4(%[out]) \n\t"
701  "mult $ac2, %[t1], %[temp_reg4] \n\t"
702  "sw %[temp_reg5], 4*7*4(%[buf]) \n\t"
703  "lw %[temp_reg6], 1*4(%[win]) \n\t"
704  "lw %[temp_reg5], 4*1*4(%[buf]) \n\t"
705  "lw %[temp_reg1], 36*4(%[win]) \n\t"
706  "mult $ac3, %[t1], %[temp_reg6] \n\t"
707  "lw %[temp_reg2], 21*4(%[win]) \n\t"
708  "mfhi %[temp_reg4], $ac2 \n\t"
709  "mult %[t0], %[temp_reg1] \n\t"
710  "mult $ac1, %[t0],%[temp_reg2] \n\t"
711  "lw %[t0], 8*4(%[tmp]) \n\t"
712  "mfhi %[temp_reg6], $ac3 \n\t"
713  "lw %[t1], 10*4(%[tmp]) \n\t"
714  "lw %[t3], 11*4(%[tmp]) \n\t"
715  "mfhi %[temp_reg1] \n\t"
716  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
717  "lw %[t2], 9*4(%[tmp]) \n\t"
718  "mfhi %[temp_reg2], $ac1 \n\t"
719  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
720  "sw %[temp_reg3], 16*32*4(%[out]) \n\t"
721  "sw %[temp_reg5], 1*32*4(%[out]) \n\t"
722  "sw %[temp_reg1], 4*16*4(%[buf]) \n\t"
723  "addu %[temp_reg3], %[t3], %[t2] \n\t"
724  "li %[temp_reg4], 0x8D3B7CD6 \n\t"
725  "sw %[temp_reg2], 4*1*4(%[buf]) \n\t"
726  "multu %[temp_reg4],%[temp_reg3] \n\t"
727  "sra %[temp_reg3], %[temp_reg3], 31 \n\t"
728  "move %[s1], $0 \n\t"
729  "movn %[s1], %[temp_reg4], %[temp_reg3] \n\t"
730  "addu %[s0], %[t1], %[t0] \n\t"
731  "mfhi %[temp_reg3] \n\t"
732  "sub %[s2], %[t1], %[t0] \n\t"
733  "sub %[temp_reg5], %[t3], %[t2] \n\t"
734  "li %[temp_reg6], 0x976fd9 \n\t"
735  "lw %[temp_reg2], 11*4(%[win]) \n\t"
736  "lw %[temp_reg1], 4*11*4(%[buf]) \n\t"
737  "mult $ac1, %[temp_reg6], %[temp_reg5] \n\t"
738  "subu %[s1], %[temp_reg3], %[s1] \n\t"
739  "lw %[temp_reg5], 31*4(%[win]) \n\t"
740  "sub %[t1], %[s0], %[s1] \n\t"
741  "add %[t0], %[s0], %[s1] \n\t"
742  "mult $ac2, %[t1], %[temp_reg2] \n\t"
743  "mult %[t0], %[temp_reg5] \n\t"
744  "lw %[temp_reg4], 6*4(%[win]) \n\t"
745  "extr.w %[s3], $ac1, 23 \n\t"
746  "lw %[temp_reg3], 4*6*4(%[buf]) \n\t"
747  "mfhi %[temp_reg2], $ac2 \n\t"
748  "lw %[temp_reg6], 26*4(%[win]) \n\t"
749  "mfhi %[temp_reg5] \n\t"
750  "mult $ac3, %[t1], %[temp_reg4] \n\t"
751  "mult $ac1, %[t0], %[temp_reg6] \n\t"
752  "add %[t0], %[s2], %[s3] \n\t"
753  "sub %[t1], %[s2], %[s3] \n\t"
754  "add %[temp_reg2], %[temp_reg2], %[temp_reg1] \n\t"
755  "mfhi %[temp_reg4], $ac3 \n\t"
756  "mfhi %[temp_reg6], $ac1 \n\t"
757  "sw %[temp_reg5], 4*11*4(%[buf]) \n\t"
758  "sw %[temp_reg2], 32*11*4(%[out]) \n\t"
759  "lw %[temp_reg1], 4*15*4(%[buf]) \n\t"
760  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
761  "lw %[temp_reg2], 15*4(%[win]) \n\t"
762  "sw %[temp_reg3], 6*32*4(%[out]) \n\t"
763  "sw %[temp_reg6], 4*6*4(%[buf]) \n\t"
764  "mult %[t1], %[temp_reg2] \n\t"
765  "lw %[temp_reg3], 2*4(%[win]) \n\t"
766  "lw %[temp_reg4], 4*2*4(%[buf]) \n\t"
767  "lw %[temp_reg5], 35*4(%[win]) \n\t"
768  "mult $ac1, %[t1], %[temp_reg3] \n\t"
769  "mfhi %[temp_reg2] \n\t"
770  "lw %[temp_reg6], 22*4(%[win]) \n\t"
771  "mult $ac2, %[t0], %[temp_reg5] \n\t"
772  "lw %[t1], 14*4(%[tmp]) \n\t"
773  "mult $ac3, %[t0], %[temp_reg6] \n\t"
774  "lw %[t0], 12*4(%[tmp]) \n\t"
775  "mfhi %[temp_reg3], $ac1 \n\t"
776  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
777  "mfhi %[temp_reg5], $ac2 \n\t"
778  "sw %[temp_reg1], 15*32*4(%[out]) \n\t"
779  "mfhi %[temp_reg6], $ac3 \n\t"
780  "lw %[t2], 13*4(%[tmp]) \n\t"
781  "lw %[t3], 15*4(%[tmp]) \n\t"
782  "add %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
783  "sw %[temp_reg5], 4*15*4(%[buf]) \n\t"
784  "addu %[temp_reg1], %[t3], %[t2] \n\t"
785  "li %[temp_reg2], 0x9C42577C \n\t"
786  "move %[s1], $0 \n\t"
787  "multu %[temp_reg2], %[temp_reg1] \n\t"
788  "sw %[temp_reg4], 2*32*4(%[out]) \n\t"
789  "sra %[temp_reg1], %[temp_reg1], 31 \n\t"
790  "movn %[s1], %[temp_reg2], %[temp_reg1] \n\t"
791  "sub %[temp_reg3], %[t3], %[t2] \n\t"
792  "li %[temp_reg4], 0x6f94a2 \n\t"
793  "mfhi %[temp_reg1] \n\t"
794  "addu %[s0], %[t1], %[t0] \n\t"
795  "sw %[temp_reg6], 4*2*4(%[buf]) \n\t"
796  "mult $ac1, %[temp_reg4], %[temp_reg3] \n\t"
797  "sub %[s2], %[t1], %[t0] \n\t"
798  "lw %[temp_reg5], 12*4(%[win]) \n\t"
799  "lw %[temp_reg6], 4*12*4(%[buf]) \n\t"
800  "subu %[s1], %[temp_reg1], %[s1] \n\t"
801  "sub %[t1], %[s0], %[s1] \n\t"
802  "lw %[temp_reg3], 32*4(%[win]) \n\t"
803  "mult $ac2, %[t1], %[temp_reg5] \n\t"
804  "add %[t0], %[s0], %[s1] \n\t"
805  "extr.w %[s3], $ac1, 23 \n\t"
806  "lw %[temp_reg2], 5*4(%[win]) \n\t"
807  "mult %[t0], %[temp_reg3] \n\t"
808  "mfhi %[temp_reg5], $ac2 \n\t"
809  "lw %[temp_reg4], 25*4(%[win]) \n\t"
810  "lw %[temp_reg1], 4*5*4(%[buf]) \n\t"
811  "mult $ac3, %[t1], %[temp_reg2] \n\t"
812  "mult $ac1, %[t0], %[temp_reg4] \n\t"
813  "mfhi %[temp_reg3] \n\t"
814  "add %[t0], %[s2], %[s3] \n\t"
815  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
816  "mfhi %[temp_reg2], $ac3 \n\t"
817  "mfhi %[temp_reg4], $ac1 \n\t"
818  "sub %[t1], %[s2], %[s3] \n\t"
819  "sw %[temp_reg5], 32*12*4(%[out]) \n\t"
820  "sw %[temp_reg3], 4*12*4(%[buf]) \n\t"
821  "lw %[temp_reg6], 14*4(%[win]) \n\t"
822  "lw %[temp_reg5], 4*14*4(%[buf]) \n\t"
823  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
824  "sw %[temp_reg4], 4*5*4(%[buf]) \n\t"
825  "sw %[temp_reg1], 5*32*4(%[out]) \n\t"
826  "mult %[t1], %[temp_reg6] \n\t"
827  "lw %[temp_reg4], 34*4(%[win]) \n\t"
828  "lw %[temp_reg2], 3*4(%[win]) \n\t"
829  "lw %[temp_reg1], 4*3*4(%[buf]) \n\t"
830  "mult $ac2, %[t0], %[temp_reg4] \n\t"
831  "mfhi %[temp_reg6] \n\t"
832  "mult $ac1, %[t1], %[temp_reg2] \n\t"
833  "lw %[temp_reg3], 23*4(%[win]) \n\t"
834  "lw %[s0], 16*4(%[tmp]) \n\t"
835  "mfhi %[temp_reg4], $ac2 \n\t"
836  "lw %[t1], 17*4(%[tmp]) \n\t"
837  "mult $ac3, %[t0], %[temp_reg3] \n\t"
838  "move %[s1], $0 \n\t"
839  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
840  "mfhi %[temp_reg2], $ac1 \n\t"
841  "sw %[temp_reg5], 14*32*4(%[out]) \n\t"
842  "sw %[temp_reg4], 4*14*4(%[buf]) \n\t"
843  "mfhi %[temp_reg3], $ac3 \n\t"
844  "li %[temp_reg5], 0xB504F334 \n\t"
845  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
846  "multu %[temp_reg5], %[t1] \n\t"
847  "lw %[temp_reg2], 4*13*4(%[buf]) \n\t"
848  "sw %[temp_reg1], 3*32*4(%[out]) \n\t"
849  "sra %[t1], %[t1], 31 \n\t"
850  "mfhi %[temp_reg6] \n\t"
851  "movn %[s1], %[temp_reg5], %[t1] \n\t"
852  "sw %[temp_reg3], 4*3*4(%[buf]) \n\t"
853  "lw %[temp_reg1], 13*4(%[win]) \n\t"
854  "lw %[temp_reg4], 4*4*4(%[buf]) \n\t"
855  "lw %[temp_reg3], 4*4(%[win]) \n\t"
856  "lw %[temp_reg5], 33*4(%[win]) \n\t"
857  "subu %[s1], %[temp_reg6], %[s1] \n\t"
858  "lw %[temp_reg6], 24*4(%[win]) \n\t"
859  "sub %[t1], %[s0], %[s1] \n\t"
860  "add %[t0], %[s0], %[s1] \n\t"
861  "mult $ac1, %[t1], %[temp_reg1] \n\t"
862  "mult $ac2, %[t1], %[temp_reg3] \n\t"
863  "mult $ac3, %[t0], %[temp_reg5] \n\t"
864  "mult %[t0], %[temp_reg6] \n\t"
865  "mfhi %[temp_reg1], $ac1 \n\t"
866  "mfhi %[temp_reg3], $ac2 \n\t"
867  "mfhi %[temp_reg5], $ac3 \n\t"
868  "mfhi %[temp_reg6] \n\t"
869  "add %[temp_reg2], %[temp_reg2], %[temp_reg1] \n\t"
870  "add %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
871  "sw %[temp_reg2], 13*32*4(%[out]) \n\t"
872  "sw %[temp_reg4], 4*32*4(%[out]) \n\t"
873  "sw %[temp_reg5], 4*13*4(%[buf]) \n\t"
874  "sw %[temp_reg6], 4*4*4(%[buf]) \n\t"
875 
876  : [t0] "=&r" (t0), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
877  [s0] "=&r" (s0), [s2] "=&r" (s2), [temp_reg1] "=&r" (temp_reg1),
878  [temp_reg2] "=&r" (temp_reg2), [s1] "=&r" (s1), [s3] "=&r" (s3),
879  [temp_reg3] "=&r" (temp_reg3), [temp_reg4] "=&r" (temp_reg4),
880  [temp_reg5] "=&r" (temp_reg5), [temp_reg6] "=&r" (temp_reg6),
881  [out] "+r" (out)
882  : [tmp] "r" (tmp), [win] "r" (win), [buf] "r" (buf)
883  : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
884  "$ac3hi", "$ac3lo"
885  );
886 }
887 
888 static void ff_imdct36_blocks_mips_fixed(int *out, int *buf, int *in,
889  int count, int switch_point, int block_type)
890 {
891  int j;
892  for (j=0 ; j < count; j++) {
893  /* apply window & overlap with previous buffer */
894 
895  /* select window */
896  int win_idx = (switch_point && j < 2) ? 0 : block_type;
897  int *win = ff_mdct_win_fixed[win_idx + (4 & -(j & 1))];
898 
899  imdct36_mips_fixed(out, buf, in, win);
900 
901  in += 18;
902  buf += ((j&3) != 3 ? 1 : (72-3));
903  out++;
904  }
905 }
906 
907 #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
908 #endif /* HAVE_INLINE_ASM */
909 
911 {
912 #if HAVE_INLINE_ASM
913 #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
914  s->apply_window_fixed = ff_mpadsp_apply_window_mips_fixed;
915  s->imdct36_blocks_fixed = ff_imdct36_blocks_mips_fixed;
916 #endif
917 #endif
918 }
out
FILE * out
Definition: movenc.c:54
ff_mdct_win_fixed
int ff_mdct_win_fixed[8][MDCT_BUF_SIZE]
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
w
uint8_t w
Definition: llviddspenc.c:38
ff_mpadsp_init_mipsdsp
void ff_mpadsp_init_mipsdsp(MPADSPContext *s)
Definition: mpegaudiodsp_mips_fixed.c:910
MPADSPContext
Definition: mpegaudiodsp.h:27
t0
#define t0
Definition: regdef.h:28
t1
#define t1
Definition: regdef.h:29
asmdefs.h
win
static float win(SuperEqualizerContext *s, float n, int N)
Definition: af_superequalizer.c:119
window
static SDL_Window * window
Definition: ffplay.c:368
s3
#define s3
Definition: regdef.h:40
s
#define s(width, name)
Definition: cbs_vp9.c:257
s1
#define s1
Definition: regdef.h:38
t7
#define t7
Definition: regdef.h:35
int32_t
int32_t
Definition: audio_convert.c:194
t5
#define t5
Definition: regdef.h:33
t6
#define t6
Definition: regdef.h:34
s2
#define s2
Definition: regdef.h:39
t8
#define t8
Definition: regdef.h:53
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
t4
#define t4
Definition: regdef.h:32
t3
#define t3
Definition: regdef.h:31
t2
#define t2
Definition: regdef.h:30
PTR_ADDIU
#define PTR_ADDIU
Definition: asmdefs.h:48
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
mpegaudiodsp.h
s0
#define s0
Definition: regdef.h:37