avg_pred_neon.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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;
  18. for (y = 0; y < height; ++y) {
  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. }
  29. } else {
  30. int i;
  31. for (i = 0; i < width * height; i += 16) {
  32. const uint8x16_t p = vld1q_u8(pred);
  33. uint8x16_t r;
  34. if (width == 4) {
  35. r = load_unaligned_u8q(ref, ref_stride);
  36. ref += 4 * ref_stride;
  37. } else {
  38. const uint8x8_t r_0 = vld1_u8(ref);
  39. const uint8x8_t r_1 = vld1_u8(ref + ref_stride);
  40. assert(width == 8);
  41. r = vcombine_u8(r_0, r_1);
  42. ref += 2 * ref_stride;
  43. }
  44. r = vrhaddq_u8(r, p);
  45. vst1q_u8(comp, r);
  46. pred += 16;
  47. comp += 16;
  48. }
  49. }
  50. }