FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 static void ff_mpadsp_apply_window_mips_fixed(int32_t *synth_buf, int32_t *window,
61  int *dither_state, int16_t *samples, int incr)
62 {
63  register const int32_t *w, *w2, *p;
64  int j;
65  int16_t *samples2;
66  int w_asm, p_asm, w_asm1, p_asm1, w_asm2, p_asm2;
67  int w2_asm, w2_asm1, *p_temp1, *p_temp2;
68  int sum1 = 0;
69  int const min_asm = -32768, max_asm = 32767;
70  int temp1, temp2 = 0, temp3 = 0;
71  int64_t sum;
72 
73  /* copy to avoid wrap */
74  memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
75  samples2 = samples + 31 * incr;
76  w = window;
77  w2 = window + 31;
78  sum = *dither_state;
79  p = synth_buf + 16;
80  p_temp1 = synth_buf + 16;
81  p_temp2 = synth_buf + 48;
82  temp1 = sum;
83 
84  /**
85  * use of round_sample function from the original code is eliminated,
86  * changed with appropriate assembly instructions.
87  */
88  __asm__ volatile (
89  "mthi $zero \n\t"
90  "mtlo %[temp1] \n\t"
91  "lw %[w_asm], 0(%[w]) \n\t"
92  "lw %[p_asm], 0(%[p]) \n\t"
93  "lw %[w_asm1], 64*4(%[w]) \n\t"
94  "lw %[p_asm1], 64*4(%[p]) \n\t"
95  "lw %[w_asm2], 128*4(%[w]) \n\t"
96  "lw %[p_asm2], 128*4(%[p]) \n\t"
97  "madd %[w_asm], %[p_asm] \n\t"
98  "madd %[w_asm1], %[p_asm1] \n\t"
99  "madd %[w_asm2], %[p_asm2] \n\t"
100  "lw %[w_asm], 192*4(%[w]) \n\t"
101  "lw %[p_asm], 192*4(%[p]) \n\t"
102  "lw %[w_asm1], 256*4(%[w]) \n\t"
103  "lw %[p_asm1], 256*4(%[p]) \n\t"
104  "lw %[w_asm2], 320*4(%[w]) \n\t"
105  "lw %[p_asm2], 320*4(%[p]) \n\t"
106  "madd %[w_asm], %[p_asm] \n\t"
107  "madd %[w_asm1], %[p_asm1] \n\t"
108  "madd %[w_asm2], %[p_asm2] \n\t"
109  "lw %[w_asm], 384*4(%[w]) \n\t"
110  "lw %[p_asm], 384*4(%[p]) \n\t"
111  "lw %[w_asm1], 448*4(%[w]) \n\t"
112  "lw %[p_asm1], 448*4(%[p]) \n\t"
113  "lw %[w_asm2], 32*4(%[w]) \n\t"
114  "lw %[p_asm2], 32*4(%[p]) \n\t"
115  "madd %[w_asm], %[p_asm] \n\t"
116  "madd %[w_asm1], %[p_asm1] \n\t"
117  "msub %[w_asm2], %[p_asm2] \n\t"
118  "lw %[w_asm], 96*4(%[w]) \n\t"
119  "lw %[p_asm], 96*4(%[p]) \n\t"
120  "lw %[w_asm1], 160*4(%[w]) \n\t"
121  "lw %[p_asm1], 160*4(%[p]) \n\t"
122  "lw %[w_asm2], 224*4(%[w]) \n\t"
123  "lw %[p_asm2], 224*4(%[p]) \n\t"
124  "msub %[w_asm], %[p_asm] \n\t"
125  "msub %[w_asm1], %[p_asm1] \n\t"
126  "msub %[w_asm2], %[p_asm2] \n\t"
127  "lw %[w_asm], 288*4(%[w]) \n\t"
128  "lw %[p_asm], 288*4(%[p]) \n\t"
129  "lw %[w_asm1], 352*4(%[w]) \n\t"
130  "lw %[p_asm1], 352*4(%[p]) \n\t"
131  "msub %[w_asm], %[p_asm] \n\t"
132  "lw %[w_asm], 480*4(%[w]) \n\t"
133  "lw %[p_asm], 480*4(%[p]) \n\t"
134  "lw %[w_asm2], 416*4(%[w]) \n\t"
135  "lw %[p_asm2], 416*4(%[p]) \n\t"
136  "msub %[w_asm], %[p_asm] \n\t"
137  "msub %[w_asm1], %[p_asm1] \n\t"
138  "msub %[w_asm2], %[p_asm2] \n\t"
139 
140  /*round_sample function from the original code is eliminated,
141  * changed with appropriate assembly instructions
142  * code example:
143 
144  "extr.w %[sum1],$ac0,24 \n\t"
145  "mflo %[temp3], $ac0 \n\t"
146  "and %[temp1], %[temp3], 0x00ffffff \n\t"
147  "slt %[temp2], %[sum1], %[min_asm] \n\t"
148  "movn %[sum1], %[min_asm],%[temp2] \n\t"
149  "slt %[temp2], %[max_asm],%[sum1] \n\t"
150  "movn %[sum1], %[max_asm],%[temp2] \n\t"
151  "sh %[sum1], 0(%[samples]) \n\t"
152  */
153 
154  "extr.w %[sum1], $ac0, 24 \n\t"
155  "mflo %[temp3] \n\t"
156  PTR_ADDIU "%[w], %[w], 4 \n\t"
157  "and %[temp1], %[temp3], 0x00ffffff \n\t"
158  "slt %[temp2], %[sum1], %[min_asm] \n\t"
159  "movn %[sum1], %[min_asm], %[temp2] \n\t"
160  "slt %[temp2], %[max_asm], %[sum1] \n\t"
161  "movn %[sum1], %[max_asm], %[temp2] \n\t"
162  "sh %[sum1], 0(%[samples]) \n\t"
163 
164  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
165  [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
166  [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2),
167  [sum1] "+r" (sum1), [w] "+r" (w), [temp3] "+r" (temp3)
168  : [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
169  [max_asm] "r" (max_asm)
170  : "memory", "hi","lo"
171  );
172 
173  samples += incr;
174 
175  /* we calculate two samples at the same time to avoid one memory
176  access per two sample */
177 
178  for(j = 1; j < 16; j++) {
179  __asm__ volatile (
180  "mthi $0, $ac1 \n\t"
181  "mtlo $0, $ac1 \n\t"
182  "mthi $0 \n\t"
183  "mtlo %[temp1] \n\t"
184  PTR_ADDIU "%[p_temp1], %[p_temp1], 4 \n\t"
185  "lw %[w_asm], 0(%[w]) \n\t"
186  "lw %[p_asm], 0(%[p_temp1]) \n\t"
187  "lw %[w2_asm], 0(%[w2]) \n\t"
188  "lw %[w_asm1], 64*4(%[w]) \n\t"
189  "lw %[p_asm1], 64*4(%[p_temp1]) \n\t"
190  "lw %[w2_asm1], 64*4(%[w2]) \n\t"
191  "madd %[w_asm], %[p_asm] \n\t"
192  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
193  "madd %[w_asm1], %[p_asm1] \n\t"
194  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
195  "lw %[w_asm], 128*4(%[w]) \n\t"
196  "lw %[p_asm], 128*4(%[p_temp1]) \n\t"
197  "lw %[w2_asm], 128*4(%[w2]) \n\t"
198  "lw %[w_asm1], 192*4(%[w]) \n\t"
199  "lw %[p_asm1], 192*4(%[p_temp1]) \n\t"
200  "lw %[w2_asm1], 192*4(%[w2]) \n\t"
201  "madd %[w_asm], %[p_asm] \n\t"
202  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
203  "madd %[w_asm1], %[p_asm1] \n\t"
204  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
205  "lw %[w_asm], 256*4(%[w]) \n\t"
206  "lw %[p_asm], 256*4(%[p_temp1]) \n\t"
207  "lw %[w2_asm], 256*4(%[w2]) \n\t"
208  "lw %[w_asm1], 320*4(%[w]) \n\t"
209  "lw %[p_asm1], 320*4(%[p_temp1]) \n\t"
210  "lw %[w2_asm1], 320*4(%[w2]) \n\t"
211  "madd %[w_asm], %[p_asm] \n\t"
212  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
213  "madd %[w_asm1], %[p_asm1] \n\t"
214  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
215  "lw %[w_asm], 384*4(%[w]) \n\t"
216  "lw %[p_asm], 384*4(%[p_temp1]) \n\t"
217  "lw %[w2_asm], 384*4(%[w2]) \n\t"
218  "lw %[w_asm1], 448*4(%[w]) \n\t"
219  "lw %[p_asm1], 448*4(%[p_temp1]) \n\t"
220  "lw %[w2_asm1], 448*4(%[w2]) \n\t"
221  "madd %[w_asm], %[p_asm] \n\t"
222  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
223  "madd %[w_asm1], %[p_asm1] \n\t"
224  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
225  PTR_ADDIU "%[p_temp2], %[p_temp2], -4 \n\t"
226  "lw %[w_asm], 32*4(%[w]) \n\t"
227  "lw %[p_asm], 0(%[p_temp2]) \n\t"
228  "lw %[w2_asm], 32*4(%[w2]) \n\t"
229  "lw %[w_asm1], 96*4(%[w]) \n\t"
230  "lw %[p_asm1], 64*4(%[p_temp2]) \n\t"
231  "lw %[w2_asm1], 96*4(%[w2]) \n\t"
232  "msub %[w_asm], %[p_asm] \n\t"
233  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
234  "msub %[w_asm1], %[p_asm1] \n\t"
235  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
236  "lw %[w_asm], 160*4(%[w]) \n\t"
237  "lw %[p_asm], 128*4(%[p_temp2]) \n\t"
238  "lw %[w2_asm], 160*4(%[w2]) \n\t"
239  "lw %[w_asm1], 224*4(%[w]) \n\t"
240  "lw %[p_asm1], 192*4(%[p_temp2]) \n\t"
241  "lw %[w2_asm1], 224*4(%[w2]) \n\t"
242  "msub %[w_asm], %[p_asm] \n\t"
243  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
244  "msub %[w_asm1], %[p_asm1] \n\t"
245  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
246  "lw %[w_asm], 288*4(%[w]) \n\t"
247  "lw %[p_asm], 256*4(%[p_temp2]) \n\t"
248  "lw %[w2_asm], 288*4(%[w2]) \n\t"
249  "lw %[w_asm1], 352*4(%[w]) \n\t"
250  "lw %[p_asm1], 320*4(%[p_temp2]) \n\t"
251  "lw %[w2_asm1], 352*4(%[w2]) \n\t"
252  "msub %[w_asm], %[p_asm] \n\t"
253  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
254  "msub %[w_asm1], %[p_asm1] \n\t"
255  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
256  "lw %[w_asm], 416*4(%[w]) \n\t"
257  "lw %[p_asm], 384*4(%[p_temp2]) \n\t"
258  "lw %[w2_asm], 416*4(%[w2]) \n\t"
259  "lw %[w_asm1], 480*4(%[w]) \n\t"
260  "lw %[p_asm1], 448*4(%[p_temp2]) \n\t"
261  "lw %[w2_asm1], 480*4(%[w2]) \n\t"
262  "msub %[w_asm], %[p_asm] \n\t"
263  "msub %[w_asm1], %[p_asm1] \n\t"
264  "msub $ac1, %[w2_asm], %[p_asm] \n\t"
265  "msub $ac1, %[w2_asm1], %[p_asm1] \n\t"
266  PTR_ADDIU "%[w], %[w], 4 \n\t"
267  PTR_ADDIU "%[w2], %[w2], -4 \n\t"
268  "mflo %[temp2] \n\t"
269  "extr.w %[sum1], $ac0, 24 \n\t"
270  "li %[temp3], 1 \n\t"
271  "and %[temp1], %[temp2], 0x00ffffff \n\t"
272  "madd $ac1, %[temp1], %[temp3] \n\t"
273  "slt %[temp2], %[sum1], %[min_asm] \n\t"
274  "movn %[sum1], %[min_asm], %[temp2] \n\t"
275  "slt %[temp2], %[max_asm], %[sum1] \n\t"
276  "movn %[sum1], %[max_asm], %[temp2] \n\t"
277  "sh %[sum1], 0(%[samples]) \n\t"
278  "mflo %[temp3], $ac1 \n\t"
279  "extr.w %[sum1], $ac1, 24 \n\t"
280  "and %[temp1], %[temp3], 0x00ffffff \n\t"
281  "slt %[temp2], %[sum1], %[min_asm] \n\t"
282  "movn %[sum1], %[min_asm], %[temp2] \n\t"
283  "slt %[temp2], %[max_asm], %[sum1] \n\t"
284  "movn %[sum1], %[max_asm], %[temp2] \n\t"
285  "sh %[sum1], 0(%[samples2]) \n\t"
286 
287  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
288  [p_asm1] "=&r" (p_asm1), [w2_asm1] "=&r" (w2_asm1),
289  [w2_asm] "=&r" (w2_asm), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
290  [p_temp1] "+r" (p_temp1), [p_temp2] "+r" (p_temp2), [sum1] "+r" (sum1),
291  [w] "+r" (w), [w2] "+r" (w2), [samples] "+r" (samples),
292  [samples2] "+r" (samples2), [temp3] "+r" (temp3)
293  : [min_asm] "r" (min_asm), [max_asm] "r" (max_asm)
294  : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
295  );
296 
297  samples += incr;
298  samples2 -= incr;
299  }
300 
301  p = synth_buf + 32;
302 
303  __asm__ volatile (
304  "mthi $0 \n\t"
305  "mtlo %[temp1] \n\t"
306  "lw %[w_asm], 32*4(%[w]) \n\t"
307  "lw %[p_asm], 0(%[p]) \n\t"
308  "lw %[w_asm1], 96*4(%[w]) \n\t"
309  "lw %[p_asm1], 64*4(%[p]) \n\t"
310  "lw %[w_asm2], 160*4(%[w]) \n\t"
311  "lw %[p_asm2], 128*4(%[p]) \n\t"
312  "msub %[w_asm], %[p_asm] \n\t"
313  "msub %[w_asm1], %[p_asm1] \n\t"
314  "msub %[w_asm2], %[p_asm2] \n\t"
315  "lw %[w_asm], 224*4(%[w]) \n\t"
316  "lw %[p_asm], 192*4(%[p]) \n\t"
317  "lw %[w_asm1], 288*4(%[w]) \n\t"
318  "lw %[p_asm1], 256*4(%[p]) \n\t"
319  "lw %[w_asm2], 352*4(%[w]) \n\t"
320  "lw %[p_asm2], 320*4(%[p]) \n\t"
321  "msub %[w_asm], %[p_asm] \n\t"
322  "msub %[w_asm1], %[p_asm1] \n\t"
323  "msub %[w_asm2], %[p_asm2] \n\t"
324  "lw %[w_asm], 416*4(%[w]) \n\t"
325  "lw %[p_asm], 384*4(%[p]) \n\t"
326  "lw %[w_asm1], 480*4(%[w]) \n\t"
327  "lw %[p_asm1], 448*4(%[p]) \n\t"
328  "msub %[w_asm], %[p_asm] \n\t"
329  "msub %[w_asm1], %[p_asm1] \n\t"
330  "extr.w %[sum1], $ac0, 24 \n\t"
331  "mflo %[temp2] \n\t"
332  "and %[temp1], %[temp2], 0x00ffffff \n\t"
333  "slt %[temp2], %[sum1], %[min_asm] \n\t"
334  "movn %[sum1], %[min_asm], %[temp2] \n\t"
335  "slt %[temp2], %[max_asm], %[sum1] \n\t"
336  "movn %[sum1], %[max_asm], %[temp2] \n\t"
337  "sh %[sum1], 0(%[samples]) \n\t"
338 
339  : [w_asm] "=&r" (w_asm), [p_asm] "=&r" (p_asm), [w_asm1] "=&r" (w_asm1),
340  [p_asm1] "=&r" (p_asm1), [temp1] "+r" (temp1), [temp2] "+r" (temp2),
341  [w_asm2] "=&r" (w_asm2), [p_asm2] "=&r" (p_asm2), [sum1] "+r" (sum1)
342  : [w] "r" (w), [p] "r" (p), [samples] "r" (samples), [min_asm] "r" (min_asm),
343  [max_asm] "r" (max_asm)
344  : "memory", "hi", "lo", "$ac1hi", "$ac1lo"
345  );
346 
347  *dither_state= temp1;
348 }
349 
350 static void imdct36_mips_fixed(int *out, int *buf, int *in, int *win)
351 {
352  int j;
353  int t0, t1, t2, t3, s0, s1, s2, s3;
354  int tmp[18], *tmp1, *in1;
355  /* temporary variables */
356  int temp_reg1, temp_reg2, temp_reg3, temp_reg4, temp_reg5, temp_reg6;
357  int t4, t5, t6, t8, t7;
358 
359  /* values defined in macros and tables are
360  * eliminated - they are directly loaded in appropriate variables
361  */
362  int const C_1 = 4229717092; /* cos(pi*1/18)*2 */
363  int const C_2 = 4035949074; /* cos(pi*2/18)*2 */
364  int const C_3 = 575416510; /* -cos(pi*3/18)*2 */
365  int const C_3A = 3719550786; /* cos(pi*3/18)*2 */
366  int const C_4 = 1004831466; /* -cos(pi*4/18)*2 */
367  int const C_5 = 1534215534; /* -cos(pi*5/18)*2 */
368  int const C_7 = -1468965330; /* -cos(pi*7/18)*2 */
369  int const C_8 = -745813244; /* -cos(pi*8/18)*2 */
370 
371  /*
372  * instructions of the first two loops are reorganized and loops are unrolled,
373  * in order to eliminate unnecessary readings and writings in array
374  */
375 
376  __asm__ volatile (
377  "lw %[t1], 17*4(%[in]) \n\t"
378  "lw %[t2], 16*4(%[in]) \n\t"
379  "lw %[t3], 15*4(%[in]) \n\t"
380  "lw %[t4], 14*4(%[in]) \n\t"
381  "addu %[t1], %[t1], %[t2] \n\t"
382  "addu %[t2], %[t2], %[t3] \n\t"
383  "addu %[t3], %[t3], %[t4] \n\t"
384  "lw %[t5], 13*4(%[in]) \n\t"
385  "addu %[t1], %[t1], %[t3] \n\t"
386  "sw %[t2], 16*4(%[in]) \n\t"
387  "lw %[t6], 12*4(%[in]) \n\t"
388  "sw %[t1], 17*4(%[in]) \n\t"
389  "addu %[t4], %[t4], %[t5] \n\t"
390  "addu %[t5], %[t5], %[t6] \n\t"
391  "lw %[t7], 11*4(%[in]) \n\t"
392  "addu %[t3], %[t3], %[t5] \n\t"
393  "sw %[t4], 14*4(%[in]) \n\t"
394  "lw %[t8], 10*4(%[in]) \n\t"
395  "sw %[t3], 15*4(%[in]) \n\t"
396  "addu %[t6], %[t6], %[t7] \n\t"
397  "addu %[t7], %[t7], %[t8] \n\t"
398  "sw %[t6], 12*4(%[in]) \n\t"
399  "addu %[t5], %[t5], %[t7] \n\t"
400  "lw %[t1], 9*4(%[in]) \n\t"
401  "lw %[t2], 8*4(%[in]) \n\t"
402  "sw %[t5], 13*4(%[in]) \n\t"
403  "addu %[t8], %[t8], %[t1] \n\t"
404  "addu %[t1], %[t1], %[t2] \n\t"
405  "sw %[t8], 10*4(%[in]) \n\t"
406  "addu %[t7], %[t7], %[t1] \n\t"
407  "lw %[t3], 7*4(%[in]) \n\t"
408  "lw %[t4], 6*4(%[in]) \n\t"
409  "sw %[t7], 11*4(%[in]) \n\t"
410  "addu %[t2], %[t2], %[t3] \n\t"
411  "addu %[t3], %[t3], %[t4] \n\t"
412  "sw %[t2], 8*4(%[in]) \n\t"
413  "addu %[t1], %[t1], %[t3] \n\t"
414  "lw %[t5], 5*4(%[in]) \n\t"
415  "lw %[t6], 4*4(%[in]) \n\t"
416  "sw %[t1], 9*4(%[in]) \n\t"
417  "addu %[t4], %[t4], %[t5] \n\t"
418  "addu %[t5], %[t5], %[t6] \n\t"
419  "sw %[t4], 6*4(%[in]) \n\t"
420  "addu %[t3], %[t3], %[t5] \n\t"
421  "lw %[t7], 3*4(%[in]) \n\t"
422  "lw %[t8], 2*4(%[in]) \n\t"
423  "sw %[t3], 7*4(%[in]) \n\t"
424  "addu %[t6], %[t6], %[t7] \n\t"
425  "addu %[t7], %[t7], %[t8] \n\t"
426  "sw %[t6], 4*4(%[in]) \n\t"
427  "addu %[t5], %[t5], %[t7] \n\t"
428  "lw %[t1], 1*4(%[in]) \n\t"
429  "lw %[t2], 0*4(%[in]) \n\t"
430  "sw %[t5], 5*4(%[in]) \n\t"
431  "addu %[t8], %[t8], %[t1] \n\t"
432  "addu %[t1], %[t1], %[t2] \n\t"
433  "sw %[t8], 2*4(%[in]) \n\t"
434  "addu %[t7], %[t7], %[t1] \n\t"
435  "sw %[t7], 3*4(%[in]) \n\t"
436  "sw %[t1], 1*4(%[in]) \n\t"
437 
438  : [in] "+r" (in), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
439  [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r" (t6),
440  [t7] "=&r" (t7), [t8] "=&r" (t8)
441  :
442  : "memory"
443  );
444 
445  for(j = 0; j < 2; j++) {
446 
447  tmp1 = tmp + j;
448  in1 = in + j;
449 
450  /**
451  * Original constants are multiplied by two in advanced
452  * for assembly optimization (e.g. C_2 = 2 * C2).
453  * That can lead to overflow in operations where they are used.
454  *
455  * Example of the solution:
456  *
457  * in original code:
458  * t0 = ((int64_t)(in1[2*2] + in1[2*4]) * (int64_t)(2*C2))>>32
459  *
460  * in assembly:
461  * C_2 = 2 * C2;
462  * .
463  * .
464  * "lw %[t7], 4*4(%[in1]) \n\t"
465  * "lw %[t8], 8*4(%[in1]) \n\t"
466  * "addu %[temp_reg2],%[t7], %[t8] \n\t"
467  * "multu %[C_2], %[temp_reg2] \n\t"
468  * "mfhi %[temp_reg1] \n\t"
469  * "sra %[temp_reg2],%[temp_reg2],31 \n\t"
470  * "move %[t0], $0 \n\t"
471  * "movn %[t0], %[C_2], %[temp_reg2] \n\t"
472  * "sub %[t0], %[temp_reg1],%[t0] \n\t"
473  */
474 
475  __asm__ volatile (
476  "lw %[t7], 4*4(%[in1]) \n\t"
477  "lw %[t8], 8*4(%[in1]) \n\t"
478  "lw %[t6], 16*4(%[in1]) \n\t"
479  "lw %[t4], 0*4(%[in1]) \n\t"
480  "addu %[temp_reg2], %[t7], %[t8] \n\t"
481  "addu %[t2], %[t6], %[t8] \n\t"
482  "multu %[C_2], %[temp_reg2] \n\t"
483  "lw %[t5], 12*4(%[in1]) \n\t"
484  "sub %[t2], %[t2], %[t7] \n\t"
485  "sub %[t1], %[t4], %[t5] \n\t"
486  "sra %[t3], %[t5], 1 \n\t"
487  "sra %[temp_reg1], %[t2], 1 \n\t"
488  "addu %[t3], %[t3], %[t4] \n\t"
489  "sub %[temp_reg1], %[t1], %[temp_reg1] \n\t"
490  "sra %[temp_reg2], %[temp_reg2], 31 \n\t"
491  "sw %[temp_reg1], 6*4(%[tmp1]) \n\t"
492  "move %[t0], $0 \n\t"
493  "movn %[t0], %[C_2], %[temp_reg2] \n\t"
494  "mfhi %[temp_reg1] \n\t"
495  "addu %[t1], %[t1], %[t2] \n\t"
496  "sw %[t1], 16*4(%[tmp1]) \n\t"
497  "sub %[temp_reg4], %[t8], %[t6] \n\t"
498  "add %[temp_reg2], %[t7], %[t6] \n\t"
499  "mult $ac1, %[C_8], %[temp_reg4] \n\t"
500  "multu $ac2, %[C_4], %[temp_reg2] \n\t"
501  "sub %[t0], %[temp_reg1], %[t0] \n\t"
502  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
503  "move %[t2], $0 \n\t"
504  "movn %[t2], %[C_4], %[temp_reg1] \n\t"
505  "mfhi %[t1], $ac1 \n\t"
506  "mfhi %[temp_reg1], $ac2 \n\t"
507  "lw %[t6], 10*4(%[in1]) \n\t"
508  "lw %[t8], 14*4(%[in1]) \n\t"
509  "lw %[t7], 2*4(%[in1]) \n\t"
510  "lw %[t4], 6*4(%[in1]) \n\t"
511  "sub %[temp_reg3], %[t3], %[t0] \n\t"
512  "add %[temp_reg4], %[t3], %[t0] \n\t"
513  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
514  "add %[temp_reg4], %[temp_reg4], %[t1] \n\t"
515  "sub %[t2], %[temp_reg1], %[t2] \n\t"
516  "sw %[temp_reg4], 2*4(%[tmp1]) \n\t"
517  "sub %[temp_reg3], %[temp_reg3], %[t2] \n\t"
518  "add %[temp_reg1], %[t3], %[t2] \n\t"
519  "sw %[temp_reg3], 10*4(%[tmp1]) \n\t"
520  "sub %[temp_reg1], %[temp_reg1], %[t1] \n\t"
521  "addu %[temp_reg2], %[t6], %[t8] \n\t"
522  "sw %[temp_reg1], 14*4(%[tmp1]) \n\t"
523  "sub %[temp_reg2], %[temp_reg2], %[t7] \n\t"
524  "addu %[temp_reg3], %[t7], %[t6] \n\t"
525  "multu $ac3, %[C_3], %[temp_reg2] \n\t"
526  "multu %[C_1], %[temp_reg3] \n\t"
527  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
528  "move %[t1], $0 \n\t"
529  "sra %[temp_reg3], %[temp_reg3], 31 \n\t"
530  "movn %[t1], %[C_3], %[temp_reg1] \n\t"
531  "mfhi %[temp_reg1], $ac3 \n\t"
532  "mfhi %[temp_reg4] \n\t"
533  "move %[t2], $0 \n\t"
534  "movn %[t2], %[C_1], %[temp_reg3] \n\t"
535  "sub %[temp_reg3], %[t6], %[t8] \n\t"
536  "sub %[t2], %[temp_reg4], %[t2] \n\t"
537  "multu $ac1, %[C_7], %[temp_reg3] \n\t"
538  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
539  "sra %[temp_reg4], %[temp_reg3], 31 \n\t"
540  "sub %[t1], %[temp_reg1], %[t1] \n\t"
541  "move %[t3], $0 \n\t"
542  "sw %[t1], 4*4(%[tmp1]) \n\t"
543  "movn %[t3], %[C_7], %[temp_reg4] \n\t"
544  "multu $ac2, %[C_3A], %[t4] \n\t"
545  "add %[temp_reg2], %[t7], %[t8] \n\t"
546  "move %[t1], $0 \n\t"
547  "mfhi %[temp_reg4], $ac1 \n\t"
548  "multu $ac3,%[C_5], %[temp_reg2] \n\t"
549  "move %[t0], $0 \n\t"
550  "sra %[temp_reg1], %[temp_reg2], 31 \n\t"
551  "movn %[t1],%[C_5], %[temp_reg1] \n\t"
552  "sub %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
553  "mfhi %[temp_reg1], $ac3 \n\t"
554  "sra %[temp_reg3], %[t4], 31 \n\t"
555  "movn %[t0], %[C_3A], %[temp_reg3] \n\t"
556  "mfhi %[temp_reg3], $ac2 \n\t"
557  "sub %[t3], %[temp_reg4], %[t3] \n\t"
558  "add %[temp_reg4], %[t3], %[t2] \n\t"
559  "sub %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
560  "sub %[t1], %[temp_reg1], %[t1] \n\t"
561  "sub %[t0], %[temp_reg3], %[t0] \n\t"
562  "add %[temp_reg1], %[t2], %[t1] \n\t"
563  "add %[temp_reg4], %[temp_reg4], %[t0] \n\t"
564  "sub %[temp_reg2], %[t3], %[t1] \n\t"
565  "sw %[temp_reg4], 0*4(%[tmp1]) \n\t"
566  "sub %[temp_reg1], %[temp_reg1], %[t0] \n\t"
567  "sub %[temp_reg2], %[temp_reg2], %[t0] \n\t"
568  "sw %[temp_reg1], 12*4(%[tmp1]) \n\t"
569  "sw %[temp_reg2], 8*4(%[tmp1]) \n\t"
570 
571  : [t7] "=&r" (t7), [temp_reg1] "=&r" (temp_reg1),
572  [temp_reg2] "=&r" (temp_reg2), [temp_reg4] "=&r" (temp_reg4),
573  [temp_reg3] "=&r" (temp_reg3), [t8] "=&r" (t8), [t0] "=&r" (t0),
574  [t4] "=&r" (t4), [t5] "=&r" (t5), [t6] "=&r"(t6), [t2] "=&r" (t2),
575  [t3] "=&r" (t3), [t1] "=&r" (t1)
576  : [C_2] "r" (C_2), [in1] "r" (in1), [tmp1] "r" (tmp1), [C_8] "r" (C_8),
577  [C_4] "r" (C_4), [C_3] "r" (C_3), [C_1] "r" (C_1), [C_7] "r" (C_7),
578  [C_3A] "r" (C_3A), [C_5] "r" (C_5)
579  : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
580  "$ac3hi", "$ac3lo"
581  );
582  }
583 
584  /**
585  * loop is unrolled four times
586  *
587  * values defined in tables(icos36[] and icos36h[]) are not loaded from
588  * these tables - they are directly loaded in appropriate registers
589  *
590  */
591 
592  __asm__ volatile (
593  "lw %[t2], 1*4(%[tmp]) \n\t"
594  "lw %[t3], 3*4(%[tmp]) \n\t"
595  "lw %[t0], 0*4(%[tmp]) \n\t"
596  "lw %[t1], 2*4(%[tmp]) \n\t"
597  "addu %[temp_reg1], %[t3], %[t2] \n\t"
598  "li %[temp_reg2], 0x807D2B1E \n\t"
599  "move %[s1], $0 \n\t"
600  "multu %[temp_reg2], %[temp_reg1] \n\t"
601  "sra %[temp_reg1], %[temp_reg1], 31 \n\t"
602  "movn %[s1], %[temp_reg2], %[temp_reg1] \n\t"
603  "sub %[temp_reg3], %[t3], %[t2] \n\t"
604  "li %[temp_reg4], 0x2de5151 \n\t"
605  "mfhi %[temp_reg2] \n\t"
606  "addu %[s0], %[t1], %[t0] \n\t"
607  "lw %[temp_reg5], 9*4(%[win]) \n\t"
608  "mult $ac1, %[temp_reg4], %[temp_reg3] \n\t"
609  "lw %[temp_reg6], 4*9*4(%[buf]) \n\t"
610  "sub %[s2], %[t1], %[t0] \n\t"
611  "lw %[temp_reg3], 29*4(%[win]) \n\t"
612  "subu %[s1], %[temp_reg2], %[s1] \n\t"
613  "lw %[temp_reg4], 28*4(%[win]) \n\t"
614  "add %[t0], %[s0], %[s1] \n\t"
615  "extr.w %[s3], $ac1,23 \n\t"
616  "mult $ac2, %[t0], %[temp_reg3] \n\t"
617  "sub %[t1], %[s0], %[s1] \n\t"
618  "lw %[temp_reg1], 4*8*4(%[buf]) \n\t"
619  "mult %[t1], %[temp_reg5] \n\t"
620  "lw %[temp_reg2], 8*4(%[win]) \n\t"
621  "mfhi %[temp_reg3], $ac2 \n\t"
622  "mult $ac3, %[t0], %[temp_reg4] \n\t"
623  "add %[t0], %[s2], %[s3] \n\t"
624  "mfhi %[temp_reg5] \n\t"
625  "mult $ac1, %[t1], %[temp_reg2] \n\t"
626  "sub %[t1], %[s2], %[s3] \n\t"
627  "sw %[temp_reg3], 4*9*4(%[buf]) \n\t"
628  "mfhi %[temp_reg4], $ac3 \n\t"
629  "lw %[temp_reg3], 37*4(%[win]) \n\t"
630  "mfhi %[temp_reg2], $ac1 \n\t"
631  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
632  "lw %[temp_reg6], 17*4(%[win]) \n\t"
633  "sw %[temp_reg5], 32*9*4(%[out]) \n\t"
634  "sw %[temp_reg4], 4*8*4(%[buf]) \n\t"
635  "mult %[t1], %[temp_reg6] \n\t"
636  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
637  "lw %[temp_reg2], 0*4(%[win]) \n\t"
638  "lw %[temp_reg5], 4*17*4(%[buf]) \n\t"
639  "sw %[temp_reg1], 8*32*4(%[out]) \n\t"
640  "mfhi %[temp_reg6] \n\t"
641  "mult $ac1, %[t1], %[temp_reg2] \n\t"
642  "lw %[temp_reg4], 20*4(%[win]) \n\t"
643  "lw %[temp_reg1], 0(%[buf]) \n\t"
644  "mult $ac2, %[t0], %[temp_reg3] \n\t"
645  "mult %[t0], %[temp_reg4] \n\t"
646  "mfhi %[temp_reg2], $ac1 \n\t"
647  "lw %[t0], 4*4(%[tmp]) \n\t"
648  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
649  "mfhi %[temp_reg3], $ac2 \n\t"
650  "mfhi %[temp_reg4] \n\t"
651  "sw %[temp_reg5], 17*32*4(%[out]) \n\t"
652  "lw %[t1], 6*4(%[tmp]) \n\t"
653  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
654  "lw %[t2], 5*4(%[tmp]) \n\t"
655  "sw %[temp_reg1], 0*32*4(%[out]) \n\t"
656  "addu %[s0], %[t1], %[t0] \n\t"
657  "sw %[temp_reg3], 4*17*4(%[buf]) \n\t"
658  "lw %[t3], 7*4(%[tmp]) \n\t"
659  "sub %[s2], %[t1], %[t0] \n\t"
660  "sw %[temp_reg4], 0(%[buf]) \n\t"
661  "addu %[temp_reg5], %[t3], %[t2] \n\t"
662  "li %[temp_reg6], 0x8483EE0C \n\t"
663  "move %[s1], $0 \n\t"
664  "multu %[temp_reg6], %[temp_reg5] \n\t"
665  "sub %[temp_reg1], %[t3], %[t2] \n\t"
666  "li %[temp_reg2], 0xf746ea \n\t"
667  "sra %[temp_reg5], %[temp_reg5], 31 \n\t"
668  "mult $ac1, %[temp_reg2], %[temp_reg1] \n\t"
669  "movn %[s1], %[temp_reg6], %[temp_reg5] \n\t"
670  "mfhi %[temp_reg5] \n\t"
671  "lw %[temp_reg3], 10*4(%[win]) \n\t"
672  "lw %[temp_reg4], 4*10*4(%[buf]) \n\t"
673  "extr.w %[s3], $ac1, 23 \n\t"
674  "lw %[temp_reg1], 4*7*4(%[buf]) \n\t"
675  "lw %[temp_reg2], 7*4(%[win]) \n\t"
676  "lw %[temp_reg6], 30*4(%[win]) \n\t"
677  "subu %[s1], %[temp_reg5], %[s1] \n\t"
678  "sub %[t1], %[s0], %[s1] \n\t"
679  "add %[t0], %[s0], %[s1] \n\t"
680  "mult $ac2, %[t1], %[temp_reg3] \n\t"
681  "mult $ac3, %[t1], %[temp_reg2] \n\t"
682  "mult %[t0], %[temp_reg6] \n\t"
683  "lw %[temp_reg5], 27*4(%[win]) \n\t"
684  "mult $ac1, %[t0], %[temp_reg5] \n\t"
685  "mfhi %[temp_reg3], $ac2 \n\t"
686  "mfhi %[temp_reg2], $ac3 \n\t"
687  "mfhi %[temp_reg6] \n\t"
688  "add %[t0], %[s2], %[s3] \n\t"
689  "sub %[t1], %[s2], %[s3] \n\t"
690  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
691  "lw %[temp_reg4], 16*4(%[win]) \n\t"
692  "mfhi %[temp_reg5], $ac1 \n\t"
693  "sw %[temp_reg3], 32*10*4(%[out]) \n\t"
694  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
695  "lw %[temp_reg3], 4*16*4(%[buf]) \n\t"
696  "sw %[temp_reg6], 4*10*4(%[buf]) \n\t"
697  "sw %[temp_reg1], 7*32*4(%[out]) \n\t"
698  "mult $ac2, %[t1], %[temp_reg4] \n\t"
699  "sw %[temp_reg5], 4*7*4(%[buf]) \n\t"
700  "lw %[temp_reg6], 1*4(%[win]) \n\t"
701  "lw %[temp_reg5], 4*1*4(%[buf]) \n\t"
702  "lw %[temp_reg1], 36*4(%[win]) \n\t"
703  "mult $ac3, %[t1], %[temp_reg6] \n\t"
704  "lw %[temp_reg2], 21*4(%[win]) \n\t"
705  "mfhi %[temp_reg4], $ac2 \n\t"
706  "mult %[t0], %[temp_reg1] \n\t"
707  "mult $ac1, %[t0],%[temp_reg2] \n\t"
708  "lw %[t0], 8*4(%[tmp]) \n\t"
709  "mfhi %[temp_reg6], $ac3 \n\t"
710  "lw %[t1], 10*4(%[tmp]) \n\t"
711  "lw %[t3], 11*4(%[tmp]) \n\t"
712  "mfhi %[temp_reg1] \n\t"
713  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
714  "lw %[t2], 9*4(%[tmp]) \n\t"
715  "mfhi %[temp_reg2], $ac1 \n\t"
716  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
717  "sw %[temp_reg3], 16*32*4(%[out]) \n\t"
718  "sw %[temp_reg5], 1*32*4(%[out]) \n\t"
719  "sw %[temp_reg1], 4*16*4(%[buf]) \n\t"
720  "addu %[temp_reg3], %[t3], %[t2] \n\t"
721  "li %[temp_reg4], 0x8D3B7CD6 \n\t"
722  "sw %[temp_reg2], 4*1*4(%[buf]) \n\t"
723  "multu %[temp_reg4],%[temp_reg3] \n\t"
724  "sra %[temp_reg3], %[temp_reg3], 31 \n\t"
725  "move %[s1], $0 \n\t"
726  "movn %[s1], %[temp_reg4], %[temp_reg3] \n\t"
727  "addu %[s0], %[t1], %[t0] \n\t"
728  "mfhi %[temp_reg3] \n\t"
729  "sub %[s2], %[t1], %[t0] \n\t"
730  "sub %[temp_reg5], %[t3], %[t2] \n\t"
731  "li %[temp_reg6], 0x976fd9 \n\t"
732  "lw %[temp_reg2], 11*4(%[win]) \n\t"
733  "lw %[temp_reg1], 4*11*4(%[buf]) \n\t"
734  "mult $ac1, %[temp_reg6], %[temp_reg5] \n\t"
735  "subu %[s1], %[temp_reg3], %[s1] \n\t"
736  "lw %[temp_reg5], 31*4(%[win]) \n\t"
737  "sub %[t1], %[s0], %[s1] \n\t"
738  "add %[t0], %[s0], %[s1] \n\t"
739  "mult $ac2, %[t1], %[temp_reg2] \n\t"
740  "mult %[t0], %[temp_reg5] \n\t"
741  "lw %[temp_reg4], 6*4(%[win]) \n\t"
742  "extr.w %[s3], $ac1, 23 \n\t"
743  "lw %[temp_reg3], 4*6*4(%[buf]) \n\t"
744  "mfhi %[temp_reg2], $ac2 \n\t"
745  "lw %[temp_reg6], 26*4(%[win]) \n\t"
746  "mfhi %[temp_reg5] \n\t"
747  "mult $ac3, %[t1], %[temp_reg4] \n\t"
748  "mult $ac1, %[t0], %[temp_reg6] \n\t"
749  "add %[t0], %[s2], %[s3] \n\t"
750  "sub %[t1], %[s2], %[s3] \n\t"
751  "add %[temp_reg2], %[temp_reg2], %[temp_reg1] \n\t"
752  "mfhi %[temp_reg4], $ac3 \n\t"
753  "mfhi %[temp_reg6], $ac1 \n\t"
754  "sw %[temp_reg5], 4*11*4(%[buf]) \n\t"
755  "sw %[temp_reg2], 32*11*4(%[out]) \n\t"
756  "lw %[temp_reg1], 4*15*4(%[buf]) \n\t"
757  "add %[temp_reg3], %[temp_reg3], %[temp_reg4] \n\t"
758  "lw %[temp_reg2], 15*4(%[win]) \n\t"
759  "sw %[temp_reg3], 6*32*4(%[out]) \n\t"
760  "sw %[temp_reg6], 4*6*4(%[buf]) \n\t"
761  "mult %[t1], %[temp_reg2] \n\t"
762  "lw %[temp_reg3], 2*4(%[win]) \n\t"
763  "lw %[temp_reg4], 4*2*4(%[buf]) \n\t"
764  "lw %[temp_reg5], 35*4(%[win]) \n\t"
765  "mult $ac1, %[t1], %[temp_reg3] \n\t"
766  "mfhi %[temp_reg2] \n\t"
767  "lw %[temp_reg6], 22*4(%[win]) \n\t"
768  "mult $ac2, %[t0], %[temp_reg5] \n\t"
769  "lw %[t1], 14*4(%[tmp]) \n\t"
770  "mult $ac3, %[t0], %[temp_reg6] \n\t"
771  "lw %[t0], 12*4(%[tmp]) \n\t"
772  "mfhi %[temp_reg3], $ac1 \n\t"
773  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
774  "mfhi %[temp_reg5], $ac2 \n\t"
775  "sw %[temp_reg1], 15*32*4(%[out]) \n\t"
776  "mfhi %[temp_reg6], $ac3 \n\t"
777  "lw %[t2], 13*4(%[tmp]) \n\t"
778  "lw %[t3], 15*4(%[tmp]) \n\t"
779  "add %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
780  "sw %[temp_reg5], 4*15*4(%[buf]) \n\t"
781  "addu %[temp_reg1], %[t3], %[t2] \n\t"
782  "li %[temp_reg2], 0x9C42577C \n\t"
783  "move %[s1], $0 \n\t"
784  "multu %[temp_reg2], %[temp_reg1] \n\t"
785  "sw %[temp_reg4], 2*32*4(%[out]) \n\t"
786  "sra %[temp_reg1], %[temp_reg1], 31 \n\t"
787  "movn %[s1], %[temp_reg2], %[temp_reg1] \n\t"
788  "sub %[temp_reg3], %[t3], %[t2] \n\t"
789  "li %[temp_reg4], 0x6f94a2 \n\t"
790  "mfhi %[temp_reg1] \n\t"
791  "addu %[s0], %[t1], %[t0] \n\t"
792  "sw %[temp_reg6], 4*2*4(%[buf]) \n\t"
793  "mult $ac1, %[temp_reg4], %[temp_reg3] \n\t"
794  "sub %[s2], %[t1], %[t0] \n\t"
795  "lw %[temp_reg5], 12*4(%[win]) \n\t"
796  "lw %[temp_reg6], 4*12*4(%[buf]) \n\t"
797  "subu %[s1], %[temp_reg1], %[s1] \n\t"
798  "sub %[t1], %[s0], %[s1] \n\t"
799  "lw %[temp_reg3], 32*4(%[win]) \n\t"
800  "mult $ac2, %[t1], %[temp_reg5] \n\t"
801  "add %[t0], %[s0], %[s1] \n\t"
802  "extr.w %[s3], $ac1, 23 \n\t"
803  "lw %[temp_reg2], 5*4(%[win]) \n\t"
804  "mult %[t0], %[temp_reg3] \n\t"
805  "mfhi %[temp_reg5], $ac2 \n\t"
806  "lw %[temp_reg4], 25*4(%[win]) \n\t"
807  "lw %[temp_reg1], 4*5*4(%[buf]) \n\t"
808  "mult $ac3, %[t1], %[temp_reg2] \n\t"
809  "mult $ac1, %[t0], %[temp_reg4] \n\t"
810  "mfhi %[temp_reg3] \n\t"
811  "add %[t0], %[s2], %[s3] \n\t"
812  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
813  "mfhi %[temp_reg2], $ac3 \n\t"
814  "mfhi %[temp_reg4], $ac1 \n\t"
815  "sub %[t1], %[s2], %[s3] \n\t"
816  "sw %[temp_reg5], 32*12*4(%[out]) \n\t"
817  "sw %[temp_reg3], 4*12*4(%[buf]) \n\t"
818  "lw %[temp_reg6], 14*4(%[win]) \n\t"
819  "lw %[temp_reg5], 4*14*4(%[buf]) \n\t"
820  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
821  "sw %[temp_reg4], 4*5*4(%[buf]) \n\t"
822  "sw %[temp_reg1], 5*32*4(%[out]) \n\t"
823  "mult %[t1], %[temp_reg6] \n\t"
824  "lw %[temp_reg4], 34*4(%[win]) \n\t"
825  "lw %[temp_reg2], 3*4(%[win]) \n\t"
826  "lw %[temp_reg1], 4*3*4(%[buf]) \n\t"
827  "mult $ac2, %[t0], %[temp_reg4] \n\t"
828  "mfhi %[temp_reg6] \n\t"
829  "mult $ac1, %[t1], %[temp_reg2] \n\t"
830  "lw %[temp_reg3], 23*4(%[win]) \n\t"
831  "lw %[s0], 16*4(%[tmp]) \n\t"
832  "mfhi %[temp_reg4], $ac2 \n\t"
833  "lw %[t1], 17*4(%[tmp]) \n\t"
834  "mult $ac3, %[t0], %[temp_reg3] \n\t"
835  "move %[s1], $0 \n\t"
836  "add %[temp_reg5], %[temp_reg5], %[temp_reg6] \n\t"
837  "mfhi %[temp_reg2], $ac1 \n\t"
838  "sw %[temp_reg5], 14*32*4(%[out]) \n\t"
839  "sw %[temp_reg4], 4*14*4(%[buf]) \n\t"
840  "mfhi %[temp_reg3], $ac3 \n\t"
841  "li %[temp_reg5], 0xB504F334 \n\t"
842  "add %[temp_reg1], %[temp_reg1], %[temp_reg2] \n\t"
843  "multu %[temp_reg5], %[t1] \n\t"
844  "lw %[temp_reg2], 4*13*4(%[buf]) \n\t"
845  "sw %[temp_reg1], 3*32*4(%[out]) \n\t"
846  "sra %[t1], %[t1], 31 \n\t"
847  "mfhi %[temp_reg6] \n\t"
848  "movn %[s1], %[temp_reg5], %[t1] \n\t"
849  "sw %[temp_reg3], 4*3*4(%[buf]) \n\t"
850  "lw %[temp_reg1], 13*4(%[win]) \n\t"
851  "lw %[temp_reg4], 4*4*4(%[buf]) \n\t"
852  "lw %[temp_reg3], 4*4(%[win]) \n\t"
853  "lw %[temp_reg5], 33*4(%[win]) \n\t"
854  "subu %[s1], %[temp_reg6], %[s1] \n\t"
855  "lw %[temp_reg6], 24*4(%[win]) \n\t"
856  "sub %[t1], %[s0], %[s1] \n\t"
857  "add %[t0], %[s0], %[s1] \n\t"
858  "mult $ac1, %[t1], %[temp_reg1] \n\t"
859  "mult $ac2, %[t1], %[temp_reg3] \n\t"
860  "mult $ac3, %[t0], %[temp_reg5] \n\t"
861  "mult %[t0], %[temp_reg6] \n\t"
862  "mfhi %[temp_reg1], $ac1 \n\t"
863  "mfhi %[temp_reg3], $ac2 \n\t"
864  "mfhi %[temp_reg5], $ac3 \n\t"
865  "mfhi %[temp_reg6] \n\t"
866  "add %[temp_reg2], %[temp_reg2], %[temp_reg1] \n\t"
867  "add %[temp_reg4], %[temp_reg4], %[temp_reg3] \n\t"
868  "sw %[temp_reg2], 13*32*4(%[out]) \n\t"
869  "sw %[temp_reg4], 4*32*4(%[out]) \n\t"
870  "sw %[temp_reg5], 4*13*4(%[buf]) \n\t"
871  "sw %[temp_reg6], 4*4*4(%[buf]) \n\t"
872 
873  : [t0] "=&r" (t0), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3),
874  [s0] "=&r" (s0), [s2] "=&r" (s2), [temp_reg1] "=&r" (temp_reg1),
875  [temp_reg2] "=&r" (temp_reg2), [s1] "=&r" (s1), [s3] "=&r" (s3),
876  [temp_reg3] "=&r" (temp_reg3), [temp_reg4] "=&r" (temp_reg4),
877  [temp_reg5] "=&r" (temp_reg5), [temp_reg6] "=&r" (temp_reg6),
878  [out] "+r" (out)
879  : [tmp] "r" (tmp), [win] "r" (win), [buf] "r" (buf)
880  : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
881  "$ac3hi", "$ac3lo"
882  );
883 }
884 
885 static void ff_imdct36_blocks_mips_fixed(int *out, int *buf, int *in,
886  int count, int switch_point, int block_type)
887 {
888  int j;
889  for (j=0 ; j < count; j++) {
890  /* apply window & overlap with previous buffer */
891 
892  /* select window */
893  int win_idx = (switch_point && j < 2) ? 0 : block_type;
894  int *win = ff_mdct_win_fixed[win_idx + (4 & -(j & 1))];
895 
896  imdct36_mips_fixed(out, buf, in, win);
897 
898  in += 18;
899  buf += ((j&3) != 3 ? 1 : (72-3));
900  out++;
901  }
902 }
903 
905 {
908 }
const char * s
Definition: avisynth_c.h:631
void(* imdct36_blocks_fixed)(int *out, int *buf, int *in, int count, int switch_point, int block_type)
Definition: mpegaudiodsp.h:35
MIPS assembly defines from sys/asm.h but rewritten for use with C inline assembly (rather than from w...
#define t8
Definition: regdef.h:53
static void ff_imdct36_blocks_mips_fixed(int *out, int *buf, int *in, int count, int switch_point, int block_type)
#define t7
Definition: regdef.h:35
void ff_mpadsp_init_mipsdspr1(MPADSPContext *s)
static void imdct36_mips_fixed(int *out, int *buf, int *in, int *win)
#define t0
Definition: regdef.h:28
#define s2
Definition: regdef.h:39
#define s0
Definition: regdef.h:37
#define t1
Definition: regdef.h:29
#define t3
Definition: regdef.h:31
GLsizei count
Definition: opengl_enc.c:109
int32_t
#define s3
Definition: regdef.h:40
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void * buf
Definition: avisynth_c.h:553
#define PTR_ADDIU
Definition: asmdefs.h:41
int ff_mdct_win_fixed[8][MDCT_BUF_SIZE]
#define t5
Definition: regdef.h:33
#define s1
Definition: regdef.h:38
void(* apply_window_fixed)(int32_t *synth_buf, int32_t *window, int *dither_state, int16_t *samples, int incr)
Definition: mpegaudiodsp.h:28
#define t6
Definition: regdef.h:34
#define t4
Definition: regdef.h:32
static void ff_mpadsp_apply_window_mips_fixed(int32_t *synth_buf, int32_t *window, int *dither_state, int16_t *samples, int incr)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
#define t2
Definition: regdef.h:30