AVX2 optimization of motion compensation functions
AVX2 implementation of av1_jnt_convolve_x, av1_jnt_convolve_y,
av1_jnt_convolve_2d and av1_jnt_convolve_2d_copy_avx2 have been added.
Change-Id: Icc4f5aa13e29aa5e8975883ef2993b7b4845fe61
diff --git a/aom_dsp/aom_dsp.cmake b/aom_dsp/aom_dsp.cmake
index 41ba04f..9a463eb 100644
--- a/aom_dsp/aom_dsp.cmake
+++ b/aom_dsp/aom_dsp.cmake
@@ -34,6 +34,7 @@
"${AOM_ROOT}/aom_dsp/simd/v64_intrinsics_c.h"
"${AOM_ROOT}/aom_dsp/subtract.c"
"${AOM_ROOT}/aom_dsp/txfm_common.h"
+ "${AOM_ROOT}/aom_dsp/x86/convolve_common_intrin.h"
"${AOM_ROOT}/aom_dsp/x86/txfm_common_intrin.h")
set(AOM_DSP_COMMON_ASM_SSE2
diff --git a/aom_dsp/x86/convolve_avx2.h b/aom_dsp/x86/convolve_avx2.h
index 3ca424c..ba62bb2 100644
--- a/aom_dsp/x86/convolve_avx2.h
+++ b/aom_dsp/x86/convolve_avx2.h
@@ -120,15 +120,37 @@
return convolve_lowbd(s, coeffs);
}
-static INLINE void add_store_aligned(CONV_BUF_TYPE *const dst,
- const __m256i *const res,
- const __m256i *const avg_mask, int shift) {
+static INLINE void add_store_aligned_256(CONV_BUF_TYPE *const dst,
+ const __m256i *const res,
+ const int do_average) {
__m256i d;
- d = _mm256_load_si256((__m256i *)dst);
- d = _mm256_and_si256(d, *avg_mask);
- d = _mm256_add_epi32(d, *res);
- if (shift) d = _mm256_srai_epi32(d, 1);
+ if (do_average) {
+ d = _mm256_load_si256((__m256i *)dst);
+ d = _mm256_add_epi32(d, *res);
+ d = _mm256_srai_epi32(d, 1);
+ } else {
+ d = *res;
+ }
_mm256_store_si256((__m256i *)dst, d);
}
+#if CONFIG_JNT_COMP
+static INLINE void mult_add_store_aligned_256(CONV_BUF_TYPE *const dst,
+ const __m256i *const res,
+ const __m256i *const wt0,
+ const __m256i *const wt1,
+ const int do_average) {
+ __m256i d;
+ if (do_average) {
+ d = _mm256_load_si256((__m256i *)dst);
+ d = _mm256_add_epi32(_mm256_mullo_epi32(d, *wt0),
+ _mm256_mullo_epi32(*res, *wt1));
+ d = _mm256_srai_epi32(d, DIST_PRECISION_BITS);
+ } else {
+ d = *res;
+ }
+ _mm256_store_si256((__m256i *)dst, d);
+}
+#endif
+
#endif
diff --git a/aom_dsp/x86/convolve_common_intrin.h b/aom_dsp/x86/convolve_common_intrin.h
new file mode 100644
index 0000000..e80c587
--- /dev/null
+++ b/aom_dsp/x86/convolve_common_intrin.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018, 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_DSP_X86_CONVOLVE_COMMON_INTRIN_H_
+#define _AOM_DSP_X86_CONVOLVE_COMMON_INTRIN_H_
+
+// Note:
+// This header file should be put below any x86 intrinsics head file
+
+static INLINE void add_store(CONV_BUF_TYPE *const dst, const __m128i *const res,
+ const int do_average) {
+ __m128i d;
+ if (do_average) {
+ d = _mm_load_si128((__m128i *)dst);
+ d = _mm_add_epi32(d, *res);
+ d = _mm_srai_epi32(d, 1);
+ } else {
+ d = *res;
+ }
+ _mm_store_si128((__m128i *)dst, d);
+}
+
+#endif // _AOM_DSP_X86_TXFM_COMMON_INTRIN_H_
diff --git a/aom_dsp/x86/convolve_sse4_1.h b/aom_dsp/x86/convolve_sse4_1.h
new file mode 100644
index 0000000..6ec9ba3
--- /dev/null
+++ b/aom_dsp/x86/convolve_sse4_1.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018, 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_DSP_X86_CONVOLVE_SSE4_1_INTRIN_H_
+#define _AOM_DSP_X86_CONVOLVE_SSE4_1_INTRIN_H_
+
+// Note:
+// This header file should be put below any x86 intrinsics head file
+
+static INLINE void mult_add_store(CONV_BUF_TYPE *const dst,
+ const __m128i *const res,
+ const __m128i *const wt0,
+ const __m128i *const wt1,
+ const int do_average) {
+ __m128i d;
+ if (do_average) {
+ d = _mm_load_si128((__m128i *)dst);
+ d = _mm_add_epi32(_mm_mullo_epi32(d, *wt0), _mm_mullo_epi32(*res, *wt1));
+ d = _mm_srai_epi32(d, DIST_PRECISION_BITS);
+ } else {
+ d = *res;
+ }
+ _mm_store_si128((__m128i *)dst, d);
+}
+
+#endif // _AOM_DSP_X86_TXFM_COMMON_INTRIN_H_
diff --git a/av1/av1.cmake b/av1/av1.cmake
index b170968..efbe26a 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -276,6 +276,10 @@
set(AOM_AV1_COMMON_INTRIN_SSE4_1
${AOM_AV1_COMMON_INTRIN_SSE4_1}
"${AOM_ROOT}/av1/common/x86/jnt_convolve_sse4.c")
+
+ set(AOM_AV1_COMMON_INTRIN_AVX2
+ ${AOM_AV1_COMMON_INTRIN_AVX2}
+ "${AOM_ROOT}/av1/common/x86/jnt_convolve_avx2.c")
endif ()
set(AOM_AV1_COMMON_INTRIN_SSE4_1
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 508f1e4..aa8dc47 100755
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -489,16 +489,16 @@
if (aom_config("CONFIG_JNT_COMP") eq "yes") {
add_proto qw/void av1_jnt_convolve_2d/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params";
- specialize qw/av1_jnt_convolve_2d sse4_1/;
+ specialize qw/av1_jnt_convolve_2d sse4_1 avx2/;
add_proto qw/void av1_jnt_convolve_2d_copy/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params";
- specialize qw/av1_jnt_convolve_2d_copy sse2/;
+ specialize qw/av1_jnt_convolve_2d_copy sse2 avx2/;
add_proto qw/void av1_jnt_convolve_x/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params";
- specialize qw/av1_jnt_convolve_x sse4_1/;
+ specialize qw/av1_jnt_convolve_x sse4_1 avx2/;
add_proto qw/void av1_jnt_convolve_y/, "const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params";
- specialize qw/av1_jnt_convolve_y sse4_1/;
+ specialize qw/av1_jnt_convolve_y sse4_1 avx2/;
}
add_proto qw/void av1_highbd_convolve_2d/, "const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w, int h, InterpFilterParams *filter_params_x, InterpFilterParams *filter_params_y, const int subpel_x_q4, const int subpel_y_q4, ConvolveParams *conv_params, int bd";
diff --git a/av1/common/x86/convolve_2d_avx2.c b/av1/common/x86/convolve_2d_avx2.c
index 6407c3a..854a18b 100644
--- a/av1/common/x86/convolve_2d_avx2.c
+++ b/av1/common/x86/convolve_2d_avx2.c
@@ -15,6 +15,7 @@
#include "./av1_rtcd.h"
#include "aom_dsp/aom_convolve.h"
#include "aom_dsp/x86/convolve_avx2.h"
+#include "aom_dsp/x86/convolve_common_intrin.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
#include "aom_dsp/x86/synonyms.h"
@@ -39,7 +40,7 @@
const int fo_vert = filter_params_y->taps / 2 - 1;
const int fo_horiz = filter_params_x->taps / 2 - 1;
const uint8_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
- const __m256i avg_mask = _mm256_set1_epi32(conv_params->do_average ? -1 : 0);
+ const int do_average = conv_params->do_average;
__m256i filt[4], s[8], coeffs_x[4], coeffs_y[4];
@@ -126,27 +127,15 @@
const __m256i res_bx =
_mm256_permute2x128_si256(res_a_round, res_b_round, 0x31);
- add_store_aligned(&dst[i * dst_stride + j], &res_ax, &avg_mask,
- conv_params->do_average);
- add_store_aligned(&dst[i * dst_stride + j + dst_stride], &res_bx,
- &avg_mask, conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_ax, do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride], &res_bx,
+ do_average);
} else {
const __m128i res_ax = _mm256_extracti128_si256(res_a_round, 0);
const __m128i res_bx = _mm256_extracti128_si256(res_a_round, 1);
- __m128i r0 = _mm_load_si128((__m128i *)&dst[i * dst_stride + j]);
- __m128i r1 =
- _mm_load_si128((__m128i *)&dst[i * dst_stride + j + dst_stride]);
- r0 = _mm_and_si128(r0, _mm256_extracti128_si256(avg_mask, 0));
- r1 = _mm_and_si128(r1, _mm256_extracti128_si256(avg_mask, 0));
- r0 = _mm_add_epi32(r0, res_ax);
- r1 = _mm_add_epi32(r1, res_bx);
- if (conv_params->do_average) {
- r0 = _mm_srai_epi32(r0, 1);
- r1 = _mm_srai_epi32(r1, 1);
- }
- _mm_store_si128((__m128i *)&dst[i * dst_stride + j], r0);
- _mm_store_si128((__m128i *)&dst[i * dst_stride + j + dst_stride], r1);
+ add_store(&dst[i * dst_stride + j], &res_ax, do_average);
+ add_store(&dst[i * dst_stride + j + dst_stride], &res_bx, do_average);
}
s[0] = s[1];
diff --git a/av1/common/x86/convolve_avx2.c b/av1/common/x86/convolve_avx2.c
index ffc870b..56046c7 100644
--- a/av1/common/x86/convolve_avx2.c
+++ b/av1/common/x86/convolve_avx2.c
@@ -355,8 +355,7 @@
const __m256i round_const =
_mm256_set1_epi32((1 << conv_params->round_1) >> 1);
const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
-
- const __m256i avg_mask = _mm256_set1_epi32(conv_params->do_average ? -1 : 0);
+ const int do_average = conv_params->do_average;
__m256i coeffs[4], s[8];
assert((FILTER_BITS - conv_params->round_0) >= 0);
@@ -452,8 +451,8 @@
_mm256_add_epi32(res_lo_0_shift, round_const), round_shift);
// Accumulate values into the destination buffer
- add_store_aligned(&dst[i * dst_stride + j], &res_lo_0_round, &avg_mask,
- conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_0_round,
+ do_average);
const __m256i res_lo_1_32b =
_mm256_cvtepi16_epi32(_mm256_extracti128_si256(res_lo, 1));
@@ -462,8 +461,8 @@
const __m256i res_lo_1_round = _mm256_sra_epi32(
_mm256_add_epi32(res_lo_1_shift, round_const), round_shift);
- add_store_aligned(&dst[i * dst_stride + j + dst_stride], &res_lo_1_round,
- &avg_mask, conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_lo_1_round, do_average);
if (w - j > 8) {
const __m256i res_hi = convolve_lowbd(s + 4, coeffs);
@@ -475,8 +474,8 @@
const __m256i res_hi_0_round = _mm256_sra_epi32(
_mm256_add_epi32(res_hi_0_shift, round_const), round_shift);
- add_store_aligned(&dst[i * dst_stride + j + 8], &res_hi_0_round,
- &avg_mask, conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + 8], &res_hi_0_round,
+ do_average);
const __m256i res_hi_1_32b =
_mm256_cvtepi16_epi32(_mm256_extracti128_si256(res_hi, 1));
@@ -485,8 +484,8 @@
const __m256i res_hi_1_round = _mm256_sra_epi32(
_mm256_add_epi32(res_hi_1_shift, round_const), round_shift);
- add_store_aligned(&dst[i * dst_stride + j + 8 + dst_stride],
- &res_hi_1_round, &avg_mask, conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + 8 + dst_stride],
+ &res_hi_1_round, do_average);
}
s[0] = s[1];
s[1] = s[2];
@@ -668,8 +667,7 @@
const int fo_horiz = filter_params_x->taps / 2 - 1;
const uint8_t *const src_ptr = src - fo_horiz;
const int bits = FILTER_BITS - conv_params->round_1;
- const __m256i avg_mask = _mm256_set1_epi32(conv_params->do_average ? -1 : 0);
-
+ const int do_average = conv_params->do_average;
__m256i filt[4], coeffs[4];
assert(bits >= 0);
@@ -712,11 +710,11 @@
const __m256i res_hi_shift = _mm256_slli_epi32(res_hi_round, bits);
// Accumulate values into the destination buffer
- add_store_aligned(&dst[i * dst_stride + j], &res_lo_shift, &avg_mask,
- conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_shift,
+ do_average);
if (w - j > 8) {
- add_store_aligned(&dst[i * dst_stride + j + 8], &res_hi_shift,
- &avg_mask, conv_params->do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + 8], &res_hi_shift,
+ do_average);
}
}
}
diff --git a/av1/common/x86/convolve_sse2.c b/av1/common/x86/convolve_sse2.c
index a03f0ef..fac06c7 100644
--- a/av1/common/x86/convolve_sse2.c
+++ b/av1/common/x86/convolve_sse2.c
@@ -15,6 +15,7 @@
#include "aom_dsp/aom_convolve.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
+#include "aom_dsp/x86/convolve_common_intrin.h"
#include "av1/common/convolve.h"
static INLINE void prepare_coeffs(const InterpFilterParams *const filter_params,
@@ -74,16 +75,6 @@
return convolve(ss, coeffs);
}
-static INLINE void add_store(CONV_BUF_TYPE *const dst, const __m128i *const res,
- const __m128i *const avg_mask, int shift) {
- __m128i d;
- d = _mm_load_si128((__m128i *)dst);
- d = _mm_and_si128(d, *avg_mask);
- d = _mm_add_epi32(d, *res);
- if (shift) d = _mm_srai_epi32(d, 1);
- _mm_store_si128((__m128i *)dst, d);
-}
-
void av1_convolve_y_sse2(const uint8_t *src, int src_stride,
const uint8_t *dst0, int dst_stride0, int w, int h,
InterpFilterParams *filter_params_x,
@@ -98,7 +89,6 @@
const __m128i left_shift = _mm_cvtsi32_si128(bits);
const __m128i round_const = _mm_set1_epi32((1 << conv_params->round_1) >> 1);
const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
- const __m128i avg_mask = _mm_set1_epi32(conv_params->do_average ? -1 : 0);
__m128i coeffs[4];
(void)filter_params_x;
@@ -142,7 +132,7 @@
res_shift = _mm_sll_epi32(res, left_shift);
res_shift =
_mm_sra_epi32(_mm_add_epi32(res_shift, round_const), round_shift);
- add_store(dst, &res_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
@@ -150,7 +140,7 @@
res_shift = _mm_sll_epi32(res, left_shift);
res_shift =
_mm_sra_epi32(_mm_add_epi32(res_shift, round_const), round_shift);
- add_store(dst, &res_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
@@ -205,9 +195,9 @@
round_shift);
res_hi_shift = _mm_sra_epi32(_mm_add_epi32(res_hi_shift, round_const),
round_shift);
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
i++;
@@ -219,9 +209,9 @@
round_shift);
res_hi_shift = _mm_sra_epi32(_mm_add_epi32(res_hi_shift, round_const),
round_shift);
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
i++;
@@ -249,7 +239,6 @@
const uint8_t *src_ptr = src - fo_horiz;
const int bits = FILTER_BITS - conv_params->round_1;
const __m128i left_shift = _mm_cvtsi32_si128(bits);
- const __m128i avg_mask = _mm_set1_epi32(conv_params->do_average ? -1 : 0);
const __m128i round_const = _mm_set1_epi32((1 << conv_params->round_0) >> 1);
const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
__m128i coeffs[4];
@@ -281,7 +270,7 @@
const __m128i res_lo_shift = _mm_sll_epi32(res_lo_round, left_shift);
// Accumulate values into the destination buffer
- add_store(dst, &res_lo_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_lo_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
} while (--h);
@@ -320,9 +309,9 @@
const __m128i res_hi_shift = _mm_sll_epi32(res_hi_round, left_shift);
// Accumulate values into the destination buffer
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
j += 8;
} while (j < w);
diff --git a/av1/common/x86/jnt_convolve_avx2.c b/av1/common/x86/jnt_convolve_avx2.c
new file mode 100644
index 0000000..cf63faa
--- /dev/null
+++ b/av1/common/x86/jnt_convolve_avx2.c
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+#include <immintrin.h>
+
+#include "./aom_dsp_rtcd.h"
+#include "aom_dsp/aom_convolve.h"
+#include "aom_dsp/x86/convolve_avx2.h"
+#include "aom_dsp/x86/convolve_common_intrin.h"
+#include "aom_dsp/x86/convolve_sse4_1.h"
+#include "aom_dsp/aom_dsp_common.h"
+#include "aom_dsp/aom_filter.h"
+#include "av1/common/convolve.h"
+
+#if CONFIG_JNT_COMP
+void av1_jnt_convolve_x_avx2(const uint8_t *src, int src_stride,
+ const uint8_t *dst0, int dst_stride0, int w, int h,
+ InterpFilterParams *filter_params_x,
+ InterpFilterParams *filter_params_y,
+ const int subpel_x_q4, const int subpel_y_q4,
+ ConvolveParams *conv_params) {
+ CONV_BUF_TYPE *dst = conv_params->dst;
+ int dst_stride = conv_params->dst_stride;
+ int i, j;
+ const int fo_horiz = filter_params_x->taps / 2 - 1;
+ const uint8_t *const src_ptr = src - fo_horiz;
+ const int bits = FILTER_BITS - conv_params->round_1;
+ const int w0 = conv_params->fwd_offset;
+ const int w1 = conv_params->bck_offset;
+ const __m256i wt0 = _mm256_set1_epi32(w0);
+ const __m256i wt1 = _mm256_set1_epi32(w1);
+ const int do_average = conv_params->do_average;
+ __m256i filt[4], coeffs[4];
+
+ assert(bits >= 0);
+ assert(conv_params->round_0 > 0);
+
+ filt[0] = _mm256_load_si256((__m256i const *)filt1_global_avx2);
+ filt[1] = _mm256_load_si256((__m256i const *)filt2_global_avx2);
+ filt[2] = _mm256_load_si256((__m256i const *)filt3_global_avx2);
+ filt[3] = _mm256_load_si256((__m256i const *)filt4_global_avx2);
+
+ prepare_coeffs_lowbd(filter_params_x, subpel_x_q4, coeffs);
+
+ const __m256i round_const =
+ _mm256_set1_epi16((1 << (conv_params->round_0 - 1)) >> 1);
+ const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0 - 1);
+
+ (void)filter_params_y;
+ (void)subpel_y_q4;
+ (void)dst0;
+ (void)dst_stride0;
+
+ for (i = 0; i < h; i += 2) {
+ for (j = 0; j < w; j += 8) {
+ const __m256i data = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(&src_ptr[i * src_stride + j]))),
+ _mm256_castsi128_si256(_mm_loadu_si128(
+ (__m128i *)(&src_ptr[i * src_stride + j + src_stride]))),
+ 0x20);
+
+ __m256i res = convolve_lowbd_x(data, coeffs, filt);
+
+ res = _mm256_sra_epi16(_mm256_add_epi16(res, round_const), round_shift);
+
+ const __m256i res_lo_round =
+ _mm256_cvtepi16_epi32(_mm256_castsi256_si128(res));
+ const __m256i res_hi_round =
+ _mm256_cvtepi16_epi32(_mm256_extracti128_si256(res, 1));
+
+ const __m256i res_lo_shift = _mm256_slli_epi32(res_lo_round, bits);
+ const __m256i res_hi_shift = _mm256_slli_epi32(res_hi_round, bits);
+
+ // Accumulate values into the destination buffer
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_shift,
+ &wt0, &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_hi_shift, &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_shift,
+ do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_hi_shift, do_average);
+ }
+ }
+ }
+}
+
+void av1_jnt_convolve_y_avx2(const uint8_t *src, int src_stride,
+ const uint8_t *dst0, int dst_stride0, int w, int h,
+ InterpFilterParams *filter_params_x,
+ InterpFilterParams *filter_params_y,
+ const int subpel_x_q4, const int subpel_y_q4,
+ ConvolveParams *conv_params) {
+ CONV_BUF_TYPE *dst = conv_params->dst;
+ int dst_stride = conv_params->dst_stride;
+ int i, j;
+ const int fo_vert = filter_params_y->taps / 2 - 1;
+ const uint8_t *const src_ptr = src - fo_vert * src_stride;
+ // +1 to compensate for dividing the filter coeffs by 2
+ const int left_shift = FILTER_BITS - conv_params->round_0 + 1;
+ const __m256i round_const =
+ _mm256_set1_epi32((1 << conv_params->round_1) >> 1);
+ const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_1);
+ const int w0 = conv_params->fwd_offset;
+ const int w1 = conv_params->bck_offset;
+ const __m256i wt0 = _mm256_set1_epi32(w0);
+ const __m256i wt1 = _mm256_set1_epi32(w1);
+ const int do_average = conv_params->do_average;
+ __m256i coeffs[4], s[8];
+
+ assert((FILTER_BITS - conv_params->round_0) >= 0);
+
+ prepare_coeffs_lowbd(filter_params_y, subpel_y_q4, coeffs);
+
+ (void)conv_params;
+ (void)filter_params_x;
+ (void)subpel_x_q4;
+ (void)dst0;
+ (void)dst_stride0;
+
+ for (j = 0; j < w; j += 16) {
+ const uint8_t *data = &src_ptr[j];
+ __m256i src6;
+
+ // Load lines a and b. Line a to lower 128, line b to upper 128
+ const __m256i src_01a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 0 * src_stride))),
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 1 * src_stride))),
+ 0x20);
+
+ const __m256i src_12a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 1 * src_stride))),
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 2 * src_stride))),
+ 0x20);
+
+ const __m256i src_23a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 2 * src_stride))),
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 3 * src_stride))),
+ 0x20);
+
+ const __m256i src_34a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 3 * src_stride))),
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 4 * src_stride))),
+ 0x20);
+
+ const __m256i src_45a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 4 * src_stride))),
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 5 * src_stride))),
+ 0x20);
+
+ src6 = _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 6 * src_stride)));
+ const __m256i src_56a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 5 * src_stride))),
+ src6, 0x20);
+
+ s[0] = _mm256_unpacklo_epi8(src_01a, src_12a);
+ s[1] = _mm256_unpacklo_epi8(src_23a, src_34a);
+ s[2] = _mm256_unpacklo_epi8(src_45a, src_56a);
+
+ s[4] = _mm256_unpackhi_epi8(src_01a, src_12a);
+ s[5] = _mm256_unpackhi_epi8(src_23a, src_34a);
+ s[6] = _mm256_unpackhi_epi8(src_45a, src_56a);
+
+ for (i = 0; i < h; i += 2) {
+ data = &src_ptr[i * src_stride + j];
+ const __m256i src_67a = _mm256_permute2x128_si256(
+ src6,
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 7 * src_stride))),
+ 0x20);
+
+ src6 = _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 8 * src_stride)));
+ const __m256i src_78a = _mm256_permute2x128_si256(
+ _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)(data + 7 * src_stride))),
+ src6, 0x20);
+
+ s[3] = _mm256_unpacklo_epi8(src_67a, src_78a);
+ s[7] = _mm256_unpackhi_epi8(src_67a, src_78a);
+
+ const __m256i res_lo = convolve_lowbd(s, coeffs);
+
+ const __m256i res_lo_0_32b =
+ _mm256_cvtepi16_epi32(_mm256_castsi256_si128(res_lo));
+ const __m256i res_lo_0_shift =
+ _mm256_slli_epi32(res_lo_0_32b, left_shift);
+ const __m256i res_lo_0_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_lo_0_shift, round_const), round_shift);
+
+ const __m256i res_lo_1_32b =
+ _mm256_cvtepi16_epi32(_mm256_extracti128_si256(res_lo, 1));
+ const __m256i res_lo_1_shift =
+ _mm256_slli_epi32(res_lo_1_32b, left_shift);
+ const __m256i res_lo_1_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_lo_1_shift, round_const), round_shift);
+
+ // Accumulate values into the destination buffer
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_0_round,
+ &wt0, &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_lo_1_round, &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo_0_round,
+ do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_lo_1_round, do_average);
+ }
+
+ if (w - j > 8) {
+ const __m256i res_hi = convolve_lowbd(s + 4, coeffs);
+
+ const __m256i res_hi_0_32b =
+ _mm256_cvtepi16_epi32(_mm256_castsi256_si128(res_hi));
+ const __m256i res_hi_0_shift =
+ _mm256_slli_epi32(res_hi_0_32b, left_shift);
+ const __m256i res_hi_0_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_hi_0_shift, round_const), round_shift);
+
+ const __m256i res_hi_1_32b =
+ _mm256_cvtepi16_epi32(_mm256_extracti128_si256(res_hi, 1));
+ const __m256i res_hi_1_shift =
+ _mm256_slli_epi32(res_hi_1_32b, left_shift);
+ const __m256i res_hi_1_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_hi_1_shift, round_const), round_shift);
+
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + 8],
+ &res_hi_0_round, &wt0, &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + 8 + dst_stride],
+ &res_hi_1_round, &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j + 8], &res_hi_0_round,
+ do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + 8 + dst_stride],
+ &res_hi_1_round, do_average);
+ }
+ }
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+
+ s[4] = s[5];
+ s[5] = s[6];
+ s[6] = s[7];
+ }
+ }
+}
+
+void av1_jnt_convolve_2d_avx2(const uint8_t *src, int src_stride, uint8_t *dst0,
+ int dst_stride0, int w, int h,
+ InterpFilterParams *filter_params_x,
+ InterpFilterParams *filter_params_y,
+ const int subpel_x_q4, const int subpel_y_q4,
+ ConvolveParams *conv_params) {
+ CONV_BUF_TYPE *dst = conv_params->dst;
+ int dst_stride = conv_params->dst_stride;
+ const int bd = 8;
+ (void)dst0;
+ (void)dst_stride0;
+
+ DECLARE_ALIGNED(32, int16_t, im_block[(MAX_SB_SIZE + MAX_FILTER_TAP) * 8]);
+ int im_h = h + filter_params_y->taps - 1;
+ int im_stride = 8;
+ int i, j;
+ const int fo_vert = filter_params_y->taps / 2 - 1;
+ const int fo_horiz = filter_params_x->taps / 2 - 1;
+ const uint8_t *const src_ptr = src - fo_vert * src_stride - fo_horiz;
+ const int w0 = conv_params->fwd_offset;
+ const int w1 = conv_params->bck_offset;
+ const __m256i wt0 = _mm256_set1_epi32(w0);
+ const __m256i wt1 = _mm256_set1_epi32(w1);
+ const int do_average = conv_params->do_average;
+ const __m128i wt0_128 = _mm256_castsi256_si128(wt0);
+ const __m128i wt1_128 = _mm256_castsi256_si128(wt1);
+ __m256i filt[4], s[8], coeffs_x[4], coeffs_y[4];
+
+ assert(conv_params->round_0 > 0);
+
+ filt[0] = _mm256_load_si256((__m256i const *)filt1_global_avx2);
+ filt[1] = _mm256_load_si256((__m256i const *)filt2_global_avx2);
+ filt[2] = _mm256_load_si256((__m256i const *)filt3_global_avx2);
+ filt[3] = _mm256_load_si256((__m256i const *)filt4_global_avx2);
+
+ prepare_coeffs_lowbd(filter_params_x, subpel_x_q4, coeffs_x);
+ prepare_coeffs(filter_params_y, subpel_y_q4, coeffs_y);
+
+ const __m256i round_const_h = _mm256_set1_epi16(
+ ((1 << (conv_params->round_0 - 1)) >> 1) + (1 << (bd + FILTER_BITS - 2)));
+ const __m128i round_shift_h = _mm_cvtsi32_si128(conv_params->round_0 - 1);
+
+ const __m256i round_const_v = _mm256_set1_epi32(
+ ((1 << conv_params->round_1) >> 1) -
+ (1 << (bd + 2 * FILTER_BITS - conv_params->round_0 - 1)));
+ const __m128i round_shift_v = _mm_cvtsi32_si128(conv_params->round_1);
+
+ for (j = 0; j < w; j += 8) {
+ /* Horizontal filter */
+ {
+ for (i = 0; i < im_h; i += 2) {
+ __m256i data = _mm256_castsi128_si256(
+ _mm_loadu_si128((__m128i *)&src_ptr[(i * src_stride) + j]));
+ if (i + 1 < im_h)
+ data = _mm256_inserti128_si256(
+ data,
+ _mm_loadu_si128(
+ (__m128i *)&src_ptr[(i * src_stride) + j + src_stride]),
+ 1);
+ __m256i res = convolve_lowbd_x(data, coeffs_x, filt);
+
+ res = _mm256_sra_epi16(_mm256_add_epi16(res, round_const_h),
+ round_shift_h);
+
+ _mm256_store_si256((__m256i *)&im_block[i * im_stride], res);
+ }
+ }
+
+ /* Vertical filter */
+ {
+ __m256i s0 = _mm256_loadu_si256((__m256i *)(im_block + 0 * im_stride));
+ __m256i s1 = _mm256_loadu_si256((__m256i *)(im_block + 1 * im_stride));
+ __m256i s2 = _mm256_loadu_si256((__m256i *)(im_block + 2 * im_stride));
+ __m256i s3 = _mm256_loadu_si256((__m256i *)(im_block + 3 * im_stride));
+ __m256i s4 = _mm256_loadu_si256((__m256i *)(im_block + 4 * im_stride));
+ __m256i s5 = _mm256_loadu_si256((__m256i *)(im_block + 5 * im_stride));
+
+ s[0] = _mm256_unpacklo_epi16(s0, s1);
+ s[1] = _mm256_unpacklo_epi16(s2, s3);
+ s[2] = _mm256_unpacklo_epi16(s4, s5);
+
+ s[4] = _mm256_unpackhi_epi16(s0, s1);
+ s[5] = _mm256_unpackhi_epi16(s2, s3);
+ s[6] = _mm256_unpackhi_epi16(s4, s5);
+
+ for (i = 0; i < h; i += 2) {
+ const int16_t *data = &im_block[i * im_stride];
+
+ const __m256i s6 =
+ _mm256_loadu_si256((__m256i *)(data + 6 * im_stride));
+ const __m256i s7 =
+ _mm256_loadu_si256((__m256i *)(data + 7 * im_stride));
+
+ s[3] = _mm256_unpacklo_epi16(s6, s7);
+ s[7] = _mm256_unpackhi_epi16(s6, s7);
+
+ const __m256i res_a = convolve(s, coeffs_y);
+ const __m256i res_a_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_a, round_const_v), round_shift_v);
+
+ if (w - j > 4) {
+ const __m256i res_b = convolve(s + 4, coeffs_y);
+ const __m256i res_b_round = _mm256_sra_epi32(
+ _mm256_add_epi32(res_b, round_const_v), round_shift_v);
+ const __m256i res_ax =
+ _mm256_permute2x128_si256(res_a_round, res_b_round, 0x20);
+ const __m256i res_bx =
+ _mm256_permute2x128_si256(res_a_round, res_b_round, 0x31);
+
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j], &res_ax, &wt0,
+ &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_bx, &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_ax,
+ do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_bx, do_average);
+ }
+ } else {
+ const __m128i res_ax = _mm256_castsi256_si128(res_a_round);
+ const __m128i res_bx = _mm256_extracti128_si256(res_a_round, 1);
+
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store(&dst[i * dst_stride + j], &res_ax, &wt0_128,
+ &wt1_128, do_average);
+ mult_add_store(&dst[i * dst_stride + j + dst_stride], &res_bx,
+ &wt0_128, &wt1_128, do_average);
+ } else {
+ add_store(&dst[i * dst_stride + j], &res_ax, do_average);
+ add_store(&dst[i * dst_stride + j + dst_stride], &res_bx,
+ do_average);
+ }
+ }
+
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+
+ s[4] = s[5];
+ s[5] = s[6];
+ s[6] = s[7];
+ }
+ }
+ }
+}
+
+void av1_jnt_convolve_2d_copy_avx2(const uint8_t *src, int src_stride,
+ uint8_t *dst0, int dst_stride0, int w, int h,
+ InterpFilterParams *filter_params_x,
+ InterpFilterParams *filter_params_y,
+ const int subpel_x_q4, const int subpel_y_q4,
+ ConvolveParams *conv_params) {
+ CONV_BUF_TYPE *dst = conv_params->dst;
+ int dst_stride = conv_params->dst_stride;
+ (void)filter_params_x;
+ (void)filter_params_y;
+ (void)subpel_x_q4;
+ (void)subpel_y_q4;
+ (void)dst0;
+ (void)dst_stride0;
+
+ const int bits =
+ FILTER_BITS * 2 - conv_params->round_1 - conv_params->round_0;
+ const __m128i left_shift = _mm_cvtsi32_si128(bits);
+ const int do_average = conv_params->do_average;
+ const int w0 = conv_params->fwd_offset;
+ const int w1 = conv_params->bck_offset;
+ const __m256i wt0 = _mm256_set1_epi32(w0);
+ const __m256i wt1 = _mm256_set1_epi32(w1);
+ const __m256i zero = _mm256_setzero_si256();
+ int i, j;
+
+ if (!(w % 16)) {
+ for (i = 0; i < h; i += 1) {
+ for (j = 0; j < w; j += 16) {
+ const __m256i src_16bit = _mm256_cvtepu8_epi16(
+ _mm_loadu_si128((__m128i *)(&src[i * src_stride + j])));
+
+ const __m256i res = _mm256_sll_epi16(src_16bit, left_shift);
+ const __m256i res_lo =
+ _mm256_cvtepu16_epi32(_mm256_castsi256_si128(res));
+ const __m256i res_hi =
+ _mm256_cvtepu16_epi32(_mm256_extracti128_si256(res, 1));
+
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j], &res_lo, &wt0,
+ &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + 8], &res_hi,
+ &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo, do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + 8], &res_hi,
+ do_average);
+ }
+ }
+ }
+ } else if (!(w % 4)) {
+ for (i = 0; i < h; i += 2) {
+ for (j = 0; j < w; j += 8) {
+ const __m128i src_row_0 =
+ _mm_loadl_epi64((__m128i *)(&src[i * src_stride + j]));
+ const __m128i src_row_1 =
+ _mm_loadl_epi64((__m128i *)(&src[i * src_stride + j + src_stride]));
+ // since not all compilers yet support _mm256_set_m128i()
+ const __m256i src_10 = _mm256_insertf128_si256(
+ _mm256_castsi128_si256(src_row_0), src_row_1, 1);
+
+ const __m256i src_16bit = _mm256_unpacklo_epi8(src_10, zero);
+
+ const __m256i res = _mm256_sll_epi16(src_16bit, left_shift);
+
+ const __m256i res_lo =
+ _mm256_cvtepu16_epi32(_mm256_castsi256_si128(res));
+ const __m256i res_hi =
+ _mm256_cvtepu16_epi32(_mm256_extracti128_si256(res, 1));
+
+ if (conv_params->use_jnt_comp_avg) {
+ mult_add_store_aligned_256(&dst[i * dst_stride + j], &res_lo, &wt0,
+ &wt1, do_average);
+ mult_add_store_aligned_256(&dst[i * dst_stride + j + dst_stride],
+ &res_hi, &wt0, &wt1, do_average);
+ } else {
+ add_store_aligned_256(&dst[i * dst_stride + j], &res_lo, do_average);
+ add_store_aligned_256(&dst[i * dst_stride + j + dst_stride], &res_hi,
+ do_average);
+ }
+ }
+ }
+ }
+}
+#endif
diff --git a/av1/common/x86/jnt_convolve_sse4.c b/av1/common/x86/jnt_convolve_sse4.c
index 54bef5a..85976a2 100644
--- a/av1/common/x86/jnt_convolve_sse4.c
+++ b/av1/common/x86/jnt_convolve_sse4.c
@@ -16,6 +16,8 @@
#include "aom_dsp/aom_convolve.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
+#include "aom_dsp/x86/convolve_common_intrin.h"
+#include "aom_dsp/x86/convolve_sse4_1.h"
#include "av1/common/convolve.h"
static INLINE void prepare_coeffs(const InterpFilterParams *const filter_params,
@@ -75,32 +77,7 @@
return convolve(ss, coeffs);
}
-static INLINE void add_store(CONV_BUF_TYPE *const dst, const __m128i *const res,
- const __m128i *const avg_mask, int shift) {
- __m128i d;
- d = _mm_load_si128((__m128i *)dst);
- d = _mm_and_si128(d, *avg_mask);
- d = _mm_add_epi32(d, *res);
- if (shift) d = _mm_srai_epi32(d, 1);
- _mm_store_si128((__m128i *)dst, d);
-}
-
#if CONFIG_JNT_COMP
-static INLINE void mult_add_store(CONV_BUF_TYPE *const dst,
- const __m128i *const res,
- const __m128i *const wt0,
- const __m128i *const wt1, int do_average) {
- __m128i d;
- if (do_average) {
- d = _mm_load_si128((__m128i *)dst);
- d = _mm_add_epi32(_mm_mullo_epi32(d, *wt0), _mm_mullo_epi32(*res, *wt1));
- d = _mm_srai_epi32(d, DIST_PRECISION_BITS);
- } else {
- d = *res;
- }
- _mm_store_si128((__m128i *)dst, d);
-}
-
void av1_jnt_convolve_y_sse4_1(const uint8_t *src, int src_stride,
const uint8_t *dst0, int dst_stride0, int w,
int h, InterpFilterParams *filter_params_x,
@@ -113,7 +90,6 @@
const uint8_t *src_ptr = src - fo_vert * src_stride;
const int bits = FILTER_BITS - conv_params->round_0;
const __m128i left_shift = _mm_cvtsi32_si128(bits);
- const __m128i avg_mask = _mm_set1_epi32(conv_params->do_average ? -1 : 0);
const __m128i wt0 = _mm_set1_epi32(conv_params->fwd_offset);
const __m128i wt1 = _mm_set1_epi32(conv_params->bck_offset);
const __m128i round_const = _mm_set1_epi32((1 << conv_params->round_1) >> 1);
@@ -162,7 +138,7 @@
if (conv_params->use_jnt_comp_avg)
mult_add_store(dst, &res_shift, &wt0, &wt1, conv_params->do_average);
else
- add_store(dst, &res_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
@@ -173,7 +149,7 @@
if (conv_params->use_jnt_comp_avg)
mult_add_store(dst, &res_shift, &wt0, &wt1, conv_params->do_average);
else
- add_store(dst, &res_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
@@ -234,9 +210,9 @@
mult_add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &wt0,
&wt1, conv_params->do_average);
} else {
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
}
i++;
@@ -255,9 +231,9 @@
mult_add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &wt0,
&wt1, conv_params->do_average);
} else {
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
}
i++;
@@ -286,7 +262,6 @@
const uint8_t *src_ptr = src - fo_horiz;
const int bits = FILTER_BITS - conv_params->round_1;
const __m128i left_shift = _mm_cvtsi32_si128(bits);
- const __m128i avg_mask = _mm_set1_epi32(conv_params->do_average ? -1 : 0);
const __m128i round_const = _mm_set1_epi32((1 << conv_params->round_0) >> 1);
const __m128i round_shift = _mm_cvtsi32_si128(conv_params->round_0);
const int w0 = conv_params->fwd_offset;
@@ -323,7 +298,7 @@
if (conv_params->use_jnt_comp_avg)
mult_add_store(dst, &res_lo_shift, &wt0, &wt1, conv_params->do_average);
else
- add_store(dst, &res_lo_shift, &avg_mask, conv_params->do_average);
+ add_store(dst, &res_lo_shift, conv_params->do_average);
src_ptr += src_stride;
dst += dst_stride;
} while (--h);
@@ -368,9 +343,9 @@
mult_add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &wt0,
&wt1, conv_params->do_average);
} else {
- add_store(dst + i * dst_stride + j + 0, &res_lo_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 0, &res_lo_shift,
conv_params->do_average);
- add_store(dst + i * dst_stride + j + 4, &res_hi_shift, &avg_mask,
+ add_store(dst + i * dst_stride + j + 4, &res_hi_shift,
conv_params->do_average);
}
j += 8;
diff --git a/test/av1_convolve_2d_test.cc b/test/av1_convolve_2d_test.cc
index ed59a6a..8b4cc19 100644
--- a/test/av1_convolve_2d_test.cc
+++ b/test/av1_convolve_2d_test.cc
@@ -123,13 +123,47 @@
libaom_test::AV1Convolve2D::BuildParams(
av1_jnt_convolve_2d_copy_c, 0, 0, 1));
+INSTANTIATE_TEST_CASE_P(
+ C_X, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_x_c, 1, 0, 1));
+
+INSTANTIATE_TEST_CASE_P(
+ C_Y, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_y_c, 0, 1, 1));
+
INSTANTIATE_TEST_CASE_P(SSE2_COPY, AV1JntConvolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(
av1_jnt_convolve_2d_copy_sse2, 0, 0, 1));
+INSTANTIATE_TEST_CASE_P(SSE4_1_X, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(
+ av1_jnt_convolve_x_sse4_1, 1, 0, 1));
+
+INSTANTIATE_TEST_CASE_P(SSE4_1_Y, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(
+ av1_jnt_convolve_y_sse4_1, 0, 1, 1));
+
INSTANTIATE_TEST_CASE_P(SSE4_1, AV1JntConvolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(
av1_jnt_convolve_2d_sse4_1, 1, 1, 1));
+
+#if HAVE_AVX2
+INSTANTIATE_TEST_CASE_P(AVX2_COPY, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(
+ av1_jnt_convolve_2d_copy_avx2, 0, 0, 1));
+
+INSTANTIATE_TEST_CASE_P(
+ AVX2_X, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_x_avx2, 1, 0, 1));
+
+INSTANTIATE_TEST_CASE_P(
+ AVX2_Y, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_y_avx2, 0, 1, 1));
+
+INSTANTIATE_TEST_CASE_P(
+ AVX2, AV1JntConvolve2DTest,
+ libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_2d_avx2, 1, 1, 1));
+#endif
#endif
#if HAVE_SSSE3