1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #include <arm_neon.h>
13
14 #include "config/aom_config.h"
15
16 #include "aom/aom_integer.h"
17
aom_subtract_block_neon(int rows,int cols,int16_t * diff,ptrdiff_t diff_stride,const uint8_t * src,ptrdiff_t src_stride,const uint8_t * pred,ptrdiff_t pred_stride)18 void aom_subtract_block_neon(int rows, int cols, int16_t *diff,
19 ptrdiff_t diff_stride, const uint8_t *src,
20 ptrdiff_t src_stride, const uint8_t *pred,
21 ptrdiff_t pred_stride) {
22 int r, c;
23
24 if (cols > 16) {
25 for (r = 0; r < rows; ++r) {
26 for (c = 0; c < cols; c += 32) {
27 const uint8x16_t v_src_00 = vld1q_u8(&src[c + 0]);
28 const uint8x16_t v_src_16 = vld1q_u8(&src[c + 16]);
29 const uint8x16_t v_pred_00 = vld1q_u8(&pred[c + 0]);
30 const uint8x16_t v_pred_16 = vld1q_u8(&pred[c + 16]);
31 const uint16x8_t v_diff_lo_00 =
32 vsubl_u8(vget_low_u8(v_src_00), vget_low_u8(v_pred_00));
33 const uint16x8_t v_diff_hi_00 =
34 vsubl_u8(vget_high_u8(v_src_00), vget_high_u8(v_pred_00));
35 const uint16x8_t v_diff_lo_16 =
36 vsubl_u8(vget_low_u8(v_src_16), vget_low_u8(v_pred_16));
37 const uint16x8_t v_diff_hi_16 =
38 vsubl_u8(vget_high_u8(v_src_16), vget_high_u8(v_pred_16));
39 vst1q_s16(&diff[c + 0], vreinterpretq_s16_u16(v_diff_lo_00));
40 vst1q_s16(&diff[c + 8], vreinterpretq_s16_u16(v_diff_hi_00));
41 vst1q_s16(&diff[c + 16], vreinterpretq_s16_u16(v_diff_lo_16));
42 vst1q_s16(&diff[c + 24], vreinterpretq_s16_u16(v_diff_hi_16));
43 }
44 diff += diff_stride;
45 pred += pred_stride;
46 src += src_stride;
47 }
48 } else if (cols > 8) {
49 for (r = 0; r < rows; ++r) {
50 const uint8x16_t v_src = vld1q_u8(&src[0]);
51 const uint8x16_t v_pred = vld1q_u8(&pred[0]);
52 const uint16x8_t v_diff_lo =
53 vsubl_u8(vget_low_u8(v_src), vget_low_u8(v_pred));
54 const uint16x8_t v_diff_hi =
55 vsubl_u8(vget_high_u8(v_src), vget_high_u8(v_pred));
56 vst1q_s16(&diff[0], vreinterpretq_s16_u16(v_diff_lo));
57 vst1q_s16(&diff[8], vreinterpretq_s16_u16(v_diff_hi));
58 diff += diff_stride;
59 pred += pred_stride;
60 src += src_stride;
61 }
62 } else if (cols > 4) {
63 for (r = 0; r < rows; ++r) {
64 const uint8x8_t v_src = vld1_u8(&src[0]);
65 const uint8x8_t v_pred = vld1_u8(&pred[0]);
66 const uint16x8_t v_diff = vsubl_u8(v_src, v_pred);
67 vst1q_s16(&diff[0], vreinterpretq_s16_u16(v_diff));
68 diff += diff_stride;
69 pred += pred_stride;
70 src += src_stride;
71 }
72 } else {
73 for (r = 0; r < rows; ++r) {
74 for (c = 0; c < cols; ++c) diff[c] = src[c] - pred[c];
75
76 diff += diff_stride;
77 pred += pred_stride;
78 src += src_stride;
79 }
80 }
81 }
82