Separate ssse3 functions from sse2 file. Bug: aomedia:2874 Change-Id: I2a23a3942731bc4833efa2b0ee33f1934cbbb682
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake index 11cd7e1..fa58f85 100644 --- a/aom_dsp/aom_dsp.cmake +++ b/aom_dsp/aom_dsp.cmake
@@ -89,6 +89,7 @@ list(APPEND AOM_DSP_COMMON_INTRIN_SSSE3 "${AOM_ROOT}/aom_dsp/x86/aom_subpixel_8t_intrin_ssse3.c" + "${AOM_ROOT}/aom_dsp/x86/convolve_ssse3.h" "${AOM_ROOT}/aom_dsp/x86/highbd_convolve_ssse3.c" "${AOM_ROOT}/aom_dsp/x86/intrapred_ssse3.c")
diff --git a/aom_dsp/x86/aom_subpixel_8t_intrin_ssse3.c b/aom_dsp/x86/aom_subpixel_8t_intrin_ssse3.c index 8ee0ba3..f36752a 100644 --- a/aom_dsp/x86/aom_subpixel_8t_intrin_ssse3.c +++ b/aom_dsp/x86/aom_subpixel_8t_intrin_ssse3.c
@@ -16,6 +16,7 @@ #include "aom_dsp/aom_filter.h" #include "aom_dsp/x86/convolve.h" #include "aom_dsp/x86/convolve_sse2.h" +#include "aom_dsp/x86/convolve_ssse3.h" #include "aom_dsp/x86/mem_sse2.h" #include "aom_dsp/x86/transpose_sse2.h" #include "aom_mem/aom_mem.h"
diff --git a/aom_dsp/x86/convolve_sse2.h b/aom_dsp/x86/convolve_sse2.h index ab254c0..6014895 100644 --- a/aom_dsp/x86/convolve_sse2.h +++ b/aom_dsp/x86/convolve_sse2.h
@@ -9,8 +9,6 @@ * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ -#include <tmmintrin.h> // SSSE3 - #include "av1/common/resize.h" #include "config/av1_rtcd.h" #include "config/aom_scale_rtcd.h" @@ -124,37 +122,4 @@ return res_round; } -static INLINE void shuffle_filter_ssse3(const int16_t *const filter, - __m128i *const f) { - const __m128i f_values = _mm_load_si128((const __m128i *)filter); - // pack and duplicate the filter values - f[0] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0200u)); - f[1] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0604u)); - f[2] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0a08u)); - f[3] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0e0cu)); -} - -static INLINE __m128i convolve8_8_ssse3(const __m128i *const s, - const __m128i *const f) { - // multiply 2 adjacent elements with the filter and add the result - const __m128i k_64 = _mm_set1_epi16(1 << 6); - const __m128i x0 = _mm_maddubs_epi16(s[0], f[0]); - const __m128i x1 = _mm_maddubs_epi16(s[1], f[1]); - const __m128i x2 = _mm_maddubs_epi16(s[2], f[2]); - const __m128i x3 = _mm_maddubs_epi16(s[3], f[3]); - __m128i sum1, sum2; - - // sum the results together, saturating only on the final step - // adding x0 with x2 and x1 with x3 is the only order that prevents - // outranges for all filters - sum1 = _mm_add_epi16(x0, x2); - sum2 = _mm_add_epi16(x1, x3); - // add the rounding offset early to avoid another saturated add - sum1 = _mm_add_epi16(sum1, k_64); - sum1 = _mm_adds_epi16(sum1, sum2); - // shift by 7 bit each 16 bit - sum1 = _mm_srai_epi16(sum1, 7); - return sum1; -} - #endif // AOM_AOM_DSP_X86_CONVOLVE_SSE2_H_
diff --git a/aom_dsp/x86/convolve_ssse3.h b/aom_dsp/x86/convolve_ssse3.h new file mode 100644 index 0000000..b1abead --- /dev/null +++ b/aom_dsp/x86/convolve_ssse3.h
@@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021, Alliance for Open Media. All rights reserved + * + * This source code is subject to the terms of the BSD 2 Clause License and + * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License + * was not distributed with this source code in the LICENSE file, you can + * obtain it at www.aomedia.org/license/software. If the Alliance for Open + * Media Patent License 1.0 was not distributed with this source code in the + * PATENTS file, you can obtain it at www.aomedia.org/license/patent. + */ + +#ifndef AOM_AOM_DSP_X86_CONVOLVE_SSSE3_H_ +#define AOM_AOM_DSP_X86_CONVOLVE_SSSE3_H_ + +#include <tmmintrin.h> // SSSE3 + +static INLINE void shuffle_filter_ssse3(const int16_t *const filter, + __m128i *const f) { + const __m128i f_values = _mm_load_si128((const __m128i *)filter); + // pack and duplicate the filter values + f[0] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0200u)); + f[1] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0604u)); + f[2] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0a08u)); + f[3] = _mm_shuffle_epi8(f_values, _mm_set1_epi16(0x0e0cu)); +} + +static INLINE __m128i convolve8_8_ssse3(const __m128i *const s, + const __m128i *const f) { + // multiply 2 adjacent elements with the filter and add the result + const __m128i k_64 = _mm_set1_epi16(1 << 6); + const __m128i x0 = _mm_maddubs_epi16(s[0], f[0]); + const __m128i x1 = _mm_maddubs_epi16(s[1], f[1]); + const __m128i x2 = _mm_maddubs_epi16(s[2], f[2]); + const __m128i x3 = _mm_maddubs_epi16(s[3], f[3]); + __m128i sum1, sum2; + + // sum the results together, saturating only on the final step + // adding x0 with x2 and x1 with x3 is the only order that prevents + // outranges for all filters + sum1 = _mm_add_epi16(x0, x2); + sum2 = _mm_add_epi16(x1, x3); + // add the rounding offset early to avoid another saturated add + sum1 = _mm_add_epi16(sum1, k_64); + sum1 = _mm_adds_epi16(sum1, sum2); + // shift by 7 bit each 16 bit + sum1 = _mm_srai_epi16(sum1, 7); + return sum1; +} + +#endif // AOM_AOM_DSP_X86_CONVOLVE_SSSE3_H_
diff --git a/av1/common/x86/resize_ssse3.c b/av1/common/x86/resize_ssse3.c index 0578668..6e3780f 100644 --- a/av1/common/x86/resize_ssse3.c +++ b/av1/common/x86/resize_ssse3.c
@@ -13,6 +13,7 @@ #include <tmmintrin.h> // SSSE3 #include "aom_dsp/x86/convolve_sse2.h" +#include "aom_dsp/x86/convolve_ssse3.h" #include "aom_dsp/x86/mem_sse2.h" #include "aom_dsp/x86/transpose_sse2.h" #include "av1/common/resize.h"