vp8_shortwalsh4x4_neon.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include <arm_neon.h>
  11. #include "./vp8_rtcd.h"
  12. #include "vpx_ports/arm.h"
  13. #ifdef VPX_INCOMPATIBLE_GCC
  14. #include "./vp8_rtcd.h"
  15. void vp8_short_walsh4x4_neon(int16_t *input, int16_t *output, int pitch) {
  16. vp8_short_walsh4x4_c(input, output, pitch);
  17. }
  18. #else
  19. void vp8_short_walsh4x4_neon(int16_t *input, int16_t *output, int pitch) {
  20. uint16x4_t d16u16;
  21. int16x8_t q0s16, q1s16;
  22. int16x4_t dEmptys16, d0s16, d1s16, d2s16, d3s16, d4s16, d5s16, d6s16, d7s16;
  23. int32x4_t qEmptys32, q0s32, q1s32, q2s32, q3s32, q8s32;
  24. int32x4_t q9s32, q10s32, q11s32, q15s32;
  25. uint32x4_t q8u32, q9u32, q10u32, q11u32;
  26. int16x4x2_t v2tmp0, v2tmp1;
  27. int32x2x2_t v2tmp2, v2tmp3;
  28. dEmptys16 = vdup_n_s16(0);
  29. qEmptys32 = vdupq_n_s32(0);
  30. q15s32 = vdupq_n_s32(3);
  31. d0s16 = vld1_s16(input);
  32. input += pitch / 2;
  33. d1s16 = vld1_s16(input);
  34. input += pitch / 2;
  35. d2s16 = vld1_s16(input);
  36. input += pitch / 2;
  37. d3s16 = vld1_s16(input);
  38. v2tmp2 = vtrn_s32(vreinterpret_s32_s16(d0s16), vreinterpret_s32_s16(d2s16));
  39. v2tmp3 = vtrn_s32(vreinterpret_s32_s16(d1s16), vreinterpret_s32_s16(d3s16));
  40. v2tmp0 = vtrn_s16(vreinterpret_s16_s32(v2tmp2.val[0]), // d0
  41. vreinterpret_s16_s32(v2tmp3.val[0])); // d1
  42. v2tmp1 = vtrn_s16(vreinterpret_s16_s32(v2tmp2.val[1]), // d2
  43. vreinterpret_s16_s32(v2tmp3.val[1])); // d3
  44. d4s16 = vadd_s16(v2tmp0.val[0], v2tmp1.val[0]);
  45. d5s16 = vadd_s16(v2tmp0.val[1], v2tmp1.val[1]);
  46. d6s16 = vsub_s16(v2tmp0.val[1], v2tmp1.val[1]);
  47. d7s16 = vsub_s16(v2tmp0.val[0], v2tmp1.val[0]);
  48. d4s16 = vshl_n_s16(d4s16, 2);
  49. d5s16 = vshl_n_s16(d5s16, 2);
  50. d6s16 = vshl_n_s16(d6s16, 2);
  51. d7s16 = vshl_n_s16(d7s16, 2);
  52. d16u16 = vceq_s16(d4s16, dEmptys16);
  53. d16u16 = vmvn_u16(d16u16);
  54. d0s16 = vadd_s16(d4s16, d5s16);
  55. d3s16 = vsub_s16(d4s16, d5s16);
  56. d1s16 = vadd_s16(d7s16, d6s16);
  57. d2s16 = vsub_s16(d7s16, d6s16);
  58. d0s16 = vsub_s16(d0s16, vreinterpret_s16_u16(d16u16));
  59. // Second for-loop
  60. v2tmp2 = vtrn_s32(vreinterpret_s32_s16(d1s16), vreinterpret_s32_s16(d3s16));
  61. v2tmp3 = vtrn_s32(vreinterpret_s32_s16(d0s16), vreinterpret_s32_s16(d2s16));
  62. v2tmp0 = vtrn_s16(vreinterpret_s16_s32(v2tmp3.val[1]), // d2
  63. vreinterpret_s16_s32(v2tmp2.val[1])); // d3
  64. v2tmp1 = vtrn_s16(vreinterpret_s16_s32(v2tmp3.val[0]), // d0
  65. vreinterpret_s16_s32(v2tmp2.val[0])); // d1
  66. q8s32 = vaddl_s16(v2tmp1.val[0], v2tmp0.val[0]);
  67. q9s32 = vaddl_s16(v2tmp1.val[1], v2tmp0.val[1]);
  68. q10s32 = vsubl_s16(v2tmp1.val[1], v2tmp0.val[1]);
  69. q11s32 = vsubl_s16(v2tmp1.val[0], v2tmp0.val[0]);
  70. q0s32 = vaddq_s32(q8s32, q9s32);
  71. q1s32 = vaddq_s32(q11s32, q10s32);
  72. q2s32 = vsubq_s32(q11s32, q10s32);
  73. q3s32 = vsubq_s32(q8s32, q9s32);
  74. q8u32 = vcltq_s32(q0s32, qEmptys32);
  75. q9u32 = vcltq_s32(q1s32, qEmptys32);
  76. q10u32 = vcltq_s32(q2s32, qEmptys32);
  77. q11u32 = vcltq_s32(q3s32, qEmptys32);
  78. q8s32 = vreinterpretq_s32_u32(q8u32);
  79. q9s32 = vreinterpretq_s32_u32(q9u32);
  80. q10s32 = vreinterpretq_s32_u32(q10u32);
  81. q11s32 = vreinterpretq_s32_u32(q11u32);
  82. q0s32 = vsubq_s32(q0s32, q8s32);
  83. q1s32 = vsubq_s32(q1s32, q9s32);
  84. q2s32 = vsubq_s32(q2s32, q10s32);
  85. q3s32 = vsubq_s32(q3s32, q11s32);
  86. q8s32 = vaddq_s32(q0s32, q15s32);
  87. q9s32 = vaddq_s32(q1s32, q15s32);
  88. q10s32 = vaddq_s32(q2s32, q15s32);
  89. q11s32 = vaddq_s32(q3s32, q15s32);
  90. d0s16 = vshrn_n_s32(q8s32, 3);
  91. d1s16 = vshrn_n_s32(q9s32, 3);
  92. d2s16 = vshrn_n_s32(q10s32, 3);
  93. d3s16 = vshrn_n_s32(q11s32, 3);
  94. q0s16 = vcombine_s16(d0s16, d1s16);
  95. q1s16 = vcombine_s16(d2s16, d3s16);
  96. vst1q_s16(output, q0s16);
  97. vst1q_s16(output + 8, q1s16);
  98. return;
  99. }
  100. #endif // VPX_INCOMPATIBLE_GCC