compare_neon64.cc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2012 The LibYuv 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 "libyuv/basic_types.h"
  11. #include "libyuv/compare_row.h"
  12. #include "libyuv/row.h"
  13. #ifdef __cplusplus
  14. namespace libyuv {
  15. extern "C" {
  16. #endif
  17. #if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
  18. uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) {
  19. volatile uint32 sse;
  20. asm volatile (
  21. "eor v16.16b, v16.16b, v16.16b \n"
  22. "eor v18.16b, v18.16b, v18.16b \n"
  23. "eor v17.16b, v17.16b, v17.16b \n"
  24. "eor v19.16b, v19.16b, v19.16b \n"
  25. "1: \n"
  26. MEMACCESS(0)
  27. "ld1 {v0.16b}, [%0], #16 \n"
  28. MEMACCESS(1)
  29. "ld1 {v1.16b}, [%1], #16 \n"
  30. "subs %w2, %w2, #16 \n"
  31. "usubl v2.8h, v0.8b, v1.8b \n"
  32. "usubl2 v3.8h, v0.16b, v1.16b \n"
  33. "smlal v16.4s, v2.4h, v2.4h \n"
  34. "smlal v17.4s, v3.4h, v3.4h \n"
  35. "smlal2 v18.4s, v2.8h, v2.8h \n"
  36. "smlal2 v19.4s, v3.8h, v3.8h \n"
  37. "b.gt 1b \n"
  38. "add v16.4s, v16.4s, v17.4s \n"
  39. "add v18.4s, v18.4s, v19.4s \n"
  40. "add v19.4s, v16.4s, v18.4s \n"
  41. "addv s0, v19.4s \n"
  42. "fmov %w3, s0 \n"
  43. : "+r"(src_a),
  44. "+r"(src_b),
  45. "+r"(count),
  46. "=r"(sse)
  47. :
  48. : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
  49. return sse;
  50. }
  51. #endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
  52. #ifdef __cplusplus
  53. } // extern "C"
  54. } // namespace libyuv
  55. #endif