• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023, 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 #ifndef AOM_AV1_ENCODER_ARM_NEON_SHIFT_NEON_H_
13 #define AOM_AV1_ENCODER_ARM_NEON_SHIFT_NEON_H_
14 
15 #include <arm_neon.h>
16 
17 #include "aom/aom_integer.h"  // For AOM_INLINE.
18 
19 #define SHIFT_LOOP_HELPER(name, type, intrinsic, arg)                \
20   static AOM_INLINE void name(const type *in, type *out, int size) { \
21     int i = 0;                                                       \
22     do {                                                             \
23       out[i] = intrinsic(in[i], arg);                                \
24     } while (++i < size);                                            \
25   }
26 
27 SHIFT_LOOP_HELPER(shift_left_2_s16_x4, int16x4_t, vshl_n_s16, 2)
28 SHIFT_LOOP_HELPER(shift_left_2_s16_x8, int16x8_t, vshlq_n_s16, 2)
29 SHIFT_LOOP_HELPER(shift_left_2_s32_x4, int32x4_t, vshlq_n_s32, 2)
30 SHIFT_LOOP_HELPER(shift_right_2_round_s16_x8, int16x8_t, vrshrq_n_s16, 2)
31 SHIFT_LOOP_HELPER(shift_right_2_round_s32_x4, int32x4_t, vrshrq_n_s32, 2)
32 SHIFT_LOOP_HELPER(shift_right_4_round_s16_x8, int16x8_t, vrshrq_n_s16, 4)
33 SHIFT_LOOP_HELPER(shift_right_4_round_s32_x4, int32x4_t, vrshrq_n_s32, 4)
34 
35 // Addition instructions have slightly better performance compared to shift
36 // instructions on some micro-architectures, so use these for shifts by one.
37 
38 SHIFT_LOOP_HELPER(shift_left_1_s16_x4, int16x4_t, vadd_s16, in[i])
39 SHIFT_LOOP_HELPER(shift_left_1_s16_x8, int16x8_t, vaddq_s16, in[i])
40 SHIFT_LOOP_HELPER(shift_right_1_round_s16_x4, int16x4_t, vrhadd_s16,
41                   vdup_n_s16(0))
42 SHIFT_LOOP_HELPER(shift_right_1_round_s16_x8, int16x8_t, vrhaddq_s16,
43                   vdupq_n_s16(0))
44 SHIFT_LOOP_HELPER(shift_right_1_round_s32_x4, int32x4_t, vrhaddq_s32,
45                   vdupq_n_s32(0))
46 
47 #undef SHIFT_LOOP_HELPER
48 
49 #endif  // AOM_AV1_ENCODER_ARM_NEON_SHIFT_NEON_H_
50