filters_arm4.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Copyright (C) 2004 Jean-Marc Valin */
  2. /**
  3. @file filters_arm4.h
  4. @brief Various analysis/synthesis filters (ARM4 version)
  5. */
  6. /*
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. - Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. - Neither the name of the Xiph.org Foundation nor the names of its
  16. contributors may be used to endorse or promote products derived from
  17. this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  22. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #define OVERRIDE_NORMALIZE16
  31. int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
  32. {
  33. spx_sig_t max_val=1;
  34. int sig_shift;
  35. int dead1, dead2, dead3, dead4, dead5, dead6;
  36. __asm__ __volatile__ (
  37. "\tmov %1, #1 \n"
  38. "\tmov %3, #0 \n"
  39. ".normalize16loop1%=: \n"
  40. "\tldr %4, [%0], #4 \n"
  41. "\tcmp %4, %1 \n"
  42. "\tmovgt %1, %4 \n"
  43. "\tcmp %4, %3 \n"
  44. "\tmovlt %3, %4 \n"
  45. "\tsubs %2, %2, #1 \n"
  46. "\tbne .normalize16loop1%=\n"
  47. "\trsb %3, %3, #0 \n"
  48. "\tcmp %1, %3 \n"
  49. "\tmovlt %1, %3 \n"
  50. : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
  51. "=r" (dead5), "=r" (dead6)
  52. : "0" (x), "2" (len)
  53. : "cc");
  54. sig_shift=0;
  55. while (max_val>max_scale)
  56. {
  57. sig_shift++;
  58. max_val >>= 1;
  59. }
  60. __asm__ __volatile__ (
  61. ".normalize16loop%=: \n"
  62. "\tldr %4, [%0], #4 \n"
  63. "\tldr %5, [%0], #4 \n"
  64. "\tmov %4, %4, asr %3 \n"
  65. "\tstrh %4, [%1], #2 \n"
  66. "\tldr %4, [%0], #4 \n"
  67. "\tmov %5, %5, asr %3 \n"
  68. "\tstrh %5, [%1], #2 \n"
  69. "\tldr %5, [%0], #4 \n"
  70. "\tmov %4, %4, asr %3 \n"
  71. "\tstrh %4, [%1], #2 \n"
  72. "\tsubs %2, %2, #1 \n"
  73. "\tmov %5, %5, asr %3 \n"
  74. "\tstrh %5, [%1], #2 \n"
  75. "\tbgt .normalize16loop%=\n"
  76. : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
  77. "=r" (dead5), "=r" (dead6)
  78. : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift)
  79. : "cc", "memory");
  80. return sig_shift;
  81. }