1*77c1e3ccSAndroid Build Coastguard Worker /* 2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2023, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker * 4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker */ 11*77c1e3ccSAndroid Build Coastguard Worker 12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_ENCODER_ARM_SHIFT_NEON_H_ 13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_ENCODER_ARM_SHIFT_NEON_H_ 14*77c1e3ccSAndroid Build Coastguard Worker 15*77c1e3ccSAndroid Build Coastguard Worker #include <arm_neon.h> 16*77c1e3ccSAndroid Build Coastguard Worker 17*77c1e3ccSAndroid Build Coastguard Worker #define SHIFT_LOOP_HELPER(name, type, intrinsic, arg) \ 18*77c1e3ccSAndroid Build Coastguard Worker static inline void name(const type *in, type *out, int size) { \ 19*77c1e3ccSAndroid Build Coastguard Worker int i = 0; \ 20*77c1e3ccSAndroid Build Coastguard Worker do { \ 21*77c1e3ccSAndroid Build Coastguard Worker out[i] = intrinsic(in[i], arg); \ 22*77c1e3ccSAndroid Build Coastguard Worker } while (++i < size); \ 23*77c1e3ccSAndroid Build Coastguard Worker } 24*77c1e3ccSAndroid Build Coastguard Worker 25*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_left_2_s16_x4, int16x4_t, vshl_n_s16, 2) 26*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_left_2_s16_x8, int16x8_t, vshlq_n_s16, 2) 27*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_left_2_s32_x4, int32x4_t, vshlq_n_s32, 2) 28*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_2_round_s16_x8, int16x8_t, vrshrq_n_s16, 2) 29*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_2_round_s32_x4, int32x4_t, vrshrq_n_s32, 2) 30*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_4_round_s16_x8, int16x8_t, vrshrq_n_s16, 4) 31*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_4_round_s32_x4, int32x4_t, vrshrq_n_s32, 4) 32*77c1e3ccSAndroid Build Coastguard Worker 33*77c1e3ccSAndroid Build Coastguard Worker // Addition instructions have slightly better performance compared to shift 34*77c1e3ccSAndroid Build Coastguard Worker // instructions on some micro-architectures, so use these for shifts by one. 35*77c1e3ccSAndroid Build Coastguard Worker 36*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_left_1_s16_x4, int16x4_t, vadd_s16, in[i]) 37*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_left_1_s16_x8, int16x8_t, vaddq_s16, in[i]) 38*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_1_round_s16_x4, int16x4_t, vrhadd_s16, 39*77c1e3ccSAndroid Build Coastguard Worker vdup_n_s16(0)) 40*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_1_round_s16_x8, int16x8_t, vrhaddq_s16, 41*77c1e3ccSAndroid Build Coastguard Worker vdupq_n_s16(0)) 42*77c1e3ccSAndroid Build Coastguard Worker SHIFT_LOOP_HELPER(shift_right_1_round_s32_x4, int32x4_t, vrhaddq_s32, 43*77c1e3ccSAndroid Build Coastguard Worker vdupq_n_s32(0)) 44*77c1e3ccSAndroid Build Coastguard Worker 45*77c1e3ccSAndroid Build Coastguard Worker #undef SHIFT_LOOP_HELPER 46*77c1e3ccSAndroid Build Coastguard Worker 47*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_ENCODER_ARM_SHIFT_NEON_H_ 48