sum_neon.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2017 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. #ifndef VPX_DSP_ARM_SUM_NEON_H_
  11. #define VPX_DSP_ARM_SUM_NEON_H_
  12. #include <arm_neon.h>
  13. #include "./vpx_config.h"
  14. #include "vpx/vpx_integer.h"
  15. static INLINE int32x2_t horizontal_add_int16x8(const int16x8_t a) {
  16. const int32x4_t b = vpaddlq_s16(a);
  17. const int64x2_t c = vpaddlq_s32(b);
  18. return vadd_s32(vreinterpret_s32_s64(vget_low_s64(c)),
  19. vreinterpret_s32_s64(vget_high_s64(c)));
  20. }
  21. static INLINE uint32x2_t horizontal_add_uint16x8(const uint16x8_t a) {
  22. const uint32x4_t b = vpaddlq_u16(a);
  23. const uint64x2_t c = vpaddlq_u32(b);
  24. return vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)),
  25. vreinterpret_u32_u64(vget_high_u64(c)));
  26. }
  27. static INLINE uint32x2_t horizontal_add_long_uint16x8(const uint16x8_t a,
  28. const uint16x8_t b) {
  29. const uint32x4_t c = vpaddlq_u16(a);
  30. const uint32x4_t d = vpadalq_u16(c, b);
  31. const uint64x2_t e = vpaddlq_u32(d);
  32. return vadd_u32(vreinterpret_u32_u64(vget_low_u64(e)),
  33. vreinterpret_u32_u64(vget_high_u64(e)));
  34. }
  35. static INLINE uint32x2_t horizontal_add_uint32x4(const uint32x4_t a) {
  36. const uint64x2_t b = vpaddlq_u32(a);
  37. return vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)),
  38. vreinterpret_u32_u64(vget_high_u64(b)));
  39. }
  40. #endif // VPX_DSP_ARM_SUM_NEON_H_