1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <arm_neon.h>
12
idct_dequant_0_2x_neon(int16_t * q,int16_t dq,unsigned char * dst,int stride)13 void idct_dequant_0_2x_neon(int16_t *q, int16_t dq, unsigned char *dst,
14 int stride) {
15 unsigned char *dst0;
16 int i, a0, a1;
17 int16x8x2_t q2Add;
18 int32x2_t d2s32 = vdup_n_s32(0), d4s32 = vdup_n_s32(0);
19 uint8x8_t d2u8, d4u8;
20 uint16x8_t q1u16, q2u16;
21
22 a0 = ((q[0] * dq) + 4) >> 3;
23 a1 = ((q[16] * dq) + 4) >> 3;
24 q[0] = q[16] = 0;
25 q2Add.val[0] = vdupq_n_s16((int16_t)a0);
26 q2Add.val[1] = vdupq_n_s16((int16_t)a1);
27
28 for (i = 0; i < 2; i++, dst += 4) {
29 dst0 = dst;
30 d2s32 = vld1_lane_s32((const int32_t *)dst0, d2s32, 0);
31 dst0 += stride;
32 d2s32 = vld1_lane_s32((const int32_t *)dst0, d2s32, 1);
33 dst0 += stride;
34 d4s32 = vld1_lane_s32((const int32_t *)dst0, d4s32, 0);
35 dst0 += stride;
36 d4s32 = vld1_lane_s32((const int32_t *)dst0, d4s32, 1);
37
38 q1u16 = vaddw_u8(vreinterpretq_u16_s16(q2Add.val[i]),
39 vreinterpret_u8_s32(d2s32));
40 q2u16 = vaddw_u8(vreinterpretq_u16_s16(q2Add.val[i]),
41 vreinterpret_u8_s32(d4s32));
42
43 d2u8 = vqmovun_s16(vreinterpretq_s16_u16(q1u16));
44 d4u8 = vqmovun_s16(vreinterpretq_s16_u16(q2u16));
45
46 d2s32 = vreinterpret_s32_u8(d2u8);
47 d4s32 = vreinterpret_s32_u8(d4u8);
48
49 dst0 = dst;
50 vst1_lane_s32((int32_t *)dst0, d2s32, 0);
51 dst0 += stride;
52 vst1_lane_s32((int32_t *)dst0, d2s32, 1);
53 dst0 += stride;
54 vst1_lane_s32((int32_t *)dst0, d4s32, 0);
55 dst0 += stride;
56 vst1_lane_s32((int32_t *)dst0, d4s32, 1);
57 }
58 return;
59 }
60