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.

185 lines
10KB

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