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.

186 lines
10.0KB

  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: Nedeljko Babic (nbabic@mips.com)
  30. *
  31. * This file is part of FFmpeg.
  32. *
  33. * FFmpeg is free software; you can redistribute it and/or
  34. * modify it under the terms of the GNU Lesser General Public
  35. * License as published by the Free Software Foundation; either
  36. * version 2.1 of the License, or (at your option) any later version.
  37. *
  38. * FFmpeg is distributed in the hope that it will be useful,
  39. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  41. * Lesser General Public License for more details.
  42. *
  43. * You should have received a copy of the GNU Lesser General Public
  44. * License along with FFmpeg; if not, write to the Free Software
  45. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  46. */
  47. /**
  48. * @file
  49. * Reference: libavcodec/amrwbdec.c
  50. */
  51. #include "libavutil/avutil.h"
  52. #include "libavcodec/amrwbdata.h"
  53. #include "amrwbdec_mips.h"
  54. void hb_fir_filter_mips(float *out, const float fir_coef[HB_FIR_SIZE + 1],
  55. float mem[HB_FIR_SIZE], const float *in)
  56. {
  57. int i;
  58. float data[AMRWB_SFR_SIZE_16k + HB_FIR_SIZE]; // past and current samples
  59. memcpy(data, mem, HB_FIR_SIZE * sizeof(float));
  60. memcpy(data + HB_FIR_SIZE, in, AMRWB_SFR_SIZE_16k * sizeof(float));
  61. for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) {
  62. float output;
  63. float * p_data = (data+i);
  64. /**
  65. * inner loop is entirely unrolled and instructions are scheduled
  66. * to minimize pipeline stall
  67. */
  68. __asm__ volatile(
  69. "mtc1 $zero, %[output] \n\t"
  70. "lwc1 $f0, 0(%[p_data]) \n\t"
  71. "lwc1 $f1, 0(%[fir_coef]) \n\t"
  72. "lwc1 $f2, 4(%[p_data]) \n\t"
  73. "madd.s %[output], %[output], $f0, $f1 \n\t"
  74. "lwc1 $f3, 4(%[fir_coef]) \n\t"
  75. "lwc1 $f4, 8(%[p_data]) \n\t"
  76. "madd.s %[output], %[output], $f2, $f3 \n\t"
  77. "lwc1 $f5, 8(%[fir_coef]) \n\t"
  78. "lwc1 $f0, 12(%[p_data]) \n\t"
  79. "lwc1 $f1, 12(%[fir_coef]) \n\t"
  80. "madd.s %[output], %[output], $f4, $f5 \n\t"
  81. "lwc1 $f2, 16(%[p_data]) \n\t"
  82. "madd.s %[output], %[output], $f0, $f1 \n\t"
  83. "lwc1 $f3, 16(%[fir_coef]) \n\t"
  84. "lwc1 $f4, 20(%[p_data]) \n\t"
  85. "lwc1 $f5, 20(%[fir_coef]) \n\t"
  86. "madd.s %[output], %[output], $f2, $f3 \n\t"
  87. "lwc1 $f0, 24(%[p_data]) \n\t"
  88. "lwc1 $f1, 24(%[fir_coef]) \n\t"
  89. "lwc1 $f2, 28(%[p_data]) \n\t"
  90. "madd.s %[output], %[output], $f4, $f5 \n\t"
  91. "lwc1 $f3, 28(%[fir_coef]) \n\t"
  92. "madd.s %[output], %[output], $f0, $f1 \n\t"
  93. "lwc1 $f4, 32(%[p_data]) \n\t"
  94. "madd.s %[output], %[output], $f2, $f3 \n\t"
  95. "lwc1 $f5, 32(%[fir_coef]) \n\t"
  96. "madd.s %[output], %[output], $f4, $f5 \n\t"
  97. "lwc1 $f0, 36(%[p_data]) \n\t"
  98. "lwc1 $f1, 36(%[fir_coef]) \n\t"
  99. "lwc1 $f2, 40(%[p_data]) \n\t"
  100. "lwc1 $f3, 40(%[fir_coef]) \n\t"
  101. "madd.s %[output], %[output], $f0, $f1 \n\t"
  102. "lwc1 $f4, 44(%[p_data]) \n\t"
  103. "lwc1 $f5, 44(%[fir_coef]) \n\t"
  104. "madd.s %[output], %[output], $f2, $f3 \n\t"
  105. "lwc1 $f0, 48(%[p_data]) \n\t"
  106. "lwc1 $f1, 48(%[fir_coef]) \n\t"
  107. "lwc1 $f2, 52(%[p_data]) \n\t"
  108. "madd.s %[output], %[output], $f4, $f5 \n\t"
  109. "lwc1 $f3, 52(%[fir_coef]) \n\t"
  110. "lwc1 $f4, 56(%[p_data]) \n\t"
  111. "madd.s %[output], %[output], $f0, $f1 \n\t"
  112. "lwc1 $f5, 56(%[fir_coef]) \n\t"
  113. "madd.s %[output], %[output], $f2, $f3 \n\t"
  114. "lwc1 $f0, 60(%[p_data]) \n\t"
  115. "lwc1 $f1, 60(%[fir_coef]) \n\t"
  116. "lwc1 $f2, 64(%[p_data]) \n\t"
  117. "madd.s %[output], %[output], $f4, $f5 \n\t"
  118. "lwc1 $f3, 64(%[fir_coef]) \n\t"
  119. "madd.s %[output], %[output], $f0, $f1 \n\t"
  120. "lwc1 $f4, 68(%[p_data]) \n\t"
  121. "madd.s %[output], %[output], $f2, $f3 \n\t"
  122. "lwc1 $f5, 68(%[fir_coef]) \n\t"
  123. "madd.s %[output], %[output], $f4, $f5 \n\t"
  124. "lwc1 $f0, 72(%[p_data]) \n\t"
  125. "lwc1 $f1, 72(%[fir_coef]) \n\t"
  126. "lwc1 $f2, 76(%[p_data]) \n\t"
  127. "lwc1 $f3, 76(%[fir_coef]) \n\t"
  128. "madd.s %[output], %[output], $f0, $f1 \n\t"
  129. "lwc1 $f4, 80(%[p_data]) \n\t"
  130. "lwc1 $f5, 80(%[fir_coef]) \n\t"
  131. "madd.s %[output], %[output], $f2, $f3 \n\t"
  132. "lwc1 $f0, 84(%[p_data]) \n\t"
  133. "lwc1 $f1, 84(%[fir_coef]) \n\t"
  134. "lwc1 $f2, 88(%[p_data]) \n\t"
  135. "madd.s %[output], %[output], $f4, $f5 \n\t"
  136. "lwc1 $f3, 88(%[fir_coef]) \n\t"
  137. "lwc1 $f4, 92(%[p_data]) \n\t"
  138. "madd.s %[output], %[output], $f0, $f1 \n\t"
  139. "lwc1 $f5, 92(%[fir_coef]) \n\t"
  140. "madd.s %[output], %[output], $f2, $f3 \n\t"
  141. "lwc1 $f0, 96(%[p_data]) \n\t"
  142. "lwc1 $f1, 96(%[fir_coef]) \n\t"
  143. "lwc1 $f2, 100(%[p_data]) \n\t"
  144. "madd.s %[output], %[output], $f4, $f5 \n\t"
  145. "lwc1 $f3, 100(%[fir_coef]) \n\t"
  146. "lwc1 $f4, 104(%[p_data]) \n\t"
  147. "madd.s %[output], %[output], $f0, $f1 \n\t"
  148. "lwc1 $f5, 104(%[fir_coef]) \n\t"
  149. "madd.s %[output], %[output], $f2, $f3 \n\t"
  150. "lwc1 $f0, 108(%[p_data]) \n\t"
  151. "lwc1 $f1, 108(%[fir_coef]) \n\t"
  152. "madd.s %[output], %[output], $f4, $f5 \n\t"
  153. "lwc1 $f2, 112(%[p_data]) \n\t"
  154. "lwc1 $f3, 112(%[fir_coef]) \n\t"
  155. "madd.s %[output], %[output], $f0, $f1 \n\t"
  156. "lwc1 $f4, 116(%[p_data]) \n\t"
  157. "lwc1 $f5, 116(%[fir_coef]) \n\t"
  158. "lwc1 $f0, 120(%[p_data]) \n\t"
  159. "madd.s %[output], %[output], $f2, $f3 \n\t"
  160. "lwc1 $f1, 120(%[fir_coef]) \n\t"
  161. "madd.s %[output], %[output], $f4, $f5 \n\t"
  162. "madd.s %[output], %[output], $f0, $f1 \n\t"
  163. : [output]"=&f"(output)
  164. : [fir_coef]"r"(fir_coef), [p_data]"r"(p_data)
  165. : "$f0", "$f1", "$f2", "$f3", "$f4", "$f5"
  166. );
  167. out[i] = output;
  168. }
  169. memcpy(mem, data + AMRWB_SFR_SIZE_16k, HB_FIR_SIZE * sizeof(float));
  170. }