You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

619 lines
26KB

  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: Djordje Pesut (djordje@mips.com)
  30. * Mirjana Vulin (mvulin@mips.com)
  31. *
  32. * This file is part of FFmpeg.
  33. *
  34. * FFmpeg is free software; you can redistribute it and/or
  35. * modify it under the terms of the GNU Lesser General Public
  36. * License as published by the Free Software Foundation; either
  37. * version 2.1 of the License, or (at your option) any later version.
  38. *
  39. * FFmpeg is distributed in the hope that it will be useful,
  40. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  42. * Lesser General Public License for more details.
  43. *
  44. * You should have received a copy of the GNU Lesser General Public
  45. * License along with FFmpeg; if not, write to the Free Software
  46. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  47. */
  48. /**
  49. * @file
  50. * Reference: libavcodec/aacsbr.c
  51. */
  52. #include "libavcodec/aac.h"
  53. #include "libavcodec/aacsbr.h"
  54. #define ENVELOPE_ADJUSTMENT_OFFSET 2
  55. #if HAVE_INLINE_ASM
  56. static int sbr_lf_gen_mips(AACContext *ac, SpectralBandReplication *sbr,
  57. float X_low[32][40][2], const float W[2][32][32][2],
  58. int buf_idx)
  59. {
  60. int i, k;
  61. int temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
  62. float *p_x_low = &X_low[0][8][0];
  63. float *p_w = (float*)&W[buf_idx][0][0][0];
  64. float *p_x1_low = &X_low[0][0][0];
  65. float *p_w1 = (float*)&W[1-buf_idx][24][0][0];
  66. float *loop_end=p_x1_low + 2560;
  67. /* loop unrolled 8 times */
  68. __asm__ volatile (
  69. "1: \n\t"
  70. "sw $0, 0(%[p_x1_low]) \n\t"
  71. "sw $0, 4(%[p_x1_low]) \n\t"
  72. "sw $0, 8(%[p_x1_low]) \n\t"
  73. "sw $0, 12(%[p_x1_low]) \n\t"
  74. "sw $0, 16(%[p_x1_low]) \n\t"
  75. "sw $0, 20(%[p_x1_low]) \n\t"
  76. "sw $0, 24(%[p_x1_low]) \n\t"
  77. "sw $0, 28(%[p_x1_low]) \n\t"
  78. "addiu %[p_x1_low], %[p_x1_low], 32 \n\t"
  79. "bne %[p_x1_low], %[loop_end], 1b \n\t"
  80. "addiu %[p_x1_low], %[p_x1_low], -10240 \n\t"
  81. : [p_x1_low]"+r"(p_x1_low)
  82. : [loop_end]"r"(loop_end)
  83. : "memory"
  84. );
  85. for (k = 0; k < sbr->kx[1]; k++) {
  86. for (i = 0; i < 32; i+=4) {
  87. /* loop unrolled 4 times */
  88. __asm__ volatile (
  89. "lw %[temp0], 0(%[p_w]) \n\t"
  90. "lw %[temp1], 4(%[p_w]) \n\t"
  91. "lw %[temp2], 256(%[p_w]) \n\t"
  92. "lw %[temp3], 260(%[p_w]) \n\t"
  93. "lw %[temp4], 512(%[p_w]) \n\t"
  94. "lw %[temp5], 516(%[p_w]) \n\t"
  95. "lw %[temp6], 768(%[p_w]) \n\t"
  96. "lw %[temp7], 772(%[p_w]) \n\t"
  97. "sw %[temp0], 0(%[p_x_low]) \n\t"
  98. "sw %[temp1], 4(%[p_x_low]) \n\t"
  99. "sw %[temp2], 8(%[p_x_low]) \n\t"
  100. "sw %[temp3], 12(%[p_x_low]) \n\t"
  101. "sw %[temp4], 16(%[p_x_low]) \n\t"
  102. "sw %[temp5], 20(%[p_x_low]) \n\t"
  103. "sw %[temp6], 24(%[p_x_low]) \n\t"
  104. "sw %[temp7], 28(%[p_x_low]) \n\t"
  105. "addiu %[p_x_low], %[p_x_low], 32 \n\t"
  106. "addiu %[p_w], %[p_w], 1024 \n\t"
  107. : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
  108. [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
  109. [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
  110. [temp6]"=&r"(temp6), [temp7]"=&r"(temp7),
  111. [p_w]"+r"(p_w), [p_x_low]"+r"(p_x_low)
  112. :
  113. : "memory"
  114. );
  115. }
  116. p_x_low += 16;
  117. p_w -= 2046;
  118. }
  119. for (k = 0; k < sbr->kx[0]; k++) {
  120. for (i = 0; i < 2; i++) {
  121. /* loop unrolled 4 times */
  122. __asm__ volatile (
  123. "lw %[temp0], 0(%[p_w1]) \n\t"
  124. "lw %[temp1], 4(%[p_w1]) \n\t"
  125. "lw %[temp2], 256(%[p_w1]) \n\t"
  126. "lw %[temp3], 260(%[p_w1]) \n\t"
  127. "lw %[temp4], 512(%[p_w1]) \n\t"
  128. "lw %[temp5], 516(%[p_w1]) \n\t"
  129. "lw %[temp6], 768(%[p_w1]) \n\t"
  130. "lw %[temp7], 772(%[p_w1]) \n\t"
  131. "sw %[temp0], 0(%[p_x1_low]) \n\t"
  132. "sw %[temp1], 4(%[p_x1_low]) \n\t"
  133. "sw %[temp2], 8(%[p_x1_low]) \n\t"
  134. "sw %[temp3], 12(%[p_x1_low]) \n\t"
  135. "sw %[temp4], 16(%[p_x1_low]) \n\t"
  136. "sw %[temp5], 20(%[p_x1_low]) \n\t"
  137. "sw %[temp6], 24(%[p_x1_low]) \n\t"
  138. "sw %[temp7], 28(%[p_x1_low]) \n\t"
  139. "addiu %[p_x1_low], %[p_x1_low], 32 \n\t"
  140. "addiu %[p_w1], %[p_w1], 1024 \n\t"
  141. : [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
  142. [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
  143. [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
  144. [temp6]"=&r"(temp6), [temp7]"=&r"(temp7),
  145. [p_w1]"+r"(p_w1), [p_x1_low]"+r"(p_x1_low)
  146. :
  147. : "memory"
  148. );
  149. }
  150. p_x1_low += 64;
  151. p_w1 -= 510;
  152. }
  153. return 0;
  154. }
  155. static int sbr_x_gen_mips(SpectralBandReplication *sbr, float X[2][38][64],
  156. const float Y0[38][64][2], const float Y1[38][64][2],
  157. const float X_low[32][40][2], int ch)
  158. {
  159. int k, i;
  160. const int i_f = 32;
  161. int temp0, temp1, temp2, temp3;
  162. const float *X_low1, *Y01, *Y11;
  163. float *x1=&X[0][0][0];
  164. float *j=x1+4864;
  165. const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0);
  166. /* loop unrolled 8 times */
  167. __asm__ volatile (
  168. "1: \n\t"
  169. "sw $0, 0(%[x1]) \n\t"
  170. "sw $0, 4(%[x1]) \n\t"
  171. "sw $0, 8(%[x1]) \n\t"
  172. "sw $0, 12(%[x1]) \n\t"
  173. "sw $0, 16(%[x1]) \n\t"
  174. "sw $0, 20(%[x1]) \n\t"
  175. "sw $0, 24(%[x1]) \n\t"
  176. "sw $0, 28(%[x1]) \n\t"
  177. "addiu %[x1], %[x1], 32 \n\t"
  178. "bne %[x1], %[j], 1b \n\t"
  179. "addiu %[x1], %[x1], -19456 \n\t"
  180. : [x1]"+r"(x1)
  181. : [j]"r"(j)
  182. : "memory"
  183. );
  184. if (i_Temp != 0) {
  185. X_low1=&X_low[0][2][0];
  186. for (k = 0; k < sbr->kx[0]; k++) {
  187. __asm__ volatile (
  188. "move %[i], $zero \n\t"
  189. "2: \n\t"
  190. "lw %[temp0], 0(%[X_low1]) \n\t"
  191. "lw %[temp1], 4(%[X_low1]) \n\t"
  192. "sw %[temp0], 0(%[x1]) \n\t"
  193. "sw %[temp1], 9728(%[x1]) \n\t"
  194. "addiu %[x1], %[x1], 256 \n\t"
  195. "addiu %[X_low1], %[X_low1], 8 \n\t"
  196. "addiu %[i], %[i], 1 \n\t"
  197. "bne %[i], %[i_Temp], 2b \n\t"
  198. : [x1]"+r"(x1), [X_low1]"+r"(X_low1), [i]"=&r"(i),
  199. [temp0]"=&r"(temp0), [temp1]"=&r"(temp1)
  200. : [i_Temp]"r"(i_Temp)
  201. : "memory"
  202. );
  203. x1-=(i_Temp<<6)-1;
  204. X_low1-=(i_Temp<<1)-80;
  205. }
  206. x1=&X[0][0][k];
  207. Y01=(float*)&Y0[32][k][0];
  208. for (; k < sbr->kx[0] + sbr->m[0]; k++) {
  209. __asm__ volatile (
  210. "move %[i], $zero \n\t"
  211. "3: \n\t"
  212. "lw %[temp0], 0(%[Y01]) \n\t"
  213. "lw %[temp1], 4(%[Y01]) \n\t"
  214. "sw %[temp0], 0(%[x1]) \n\t"
  215. "sw %[temp1], 9728(%[x1]) \n\t"
  216. "addiu %[x1], %[x1], 256 \n\t"
  217. "addiu %[Y01], %[Y01], 512 \n\t"
  218. "addiu %[i], %[i], 1 \n\t"
  219. "bne %[i], %[i_Temp], 3b \n\t"
  220. : [x1]"+r"(x1), [Y01]"+r"(Y01), [i]"=&r"(i),
  221. [temp0]"=&r"(temp0), [temp1]"=&r"(temp1)
  222. : [i_Temp]"r"(i_Temp)
  223. : "memory"
  224. );
  225. x1 -=(i_Temp<<6)-1;
  226. Y01 -=(i_Temp<<7)-2;
  227. }
  228. }
  229. x1=&X[0][i_Temp][0];
  230. X_low1=&X_low[0][i_Temp+2][0];
  231. temp3=38;
  232. for (k = 0; k < sbr->kx[1]; k++) {
  233. __asm__ volatile (
  234. "move %[i], %[i_Temp] \n\t"
  235. "4: \n\t"
  236. "lw %[temp0], 0(%[X_low1]) \n\t"
  237. "lw %[temp1], 4(%[X_low1]) \n\t"
  238. "sw %[temp0], 0(%[x1]) \n\t"
  239. "sw %[temp1], 9728(%[x1]) \n\t"
  240. "addiu %[x1], %[x1], 256 \n\t"
  241. "addiu %[X_low1], %[X_low1], 8 \n\t"
  242. "addiu %[i], %[i], 1 \n\t"
  243. "bne %[i], %[temp3], 4b \n\t"
  244. : [x1]"+r"(x1), [X_low1]"+r"(X_low1), [i]"=&r"(i),
  245. [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
  246. [temp2]"=&r"(temp2)
  247. : [i_Temp]"r"(i_Temp), [temp3]"r"(temp3)
  248. : "memory"
  249. );
  250. x1 -= ((38-i_Temp)<<6)-1;
  251. X_low1 -= ((38-i_Temp)<<1)- 80;
  252. }
  253. x1=&X[0][i_Temp][k];
  254. Y11=&Y1[i_Temp][k][0];
  255. temp2=32;
  256. for (; k < sbr->kx[1] + sbr->m[1]; k++) {
  257. __asm__ volatile (
  258. "move %[i], %[i_Temp] \n\t"
  259. "5: \n\t"
  260. "lw %[temp0], 0(%[Y11]) \n\t"
  261. "lw %[temp1], 4(%[Y11]) \n\t"
  262. "sw %[temp0], 0(%[x1]) \n\t"
  263. "sw %[temp1], 9728(%[x1]) \n\t"
  264. "addiu %[x1], %[x1], 256 \n\t"
  265. "addiu %[Y11], %[Y11], 512 \n\t"
  266. "addiu %[i], %[i], 1 \n\t"
  267. "bne %[i], %[temp2], 5b \n\t"
  268. : [x1]"+r"(x1), [Y11]"+r"(Y11), [i]"=&r"(i),
  269. [temp0]"=&r"(temp0), [temp1]"=&r"(temp1)
  270. : [i_Temp]"r"(i_Temp), [temp3]"r"(temp3),
  271. [temp2]"r"(temp2)
  272. : "memory"
  273. );
  274. x1 -= ((32-i_Temp)<<6)-1;
  275. Y11 -= ((32-i_Temp)<<7)-2;
  276. }
  277. return 0;
  278. }
  279. #if HAVE_MIPSFPU
  280. static void sbr_hf_assemble_mips(float Y1[38][64][2],
  281. const float X_high[64][40][2],
  282. SpectralBandReplication *sbr, SBRData *ch_data,
  283. const int e_a[2])
  284. {
  285. int e, i, j, m;
  286. const int h_SL = 4 * !sbr->bs_smoothing_mode;
  287. const int kx = sbr->kx[1];
  288. const int m_max = sbr->m[1];
  289. static const float h_smooth[5] = {
  290. 0.33333333333333,
  291. 0.30150283239582,
  292. 0.21816949906249,
  293. 0.11516383427084,
  294. 0.03183050093751,
  295. };
  296. float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp;
  297. int indexnoise = ch_data->f_indexnoise;
  298. int indexsine = ch_data->f_indexsine;
  299. float *g_temp1, *q_temp1, *pok, *pok1;
  300. float temp1, temp2, temp3, temp4;
  301. int size = m_max;
  302. if (sbr->reset) {
  303. for (i = 0; i < h_SL; i++) {
  304. memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0]));
  305. memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0]));
  306. }
  307. } else if (h_SL) {
  308. memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0]));
  309. memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
  310. }
  311. for (e = 0; e < ch_data->bs_num_env; e++) {
  312. for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
  313. g_temp1 = g_temp[h_SL + i];
  314. pok = sbr->gain[e];
  315. q_temp1 = q_temp[h_SL + i];
  316. pok1 = sbr->q_m[e];
  317. /* loop unrolled 4 times */
  318. for (j=0; j<(size>>2); j++) {
  319. __asm__ volatile (
  320. "lw %[temp1], 0(%[pok]) \n\t"
  321. "lw %[temp2], 4(%[pok]) \n\t"
  322. "lw %[temp3], 8(%[pok]) \n\t"
  323. "lw %[temp4], 12(%[pok]) \n\t"
  324. "sw %[temp1], 0(%[g_temp1]) \n\t"
  325. "sw %[temp2], 4(%[g_temp1]) \n\t"
  326. "sw %[temp3], 8(%[g_temp1]) \n\t"
  327. "sw %[temp4], 12(%[g_temp1]) \n\t"
  328. "lw %[temp1], 0(%[pok1]) \n\t"
  329. "lw %[temp2], 4(%[pok1]) \n\t"
  330. "lw %[temp3], 8(%[pok1]) \n\t"
  331. "lw %[temp4], 12(%[pok1]) \n\t"
  332. "sw %[temp1], 0(%[q_temp1]) \n\t"
  333. "sw %[temp2], 4(%[q_temp1]) \n\t"
  334. "sw %[temp3], 8(%[q_temp1]) \n\t"
  335. "sw %[temp4], 12(%[q_temp1]) \n\t"
  336. "addiu %[pok], %[pok], 16 \n\t"
  337. "addiu %[g_temp1], %[g_temp1], 16 \n\t"
  338. "addiu %[pok1], %[pok1], 16 \n\t"
  339. "addiu %[q_temp1], %[q_temp1], 16 \n\t"
  340. : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
  341. [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
  342. [pok]"+r"(pok), [g_temp1]"+r"(g_temp1),
  343. [pok1]"+r"(pok1), [q_temp1]"+r"(q_temp1)
  344. :
  345. : "memory"
  346. );
  347. }
  348. for (j=0; j<(size&3); j++) {
  349. __asm__ volatile (
  350. "lw %[temp1], 0(%[pok]) \n\t"
  351. "lw %[temp2], 0(%[pok1]) \n\t"
  352. "sw %[temp1], 0(%[g_temp1]) \n\t"
  353. "sw %[temp2], 0(%[q_temp1]) \n\t"
  354. "addiu %[pok], %[pok], 4 \n\t"
  355. "addiu %[g_temp1], %[g_temp1], 4 \n\t"
  356. "addiu %[pok1], %[pok1], 4 \n\t"
  357. "addiu %[q_temp1], %[q_temp1], 4 \n\t"
  358. : [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
  359. [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
  360. [pok]"+r"(pok), [g_temp1]"+r"(g_temp1),
  361. [pok1]"+r"(pok1), [q_temp1]"+r"(q_temp1)
  362. :
  363. : "memory"
  364. );
  365. }
  366. }
  367. }
  368. for (e = 0; e < ch_data->bs_num_env; e++) {
  369. for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
  370. LOCAL_ALIGNED_16(float, g_filt_tab, [48]);
  371. LOCAL_ALIGNED_16(float, q_filt_tab, [48]);
  372. float *g_filt, *q_filt;
  373. if (h_SL && e != e_a[0] && e != e_a[1]) {
  374. g_filt = g_filt_tab;
  375. q_filt = q_filt_tab;
  376. for (m = 0; m < m_max; m++) {
  377. const int idx1 = i + h_SL;
  378. g_filt[m] = 0.0f;
  379. q_filt[m] = 0.0f;
  380. for (j = 0; j <= h_SL; j++) {
  381. g_filt[m] += g_temp[idx1 - j][m] * h_smooth[j];
  382. q_filt[m] += q_temp[idx1 - j][m] * h_smooth[j];
  383. }
  384. }
  385. } else {
  386. g_filt = g_temp[i + h_SL];
  387. q_filt = q_temp[i];
  388. }
  389. sbr->dsp.hf_g_filt(Y1[i] + kx, X_high + kx, g_filt, m_max,
  390. i + ENVELOPE_ADJUSTMENT_OFFSET);
  391. if (e != e_a[0] && e != e_a[1]) {
  392. sbr->dsp.hf_apply_noise[indexsine](Y1[i] + kx, sbr->s_m[e],
  393. q_filt, indexnoise,
  394. kx, m_max);
  395. } else {
  396. int idx = indexsine&1;
  397. int A = (1-((indexsine+(kx & 1))&2));
  398. int B = (A^(-idx)) + idx;
  399. float *out = &Y1[i][kx][idx];
  400. float *in = sbr->s_m[e];
  401. float temp0, temp1, temp2, temp3, temp4, temp5;
  402. float A_f = (float)A;
  403. float B_f = (float)B;
  404. for (m = 0; m+1 < m_max; m+=2) {
  405. temp2 = out[0];
  406. temp3 = out[2];
  407. __asm__ volatile(
  408. "lwc1 %[temp0], 0(%[in]) \n\t"
  409. "lwc1 %[temp1], 4(%[in]) \n\t"
  410. "madd.s %[temp4], %[temp2], %[temp0], %[A_f] \n\t"
  411. "madd.s %[temp5], %[temp3], %[temp1], %[B_f] \n\t"
  412. "swc1 %[temp4], 0(%[out]) \n\t"
  413. "swc1 %[temp5], 8(%[out]) \n\t"
  414. "addiu %[in], %[in], 8 \n\t"
  415. "addiu %[out], %[out], 16 \n\t"
  416. : [temp0]"=&f" (temp0), [temp1]"=&f"(temp1),
  417. [temp4]"=&f" (temp4), [temp5]"=&f"(temp5),
  418. [in]"+r"(in), [out]"+r"(out)
  419. : [A_f]"f"(A_f), [B_f]"f"(B_f), [temp2]"f"(temp2),
  420. [temp3]"f"(temp3)
  421. : "memory"
  422. );
  423. }
  424. if(m_max&1)
  425. out[2*m ] += in[m ] * A;
  426. }
  427. indexnoise = (indexnoise + m_max) & 0x1ff;
  428. indexsine = (indexsine + 1) & 3;
  429. }
  430. }
  431. ch_data->f_indexnoise = indexnoise;
  432. ch_data->f_indexsine = indexsine;
  433. }
  434. static void sbr_hf_inverse_filter_mips(SBRDSPContext *dsp,
  435. float (*alpha0)[2], float (*alpha1)[2],
  436. const float X_low[32][40][2], int k0)
  437. {
  438. int k;
  439. float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, c;
  440. float *phi1, *alpha_1, *alpha_0, res1, res2, temp_real, temp_im;;
  441. c = 1.000001f;
  442. for (k = 0; k < k0; k++) {
  443. LOCAL_ALIGNED_16(float, phi, [3], [2][2]);
  444. float dk;
  445. phi1 = &phi[0][0][0];
  446. alpha_1 = &alpha1[k][0];
  447. alpha_0 = &alpha0[k][0];
  448. dsp->autocorrelate(X_low[k], phi);
  449. __asm__ volatile (
  450. "lwc1 %[temp0], 40(%[phi1]) \n\t"
  451. "lwc1 %[temp1], 16(%[phi1]) \n\t"
  452. "lwc1 %[temp2], 24(%[phi1]) \n\t"
  453. "lwc1 %[temp3], 28(%[phi1]) \n\t"
  454. "mul.s %[dk], %[temp0], %[temp1] \n\t"
  455. "lwc1 %[temp4], 0(%[phi1]) \n\t"
  456. "mul.s %[res2], %[temp2], %[temp2] \n\t"
  457. "lwc1 %[temp5], 4(%[phi1]) \n\t"
  458. "madd.s %[res2], %[res2], %[temp3], %[temp3] \n\t"
  459. "lwc1 %[temp6], 8(%[phi1]) \n\t"
  460. "div.s %[res2], %[res2], %[c] \n\t"
  461. "lwc1 %[temp0], 12(%[phi1]) \n\t"
  462. "sub.s %[dk], %[dk], %[res2] \n\t"
  463. : [temp0]"=&f"(temp0), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
  464. [temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
  465. [temp6]"=&f"(temp6), [res2]"=&f"(res2), [dk]"=&f"(dk)
  466. : [phi1]"r"(phi1), [c]"f"(c)
  467. : "memory"
  468. );
  469. if (!dk) {
  470. alpha_1[0] = 0;
  471. alpha_1[1] = 0;
  472. } else {
  473. __asm__ volatile (
  474. "mul.s %[temp_real], %[temp4], %[temp2] \n\t"
  475. "nmsub.s %[temp_real], %[temp_real], %[temp5], %[temp3] \n\t"
  476. "nmsub.s %[temp_real], %[temp_real], %[temp6], %[temp1] \n\t"
  477. "mul.s %[temp_im], %[temp4], %[temp3] \n\t"
  478. "madd.s %[temp_im], %[temp_im], %[temp5], %[temp2] \n\t"
  479. "nmsub.s %[temp_im], %[temp_im], %[temp0], %[temp1] \n\t"
  480. "div.s %[temp_real], %[temp_real], %[dk] \n\t"
  481. "div.s %[temp_im], %[temp_im], %[dk] \n\t"
  482. "swc1 %[temp_real], 0(%[alpha_1]) \n\t"
  483. "swc1 %[temp_im], 4(%[alpha_1]) \n\t"
  484. : [temp_real]"=&f" (temp_real), [temp_im]"=&f"(temp_im)
  485. : [phi1]"r"(phi1), [temp0]"f"(temp0), [temp1]"f"(temp1),
  486. [temp2]"f"(temp2), [temp3]"f"(temp3), [temp4]"f"(temp4),
  487. [temp5]"f"(temp5), [temp6]"f"(temp6),
  488. [alpha_1]"r"(alpha_1), [dk]"f"(dk)
  489. : "memory"
  490. );
  491. }
  492. if (!phi1[4]) {
  493. alpha_0[0] = 0;
  494. alpha_0[1] = 0;
  495. } else {
  496. __asm__ volatile (
  497. "lwc1 %[temp6], 0(%[alpha_1]) \n\t"
  498. "lwc1 %[temp7], 4(%[alpha_1]) \n\t"
  499. "mul.s %[temp_real], %[temp6], %[temp2] \n\t"
  500. "add.s %[temp_real], %[temp_real], %[temp4] \n\t"
  501. "madd.s %[temp_real], %[temp_real], %[temp7], %[temp3] \n\t"
  502. "mul.s %[temp_im], %[temp7], %[temp2] \n\t"
  503. "add.s %[temp_im], %[temp_im], %[temp5] \n\t"
  504. "nmsub.s %[temp_im], %[temp_im], %[temp6], %[temp3] \n\t"
  505. "div.s %[temp_real], %[temp_real], %[temp1] \n\t"
  506. "div.s %[temp_im], %[temp_im], %[temp1] \n\t"
  507. "neg.s %[temp_real], %[temp_real] \n\t"
  508. "neg.s %[temp_im], %[temp_im] \n\t"
  509. "swc1 %[temp_real], 0(%[alpha_0]) \n\t"
  510. "swc1 %[temp_im], 4(%[alpha_0]) \n\t"
  511. : [temp_real]"=&f"(temp_real), [temp_im]"=&f"(temp_im),
  512. [temp6]"=&f"(temp6), [temp7]"=&f"(temp7),
  513. [res1]"=&f"(res1), [res2]"=&f"(res2)
  514. : [alpha_1]"r"(alpha_1), [alpha_0]"r"(alpha_0),
  515. [temp0]"f"(temp0), [temp1]"f"(temp1), [temp2]"f"(temp2),
  516. [temp3]"f"(temp3), [temp4]"f"(temp4), [temp5]"f"(temp5)
  517. : "memory"
  518. );
  519. }
  520. __asm__ volatile (
  521. "lwc1 %[temp1], 0(%[alpha_1]) \n\t"
  522. "lwc1 %[temp2], 4(%[alpha_1]) \n\t"
  523. "lwc1 %[temp_real], 0(%[alpha_0]) \n\t"
  524. "lwc1 %[temp_im], 4(%[alpha_0]) \n\t"
  525. "mul.s %[res1], %[temp1], %[temp1] \n\t"
  526. "madd.s %[res1], %[res1], %[temp2], %[temp2] \n\t"
  527. "mul.s %[res2], %[temp_real], %[temp_real] \n\t"
  528. "madd.s %[res2], %[res2], %[temp_im], %[temp_im] \n\t"
  529. : [temp_real]"=&f"(temp_real), [temp_im]"=&f"(temp_im),
  530. [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
  531. [res1]"=&f"(res1), [res2]"=&f"(res2)
  532. : [alpha_1]"r"(alpha_1), [alpha_0]"r"(alpha_0)
  533. : "memory"
  534. );
  535. if (res1 >= 16.0f || res2 >= 16.0f) {
  536. alpha_1[0] = 0;
  537. alpha_1[1] = 0;
  538. alpha_0[0] = 0;
  539. alpha_0[1] = 0;
  540. }
  541. }
  542. }
  543. #endif /* HAVE_MIPSFPU */
  544. #endif /* HAVE_INLINE_ASM */
  545. void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c)
  546. {
  547. #if HAVE_INLINE_ASM
  548. c->sbr_lf_gen = sbr_lf_gen_mips;
  549. c->sbr_x_gen = sbr_x_gen_mips;
  550. #if HAVE_MIPSFPU
  551. c->sbr_hf_inverse_filter = sbr_hf_inverse_filter_mips;
  552. c->sbr_hf_assemble = sbr_hf_assemble_mips;
  553. #endif /* HAVE_MIPSFPU */
  554. #endif /* HAVE_INLINE_ASM */
  555. }