tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

shift_neon.h (2211B)


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