celt_lpc_sse4_1.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Copyright (c) 2014, Cisco Systems, INC
  2. Written by XiangMingZhu WeiZhou MinPeng YanWang
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. - Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. - Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  12. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  13. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  14. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  15. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  16. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  20. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifdef HAVE_CONFIG_H
  24. #include "config.h"
  25. #endif
  26. #include <xmmintrin.h>
  27. #include <emmintrin.h>
  28. #include <smmintrin.h>
  29. #include "celt_lpc.h"
  30. #include "stack_alloc.h"
  31. #include "mathops.h"
  32. #include "pitch.h"
  33. #include "x86cpu.h"
  34. #if defined(FIXED_POINT)
  35. void celt_fir_sse4_1(const opus_val16 *x,
  36. const opus_val16 *num,
  37. opus_val16 *y,
  38. int N,
  39. int ord,
  40. int arch)
  41. {
  42. int i,j;
  43. VARDECL(opus_val16, rnum);
  44. __m128i vecNoA;
  45. opus_int32 noA ;
  46. SAVE_STACK;
  47. ALLOC(rnum, ord, opus_val16);
  48. for(i=0;i<ord;i++)
  49. rnum[i] = num[ord-i-1];
  50. noA = EXTEND32(1) << SIG_SHIFT >> 1;
  51. vecNoA = _mm_set_epi32(noA, noA, noA, noA);
  52. for (i=0;i<N-3;i+=4)
  53. {
  54. opus_val32 sums[4] = {0};
  55. __m128i vecSum, vecX;
  56. xcorr_kernel(rnum, x+i-ord, sums, ord, arch);
  57. vecSum = _mm_loadu_si128((__m128i *)sums);
  58. vecSum = _mm_add_epi32(vecSum, vecNoA);
  59. vecSum = _mm_srai_epi32(vecSum, SIG_SHIFT);
  60. vecX = OP_CVTEPI16_EPI32_M64(x + i);
  61. vecSum = _mm_add_epi32(vecSum, vecX);
  62. vecSum = _mm_packs_epi32(vecSum, vecSum);
  63. _mm_storel_epi64((__m128i *)(y + i), vecSum);
  64. }
  65. for (;i<N;i++)
  66. {
  67. opus_val32 sum = 0;
  68. for (j=0;j<ord;j++)
  69. sum = MAC16_16(sum, rnum[j], x[i+j-ord]);
  70. y[i] = SATURATE16(ADD32(EXTEND32(x[i]), PSHR32(sum, SIG_SHIFT)));
  71. }
  72. RESTORE_STACK;
  73. }
  74. #endif