hybrid_fwd_txfm_neon.c (2283B)
1 /* 2 * Copyright (c) 2020, 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 "aom_dsp/txfm_common.h" 15 #include "config/av1_rtcd.h" 16 17 static void transpose4x4(int16x8_t in[2], int16x4_t out[4]) { 18 int32x4x2_t b0 = 19 vtrnq_s32(vreinterpretq_s32_s16(in[0]), vreinterpretq_s32_s16(in[1])); 20 int16x4x2_t c0 = vtrn_s16(vreinterpret_s16_s32(vget_low_s32(b0.val[0])), 21 vreinterpret_s16_s32(vget_high_s32(b0.val[0]))); 22 int16x4x2_t c1 = vtrn_s16(vreinterpret_s16_s32(vget_low_s32(b0.val[1])), 23 vreinterpret_s16_s32(vget_high_s32(b0.val[1]))); 24 out[0] = c0.val[0]; 25 out[1] = c0.val[1]; 26 out[2] = c1.val[0]; 27 out[3] = c1.val[1]; 28 } 29 30 void av1_fwht4x4_neon(const int16_t *input, tran_low_t *output, int stride) { 31 // Load the 4x4 source in transposed form. 32 int16x4_t a1, b1, c1, d1, e; 33 a1 = vld1_s16(&input[0]); 34 b1 = vld1_s16(&input[1 * stride]); 35 c1 = vld1_s16(&input[2 * stride]); 36 d1 = vld1_s16(&input[3 * stride]); 37 38 // WHT. 39 40 // Row transforms. 41 a1 = vadd_s16(a1, b1); 42 d1 = vsub_s16(d1, c1); 43 e = vhsub_s16(a1, d1); 44 b1 = vsub_s16(e, b1); 45 c1 = vsub_s16(e, c1); 46 a1 = vsub_s16(a1, c1); 47 d1 = vadd_s16(d1, b1); 48 49 int16x8_t x[2]; 50 x[0] = vcombine_s16(a1, c1); 51 x[1] = vcombine_s16(d1, b1); 52 53 int16x4_t s[4]; 54 transpose4x4(x, s); 55 56 a1 = s[0]; 57 b1 = s[1]; 58 c1 = s[2]; 59 d1 = s[3]; 60 61 // Row transforms. 62 a1 = vadd_s16(a1, b1); 63 d1 = vsub_s16(d1, c1); 64 e = vhsub_s16(a1, d1); 65 b1 = vsub_s16(e, b1); 66 c1 = vsub_s16(e, c1); 67 a1 = vsub_s16(a1, c1); 68 d1 = vadd_s16(d1, b1); 69 70 vst1q_s32(&output[0], vshll_n_s16(a1, UNIT_QUANT_SHIFT)); 71 vst1q_s32(&output[4], vshll_n_s16(c1, UNIT_QUANT_SHIFT)); 72 vst1q_s32(&output[8], vshll_n_s16(d1, UNIT_QUANT_SHIFT)); 73 vst1q_s32(&output[12], vshll_n_s16(b1, UNIT_QUANT_SHIFT)); 74 }