aac.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_ARM_AAC_H
  21. #define AVCODEC_ARM_AAC_H
  22. #include "config.h"
  23. #if HAVE_NEON_INLINE
  24. #define VMUL2 VMUL2
  25. static inline float *VMUL2(float *dst, const float *v, unsigned idx,
  26. const float *scale)
  27. {
  28. unsigned v0, v1;
  29. __asm__ ("ubfx %0, %6, #0, #4 \n\t"
  30. "ubfx %1, %6, #4, #4 \n\t"
  31. "ldr %0, [%5, %0, lsl #2] \n\t"
  32. "ldr %1, [%5, %1, lsl #2] \n\t"
  33. "vld1.32 {d1[]}, [%7,:32] \n\t"
  34. "vmov d0, %0, %1 \n\t"
  35. "vmul.f32 d0, d0, d1 \n\t"
  36. "vst1.32 {d0}, [%2,:64]! \n\t"
  37. : "=&r"(v0), "=&r"(v1), "+r"(dst), "=m"(dst[0]), "=m"(dst[1])
  38. : "r"(v), "r"(idx), "r"(scale)
  39. : "d0", "d1");
  40. return dst;
  41. }
  42. #define VMUL4 VMUL4
  43. static inline float *VMUL4(float *dst, const float *v, unsigned idx,
  44. const float *scale)
  45. {
  46. unsigned v0, v1, v2, v3;
  47. __asm__ ("ubfx %0, %10, #0, #2 \n\t"
  48. "ubfx %1, %10, #2, #2 \n\t"
  49. "ldr %0, [%9, %0, lsl #2] \n\t"
  50. "ubfx %2, %10, #4, #2 \n\t"
  51. "ldr %1, [%9, %1, lsl #2] \n\t"
  52. "ubfx %3, %10, #6, #2 \n\t"
  53. "ldr %2, [%9, %2, lsl #2] \n\t"
  54. "vmov d0, %0, %1 \n\t"
  55. "ldr %3, [%9, %3, lsl #2] \n\t"
  56. "vld1.32 {d2[],d3[]},[%11,:32] \n\t"
  57. "vmov d1, %2, %3 \n\t"
  58. "vmul.f32 q0, q0, q1 \n\t"
  59. "vst1.32 {q0}, [%4,:128]! \n\t"
  60. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
  61. "=m"(dst[0]), "=m"(dst[1]), "=m"(dst[2]), "=m"(dst[3])
  62. : "r"(v), "r"(idx), "r"(scale)
  63. : "d0", "d1", "d2", "d3");
  64. return dst;
  65. }
  66. #define VMUL2S VMUL2S
  67. static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
  68. unsigned sign, const float *scale)
  69. {
  70. unsigned v0, v1, v2, v3;
  71. __asm__ ("ubfx %0, %8, #0, #4 \n\t"
  72. "ubfx %1, %8, #4, #4 \n\t"
  73. "ldr %0, [%7, %0, lsl #2] \n\t"
  74. "lsl %2, %10, #30 \n\t"
  75. "ldr %1, [%7, %1, lsl #2] \n\t"
  76. "lsl %3, %10, #31 \n\t"
  77. "vmov d0, %0, %1 \n\t"
  78. "bic %2, %2, #1<<30 \n\t"
  79. "vld1.32 {d1[]}, [%9,:32] \n\t"
  80. "vmov d2, %2, %3 \n\t"
  81. "veor d0, d0, d2 \n\t"
  82. "vmul.f32 d0, d0, d1 \n\t"
  83. "vst1.32 {d0}, [%4,:64]! \n\t"
  84. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
  85. "=m"(dst[0]), "=m"(dst[1])
  86. : "r"(v), "r"(idx), "r"(scale), "r"(sign)
  87. : "d0", "d1", "d2");
  88. return dst;
  89. }
  90. #define VMUL4S VMUL4S
  91. static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
  92. unsigned sign, const float *scale)
  93. {
  94. unsigned v0, v1, v2, v3, nz;
  95. __asm__ ("vld1.32 {d2[],d3[]},[%13,:32] \n\t"
  96. "ubfx %0, %12, #0, #2 \n\t"
  97. "ubfx %1, %12, #2, #2 \n\t"
  98. "ldr %0, [%11,%0, lsl #2] \n\t"
  99. "ubfx %2, %12, #4, #2 \n\t"
  100. "ldr %1, [%11,%1, lsl #2] \n\t"
  101. "ubfx %3, %12, #6, #2 \n\t"
  102. "ldr %2, [%11,%2, lsl #2] \n\t"
  103. "vmov d0, %0, %1 \n\t"
  104. "ldr %3, [%11,%3, lsl #2] \n\t"
  105. "lsr %6, %12, #12 \n\t"
  106. "rbit %6, %6 \n\t"
  107. "vmov d1, %2, %3 \n\t"
  108. "lsls %6, %6, #1 \n\t"
  109. "and %0, %5, #1<<31 \n\t"
  110. "it cs \n\t"
  111. "lslcs %5, %5, #1 \n\t"
  112. "lsls %6, %6, #1 \n\t"
  113. "and %1, %5, #1<<31 \n\t"
  114. "it cs \n\t"
  115. "lslcs %5, %5, #1 \n\t"
  116. "lsls %6, %6, #1 \n\t"
  117. "and %2, %5, #1<<31 \n\t"
  118. "it cs \n\t"
  119. "lslcs %5, %5, #1 \n\t"
  120. "vmov d4, %0, %1 \n\t"
  121. "and %3, %5, #1<<31 \n\t"
  122. "vmov d5, %2, %3 \n\t"
  123. "veor q0, q0, q2 \n\t"
  124. "vmul.f32 q0, q0, q1 \n\t"
  125. "vst1.32 {q0}, [%4,:128]! \n\t"
  126. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
  127. "+r"(sign), "=r"(nz),
  128. "=m"(dst[0]), "=m"(dst[1]), "=m"(dst[2]), "=m"(dst[3])
  129. : "r"(v), "r"(idx), "r"(scale)
  130. : "cc", "d0", "d1", "d2", "d3", "d4", "d5");
  131. return dst;
  132. }
  133. #endif /* HAVE_NEON_INLINE */
  134. #endif /* AVCODEC_ARM_AAC_H */