FFmpeg
compute_antialias_fixed.h
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  * Compute antialias function optimised 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/mpegaudiodec.c
53  */
54 
55 #ifndef AVCODEC_MIPS_COMPUTE_ANTIALIAS_FIXED_H
56 #define AVCODEC_MIPS_COMPUTE_ANTIALIAS_FIXED_H
57 
58 #if HAVE_INLINE_ASM
59 #if !HAVE_MIPS32R6 && !HAVE_MIPS64R6
60 static void compute_antialias_mips_fixed(MPADecodeContext *s,
61  GranuleDef *g)
62 {
63  const int32_t *csa;
64  int32_t *ptr;
65  int n, i;
66  int MAX_lo = 0xffffffff;
67 
68  /* we antialias only "long" bands */
69  if (g->block_type == 2) {
70  if (!g->switch_point)
71  return;
72  /* XXX: check this for 8000Hz case */
73  n = 1;
74  } else {
75  n = SBLIMIT - 1;
76  }
77 
78 
79  ptr = g->sb_hybrid + 18;
80 
81  for(i = n;i > 0;i--) {
82  int tmp0, tmp1, tmp2, tmp00, tmp11;
83  int temp_reg1, temp_reg2, temp_reg3, temp_reg4, temp_reg5, temp_reg6;
84  csa = &csa_table[0][0];
85 
86  /**
87  * instructions are scheduled to minimize pipeline stall.
88  */
89  __asm__ volatile (
90  "lw %[tmp0], -1*4(%[ptr]) \n\t"
91  "lw %[tmp1], 0*4(%[ptr]) \n\t"
92  "lw %[temp_reg1], 0*4(%[csa]) \n\t"
93  "lw %[temp_reg2], 2*4(%[csa]) \n\t"
94  "add %[tmp2], %[tmp0], %[tmp1] \n\t"
95  "lw %[temp_reg3], 3*4(%[csa]) \n\t"
96  "mult $ac0, %[tmp2], %[temp_reg1] \n\t"
97  "mult $ac1, %[tmp2], %[temp_reg1] \n\t"
98  "lw %[tmp00], -2*4(%[ptr]) \n\t"
99  "lw %[tmp11], 1*4(%[ptr]) \n\t"
100  "lw %[temp_reg4], 4*4(%[csa]) \n\t"
101  "mtlo %[MAX_lo], $ac0 \n\t"
102  "mtlo $zero, $ac1 \n\t"
103  "msub $ac0, %[tmp1], %[temp_reg2] \n\t"
104  "madd $ac1, %[tmp0], %[temp_reg3] \n\t"
105  "add %[tmp2], %[tmp00], %[tmp11] \n\t"
106  "lw %[temp_reg5], 6*4(%[csa]) \n\t"
107  "mult $ac2, %[tmp2], %[temp_reg4] \n\t"
108  "mult $ac3, %[tmp2], %[temp_reg4] \n\t"
109  "mfhi %[temp_reg1], $ac0 \n\t"
110  "mfhi %[temp_reg2], $ac1 \n\t"
111  "lw %[temp_reg6], 7*4(%[csa]) \n\t"
112  "mtlo %[MAX_lo], $ac2 \n\t"
113  "msub $ac2, %[tmp11], %[temp_reg5] \n\t"
114  "mtlo $zero, $ac3 \n\t"
115  "madd $ac3, %[tmp00], %[temp_reg6] \n\t"
116  "sll %[temp_reg1], %[temp_reg1], 2 \n\t"
117  "sw %[temp_reg1], -1*4(%[ptr]) \n\t"
118  "mfhi %[temp_reg4], $ac2 \n\t"
119  "sll %[temp_reg2], %[temp_reg2], 2 \n\t"
120  "mfhi %[temp_reg5], $ac3 \n\t"
121  "sw %[temp_reg2], 0*4(%[ptr]) \n\t"
122  "lw %[tmp0], -3*4(%[ptr]) \n\t"
123  "lw %[tmp1], 2*4(%[ptr]) \n\t"
124  "lw %[temp_reg1], 8*4(%[csa]) \n\t"
125  "sll %[temp_reg4], %[temp_reg4], 2 \n\t"
126  "add %[tmp2], %[tmp0], %[tmp1] \n\t"
127  "sll %[temp_reg5], %[temp_reg5], 2 \n\t"
128  "mult $ac0, %[tmp2], %[temp_reg1] \n\t"
129  "mult $ac1, %[tmp2], %[temp_reg1] \n\t"
130  "sw %[temp_reg4], -2*4(%[ptr]) \n\t"
131  "sw %[temp_reg5], 1*4(%[ptr]) \n\t"
132  "lw %[temp_reg2], 10*4(%[csa]) \n\t"
133  "mtlo %[MAX_lo], $ac0 \n\t"
134  "lw %[temp_reg3], 11*4(%[csa]) \n\t"
135  "msub $ac0, %[tmp1], %[temp_reg2] \n\t"
136  "mtlo $zero, $ac1 \n\t"
137  "madd $ac1, %[tmp0], %[temp_reg3] \n\t"
138  "lw %[tmp00], -4*4(%[ptr]) \n\t"
139  "lw %[tmp11], 3*4(%[ptr]) \n\t"
140  "mfhi %[temp_reg1], $ac0 \n\t"
141  "lw %[temp_reg4], 12*4(%[csa]) \n\t"
142  "mfhi %[temp_reg2], $ac1 \n\t"
143  "add %[tmp2], %[tmp00], %[tmp11] \n\t"
144  "mult $ac2, %[tmp2], %[temp_reg4] \n\t"
145  "mult $ac3, %[tmp2], %[temp_reg4] \n\t"
146  "lw %[temp_reg5], 14*4(%[csa]) \n\t"
147  "lw %[temp_reg6], 15*4(%[csa]) \n\t"
148  "sll %[temp_reg1], %[temp_reg1], 2 \n\t"
149  "mtlo %[MAX_lo], $ac2 \n\t"
150  "msub $ac2, %[tmp11], %[temp_reg5] \n\t"
151  "mtlo $zero, $ac3 \n\t"
152  "madd $ac3, %[tmp00], %[temp_reg6] \n\t"
153  "sll %[temp_reg2], %[temp_reg2], 2 \n\t"
154  "sw %[temp_reg1], -3*4(%[ptr]) \n\t"
155  "mfhi %[temp_reg4], $ac2 \n\t"
156  "sw %[temp_reg2], 2*4(%[ptr]) \n\t"
157  "mfhi %[temp_reg5], $ac3 \n\t"
158  "lw %[tmp0], -5*4(%[ptr]) \n\t"
159  "lw %[tmp1], 4*4(%[ptr]) \n\t"
160  "lw %[temp_reg1], 16*4(%[csa]) \n\t"
161  "lw %[temp_reg2], 18*4(%[csa]) \n\t"
162  "add %[tmp2], %[tmp0], %[tmp1] \n\t"
163  "lw %[temp_reg3], 19*4(%[csa]) \n\t"
164  "mult $ac0, %[tmp2], %[temp_reg1] \n\t"
165  "mult $ac1, %[tmp2], %[temp_reg1] \n\t"
166  "sll %[temp_reg4], %[temp_reg4], 2 \n\t"
167  "sll %[temp_reg5], %[temp_reg5], 2 \n\t"
168  "sw %[temp_reg4], -4*4(%[ptr]) \n\t"
169  "mtlo %[MAX_lo], $ac0 \n\t"
170  "msub $ac0, %[tmp1], %[temp_reg2] \n\t"
171  "mtlo $zero, $ac1 \n\t"
172  "madd $ac1, %[tmp0], %[temp_reg3] \n\t"
173  "sw %[temp_reg5], 3*4(%[ptr]) \n\t"
174  "lw %[tmp00], -6*4(%[ptr]) \n\t"
175  "mfhi %[temp_reg1], $ac0 \n\t"
176  "lw %[tmp11], 5*4(%[ptr]) \n\t"
177  "mfhi %[temp_reg2], $ac1 \n\t"
178  "lw %[temp_reg4], 20*4(%[csa]) \n\t"
179  "add %[tmp2], %[tmp00], %[tmp11] \n\t"
180  "lw %[temp_reg5], 22*4(%[csa]) \n\t"
181  "mult $ac2, %[tmp2], %[temp_reg4] \n\t"
182  "mult $ac3, %[tmp2], %[temp_reg4] \n\t"
183  "lw %[temp_reg6], 23*4(%[csa]) \n\t"
184  "sll %[temp_reg1], %[temp_reg1], 2 \n\t"
185  "sll %[temp_reg2], %[temp_reg2], 2 \n\t"
186  "mtlo %[MAX_lo], $ac2 \n\t"
187  "msub $ac2, %[tmp11], %[temp_reg5] \n\t"
188  "mtlo $zero, $ac3 \n\t"
189  "madd $ac3, %[tmp00], %[temp_reg6] \n\t"
190  "sw %[temp_reg1], -5*4(%[ptr]) \n\t"
191  "sw %[temp_reg2], 4*4(%[ptr]) \n\t"
192  "mfhi %[temp_reg4], $ac2 \n\t"
193  "lw %[tmp0], -7*4(%[ptr]) \n\t"
194  "mfhi %[temp_reg5], $ac3 \n\t"
195  "lw %[tmp1], 6*4(%[ptr]) \n\t"
196  "lw %[temp_reg1], 24*4(%[csa]) \n\t"
197  "lw %[temp_reg2], 26*4(%[csa]) \n\t"
198  "add %[tmp2], %[tmp0], %[tmp1] \n\t"
199  "lw %[temp_reg3], 27*4(%[csa]) \n\t"
200  "mult $ac0, %[tmp2], %[temp_reg1] \n\t"
201  "mult $ac1, %[tmp2], %[temp_reg1] \n\t"
202  "sll %[temp_reg4], %[temp_reg4], 2 \n\t"
203  "sll %[temp_reg5], %[temp_reg5], 2 \n\t"
204  "sw %[temp_reg4], -6*4(%[ptr]) \n\t"
205  "mtlo %[MAX_lo], $ac0 \n\t"
206  "msub $ac0, %[tmp1], %[temp_reg2] \n\t"
207  "mtlo $zero, $ac1 \n\t"
208  "madd $ac1, %[tmp0], %[temp_reg3] \n\t"
209  "sw %[temp_reg5], 5*4(%[ptr]) \n\t"
210  "lw %[tmp00], -8*4(%[ptr]) \n\t"
211  "mfhi %[temp_reg1], $ac0 \n\t"
212  "lw %[tmp11], 7*4(%[ptr]) \n\t"
213  "mfhi %[temp_reg2], $ac1 \n\t"
214  "lw %[temp_reg4], 28*4(%[csa]) \n\t"
215  "add %[tmp2], %[tmp00], %[tmp11] \n\t"
216  "lw %[temp_reg5], 30*4(%[csa]) \n\t"
217  "mult $ac2, %[tmp2], %[temp_reg4] \n\t"
218  "mult $ac3, %[tmp2], %[temp_reg4] \n\t"
219  "lw %[temp_reg6], 31*4(%[csa]) \n\t"
220  "sll %[temp_reg1], %[temp_reg1], 2 \n\t"
221  "sll %[temp_reg2], %[temp_reg2], 2 \n\t"
222  "mtlo %[MAX_lo], $ac2 \n\t"
223  "msub $ac2, %[tmp11], %[temp_reg5] \n\t"
224  "mtlo $zero, $ac3 \n\t"
225  "madd $ac3, %[tmp00], %[temp_reg6] \n\t"
226  "sw %[temp_reg1], -7*4(%[ptr]) \n\t"
227  "sw %[temp_reg2], 6*4(%[ptr]) \n\t"
228  "mfhi %[temp_reg4], $ac2 \n\t"
229  "mfhi %[temp_reg5], $ac3 \n\t"
230  "sll %[temp_reg4], %[temp_reg4], 2 \n\t"
231  "sll %[temp_reg5], %[temp_reg5], 2 \n\t"
232  "sw %[temp_reg4], -8*4(%[ptr]) \n\t"
233  "sw %[temp_reg5], 7*4(%[ptr]) \n\t"
234 
235  : [tmp0] "=&r" (tmp0), [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2),
236  [tmp00] "=&r" (tmp00), [tmp11] "=&r" (tmp11),
237  [temp_reg1] "=&r" (temp_reg1), [temp_reg2] "=&r" (temp_reg2),
238  [temp_reg3] "=&r" (temp_reg3), [temp_reg4] "=&r" (temp_reg4),
239  [temp_reg5] "=&r" (temp_reg5), [temp_reg6] "=&r" (temp_reg6)
240  : [csa] "r" (csa), [ptr] "r" (ptr),
241  [MAX_lo] "r" (MAX_lo)
242  : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
243  "$ac3hi", "$ac3lo"
244  );
245 
246  ptr += 18;
247  }
248 }
249 #define compute_antialias compute_antialias_mips_fixed
250 #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
251 #endif /* HAVE_INLINE_ASM */
252 
253 #endif /* AVCODEC_MIPS_COMPUTE_ANTIALIAS_FIXED_H */
MPADecodeContext
Definition: mpegaudiodec_template.c:77
s
#define s(width, name)
Definition: cbs_vp9.c:198
g
const char * g
Definition: vf_curves.c:128
SBLIMIT
#define SBLIMIT
Definition: mpegaudio.h:44
GranuleDef
Definition: mpegaudiodec_template.c:58
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
__asm__
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
int32_t
int32_t
Definition: audioconvert.c:56
csa_table
static const int32_t csa_table[8][4]
Definition: mpegaudiodec_fixed.c:50