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  * Authors:  Darko Laus      (darko@mips.com)
30  *           Djordje Pesut   (djordje@mips.com)
31  *           Mirjana Vulin   (mvulin@mips.com)
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/aacpsdsp.c
53  */
54 
55 #include "config.h"
56 #include "libavcodec/aacpsdsp.h"
57 #include "libavutil/mips/asmdefs.h"
58 
59 #if HAVE_INLINE_ASM
60 #if HAVE_MIPSFPU
ps_hybrid_analysis_ileave_mips(float (* out)[32][2],float L[2][38][64],int i,int len)61 static void ps_hybrid_analysis_ileave_mips(float (*out)[32][2], float L[2][38][64],
62                                         int i, int len)
63 {
64     int temp0, temp1, temp2, temp3;
65     int temp4, temp5, temp6, temp7;
66     float *out1=&out[i][0][0];
67     float *L1=&L[0][0][i];
68     float *j=out1+ len*2;
69 
70     for (; i < 64; i++) {
71 
72         /* loop unrolled 8 times */
73         __asm__ volatile (
74         "1:                                          \n\t"
75             "lw      %[temp0],   0(%[L1])            \n\t"
76             "lw      %[temp1],   9728(%[L1])         \n\t"
77             "lw      %[temp2],   256(%[L1])          \n\t"
78             "lw      %[temp3],   9984(%[L1])         \n\t"
79             "lw      %[temp4],   512(%[L1])          \n\t"
80             "lw      %[temp5],   10240(%[L1])        \n\t"
81             "lw      %[temp6],   768(%[L1])          \n\t"
82             "lw      %[temp7],   10496(%[L1])        \n\t"
83             "sw      %[temp0],   0(%[out1])          \n\t"
84             "sw      %[temp1],   4(%[out1])          \n\t"
85             "sw      %[temp2],   8(%[out1])          \n\t"
86             "sw      %[temp3],   12(%[out1])         \n\t"
87             "sw      %[temp4],   16(%[out1])         \n\t"
88             "sw      %[temp5],   20(%[out1])         \n\t"
89             "sw      %[temp6],   24(%[out1])         \n\t"
90             "sw      %[temp7],   28(%[out1])         \n\t"
91             PTR_ADDIU "%[out1],  %[out1],      32    \n\t"
92             PTR_ADDIU "%[L1],    %[L1],        1024  \n\t"
93             "bne     %[out1],    %[j],         1b    \n\t"
94 
95             : [out1]"+r"(out1), [L1]"+r"(L1), [j]"+r"(j),
96               [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
97               [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
98               [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
99               [temp6]"=&r"(temp6), [temp7]"=&r"(temp7)
100             : [len]"r"(len)
101             : "memory"
102         );
103         out1-=(len<<1)-64;
104         L1-=(len<<6)-1;
105         j+=len*2;
106     }
107 }
108 
ps_hybrid_synthesis_deint_mips(float out[2][38][64],float (* in)[32][2],int i,int len)109 static void ps_hybrid_synthesis_deint_mips(float out[2][38][64],
110                                         float (*in)[32][2],
111                                         int i, int len)
112 {
113     int n;
114     int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
115     float *out1 = (float*)out + i;
116     float *out2 = (float*)out + 2432 + i;
117     float *in1 = (float*)in + 64 * i;
118     float *in2 = (float*)in + 64 * i + 1;
119 
120     for (; i < 64; i++) {
121         for (n = 0; n < 7; n++) {
122 
123             /* loop unrolled 8 times */
124             __asm__ volatile (
125                  "lw      %[temp0],   0(%[in1])               \n\t"
126                  "lw      %[temp1],   0(%[in2])               \n\t"
127                  "lw      %[temp2],   8(%[in1])               \n\t"
128                  "lw      %[temp3],   8(%[in2])               \n\t"
129                  "lw      %[temp4],   16(%[in1])              \n\t"
130                  "lw      %[temp5],   16(%[in2])              \n\t"
131                  "lw      %[temp6],   24(%[in1])              \n\t"
132                  "lw      %[temp7],   24(%[in2])              \n\t"
133                  PTR_ADDIU "%[out1],  %[out1],         1024   \n\t"
134                  PTR_ADDIU "%[out2],  %[out2],         1024   \n\t"
135                  PTR_ADDIU "%[in1],   %[in1],          32     \n\t"
136                  PTR_ADDIU "%[in2],   %[in2],          32     \n\t"
137                  "sw      %[temp0],   -1024(%[out1])          \n\t"
138                  "sw      %[temp1],   -1024(%[out2])          \n\t"
139                  "sw      %[temp2],   -768(%[out1])           \n\t"
140                  "sw      %[temp3],   -768(%[out2])           \n\t"
141                  "sw      %[temp4],   -512(%[out1])           \n\t"
142                  "sw      %[temp5],   -512(%[out2])           \n\t"
143                  "sw      %[temp6],   -256(%[out1])           \n\t"
144                  "sw      %[temp7],   -256(%[out2])           \n\t"
145 
146                  : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
147                    [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
148                    [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
149                    [temp6]"=&r"(temp6), [temp7]"=&r"(temp7),
150                    [out1]"+r"(out1), [out2]"+r"(out2),
151                    [in1]"+r"(in1), [in2]"+r"(in2)
152                  :
153                  : "memory"
154             );
155         }
156         /* loop unrolled 8 times */
157         __asm__ volatile (
158             "lw      %[temp0],   0(%[in1])               \n\t"
159             "lw      %[temp1],   0(%[in2])               \n\t"
160             "lw      %[temp2],   8(%[in1])               \n\t"
161             "lw      %[temp3],   8(%[in2])               \n\t"
162             "lw      %[temp4],   16(%[in1])              \n\t"
163             "lw      %[temp5],   16(%[in2])              \n\t"
164             "lw      %[temp6],   24(%[in1])              \n\t"
165             "lw      %[temp7],   24(%[in2])              \n\t"
166             PTR_ADDIU "%[out1],  %[out1],        -7164   \n\t"
167             PTR_ADDIU "%[out2],  %[out2],        -7164   \n\t"
168             PTR_ADDIU "%[in1],   %[in1],         32      \n\t"
169             PTR_ADDIU "%[in2],   %[in2],         32      \n\t"
170             "sw      %[temp0],   7164(%[out1])           \n\t"
171             "sw      %[temp1],   7164(%[out2])           \n\t"
172             "sw      %[temp2],   7420(%[out1])           \n\t"
173             "sw      %[temp3],   7420(%[out2])           \n\t"
174             "sw      %[temp4],   7676(%[out1])           \n\t"
175             "sw      %[temp5],   7676(%[out2])           \n\t"
176             "sw      %[temp6],   7932(%[out1])           \n\t"
177             "sw      %[temp7],   7932(%[out2])           \n\t"
178 
179             : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
180               [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
181               [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
182               [temp6]"=&r"(temp6), [temp7]"=&r"(temp7),
183               [out1]"+r"(out1), [out2]"+r"(out2),
184               [in1]"+r"(in1), [in2]"+r"(in2)
185             :
186             : "memory"
187         );
188     }
189 }
190 
191 #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
ps_add_squares_mips(float * dst,const float (* src)[2],int n)192 static void ps_add_squares_mips(float *dst, const float (*src)[2], int n)
193 {
194     int i;
195     float temp0, temp1, temp2, temp3, temp4, temp5;
196     float temp6, temp7, temp8, temp9, temp10, temp11;
197     float *src0 = (float*)&src[0][0];
198     float *dst0 = &dst[0];
199 
200     for (i = 0; i < 8; i++) {
201         /* loop unrolled 4 times */
202         __asm__ volatile (
203             "lwc1     %[temp0],    0(%[src0])                          \n\t"
204             "lwc1     %[temp1],    4(%[src0])                          \n\t"
205             "lwc1     %[temp2],    8(%[src0])                          \n\t"
206             "lwc1     %[temp3],    12(%[src0])                         \n\t"
207             "lwc1     %[temp4],    16(%[src0])                         \n\t"
208             "lwc1     %[temp5],    20(%[src0])                         \n\t"
209             "lwc1     %[temp6],    24(%[src0])                         \n\t"
210             "lwc1     %[temp7],    28(%[src0])                         \n\t"
211             "lwc1     %[temp8],    0(%[dst0])                          \n\t"
212             "lwc1     %[temp9],    4(%[dst0])                          \n\t"
213             "lwc1     %[temp10],   8(%[dst0])                          \n\t"
214             "lwc1     %[temp11],   12(%[dst0])                         \n\t"
215             "mul.s    %[temp1],    %[temp1],    %[temp1]               \n\t"
216             "mul.s    %[temp3],    %[temp3],    %[temp3]               \n\t"
217             "mul.s    %[temp5],    %[temp5],    %[temp5]               \n\t"
218             "mul.s    %[temp7],    %[temp7],    %[temp7]               \n\t"
219             "madd.s   %[temp0],    %[temp1],    %[temp0],   %[temp0]   \n\t"
220             "madd.s   %[temp2],    %[temp3],    %[temp2],   %[temp2]   \n\t"
221             "madd.s   %[temp4],    %[temp5],    %[temp4],   %[temp4]   \n\t"
222             "madd.s   %[temp6],    %[temp7],    %[temp6],   %[temp6]   \n\t"
223             "add.s    %[temp0],    %[temp8],    %[temp0]               \n\t"
224             "add.s    %[temp2],    %[temp9],    %[temp2]               \n\t"
225             "add.s    %[temp4],    %[temp10],   %[temp4]               \n\t"
226             "add.s    %[temp6],    %[temp11],   %[temp6]               \n\t"
227             "swc1     %[temp0],    0(%[dst0])                          \n\t"
228             "swc1     %[temp2],    4(%[dst0])                          \n\t"
229             "swc1     %[temp4],    8(%[dst0])                          \n\t"
230             "swc1     %[temp6],    12(%[dst0])                         \n\t"
231             PTR_ADDIU "%[dst0],    %[dst0],     16                     \n\t"
232             PTR_ADDIU "%[src0],    %[src0],     32                     \n\t"
233 
234             : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
235               [temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
236               [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), [temp8]"=&f"(temp8),
237               [temp9]"=&f"(temp9), [dst0]"+r"(dst0), [src0]"+r"(src0),
238               [temp10]"=&f"(temp10), [temp11]"=&f"(temp11)
239             :
240             : "memory"
241         );
242    }
243 }
244 
ps_mul_pair_single_mips(float (* dst)[2],float (* src0)[2],float * src1,int n)245 static void ps_mul_pair_single_mips(float (*dst)[2], float (*src0)[2], float *src1,
246                                  int n)
247 {
248     float temp0, temp1, temp2;
249     float *p_d, *p_s0, *p_s1, *end;
250     p_d = &dst[0][0];
251     p_s0 = &src0[0][0];
252     p_s1 = &src1[0];
253     end = p_s1 + n;
254 
255     __asm__ volatile(
256         ".set push                                      \n\t"
257         ".set noreorder                                 \n\t"
258         "1:                                             \n\t"
259         "lwc1     %[temp2],   0(%[p_s1])                \n\t"
260         "lwc1     %[temp0],   0(%[p_s0])                \n\t"
261         "lwc1     %[temp1],   4(%[p_s0])                \n\t"
262         PTR_ADDIU "%[p_d],    %[p_d],       8           \n\t"
263         "mul.s    %[temp0],   %[temp0],     %[temp2]    \n\t"
264         "mul.s    %[temp1],   %[temp1],     %[temp2]    \n\t"
265         PTR_ADDIU "%[p_s0],   %[p_s0],      8           \n\t"
266         "swc1     %[temp0],   -8(%[p_d])                \n\t"
267         "swc1     %[temp1],   -4(%[p_d])                \n\t"
268         "bne      %[p_s1],    %[end],       1b          \n\t"
269         PTR_ADDIU "%[p_s1],   %[p_s1],      4           \n\t"
270         ".set pop                                       \n\t"
271 
272         : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1),
273           [temp2]"=&f"(temp2), [p_d]"+r"(p_d),
274           [p_s0]"+r"(p_s0), [p_s1]"+r"(p_s1)
275         : [end]"r"(end)
276         : "memory"
277     );
278 }
279 
ps_decorrelate_mips(float (* out)[2],float (* delay)[2],float (* ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],const float phi_fract[2],const float (* Q_fract)[2],const float * transient_gain,float g_decay_slope,int len)280 static void ps_decorrelate_mips(float (*out)[2], float (*delay)[2],
281                              float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
282                              const float phi_fract[2], const float (*Q_fract)[2],
283                              const float *transient_gain,
284                              float g_decay_slope,
285                              int len)
286 {
287     float *p_delay = &delay[0][0];
288     float *p_out = &out[0][0];
289     float *p_ap_delay = &ap_delay[0][0][0];
290     const float *p_t_gain = transient_gain;
291     const float *p_Q_fract = &Q_fract[0][0];
292     float ag0, ag1, ag2;
293     float phi_fract0 = phi_fract[0];
294     float phi_fract1 = phi_fract[1];
295     float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
296     float f1, f2, f3;
297 
298     float *p_delay_end = (p_delay + (len << 1));
299 
300     /* merged 2 loops */
301     f1 = 0.65143905753106;
302     f2 = 0.56471812200776;
303     f3 = 0.48954165955695;
304     __asm__ volatile(
305         ".set    push                                                    \n\t"
306         ".set    noreorder                                               \n\t"
307         "mul.s   %[ag0],        %[ag0],        %[g_decay_slope]          \n\t"
308         "mul.s   %[ag1],        %[ag1],        %[g_decay_slope]          \n\t"
309         "mul.s   %[ag2],        %[ag2],        %[g_decay_slope]          \n\t"
310     "1:                                                                  \n\t"
311         "lwc1    %[temp0],      0(%[p_delay])                            \n\t"
312         "lwc1    %[temp1],      4(%[p_delay])                            \n\t"
313         "lwc1    %[temp4],      16(%[p_ap_delay])                        \n\t"
314         "lwc1    %[temp5],      20(%[p_ap_delay])                        \n\t"
315         "mul.s   %[temp3],      %[temp0],      %[phi_fract1]             \n\t"
316         "lwc1    %[temp6],      0(%[p_Q_fract])                          \n\t"
317         "mul.s   %[temp2],      %[temp1],      %[phi_fract1]             \n\t"
318         "lwc1    %[temp7],      4(%[p_Q_fract])                          \n\t"
319         "madd.s  %[temp3],      %[temp3],      %[temp1], %[phi_fract0]   \n\t"
320         "msub.s  %[temp2],      %[temp2],      %[temp0], %[phi_fract0]   \n\t"
321         "mul.s   %[temp8],      %[temp5],      %[temp7]                  \n\t"
322         "mul.s   %[temp9],      %[temp4],      %[temp7]                  \n\t"
323         "lwc1    %[temp7],      12(%[p_Q_fract])                         \n\t"
324         "mul.s   %[temp0],      %[ag0],        %[temp2]                  \n\t"
325         "mul.s   %[temp1],      %[ag0],        %[temp3]                  \n\t"
326         "msub.s  %[temp8],      %[temp8],      %[temp4], %[temp6]        \n\t"
327         "lwc1    %[temp4],      304(%[p_ap_delay])                       \n\t"
328         "madd.s  %[temp9],      %[temp9],      %[temp5], %[temp6]        \n\t"
329         "lwc1    %[temp5],      308(%[p_ap_delay])                       \n\t"
330         "sub.s   %[temp0],      %[temp8],      %[temp0]                  \n\t"
331         "sub.s   %[temp1],      %[temp9],      %[temp1]                  \n\t"
332         "madd.s  %[temp2],      %[temp2],      %[ag0],   %[temp0]        \n\t"
333         "lwc1    %[temp6],      8(%[p_Q_fract])                          \n\t"
334         "madd.s  %[temp3],      %[temp3],      %[ag0],   %[temp1]        \n\t"
335         "mul.s   %[temp8],      %[temp5],      %[temp7]                  \n\t"
336         "mul.s   %[temp9],      %[temp4],      %[temp7]                  \n\t"
337         "lwc1    %[temp7],      20(%[p_Q_fract])                         \n\t"
338         "msub.s  %[temp8],      %[temp8],      %[temp4], %[temp6]        \n\t"
339         "swc1    %[temp2],      40(%[p_ap_delay])                        \n\t"
340         "mul.s   %[temp2],      %[ag1],        %[temp0]                  \n\t"
341         "swc1    %[temp3],      44(%[p_ap_delay])                        \n\t"
342         "mul.s   %[temp3],      %[ag1],        %[temp1]                  \n\t"
343         "lwc1    %[temp4],      592(%[p_ap_delay])                       \n\t"
344         "madd.s  %[temp9],      %[temp9],      %[temp5], %[temp6]        \n\t"
345         "lwc1    %[temp5],      596(%[p_ap_delay])                       \n\t"
346         "sub.s   %[temp2],      %[temp8],      %[temp2]                  \n\t"
347         "sub.s   %[temp3],      %[temp9],      %[temp3]                  \n\t"
348         "lwc1    %[temp6],      16(%[p_Q_fract])                         \n\t"
349         "madd.s  %[temp0],      %[temp0],      %[ag1],   %[temp2]        \n\t"
350         "madd.s  %[temp1],      %[temp1],      %[ag1],   %[temp3]        \n\t"
351         "mul.s   %[temp8],      %[temp5],      %[temp7]                  \n\t"
352         "mul.s   %[temp9],      %[temp4],      %[temp7]                  \n\t"
353         "msub.s  %[temp8],      %[temp8],      %[temp4], %[temp6]        \n\t"
354         "madd.s  %[temp9],      %[temp9],      %[temp5], %[temp6]        \n\t"
355         "swc1    %[temp0],      336(%[p_ap_delay])                       \n\t"
356         "mul.s   %[temp0],      %[ag2],        %[temp2]                  \n\t"
357         "swc1    %[temp1],      340(%[p_ap_delay])                       \n\t"
358         "mul.s   %[temp1],      %[ag2],        %[temp3]                  \n\t"
359         "lwc1    %[temp4],      0(%[p_t_gain])                           \n\t"
360         "sub.s   %[temp0],      %[temp8],      %[temp0]                  \n\t"
361         PTR_ADDIU "%[p_ap_delay], %[p_ap_delay], 8                       \n\t"
362         "sub.s   %[temp1],      %[temp9],      %[temp1]                  \n\t"
363         PTR_ADDIU "%[p_t_gain], %[p_t_gain],   4                         \n\t"
364         "madd.s  %[temp2],      %[temp2],      %[ag2],   %[temp0]        \n\t"
365         PTR_ADDIU "%[p_delay],  %[p_delay],    8                         \n\t"
366         "madd.s  %[temp3],      %[temp3],      %[ag2],   %[temp1]        \n\t"
367         PTR_ADDIU "%[p_out],    %[p_out],      8                         \n\t"
368         "mul.s   %[temp5],      %[temp4],      %[temp0]                  \n\t"
369         "mul.s   %[temp6],      %[temp4],      %[temp1]                  \n\t"
370         "swc1    %[temp2],      624(%[p_ap_delay])                       \n\t"
371         "swc1    %[temp3],      628(%[p_ap_delay])                       \n\t"
372         "swc1    %[temp5],      -8(%[p_out])                             \n\t"
373         "swc1    %[temp6],      -4(%[p_out])                             \n\t"
374         "bne     %[p_delay],    %[p_delay_end],1b                        \n\t"
375         " swc1   %[temp6],      -4(%[p_out])                             \n\t"
376         ".set    pop                                                     \n\t"
377 
378         : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
379           [temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
380           [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), [temp8]"=&f"(temp8),
381           [temp9]"=&f"(temp9), [p_delay]"+r"(p_delay), [p_ap_delay]"+r"(p_ap_delay),
382           [p_Q_fract]"+r"(p_Q_fract), [p_t_gain]"+r"(p_t_gain), [p_out]"+r"(p_out)
383         : [phi_fract0]"f"(phi_fract0), [phi_fract1]"f"(phi_fract1),
384           [p_delay_end]"r"(p_delay_end), [g_decay_slope]"f"(g_decay_slope),
385           [ag0]"f"(f1), [ag1]"f"(f2), [ag2]"f"(f3)
386         : "memory"
387     );
388 }
389 
ps_stereo_interpolate_mips(float (* l)[2],float (* r)[2],float h[2][4],float h_step[2][4],int len)390 static void ps_stereo_interpolate_mips(float (*l)[2], float (*r)[2],
391                                     float h[2][4], float h_step[2][4],
392                                     int len)
393 {
394     float h0 = h[0][0];
395     float h1 = h[0][1];
396     float h2 = h[0][2];
397     float h3 = h[0][3];
398     float hs0 = h_step[0][0];
399     float hs1 = h_step[0][1];
400     float hs2 = h_step[0][2];
401     float hs3 = h_step[0][3];
402     float temp0, temp1, temp2, temp3;
403     float l_re, l_im, r_re, r_im;
404 
405     float *l_end = ((float *)l + (len << 1));
406 
407     __asm__ volatile(
408         ".set    push                                     \n\t"
409         ".set    noreorder                                \n\t"
410     "1:                                                   \n\t"
411         "add.s   %[h0],     %[h0],     %[hs0]             \n\t"
412         "lwc1    %[l_re],   0(%[l])                       \n\t"
413         "add.s   %[h1],     %[h1],     %[hs1]             \n\t"
414         "lwc1    %[r_re],   0(%[r])                       \n\t"
415         "add.s   %[h2],     %[h2],     %[hs2]             \n\t"
416         "lwc1    %[l_im],   4(%[l])                       \n\t"
417         "add.s   %[h3],     %[h3],     %[hs3]             \n\t"
418         "lwc1    %[r_im],   4(%[r])                       \n\t"
419         "mul.s   %[temp0],  %[h0],     %[l_re]            \n\t"
420         PTR_ADDIU "%[l],    %[l],      8                  \n\t"
421         "mul.s   %[temp2],  %[h1],     %[l_re]            \n\t"
422         PTR_ADDIU "%[r],    %[r],      8                  \n\t"
423         "madd.s  %[temp0],  %[temp0],  %[h2],   %[r_re]   \n\t"
424         "madd.s  %[temp2],  %[temp2],  %[h3],   %[r_re]   \n\t"
425         "mul.s   %[temp1],  %[h0],     %[l_im]            \n\t"
426         "mul.s   %[temp3],  %[h1],     %[l_im]            \n\t"
427         "madd.s  %[temp1],  %[temp1],  %[h2],   %[r_im]   \n\t"
428         "madd.s  %[temp3],  %[temp3],  %[h3],   %[r_im]   \n\t"
429         "swc1    %[temp0],  -8(%[l])                      \n\t"
430         "swc1    %[temp2],  -8(%[r])                      \n\t"
431         "swc1    %[temp1],  -4(%[l])                      \n\t"
432         "bne     %[l],      %[l_end],  1b                 \n\t"
433         " swc1   %[temp3],  -4(%[r])                      \n\t"
434         ".set    pop                                      \n\t"
435 
436         : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1),
437           [temp2]"=&f"(temp2), [temp3]"=&f"(temp3),
438           [h0]"+f"(h0), [h1]"+f"(h1), [h2]"+f"(h2),
439           [h3]"+f"(h3), [l]"+r"(l), [r]"+r"(r),
440           [l_re]"=&f"(l_re), [l_im]"=&f"(l_im),
441           [r_re]"=&f"(r_re), [r_im]"=&f"(r_im)
442         : [hs0]"f"(hs0), [hs1]"f"(hs1), [hs2]"f"(hs2),
443           [hs3]"f"(hs3), [l_end]"r"(l_end)
444         : "memory"
445     );
446 }
447 #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
448 #endif /* HAVE_MIPSFPU */
449 #endif /* HAVE_INLINE_ASM */
450 
ff_psdsp_init_mips(PSDSPContext * s)451 void ff_psdsp_init_mips(PSDSPContext *s)
452 {
453 #if HAVE_INLINE_ASM
454 #if HAVE_MIPSFPU
455     s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_mips;
456     s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_mips;
457 #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
458     s->add_squares            = ps_add_squares_mips;
459     s->mul_pair_single        = ps_mul_pair_single_mips;
460     s->decorrelate            = ps_decorrelate_mips;
461     s->stereo_interpolate[0]  = ps_stereo_interpolate_mips;
462 #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
463 #endif /* HAVE_MIPSFPU */
464 #endif /* HAVE_INLINE_ASM */
465 }
466