Commit | Line | Data |
---|---|---|
2ba45a60 DM |
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 floating-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_FLOAT_H | |
56 | #define AVCODEC_MIPS_COMPUTE_ANTIALIAS_FLOAT_H | |
57 | ||
58 | #if HAVE_INLINE_ASM | |
59 | static void compute_antialias_mips_float(MPADecodeContext *s, | |
60 | GranuleDef *g) | |
61 | { | |
62 | float *ptr, *ptr_end; | |
63 | float *csa = &csa_table[0][0]; | |
64 | /* temporary variables */ | |
65 | float in1, in2, in3, in4, in5, in6, in7, in8; | |
66 | float out1, out2, out3, out4; | |
67 | ||
68 | ptr = g->sb_hybrid + 18; | |
69 | /* we antialias only "long" bands */ | |
70 | if (g->block_type == 2) { | |
71 | if (!g->switch_point) | |
72 | return; | |
73 | /* XXX: check this for 8000Hz case */ | |
74 | ptr_end = ptr + 18; | |
75 | } else { | |
76 | ptr_end = ptr + 558; | |
77 | } | |
78 | ||
79 | /** | |
80 | * instructions are scheduled to minimize pipeline stall. | |
81 | */ | |
82 | ||
83 | __asm__ volatile ( | |
84 | "compute_antialias_float_loop%=: \t\n" | |
85 | "lwc1 %[in1], -1*4(%[ptr]) \t\n" | |
86 | "lwc1 %[in2], 0(%[csa]) \t\n" | |
87 | "lwc1 %[in3], 1*4(%[csa]) \t\n" | |
88 | "lwc1 %[in4], 0(%[ptr]) \t\n" | |
89 | "lwc1 %[in5], -2*4(%[ptr]) \t\n" | |
90 | "lwc1 %[in6], 4*4(%[csa]) \t\n" | |
91 | "mul.s %[out1], %[in1], %[in2] \t\n" | |
92 | "mul.s %[out2], %[in1], %[in3] \t\n" | |
93 | "lwc1 %[in7], 5*4(%[csa]) \t\n" | |
94 | "lwc1 %[in8], 1*4(%[ptr]) \t\n" | |
95 | "nmsub.s %[out1], %[out1], %[in3], %[in4] \t\n" | |
96 | "madd.s %[out2], %[out2], %[in2], %[in4] \t\n" | |
97 | "mul.s %[out3], %[in5], %[in6] \t\n" | |
98 | "mul.s %[out4], %[in5], %[in7] \t\n" | |
99 | "lwc1 %[in1], -3*4(%[ptr]) \t\n" | |
100 | "swc1 %[out1], -1*4(%[ptr]) \t\n" | |
101 | "swc1 %[out2], 0(%[ptr]) \t\n" | |
102 | "nmsub.s %[out3], %[out3], %[in7], %[in8] \t\n" | |
103 | "madd.s %[out4], %[out4], %[in6], %[in8] \t\n" | |
104 | "lwc1 %[in2], 8*4(%[csa]) \t\n" | |
105 | "swc1 %[out3], -2*4(%[ptr]) \t\n" | |
106 | "swc1 %[out4], 1*4(%[ptr]) \t\n" | |
107 | "lwc1 %[in3], 9*4(%[csa]) \t\n" | |
108 | "lwc1 %[in4], 2*4(%[ptr]) \t\n" | |
109 | "mul.s %[out1], %[in1], %[in2] \t\n" | |
110 | "lwc1 %[in5], -4*4(%[ptr]) \t\n" | |
111 | "lwc1 %[in6], 12*4(%[csa]) \t\n" | |
112 | "mul.s %[out2], %[in1], %[in3] \t\n" | |
113 | "lwc1 %[in7], 13*4(%[csa]) \t\n" | |
114 | "nmsub.s %[out1], %[out1], %[in3], %[in4] \t\n" | |
115 | "lwc1 %[in8], 3*4(%[ptr]) \t\n" | |
116 | "mul.s %[out3], %[in5], %[in6] \t\n" | |
117 | "madd.s %[out2], %[out2], %[in2], %[in4] \t\n" | |
118 | "mul.s %[out4], %[in5], %[in7] \t\n" | |
119 | "swc1 %[out1], -3*4(%[ptr]) \t\n" | |
120 | "lwc1 %[in1], -5*4(%[ptr]) \t\n" | |
121 | "nmsub.s %[out3], %[out3], %[in7], %[in8] \t\n" | |
122 | "swc1 %[out2], 2*4(%[ptr]) \t\n" | |
123 | "madd.s %[out4], %[out4], %[in6], %[in8] \t\n" | |
124 | "lwc1 %[in2], 16*4(%[csa]) \t\n" | |
125 | "lwc1 %[in3], 17*4(%[csa]) \t\n" | |
126 | "swc1 %[out3], -4*4(%[ptr]) \t\n" | |
127 | "lwc1 %[in4], 4*4(%[ptr]) \t\n" | |
128 | "swc1 %[out4], 3*4(%[ptr]) \t\n" | |
129 | "mul.s %[out1], %[in1], %[in2] \t\n" | |
130 | "mul.s %[out2], %[in1], %[in3] \t\n" | |
131 | "lwc1 %[in5], -6*4(%[ptr]) \t\n" | |
132 | "lwc1 %[in6], 20*4(%[csa]) \t\n" | |
133 | "lwc1 %[in7], 21*4(%[csa]) \t\n" | |
134 | "nmsub.s %[out1], %[out1], %[in3], %[in4] \t\n" | |
135 | "madd.s %[out2], %[out2], %[in2], %[in4] \t\n" | |
136 | "lwc1 %[in8], 5*4(%[ptr]) \t\n" | |
137 | "mul.s %[out3], %[in5], %[in6] \t\n" | |
138 | "mul.s %[out4], %[in5], %[in7] \t\n" | |
139 | "swc1 %[out1], -5*4(%[ptr]) \t\n" | |
140 | "swc1 %[out2], 4*4(%[ptr]) \t\n" | |
141 | "lwc1 %[in1], -7*4(%[ptr]) \t\n" | |
142 | "nmsub.s %[out3], %[out3], %[in7], %[in8] \t\n" | |
143 | "madd.s %[out4], %[out4], %[in6], %[in8] \t\n" | |
144 | "lwc1 %[in2], 24*4(%[csa]) \t\n" | |
145 | "lwc1 %[in3], 25*4(%[csa]) \t\n" | |
146 | "lwc1 %[in4], 6*4(%[ptr]) \t\n" | |
147 | "swc1 %[out3], -6*4(%[ptr]) \t\n" | |
148 | "swc1 %[out4], 5*4(%[ptr]) \t\n" | |
149 | "mul.s %[out1], %[in1], %[in2] \t\n" | |
150 | "lwc1 %[in5], -8*4(%[ptr]) \t\n" | |
151 | "mul.s %[out2], %[in1], %[in3] \t\n" | |
152 | "lwc1 %[in6], 28*4(%[csa]) \t\n" | |
153 | "lwc1 %[in7], 29*4(%[csa]) \t\n" | |
154 | "nmsub.s %[out1], %[out1], %[in3], %[in4] \t\n" | |
155 | "lwc1 %[in8], 7*4(%[ptr]) \t\n" | |
156 | "madd.s %[out2], %[out2], %[in2], %[in4] \t\n" | |
157 | "mul.s %[out3], %[in5], %[in6] \t\n" | |
158 | "mul.s %[out4], %[in5], %[in7] \t\n" | |
159 | "swc1 %[out1], -7*4(%[ptr]) \t\n" | |
160 | "swc1 %[out2], 6*4(%[ptr]) \t\n" | |
161 | "addiu %[ptr], %[ptr], 72 \t\n" | |
162 | "nmsub.s %[out3], %[out3], %[in7], %[in8] \t\n" | |
163 | "madd.s %[out4], %[out4], %[in6], %[in8] \t\n" | |
164 | "swc1 %[out3], -26*4(%[ptr]) \t\n" | |
165 | "swc1 %[out4], -11*4(%[ptr]) \t\n" | |
166 | "bne %[ptr], %[ptr_end], compute_antialias_float_loop%= \t\n" | |
167 | ||
168 | : [ptr] "+r" (ptr), | |
169 | [in1] "=&f" (in1), [in2] "=&f" (in2), | |
170 | [in3] "=&f" (in3), [in4] "=&f" (in4), | |
171 | [in5] "=&f" (in5), [in6] "=&f" (in6), | |
172 | [in7] "=&f" (in7), [in8] "=&f" (in8), | |
173 | [out1] "=&f" (out1), [out2] "=&f" (out2), | |
174 | [out3] "=&f" (out3), [out4] "=&f" (out4) | |
175 | : [csa] "r" (csa), [ptr_end] "r" (ptr_end) | |
176 | : "memory" | |
177 | ); | |
178 | } | |
179 | #define compute_antialias compute_antialias_mips_float | |
180 | #endif /* HAVE_INLINE_ASM */ | |
181 | ||
182 | #endif /* AVCODEC_MIPS_COMPUTE_ANTIALIAS_FLOAT_H */ |