You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
6.0KB

  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. #if HAVE_NEON && HAVE_INLINE_ASM
  21. #define VMUL2 VMUL2
  22. static inline float *VMUL2(float *dst, const float *v, unsigned idx,
  23. const float *scale)
  24. {
  25. unsigned v0, v1;
  26. __asm__ volatile ("ubfx %0, %4, #0, #4 \n\t"
  27. "ubfx %1, %4, #4, #4 \n\t"
  28. "ldr %0, [%3, %0, lsl #2] \n\t"
  29. "ldr %1, [%3, %1, lsl #2] \n\t"
  30. "vld1.32 {d1[]}, [%5,:32] \n\t"
  31. "vmov d0, %0, %1 \n\t"
  32. "vmul.f32 d0, d0, d1 \n\t"
  33. "vst1.32 {d0}, [%2,:64]! \n\t"
  34. : "=&r"(v0), "=&r"(v1), "+r"(dst)
  35. : "r"(v), "r"(idx), "r"(scale)
  36. : "d0", "d1");
  37. return dst;
  38. }
  39. #define VMUL4 VMUL4
  40. static inline float *VMUL4(float *dst, const float *v, unsigned idx,
  41. const float *scale)
  42. {
  43. unsigned v0, v1, v2, v3;
  44. __asm__ volatile ("ubfx %0, %6, #0, #2 \n\t"
  45. "ubfx %1, %6, #2, #2 \n\t"
  46. "ldr %0, [%5, %0, lsl #2] \n\t"
  47. "ubfx %2, %6, #4, #2 \n\t"
  48. "ldr %1, [%5, %1, lsl #2] \n\t"
  49. "ubfx %3, %6, #6, #2 \n\t"
  50. "ldr %2, [%5, %2, lsl #2] \n\t"
  51. "vmov d0, %0, %1 \n\t"
  52. "ldr %3, [%5, %3, lsl #2] \n\t"
  53. "vld1.32 {d2[],d3[]},[%7,:32] \n\t"
  54. "vmov d1, %2, %3 \n\t"
  55. "vmul.f32 q0, q0, q1 \n\t"
  56. "vst1.32 {q0}, [%4,:128]! \n\t"
  57. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst)
  58. : "r"(v), "r"(idx), "r"(scale)
  59. : "d0", "d1", "d2", "d3");
  60. return dst;
  61. }
  62. #define VMUL2S VMUL2S
  63. static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
  64. unsigned sign, const float *scale)
  65. {
  66. unsigned v0, v1, v2, v3;
  67. __asm__ volatile ("ubfx %0, %6, #0, #4 \n\t"
  68. "ubfx %1, %6, #4, #4 \n\t"
  69. "ldr %0, [%5, %0, lsl #2] \n\t"
  70. "lsl %2, %8, #30 \n\t"
  71. "ldr %1, [%5, %1, lsl #2] \n\t"
  72. "lsl %3, %8, #31 \n\t"
  73. "vmov d0, %0, %1 \n\t"
  74. "bic %2, %2, #1<<30 \n\t"
  75. "vld1.32 {d1[]}, [%7,:32] \n\t"
  76. "vmov d2, %2, %3 \n\t"
  77. "veor d0, d0, d2 \n\t"
  78. "vmul.f32 d0, d0, d1 \n\t"
  79. "vst1.32 {d0}, [%4,:64]! \n\t"
  80. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst)
  81. : "r"(v), "r"(idx), "r"(scale), "r"(sign)
  82. : "d0", "d1", "d2");
  83. return dst;
  84. }
  85. #define VMUL4S VMUL4S
  86. static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
  87. unsigned sign, const float *scale)
  88. {
  89. unsigned v0, v1, v2, v3, nz;
  90. __asm__ volatile ("vld1.32 {d2[],d3[]},[%9,:32] \n\t"
  91. "ubfx %0, %8, #0, #2 \n\t"
  92. "ubfx %1, %8, #2, #2 \n\t"
  93. "ldr %0, [%7, %0, lsl #2] \n\t"
  94. "ubfx %2, %8, #4, #2 \n\t"
  95. "ldr %1, [%7, %1, lsl #2] \n\t"
  96. "ubfx %3, %8, #6, #2 \n\t"
  97. "ldr %2, [%7, %2, lsl #2] \n\t"
  98. "vmov d0, %0, %1 \n\t"
  99. "ldr %3, [%7, %3, lsl #2] \n\t"
  100. "lsr %6, %8, #12 \n\t"
  101. "rbit %6, %6 \n\t"
  102. "vmov d1, %2, %3 \n\t"
  103. "lsls %6, %6, #1 \n\t"
  104. "and %0, %5, #1<<31 \n\t"
  105. "lslcs %5, %5, #1 \n\t"
  106. "lsls %6, %6, #1 \n\t"
  107. "and %1, %5, #1<<31 \n\t"
  108. "lslcs %5, %5, #1 \n\t"
  109. "lsls %6, %6, #1 \n\t"
  110. "and %2, %5, #1<<31 \n\t"
  111. "lslcs %5, %5, #1 \n\t"
  112. "vmov d4, %0, %1 \n\t"
  113. "and %3, %5, #1<<31 \n\t"
  114. "vmov d5, %2, %3 \n\t"
  115. "veor q0, q0, q2 \n\t"
  116. "vmul.f32 q0, q0, q1 \n\t"
  117. "vst1.32 {q0}, [%4,:128]! \n\t"
  118. : "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), "+r"(dst),
  119. "+r"(sign), "=r"(nz)
  120. : "r"(v), "r"(idx), "r"(scale)
  121. : "d0", "d1", "d2", "d3", "d4", "d5");
  122. return dst;
  123. }
  124. #endif /* HAVE_NEON && HAVE_INLINE_ASM */