lsp_bfin.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2006 David Rowe */
  2. /**
  3. @file lsp_bfin.h
  4. @author David Rowe
  5. @brief LSP routines optimised for the Blackfin
  6. */
  7. /*
  8. Redistribution and use in source and binary forms, with or without
  9. modification, are permitted provided that the following conditions
  10. are met:
  11. - Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. - Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. - Neither the name of the Xiph.org Foundation nor the names of its
  17. contributors may be used to endorse or promote products derived from
  18. this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  23. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #define OVERRIDE_CHEB_POLY_EVA
  32. #ifdef OVERRIDE_CHEB_POLY_EVA
  33. static inline spx_word32_t cheb_poly_eva(
  34. spx_word16_t *coef, /* P or Q coefs in Q13 format */
  35. spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */
  36. int m, /* LPC order/2 */
  37. char *stack
  38. )
  39. {
  40. spx_word32_t sum;
  41. __asm__ __volatile__
  42. (
  43. "P0 = %2;\n\t" /* P0: coef[m], coef[m-1],..., coef[0] */
  44. "R4 = 8192;\n\t" /* R4: rounding constant */
  45. "R2 = %1;\n\t" /* R2: x */
  46. "R5 = -16383;\n\t"
  47. "R2 = MAX(R2,R5);\n\t"
  48. "R5 = 16383;\n\t"
  49. "R2 = MIN(R2,R5);\n\t"
  50. "R3 = W[P0--] (X);\n\t" /* R3: sum */
  51. "R5 = W[P0--] (X);\n\t"
  52. "R5 = R5.L * R2.L (IS);\n\t"
  53. "R5 = R5 + R4;\n\t"
  54. "R5 >>>= 14;\n\t"
  55. "R3 = R3 + R5;\n\t"
  56. "R0 = R2;\n\t" /* R0: b0 */
  57. "R1 = 16384;\n\t" /* R1: b1 */
  58. "LOOP cpe%= LC0 = %3;\n\t"
  59. "LOOP_BEGIN cpe%=;\n\t"
  60. "P1 = R0;\n\t"
  61. "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t"
  62. "R0 >>>= 13;\n\t"
  63. "R0 = R0 - R1;\n\t"
  64. "R1 = P1;\n\t"
  65. "R5 = R5.L * R0.L (IS);\n\t"
  66. "R5 = R5 + R4;\n\t"
  67. "R5 >>>= 14;\n\t"
  68. "R3 = R3 + R5;\n\t"
  69. "LOOP_END cpe%=;\n\t"
  70. "%0 = R3;\n\t"
  71. : "=&d" (sum)
  72. : "a" (x), "a" (&coef[m]), "a" (m-1)
  73. : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1", "ASTAT" BFIN_HWLOOP0_REGS
  74. );
  75. return sum;
  76. }
  77. #endif