1 /*
2 * Copyright (c) 2018, 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_AOM_DSP_X86_CONVOLVE_SSE4_1_H_
13 #define AOM_AOM_DSP_X86_CONVOLVE_SSE4_1_H_
14
15 // Note:
16 // This header file should be put below any x86 intrinsics head file
17
mult_add_store(CONV_BUF_TYPE * const dst,const __m128i * const res,const __m128i * const wt0,const __m128i * const wt1,const int do_average)18 static INLINE void mult_add_store(CONV_BUF_TYPE *const dst,
19 const __m128i *const res,
20 const __m128i *const wt0,
21 const __m128i *const wt1,
22 const int do_average) {
23 __m128i d;
24 if (do_average) {
25 d = _mm_load_si128((__m128i *)dst);
26 d = _mm_add_epi32(_mm_mullo_epi32(d, *wt0), _mm_mullo_epi32(*res, *wt1));
27 d = _mm_srai_epi32(d, DIST_PRECISION_BITS);
28 } else {
29 d = *res;
30 }
31 _mm_store_si128((__m128i *)dst, d);
32 }
33
highbd_comp_avg_sse4_1(const __m128i * const data_ref_0,const __m128i * const res_unsigned,const __m128i * const wt0,const __m128i * const wt1,const int use_dist_wtd_avg)34 static INLINE __m128i highbd_comp_avg_sse4_1(const __m128i *const data_ref_0,
35 const __m128i *const res_unsigned,
36 const __m128i *const wt0,
37 const __m128i *const wt1,
38 const int use_dist_wtd_avg) {
39 __m128i res;
40 if (use_dist_wtd_avg) {
41 const __m128i wt0_res = _mm_mullo_epi32(*data_ref_0, *wt0);
42 const __m128i wt1_res = _mm_mullo_epi32(*res_unsigned, *wt1);
43
44 const __m128i wt_res = _mm_add_epi32(wt0_res, wt1_res);
45 res = _mm_srai_epi32(wt_res, DIST_PRECISION_BITS);
46 } else {
47 const __m128i wt_res = _mm_add_epi32(*data_ref_0, *res_unsigned);
48 res = _mm_srai_epi32(wt_res, 1);
49 }
50 return res;
51 }
52
53 #endif // AOM_AOM_DSP_X86_CONVOLVE_SSE4_1_H_
54