avg_pred_neon.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include <arm_neon.h>
  11. #include <assert.h>
  12. #include "./vpx_dsp_rtcd.h"
  13. #include "vpx_dsp/arm/mem_neon.h"
  14. void vpx_comp_avg_pred_neon(uint8_t *comp, const uint8_t *pred, int width,
  15. int height, const uint8_t *ref, int ref_stride) {
  16. if (width > 8) {
  17. int x, y = height;
  18. do {
  19. for (x = 0; x < width; x += 16) {
  20. const uint8x16_t p = vld1q_u8(pred + x);
  21. const uint8x16_t r = vld1q_u8(ref + x);
  22. const uint8x16_t avg = vrhaddq_u8(p, r);
  23. vst1q_u8(comp + x, avg);
  24. }
  25. comp += width;
  26. pred += width;
  27. ref += ref_stride;
  28. } while (--y);
  29. } else if (width == 8) {
  30. int i = width * height;
  31. do {
  32. const uint8x16_t p = vld1q_u8(pred);
  33. uint8x16_t r;
  34. const uint8x8_t r_0 = vld1_u8(ref);
  35. const uint8x8_t r_1 = vld1_u8(ref + ref_stride);
  36. r = vcombine_u8(r_0, r_1);
  37. ref += 2 * ref_stride;
  38. r = vrhaddq_u8(r, p);
  39. vst1q_u8(comp, r);
  40. pred += 16;
  41. comp += 16;
  42. i -= 16;
  43. } while (i);
  44. } else {
  45. int i = width * height;
  46. assert(width == 4);
  47. do {
  48. const uint8x16_t p = vld1q_u8(pred);
  49. uint8x16_t r;
  50. r = load_unaligned_u8q(ref, ref_stride);
  51. ref += 4 * ref_stride;
  52. r = vrhaddq_u8(r, p);
  53. vst1q_u8(comp, r);
  54. pred += 16;
  55. comp += 16;
  56. i -= 16;
  57. } while (i);
  58. }
  59. }