yading@10
|
1 /*
|
yading@10
|
2 * Copyright (c) 2012
|
yading@10
|
3 * MIPS Technologies, Inc., California.
|
yading@10
|
4 *
|
yading@10
|
5 * Redistribution and use in source and binary forms, with or without
|
yading@10
|
6 * modification, are permitted provided that the following conditions
|
yading@10
|
7 * are met:
|
yading@10
|
8 * 1. Redistributions of source code must retain the above copyright
|
yading@10
|
9 * notice, this list of conditions and the following disclaimer.
|
yading@10
|
10 * 2. Redistributions in binary form must reproduce the above copyright
|
yading@10
|
11 * notice, this list of conditions and the following disclaimer in the
|
yading@10
|
12 * documentation and/or other materials provided with the distribution.
|
yading@10
|
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
|
yading@10
|
14 * contributors may be used to endorse or promote products derived from
|
yading@10
|
15 * this software without specific prior written permission.
|
yading@10
|
16 *
|
yading@10
|
17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
|
yading@10
|
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
yading@10
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
yading@10
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
|
yading@10
|
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
yading@10
|
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
yading@10
|
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
yading@10
|
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
yading@10
|
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
yading@10
|
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
yading@10
|
27 * SUCH DAMAGE.
|
yading@10
|
28 *
|
yading@10
|
29 * Author: Bojan Zivkovic (bojan@mips.com)
|
yading@10
|
30 *
|
yading@10
|
31 * AAC encoder psychoacoustic model routines optimized
|
yading@10
|
32 * for MIPS floating-point architecture
|
yading@10
|
33 *
|
yading@10
|
34 * This file is part of FFmpeg.
|
yading@10
|
35 *
|
yading@10
|
36 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
37 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
38 * License as published by the Free Software Foundation; either
|
yading@10
|
39 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
40 *
|
yading@10
|
41 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
42 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
44 * Lesser General Public License for more details.
|
yading@10
|
45 *
|
yading@10
|
46 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
47 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
48 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
49 */
|
yading@10
|
50
|
yading@10
|
51 /**
|
yading@10
|
52 * @file
|
yading@10
|
53 * Reference: libavcodec/aacpsy.c
|
yading@10
|
54 */
|
yading@10
|
55
|
yading@10
|
56 #ifndef AVCODEC_MIPS_AACPSY_MIPS_H
|
yading@10
|
57 #define AVCODEC_MIPS_AACPSY_MIPS_H
|
yading@10
|
58
|
yading@10
|
59 #if HAVE_INLINE_ASM && HAVE_MIPSFPU && ( PSY_LAME_FIR_LEN == 21 )
|
yading@10
|
60 static void calc_thr_3gpp_mips(const FFPsyWindowInfo *wi, const int num_bands,
|
yading@10
|
61 AacPsyChannel *pch, const uint8_t *band_sizes,
|
yading@10
|
62 const float *coefs)
|
yading@10
|
63 {
|
yading@10
|
64 int i, w, g;
|
yading@10
|
65 int start = 0;
|
yading@10
|
66 for (w = 0; w < wi->num_windows*16; w += 16) {
|
yading@10
|
67 for (g = 0; g < num_bands; g++) {
|
yading@10
|
68 AacPsyBand *band = &pch->band[w+g];
|
yading@10
|
69
|
yading@10
|
70 float form_factor = 0.0f;
|
yading@10
|
71 float Temp;
|
yading@10
|
72 band->energy = 0.0f;
|
yading@10
|
73 for (i = 0; i < band_sizes[g]; i+=4) {
|
yading@10
|
74 float a, b, c, d;
|
yading@10
|
75 float ax, bx, cx, dx;
|
yading@10
|
76 float *cf = (float *)&coefs[start+i];
|
yading@10
|
77
|
yading@10
|
78 __asm__ volatile (
|
yading@10
|
79 "lwc1 %[a], 0(%[cf]) \n\t"
|
yading@10
|
80 "lwc1 %[b], 4(%[cf]) \n\t"
|
yading@10
|
81 "lwc1 %[c], 8(%[cf]) \n\t"
|
yading@10
|
82 "lwc1 %[d], 12(%[cf]) \n\t"
|
yading@10
|
83 "abs.s %[a], %[a] \n\t"
|
yading@10
|
84 "abs.s %[b], %[b] \n\t"
|
yading@10
|
85 "abs.s %[c], %[c] \n\t"
|
yading@10
|
86 "abs.s %[d], %[d] \n\t"
|
yading@10
|
87 "sqrt.s %[ax], %[a] \n\t"
|
yading@10
|
88 "sqrt.s %[bx], %[b] \n\t"
|
yading@10
|
89 "sqrt.s %[cx], %[c] \n\t"
|
yading@10
|
90 "sqrt.s %[dx], %[d] \n\t"
|
yading@10
|
91 "madd.s %[e], %[e], %[a], %[a] \n\t"
|
yading@10
|
92 "madd.s %[e], %[e], %[b], %[b] \n\t"
|
yading@10
|
93 "madd.s %[e], %[e], %[c], %[c] \n\t"
|
yading@10
|
94 "madd.s %[e], %[e], %[d], %[d] \n\t"
|
yading@10
|
95 "add.s %[f], %[f], %[ax] \n\t"
|
yading@10
|
96 "add.s %[f], %[f], %[bx] \n\t"
|
yading@10
|
97 "add.s %[f], %[f], %[cx] \n\t"
|
yading@10
|
98 "add.s %[f], %[f], %[dx] \n\t"
|
yading@10
|
99
|
yading@10
|
100 : [a]"=&f"(a), [b]"=&f"(b),
|
yading@10
|
101 [c]"=&f"(c), [d]"=&f"(d),
|
yading@10
|
102 [e]"+f"(band->energy), [f]"+f"(form_factor),
|
yading@10
|
103 [ax]"=&f"(ax), [bx]"=&f"(bx),
|
yading@10
|
104 [cx]"=&f"(cx), [dx]"=&f"(dx)
|
yading@10
|
105 : [cf]"r"(cf)
|
yading@10
|
106 : "memory"
|
yading@10
|
107 );
|
yading@10
|
108 }
|
yading@10
|
109
|
yading@10
|
110 Temp = sqrtf((float)band_sizes[g] / band->energy);
|
yading@10
|
111 band->thr = band->energy * 0.001258925f;
|
yading@10
|
112 band->nz_lines = form_factor * sqrtf(Temp);
|
yading@10
|
113 start += band_sizes[g];
|
yading@10
|
114 }
|
yading@10
|
115 }
|
yading@10
|
116 }
|
yading@10
|
117
|
yading@10
|
118 static void psy_hp_filter_mips(const float *firbuf, float *hpfsmpl, const float * psy_fir_coeffs)
|
yading@10
|
119 {
|
yading@10
|
120 float sum1, sum2, sum3, sum4;
|
yading@10
|
121 float *fb = (float*)firbuf;
|
yading@10
|
122 float *fb_end = fb + AAC_BLOCK_SIZE_LONG;
|
yading@10
|
123 float *hp = hpfsmpl;
|
yading@10
|
124
|
yading@10
|
125 float coeff0 = psy_fir_coeffs[1];
|
yading@10
|
126 float coeff1 = psy_fir_coeffs[3];
|
yading@10
|
127 float coeff2 = psy_fir_coeffs[5];
|
yading@10
|
128 float coeff3 = psy_fir_coeffs[7];
|
yading@10
|
129 float coeff4 = psy_fir_coeffs[9];
|
yading@10
|
130
|
yading@10
|
131 __asm__ volatile (
|
yading@10
|
132 ".set push \n\t"
|
yading@10
|
133 ".set noreorder \n\t"
|
yading@10
|
134
|
yading@10
|
135 "li.s $f12, 32768 \n\t"
|
yading@10
|
136 "1: \n\t"
|
yading@10
|
137 "lwc1 $f0, 40(%[fb]) \n\t"
|
yading@10
|
138 "lwc1 $f1, 4(%[fb]) \n\t"
|
yading@10
|
139 "lwc1 $f2, 80(%[fb]) \n\t"
|
yading@10
|
140 "lwc1 $f3, 44(%[fb]) \n\t"
|
yading@10
|
141 "lwc1 $f4, 8(%[fb]) \n\t"
|
yading@10
|
142 "madd.s %[sum1], $f0, $f1, %[coeff0] \n\t"
|
yading@10
|
143 "lwc1 $f5, 84(%[fb]) \n\t"
|
yading@10
|
144 "lwc1 $f6, 48(%[fb]) \n\t"
|
yading@10
|
145 "madd.s %[sum2], $f3, $f4, %[coeff0] \n\t"
|
yading@10
|
146 "lwc1 $f7, 12(%[fb]) \n\t"
|
yading@10
|
147 "madd.s %[sum1], %[sum1], $f2, %[coeff0] \n\t"
|
yading@10
|
148 "lwc1 $f8, 88(%[fb]) \n\t"
|
yading@10
|
149 "lwc1 $f9, 52(%[fb]) \n\t"
|
yading@10
|
150 "madd.s %[sum2], %[sum2], $f5, %[coeff0] \n\t"
|
yading@10
|
151 "madd.s %[sum3], $f6, $f7, %[coeff0] \n\t"
|
yading@10
|
152 "lwc1 $f10, 16(%[fb]) \n\t"
|
yading@10
|
153 "lwc1 $f11, 92(%[fb]) \n\t"
|
yading@10
|
154 "madd.s %[sum1], %[sum1], $f7, %[coeff1] \n\t"
|
yading@10
|
155 "lwc1 $f1, 72(%[fb]) \n\t"
|
yading@10
|
156 "madd.s %[sum3], %[sum3], $f8, %[coeff0] \n\t"
|
yading@10
|
157 "madd.s %[sum4], $f9, $f10, %[coeff0] \n\t"
|
yading@10
|
158 "madd.s %[sum2], %[sum2], $f10, %[coeff1] \n\t"
|
yading@10
|
159 "madd.s %[sum1], %[sum1], $f1, %[coeff1] \n\t"
|
yading@10
|
160 "lwc1 $f4, 76(%[fb]) \n\t"
|
yading@10
|
161 "lwc1 $f8, 20(%[fb]) \n\t"
|
yading@10
|
162 "madd.s %[sum4], %[sum4], $f11, %[coeff0] \n\t"
|
yading@10
|
163 "lwc1 $f11, 24(%[fb]) \n\t"
|
yading@10
|
164 "madd.s %[sum2], %[sum2], $f4, %[coeff1] \n\t"
|
yading@10
|
165 "madd.s %[sum1], %[sum1], $f8, %[coeff2] \n\t"
|
yading@10
|
166 "madd.s %[sum3], %[sum3], $f8, %[coeff1] \n\t"
|
yading@10
|
167 "madd.s %[sum4], %[sum4], $f11, %[coeff1] \n\t"
|
yading@10
|
168 "lwc1 $f7, 64(%[fb]) \n\t"
|
yading@10
|
169 "madd.s %[sum2], %[sum2], $f11, %[coeff2] \n\t"
|
yading@10
|
170 "lwc1 $f10, 68(%[fb]) \n\t"
|
yading@10
|
171 "madd.s %[sum3], %[sum3], $f2, %[coeff1] \n\t"
|
yading@10
|
172 "madd.s %[sum4], %[sum4], $f5, %[coeff1] \n\t"
|
yading@10
|
173 "madd.s %[sum1], %[sum1], $f7, %[coeff2] \n\t"
|
yading@10
|
174 "madd.s %[sum2], %[sum2], $f10, %[coeff2] \n\t"
|
yading@10
|
175 "lwc1 $f2, 28(%[fb]) \n\t"
|
yading@10
|
176 "lwc1 $f5, 32(%[fb]) \n\t"
|
yading@10
|
177 "lwc1 $f8, 56(%[fb]) \n\t"
|
yading@10
|
178 "lwc1 $f11, 60(%[fb]) \n\t"
|
yading@10
|
179 "madd.s %[sum3], %[sum3], $f2, %[coeff2] \n\t"
|
yading@10
|
180 "madd.s %[sum4], %[sum4], $f5, %[coeff2] \n\t"
|
yading@10
|
181 "madd.s %[sum1], %[sum1], $f2, %[coeff3] \n\t"
|
yading@10
|
182 "madd.s %[sum2], %[sum2], $f5, %[coeff3] \n\t"
|
yading@10
|
183 "madd.s %[sum3], %[sum3], $f1, %[coeff2] \n\t"
|
yading@10
|
184 "madd.s %[sum4], %[sum4], $f4, %[coeff2] \n\t"
|
yading@10
|
185 "madd.s %[sum1], %[sum1], $f8, %[coeff3] \n\t"
|
yading@10
|
186 "madd.s %[sum2], %[sum2], $f11, %[coeff3] \n\t"
|
yading@10
|
187 "lwc1 $f1, 36(%[fb]) \n\t"
|
yading@10
|
188 "addiu %[fb], %[fb], 16 \n\t"
|
yading@10
|
189 "madd.s %[sum4], %[sum4], $f0, %[coeff3] \n\t"
|
yading@10
|
190 "madd.s %[sum3], %[sum3], $f1, %[coeff3] \n\t"
|
yading@10
|
191 "madd.s %[sum1], %[sum1], $f1, %[coeff4] \n\t"
|
yading@10
|
192 "madd.s %[sum2], %[sum2], $f0, %[coeff4] \n\t"
|
yading@10
|
193 "madd.s %[sum4], %[sum4], $f10, %[coeff3] \n\t"
|
yading@10
|
194 "madd.s %[sum3], %[sum3], $f7, %[coeff3] \n\t"
|
yading@10
|
195 "madd.s %[sum1], %[sum1], $f6, %[coeff4] \n\t"
|
yading@10
|
196 "madd.s %[sum2], %[sum2], $f9, %[coeff4] \n\t"
|
yading@10
|
197 "madd.s %[sum4], %[sum4], $f6, %[coeff4] \n\t"
|
yading@10
|
198 "madd.s %[sum3], %[sum3], $f3, %[coeff4] \n\t"
|
yading@10
|
199 "mul.s %[sum1], %[sum1], $f12 \n\t"
|
yading@10
|
200 "mul.s %[sum2], %[sum2], $f12 \n\t"
|
yading@10
|
201 "madd.s %[sum4], %[sum4], $f11, %[coeff4] \n\t"
|
yading@10
|
202 "madd.s %[sum3], %[sum3], $f8, %[coeff4] \n\t"
|
yading@10
|
203 "swc1 %[sum1], 0(%[hp]) \n\t"
|
yading@10
|
204 "swc1 %[sum2], 4(%[hp]) \n\t"
|
yading@10
|
205 "mul.s %[sum4], %[sum4], $f12 \n\t"
|
yading@10
|
206 "mul.s %[sum3], %[sum3], $f12 \n\t"
|
yading@10
|
207 "swc1 %[sum4], 12(%[hp]) \n\t"
|
yading@10
|
208 "swc1 %[sum3], 8(%[hp]) \n\t"
|
yading@10
|
209 "bne %[fb], %[fb_end], 1b \n\t"
|
yading@10
|
210 " addiu %[hp], %[hp], 16 \n\t"
|
yading@10
|
211
|
yading@10
|
212 ".set pop \n\t"
|
yading@10
|
213
|
yading@10
|
214 : [sum1]"=&f"(sum1), [sum2]"=&f"(sum2),
|
yading@10
|
215 [sum3]"=&f"(sum3), [sum4]"=&f"(sum4),
|
yading@10
|
216 [fb]"+r"(fb), [hp]"+r"(hp)
|
yading@10
|
217 : [coeff0]"f"(coeff0), [coeff1]"f"(coeff1),
|
yading@10
|
218 [coeff2]"f"(coeff2), [coeff3]"f"(coeff3),
|
yading@10
|
219 [coeff4]"f"(coeff4), [fb_end]"r"(fb_end)
|
yading@10
|
220 : "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6",
|
yading@10
|
221 "$f7", "$f8", "$f9", "$f10", "$f11", "$f12",
|
yading@10
|
222 "memory"
|
yading@10
|
223 );
|
yading@10
|
224 }
|
yading@10
|
225
|
yading@10
|
226 #define calc_thr_3gpp calc_thr_3gpp_mips
|
yading@10
|
227 #define psy_hp_filter psy_hp_filter_mips
|
yading@10
|
228
|
yading@10
|
229 #endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */
|
yading@10
|
230 #endif /* AVCODEC_MIPS_AACPSY_MIPS_H */
|