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