cb_search_arm4.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* Copyright (C) 2004 Jean-Marc Valin */
  2. /**
  3. @file cb_search_arm4.h
  4. @brief Fixed codebook functions (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. /* This optimization is temporarily disabled until it is fixed to account for the fact
  31. that "r" is now a 16-bit array */
  32. #if 0
  33. #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
  34. static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
  35. {
  36. int i, j, k;
  37. //const signed char *shape;
  38. for (i=0;i<shape_cb_size;i+=4)
  39. {
  40. //shape = shape_cb;
  41. E[0]=0;
  42. E[1]=0;
  43. E[2]=0;
  44. E[3]=0;
  45. /* Compute codeword response using convolution with impulse response */
  46. for(j=0;j<subvect_size;j++)
  47. {
  48. #if 1
  49. spx_word16_t *res;
  50. res = resp+j;
  51. spx_word32_t resj0,resj1,resj2,resj3;
  52. spx_word32_t dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8;
  53. __asm__ __volatile__ (
  54. "mov %0, #0 \n\t"
  55. "mov %1, #0 \n\t"
  56. "mov %2, #0 \n\t"
  57. "mov %3, #0 \n\t"
  58. ".weighted%=: \n\t"
  59. "ldrsb %8, [%6] \n\t"
  60. "ldr %10, [%5], #-4 \n\t"
  61. "mov %9, %6 \n\t"
  62. "ldrsb %11, [%9, %7]! \n\t"
  63. "mla %0, %10, %8, %0 \n\t"
  64. "ldrsb %8, [%9, %7]! \n\t"
  65. "mla %1, %10, %11, %1 \n\t"
  66. "ldrsb %11, [%9, %7]! \n\t"
  67. "mla %2, %10, %8, %2 \n\t"
  68. "subs %4, %4, #1 \n\t"
  69. "mla %3, %10, %11, %3 \n\t"
  70. "add %6, %6, #1 \n\t"
  71. "bne .weighted%= \n\t"
  72. : "=r" (resj0), "=r" (resj1), "=r" (resj2), "=r" (resj3),
  73. "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
  74. "=r" (dead5), "=r" (dead6), "=r" (dead7), "=r" (dead8)
  75. : "4" (j+1), "5" (r+j), "6" (shape_cb), "7" (subvect_size)
  76. : "cc", "memory");
  77. #else
  78. spx_word16_t *res;
  79. res = resp+j;
  80. spx_word32_t resj0=0;
  81. spx_word32_t resj1=0;
  82. spx_word32_t resj2=0;
  83. spx_word32_t resj3=0;
  84. for (k=0;k<=j;k++)
  85. {
  86. const signed char *shape=shape_cb+k;
  87. resj0 = MAC16_16(resj0,*shape,r[j-k]);
  88. shape += subvect_size;
  89. resj1 = MAC16_16(resj1,*shape,r[j-k]);
  90. shape += subvect_size;
  91. resj2 = MAC16_16(resj2,*shape,r[j-k]);
  92. shape += subvect_size;
  93. resj3 = MAC16_16(resj3,*shape,r[j-k]);
  94. shape += subvect_size;
  95. }
  96. #endif
  97. #ifdef FIXED_POINT
  98. resj0 = SHR(resj0, 11);
  99. resj1 = SHR(resj1, 11);
  100. resj2 = SHR(resj2, 11);
  101. resj3 = SHR(resj3, 11);
  102. #else
  103. resj0 *= 0.03125;
  104. resj1 *= 0.03125;
  105. resj2 *= 0.03125;
  106. resj3 *= 0.03125;
  107. #endif
  108. /* Compute codeword energy */
  109. E[0]=ADD32(E[0],MULT16_16(resj0,resj0));
  110. E[1]=ADD32(E[1],MULT16_16(resj1,resj1));
  111. E[2]=ADD32(E[2],MULT16_16(resj2,resj2));
  112. E[3]=ADD32(E[3],MULT16_16(resj3,resj3));
  113. *res = resj0;
  114. res += subvect_size;
  115. *res = resj1;
  116. res += subvect_size;
  117. *res = resj2;
  118. res += subvect_size;
  119. *res = resj3;
  120. res += subvect_size;
  121. }
  122. resp += subvect_size<<2;
  123. shape_cb += subvect_size<<2;
  124. E+=4;
  125. }
  126. }
  127. #endif